CVS commit: src/sys/secmodel/suser

2020-05-16 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sat May 16 19:12:38 UTC 2020

Modified Files:
src/sys/secmodel/suser: secmodel_suser.c

Log Message:
Make it clear that only KAUTH_MACHDEP_SVS_DISABLE is deprecated.


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/sys/secmodel/suser/secmodel_suser.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/secmodel/suser/secmodel_suser.c
diff -u src/sys/secmodel/suser/secmodel_suser.c:1.53 src/sys/secmodel/suser/secmodel_suser.c:1.54
--- src/sys/secmodel/suser/secmodel_suser.c:1.53	Mon May 11 19:36:40 2020
+++ src/sys/secmodel/suser/secmodel_suser.c	Sat May 16 19:12:38 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: secmodel_suser.c,v 1.53 2020/05/11 19:36:40 alnsn Exp $ */
+/* $NetBSD: secmodel_suser.c,v 1.54 2020/05/16 19:12:38 alnsn Exp $ */
 /*-
  * Copyright (c) 2006 Elad Efrat 
  * All rights reserved.
@@ -38,7 +38,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: secmodel_suser.c,v 1.53 2020/05/11 19:36:40 alnsn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: secmodel_suser.c,v 1.54 2020/05/16 19:12:38 alnsn Exp $");
 
 #include 
 #include 
@@ -846,6 +846,10 @@ secmodel_suser_machdep_cb(kauth_cred_t c
 	case KAUTH_MACHDEP_NVRAM:
 	case KAUTH_MACHDEP_UNMANAGEDMEM:
 	case KAUTH_MACHDEP_PXG:
+		if (isroot)
+			result = KAUTH_RESULT_ALLOW;
+		break;
+
 	case KAUTH_MACHDEP_SVS_DISABLE:
 		/* Deprecated. */
 		if (isroot)



CVS commit: src/sys/secmodel

2020-05-11 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Mon May 11 19:36:40 UTC 2020

Modified Files:
src/sys/secmodel/securelevel: secmodel_securelevel.c
src/sys/secmodel/suser: secmodel_suser.c

Log Message:
KAUTH_MACHDEP_SVS_DISABLE is deprecated.

sysctl machdep.svs.enabled can't be changed anymore
at runtime because it's now a boot option.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 \
src/sys/secmodel/securelevel/secmodel_securelevel.c
cvs rdiff -u -r1.52 -r1.53 src/sys/secmodel/suser/secmodel_suser.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/secmodel/securelevel/secmodel_securelevel.c
diff -u src/sys/secmodel/securelevel/secmodel_securelevel.c:1.34 src/sys/secmodel/securelevel/secmodel_securelevel.c:1.35
--- src/sys/secmodel/securelevel/secmodel_securelevel.c:1.34	Mon Mar 16 21:20:12 2020
+++ src/sys/secmodel/securelevel/secmodel_securelevel.c	Mon May 11 19:36:39 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: secmodel_securelevel.c,v 1.34 2020/03/16 21:20:12 pgoyette Exp $ */
+/* $NetBSD: secmodel_securelevel.c,v 1.35 2020/05/11 19:36:39 alnsn Exp $ */
 /*-
  * Copyright (c) 2006 Elad Efrat 
  * All rights reserved.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: secmodel_securelevel.c,v 1.34 2020/03/16 21:20:12 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: secmodel_securelevel.c,v 1.35 2020/05/11 19:36:39 alnsn Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_insecure.h"
@@ -480,6 +480,7 @@ secmodel_securelevel_machdep_cb(kauth_cr
 		break;
 
 	case KAUTH_MACHDEP_SVS_DISABLE:
+		/* Deprecated. */
 		if (securelevel > 0)
 			result = KAUTH_RESULT_DENY;
 		break;

Index: src/sys/secmodel/suser/secmodel_suser.c
diff -u src/sys/secmodel/suser/secmodel_suser.c:1.52 src/sys/secmodel/suser/secmodel_suser.c:1.53
--- src/sys/secmodel/suser/secmodel_suser.c:1.52	Mon Mar 16 21:20:12 2020
+++ src/sys/secmodel/suser/secmodel_suser.c	Mon May 11 19:36:40 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: secmodel_suser.c,v 1.52 2020/03/16 21:20:12 pgoyette Exp $ */
+/* $NetBSD: secmodel_suser.c,v 1.53 2020/05/11 19:36:40 alnsn Exp $ */
 /*-
  * Copyright (c) 2006 Elad Efrat 
  * All rights reserved.
@@ -38,7 +38,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: secmodel_suser.c,v 1.52 2020/03/16 21:20:12 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: secmodel_suser.c,v 1.53 2020/05/11 19:36:40 alnsn Exp $");
 
 #include 
 #include 
@@ -847,6 +847,7 @@ secmodel_suser_machdep_cb(kauth_cred_t c
 	case KAUTH_MACHDEP_UNMANAGEDMEM:
 	case KAUTH_MACHDEP_PXG:
 	case KAUTH_MACHDEP_SVS_DISABLE:
+		/* Deprecated. */
 		if (isroot)
 			result = KAUTH_RESULT_ALLOW;
 		break;



CVS commit: src/sys/kern

2019-04-28 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sun Apr 28 21:36:20 UTC 2019

Modified Files:
src/sys/kern: kern_veriexec.c

Log Message:
Document that veriexec_file_add() also expects keep-filename and eval-on-load.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/kern/kern_veriexec.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/kern_veriexec.c
diff -u src/sys/kern/kern_veriexec.c:1.19 src/sys/kern/kern_veriexec.c:1.20
--- src/sys/kern/kern_veriexec.c:1.19	Mon Feb  4 09:54:47 2019
+++ src/sys/kern/kern_veriexec.c	Sun Apr 28 21:36:19 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_veriexec.c,v 1.19 2019/02/04 09:54:47 mrg Exp $	*/
+/*	$NetBSD: kern_veriexec.c,v 1.20 2019/04/28 21:36:19 alnsn Exp $	*/
 
 /*-
  * Copyright (c) 2005, 2006 Elad Efrat 
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_veriexec.c,v 1.19 2019/02/04 09:54:47 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_veriexec.c,v 1.20 2019/04/28 21:36:19 alnsn Exp $");
 
 #include "opt_veriexec.h"
 
@@ -1029,7 +1029,8 @@ veriexec_table_add(struct lwp *l, struct
 /*
  * Add a file to be monitored by Veriexec.
  *
- * Expected elements in dict: file, fp, fp-type, entry-type.
+ * Expected elements in dict:
+ * file, fp, fp-type, entry-type, keep-filename, eval-on-load.
  */
 int
 veriexec_file_add(struct lwp *l, prop_dictionary_t dict)



CVS commit: src/distrib

2019-04-11 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Thu Apr 11 23:50:01 UTC 2019

Modified Files:
src/distrib/amd64/ramdisks/ramdisk-cgdroot: list
src/distrib/i386/ramdisks/ramdisk-cgdroot: list

Log Message:
Add a symlink to /altroot/stand to help the kernel find modules.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/distrib/amd64/ramdisks/ramdisk-cgdroot/list
cvs rdiff -u -r1.1 -r1.2 src/distrib/i386/ramdisks/ramdisk-cgdroot/list

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/amd64/ramdisks/ramdisk-cgdroot/list
diff -u src/distrib/amd64/ramdisks/ramdisk-cgdroot/list:1.1 src/distrib/amd64/ramdisks/ramdisk-cgdroot/list:1.2
--- src/distrib/amd64/ramdisks/ramdisk-cgdroot/list:1.1	Mon Jul 15 00:22:10 2013
+++ src/distrib/amd64/ramdisks/ramdisk-cgdroot/list	Thu Apr 11 23:50:01 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: list,v 1.1 2013/07/15 00:22:10 khorben Exp $
+#	$NetBSD: list,v 1.2 2019/04/11 23:50:01 alnsn Exp $
 
 PROG	bin/chio
 PROG	bin/dd
@@ -30,3 +30,5 @@ PROG	usr/bin/tip
 PROG	usr/sbin/installboot
 
 PROG	usr/sbin/wiconfig
+
+SYMLINK	/altroot/stand	stand

Index: src/distrib/i386/ramdisks/ramdisk-cgdroot/list
diff -u src/distrib/i386/ramdisks/ramdisk-cgdroot/list:1.1 src/distrib/i386/ramdisks/ramdisk-cgdroot/list:1.2
--- src/distrib/i386/ramdisks/ramdisk-cgdroot/list:1.1	Tue Jul 16 02:10:43 2013
+++ src/distrib/i386/ramdisks/ramdisk-cgdroot/list	Thu Apr 11 23:50:01 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: list,v 1.1 2013/07/16 02:10:43 khorben Exp $
+#	$NetBSD: list,v 1.2 2019/04/11 23:50:01 alnsn Exp $
 
 PROG	bin/chio
 PROG	bin/dd
@@ -30,3 +30,5 @@ PROG	usr/bin/tip
 PROG	usr/sbin/installboot
 
 PROG	usr/sbin/wiconfig
+
+SYMLINK	/altroot/stand	stand



CVS commit: src/sys/arch/aarch64/aarch64

2019-01-27 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sun Jan 27 19:13:04 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: netbsd32_machdep.c

Log Message:
Local variable p is __diagused.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/aarch64/aarch64/netbsd32_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/aarch64/netbsd32_machdep.c
diff -u src/sys/arch/aarch64/aarch64/netbsd32_machdep.c:1.4 src/sys/arch/aarch64/aarch64/netbsd32_machdep.c:1.5
--- src/sys/arch/aarch64/aarch64/netbsd32_machdep.c:1.4	Sun Jan 27 02:08:36 2019
+++ src/sys/arch/aarch64/aarch64/netbsd32_machdep.c	Sun Jan 27 19:13:04 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_machdep.c,v 1.4 2019/01/27 02:08:36 pgoyette Exp $	*/
+/*	$NetBSD: netbsd32_machdep.c,v 1.5 2019/01/27 19:13:04 alnsn Exp $	*/
 
 /*
  * Copyright (c) 2018 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.4 2019/01/27 02:08:36 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.5 2019/01/27 19:13:04 alnsn Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -308,7 +308,7 @@ startlwp32(void *arg)
 int
 cpu_mcontext32_validate(struct lwp *l, const mcontext32_t *mcp)
 {
-	struct proc * const p = l->l_proc;
+	struct proc * const p __diagused = l->l_proc;
 	const uint32_t spsr = mcp->__gregs[_REG_CPSR];
 
 	KASSERT(p->p_flag & PK_32);



CVS commit: src/external/bsd/flex/dist/src

2019-01-26 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sun Jan 27 03:01:48 UTC 2019

Modified Files:
src/external/bsd/flex/dist/src: libyywrap.c

Log Message:
Remove extra #endif.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/bsd/flex/dist/src/libyywrap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/flex/dist/src/libyywrap.c
diff -u src/external/bsd/flex/dist/src/libyywrap.c:1.4 src/external/bsd/flex/dist/src/libyywrap.c:1.5
--- src/external/bsd/flex/dist/src/libyywrap.c:1.4	Sun Jan 27 02:08:34 2019
+++ src/external/bsd/flex/dist/src/libyywrap.c	Sun Jan 27 03:01:48 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: libyywrap.c,v 1.4 2019/01/27 02:08:34 pgoyette Exp $	*/
+/*	$NetBSD: libyywrap.c,v 1.5 2019/01/27 03:01:48 alnsn Exp $	*/
 
 /* libyywrap - flex run-time support library "yywrap" function */
 
@@ -25,8 +25,7 @@
 #ifndef HAVE_NBTOOL_CONFIG_H
 #include 
 #ifdef __RCSID
-__RCSID("$NetBSD: libyywrap.c,v 1.4 2019/01/27 02:08:34 pgoyette Exp $");
-#endif
+__RCSID("$NetBSD: libyywrap.c,v 1.5 2019/01/27 03:01:48 alnsn Exp $");
 #endif
 #endif
 



CVS commit: src/sys/rump/kern/lib/libsljit/arch/mips

2019-01-21 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Tue Jan 22 01:25:53 UTC 2019

Modified Files:
src/sys/rump/kern/lib/libsljit/arch/mips: cache.c

Log Message:
Cast register_t to uintptr_t before casting to void *.

Not sure what's going on here but evbmips64-el build fails
without this cast.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/rump/kern/lib/libsljit/arch/mips/cache.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/rump/kern/lib/libsljit/arch/mips/cache.c
diff -u src/sys/rump/kern/lib/libsljit/arch/mips/cache.c:1.2 src/sys/rump/kern/lib/libsljit/arch/mips/cache.c:1.3
--- src/sys/rump/kern/lib/libsljit/arch/mips/cache.c:1.2	Tue Jan 22 00:36:02 2019
+++ src/sys/rump/kern/lib/libsljit/arch/mips/cache.c	Tue Jan 22 01:25:53 2019
@@ -1,4 +1,4 @@
-/*  $NetBSD: cache.c,v 1.2 2019/01/22 00:36:02 alnsn Exp $	*/
+/*  $NetBSD: cache.c,v 1.3 2019/01/22 01:25:53 alnsn Exp $	*/
 
 /*-
  * Copyright (c) 2014 Alexander Nasonov.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cache.c,v 1.2 2019/01/22 00:36:02 alnsn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cache.c,v 1.3 2019/01/22 01:25:53 alnsn Exp $");
 
 /*
  * Barebone implementation of mips cache routines for rump.
@@ -48,5 +48,5 @@ static void
 icache_sync_range(register_t va, vsize_t sz)
 {
 
-	(void)rumpcomp_sync_icache((void *)va, (uint64_t)sz);
+	(void)rumpcomp_sync_icache((void *)(uintptr_t)va, (uint64_t)sz);
 }



CVS commit: src/sys/rump/kern/lib/libsljit/arch/mips

2019-01-21 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Tue Jan 22 00:36:02 UTC 2019

Modified Files:
src/sys/rump/kern/lib/libsljit/arch/mips: cache.c

Log Message:
Sync the first argument type with mco_icache_sync_range.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/rump/kern/lib/libsljit/arch/mips/cache.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/rump/kern/lib/libsljit/arch/mips/cache.c
diff -u src/sys/rump/kern/lib/libsljit/arch/mips/cache.c:1.1 src/sys/rump/kern/lib/libsljit/arch/mips/cache.c:1.2
--- src/sys/rump/kern/lib/libsljit/arch/mips/cache.c:1.1	Tue Jul 22 20:25:13 2014
+++ src/sys/rump/kern/lib/libsljit/arch/mips/cache.c	Tue Jan 22 00:36:02 2019
@@ -1,4 +1,4 @@
-/*  $NetBSD: cache.c,v 1.1 2014/07/22 20:25:13 alnsn Exp $	*/
+/*  $NetBSD: cache.c,v 1.2 2019/01/22 00:36:02 alnsn Exp $	*/
 
 /*-
  * Copyright (c) 2014 Alexander Nasonov.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cache.c,v 1.1 2014/07/22 20:25:13 alnsn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cache.c,v 1.2 2019/01/22 00:36:02 alnsn Exp $");
 
 /*
  * Barebone implementation of mips cache routines for rump.
@@ -38,14 +38,14 @@ __KERNEL_RCSID(0, "$NetBSD: cache.c,v 1.
 
 #include "sljit_rump.h"
 
-static void icache_sync_range(vaddr_t, vsize_t);
+static void icache_sync_range(register_t, vsize_t);
 
 struct mips_cache_ops mips_cache_ops = {
 	.mco_icache_sync_range = _sync_range
 };
 
 static void
-icache_sync_range(vaddr_t va, vsize_t sz)
+icache_sync_range(register_t va, vsize_t sz)
 {
 
 	(void)rumpcomp_sync_icache((void *)va, (uint64_t)sz);



CVS commit: src/doc

2019-01-20 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Mon Jan 21 01:02:50 UTC 2019

Modified Files:
src/doc: 3RDPARTY

Log Message:
Update sljit version.


To generate a diff of this commit:
cvs rdiff -u -r1.1593 -r1.1594 src/doc/3RDPARTY

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/doc/3RDPARTY
diff -u src/doc/3RDPARTY:1.1593 src/doc/3RDPARTY:1.1594
--- src/doc/3RDPARTY:1.1593	Wed Jan  9 22:51:53 2019
+++ src/doc/3RDPARTY	Mon Jan 21 01:02:50 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: 3RDPARTY,v 1.1593 2019/01/09 22:51:53 christos Exp $
+#	$NetBSD: 3RDPARTY,v 1.1594 2019/01/21 01:02:50 alnsn Exp $
 #
 # This file contains a list of the software that has been integrated into
 # NetBSD where we are not the primary maintainer.
@@ -1532,7 +1532,7 @@ Location:	external/cddl/osnet
 Notes:
 
 Package:	sljit
-Version:	svn revision 313
+Version:	0.93 (svn revision 333)
 Current Vers:	0.93
 Maintainer:	Zoltán Herczeg http://sourceforge.net/projects/sljit/



CVS commit: src/sys/rump/kern/lib/libsljit

2019-01-20 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Mon Jan 21 00:30:14 UTC 2019

Modified Files:
src/sys/rump/kern/lib/libsljit: Makefile
Added Files:
src/sys/rump/kern/lib/libsljit/arch/aarch64: cpufunc.c sljit_rump.c

Log Message:
Add sljit rump glue for aarch64.

XXX arm_icache_sync_range() and mips_icache_sync_range() call

(void)rumpcomp_sync_icache((void *)va, (uint64_t)sz);

but linking fails if I do the same on aarch64 (I suspect it also
fails on 32bit arm and mips).

As a workaround, I call __builtin___clear_cache().


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/rump/kern/lib/libsljit/Makefile
cvs rdiff -u -r0 -r1.1 src/sys/rump/kern/lib/libsljit/arch/aarch64/cpufunc.c \
src/sys/rump/kern/lib/libsljit/arch/aarch64/sljit_rump.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/rump/kern/lib/libsljit/Makefile
diff -u src/sys/rump/kern/lib/libsljit/Makefile:1.5 src/sys/rump/kern/lib/libsljit/Makefile:1.6
--- src/sys/rump/kern/lib/libsljit/Makefile:1.5	Tue Jan  5 13:07:47 2016
+++ src/sys/rump/kern/lib/libsljit/Makefile	Mon Jan 21 00:30:14 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.5 2016/01/05 13:07:47 christos Exp $
+#	$NetBSD: Makefile,v 1.6 2019/01/21 00:30:14 alnsn Exp $
 #
 # Public Domain.
 #
@@ -38,5 +38,14 @@ RUMPCOMP_USER_CPPFLAGS=-I${RUMPCOMP_INCS
 LIBDPLIBS+=	arm ${NETBSDSRCDIR}/lib/libarch
 .endif
 
+.if !empty(MACHINE_ARCH:Maarch64*)
+SRCS+=			cpufunc.c
+RUMPCOMP_USER_SRCS=	sljit_rump.c
+.PATH:			${.CURDIR}/arch/aarch64
+
+RUMPCOMP_INCS_DIR:=	${.PARSEDIR}
+RUMPCOMP_USER_CPPFLAGS=-I${RUMPCOMP_INCS_DIR}
+.endif
+
 .include 
 .include 

Added files:

Index: src/sys/rump/kern/lib/libsljit/arch/aarch64/cpufunc.c
diff -u /dev/null src/sys/rump/kern/lib/libsljit/arch/aarch64/cpufunc.c:1.1
--- /dev/null	Mon Jan 21 00:30:14 2019
+++ src/sys/rump/kern/lib/libsljit/arch/aarch64/cpufunc.c	Mon Jan 21 00:30:14 2019
@@ -0,0 +1,51 @@
+/*	$NetBSD: cpufunc.c,v 1.1 2019/01/21 00:30:14 alnsn Exp $	*/
+
+/*-
+ * Copyright (c) 2019 Alexander Nasonov.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include 
+__KERNEL_RCSID(0, "$NetBSD: cpufunc.c,v 1.1 2019/01/21 00:30:14 alnsn Exp $");
+
+/*
+ * Barebone implementation of arm cpufunc routines for rump.
+ */
+
+#include 
+#include 
+
+#include "sljit_rump.h"
+
+void aarch64_icache_sync_range(vaddr_t, vsize_t);
+
+void
+aarch64_icache_sync_range(vaddr_t va, vsize_t sz)
+{
+
+	// XXX MIPS and 32-bit ARM make this call:
+	// (void)rumpcomp_sync_icache((void *)va, (uint64_t)sz);
+	// but it doesn't link. Fix Makefiles to make it link.
+	__builtin___clear_cache((void *)va, (char *)va + sz);
+}
Index: src/sys/rump/kern/lib/libsljit/arch/aarch64/sljit_rump.c
diff -u /dev/null src/sys/rump/kern/lib/libsljit/arch/aarch64/sljit_rump.c:1.1
--- /dev/null	Mon Jan 21 00:30:14 2019
+++ src/sys/rump/kern/lib/libsljit/arch/aarch64/sljit_rump.c	Mon Jan 21 00:30:14 2019
@@ -0,0 +1,45 @@
+/*  $NetBSD: sljit_rump.c,v 1.1 2019/01/21 00:30:14 alnsn Exp $	*/
+
+/*-
+ * Copyright (c) 2019 Alexander Nasonov.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+

CVS commit: src/sys/modules

2019-01-20 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Mon Jan 21 00:21:48 UTC 2019

Modified Files:
src/sys/modules: Makefile

Log Message:
Build bpfjit and sljit modules on aarch64.


To generate a diff of this commit:
cvs rdiff -u -r1.214 -r1.215 src/sys/modules/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/modules/Makefile
diff -u src/sys/modules/Makefile:1.214 src/sys/modules/Makefile:1.215
--- src/sys/modules/Makefile:1.214	Wed Dec 19 13:57:52 2018
+++ src/sys/modules/Makefile	Mon Jan 21 00:21:48 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.214 2018/12/19 13:57:52 maxv Exp $
+#	$NetBSD: Makefile,v 1.215 2019/01/21 00:21:48 alnsn Exp $
 
 .include 
 
@@ -212,10 +212,11 @@ SUBDIR+=	ubsec		# Builds on architecture
 .endif
 
 .if ${MKSLJIT} != "no"
-# No modules for arm, mips and powerpc yet.
-.if ${MACHINE_ARCH} == "i386" || \
-${MACHINE_ARCH} == "x86_64" || \
-${MACHINE_ARCH} == "sparc"
+# No modules for 32-bit arm, mips and powerpc yet.
+.if ${MACHINE_ARCH} == "aarch64" || \
+${MACHINE_ARCH} == "i386"|| \
+${MACHINE_ARCH} == "sparc"   || \
+${MACHINE_ARCH} == "x86_64"
 SUBDIR+=	bpfjit
 SUBDIR+=	sljit
 .endif



CVS commit: src/distrib/sets/lists/modules

2019-01-20 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Mon Jan 21 00:22:24 UTC 2019

Modified Files:
src/distrib/sets/lists/modules: ad.aarch64

Log Message:
Add bpfjit and sljit modules.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/distrib/sets/lists/modules/ad.aarch64

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/sets/lists/modules/ad.aarch64
diff -u src/distrib/sets/lists/modules/ad.aarch64:1.1 src/distrib/sets/lists/modules/ad.aarch64:1.2
--- src/distrib/sets/lists/modules/ad.aarch64:1.1	Sun Aug 10 05:47:35 2014
+++ src/distrib/sets/lists/modules/ad.aarch64	Mon Jan 21 00:22:24 2019
@@ -1,3 +1,7 @@
-# $NetBSD: ad.aarch64,v 1.1 2014/08/10 05:47:35 matt Exp $
+# $NetBSD: ad.aarch64,v 1.2 2019/01/21 00:22:24 alnsn Exp $
+./@MODULEDIR@/bpfjitbase-kernel-modules	kmod,sljit
+./@MODULEDIR@/bpfjit/bpfjit.kmod		base-kernel-modules	kmod,sljit
 ./@MODULEDIR@/exec_elf64			base-kernel-modules	kmod
 ./@MODULEDIR@/exec_elf64/exec_elf64.kmod	base-kernel-modules	kmod
+./@MODULEDIR@/sljitbase-kernel-modules	kmod,sljit
+./@MODULEDIR@/sljit/sljit.kmod			base-kernel-modules	kmod,sljit



CVS commit: src/sys/external/bsd/sljit/dist/sljit_src

2019-01-20 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Mon Jan 21 00:07:11 UTC 2019

Modified Files:
src/sys/external/bsd/sljit/dist/sljit_src: sljitLir.c

Log Message:
Add #ifndef _KERNEL guard around userspace #includes


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/external/bsd/sljit/dist/sljit_src/sljitLir.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/sljit/dist/sljit_src/sljitLir.c
diff -u src/sys/external/bsd/sljit/dist/sljit_src/sljitLir.c:1.6 src/sys/external/bsd/sljit/dist/sljit_src/sljitLir.c:1.7
--- src/sys/external/bsd/sljit/dist/sljit_src/sljitLir.c:1.6	Sun Jan 20 23:14:16 2019
+++ src/sys/external/bsd/sljit/dist/sljit_src/sljitLir.c	Mon Jan 21 00:07:10 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: sljitLir.c,v 1.6 2019/01/20 23:14:16 alnsn Exp $	*/
+/*	$NetBSD: sljitLir.c,v 1.7 2019/01/21 00:07:10 alnsn Exp $	*/
 
 /*
  *Stack-less Just-In-Time compiler
@@ -30,9 +30,11 @@
 
 #if !(defined SLJIT_STD_MACROS_DEFINED && SLJIT_STD_MACROS_DEFINED)
 
+#ifndef _KERNEL
 /* These libraries are needed for the macros below. */
 #include 
 #include 
+#endif
 
 #endif /* SLJIT_STD_MACROS_DEFINED */
 



CVS commit: src/sys/net

2019-01-20 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sun Jan 20 23:36:58 UTC 2019

Modified Files:
src/sys/net: bpfjit.c

Log Message:
Add missing include.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sys/net/bpfjit.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/net/bpfjit.c
diff -u src/sys/net/bpfjit.c:1.46 src/sys/net/bpfjit.c:1.47
--- src/sys/net/bpfjit.c:1.46	Fri Jul 29 20:29:38 2016
+++ src/sys/net/bpfjit.c	Sun Jan 20 23:36:57 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: bpfjit.c,v 1.46 2016/07/29 20:29:38 alnsn Exp $	*/
+/*	$NetBSD: bpfjit.c,v 1.47 2019/01/20 23:36:57 alnsn Exp $	*/
 
 /*-
  * Copyright (c) 2011-2015 Alexander Nasonov.
@@ -31,9 +31,9 @@
 
 #include 
 #ifdef _KERNEL
-__KERNEL_RCSID(0, "$NetBSD: bpfjit.c,v 1.46 2016/07/29 20:29:38 alnsn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bpfjit.c,v 1.47 2019/01/20 23:36:57 alnsn Exp $");
 #else
-__RCSID("$NetBSD: bpfjit.c,v 1.46 2016/07/29 20:29:38 alnsn Exp $");
+__RCSID("$NetBSD: bpfjit.c,v 1.47 2019/01/20 23:36:57 alnsn Exp $");
 #endif
 
 #include 
@@ -61,6 +61,7 @@ __RCSID("$NetBSD: bpfjit.c,v 1.46 2016/0
 #include 
 #include 
 #include 
+#include 
 #else
 #include 
 #include 



CVS commit: src/sys/external/bsd/sljit

2019-01-20 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sun Jan 20 23:23:01 UTC 2019

Modified Files:
src/sys/external/bsd/sljit: README.import

Log Message:
Update sljit revision.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/external/bsd/sljit/README.import

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/sljit/README.import
diff -u src/sys/external/bsd/sljit/README.import:1.5 src/sys/external/bsd/sljit/README.import:1.6
--- src/sys/external/bsd/sljit/README.import:1.5	Sun May 29 17:56:20 2016
+++ src/sys/external/bsd/sljit/README.import	Sun Jan 20 23:23:01 2019
@@ -1,6 +1,6 @@
 There are no CVS/SVN ids in sljit repository but don't forget to
 remove .svn before importing the new version.
 
-Current sljit import is @ r313:
+Current sljit import is @ r333:
 
-svn co https://svn.code.sf.net/p/sljit/code@r313 dist
+svn co https://svn.code.sf.net/p/sljit/code@r333 dist



CVS import: src/sys/external/bsd/sljit/dist

2019-01-20 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sun Jan 20 22:44:26 UTC 2019

Update of /cvsroot/src/sys/external/bsd/sljit/dist
In directory ivanova.netbsd.org:/tmp/cvs-serv663

Log Message:
Update sljit to version 0.93 (svn revision r333).

Changes since the last import:

r333 More x86 fixes and a new stack test.
r332 Improve stack allocation on x86.
r331 Make sljit_free_unused_memory_exec public, PPC flush takes priority.
r330 Reverse the stack utility to top-down.
r329 Add sljit_set_current_flags function.
r328 Add two more virtual registers to x86/32, ARM-32 refactor.
r327 Remove value caching on ARM-32.
r326 Remove value caching on ARM-Thumb2.
r325 Move with update rework.
r324 Arm32 store fixes.
r323 Update macros and remove copyright years.
r322 Reworking flags, removing keep flags.
r321 Quick fix for regexjit.
r320 Improve protected executable allocator. Patch insipred by Christian Persch.
r319 Fully support dynamic code modifications again.
r318 Support protected allocator on all architectures except TILEGX.
r317 Rework protected allocator, only x86 linux is supported now.
r316 Add protected executable allocator.
r315 Remove SLJIT_MEMMOVE.
r314 Fix unaligned accesses on x86. Patch by Marc Mutz.

Status:

Vendor Tag: TNF
Release Tags:   SLJIT-r333

U src/sys/external/bsd/sljit/dist/API_CHANGES
U src/sys/external/bsd/sljit/dist/INTERNAL_CHANGES
U src/sys/external/bsd/sljit/dist/Makefile
U src/sys/external/bsd/sljit/dist/README
C src/sys/external/bsd/sljit/dist/sljit_src/sljitNativeX86_32.c
C src/sys/external/bsd/sljit/dist/sljit_src/sljitNativeX86_common.c
C src/sys/external/bsd/sljit/dist/sljit_src/sljitConfigInternal.h
C src/sys/external/bsd/sljit/dist/sljit_src/sljitLir.c
C src/sys/external/bsd/sljit/dist/sljit_src/sljitLir.h
C src/sys/external/bsd/sljit/dist/sljit_src/sljitNativeX86_64.c
C src/sys/external/bsd/sljit/dist/sljit_src/sljitUtils.c
C src/sys/external/bsd/sljit/dist/sljit_src/sljitNativeARM_32.c
C src/sys/external/bsd/sljit/dist/sljit_src/sljitNativeARM_T2_32.c
C src/sys/external/bsd/sljit/dist/sljit_src/sljitNativeARM_64.c
C src/sys/external/bsd/sljit/dist/sljit_src/sljitNativeMIPS_common.c
C src/sys/external/bsd/sljit/dist/sljit_src/sljitNativePPC_common.c
C src/sys/external/bsd/sljit/dist/sljit_src/sljitNativeSPARC_common.c
C src/sys/external/bsd/sljit/dist/sljit_src/sljitConfig.h
C src/sys/external/bsd/sljit/dist/sljit_src/sljitExecAllocator.c
C src/sys/external/bsd/sljit/dist/sljit_src/sljitNativeMIPS_32.c
C src/sys/external/bsd/sljit/dist/sljit_src/sljitNativeMIPS_64.c
C src/sys/external/bsd/sljit/dist/sljit_src/sljitNativePPC_32.c
C src/sys/external/bsd/sljit/dist/sljit_src/sljitNativePPC_64.c
C src/sys/external/bsd/sljit/dist/sljit_src/sljitNativeSPARC_32.c
C src/sys/external/bsd/sljit/dist/sljit_src/sljitNativeTILEGX-encoder.c
C src/sys/external/bsd/sljit/dist/sljit_src/sljitNativeTILEGX_64.c
N src/sys/external/bsd/sljit/dist/sljit_src/sljitProtExecAllocator.c
U src/sys/external/bsd/sljit/dist/test_src/sljitMain.c
C src/sys/external/bsd/sljit/dist/test_src/sljitTest.c
U src/sys/external/bsd/sljit/dist/regex_src/regexJIT.c
U src/sys/external/bsd/sljit/dist/regex_src/regexMain.c
U src/sys/external/bsd/sljit/dist/regex_src/regexJIT.h
U src/sys/external/bsd/sljit/dist/doc/overview.txt
U src/sys/external/bsd/sljit/dist/doc/tutorial/brainfuck.c
U src/sys/external/bsd/sljit/dist/doc/tutorial/func_call.c
U src/sys/external/bsd/sljit/dist/doc/tutorial/struct_access.c
U src/sys/external/bsd/sljit/dist/doc/tutorial/sljit_tutorial.html
U src/sys/external/bsd/sljit/dist/doc/tutorial/99bottles.bf
U src/sys/external/bsd/sljit/dist/doc/tutorial/array_access.c
U src/sys/external/bsd/sljit/dist/doc/tutorial/first_program.c
U src/sys/external/bsd/sljit/dist/doc/tutorial/loop.c
U src/sys/external/bsd/sljit/dist/doc/tutorial/README
U src/sys/external/bsd/sljit/dist/doc/tutorial/branch.c
U src/sys/external/bsd/sljit/dist/doc/tutorial/hello.bf
U src/sys/external/bsd/sljit/dist/doc/tutorial/temp_var.c

23 conflicts created by this import.
Use the following command to help the merge:

cvs checkout -jTNF:yesterday -jTNF src/sys/external/bsd/sljit/dist



CVS commit: src/sys/arch/aarch64/aarch64

2018-12-29 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sat Dec 29 19:53:38 UTC 2018

Modified Files:
src/sys/arch/aarch64/aarch64: pmapboot.c

Log Message:
pmapboot_pte_print() is only used when VERBOSE_INIT_ARM is defined.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/aarch64/aarch64/pmapboot.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/aarch64/pmapboot.c
diff -u src/sys/arch/aarch64/aarch64/pmapboot.c:1.2 src/sys/arch/aarch64/aarch64/pmapboot.c:1.3
--- src/sys/arch/aarch64/aarch64/pmapboot.c:1.2	Fri Oct  5 01:54:10 2018
+++ src/sys/arch/aarch64/aarch64/pmapboot.c	Sat Dec 29 19:53:38 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmapboot.c,v 1.2 2018/10/05 01:54:10 ryo Exp $	*/
+/*	$NetBSD: pmapboot.c,v 1.3 2018/12/29 19:53:38 alnsn Exp $	*/
 
 /*
  * Copyright (c) 2018 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmapboot.c,v 1.2 2018/10/05 01:54:10 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmapboot.c,v 1.3 2018/12/29 19:53:38 alnsn Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_ddb.h"
@@ -139,6 +139,7 @@ pmapboot_protect(vaddr_t sva, vaddr_t ev
  * it supports only maximum 7 argument, and only '%d', '%x', and '%s' formats.
  */
 
+#ifdef VERBOSE_INIT_ARM
 static void
 pmapboot_pte_print(pt_entry_t pte, int level,
 void (*pr)(const char *, ...) __printflike(1, 2))
@@ -152,6 +153,7 @@ pmapboot_pte_print(pt_entry_t pte, int l
 	l0pde_pa(pte));
 #endif
 }
+#endif /* VERBOSE_INIT_ARM */
 
 #ifdef OPTIMIZE_TLB_CONTIG
 static inline bool



CVS commit: src/distrib/common

2018-12-29 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sat Dec 29 13:09:35 UTC 2018

Modified Files:
src/distrib/common: cgdroot.rc

Log Message:
ROOT.a doesn't resolve to a useful partition, hardcode wd0a and ld0a for now.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/distrib/common/cgdroot.rc

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/common/cgdroot.rc
diff -u src/distrib/common/cgdroot.rc:1.3 src/distrib/common/cgdroot.rc:1.4
--- src/distrib/common/cgdroot.rc:1.3	Sat Dec 29 01:04:38 2018
+++ src/distrib/common/cgdroot.rc	Sat Dec 29 13:09:35 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: cgdroot.rc,v 1.3 2018/12/29 01:04:38 alnsn Exp $
+#	$NetBSD: cgdroot.rc,v 1.4 2018/12/29 13:09:35 alnsn Exp $
 #
 # Copyright (c) 2013 Pierre Pronchery 
 # All rights reserved.
@@ -37,7 +37,7 @@ export EDITOR
 umask 022
 
 mounted=
-for dev in NAME=cgd.conf ROOT.a ; do
+for dev in NAME=cgd.conf /dev/wd0a /dev/ld0a ; do
 	if mount -o ro $dev /etc/cgd 2>/dev/null ; then
 		mounted=$dev
 		break



CVS commit: src/distrib/common

2018-12-28 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sat Dec 29 01:04:39 UTC 2018

Modified Files:
src/distrib/common: cgdroot.rc

Log Message:
Break the loop after a successful mount.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/distrib/common/cgdroot.rc

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/common/cgdroot.rc
diff -u src/distrib/common/cgdroot.rc:1.2 src/distrib/common/cgdroot.rc:1.3
--- src/distrib/common/cgdroot.rc:1.2	Sat Dec 29 00:52:11 2018
+++ src/distrib/common/cgdroot.rc	Sat Dec 29 01:04:38 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: cgdroot.rc,v 1.2 2018/12/29 00:52:11 alnsn Exp $
+#	$NetBSD: cgdroot.rc,v 1.3 2018/12/29 01:04:38 alnsn Exp $
 #
 # Copyright (c) 2013 Pierre Pronchery 
 # All rights reserved.
@@ -40,6 +40,7 @@ mounted=
 for dev in NAME=cgd.conf ROOT.a ; do
 	if mount -o ro $dev /etc/cgd 2>/dev/null ; then
 		mounted=$dev
+		break
 	fi
 done
 if [ -z "$mounted" ]; then



CVS commit: src/distrib/common

2018-12-28 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sat Dec 29 00:52:11 UTC 2018

Modified Files:
src/distrib/common: cgdroot.rc

Log Message:
Don't hardcode wd0a in cgdroot.kmod, try NAME=cgd.conf and ROOT.a.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/distrib/common/cgdroot.rc

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/common/cgdroot.rc
diff -u src/distrib/common/cgdroot.rc:1.1 src/distrib/common/cgdroot.rc:1.2
--- src/distrib/common/cgdroot.rc:1.1	Mon Jul 15 00:25:38 2013
+++ src/distrib/common/cgdroot.rc	Sat Dec 29 00:52:11 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: cgdroot.rc,v 1.1 2013/07/15 00:25:38 khorben Exp $
+#	$NetBSD: cgdroot.rc,v 1.2 2018/12/29 00:52:11 alnsn Exp $
 #
 # Copyright (c) 2013 Pierre Pronchery 
 # All rights reserved.
@@ -36,8 +36,13 @@ export EDITOR
 
 umask 022
 
-mount -o ro /dev/wd0a /etc/cgd
-if [ $? -ne 0 ]; then
+mounted=
+for dev in NAME=cgd.conf ROOT.a ; do
+	if mount -o ro $dev /etc/cgd 2>/dev/null ; then
+		mounted=$dev
+	fi
+done
+if [ -z "$mounted" ]; then
 	echo "Could not mount the boot partition" 1>&2
 	exit 2
 fi



CVS commit: src/lib/libutil

2018-12-28 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Fri Dec 28 18:44:11 UTC 2018

Modified Files:
src/lib/libutil: getfsspecname.3

Log Message:
Document "ROOT." syntax before documenting a generic .


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/lib/libutil/getfsspecname.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libutil/getfsspecname.3
diff -u src/lib/libutil/getfsspecname.3:1.6 src/lib/libutil/getfsspecname.3:1.7
--- src/lib/libutil/getfsspecname.3:1.6	Sat Oct  6 13:09:53 2018
+++ src/lib/libutil/getfsspecname.3	Fri Dec 28 18:44:11 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: getfsspecname.3,v 1.6 2018/10/06 13:09:53 jmcneill Exp $
+.\"	$NetBSD: getfsspecname.3,v 1.7 2018/12/28 18:44:11 alnsn Exp $
 .\"
 .\" Copyright (c) 2012 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -28,7 +28,7 @@
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
 .\"
-.Dd October 6, 2018
+.Dd December 28, 2018
 .Dt GETFSSPECNAME 3
 .Os
 .Sh NAME
@@ -58,16 +58,6 @@ up to len
 .Pp
 If the
 .Fa spec
-argument is not of the form
-.Dq NAME=wedgename ,
-.Fa spec
-is copied
-to
-.Fa buf
-and returned.
-.Pp
-If the
-.Fa spec
 argument starts with
 .Dq ROOT. ,
 a path in the form
@@ -85,6 +75,18 @@ is the characters following
 in the
 .Fa spec
 argument.
+.Pp
+If the
+.Fa spec
+argument is not of the form
+.Dq NAME=wedgename
+and it doesn't start with
+.Dq ROOT. ,
+.Fa spec
+is copied
+to
+.Fa buf
+and returned.
 .Sh RETURN VALUES
 On success the absolute pathname of the underlying wedge device is returned,
 or the original



CVS commit: src/sbin/cgdconfig

2018-12-28 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Fri Dec 28 18:33:54 UTC 2018

Modified Files:
src/sbin/cgdconfig: cgdconfig.8

Log Message:
s/Dec/December/.


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sbin/cgdconfig/cgdconfig.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/cgdconfig/cgdconfig.8
diff -u src/sbin/cgdconfig/cgdconfig.8:1.42 src/sbin/cgdconfig/cgdconfig.8:1.43
--- src/sbin/cgdconfig/cgdconfig.8:1.42	Thu Dec 27 21:17:08 2018
+++ src/sbin/cgdconfig/cgdconfig.8	Fri Dec 28 18:33:54 2018
@@ -1,4 +1,4 @@
-.\" $NetBSD: cgdconfig.8,v 1.42 2018/12/27 21:17:08 alnsn Exp $
+.\" $NetBSD: cgdconfig.8,v 1.43 2018/12/28 18:33:54 alnsn Exp $
 .\"
 .\" Copyright (c) 2002, The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd Dec 27, 2018
+.Dd December 27, 2018
 .Dt CGDCONFIG 8
 .Os
 .Sh NAME



CVS commit: src/lib/libutil

2018-12-27 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Thu Dec 27 21:35:48 UTC 2018

Modified Files:
src/lib/libutil: getfsspecname.c

Log Message:
No need to quadruple a buffer because strunvis(3) doesn't expand.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/lib/libutil/getfsspecname.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libutil/getfsspecname.c
diff -u src/lib/libutil/getfsspecname.c:1.7 src/lib/libutil/getfsspecname.c:1.8
--- src/lib/libutil/getfsspecname.c:1.7	Sat Oct  6 23:48:00 2018
+++ src/lib/libutil/getfsspecname.c	Thu Dec 27 21:35:48 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: getfsspecname.c,v 1.7 2018/10/06 23:48:00 christos Exp $	*/
+/*	$NetBSD: getfsspecname.c,v 1.8 2018/12/27 21:35:48 alnsn Exp $	*/
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__RCSID("$NetBSD: getfsspecname.c,v 1.7 2018/10/06 23:48:00 christos Exp $");
+__RCSID("$NetBSD: getfsspecname.c,v 1.8 2018/12/27 21:35:48 alnsn Exp $");
 
 #include 
 #include 
@@ -108,7 +108,7 @@ getfsspecname(char *buf, size_t bufsiz, 
 #ifdef COMPAT_DKWEDGE
 search:
 #endif
-	vname = malloc(strlen(name) * 4 + 1);
+	vname = malloc(strlen(name) + 1);
 	if (vname == NULL) {
 		savee = errno;
 		strlcpy(buf, "malloc failed", bufsiz);



CVS commit: src/sbin/cgdconfig

2018-12-27 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Thu Dec 27 21:17:08 UTC 2018

Modified Files:
src/sbin/cgdconfig: cgdconfig.8

Log Message:
Document that cgd.conf supports NAME=label and ROOT. targets.

XXX Default paramsfile for NAME=label is /etc/cgd/dkNN (resolved wedge
partition) and /etc/cgd/ROOT. for ROOT.. This isn't yet
documented. IMO, it should be the other way around: /etc/cgd/label
for the former and /et/cgd/[root-device] for the latter.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sbin/cgdconfig/cgdconfig.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/cgdconfig/cgdconfig.8
diff -u src/sbin/cgdconfig/cgdconfig.8:1.41 src/sbin/cgdconfig/cgdconfig.8:1.42
--- src/sbin/cgdconfig/cgdconfig.8:1.41	Sat Sep  1 11:46:52 2018
+++ src/sbin/cgdconfig/cgdconfig.8	Thu Dec 27 21:17:08 2018
@@ -1,4 +1,4 @@
-.\" $NetBSD: cgdconfig.8,v 1.41 2018/09/01 11:46:52 prlw1 Exp $
+.\" $NetBSD: cgdconfig.8,v 1.42 2018/12/27 21:17:08 alnsn Exp $
 .\"
 .\" Copyright (c) 2002, The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd May 9, 2018
+.Dd Dec 27, 2018
 .Dt CGDCONFIG 8
 .Os
 .Sh NAME
@@ -248,6 +248,24 @@ A
 at the end of a line indicates that the next line is a continuation of
 the current line.
 .Pp
+If the second field is of the form
+.Dq NAME=
+then all the
+.Xr dk 4
+wedge partitions are searched for one that has a wedge name equal to
+.Ar 
+and the device corresponding to it is selected.
+.Pp
+If the second field starts with the prefix
+.Dq ROOT.
+the prefix is replaced with
+.Dq /dev/[root_device] ,
+where
+.Bq root_device
+is the value of the
+.Dq kern.root_device
+sysctl.
+.Pp
 See
 .Sx EXAMPLES
 for an example of
@@ -418,7 +436,7 @@ An example
 
 	# cgd		target		[paramsfile]
 	cgd0		/dev/wd0e
-	cgd1		/dev/sd0h	/usr/local/etc/cgd/sd0h
+	cgd1		NAME=mycgd	/usr/local/etc/cgd/mycgd
 .Ed
 .Pp
 Note the first entry will store the parameters file as
@@ -439,6 +457,8 @@ program's execution.
 .Sh SEE ALSO
 .Xr cgd 4 ,
 .Xr disklabel 8 ,
+.Xr dk 4 ,
+.Xr fstab 5 ,
 .Xr gpt 8
 .Pp
 .Dq PKCS #5 v2.0: Password-Based Cryptography Standard ,



CVS commit: src/sys/arch/aarch64/include

2018-12-15 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sat Dec 15 16:54:30 UTC 2018

Modified Files:
src/sys/arch/aarch64/include: cpufunc.h

Log Message:
Add missing include for device_t declaration.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/aarch64/include/cpufunc.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/include/cpufunc.h
diff -u src/sys/arch/aarch64/include/cpufunc.h:1.3 src/sys/arch/aarch64/include/cpufunc.h:1.4
--- src/sys/arch/aarch64/include/cpufunc.h:1.3	Sun Aug 26 18:15:49 2018
+++ src/sys/arch/aarch64/include/cpufunc.h	Sat Dec 15 16:54:30 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc.h,v 1.3 2018/08/26 18:15:49 ryo Exp $	*/
+/*	$NetBSD: cpufunc.h,v 1.4 2018/12/15 16:54:30 alnsn Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -32,6 +32,7 @@
 #ifdef _KERNEL
 
 #include 
+#include 
 
 static inline int
 set_cpufuncs(void)



CVS commit: src/sys/rump

2018-12-11 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Wed Dec 12 00:48:44 UTC 2018

Modified Files:
src/sys/rump/dev/lib/libnetsmb: netsmb_user.c
src/sys/rump/dev/lib/libpci: rumpdev_bus_dma.c rumpdev_bus_space.c
src/sys/rump/dev/lib/libscsipi: scsipi_component.c
src/sys/rump/dev/lib/libucom: ucom_at_usb.c
src/sys/rump/dev/lib/libugenhc: ugenhc_user.c
src/sys/rump/dev/lib/libulpt: ulpt_at_usb.c
src/sys/rump/dev/lib/libumass: umass_component.c
src/sys/rump/dev/lib/libwscons: wscons_component.c
src/sys/rump/kern/lib/libsys_cygwin: rump_cygwin_compat.c
sys_cygwin_component.c
src/sys/rump/kern/lib/libsys_linux: linux_rump.c sys_linux_component.c
src/sys/rump/kern/lib/libsys_sunos: rump_sunos_compat.c
sys_sunos_component.c
src/sys/rump/librump/rumpkern/arch/generic: rump_generic_directmap.c
src/sys/rump/net/lib/libpppoe: pppoe_component.c
src/sys/rump/net/lib/libshmif: shmif_user.c
src/sys/rump/net/lib/libsockin: sockin_user.c
src/sys/rump/net/lib/libvirtif: virtif_user.c

Log Message:
Add missing RCSIDs.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/rump/dev/lib/libnetsmb/netsmb_user.c
cvs rdiff -u -r1.6 -r1.7 src/sys/rump/dev/lib/libpci/rumpdev_bus_dma.c
cvs rdiff -u -r1.8 -r1.9 src/sys/rump/dev/lib/libpci/rumpdev_bus_space.c
cvs rdiff -u -r1.2 -r1.3 src/sys/rump/dev/lib/libscsipi/scsipi_component.c
cvs rdiff -u -r1.8 -r1.9 src/sys/rump/dev/lib/libucom/ucom_at_usb.c
cvs rdiff -u -r1.1 -r1.2 src/sys/rump/dev/lib/libugenhc/ugenhc_user.c
cvs rdiff -u -r1.6 -r1.7 src/sys/rump/dev/lib/libulpt/ulpt_at_usb.c
cvs rdiff -u -r1.2 -r1.3 src/sys/rump/dev/lib/libumass/umass_component.c
cvs rdiff -u -r1.2 -r1.3 src/sys/rump/dev/lib/libwscons/wscons_component.c
cvs rdiff -u -r1.1 -r1.2 \
src/sys/rump/kern/lib/libsys_cygwin/rump_cygwin_compat.c
cvs rdiff -u -r1.3 -r1.4 \
src/sys/rump/kern/lib/libsys_cygwin/sys_cygwin_component.c
cvs rdiff -u -r1.2 -r1.3 src/sys/rump/kern/lib/libsys_linux/linux_rump.c
cvs rdiff -u -r1.4 -r1.5 \
src/sys/rump/kern/lib/libsys_linux/sys_linux_component.c
cvs rdiff -u -r1.2 -r1.3 \
src/sys/rump/kern/lib/libsys_sunos/rump_sunos_compat.c
cvs rdiff -u -r1.3 -r1.4 \
src/sys/rump/kern/lib/libsys_sunos/sys_sunos_component.c
cvs rdiff -u -r1.1 -r1.2 \
src/sys/rump/librump/rumpkern/arch/generic/rump_generic_directmap.c
cvs rdiff -u -r1.1 -r1.2 src/sys/rump/net/lib/libpppoe/pppoe_component.c
cvs rdiff -u -r1.2 -r1.3 src/sys/rump/net/lib/libshmif/shmif_user.c
cvs rdiff -u -r1.1 -r1.2 src/sys/rump/net/lib/libsockin/sockin_user.c
cvs rdiff -u -r1.3 -r1.4 src/sys/rump/net/lib/libvirtif/virtif_user.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/rump/dev/lib/libnetsmb/netsmb_user.c
diff -u src/sys/rump/dev/lib/libnetsmb/netsmb_user.c:1.3 src/sys/rump/dev/lib/libnetsmb/netsmb_user.c:1.4
--- src/sys/rump/dev/lib/libnetsmb/netsmb_user.c:1.3	Sun Nov 16 15:31:12 2014
+++ src/sys/rump/dev/lib/libnetsmb/netsmb_user.c	Wed Dec 12 00:48:43 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: netsmb_user.c,v 1.3 2014/11/16 15:31:12 nakayama Exp $	*/
+/*	$NetBSD: netsmb_user.c,v 1.4 2018/12/12 00:48:43 alnsn Exp $	*/
 
 /*
  * Copyright (c) 2014 Takeshi Nakayama.
@@ -24,6 +24,10 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
+
+#include 
+__KERNEL_RCSID(0, "$NetBSD: netsmb_user.c,v 1.4 2018/12/12 00:48:43 alnsn Exp $");
+
 #ifndef _KERNEL
 #include 
 #include 

Index: src/sys/rump/dev/lib/libpci/rumpdev_bus_dma.c
diff -u src/sys/rump/dev/lib/libpci/rumpdev_bus_dma.c:1.6 src/sys/rump/dev/lib/libpci/rumpdev_bus_dma.c:1.7
--- src/sys/rump/dev/lib/libpci/rumpdev_bus_dma.c:1.6	Fri Apr 27 08:51:26 2018
+++ src/sys/rump/dev/lib/libpci/rumpdev_bus_dma.c	Wed Dec 12 00:48:43 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpdev_bus_dma.c,v 1.6 2018/04/27 08:51:26 maxv Exp $	*/
+/*	$NetBSD: rumpdev_bus_dma.c,v 1.7 2018/12/12 00:48:43 alnsn Exp $	*/
 
 /*-
  * Copyright (c) 2013 Antti Kantee
@@ -67,6 +67,9 @@
  *	NetBSD: bus_dma.c,v 1.46 2012/02/01 09:54:03 matt Exp
  */
 
+#include 
+__KERNEL_RCSID(0, "$NetBSD: rumpdev_bus_dma.c,v 1.7 2018/12/12 00:48:43 alnsn Exp $");
+
 #include 
 #include 
 #include 

Index: src/sys/rump/dev/lib/libpci/rumpdev_bus_space.c
diff -u src/sys/rump/dev/lib/libpci/rumpdev_bus_space.c:1.8 src/sys/rump/dev/lib/libpci/rumpdev_bus_space.c:1.9
--- src/sys/rump/dev/lib/libpci/rumpdev_bus_space.c:1.8	Thu Jul  7 06:55:43 2016
+++ src/sys/rump/dev/lib/libpci/rumpdev_bus_space.c	Wed Dec 12 00:48:43 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpdev_bus_space.c,v 1.8 2016/07/07 06:55:43 msaitoh Exp $	*/
+/*	$NetBSD: rumpdev_bus_space.c,v 1.9 2018/12/12 00:48:43 alnsn Exp $	*/
 
 /*-
  * Copyright (c) 2013 Antti Kantee.  All Rights Reserved.
@@ -26,6 

CVS commit: src/sys/arch/arm/include

2018-12-11 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Tue Dec 11 19:38:42 UTC 2018

Modified Files:
src/sys/arch/arm/include: cpufunc.h

Log Message:
Don't exclude code from rump kernel build.


To generate a diff of this commit:
cvs rdiff -u -r1.81 -r1.82 src/sys/arch/arm/include/cpufunc.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/include/cpufunc.h
diff -u src/sys/arch/arm/include/cpufunc.h:1.81 src/sys/arch/arm/include/cpufunc.h:1.82
--- src/sys/arch/arm/include/cpufunc.h:1.81	Sat Oct 20 06:35:34 2018
+++ src/sys/arch/arm/include/cpufunc.h	Tue Dec 11 19:38:42 2018
@@ -46,8 +46,6 @@
 
 #ifdef _KERNEL
 
-#if !defined(_RUMPKERNEL)
-
 #include 
 
 #include 
@@ -415,8 +413,6 @@ extern struct arm_cache_info arm_scache;
 
 extern uint32_t cpu_ttb;
 
-#endif	/* _GUMP */
-
 #endif	/* _KERNEL */
 
 #if defined(_KERNEL) || defined(_KMEMUSER)



CVS commit: src

2018-12-09 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sun Dec  9 15:08:06 UTC 2018

Modified Files:
src/distrib/sets/lists/comp: ad.aarch64
src/sys/arch/aarch64/include: Makefile

Log Message:
Install aarch64/sljit_machdep.h.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/distrib/sets/lists/comp/ad.aarch64
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/aarch64/include/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/sets/lists/comp/ad.aarch64
diff -u src/distrib/sets/lists/comp/ad.aarch64:1.24 src/distrib/sets/lists/comp/ad.aarch64:1.25
--- src/distrib/sets/lists/comp/ad.aarch64:1.24	Tue Aug 14 14:48:01 2018
+++ src/distrib/sets/lists/comp/ad.aarch64	Sun Dec  9 15:08:05 2018
@@ -1,4 +1,4 @@
-# $NetBSD: ad.aarch64,v 1.24 2018/08/14 14:48:01 rjs Exp $
+# $NetBSD: ad.aarch64,v 1.25 2018/12/09 15:08:05 alnsn Exp $
 ./usr/include/aarch64comp-c-include
 ./usr/include/aarch64/ansi.h			comp-c-include
 ./usr/include/aarch64/aout_machdep.h		comp-c-include
@@ -42,6 +42,7 @@
 ./usr/include/aarch64/rwlock.h			comp-c-include
 ./usr/include/aarch64/setjmp.h			comp-c-include
 ./usr/include/aarch64/signal.h			comp-c-include
+./usr/include/aarch64/sljit_machdep.h		comp-c-include
 ./usr/include/aarch64/sysarch.h			comp-c-include
 ./usr/include/aarch64/trap.h			comp-obsolete		obsolete
 ./usr/include/aarch64/types.h			comp-c-include

Index: src/sys/arch/aarch64/include/Makefile
diff -u src/sys/arch/aarch64/include/Makefile:1.2 src/sys/arch/aarch64/include/Makefile:1.3
--- src/sys/arch/aarch64/include/Makefile:1.2	Sun Apr  1 04:35:03 2018
+++ src/sys/arch/aarch64/include/Makefile	Sun Dec  9 15:08:05 2018
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.2 2018/04/01 04:35:03 ryo Exp $
+# $NetBSD: Makefile,v 1.3 2018/12/09 15:08:05 alnsn Exp $
 
 INCSDIR= /usr/include/aarch64
 
@@ -16,7 +16,7 @@ INCS=	ansi.h aout_machdep.h armreg.h asm
 	param.h pcb.h pmap.h \
 	proc.h profile.h pte.h ptrace.h \
 	reg.h rwlock.h \
-	setjmp.h signal.h sysarch.h \
+	setjmp.h signal.h sljit_machdep.h sysarch.h \
 	types.h \
 	vmparam.h \
 	wchar_limits.h



CVS commit: src/sys/arch/aarch64/include

2018-12-02 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sun Dec  2 20:54:44 UTC 2018

Modified Files:
src/sys/arch/aarch64/include: sljit_machdep.h

Log Message:
Switch to __builtin___clear_cache() in userspace.

aarch64_sync_icache() doesn't exist because there no libarm equivalent
on aarch64.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/aarch64/include/sljit_machdep.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/include/sljit_machdep.h
diff -u src/sys/arch/aarch64/include/sljit_machdep.h:1.1 src/sys/arch/aarch64/include/sljit_machdep.h:1.2
--- src/sys/arch/aarch64/include/sljit_machdep.h:1.1	Sun Aug 26 21:06:46 2018
+++ src/sys/arch/aarch64/include/sljit_machdep.h	Sun Dec  2 20:54:44 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: sljit_machdep.h,v 1.1 2018/08/26 21:06:46 rjs Exp $	*/
+/*	$NetBSD: sljit_machdep.h,v 1.2 2018/12/02 20:54:44 alnsn Exp $	*/
 
 /*-
  * Copyright (c) 2014 Alexander Nasonov.
@@ -47,7 +47,7 @@
 	cpu_icache_sync_range((vaddr_t)(from), (vsize_t)((to) - (from)))
 #else
 #define SLJIT_CACHE_FLUSH(from, to) \
-	(void)aarch64_sync_icache((uintptr_t)(from), (size_t)((to) - (from)))
+	(void)__builtin___clear_cache((char *)(from), (char *)(to))
 #endif
 
 #endif



CVS commit: src/sys/stand/efiboot

2018-08-27 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Mon Aug 27 22:51:55 UTC 2018

Modified Files:
src/sys/stand/efiboot: efifdt.c

Log Message:
Fix typo in a panic string.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/stand/efiboot/efifdt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/stand/efiboot/efifdt.c
diff -u src/sys/stand/efiboot/efifdt.c:1.3 src/sys/stand/efiboot/efifdt.c:1.4
--- src/sys/stand/efiboot/efifdt.c:1.3	Mon Aug 27 09:51:32 2018
+++ src/sys/stand/efiboot/efifdt.c	Mon Aug 27 22:51:55 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: efifdt.c,v 1.3 2018/08/27 09:51:32 jmcneill Exp $ */
+/* $NetBSD: efifdt.c,v 1.4 2018/08/27 22:51:55 alnsn Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -149,7 +149,7 @@ efi_fdt_bootargs(const char *bootargs)
 	if (chosen < 0)
 		chosen = fdt_add_subnode(fdt_data, fdt_path_offset(fdt_data, "/"), FDT_CHOSEN_NODE_NAME);
 	if (chosen < 0)
-		panic("FDT: Failed to craete " FDT_CHOSEN_NODE_PATH " node");
+		panic("FDT: Failed to create " FDT_CHOSEN_NODE_PATH " node");
 
 	if (*bootargs)
 		fdt_setprop_string(fdt_data, chosen, "bootargs", bootargs);



CVS commit: src/share/misc

2018-08-13 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Mon Aug 13 22:22:59 UTC 2018

Modified Files:
src/share/misc: acronyms.comp

Log Message:
It's Flattened Device Tree.

Thanks @sevan for the heads up.


To generate a diff of this commit:
cvs rdiff -u -r1.213 -r1.214 src/share/misc/acronyms.comp

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/share/misc/acronyms.comp
diff -u src/share/misc/acronyms.comp:1.213 src/share/misc/acronyms.comp:1.214
--- src/share/misc/acronyms.comp:1.213	Mon Aug 13 20:33:35 2018
+++ src/share/misc/acronyms.comp	Mon Aug 13 22:22:59 2018
@@ -1,4 +1,4 @@
-$NetBSD: acronyms.comp,v 1.213 2018/08/13 20:33:35 alnsn Exp $
+$NetBSD: acronyms.comp,v 1.214 2018/08/13 22:22:59 alnsn Exp $
 3WHS	three-way handshake
 8VSB	8-state vestigial side band modulation
 AA	anti-aliasing
@@ -484,7 +484,7 @@ FDC	floppy disk controller
 FDD	floppy disk drive
 FDDI	fiber distributed data interface
 FDE	full disk encryption
-FDT	flat device tree
+FDT	flattened device tree
 FEA	finite element analysis
 FEC	forward error correction
 FET	field-effect transistor



CVS commit: src/share/misc

2018-08-13 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Mon Aug 13 20:33:35 UTC 2018

Modified Files:
src/share/misc: acronyms.comp

Log Message:
Add FDT (flat device tree).


To generate a diff of this commit:
cvs rdiff -u -r1.212 -r1.213 src/share/misc/acronyms.comp

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/share/misc/acronyms.comp
diff -u src/share/misc/acronyms.comp:1.212 src/share/misc/acronyms.comp:1.213
--- src/share/misc/acronyms.comp:1.212	Wed Jul  4 15:38:46 2018
+++ src/share/misc/acronyms.comp	Mon Aug 13 20:33:35 2018
@@ -1,4 +1,4 @@
-$NetBSD: acronyms.comp,v 1.212 2018/07/04 15:38:46 maya Exp $
+$NetBSD: acronyms.comp,v 1.213 2018/08/13 20:33:35 alnsn Exp $
 3WHS	three-way handshake
 8VSB	8-state vestigial side band modulation
 AA	anti-aliasing
@@ -484,6 +484,7 @@ FDC	floppy disk controller
 FDD	floppy disk drive
 FDDI	fiber distributed data interface
 FDE	full disk encryption
+FDT	flat device tree
 FEA	finite element analysis
 FEC	forward error correction
 FET	field-effect transistor



CVS commit: src/doc

2018-08-10 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Fri Aug 10 20:11:29 UTC 2018

Modified Files:
src/doc: CHANGES

Log Message:
lua: Import version 5.3.5.


To generate a diff of this commit:
cvs rdiff -u -r1.2418 -r1.2419 src/doc/CHANGES

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/doc/CHANGES
diff -u src/doc/CHANGES:1.2418 src/doc/CHANGES:1.2419
--- src/doc/CHANGES:1.2418	Wed Aug  8 19:05:19 2018
+++ src/doc/CHANGES	Fri Aug 10 20:11:29 2018
@@ -1,4 +1,4 @@
-# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2418 $>
+# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2419 $>
 #
 #
 # [Note: This file does not mention every change made to the NetBSD source tree.
@@ -192,4 +192,5 @@ Changes from NetBSD 8.0 to NetBSD 9.0:
 		[kamil 20180803]
 	kUBSan: Added support for micro-UBSan (kernel-UBSan) as KUBSAN.
 		[kamil 20180803]
+	lua: Import version 5.3.5. [alnsn 20180804]
 	arm: Add driver for ARM GICv3 interrupt controllers. [jmcneill 20180808]



CVS commit: src/doc

2018-08-05 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sun Aug  5 17:39:55 UTC 2018

Modified Files:
src/doc: 3RDPARTY

Log Message:
Update Lua, add myself to responsible.


To generate a diff of this commit:
cvs rdiff -u -r1.1535 -r1.1536 src/doc/3RDPARTY

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/doc/3RDPARTY
diff -u src/doc/3RDPARTY:1.1535 src/doc/3RDPARTY:1.1536
--- src/doc/3RDPARTY:1.1535	Fri Jul 27 14:38:50 2018
+++ src/doc/3RDPARTY	Sun Aug  5 17:39:55 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: 3RDPARTY,v 1.1535 2018/07/27 14:38:50 maya Exp $
+#	$NetBSD: 3RDPARTY,v 1.1536 2018/08/05 17:39:55 alnsn Exp $
 #
 # This file contains a list of the software that has been integrated into
 # NetBSD where we are not the primary maintainer.
@@ -806,12 +806,12 @@ under src/usr.sbin). We don't use tcpd; 
 into inetd. The provided libwrap2netbsd script handles just libwrap.
 
 Package:	Lua
-Version:	Lua 5.3.4
-Current Vers:	Lua 5.3.4
+Version:	Lua 5.3.5
+Current Vers:	Lua 5.3.5
 Maintainer:	PUC Rio
 Home Page:	http://www.lua.org/
 Mailing List:
-Responsible:	mbalmer, lneto, salazar
+Responsible:	mbalmer, lneto, salazar, alnsn
 License:	MIT
 Location:	external/mit/lua/dist
 Notes:



CVS commit: src/external/mit/lua/dist

2018-08-04 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sat Aug  4 17:53:29 UTC 2018

Modified Files:
src/external/mit/lua/dist: README.import

Log Message:
Don't use $NetBSD$ in a sentence, refer to them as 'RCS identifiers'.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/external/mit/lua/dist/README.import

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/mit/lua/dist/README.import
diff -u src/external/mit/lua/dist/README.import:1.1 src/external/mit/lua/dist/README.import:1.2
--- src/external/mit/lua/dist/README.import:1.1	Sat Aug  4 17:47:26 2018
+++ src/external/mit/lua/dist/README.import	Sat Aug  4 17:53:29 2018
@@ -10,8 +10,8 @@ How to import Lua x.y.z
 5. Run 'cvs up -dP' to bring the new import to the tree.
 6. Run 'cvs up -j LUA_<> -j LUA_<>'.
It will generate many conflicts.
-7. Resolve conflicts. Most (if not all) conflicts are around $NetBSD: README.import,v 1.1 2018/08/04 17:47:26 alnsn Exp $
-   RCS identifiers.
+7. Resolve conflicts. Most (if not all) conflicts are around RCS
+   identifiers.
 8. Commit your changes.
 
 Vendor branches are usually named LUA_<> but if there was a problem



CVS commit: src/external/mit/lua/dist

2018-08-04 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sat Aug  4 17:47:26 UTC 2018

Added Files:
src/external/mit/lua/dist: README.import

Log Message:
README.import with step-by-step import instruction.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/external/mit/lua/dist/README.import

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Added files:

Index: src/external/mit/lua/dist/README.import
diff -u /dev/null src/external/mit/lua/dist/README.import:1.1
--- /dev/null	Sat Aug  4 17:47:26 2018
+++ src/external/mit/lua/dist/README.import	Sat Aug  4 17:47:26 2018
@@ -0,0 +1,20 @@
+How to import Lua x.y.z
+===
+
+1. Untar a new version to a directory called dist.work or even
+   somethere outside of the tree.
+2. Run lua2netbsd script inside that directory.
+3. Run 'cvs import src/external/mit/lua/dist LUA LUA_<>'.
+   It's very important to run it from inside the right direcory!
+4. Move the dist directory away (is it optional?).
+5. Run 'cvs up -dP' to bring the new import to the tree.
+6. Run 'cvs up -j LUA_<> -j LUA_<>'.
+   It will generate many conflicts.
+7. Resolve conflicts. Most (if not all) conflicts are around $NetBSD: README.import,v 1.1 2018/08/04 17:47:26 alnsn Exp $
+   RCS identifiers.
+8. Commit your changes.
+
+Vendor branches are usually named LUA_<> but if there was a problem
+with cvs import, they can be named differently.
+
+The last imported vendor branch is called LUA_5_3_5_try2.



CVS commit: src/external/mit/lua/dist

2018-08-04 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sat Aug  4 17:30:01 UTC 2018

Modified Files:
src/external/mit/lua/dist: README
src/external/mit/lua/dist/doc: contents.html lua.css manual.html
readme.html
src/external/mit/lua/dist/src: Makefile lapi.c lapi.h lauxlib.c
lauxlib.h lbaselib.c lbitlib.c lcode.c lcode.h lcorolib.c lctype.c
lctype.h ldblib.c ldebug.c ldebug.h ldo.c ldo.h ldump.c lfunc.c
lfunc.h lgc.c lgc.h linit.c liolib.c llex.c llex.h llimits.h
lmathlib.c lmem.c lmem.h loadlib.c lobject.c lobject.h lopcodes.c
lopcodes.h loslib.c lparser.c lparser.h lprefix.h lstate.c lstate.h
lstring.c lstring.h lstrlib.c ltable.c ltable.h ltablib.c ltm.c
ltm.h lua.c lua.h luac.c luaconf.h lualib.h lundump.c lundump.h
lutf8lib.c lvm.c lvm.h lzio.c lzio.h

Log Message:
Resolve conflicts.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/external/mit/lua/dist/README
cvs rdiff -u -r1.6 -r1.7 src/external/mit/lua/dist/doc/contents.html \
src/external/mit/lua/dist/doc/lua.css \
src/external/mit/lua/dist/doc/readme.html
cvs rdiff -u -r1.7 -r1.8 src/external/mit/lua/dist/doc/manual.html
cvs rdiff -u -r1.4 -r1.5 src/external/mit/lua/dist/src/Makefile
cvs rdiff -u -r1.10 -r1.11 src/external/mit/lua/dist/src/lapi.c \
src/external/mit/lua/dist/src/lauxlib.c \
src/external/mit/lua/dist/src/lcode.c \
src/external/mit/lua/dist/src/ldblib.c \
src/external/mit/lua/dist/src/ldebug.c \
src/external/mit/lua/dist/src/loslib.c \
src/external/mit/lua/dist/src/lparser.c \
src/external/mit/lua/dist/src/ltable.c \
src/external/mit/lua/dist/src/lua.h
cvs rdiff -u -r1.8 -r1.9 src/external/mit/lua/dist/src/lapi.h \
src/external/mit/lua/dist/src/ldebug.h \
src/external/mit/lua/dist/src/ldo.c src/external/mit/lua/dist/src/ldo.h \
src/external/mit/lua/dist/src/ldump.c \
src/external/mit/lua/dist/src/linit.c \
src/external/mit/lua/dist/src/liolib.c \
src/external/mit/lua/dist/src/lmathlib.c \
src/external/mit/lua/dist/src/lmem.c \
src/external/mit/lua/dist/src/loadlib.c \
src/external/mit/lua/dist/src/lstate.c \
src/external/mit/lua/dist/src/lstate.h \
src/external/mit/lua/dist/src/lstring.c \
src/external/mit/lua/dist/src/lstring.h \
src/external/mit/lua/dist/src/ltablib.c \
src/external/mit/lua/dist/src/ltm.c src/external/mit/lua/dist/src/lua.c
cvs rdiff -u -r1.7 -r1.8 src/external/mit/lua/dist/src/lauxlib.h \
src/external/mit/lua/dist/src/lcode.h \
src/external/mit/lua/dist/src/lfunc.c \
src/external/mit/lua/dist/src/lfunc.h src/external/mit/lua/dist/src/lgc.h \
src/external/mit/lua/dist/src/llex.h src/external/mit/lua/dist/src/lmem.h \
src/external/mit/lua/dist/src/lopcodes.c \
src/external/mit/lua/dist/src/lopcodes.h \
src/external/mit/lua/dist/src/lparser.h \
src/external/mit/lua/dist/src/ltable.h \
src/external/mit/lua/dist/src/ltm.h \
src/external/mit/lua/dist/src/lundump.c \
src/external/mit/lua/dist/src/lutf8lib.c \
src/external/mit/lua/dist/src/lzio.c src/external/mit/lua/dist/src/lzio.h
cvs rdiff -u -r1.9 -r1.10 src/external/mit/lua/dist/src/lbaselib.c \
src/external/mit/lua/dist/src/lgc.c \
src/external/mit/lua/dist/src/llimits.h \
src/external/mit/lua/dist/src/lobject.h \
src/external/mit/lua/dist/src/luac.c src/external/mit/lua/dist/src/lvm.h
cvs rdiff -u -r1.6 -r1.7 src/external/mit/lua/dist/src/lbitlib.c \
src/external/mit/lua/dist/src/lcorolib.c \
src/external/mit/lua/dist/src/lctype.c \
src/external/mit/lua/dist/src/lctype.h \
src/external/mit/lua/dist/src/lprefix.h \
src/external/mit/lua/dist/src/lualib.h \
src/external/mit/lua/dist/src/lundump.h
cvs rdiff -u -r1.11 -r1.12 src/external/mit/lua/dist/src/llex.c \
src/external/mit/lua/dist/src/lobject.c
cvs rdiff -u -r1.17 -r1.18 src/external/mit/lua/dist/src/lstrlib.c
cvs rdiff -u -r1.22 -r1.23 src/external/mit/lua/dist/src/luaconf.h
cvs rdiff -u -r1.13 -r1.14 src/external/mit/lua/dist/src/lvm.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/mit/lua/dist/README
diff -u src/external/mit/lua/dist/README:1.7 src/external/mit/lua/dist/README:1.8
--- src/external/mit/lua/dist/README:1.7	Wed Apr 26 13:06:22 2017
+++ src/external/mit/lua/dist/README	Sat Aug  4 17:30:01 2018
@@ -1,5 +1,5 @@
 
-This is Lua 5.3.4, released on 12 Jan 2017.
+This is Lua 5.3.5, released on 26 Jun 2018.
 
 For installation instructions, license details, and
 further information about Lua, see doc/readme.html.

Index: src/external/mit/lua/dist/doc/contents.html
diff -u src/external/mit/lua/dist/doc/contents.html:1.6 src/external/mit/lua/dist/doc/contents.html:1.7
--- src/external/mit/lua/dist/doc/contents.html:1.6	Wed Apr 26 12:36:53 2017
+++ 

CVS import: src/external/mit/lua/dist

2018-08-04 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sat Aug  4 17:14:17 UTC 2018

Update of /cvsroot/src/external/mit/lua/dist
In directory ivanova.netbsd.org:/tmp/cvs-serv12861

Log Message:
Import Lua 5.3.5.

Vendor branch is called LUA_5_3_5_try2 because the first attempt to
import 5.3.5 failed (I launched cvs import from a wrong directory).

Status:

Vendor Tag: LUA
Release Tags:   LUA_5_3_5_try2

C src/external/mit/lua/dist/Makefile
C src/external/mit/lua/dist/README
C src/external/mit/lua/dist/doc/manual.html
U src/external/mit/lua/dist/doc/luac.1
C src/external/mit/lua/dist/doc/contents.html
U src/external/mit/lua/dist/doc/manual.css
U src/external/mit/lua/dist/doc/index.css
C src/external/mit/lua/dist/doc/lua.css
U src/external/mit/lua/dist/doc/logo.gif
U src/external/mit/lua/dist/doc/lua.1
U src/external/mit/lua/dist/doc/osi-certified-72x60.png
C src/external/mit/lua/dist/doc/readme.html
C src/external/mit/lua/dist/src/lmathlib.c
C src/external/mit/lua/dist/src/ldblib.c
C src/external/mit/lua/dist/src/loadlib.c
C src/external/mit/lua/dist/src/loslib.c
C src/external/mit/lua/dist/src/lvm.c
C src/external/mit/lua/dist/src/ldo.h
C src/external/mit/lua/dist/src/lua.h
C src/external/mit/lua/dist/src/lgc.h
C src/external/mit/lua/dist/src/ltm.h
C src/external/mit/lua/dist/src/luaconf.h
C src/external/mit/lua/dist/src/lmem.c
C src/external/mit/lua/dist/src/lstate.h
C src/external/mit/lua/dist/src/Makefile
C src/external/mit/lua/dist/src/lzio.h
C src/external/mit/lua/dist/src/lstring.c
C src/external/mit/lua/dist/src/lzio.c
C src/external/mit/lua/dist/src/lopcodes.c
C src/external/mit/lua/dist/src/lua.c
C src/external/mit/lua/dist/src/lundump.h
C src/external/mit/lua/dist/src/lbaselib.c
C src/external/mit/lua/dist/src/ltable.c
C src/external/mit/lua/dist/src/ldump.c
C src/external/mit/lua/dist/src/liolib.c
C src/external/mit/lua/dist/src/llimits.h
C src/external/mit/lua/dist/src/lfunc.h
C src/external/mit/lua/dist/src/lualib.h
C src/external/mit/lua/dist/src/lctype.c
C src/external/mit/lua/dist/src/lmem.h
C src/external/mit/lua/dist/src/llex.h
C src/external/mit/lua/dist/src/ltable.h
C src/external/mit/lua/dist/src/lbitlib.c
C src/external/mit/lua/dist/src/ldebug.h
C src/external/mit/lua/dist/src/lprefix.h
C src/external/mit/lua/dist/src/llex.c
C src/external/mit/lua/dist/src/linit.c
C src/external/mit/lua/dist/src/lobject.h
C src/external/mit/lua/dist/src/lapi.h
C src/external/mit/lua/dist/src/ldebug.c
C src/external/mit/lua/dist/src/ldo.c
C src/external/mit/lua/dist/src/lvm.h
C src/external/mit/lua/dist/src/lauxlib.c
C src/external/mit/lua/dist/src/luac.c
C src/external/mit/lua/dist/src/lctype.h
C src/external/mit/lua/dist/src/lstring.h
C src/external/mit/lua/dist/src/lcorolib.c
C src/external/mit/lua/dist/src/lutf8lib.c
C src/external/mit/lua/dist/src/lgc.c
C src/external/mit/lua/dist/src/lstate.c
C src/external/mit/lua/dist/src/lundump.c
C src/external/mit/lua/dist/src/ltablib.c
C src/external/mit/lua/dist/src/lauxlib.h
C src/external/mit/lua/dist/src/ltm.c
C src/external/mit/lua/dist/src/lparser.c
C src/external/mit/lua/dist/src/lcode.h
C src/external/mit/lua/dist/src/lobject.c
C src/external/mit/lua/dist/src/lcode.c
C src/external/mit/lua/dist/src/lopcodes.h
C src/external/mit/lua/dist/src/lfunc.c
C src/external/mit/lua/dist/src/lapi.c
C src/external/mit/lua/dist/src/lparser.h
C src/external/mit/lua/dist/src/lstrlib.c
U src/external/mit/lua/dist/src/lua.hpp

67 conflicts created by this import.
Use the following command to help the merge:

cvs checkout -jLUA:yesterday -jLUA src/external/mit/lua/dist



CVS commit: src/external/mit/lua/dist

2018-07-29 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sun Jul 29 22:46:15 UTC 2018

Removed Files:
src/external/mit/lua/dist/dist: Makefile README lua2netbsd
src/external/mit/lua/dist/dist.work: Makefile README
src/external/mit/lua/dist/dist.work/doc: contents.html index.css
logo.gif lua.1 lua.css luac.1 manual.css manual.html
osi-certified-72x60.png readme.html
src/external/mit/lua/dist/dist.work/src: Makefile lapi.c lapi.h
lauxlib.c lauxlib.h lbaselib.c lbitlib.c lcode.c lcode.h lcorolib.c
lctype.c lctype.h ldblib.c ldebug.c ldebug.h ldo.c ldo.h ldump.c
lfunc.c lfunc.h lgc.c lgc.h linit.c liolib.c llex.c llex.h
llimits.h lmathlib.c lmem.c lmem.h loadlib.c lobject.c lobject.h
lopcodes.c lopcodes.h loslib.c lparser.c lparser.h lprefix.h
lstate.c lstate.h lstring.c lstring.h lstrlib.c ltable.c ltable.h
ltablib.c ltm.c ltm.h lua.c lua.h lua.hpp luac.c luaconf.h lualib.h
lundump.c lundump.h lutf8lib.c lvm.c lvm.h lzio.c lzio.h
src/external/mit/lua/dist/dist/doc: contents.html index.css logo.gif
lua.1 lua.css luac.1 manual.css manual.html osi-certified-72x60.png
readme.html
src/external/mit/lua/dist/dist/src: Makefile lapi.c lapi.h lauxlib.c
lauxlib.h lbaselib.c lbitlib.c lcode.c lcode.h lcorolib.c lctype.c
lctype.h ldblib.c ldebug.c ldebug.h ldo.c ldo.h ldump.c lfunc.c
lfunc.h lgc.c lgc.h linit.c liolib.c llex.c llex.h llimits.h
lmathlib.c lmem.c lmem.h loadlib.c lobject.c lobject.h lopcodes.c
lopcodes.h loslib.c lparser.c lparser.h lprefix.h lstate.c lstate.h
lstring.c lstring.h lstrlib.c ltable.c ltable.h ltablib.c ltm.c
ltm.h lua.c lua.h lua.hpp luac.c luaconf.h lualib.h lundump.c
lundump.h lutf8lib.c lvm.c lvm.h lzio.c lzio.h
src/external/mit/lua/dist/lib: Makefile
src/external/mit/lua/dist/lib/liblua: Makefile shlib_version
src/external/mit/lua/dist/usr.bin: Makefile
src/external/mit/lua/dist/usr.bin/lua: Makefile
src/external/mit/lua/dist/usr.bin/luac: Makefile

Log Message:
Remove files imported to a wrong directory.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r0 src/external/mit/lua/dist/dist/Makefile \
src/external/mit/lua/dist/dist/README \
src/external/mit/lua/dist/dist/lua2netbsd
cvs rdiff -u -r1.1.1.1 -r0 src/external/mit/lua/dist/dist.work/Makefile \
src/external/mit/lua/dist/dist.work/README
cvs rdiff -u -r1.1.1.1 -r0 \
src/external/mit/lua/dist/dist.work/doc/contents.html \
src/external/mit/lua/dist/dist.work/doc/index.css \
src/external/mit/lua/dist/dist.work/doc/logo.gif \
src/external/mit/lua/dist/dist.work/doc/lua.1 \
src/external/mit/lua/dist/dist.work/doc/lua.css \
src/external/mit/lua/dist/dist.work/doc/luac.1 \
src/external/mit/lua/dist/dist.work/doc/manual.css \
src/external/mit/lua/dist/dist.work/doc/manual.html \
src/external/mit/lua/dist/dist.work/doc/osi-certified-72x60.png \
src/external/mit/lua/dist/dist.work/doc/readme.html
cvs rdiff -u -r1.1.1.1 -r0 src/external/mit/lua/dist/dist.work/src/Makefile \
src/external/mit/lua/dist/dist.work/src/lapi.c \
src/external/mit/lua/dist/dist.work/src/lapi.h \
src/external/mit/lua/dist/dist.work/src/lauxlib.c \
src/external/mit/lua/dist/dist.work/src/lauxlib.h \
src/external/mit/lua/dist/dist.work/src/lbaselib.c \
src/external/mit/lua/dist/dist.work/src/lbitlib.c \
src/external/mit/lua/dist/dist.work/src/lcode.c \
src/external/mit/lua/dist/dist.work/src/lcode.h \
src/external/mit/lua/dist/dist.work/src/lcorolib.c \
src/external/mit/lua/dist/dist.work/src/lctype.c \
src/external/mit/lua/dist/dist.work/src/lctype.h \
src/external/mit/lua/dist/dist.work/src/ldblib.c \
src/external/mit/lua/dist/dist.work/src/ldebug.c \
src/external/mit/lua/dist/dist.work/src/ldebug.h \
src/external/mit/lua/dist/dist.work/src/ldo.c \
src/external/mit/lua/dist/dist.work/src/ldo.h \
src/external/mit/lua/dist/dist.work/src/ldump.c \
src/external/mit/lua/dist/dist.work/src/lfunc.c \
src/external/mit/lua/dist/dist.work/src/lfunc.h \
src/external/mit/lua/dist/dist.work/src/lgc.c \
src/external/mit/lua/dist/dist.work/src/lgc.h \
src/external/mit/lua/dist/dist.work/src/linit.c \
src/external/mit/lua/dist/dist.work/src/liolib.c \
src/external/mit/lua/dist/dist.work/src/llex.c \
src/external/mit/lua/dist/dist.work/src/llex.h \
src/external/mit/lua/dist/dist.work/src/llimits.h \
src/external/mit/lua/dist/dist.work/src/lmathlib.c \
src/external/mit/lua/dist/dist.work/src/lmem.c \
src/external/mit/lua/dist/dist.work/src/lmem.h \
src/external/mit/lua/dist/dist.work/src/loadlib.c \
src/external/mit/lua/dist/dist.work/src/lobject.c \

CVS import: src/external/mit/lua/dist

2018-07-29 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sun Jul 29 19:46:08 UTC 2018

Update of /cvsroot/src/external/mit/lua/dist
In directory ivanova.netbsd.org:/tmp/cvs-serv15569

Log Message:
Import Lua 5.3.5.

Status:

Vendor Tag: LUA
Release Tags:   LUA_5_3_5

C src/external/mit/lua/dist/Makefile
N src/external/mit/lua/dist/dist/README
N src/external/mit/lua/dist/dist/lua2netbsd
N src/external/mit/lua/dist/dist/Makefile
N src/external/mit/lua/dist/dist/doc/lua.1
N src/external/mit/lua/dist/dist/doc/contents.html
N src/external/mit/lua/dist/dist/doc/index.css
N src/external/mit/lua/dist/dist/doc/logo.gif
N src/external/mit/lua/dist/dist/doc/lua.css
N src/external/mit/lua/dist/dist/doc/luac.1
N src/external/mit/lua/dist/dist/doc/manual.html
N src/external/mit/lua/dist/dist/doc/manual.css
N src/external/mit/lua/dist/dist/doc/osi-certified-72x60.png
N src/external/mit/lua/dist/dist/doc/readme.html
N src/external/mit/lua/dist/dist/src/Makefile
N src/external/mit/lua/dist/dist/src/lapi.h
N src/external/mit/lua/dist/dist/src/lauxlib.c
N src/external/mit/lua/dist/dist/src/lauxlib.h
N src/external/mit/lua/dist/dist/src/lbaselib.c
N src/external/mit/lua/dist/dist/src/lbitlib.c
N src/external/mit/lua/dist/dist/src/lcode.c
N src/external/mit/lua/dist/dist/src/lcode.h
N src/external/mit/lua/dist/dist/src/lcorolib.c
N src/external/mit/lua/dist/dist/src/lctype.c
N src/external/mit/lua/dist/dist/src/lctype.h
N src/external/mit/lua/dist/dist/src/ldblib.c
N src/external/mit/lua/dist/dist/src/ldebug.c
N src/external/mit/lua/dist/dist/src/ldebug.h
N src/external/mit/lua/dist/dist/src/ldo.c
N src/external/mit/lua/dist/dist/src/ldo.h
N src/external/mit/lua/dist/dist/src/ldump.c
N src/external/mit/lua/dist/dist/src/lfunc.c
N src/external/mit/lua/dist/dist/src/lfunc.h
N src/external/mit/lua/dist/dist/src/lgc.c
N src/external/mit/lua/dist/dist/src/lgc.h
N src/external/mit/lua/dist/dist/src/linit.c
N src/external/mit/lua/dist/dist/src/liolib.c
N src/external/mit/lua/dist/dist/src/llex.c
N src/external/mit/lua/dist/dist/src/llex.h
N src/external/mit/lua/dist/dist/src/llimits.h
N src/external/mit/lua/dist/dist/src/lmathlib.c
N src/external/mit/lua/dist/dist/src/lmem.c
N src/external/mit/lua/dist/dist/src/lmem.h
N src/external/mit/lua/dist/dist/src/loadlib.c
N src/external/mit/lua/dist/dist/src/lobject.c
N src/external/mit/lua/dist/dist/src/lobject.h
N src/external/mit/lua/dist/dist/src/lopcodes.c
N src/external/mit/lua/dist/dist/src/lopcodes.h
N src/external/mit/lua/dist/dist/src/loslib.c
N src/external/mit/lua/dist/dist/src/lstrlib.c
N src/external/mit/lua/dist/dist/src/lparser.h
N src/external/mit/lua/dist/dist/src/lprefix.h
N src/external/mit/lua/dist/dist/src/lstate.c
N src/external/mit/lua/dist/dist/src/lstate.h
N src/external/mit/lua/dist/dist/src/lstring.c
N src/external/mit/lua/dist/dist/src/lstring.h
N src/external/mit/lua/dist/dist/src/ltable.c
N src/external/mit/lua/dist/dist/src/ltable.h
N src/external/mit/lua/dist/dist/src/ltablib.c
N src/external/mit/lua/dist/dist/src/ltm.c
N src/external/mit/lua/dist/dist/src/ltm.h
N src/external/mit/lua/dist/dist/src/lua.c
N src/external/mit/lua/dist/dist/src/lua.h
N src/external/mit/lua/dist/dist/src/luac.c
N src/external/mit/lua/dist/dist/src/lua.hpp
N src/external/mit/lua/dist/dist/src/luaconf.h
N src/external/mit/lua/dist/dist/src/lualib.h
N src/external/mit/lua/dist/dist/src/lundump.c
N src/external/mit/lua/dist/dist/src/lundump.h
N src/external/mit/lua/dist/dist/src/lutf8lib.c
N src/external/mit/lua/dist/dist/src/lvm.c
N src/external/mit/lua/dist/dist/src/lvm.h
N src/external/mit/lua/dist/dist/src/lzio.c
N src/external/mit/lua/dist/dist/src/lzio.h
N src/external/mit/lua/dist/dist/src/lapi.c
N src/external/mit/lua/dist/dist/src/lparser.c
N src/external/mit/lua/dist/lib/Makefile
N src/external/mit/lua/dist/lib/liblua/Makefile
N src/external/mit/lua/dist/lib/liblua/shlib_version
N src/external/mit/lua/dist/usr.bin/Makefile
N src/external/mit/lua/dist/usr.bin/lua/Makefile
N src/external/mit/lua/dist/usr.bin/luac/Makefile
N src/external/mit/lua/dist/dist.work/Makefile
N src/external/mit/lua/dist/dist.work/README
N src/external/mit/lua/dist/dist.work/doc/manual.html
N src/external/mit/lua/dist/dist.work/doc/luac.1
N src/external/mit/lua/dist/dist.work/doc/contents.html
N src/external/mit/lua/dist/dist.work/doc/manual.css
N src/external/mit/lua/dist/dist.work/doc/index.css
N src/external/mit/lua/dist/dist.work/doc/lua.css
N src/external/mit/lua/dist/dist.work/doc/logo.gif
N src/external/mit/lua/dist/dist.work/doc/lua.1
N src/external/mit/lua/dist/dist.work/doc/osi-certified-72x60.png
N src/external/mit/lua/dist/dist.work/doc/readme.html
N src/external/mit/lua/dist/dist.work/src/lmathlib.c
N src/external/mit/lua/dist/dist.work/src/ldblib.c
N src/external/mit/lua/dist/dist.work/src/loadlib.c
N src/external/mit/lua/dist/dist.work/src/loslib.c
N src/external/mit/lua/dist/dist.work/src/lvm.c
N src/external/mit/lua/dist/dist.work/src/ldo.h
N 

CVS commit: src/doc

2018-06-17 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sun Jun 17 18:10:18 UTC 2018

Modified Files:
src/doc: 3RDPARTY

Log Message:
Current sljit version is r381.


To generate a diff of this commit:
cvs rdiff -u -r1.1528 -r1.1529 src/doc/3RDPARTY

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/doc/3RDPARTY
diff -u src/doc/3RDPARTY:1.1528 src/doc/3RDPARTY:1.1529
--- src/doc/3RDPARTY:1.1528	Thu Jun  7 05:48:29 2018
+++ src/doc/3RDPARTY	Sun Jun 17 18:10:18 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: 3RDPARTY,v 1.1528 2018/06/07 05:48:29 maya Exp $
+#	$NetBSD: 3RDPARTY,v 1.1529 2018/06/17 18:10:18 alnsn Exp $
 #
 # This file contains a list of the software that has been integrated into
 # NetBSD where we are not the primary maintainer.
@@ -1557,7 +1557,7 @@ Notes:
 
 Package:	sljit
 Version:	svn revision 313
-Current Vers:	svn revision 350
+Current Vers:	svn revision 381
 Maintainer:	Zoltán Herczeg http://sourceforge.net/projects/sljit/
 Home Page:	http://sljit.sourceforge.net/



CVS commit: src/external/mit/lua/dist/src

2018-05-26 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sat May 26 20:17:56 UTC 2018

Modified Files:
src/external/mit/lua/dist/src: luaconf.h

Log Message:
Change LUAL_BUFFERSIZE from 4-8K to 128 bytes for kernel-side Lua.

LUAL_BUFFERSIZE defines how much luaL_Buffer allocates from
the stack. Apparently, 4-8K is too much for the kernel stack.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/external/mit/lua/dist/src/luaconf.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/mit/lua/dist/src/luaconf.h
diff -u src/external/mit/lua/dist/src/luaconf.h:1.21 src/external/mit/lua/dist/src/luaconf.h:1.22
--- src/external/mit/lua/dist/src/luaconf.h:1.21	Wed Apr 26 13:17:33 2017
+++ src/external/mit/lua/dist/src/luaconf.h	Sat May 26 20:17:56 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: luaconf.h,v 1.21 2017/04/26 13:17:33 mbalmer Exp $	*/
+/*	$NetBSD: luaconf.h,v 1.22 2018/05/26 20:17:56 alnsn Exp $	*/
 
 /*
 ** Id: luaconf.h,v 1.259 2016/12/22 13:08:50 roberto Exp 
@@ -757,7 +757,9 @@
 ** smaller buffer would force a memory allocation for each call to
 ** 'string.format'.)
 */
-#if LUA_FLOAT_TYPE == LUA_FLOAT_LONGDOUBLE
+#ifdef _KERNEL
+#define LUAL_BUFFERSIZE		128
+#elif LUA_FLOAT_TYPE == LUA_FLOAT_LONGDOUBLE
 #define LUAL_BUFFERSIZE		8192
 #else
 #define LUAL_BUFFERSIZE   ((int)(0x80 * sizeof(void*) * sizeof(lua_Integer)))



CVS commit: src/sbin/cgdconfig

2018-05-09 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Wed May  9 19:38:46 UTC 2018

Modified Files:
src/sbin/cgdconfig: cgdconfig.c

Log Message:
use explicit_memset(3)


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/sbin/cgdconfig/cgdconfig.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/cgdconfig/cgdconfig.c
diff -u src/sbin/cgdconfig/cgdconfig.c:1.47 src/sbin/cgdconfig/cgdconfig.c:1.48
--- src/sbin/cgdconfig/cgdconfig.c:1.47	Wed May  9 18:18:11 2018
+++ src/sbin/cgdconfig/cgdconfig.c	Wed May  9 19:38:46 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: cgdconfig.c,v 1.47 2018/05/09 18:18:11 alnsn Exp $ */
+/* $NetBSD: cgdconfig.c,v 1.48 2018/05/09 19:38:46 alnsn Exp $ */
 
 /*-
  * Copyright (c) 2002, 2003 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
 #ifndef lint
 __COPYRIGHT("@(#) Copyright (c) 2002, 2003\
  The NetBSD Foundation, Inc.  All rights reserved.");
-__RCSID("$NetBSD: cgdconfig.c,v 1.47 2018/05/09 18:18:11 alnsn Exp $");
+__RCSID("$NetBSD: cgdconfig.c,v 1.48 2018/05/09 19:38:46 alnsn Exp $");
 #endif
 
 #include 
@@ -412,7 +412,7 @@ maybe_getpass(char *prompt)
 		err(EXIT_FAILURE, "failed to read passphrase");
 
 	pass = estrdup(p);
-	memset(buf, 0, sizeof(buf));
+	explicit_memset(buf, 0, sizeof(buf));
 
 	return pass;
 }
@@ -448,7 +448,7 @@ getkey_pkcs5_pbkdf2(const char *target, 
 
 	ret = bits_new(tmp, keylen);
 	kg->kg_key = bits_dup(ret);
-	memset(passp, 0, strlen(passp));
+	explicit_memset(passp, 0, strlen(passp));
 	free(passp);
 	free(tmp);
 	return ret;



CVS commit: src/sbin/cgdconfig

2018-05-09 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Wed May  9 18:18:11 UTC 2018

Modified Files:
src/sbin/cgdconfig: cgdconfig.c

Log Message:
Missed one change when doing a manual merge of my patch with kre's commit.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sbin/cgdconfig/cgdconfig.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/cgdconfig/cgdconfig.c
diff -u src/sbin/cgdconfig/cgdconfig.c:1.46 src/sbin/cgdconfig/cgdconfig.c:1.47
--- src/sbin/cgdconfig/cgdconfig.c:1.46	Wed May  9 18:11:56 2018
+++ src/sbin/cgdconfig/cgdconfig.c	Wed May  9 18:18:11 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: cgdconfig.c,v 1.46 2018/05/09 18:11:56 alnsn Exp $ */
+/* $NetBSD: cgdconfig.c,v 1.47 2018/05/09 18:18:11 alnsn Exp $ */
 
 /*-
  * Copyright (c) 2002, 2003 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
 #ifndef lint
 __COPYRIGHT("@(#) Copyright (c) 2002, 2003\
  The NetBSD Foundation, Inc.  All rights reserved.");
-__RCSID("$NetBSD: cgdconfig.c,v 1.46 2018/05/09 18:11:56 alnsn Exp $");
+__RCSID("$NetBSD: cgdconfig.c,v 1.47 2018/05/09 18:18:11 alnsn Exp $");
 #endif
 
 #include 
@@ -599,7 +599,9 @@ configure(int argc, char **argv, struct 
 	 * a password.
 	 */
 
-	for (kg = p->keygen; pflag == PFLAG_GETPASS && kg; kg = kg->next)
+	for (kg = p->keygen;
+	(pflag & PFLAG_GETPASS_MASK) && kg;
+	kg = kg->next)
 		if ((kg->kg_method == KEYGEN_PKCS5_PBKDF2_SHA1) ||
 		(kg->kg_method == KEYGEN_PKCS5_PBKDF2_OLD )) {
 			loop = 1;



CVS commit: src/sbin/cgdconfig

2018-05-09 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Wed May  9 18:11:56 UTC 2018

Modified Files:
src/sbin/cgdconfig: cgdconfig.8 cgdconfig.c

Log Message:
Add '-e' option (echo the passphrase) and wipe the passphrase after use.

XXX Using memset for wiping isn't a good idea because memset is likely
optimised away by gcc. This should be revisited.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sbin/cgdconfig/cgdconfig.8
cvs rdiff -u -r1.45 -r1.46 src/sbin/cgdconfig/cgdconfig.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/cgdconfig/cgdconfig.8
diff -u src/sbin/cgdconfig/cgdconfig.8:1.38 src/sbin/cgdconfig/cgdconfig.8:1.39
--- src/sbin/cgdconfig/cgdconfig.8:1.38	Wed May  9 17:35:03 2018
+++ src/sbin/cgdconfig/cgdconfig.8	Wed May  9 18:11:56 2018
@@ -1,4 +1,4 @@
-.\" $NetBSD: cgdconfig.8,v 1.38 2018/05/09 17:35:03 wiz Exp $
+.\" $NetBSD: cgdconfig.8,v 1.39 2018/05/09 18:11:56 alnsn Exp $
 .\"
 .\" Copyright (c) 2002, The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -35,17 +35,17 @@
 .Nd configuration utility for the cryptographic disk driver
 .Sh SYNOPSIS
 .Nm
-.Op Fl npv
+.Op Fl enpv
 .Op Fl V Ar vmeth
 .Ar cgd dev
 .Op Ar paramsfile
 .Nm
 .Fl C
-.Op Fl npv
+.Op Fl enpv
 .Op Fl f Ar configfile
 .Nm
 .Fl G
-.Op Fl npv
+.Op Fl enpv
 .Op Fl i Ar ivmeth
 .Op Fl k Ar kgmeth
 .Op Fl o Ar outfile
@@ -89,6 +89,8 @@ The options are as follows:
 .Bl -tag -width configfile
 .It Fl C
 Configure all the devices listed in the cgd configuration file.
+.It Fl e
+Echo the passphase.
 .It Fl f Ar configfile
 Specify the configuration file explicitly, rather than using the default
 configuration file

Index: src/sbin/cgdconfig/cgdconfig.c
diff -u src/sbin/cgdconfig/cgdconfig.c:1.45 src/sbin/cgdconfig/cgdconfig.c:1.46
--- src/sbin/cgdconfig/cgdconfig.c:1.45	Wed May  9 14:27:41 2018
+++ src/sbin/cgdconfig/cgdconfig.c	Wed May  9 18:11:56 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: cgdconfig.c,v 1.45 2018/05/09 14:27:41 kre Exp $ */
+/* $NetBSD: cgdconfig.c,v 1.46 2018/05/09 18:11:56 alnsn Exp $ */
 
 /*-
  * Copyright (c) 2002, 2003 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
 #ifndef lint
 __COPYRIGHT("@(#) Copyright (c) 2002, 2003\
  The NetBSD Foundation, Inc.  All rights reserved.");
-__RCSID("$NetBSD: cgdconfig.c,v 1.45 2018/05/09 14:27:41 kre Exp $");
+__RCSID("$NetBSD: cgdconfig.c,v 1.46 2018/05/09 18:11:56 alnsn Exp $");
 #endif
 
 #include 
@@ -89,8 +89,10 @@ int	nflag = 0;
 
 /* if pflag is set to PFLAG_STDIN read from stdin rather than getpass(3) */
 
-#define	PFLAG_GETPASS	0x01
-#define	PFLAG_STDIN	0x02
+#define	PFLAG_GETPASS		0x01
+#define	PFLAG_GETPASS_ECHO	0x02
+#define	PFLAG_GETPASS_MASK	0x03
+#define	PFLAG_STDIN		0x04
 int	pflag = PFLAG_GETPASS;
 
 static int	configure(int, char **, struct params *, int);
@@ -136,11 +138,11 @@ static void
 usage(void)
 {
 
-	(void)fprintf(stderr, "usage: %s [-npv] [-V vmeth] cgd dev "
+	(void)fprintf(stderr, "usage: %s [-enpv] [-V vmeth] cgd dev "
 	"[paramsfile]\n", getprogname());
-	(void)fprintf(stderr, "   %s -C [-npv] [-f configfile]\n",
+	(void)fprintf(stderr, "   %s -C [-enpv] [-f configfile]\n",
 	getprogname());
-	(void)fprintf(stderr, "   %s -G [-npv] [-i ivmeth] [-k kgmeth] "
+	(void)fprintf(stderr, "   %s -G [-enpv] [-i ivmeth] [-k kgmeth] "
 	"[-o outfile] paramsfile\n", getprogname());
 	(void)fprintf(stderr, "   %s -g [-nv] [-i ivmeth] [-k kgmeth] "
 	"[-o outfile] alg [keylen]\n", getprogname());
@@ -201,7 +203,7 @@ main(int argc, char **argv)
 	p = params_new();
 	kg = NULL;
 
-	while ((ch = getopt(argc, argv, "CGUV:b:f:gi:k:lno:spuv")) != -1)
+	while ((ch = getopt(argc, argv, "CGUV:b:ef:gi:k:lno:spuv")) != -1)
 		switch (ch) {
 		case 'C':
 			set_action(, ACTION_CONFIGALL);
@@ -230,6 +232,9 @@ main(int argc, char **argv)
 p = params_combine(p, tp);
 			}
 			break;
+		case 'e':
+			pflag = PFLAG_GETPASS_ECHO;
+			break;
 		case 'f':
 			if (cfile)
 usage();
@@ -377,12 +382,17 @@ static char *
 maybe_getpass(char *prompt)
 {
 	char	 buf[1024];
-	char	*p = buf;
-	char	*tmp;
+	char	*p = NULL;
+	char	*tmp, *pass;
 
 	switch (pflag) {
 	case PFLAG_GETPASS:
-		p = getpass(prompt);
+		p = getpass_r(prompt, buf, sizeof(buf));
+		break;
+
+	case PFLAG_GETPASS_ECHO:
+		p = getpassfd(prompt, buf, sizeof(buf), NULL,
+		GETPASS_ECHO|GETPASS_ECHO_NL|GETPASS_NEED_TTY, 0);
 		break;
 
 	case PFLAG_STDIN:
@@ -401,7 +411,10 @@ maybe_getpass(char *prompt)
 	if (!p)
 		err(EXIT_FAILURE, "failed to read passphrase");
 
-	return estrdup(p);
+	pass = estrdup(p);
+	memset(buf, 0, sizeof(buf));
+
+	return pass;
 }
 
 /*ARGSUSED*/
@@ -422,7 +435,8 @@ getkey_pkcs5_pbkdf2(const char *target, 
 	char		 buf[1024];
 	u_int8_t	*tmp;
 
-	snprintf(buf, sizeof(buf), "%s's passphrase:", target);
+	snprintf(buf, sizeof(buf), "%s's passphrase%s:", target,
+	pflag & PFLAG_GETPASS_ECHO ? " (echo)" : "");
 	

CVS commit: src/share/man/man9

2018-04-26 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Thu Apr 26 18:56:18 UTC 2018

Modified Files:
src/share/man/man9: secmodel_securelevel.9

Log Message:
Add SVS. It may not be disabled at securelevel 1 and above.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/share/man/man9/secmodel_securelevel.9

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/share/man/man9/secmodel_securelevel.9
diff -u src/share/man/man9/secmodel_securelevel.9:1.15 src/share/man/man9/secmodel_securelevel.9:1.16
--- src/share/man/man9/secmodel_securelevel.9:1.15	Tue Mar 18 18:20:40 2014
+++ src/share/man/man9/secmodel_securelevel.9	Thu Apr 26 18:56:18 2018
@@ -1,4 +1,4 @@
-.\" $NetBSD: secmodel_securelevel.9,v 1.15 2014/03/18 18:20:40 riastradh Exp $
+.\" $NetBSD: secmodel_securelevel.9,v 1.16 2018/04/26 18:56:18 alnsn Exp $
 .\"
 .\" Copyright (c) 2006 Elad Efrat 
 .\" Copyright (c) 2000 Hugh Graham
@@ -26,7 +26,7 @@
 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd November 22, 2012
+.Dd April 26, 2018
 .Dt SECMODEL_SECURELEVEL 9
 .Os
 .Sh NAME
@@ -136,6 +136,8 @@ Access to unmanaged memory is denied.
 Only GPIO pins that have been set at
 .Em securelevel
 0 can be accessed.
+.It
+SVS (Separate Virtual Space) may not be disabled on platforms that support it.
 .El
 .It \ 2 Em Highly secure mode
 .Bl -bullet



CVS commit: src/sys

2018-04-26 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Thu Apr 26 18:54:09 UTC 2018

Modified Files:
src/sys/arch/x86/x86: svs.c
src/sys/secmodel/securelevel: secmodel_securelevel.c
src/sys/secmodel/suser: secmodel_suser.c
src/sys/sys: kauth.h

Log Message:
Add KAUTH_MACHDEP_SVS_DISABLE and add support to secmodel_securelevel(9).

Disabling SVS is denied at securelevel 1 and above.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/x86/x86/svs.c
cvs rdiff -u -r1.30 -r1.31 \
src/sys/secmodel/securelevel/secmodel_securelevel.c
cvs rdiff -u -r1.43 -r1.44 src/sys/secmodel/suser/secmodel_suser.c
cvs rdiff -u -r1.75 -r1.76 src/sys/sys/kauth.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/x86/svs.c
diff -u src/sys/arch/x86/x86/svs.c:1.17 src/sys/arch/x86/x86/svs.c:1.18
--- src/sys/arch/x86/x86/svs.c:1.17	Fri Mar 30 19:58:05 2018
+++ src/sys/arch/x86/x86/svs.c	Thu Apr 26 18:54:09 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: svs.c,v 1.17 2018/03/30 19:58:05 maxv Exp $	*/
+/*	$NetBSD: svs.c,v 1.18 2018/04/26 18:54:09 alnsn Exp $	*/
 
 /*
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: svs.c,v 1.17 2018/03/30 19:58:05 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: svs.c,v 1.18 2018/04/26 18:54:09 alnsn Exp $");
 
 #include "opt_svs.h"
 
@@ -38,6 +38,7 @@ __KERNEL_RCSID(0, "$NetBSD: svs.c,v 1.17
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -737,11 +738,13 @@ sysctl_machdep_svs_enabled(SYSCTLFN_ARGS
 			error = 0;
 		else
 			error = EOPNOTSUPP;
-	} else {
-		if (svs_enabled)
+	} else if (svs_enabled) {
+		error = kauth_authorize_machdep(kauth_cred_get(),
+		KAUTH_MACHDEP_SVS_DISABLE, NULL, NULL, NULL, NULL);
+		if (!error)
 			error = svs_disable();
-		else
-			error = 0;
+	} else {
+		error = 0;
 	}
 
 	return error;

Index: src/sys/secmodel/securelevel/secmodel_securelevel.c
diff -u src/sys/secmodel/securelevel/secmodel_securelevel.c:1.30 src/sys/secmodel/securelevel/secmodel_securelevel.c:1.31
--- src/sys/secmodel/securelevel/secmodel_securelevel.c:1.30	Tue Feb 25 18:30:13 2014
+++ src/sys/secmodel/securelevel/secmodel_securelevel.c	Thu Apr 26 18:54:09 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: secmodel_securelevel.c,v 1.30 2014/02/25 18:30:13 pooka Exp $ */
+/* $NetBSD: secmodel_securelevel.c,v 1.31 2018/04/26 18:54:09 alnsn Exp $ */
 /*-
  * Copyright (c) 2006 Elad Efrat 
  * All rights reserved.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: secmodel_securelevel.c,v 1.30 2014/02/25 18:30:13 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: secmodel_securelevel.c,v 1.31 2018/04/26 18:54:09 alnsn Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_insecure.h"
@@ -494,6 +494,11 @@ secmodel_securelevel_machdep_cb(kauth_cr
 			result = KAUTH_RESULT_DENY;
 		break;
 
+	case KAUTH_MACHDEP_SVS_DISABLE:
+		if (securelevel > 0)
+			result = KAUTH_RESULT_DENY;
+		break;
+
 	case KAUTH_MACHDEP_CPU_UCODE_APPLY:
 		if (securelevel > 1)
 			result = KAUTH_RESULT_DENY;

Index: src/sys/secmodel/suser/secmodel_suser.c
diff -u src/sys/secmodel/suser/secmodel_suser.c:1.43 src/sys/secmodel/suser/secmodel_suser.c:1.44
--- src/sys/secmodel/suser/secmodel_suser.c:1.43	Wed Jun 14 17:48:41 2017
+++ src/sys/secmodel/suser/secmodel_suser.c	Thu Apr 26 18:54:09 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: secmodel_suser.c,v 1.43 2017/06/14 17:48:41 maxv Exp $ */
+/* $NetBSD: secmodel_suser.c,v 1.44 2018/04/26 18:54:09 alnsn Exp $ */
 /*-
  * Copyright (c) 2006 Elad Efrat 
  * All rights reserved.
@@ -38,7 +38,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: secmodel_suser.c,v 1.43 2017/06/14 17:48:41 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: secmodel_suser.c,v 1.44 2018/04/26 18:54:09 alnsn Exp $");
 
 #include 
 #include 
@@ -854,6 +854,7 @@ secmodel_suser_machdep_cb(kauth_cred_t c
 	case KAUTH_MACHDEP_UNMANAGEDMEM:
 	case KAUTH_MACHDEP_PXG:
 	case KAUTH_MACHDEP_X86PMC:
+	case KAUTH_MACHDEP_SVS_DISABLE:
 		if (isroot)
 			result = KAUTH_RESULT_ALLOW;
 		break;

Index: src/sys/sys/kauth.h
diff -u src/sys/sys/kauth.h:1.75 src/sys/sys/kauth.h:1.76
--- src/sys/sys/kauth.h:1.75	Mon Aug 28 00:46:07 2017
+++ src/sys/sys/kauth.h	Thu Apr 26 18:54:09 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: kauth.h,v 1.75 2017/08/28 00:46:07 kamil Exp $ */
+/* $NetBSD: kauth.h,v 1.76 2018/04/26 18:54:09 alnsn Exp $ */
 
 /*-
  * Copyright (c) 2005, 2006 Elad Efrat   
@@ -320,7 +320,8 @@ enum {
 	KAUTH_MACHDEP_NVRAM,
 	KAUTH_MACHDEP_UNMANAGEDMEM,
 	KAUTH_MACHDEP_PXG,
-	KAUTH_MACHDEP_X86PMC
+	KAUTH_MACHDEP_X86PMC,
+	KAUTH_MACHDEP_SVS_DISABLE
 };
 
 /*



CVS commit: src/share/misc

2018-01-21 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sun Jan 21 14:01:55 UTC 2018

Modified Files:
src/share/misc: acronyms.comp

Log Message:
Add KASLR.


To generate a diff of this commit:
cvs rdiff -u -r1.188 -r1.189 src/share/misc/acronyms.comp

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/share/misc/acronyms.comp
diff -u src/share/misc/acronyms.comp:1.188 src/share/misc/acronyms.comp:1.189
--- src/share/misc/acronyms.comp:1.188	Wed Jan 10 08:47:30 2018
+++ src/share/misc/acronyms.comp	Sun Jan 21 14:01:55 2018
@@ -1,4 +1,4 @@
-$NetBSD: acronyms.comp,v 1.188 2018/01/10 08:47:30 pgoyette Exp $
+$NetBSD: acronyms.comp,v 1.189 2018/01/21 14:01:55 alnsn Exp $
 3WHS	three-way handshake
 8VSB	8-state vestigial side band modulation
 AA	anti-aliasing
@@ -650,6 +650,7 @@ JIT	just in time
 JPEG	Joint Photographic Experts Group
 JRE	Java Runtime Environment
 JTAG	joint test action group
+KASLR	kernel address space layout randomization
 KB	keyboard
 KB	kilobyte
 KBD	keyboard



CVS commit: src/lib/libc/cdb

2017-11-11 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sat Nov 11 18:05:31 UTC 2017

Modified Files:
src/lib/libc/cdb: cdbw.c

Log Message:
Use a more efficient data structure for graph peeling.

New code is about 50% faster on amd64 and it consumes less memory.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/lib/libc/cdb/cdbw.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/cdb/cdbw.c
diff -u src/lib/libc/cdb/cdbw.c:1.5 src/lib/libc/cdb/cdbw.c:1.6
--- src/lib/libc/cdb/cdbw.c:1.5	Sat Jul 21 22:49:37 2012
+++ src/lib/libc/cdb/cdbw.c	Sat Nov 11 18:05:31 2017
@@ -1,10 +1,10 @@
-/*	$NetBSD: cdbw.c,v 1.5 2012/07/21 22:49:37 joerg Exp $	*/
+/*	$NetBSD: cdbw.c,v 1.6 2017/11/11 18:05:31 alnsn Exp $	*/
 /*-
- * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
+ * Copyright (c) 2009, 2010, 2015 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
- * by Joerg Sonnenberger.
+ * by Joerg Sonnenberger and Alexander Nasonov.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -36,7 +36,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: cdbw.c,v 1.5 2012/07/21 22:49:37 joerg Exp $");
+__RCSID("$NetBSD: cdbw.c,v 1.6 2017/11/11 18:05:31 alnsn Exp $");
 
 #include "namespace.h"
 
@@ -278,18 +278,31 @@ cdbw_stable_seeder(void)
 	return 0;
 }
 
-#define unused 0xU
+/*
+ * The algorithm below is based on paper
+ * Cache-Oblivious Peeling of Random Hypergraphs by Djamal Belazzougui,
+ * Paolo Boldi, Giuseppe Ottaviano, Rossano Venturini, and Sebastiano
+ * Vigna.
+ * http://zola.di.unipi.it/rossano/wp-content/papercite-data/pdf/dcc14.pdf
+ */
 
-struct vertex {
-	uint32_t l_edge, m_edge, r_edge;
+/*
+ * Data type for a valid oriented edge (v0, v1, v2), v1 < v2.
+ * The first vertex v0 is implicit and is determined by an index
+ * of the corresponding element in the state->oedges array.
+ * If the degree of v0 is greater than 1, other members don't
+ * make sense because they're a result of XORing multiple values.
+ */
+struct oedge {
+	uint32_t degree;   /* Degree of v0. */
+	uint32_t verts[2]; /* v1 and v2 */
+	uint32_t edge;
 };
 
 struct edge {
 	uint32_t idx;
 
 	uint32_t left, middle, right;
-	uint32_t l_prev, m_prev, l_next;
-	uint32_t r_prev, m_next, r_next;
 };
 
 struct state {
@@ -301,69 +314,49 @@ struct state {
 	uint32_t *g;
 	char *visited;
 
-	struct vertex *verts;
+	struct oedge *oedges;
 	struct edge *edges;
 	uint32_t output_index;
 	uint32_t *output_order;
 };
 
-static void
-remove_vertex(struct state *state, struct vertex *v)
+/*
+ * Add (delta == 1) or remove (delta == -1) the edge e from vertex v0.
+ */
+static inline void
+add_remove_edge(struct oedge *o, int delta, uint32_t e,
+uint32_t v0, uint32_t v1, uint32_t v2)
 {
-	struct edge *e;
-	struct vertex *vl, *vm, *vr;
 
-	if (v->l_edge != unused && v->m_edge != unused)
-		return;
-	if (v->l_edge != unused && v->r_edge != unused)
-		return;
-	if (v->m_edge != unused && v->r_edge != unused)
-		return;
-	if (v->l_edge == unused && v->m_edge == unused && v->r_edge == unused)
-		return;
-
-	if (v->l_edge != unused) {
-		e = >edges[v->l_edge];
-		if (e->l_next != unused)
-			return;
-	} else if (v->m_edge != unused) {
-		e = >edges[v->m_edge];
-		if (e->m_next != unused)
-			return;
-	} else {
-		if (v->r_edge == unused)
-			abort();
-		e = >edges[v->r_edge];
-		if (e->r_next != unused)
-			return;
-	}
-
-	state->output_order[--state->output_index] = e - state->edges;
-
-	vl = >verts[e->left];
-	vm = >verts[e->middle];
-	vr = >verts[e->right];
+	o[v0].verts[v1 < v2 ? 0 : 1] ^= v1;
+	o[v0].verts[v1 < v2 ? 1 : 0] ^= v2;
+	o[v0].degree += delta;
+	o[v0].edge ^= e;
+}
 
-	if (e->l_prev == unused)
-		vl->l_edge = e->l_next;
-	else
-		state->edges[e->l_prev].l_next = e->l_next;
-	if (e->l_next != unused)
-		state->edges[e->l_next].l_prev = e->l_prev;
+static inline void
+add_edge(struct oedge *o, uint32_t e,
+uint32_t v0, uint32_t v1, uint32_t v2)
+{
 
-	if (e->m_prev == unused)
-		vm->m_edge = e->m_next;
-	else
-		state->edges[e->m_prev].m_next = e->m_next;
-	if (e->m_next != unused)
-		state->edges[e->m_next].m_prev = e->m_prev;
+	add_remove_edge(o, 1, e, v0, v1, v2);
+}
 
-	if (e->r_prev == unused)
-		vr->r_edge = e->r_next;
-	else
-		state->edges[e->r_prev].r_next = e->r_next;
-	if (e->r_next != unused)
-		state->edges[e->r_next].r_prev = e->r_prev;
+static inline void
+remove_vertex(struct state *state, uint32_t v0)
+{
+	uint32_t e, v1, v2;
+	struct oedge *o = state->oedges;
+
+	if 

CVS commit: src/doc

2017-07-25 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Tue Jul 25 10:43:41 UTC 2017

Modified Files:
src/doc: 3RDPARTY

Log Message:
Current sljit version is r350.


To generate a diff of this commit:
cvs rdiff -u -r1.1456 -r1.1457 src/doc/3RDPARTY

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/doc/3RDPARTY
diff -u src/doc/3RDPARTY:1.1456 src/doc/3RDPARTY:1.1457
--- src/doc/3RDPARTY:1.1456	Wed Jul  5 11:22:18 2017
+++ src/doc/3RDPARTY	Tue Jul 25 10:43:40 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: 3RDPARTY,v 1.1456 2017/07/05 11:22:18 wiz Exp $
+#	$NetBSD: 3RDPARTY,v 1.1457 2017/07/25 10:43:40 alnsn Exp $
 #
 # This file contains a list of the software that has been integrated into
 # NetBSD where we are not the primary maintainer.
@@ -1557,7 +1557,7 @@ Notes:
 
 Package:	sljit
 Version:	svn revision 313
-Current Vers:	svn revision 313
+Current Vers:	svn revision 350
 Maintainer:	Zoltán Herczeg 

CVS commit: src/libexec/httpd

2017-05-28 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sun May 28 22:37:36 UTC 2017

Modified Files:
src/libexec/httpd: lua-bozo.c

Log Message:
Cosmetic changes to Lua binding in bozohttpd.

- Don't use negative indicies to read arguments of Lua functions.
- On error, return nil, "error string".
- Use ssize_t for return values from bozo_read() and bozo_write().
- Prefer lstring especially when if saves you from appending NUL and
  doing len + 1 which can potentially wraparound.
- Don't mix C allocations with Lua functions marked with "m" in the Lua
  manual. Those functions may throw (longjump) and leak data allocated
  by C function. In one case, I use luaL_Buffer, in the other case,
  I rearranged calls a bit.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/libexec/httpd/lua-bozo.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/libexec/httpd/lua-bozo.c
diff -u src/libexec/httpd/lua-bozo.c:1.14 src/libexec/httpd/lua-bozo.c:1.15
--- src/libexec/httpd/lua-bozo.c:1.14	Mon Dec 28 07:37:59 2015
+++ src/libexec/httpd/lua-bozo.c	Sun May 28 22:37:36 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lua-bozo.c,v 1.14 2015/12/28 07:37:59 mrg Exp $	*/
+/*	$NetBSD: lua-bozo.c,v 1.15 2017/05/28 22:37:36 alnsn Exp $	*/
 
 /*
  * Copyright (c) 2013 Marc Balmer 
@@ -51,8 +51,8 @@
 
 #define FORM	"application/x-www-form-urlencoded"
 
-static int
-lua_flush(lua_State *L)
+static bozohttpd_t *
+httpd_instance(lua_State *L)
 {
 	bozohttpd_t *httpd;
 
@@ -61,6 +61,14 @@ lua_flush(lua_State *L)
 	httpd = lua_touserdata(L, -1);
 	lua_pop(L, 1);
 
+	return httpd;
+}
+
+static int
+lua_flush(lua_State *L)
+{
+	bozohttpd_t *httpd = httpd_instance(L);
+
 	bozo_flush(httpd, stdout);
 	return 0;
 }
@@ -68,63 +76,57 @@ lua_flush(lua_State *L)
 static int
 lua_print(lua_State *L)
 {
-	bozohttpd_t *httpd;
-
-	lua_pushstring(L, "bozohttpd");
-	lua_gettable(L, LUA_REGISTRYINDEX);
-	httpd = lua_touserdata(L, -1);
-	lua_pop(L, 1);
+	bozohttpd_t *httpd = httpd_instance(L);
 
-	bozo_printf(httpd, "%s\r\n", lua_tostring(L, -1));
+	bozo_printf(httpd, "%s\r\n", lua_tostring(L, 1));
 	return 0;
 }
 
 static int
 lua_read(lua_State *L)
 {
-	bozohttpd_t *httpd;
-	int n, len;
+	bozohttpd_t *httpd = httpd_instance(L);
+	luaL_Buffer lbuf;
 	char *data;
+	lua_Integer len;
+	ssize_t n;
 
-	lua_pushstring(L, "bozohttpd");
-	lua_gettable(L, LUA_REGISTRYINDEX);
-	httpd = lua_touserdata(L, -1);
-	lua_pop(L, 1);
+	len = luaL_checkinteger(L, 1);
+	data = luaL_buffinitsize(L, , (size_t)len);
 
-	len = luaL_checkinteger(L, -1);
-	data = bozomalloc(httpd, len + 1);
-	n = bozo_read(httpd, STDIN_FILENO, data, len);
-	if (n >= 0) {
-		data[n] = '\0';
-		lua_pushstring(L, data);
-	} else
+	if ((n = bozo_read(httpd, STDIN_FILENO, data, len)) >= 0) {
+		luaL_pushresultsize(, n);
+		return 1;
+	} else {
 		lua_pushnil(L);
-	free(data);
-	return 1;
+		lua_pushstring(L, "bozo_read() call failed");
+		return 2;
+	}
 }
 
 static int
 lua_register_handler(lua_State *L)
 {
+	bozohttpd_t *httpd = httpd_instance(L);
 	lua_state_map_t *map;
 	lua_handler_t *handler;
-	bozohttpd_t *httpd;
+	const char *name;
+	int ref;
 
 	lua_pushstring(L, "lua_state_map");
 	lua_gettable(L, LUA_REGISTRYINDEX);
 	map = lua_touserdata(L, -1);
-	lua_pushstring(L, "bozohttpd");
-	lua_gettable(L, LUA_REGISTRYINDEX);
-	httpd = lua_touserdata(L, -1);
-	lua_pop(L, 2);
+	lua_pop(L, 1);
+
+	name = luaL_checkstring(L, 1);
 
-	luaL_checkstring(L, 1);
 	luaL_checktype(L, 2, LUA_TFUNCTION);
+	lua_pushvalue(L, 2);
+	ref = luaL_ref(L, LUA_REGISTRYINDEX);
 
 	handler = bozomalloc(httpd, sizeof(lua_handler_t));
-
-	handler->name = bozostrdup(httpd, NULL, lua_tostring(L, 1));
-	handler->ref = luaL_ref(L, LUA_REGISTRYINDEX);
+	handler->name = bozostrdup(httpd, NULL, name);
+	handler->ref = ref;
 	SIMPLEQ_INSERT_TAIL(>handlers, handler, h_next);
 	httpd->process_lua = 1;
 	return 0;
@@ -133,23 +135,26 @@ lua_register_handler(lua_State *L)
 static int
 lua_write(lua_State *L)
 {
-	bozohttpd_t *httpd;
+	bozohttpd_t *httpd = httpd_instance(L);
 	const char *data;
+	size_t len;
+	ssize_t n;
 
-	lua_pushstring(L, "bozohttpd");
-	lua_gettable(L, LUA_REGISTRYINDEX);
-	httpd = lua_touserdata(L, -1);
-	lua_pop(L, 1);
-
-	data = luaL_checkstring(L, -1);
-	lua_pushinteger(L, bozo_write(httpd, STDIN_FILENO, data, strlen(data)));
-	return 1;
+	data = luaL_checklstring(L, 1, );
+	if ((n = bozo_write(httpd, STDIN_FILENO, data, len)) >= 0) {
+		lua_pushinteger(L, n);
+		return 1;
+	} else {
+		lua_pushnil(L);
+		lua_pushstring(L, "bozo_write() call failed");
+		return 2;
+	}
 }
 
 static int
 luaopen_httpd(lua_State *L)
 {
-	struct luaL_Reg functions[] = {
+	static struct luaL_Reg functions[] = {
 		{ "flush",		lua_flush },
 		{ "print",		lua_print },
 		{ "read",		lua_read },



CVS commit: src/sys/dev

2017-01-02 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Mon Jan  2 14:28:29 UTC 2017

Modified Files:
src/sys/dev: cgd_crypto.c cgd_crypto.h

Log Message:
Replace numeric block sizes with symbolic names,

No functional change. Requested by mrg a couple of months ago.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/cgd_crypto.c
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/cgd_crypto.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/cgd_crypto.c
diff -u src/sys/dev/cgd_crypto.c:1.14 src/sys/dev/cgd_crypto.c:1.15
--- src/sys/dev/cgd_crypto.c:1.14	Sun Dec 11 00:20:49 2016
+++ src/sys/dev/cgd_crypto.c	Mon Jan  2 14:28:29 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: cgd_crypto.c,v 1.14 2016/12/11 00:20:49 alnsn Exp $ */
+/* $NetBSD: cgd_crypto.c,v 1.15 2017/01/02 14:28:29 alnsn Exp $ */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cgd_crypto.c,v 1.14 2016/12/11 00:20:49 alnsn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cgd_crypto.c,v 1.15 2017/01/02 14:28:29 alnsn Exp $");
 
 #include 
 #include 
@@ -199,7 +199,7 @@ struct aes_privdata {
 
 struct aes_encdata {
 	keyInstance	*ae_key;	/* key for this direction */
-	u_int8_t	 ae_iv[16];	/* Initialization Vector */
+	u_int8_t	 ae_iv[CGD_AES_BLOCK_SIZE]; /* Initialization Vector */
 };
 
 static void *
@@ -244,8 +244,10 @@ cgd_cipher_aes_cbc_prep(void *privdata, 
 	KASSERT(cipher_ok > 0);
 	rijndael_blockEncrypt(, >ap_enckey,
 	blkno_buf, blocksize * 8, iv);
-	if (blocksize > 16)
-		(void)memmove(iv, iv + blocksize - 16, 16);
+	if (blocksize > CGD_AES_BLOCK_SIZE) {
+		(void)memmove(iv, iv + blocksize - CGD_AES_BLOCK_SIZE,
+		CGD_AES_BLOCK_SIZE);
+	}
 }
 
 static void
@@ -258,7 +260,8 @@ aes_cbc_enc_int(void *privdata, void *ds
 	cipher_ok = rijndael_cipherInit(, MODE_CBC, ae->ae_iv);
 	KASSERT(cipher_ok > 0);
 	rijndael_blockEncrypt(, ae->ae_key, src, len * 8, dst);
-	(void)memcpy(ae->ae_iv, (u_int8_t *)dst + (len - 16), 16);
+	(void)memcpy(ae->ae_iv, (u_int8_t *)dst +
+	(len - CGD_AES_BLOCK_SIZE), CGD_AES_BLOCK_SIZE);
 }
 
 static void
@@ -271,7 +274,8 @@ aes_cbc_dec_int(void *privdata, void *ds
 	cipher_ok = rijndael_cipherInit(, MODE_CBC, ae->ae_iv);
 	KASSERT(cipher_ok > 0);
 	rijndael_blockDecrypt(, ae->ae_key, src, len * 8, dst);
-	(void)memcpy(ae->ae_iv, (const u_int8_t *)src + (len - 16), 16);
+	(void)memcpy(ae->ae_iv, (const u_int8_t *)src +
+	(len - CGD_AES_BLOCK_SIZE), CGD_AES_BLOCK_SIZE);
 }
 
 static void
@@ -281,7 +285,7 @@ cgd_cipher_aes_cbc(void *privdata, struc
 	struct aes_privdata	*apd = privdata;
 	struct aes_encdata	 encd;
 
-	(void)memcpy(encd.ae_iv, iv, 16);
+	(void)memcpy(encd.ae_iv, iv, CGD_AES_BLOCK_SIZE);
 	switch (dir) {
 	case CGD_CIPHER_ENCRYPT:
 		encd.ae_key = >ap_enckey;
@@ -358,7 +362,7 @@ aes_xts_enc_int(void *privdata, void *ds
 	cipher_ok = rijndael_cipherInit(, MODE_XTS, ae->ae_iv);
 	KASSERT(cipher_ok > 0);
 	rijndael_blockEncrypt(, ae->ae_key, src, len * 8, dst);
-	(void)memcpy(ae->ae_iv, cipher.IV, 16);
+	(void)memcpy(ae->ae_iv, cipher.IV, CGD_AES_BLOCK_SIZE);
 }
 
 static void
@@ -371,7 +375,7 @@ aes_xts_dec_int(void *privdata, void *ds
 	cipher_ok = rijndael_cipherInit(, MODE_XTS, ae->ae_iv);
 	KASSERT(cipher_ok > 0);
 	rijndael_blockDecrypt(, ae->ae_key, src, len * 8, dst);
-	(void)memcpy(ae->ae_iv, cipher.IV, 16);
+	(void)memcpy(ae->ae_iv, cipher.IV, CGD_AES_BLOCK_SIZE);
 }
 
 static void
@@ -381,7 +385,7 @@ cgd_cipher_aes_xts(void *privdata, struc
 	struct aes_privdata	*apd = privdata;
 	struct aes_encdata	 encd;
 
-	(void)memcpy(encd.ae_iv, iv, 16);
+	(void)memcpy(encd.ae_iv, iv, CGD_AES_BLOCK_SIZE);
 	switch (dir) {
 	case CGD_CIPHER_ENCRYPT:
 		encd.ae_key = >ap_enckey;
@@ -410,7 +414,7 @@ struct c3des_encdata {
 	des_key_schedule	*ce_key1;
 	des_key_schedule	*ce_key2;
 	des_key_schedule	*ce_key3;
-	u_int8_t		ce_iv[8];
+	u_int8_t		ce_iv[CGD_3DES_BLOCK_SIZE];
 };
 
 static void *
@@ -455,13 +459,15 @@ cgd_cipher_3des_cbc_prep(void *privdata,
 const char *blkno_buf, size_t blocksize, int dir)
 {
 	struct	c3des_privdata *cp = privdata;
-	char	zero_iv[8];
+	char	zero_iv[CGD_3DES_BLOCK_SIZE];
 
 	memset(zero_iv, 0, sizeof(zero_iv));
 	des_ede3_cbc_encrypt(blkno_buf, iv, blocksize,
 	cp->cp_key1, cp->cp_key2, cp->cp_key3, (des_cblock *)zero_iv, 1);
-	if (blocksize > 8)
-		(void)memmove(iv, iv + blocksize - 8, 8);
+	if (blocksize > CGD_3DES_BLOCK_SIZE) {
+		(void)memmove(iv, iv + blocksize - CGD_3DES_BLOCK_SIZE,
+		CGD_3DES_BLOCK_SIZE);
+	}
 }
 
 static void
@@ -471,7 +477,8 @@ c3des_cbc_enc_int(void *privdata, void *
 
 	des_ede3_cbc_encrypt(src, dst, len, *ce->ce_key1, *ce->ce_key2,
 	*ce->ce_key3, (des_cblock *)ce->ce_iv, 1);
-	(void)memcpy(ce->ce_iv, (const u_int8_t *)dst + (len - 8), 8);
+	(void)memcpy(ce->ce_iv, (const u_int8_t *)dst +
+	(len - CGD_3DES_BLOCK_SIZE), CGD_3DES_BLOCK_SIZE);
 }
 
 

CVS commit: src/usr.sbin/sysinst

2016-12-10 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sun Dec 11 00:56:34 UTC 2016

Modified Files:
src/usr.sbin/sysinst: menus.mi partman.c

Log Message:
Add aes-xts to sysinst(8).


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/usr.sbin/sysinst/menus.mi
cvs rdiff -u -r1.13 -r1.14 src/usr.sbin/sysinst/partman.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/sysinst/menus.mi
diff -u src/usr.sbin/sysinst/menus.mi:1.10 src/usr.sbin/sysinst/menus.mi:1.11
--- src/usr.sbin/sysinst/menus.mi:1.10	Mon May 11 13:07:57 2015
+++ src/usr.sbin/sysinst/menus.mi	Sun Dec 11 00:56:34 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: menus.mi,v 1.10 2015/05/11 13:07:57 martin Exp $	*/
+/*	$NetBSD: menus.mi,v 1.11 2016/12/11 00:56:34 alnsn Exp $	*/
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -731,6 +731,7 @@ menu raidlevel;
 	option MSG_raid5, exit, action { *(int *)arg = 5; };
 
 menu cgd_enctype;
+	option "aes-xts",			exit, action { *(const char**)arg = "aes-xts"; };
 	option "aes-cbc",			exit, action { *(const char**)arg = "aes-cbc"; };
 	option "3des-cbc",			exit, action { *(const char**)arg = "3des-cbc"; };
 	option "blowfish-cbc",		exit, action { *(const char**)arg = "blowfish-cbc"; };

Index: src/usr.sbin/sysinst/partman.c
diff -u src/usr.sbin/sysinst/partman.c:1.13 src/usr.sbin/sysinst/partman.c:1.14
--- src/usr.sbin/sysinst/partman.c:1.13	Mon May 30 17:03:21 2016
+++ src/usr.sbin/sysinst/partman.c	Sun Dec 11 00:56:34 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: partman.c,v 1.13 2016/05/30 17:03:21 dholland Exp $ */
+/*	$NetBSD: partman.c,v 1.14 2016/12/11 00:56:34 alnsn Exp $ */
 
 /*
  * Copyright 2012 Eugene Lozovoy
@@ -1023,12 +1023,19 @@ pm_cgd_set_value(menudesc *m, void *arg)
 		case PMC_MENU_ENCTYPE:
 			process_menu(MENU_cgd_enctype, );
 			dev_ptr->enc_type = retstring;
+			if (! strcmp(retstring, "aes-xts"))
+dev_ptr->key_size = 256;
+			if (! strcmp(retstring, "aes-cbc"))
+dev_ptr->key_size = 192;
 			if (! strcmp(retstring, "blowfish-cbc"))
 dev_ptr->key_size = 128;
 			if (! strcmp(retstring, "3des-cbc"))
 dev_ptr->key_size = 192;
 			return 0;
 		case PMC_MENU_KEYSIZE:
+			if (! strcmp(dev_ptr->enc_type, "aes-xts"))
+dev_ptr->key_size +=
+	(dev_ptr->key_size < 512)? 256 : -256;
 			if (! strcmp(dev_ptr->enc_type, "aes-cbc"))
 dev_ptr->key_size +=
 	(dev_ptr->key_size < 256)? 64 : -128;
@@ -1071,9 +1078,9 @@ pm_cgd_init(void *arg1, void *arg2)
 		.pm_part = 0,
 		.keygen_type = "pkcs5_pbkdf2/sha1",
 		.verify_type = "disklabel",
-		.enc_type = "aes-cbc",
+		.enc_type = "aes-xts",
 		.iv_type = "encblkno1",
-		.key_size = 192,
+		.key_size = 256,
 	};
 	if (disk_entrie != NULL) {
 		pm_getdevstring(disk_entrie->fullname, SSTRSIZE,



CVS commit: src/sbin/cgdconfig

2016-12-10 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sun Dec 11 00:34:39 UTC 2016

Modified Files:
src/sbin/cgdconfig: params.c

Log Message:
Add aes-xts to cgdconfig(8).


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sbin/cgdconfig/params.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/cgdconfig/params.c
diff -u src/sbin/cgdconfig/params.c:1.28 src/sbin/cgdconfig/params.c:1.29
--- src/sbin/cgdconfig/params.c:1.28	Tue Nov 24 14:07:18 2015
+++ src/sbin/cgdconfig/params.c	Sun Dec 11 00:34:39 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: params.c,v 1.28 2015/11/24 14:07:18 christos Exp $ */
+/* $NetBSD: params.c,v 1.29 2016/12/11 00:34:39 alnsn Exp $ */
 
 /*-
  * Copyright (c) 2002, 2003 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: params.c,v 1.28 2015/11/24 14:07:18 christos Exp $");
+__RCSID("$NetBSD: params.c,v 1.29 2016/12/11 00:34:39 alnsn Exp $");
 #endif
 
 #include 
@@ -70,6 +70,7 @@ static struct crypto_defaults {
 	int	keylen;
 } crypto_defaults[] = {
 	{ "aes-cbc",		128 },
+	{ "aes-xts",		256 },
 	{ "3des-cbc",		192 },
 	{ "blowfish-cbc",	128 }
 };



CVS commit: src/sys/crypto/rijndael

2016-12-10 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sun Dec 11 00:28:45 UTC 2016

Modified Files:
src/sys/crypto/rijndael: rijndael-api-fst.c rijndael-api-fst.h

Log Message:
Add XTS mode.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/crypto/rijndael/rijndael-api-fst.c
cvs rdiff -u -r1.8 -r1.9 src/sys/crypto/rijndael/rijndael-api-fst.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/crypto/rijndael/rijndael-api-fst.c
diff -u src/sys/crypto/rijndael/rijndael-api-fst.c:1.24 src/sys/crypto/rijndael/rijndael-api-fst.c:1.25
--- src/sys/crypto/rijndael/rijndael-api-fst.c:1.24	Sat May 14 16:46:55 2011
+++ src/sys/crypto/rijndael/rijndael-api-fst.c	Sun Dec 11 00:28:44 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: rijndael-api-fst.c,v 1.24 2011/05/14 16:46:55 jmmv Exp $	*/
+/*	$NetBSD: rijndael-api-fst.c,v 1.25 2016/12/11 00:28:44 alnsn Exp $	*/
 
 /**
  * rijndael-api-fst.c
@@ -38,7 +38,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rijndael-api-fst.c,v 1.24 2011/05/14 16:46:55 jmmv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rijndael-api-fst.c,v 1.25 2016/12/11 00:28:44 alnsn Exp $");
 
 #include 
 #ifdef _KERNEL
@@ -52,6 +52,8 @@ __KERNEL_RCSID(0, "$NetBSD: rijndael-api
 #include 
 #include 
 
+#define XTS_ALPHA 0x87
+
 static void xor16(uint8_t *d, const uint8_t *a, const uint8_t* b)
 {
 	for (size_t i = 0; i < 4; i++) {
@@ -62,6 +64,22 @@ static void xor16(uint8_t *d, const uint
 	}
 }
 
+static void
+xts_exponentiate(uint8_t *iv)
+{
+	unsigned int carry = 0;
+
+	for (size_t i = 0; i < 16; i++) {
+		unsigned int msb = iv[i] >> 7;
+
+		iv[i] = (iv[i] << 1) | carry;
+		carry = msb;
+	}
+
+	if (carry != 0)
+		iv[0] ^= XTS_ALPHA;
+}
+
 int
 rijndael_makeKey(keyInstance *key, BYTE direction, int keyLen,
 const char *keyMaterial)
@@ -102,7 +120,8 @@ rijndael_makeKey(keyInstance *key, BYTE 
 int
 rijndael_cipherInit(cipherInstance *cipher, BYTE mode, const char *IV)
 {
-	if ((mode == MODE_ECB) || (mode == MODE_CBC) || (mode == MODE_CFB1)) {
+	if ((mode == MODE_ECB) || (mode == MODE_CBC) ||
+	(mode == MODE_XTS) || (mode == MODE_CFB1)) {
 		cipher->mode = mode;
 	} else {
 		return BAD_CIPHER_MODE;
@@ -153,6 +172,18 @@ rijndael_blockEncrypt(cipherInstance *ci
 		}
 		break;
 
+	case MODE_XTS:
+		iv = (u_int8_t *)cipher->IV;
+		for (i = numBlocks; i > 0; i--) {
+			xor16(block, input, iv);
+			rijndaelEncrypt(key->rk, key->Nr, block, block);
+			xor16(outBuffer, block, iv);
+			xts_exponentiate(iv);
+			input += 16;
+			outBuffer += 16;
+		}
+		break;
+
 	case MODE_CFB1:
 		iv = (u_int8_t *)cipher->IV;
 		for (i = numBlocks; i > 0; i--) {
@@ -284,7 +315,19 @@ rijndael_blockDecrypt(cipherInstance *ci
 		}
 		break;
 
-case MODE_CFB1:
+	case MODE_XTS:
+		iv = (u_int8_t *)cipher->IV;
+		for (i = numBlocks; i > 0; i--) {
+			xor16(block, input, iv);
+			rijndaelDecrypt(key->rk, key->Nr, block, block);
+			xor16(outBuffer, block, iv);
+			xts_exponentiate(iv);
+			input += 16;
+			outBuffer += 16;
+		}
+		break;
+
+	case MODE_CFB1:
 		iv = (u_int8_t *)cipher->IV;
 		for (i = numBlocks; i > 0; i--) {
 			memcpy(outBuffer, input, 16);

Index: src/sys/crypto/rijndael/rijndael-api-fst.h
diff -u src/sys/crypto/rijndael/rijndael-api-fst.h:1.8 src/sys/crypto/rijndael/rijndael-api-fst.h:1.9
--- src/sys/crypto/rijndael/rijndael-api-fst.h:1.8	Sun Jan 21 23:00:08 2007
+++ src/sys/crypto/rijndael/rijndael-api-fst.h	Sun Dec 11 00:28:44 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: rijndael-api-fst.h,v 1.8 2007/01/21 23:00:08 cbiere Exp $	*/
+/*	$NetBSD: rijndael-api-fst.h,v 1.9 2016/12/11 00:28:44 alnsn Exp $	*/
 
 /**
  * rijndael-api-fst.h
@@ -48,6 +48,7 @@
 #define MODE_ECB  1 /*  Are we ciphering in ECB mode?   */
 #define MODE_CBC  2 /*  Are we ciphering in CBC mode?   */
 #define MODE_CFB1 3 /*  Are we ciphering in 1-bit CFB mode? */
+#define MODE_XTS  4 /*  Are we ciphering in XTS mode? */
 #define TRUE  1
 #define FALSE 0
 #define BITSPERBLOCK128 /* Default number of bits in a cipher block */



CVS commit: src/doc

2016-12-10 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sun Dec 11 00:25:32 UTC 2016

Modified Files:
src/doc: CHANGES

Log Message:
Added aes-xts to cgd(4).


To generate a diff of this commit:
cvs rdiff -u -r1.2219 -r1.2220 src/doc/CHANGES

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/doc/CHANGES
diff -u src/doc/CHANGES:1.2219 src/doc/CHANGES:1.2220
--- src/doc/CHANGES:1.2219	Sat Dec 10 10:43:28 2016
+++ src/doc/CHANGES	Sun Dec 11 00:25:32 2016
@@ -1,4 +1,4 @@
-# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2219 $>
+# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2220 $>
 #
 #
 # [Note: This file does not mention every change made to the NetBSD source tree.
@@ -407,3 +407,4 @@ Changes from NetBSD 7.0 to NetBSD 8.0:
 	audio(4): Audio sub-system changes - in kernel mixing [nat 20161208]
 	speaker(4):Synthesized beep for platforms with audio [nat 20161208]
 	crash(8): Add sparc support.  [mrg 20161210]
+	cgd(4): Add aes-xts. [alnsn 20161211]



CVS commit: src/share/man/man4

2016-12-10 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sun Dec 11 00:24:48 UTC 2016

Modified Files:
src/share/man/man4: cgd.4

Log Message:
Document AES-XTS in cgd(4).


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/share/man/man4/cgd.4

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/share/man/man4/cgd.4
diff -u src/share/man/man4/cgd.4:1.19 src/share/man/man4/cgd.4:1.20
--- src/share/man/man4/cgd.4:1.19	Wed Jun  1 01:34:43 2016
+++ src/share/man/man4/cgd.4	Sun Dec 11 00:24:48 2016
@@ -1,4 +1,4 @@
-.\" $NetBSD: cgd.4,v 1.19 2016/06/01 01:34:43 pgoyette Exp $
+.\" $NetBSD: cgd.4,v 1.20 2016/12/11 00:24:48 alnsn Exp $
 .\"
 .\" Copyright (c) 2002, 2003 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd November 30, 2013
+.Dd December 11, 2016
 .Dt CGD 4
 .Os
 .Sh NAME
@@ -64,6 +64,21 @@ mode.
 .Tn AES
 uses a 128 bit blocksize and can accept keys of length 128, 192, or 256.
 The default key length is 128.
+.It Ic aes-xts
+.Tn AES
+in
+.Tn XTS
+mode.
+.Tn AES-XTS
+uses a 128 bit blocksize and can accept keys of length 256 or 512.
+Note that
+.Tn AES-XTS
+key is made of two
+.Tn AES
+keys of equal size.
+The second key is used solely to encrypt the block number of the physical
+disk block.
+The default key length is 256.
 .It Ic 3des-cbc
 Triple
 .Tn DES
@@ -159,11 +174,25 @@ and their associated data structures are
 .In dev/cgdvar.h
 header.
 .Sh WARNINGS
+.Pp
 It goes without saying that if you forget the passphrase that you used
 to configure a
 .Nm ,
 then you have irrevocably lost all of the data on the disk.
 Please ensure that you are using an appropriate backup strategy.
+.Pp
+A
+.Nm
+device doesn't authenticate data and thus it can't guarantee integrity
+of the encrypted data.
+In particular, if the plaintext is known to an adversary, it is
+possible to change every second block on a disk encrypted in the
+.Tn CBC
+mode to plaintext blocks of their choice.
+The
+.Tn
+XTS mode isn't vulnerable to this particular attack but a lack of
+integrity should be taken into accout when evaluating security risks.
 .Sh FILES
 .Bl -tag -width indentxxx
 .It /dev/{,r}cgd*



CVS commit: src/tests/dev/cgd

2016-12-10 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sun Dec 11 00:23:44 UTC 2016

Modified Files:
src/tests/dev/cgd: t_cgd_aes.c

Log Message:
AES XTS unit tests should now pass.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/dev/cgd/t_cgd_aes.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/dev/cgd/t_cgd_aes.c
diff -u src/tests/dev/cgd/t_cgd_aes.c:1.4 src/tests/dev/cgd/t_cgd_aes.c:1.5
--- src/tests/dev/cgd/t_cgd_aes.c:1.4	Thu Nov 24 22:42:16 2016
+++ src/tests/dev/cgd/t_cgd_aes.c	Sun Dec 11 00:23:44 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_cgd_aes.c,v 1.4 2016/11/24 22:42:16 alnsn Exp $	*/
+/*	$NetBSD: t_cgd_aes.c,v 1.5 2016/12/11 00:23:44 alnsn Exp $	*/
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
  * Copyright (c) 2007 The Institute of Electrical and Electronics Engineers, Inc
@@ -3511,8 +3511,6 @@ ATF_TC_BODY(cgd_aes_xts_256, tc)
 	const size_t dksize = 256 * SECSIZE; /* Last blkno is 0xff. */
 	int dkfd, cgdfd;
 
-	atf_tc_expect_fail("aes-xts implementation not committed yet");
-
 	rump_init();
 
 	RL(dkfd = open_disk(dkpath, imgpath, dksize));
@@ -3565,8 +3563,6 @@ ATF_TC_BODY(cgd_aes_xts_512, tc)
 	const size_t dksize = 65536 * SECSIZE; /* Last blkno is 0x. */
 	int dkfd, cgdfd;
 
-	atf_tc_expect_fail("aes-xts implementation not committed yet");
-
 	rump_init();
 
 	RL(dkfd = open_disk(dkpath, imgpath, dksize));



CVS commit: src/sys/sys

2016-12-10 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sun Dec 11 00:23:04 UTC 2016

Modified Files:
src/sys/sys: param.h

Log Message:
Welcome to 7.99.45.

cgd(4): struct cryptfuncs gets a new cf_cipher_prep member.


To generate a diff of this commit:
cvs rdiff -u -r1.511 -r1.512 src/sys/sys/param.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/sys/param.h
diff -u src/sys/sys/param.h:1.511 src/sys/sys/param.h:1.512
--- src/sys/sys/param.h:1.511	Thu Dec  8 12:21:54 2016
+++ src/sys/sys/param.h	Sun Dec 11 00:23:04 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.511 2016/12/08 12:21:54 mlelstv Exp $	*/
+/*	$NetBSD: param.h,v 1.512 2016/12/11 00:23:04 alnsn Exp $	*/
 
 /*-
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -67,7 +67,7 @@
  *	2.99.9		(299000900)
  */
 
-#define	__NetBSD_Version__	799004400	/* NetBSD 7.99.44 */
+#define	__NetBSD_Version__	799004500	/* NetBSD 7.99.45 */
 
 #define __NetBSD_Prereq__(M,m,p) (M) * 1) + \
 (m) * 100) + (p) * 100) <= __NetBSD_Version__)



CVS commit: src/sys/dev

2016-12-10 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sun Dec 11 00:20:49 UTC 2016

Modified Files:
src/sys/dev: cgd.c cgd_crypto.c cgd_crypto.h

Log Message:
Add XTS mode to cgd(4).


To generate a diff of this commit:
cvs rdiff -u -r1.111 -r1.112 src/sys/dev/cgd.c
cvs rdiff -u -r1.13 -r1.14 src/sys/dev/cgd_crypto.c
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/cgd_crypto.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/cgd.c
diff -u src/sys/dev/cgd.c:1.111 src/sys/dev/cgd.c:1.112
--- src/sys/dev/cgd.c:1.111	Wed Sep 14 23:16:30 2016
+++ src/sys/dev/cgd.c	Sun Dec 11 00:20:49 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: cgd.c,v 1.111 2016/09/14 23:16:30 mlelstv Exp $ */
+/* $NetBSD: cgd.c,v 1.112 2016/12/11 00:20:49 alnsn Exp $ */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.111 2016/09/14 23:16:30 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.112 2016/12/11 00:20:49 alnsn Exp $");
 
 #include 
 #include 
@@ -59,6 +59,18 @@ __KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.11
 
 #include "ioconf.h"
 
+struct selftest_params {
+	const char *alg;
+	int blocksize;	/* number of bytes */
+	int secsize;
+	daddr_t blkno;
+	int keylen;	/* number of bits */
+	int txtlen;	/* number of bytes */
+	const uint8_t *key;
+	const uint8_t *ptxt;
+	const uint8_t *ctxt;
+};
+
 /* Entry Point Functions */
 
 static dev_type_open(cgdopen);
@@ -96,6 +108,101 @@ const struct cdevsw cgd_cdevsw = {
 	.d_flag = D_DISK
 };
 
+/*
+ * Vector 5 from IEEE 1619/D16 truncated to 64 bytes, blkno 1.
+ */
+static const uint8_t selftest_aes_xts_256_ptxt[64] = {
+	0x27, 0xa7, 0x47, 0x9b, 0xef, 0xa1, 0xd4, 0x76,
+	0x48, 0x9f, 0x30, 0x8c, 0xd4, 0xcf, 0xa6, 0xe2,
+	0xa9, 0x6e, 0x4b, 0xbe, 0x32, 0x08, 0xff, 0x25,
+	0x28, 0x7d, 0xd3, 0x81, 0x96, 0x16, 0xe8, 0x9c,
+	0xc7, 0x8c, 0xf7, 0xf5, 0xe5, 0x43, 0x44, 0x5f,
+	0x83, 0x33, 0xd8, 0xfa, 0x7f, 0x56, 0x00, 0x00,
+	0x05, 0x27, 0x9f, 0xa5, 0xd8, 0xb5, 0xe4, 0xad,
+	0x40, 0xe7, 0x36, 0xdd, 0xb4, 0xd3, 0x54, 0x12,
+};
+
+static const uint8_t selftest_aes_xts_256_ctxt[512] = {
+	0x26, 0x4d, 0x3c, 0xa8, 0x51, 0x21, 0x94, 0xfe,
+	0xc3, 0x12, 0xc8, 0xc9, 0x89, 0x1f, 0x27, 0x9f,
+	0xef, 0xdd, 0x60, 0x8d, 0x0c, 0x02, 0x7b, 0x60,
+	0x48, 0x3a, 0x3f, 0xa8, 0x11, 0xd6, 0x5e, 0xe5,
+	0x9d, 0x52, 0xd9, 0xe4, 0x0e, 0xc5, 0x67, 0x2d,
+	0x81, 0x53, 0x2b, 0x38, 0xb6, 0xb0, 0x89, 0xce,
+	0x95, 0x1f, 0x0f, 0x9c, 0x35, 0x59, 0x0b, 0x8b,
+	0x97, 0x8d, 0x17, 0x52, 0x13, 0xf3, 0x29, 0xbb,
+};
+
+static const uint8_t selftest_aes_xts_256_key[33] = {
+	0x27, 0x18, 0x28, 0x18, 0x28, 0x45, 0x90, 0x45,
+	0x23, 0x53, 0x60, 0x28, 0x74, 0x71, 0x35, 0x26,
+	0x31, 0x41, 0x59, 0x26, 0x53, 0x58, 0x97, 0x93,
+	0x23, 0x84, 0x62, 0x64, 0x33, 0x83, 0x27, 0x95,
+	0
+};
+
+/*
+ * Vector 11 from IEEE 1619/D16 truncated to 64 bytes, blkno 0x.
+ */
+static const uint8_t selftest_aes_xts_512_ptxt[64] = {
+	0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+	0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+	0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+	0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+	0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
+	0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+	0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
+	0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+};
+
+static const uint8_t selftest_aes_xts_512_ctxt[64] = {
+	0x77, 0xa3, 0x12, 0x51, 0x61, 0x8a, 0x15, 0xe6,
+	0xb9, 0x2d, 0x1d, 0x66, 0xdf, 0xfe, 0x7b, 0x50,
+	0xb5, 0x0b, 0xad, 0x55, 0x23, 0x05, 0xba, 0x02,
+	0x17, 0xa6, 0x10, 0x68, 0x8e, 0xff, 0x7e, 0x11,
+	0xe1, 0xd0, 0x22, 0x54, 0x38, 0xe0, 0x93, 0x24,
+	0x2d, 0x6d, 0xb2, 0x74, 0xfd, 0xe8, 0x01, 0xd4,
+	0xca, 0xe0, 0x6f, 0x20, 0x92, 0xc7, 0x28, 0xb2,
+	0x47, 0x85, 0x59, 0xdf, 0x58, 0xe8, 0x37, 0xc2,
+};
+
+static const uint8_t selftest_aes_xts_512_key[65] = {
+	0x27, 0x18, 0x28, 0x18, 0x28, 0x45, 0x90, 0x45,
+	0x23, 0x53, 0x60, 0x28, 0x74, 0x71, 0x35, 0x26,
+	0x62, 0x49, 0x77, 0x57, 0x24, 0x70, 0x93, 0x69,
+	0x99, 0x59, 0x57, 0x49, 0x66, 0x96, 0x76, 0x27,
+	0x31, 0x41, 0x59, 0x26, 0x53, 0x58, 0x97, 0x93,
+	0x23, 0x84, 0x62, 0x64, 0x33, 0x83, 0x27, 0x95,
+	0x02, 0x88, 0x41, 0x97, 0x16, 0x93, 0x99, 0x37,
+	0x51, 0x05, 0x82, 0x09, 0x74, 0x94, 0x45, 0x92,
+	0
+};
+
+const struct selftest_params selftests[] = {
+	{
+		.alg = "aes-xts",
+		.blocksize = 16,
+		.secsize = 512,
+		.blkno = 1,
+		.keylen = 256,
+		.txtlen = sizeof(selftest_aes_xts_256_ptxt),
+		.key  = selftest_aes_xts_256_key,
+		.ptxt = selftest_aes_xts_256_ptxt,
+		.ctxt = selftest_aes_xts_256_ctxt
+	},
+	{
+		.alg = "aes-xts",
+		.blocksize = 16,
+		.secsize = 512,
+		.blkno = 0x,
+		.keylen = 512,
+		.txtlen = sizeof(selftest_aes_xts_512_ptxt),
+		.key  = selftest_aes_xts_512_key,
+		.ptxt = selftest_aes_xts_512_ptxt,
+		.ctxt = selftest_aes_xts_512_ctxt
+	}
+};
+
 static int cgd_match(device_t, cfdata_t, void *);
 static void cgd_attach(device_t, 

CVS commit: src/tests/dev/cgd

2016-11-24 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Thu Nov 24 22:42:16 UTC 2016

Modified Files:
src/tests/dev/cgd: t_cgd_aes.c

Log Message:
Switch to CHECK_LIBC for writing.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/dev/cgd/t_cgd_aes.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/dev/cgd/t_cgd_aes.c
diff -u src/tests/dev/cgd/t_cgd_aes.c:1.3 src/tests/dev/cgd/t_cgd_aes.c:1.4
--- src/tests/dev/cgd/t_cgd_aes.c:1.3	Wed Nov  9 22:01:15 2016
+++ src/tests/dev/cgd/t_cgd_aes.c	Thu Nov 24 22:42:16 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_cgd_aes.c,v 1.3 2016/11/09 22:01:15 alnsn Exp $	*/
+/*	$NetBSD: t_cgd_aes.c,v 1.4 2016/11/24 22:42:16 alnsn Exp $	*/
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
  * Copyright (c) 2007 The Institute of Electrical and Electronics Engineers, Inc
@@ -3156,12 +3156,18 @@ unconfigure_cgd(int fd)
 static int
 write_testvec(int cgdfd, const struct testvec *tv)
 {
+	ssize_t written;
 
 	if (rump_sys_lseek(cgdfd, tv->blkno * SECSIZE, SEEK_SET) < 0)
 		return -1;
 
-	if (rump_sys_write(cgdfd, tv->ptxt, SECSIZE) != SECSIZE)
+	written = rump_sys_write(cgdfd, tv->ptxt, SECSIZE);
+	if (written < 0)
 		return -1;
+	if (written != SECSIZE) {
+		errno = EDOM; /* Something distinct. */
+		return -1;
+	}
 
 	return 0;
 }
@@ -3232,10 +3238,10 @@ ATF_TC_BODY(cgd_aes_cbc_128_encblkno1, t
 	RL(configure_cgd(cgdfd, dkpath, "aes-cbc", "encblkno1",
 	aes_cbc_128_key, sizeof(aes_cbc_128_key)));
 
-	ATF_CHECK_EQ(write_testvec(cgdfd, _cbc_128_1_vectors[0]), 0);
-	ATF_CHECK_EQ(write_testvec(cgdfd, _cbc_128_1_vectors[1]), 0);
-	ATF_CHECK_EQ(write_testvec(cgdfd, _cbc_128_1_vectors[2]), 0);
-	ATF_CHECK_EQ(write_testvec(cgdfd, _cbc_128_1_vectors[3]), 0);
+	CHECK_LIBC(write_testvec(cgdfd, _cbc_128_1_vectors[0]), -1);
+	CHECK_LIBC(write_testvec(cgdfd, _cbc_128_1_vectors[1]), -1);
+	CHECK_LIBC(write_testvec(cgdfd, _cbc_128_1_vectors[2]), -1);
+	CHECK_LIBC(write_testvec(cgdfd, _cbc_128_1_vectors[3]), -1);
 
 	RL(unconfigure_cgd(cgdfd));
 	RL(configure_cgd(cgdfd, dkpath, "aes-cbc", "encblkno1",
@@ -3279,10 +3285,10 @@ ATF_TC_BODY(cgd_aes_cbc_128_encblkno8, t
 	RL(configure_cgd(cgdfd, dkpath, "aes-cbc", "encblkno8",
 	aes_cbc_128_key, sizeof(aes_cbc_128_key)));
 
-	ATF_CHECK_EQ(write_testvec(cgdfd, _cbc_128_8_vectors[0]), 0);
-	ATF_CHECK_EQ(write_testvec(cgdfd, _cbc_128_8_vectors[1]), 0);
-	ATF_CHECK_EQ(write_testvec(cgdfd, _cbc_128_8_vectors[2]), 0);
-	ATF_CHECK_EQ(write_testvec(cgdfd, _cbc_128_8_vectors[3]), 0);
+	CHECK_LIBC(write_testvec(cgdfd, _cbc_128_8_vectors[0]), -1);
+	CHECK_LIBC(write_testvec(cgdfd, _cbc_128_8_vectors[1]), -1);
+	CHECK_LIBC(write_testvec(cgdfd, _cbc_128_8_vectors[2]), -1);
+	CHECK_LIBC(write_testvec(cgdfd, _cbc_128_8_vectors[3]), -1);
 
 	RL(unconfigure_cgd(cgdfd));
 	RL(configure_cgd(cgdfd, dkpath, "aes-cbc", "encblkno8",
@@ -3326,10 +3332,10 @@ ATF_TC_BODY(cgd_aes_cbc_192_encblkno1, t
 	RL(configure_cgd(cgdfd, dkpath, "aes-cbc", "encblkno1",
 	aes_cbc_192_key, sizeof(aes_cbc_192_key)));
 
-	ATF_CHECK_EQ(write_testvec(cgdfd, _cbc_192_1_vectors[0]), 0);
-	ATF_CHECK_EQ(write_testvec(cgdfd, _cbc_192_1_vectors[1]), 0);
-	ATF_CHECK_EQ(write_testvec(cgdfd, _cbc_192_1_vectors[2]), 0);
-	ATF_CHECK_EQ(write_testvec(cgdfd, _cbc_192_1_vectors[3]), 0);
+	CHECK_LIBC(write_testvec(cgdfd, _cbc_192_1_vectors[0]), -1);
+	CHECK_LIBC(write_testvec(cgdfd, _cbc_192_1_vectors[1]), -1);
+	CHECK_LIBC(write_testvec(cgdfd, _cbc_192_1_vectors[2]), -1);
+	CHECK_LIBC(write_testvec(cgdfd, _cbc_192_1_vectors[3]), -1);
 
 	RL(unconfigure_cgd(cgdfd));
 	RL(configure_cgd(cgdfd, dkpath, "aes-cbc", "encblkno1",
@@ -3373,10 +3379,10 @@ ATF_TC_BODY(cgd_aes_cbc_192_encblkno8, t
 	RL(configure_cgd(cgdfd, dkpath, "aes-cbc", "encblkno8",
 	aes_cbc_192_key, sizeof(aes_cbc_192_key)));
 
-	ATF_CHECK_EQ(write_testvec(cgdfd, _cbc_192_8_vectors[0]), 0);
-	ATF_CHECK_EQ(write_testvec(cgdfd, _cbc_192_8_vectors[1]), 0);
-	ATF_CHECK_EQ(write_testvec(cgdfd, _cbc_192_8_vectors[2]), 0);
-	ATF_CHECK_EQ(write_testvec(cgdfd, _cbc_192_8_vectors[3]), 0);
+	CHECK_LIBC(write_testvec(cgdfd, _cbc_192_8_vectors[0]), -1);
+	CHECK_LIBC(write_testvec(cgdfd, _cbc_192_8_vectors[1]), -1);
+	CHECK_LIBC(write_testvec(cgdfd, _cbc_192_8_vectors[2]), -1);
+	CHECK_LIBC(write_testvec(cgdfd, _cbc_192_8_vectors[3]), -1);
 
 	RL(unconfigure_cgd(cgdfd));
 	RL(configure_cgd(cgdfd, dkpath, "aes-cbc", "encblkno8",
@@ -3420,10 +3426,10 @@ ATF_TC_BODY(cgd_aes_cbc_256_encblkno1, t
 	RL(configure_cgd(cgdfd, dkpath, "aes-cbc", "encblkno1",
 	aes_cbc_256_key, sizeof(aes_cbc_256_key)));
 
-	ATF_CHECK_EQ(write_testvec(cgdfd, _cbc_256_1_vectors[0]), 0);
-	ATF_CHECK_EQ(write_testvec(cgdfd, _cbc_256_1_vectors[1]), 0);
-	ATF_CHECK_EQ(write_testvec(cgdfd, _cbc_256_1_vectors[2]), 0);
-	ATF_CHECK_EQ(write_testvec(cgdfd, _cbc_256_1_vectors[3]), 0);
+	CHECK_LIBC(write_testvec(cgdfd, _cbc_256_1_vectors[0]), -1);
+	

CVS commit: src

2016-11-10 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Fri Nov 11 07:39:58 UTC 2016

Modified Files:
src/distrib/sets/lists/debug: mi
src/distrib/sets/lists/tests: mi
src/tests/dev/cgd: Makefile
Added Files:
src/tests/dev/cgd: t_cgd_3des.c

Log Message:
Add 3des-cbc tests with 192 bits key.


To generate a diff of this commit:
cvs rdiff -u -r1.174 -r1.175 src/distrib/sets/lists/debug/mi
cvs rdiff -u -r1.697 -r1.698 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.6 -r1.7 src/tests/dev/cgd/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/dev/cgd/t_cgd_3des.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/sets/lists/debug/mi
diff -u src/distrib/sets/lists/debug/mi:1.174 src/distrib/sets/lists/debug/mi:1.175
--- src/distrib/sets/lists/debug/mi:1.174	Thu Nov 10 23:44:36 2016
+++ src/distrib/sets/lists/debug/mi	Fri Nov 11 07:39:58 2016
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.174 2016/11/10 23:44:36 alnsn Exp $
+# $NetBSD: mi,v 1.175 2016/11/11 07:39:58 alnsn Exp $
 ./etc/mtree/set.debug   comp-sys-root
 ./usr/lib	comp-sys-usr		compatdir
 ./usr/lib/i18n/libBIG5_g.a			comp-c-debuglib		debuglib,compatfile
@@ -1591,6 +1591,7 @@
 ./usr/libdata/debug/usr/tests/crypto/opencrypto/h_xcbcmac.debug		tests-crypto-debug	debug,atf,crypto,compattestfile
 ./usr/libdata/debug/usr/tests/dev/audio/h_pad.debug			tests-fs-debug		debug,atf,rump
 ./usr/libdata/debug/usr/tests/dev/cgd/h_img2cgd/h_img2cgd.debug			tests-obsolete	obsolete,compattestfile
+./usr/libdata/debug/usr/tests/dev/cgd/t_cgd_3des.debug			tests-fs-debug		atf,compattestfile,crypto,debug,rump
 ./usr/libdata/debug/usr/tests/dev/cgd/t_cgd_aes.debug			tests-fs-debug		atf,compattestfile,crypto,debug,rump
 ./usr/libdata/debug/usr/tests/dev/cgd/t_cgd_blowfish.debug		tests-fs-debug		atf,compattestfile,crypto,debug,rump
 ./usr/libdata/debug/usr/tests/dev/clock_subr/t_clock_subr.debug		tests-fs-debug		debug,atf,rump

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.697 src/distrib/sets/lists/tests/mi:1.698
--- src/distrib/sets/lists/tests/mi:1.697	Thu Nov 10 23:47:23 2016
+++ src/distrib/sets/lists/tests/mi	Fri Nov 11 07:39:58 2016
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.697 2016/11/10 23:47:23 alnsn Exp $
+# $NetBSD: mi,v 1.698 2016/11/11 07:39:58 alnsn Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -1366,6 +1366,7 @@
 ./usr/tests/dev/cgd/h_img2cgd/h_img2cgd		tests-obsolete		obsolete
 ./usr/tests/dev/cgd/paramsfile			tests-fs-tests		compattestfile,atf
 ./usr/tests/dev/cgd/t_cgd			tests-fs-tests		compattestfile,atf
+./usr/tests/dev/cgd/t_cgd_3des			tests-fs-tests		atf,compattestfile,crypto,rump
 ./usr/tests/dev/cgd/t_cgd_aes			tests-fs-tests		atf,compattestfile,crypto,rump
 ./usr/tests/dev/cgd/t_cgd_blowfish		tests-fs-tests		atf,compattestfile,crypto,rump
 ./usr/tests/dev/clock_subr			tests-fs-tests		compattestfile,atf

Index: src/tests/dev/cgd/Makefile
diff -u src/tests/dev/cgd/Makefile:1.6 src/tests/dev/cgd/Makefile:1.7
--- src/tests/dev/cgd/Makefile:1.6	Thu Nov 10 23:44:36 2016
+++ src/tests/dev/cgd/Makefile	Fri Nov 11 07:39:58 2016
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.6 2016/11/10 23:44:36 alnsn Exp $
+#	$NetBSD: Makefile,v 1.7 2016/11/11 07:39:58 alnsn Exp $
 #
 
 .include 
@@ -10,7 +10,7 @@ FILESDIR=	${TESTSDIR}
 TESTS_SH=	t_cgd
 
 .if ${MKCRYPTO} != "no" && ${MKRUMP} != "no"
-TESTS_C=	t_cgd_aes t_cgd_blowfish
+TESTS_C=	t_cgd_3des t_cgd_aes t_cgd_blowfish
 
 WARNS=	4
 CPPFLAGS+=	-D_KERNTYPES

Added files:

Index: src/tests/dev/cgd/t_cgd_3des.c
diff -u /dev/null src/tests/dev/cgd/t_cgd_3des.c:1.1
--- /dev/null	Fri Nov 11 07:39:58 2016
+++ src/tests/dev/cgd/t_cgd_3des.c	Fri Nov 11 07:39:58 2016
@@ -0,0 +1,913 @@
+/*	$NetBSD: t_cgd_3des.c,v 1.1 2016/11/11 07:39:58 alnsn Exp $	*/
+/*-
+ * Copyright (c) 2016 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Alexander Nasonov.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in
+ *the documentation and/or other materials provided with the
+ *distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDERS OR CONTRIBUT

CVS commit: src/distrib/sets/lists/tests

2016-11-10 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Thu Nov 10 23:47:24 UTC 2016

Modified Files:
src/distrib/sets/lists/tests: mi

Log Message:
Add t_cgd_blowfish.


To generate a diff of this commit:
cvs rdiff -u -r1.696 -r1.697 src/distrib/sets/lists/tests/mi

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.696 src/distrib/sets/lists/tests/mi:1.697
--- src/distrib/sets/lists/tests/mi:1.696	Mon Nov  7 21:09:03 2016
+++ src/distrib/sets/lists/tests/mi	Thu Nov 10 23:47:23 2016
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.696 2016/11/07 21:09:03 kamil Exp $
+# $NetBSD: mi,v 1.697 2016/11/10 23:47:23 alnsn Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -1367,6 +1367,7 @@
 ./usr/tests/dev/cgd/paramsfile			tests-fs-tests		compattestfile,atf
 ./usr/tests/dev/cgd/t_cgd			tests-fs-tests		compattestfile,atf
 ./usr/tests/dev/cgd/t_cgd_aes			tests-fs-tests		atf,compattestfile,crypto,rump
+./usr/tests/dev/cgd/t_cgd_blowfish		tests-fs-tests		atf,compattestfile,crypto,rump
 ./usr/tests/dev/clock_subr			tests-fs-tests		compattestfile,atf
 ./usr/tests/dev/clock_subr/Atffile		tests-fs-tests		compattestfile,atf
 ./usr/tests/dev/clock_subr/Kyuafile		tests-fs-tests		compattestfile,atf,kyua



CVS commit: src

2016-11-10 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Thu Nov 10 23:44:36 UTC 2016

Modified Files:
src/distrib/sets/lists/debug: mi
src/tests/dev/cgd: Makefile
Added Files:
src/tests/dev/cgd: t_cgd_blowfish.c

Log Message:
Add blowfish-cbc tests for 128, 256 and 448 bits keys.


To generate a diff of this commit:
cvs rdiff -u -r1.173 -r1.174 src/distrib/sets/lists/debug/mi
cvs rdiff -u -r1.5 -r1.6 src/tests/dev/cgd/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/dev/cgd/t_cgd_blowfish.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/sets/lists/debug/mi
diff -u src/distrib/sets/lists/debug/mi:1.173 src/distrib/sets/lists/debug/mi:1.174
--- src/distrib/sets/lists/debug/mi:1.173	Mon Nov  7 21:09:03 2016
+++ src/distrib/sets/lists/debug/mi	Thu Nov 10 23:44:36 2016
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.173 2016/11/07 21:09:03 kamil Exp $
+# $NetBSD: mi,v 1.174 2016/11/10 23:44:36 alnsn Exp $
 ./etc/mtree/set.debug   comp-sys-root
 ./usr/lib	comp-sys-usr		compatdir
 ./usr/lib/i18n/libBIG5_g.a			comp-c-debuglib		debuglib,compatfile
@@ -1592,6 +1592,7 @@
 ./usr/libdata/debug/usr/tests/dev/audio/h_pad.debug			tests-fs-debug		debug,atf,rump
 ./usr/libdata/debug/usr/tests/dev/cgd/h_img2cgd/h_img2cgd.debug			tests-obsolete	obsolete,compattestfile
 ./usr/libdata/debug/usr/tests/dev/cgd/t_cgd_aes.debug			tests-fs-debug		atf,compattestfile,crypto,debug,rump
+./usr/libdata/debug/usr/tests/dev/cgd/t_cgd_blowfish.debug		tests-fs-debug		atf,compattestfile,crypto,debug,rump
 ./usr/libdata/debug/usr/tests/dev/clock_subr/t_clock_subr.debug		tests-fs-debug		debug,atf,rump
 ./usr/libdata/debug/usr/tests/dev/md/h_mdserv.debug	tests-fs-debug	debug,atf,rump
 ./usr/libdata/debug/usr/tests/dev/scsipi/t_cd.debug			tests-fs-debug		debug,atf,rump

Index: src/tests/dev/cgd/Makefile
diff -u src/tests/dev/cgd/Makefile:1.5 src/tests/dev/cgd/Makefile:1.6
--- src/tests/dev/cgd/Makefile:1.5	Mon Nov  7 16:33:37 2016
+++ src/tests/dev/cgd/Makefile	Thu Nov 10 23:44:36 2016
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.5 2016/11/07 16:33:37 scole Exp $
+#	$NetBSD: Makefile,v 1.6 2016/11/10 23:44:36 alnsn Exp $
 #
 
 .include 
@@ -9,8 +9,8 @@ FILESDIR=	${TESTSDIR}
 
 TESTS_SH=	t_cgd
 
-.if ${MKCRYPTO} == "yes" && ${MKRUMP} == "yes"
-TESTS_C=	t_cgd_aes
+.if ${MKCRYPTO} != "no" && ${MKRUMP} != "no"
+TESTS_C=	t_cgd_aes t_cgd_blowfish
 
 WARNS=	4
 CPPFLAGS+=	-D_KERNTYPES

Added files:

Index: src/tests/dev/cgd/t_cgd_blowfish.c
diff -u /dev/null src/tests/dev/cgd/t_cgd_blowfish.c:1.1
--- /dev/null	Thu Nov 10 23:44:36 2016
+++ src/tests/dev/cgd/t_cgd_blowfish.c	Thu Nov 10 23:44:36 2016
@@ -0,0 +1,2341 @@
+/*	$NetBSD: t_cgd_blowfish.c,v 1.1 2016/11/10 23:44:36 alnsn Exp $	*/
+/*-
+ * Copyright (c) 2016 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Alexander Nasonov.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in
+ *the documentation and/or other materials provided with the
+ *distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+
+#include "../../h_macros.h"
+
+#define SECSIZE 512
+
+struct testvec {
+	unsigned int blkno;
+	const uint8_t *ptxt;	/* PlainText  */
+	const uint8_t *ctxt;	/* CipherText */
+};
+
+/*
+ * 128 bits Blowfish key, NUL terminated.
+ */
+static const char bf_cbc_128_key[17] = {
+	0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* 01234567 */
+	0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, /* 89ABCDEF */
+	0
+};
+
+/*

CVS commit: src/tests/dev/cgd

2016-11-09 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Wed Nov  9 22:01:15 UTC 2016

Modified Files:
src/tests/dev/cgd: t_cgd_aes.c

Log Message:
Add aes-cbc tests.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/dev/cgd/t_cgd_aes.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/dev/cgd/t_cgd_aes.c
diff -u src/tests/dev/cgd/t_cgd_aes.c:1.2 src/tests/dev/cgd/t_cgd_aes.c:1.3
--- src/tests/dev/cgd/t_cgd_aes.c:1.2	Mon Nov  7 18:11:45 2016
+++ src/tests/dev/cgd/t_cgd_aes.c	Wed Nov  9 22:01:15 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_cgd_aes.c,v 1.2 2016/11/07 18:11:45 alnsn Exp $	*/
+/*	$NetBSD: t_cgd_aes.c,v 1.3 2016/11/09 22:01:15 alnsn Exp $	*/
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
  * Copyright (c) 2007 The Institute of Electrical and Electronics Engineers, Inc
@@ -60,6 +60,1872 @@ struct testvec {
 };
 
 /*
+ * 128 bits CBC key, NUL terminated.
+ */
+static const char aes_cbc_128_key[17] = {
+	0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* 01234567 */
+	0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, /* 89ABCDEF */
+	0
+};
+
+/*
+ * 192 bits CBC key, NUL terminated.
+ */
+static const char aes_cbc_192_key[25] = {
+	0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, /* ABCDEFGH */
+	0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, /* IJKLMNOP */
+	0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, /* QRSTUVWX */
+	0
+};
+
+/*
+ * 256 bits CBC key, NUL terminated.
+ */
+static const char aes_cbc_256_key[33] = {
+	0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* 01234567 */
+	0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, /* 89ABCDEF */
+	0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* 01234567 */
+	0x38, 0x39, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, /* 89abcdef */
+	0
+};
+
+static const uint8_t aes_cbc_ptxt[SECSIZE] =
+	"abcdefghijklmnop"
+	"abcdefghijklmnop"
+	"abcdefghijklmnop"
+	"abcdefghijklmnop"
+	"abcdefghijklmnop"
+	"abcdefghijklmnop"
+	"abcdefghijklmnop"
+	"abcdefghijklmnop"
+	"abcdefghijklmnop"
+	"abcdefghijklmnop"
+	"abcdefghijklmnop"
+	"abcdefghijklmnop"
+	"abcdefghijklmnop"
+	"abcdefghijklmnop"
+	"abcdefghijklmnop"
+	"abcdefghijklmnop";
+
+/*
+ * IV method encblkno1, blkno 0.
+ */
+static const uint8_t aes_cbc_128_encblkno1_vec0_ctxt[SECSIZE] = {
+	0x1e, 0x95, 0x12, 0x15, 0xf6, 0xe0, 0xa7, 0x56,
+	0x95, 0xa0, 0xa7, 0x35, 0x77, 0xf4, 0xdd, 0xdc,
+	0x37, 0xc0, 0x28, 0x20, 0x00, 0x79, 0xa0, 0x35,
+	0xe0, 0x83, 0x23, 0x95, 0x4e, 0xea, 0x8d, 0xa2,
+	0x11, 0xbf, 0x9a, 0xd5, 0x21, 0x1e, 0x15, 0xb9,
+	0xd1, 0x2e, 0xd2, 0xd9, 0xa5, 0xcc, 0x26, 0x75,
+	0xba, 0x3e, 0x30, 0x11, 0xb2, 0x40, 0xdd, 0x1d,
+	0x07, 0x3b, 0xe6, 0x00, 0xa7, 0x31, 0x9e, 0x58,
+	0x41, 0xf3, 0x02, 0xf5, 0xad, 0x35, 0x79, 0x9a,
+	0x9e, 0x03, 0xc8, 0x7a, 0x9d, 0x1d, 0x58, 0x9f,
+	0x98, 0x67, 0xe2, 0x49, 0x81, 0x0c, 0x23, 0x90,
+	0xd8, 0xc6, 0xf0, 0xc5, 0x73, 0x46, 0xd5, 0x14,
+	0x1d, 0x78, 0x24, 0x7c, 0x9f, 0x5c, 0x8c, 0xe6,
+	0x5d, 0x85, 0x7a, 0x5f, 0x76, 0xcc, 0xd8, 0xe9,
+	0x03, 0xff, 0xfd, 0xd4, 0x12, 0x3f, 0xcb, 0xb0,
+	0xfe, 0xfd, 0x86, 0x00, 0x0c, 0xe3, 0xdd, 0xa6,
+	0x89, 0x92, 0xfe, 0xc8, 0x07, 0x5a, 0x94, 0x55,
+	0x75, 0xae, 0x68, 0x47, 0xba, 0x84, 0x75, 0x58,
+	0x33, 0x30, 0x2c, 0x16, 0x5b, 0xe9, 0x3f, 0x2a,
+	0x09, 0xf9, 0x69, 0x23, 0x77, 0xd7, 0x2b, 0x95,
+	0x4b, 0x78, 0x59, 0xcc, 0xfa, 0xf5, 0x79, 0xd2,
+	0x05, 0x87, 0x66, 0x57, 0x93, 0xbf, 0x05, 0x90,
+	0x4d, 0x6d, 0xd2, 0x72, 0x92, 0x24, 0xec, 0x14,
+	0xe7, 0xbf, 0x82, 0x57, 0xbb, 0x14, 0x51, 0xe6,
+	0xce, 0x3f, 0xa1, 0xfc, 0x63, 0x75, 0xee, 0xde,
+	0xf9, 0x31, 0xd3, 0xa0, 0x07, 0xcd, 0x4d, 0x8f,
+	0x83, 0x7d, 0x65, 0xe1, 0xc6, 0x60, 0x9e, 0x5c,
+	0x51, 0x76, 0xfa, 0x64, 0xdf, 0xdc, 0xaf, 0x38,
+	0xee, 0xe9, 0x8f, 0x4b, 0xa0, 0x3a, 0x21, 0xdf,
+	0x58, 0x3b, 0x73, 0xf5, 0x30, 0xbb, 0x29, 0xe0,
+	0xff, 0x60, 0xf0, 0x05, 0x5e, 0x37, 0xbc, 0x78,
+	0x95, 0x3f, 0xa8, 0xd4, 0xb4, 0x82, 0x0d, 0xe1,
+	0x10, 0xe3, 0xa7, 0x61, 0x37, 0x58, 0x28, 0x14,
+	0x22, 0x57, 0x32, 0x28, 0x80, 0x98, 0x3e, 0x5f,
+	0x71, 0xcf, 0x34, 0xb8, 0x6d, 0x6b, 0xc0, 0x23,
+	0xc1, 0x9e, 0x58, 0x4f, 0xd5, 0xa4, 0x14, 0x03,
+	0x2a, 0xed, 0xc4, 0xa7, 0x77, 0x7c, 0x4f, 0x94,
+	0x91, 0x1d, 0x47, 0x34, 0x82, 0xe8, 0x9d, 0x32,
+	0x5c, 0xc7, 0x38, 0xe9, 0x92, 0xcd, 0x35, 0xfd,
+	0x1c, 0xcc, 0x3c, 0x28, 0x75, 0x6f, 0xff, 0xd5,
+	0xe8, 0xbf, 0x90, 0x92, 0x34, 0x13, 0x11, 0x89,
+	0xe0, 0xa2, 0x25, 0xeb, 0x82, 0x63, 0x31, 0x80,
+	0x50, 0x6c, 0x99, 0xaa, 0x97, 0x0e, 0x59, 0x45,
+	0x64, 0xb8, 0x77, 0x78, 0x6b, 0x24, 0xac, 0xc0,
+	0xc9, 0xa9, 0xbc, 0x13, 0xd1, 0x5e, 0x50, 0x9a,
+	0x91, 0x1a, 0x08, 0xf7, 0xc5, 0x18, 0x9f, 0x87,
+	0x97, 0x9c, 0x0a, 0x27, 0xf1, 0x66, 0xf8, 0x09,
+	0x52, 0x09, 0x41, 0x07, 0xc1, 0xa1, 0x91, 0xa4,

Re: CVS commit: src/tests/dev/cgd

2016-11-07 Thread Alexander Nasonov
Sean Cole wrote:
> Module Name:  src
> Committed By: scole
> Date: Mon Nov  7 16:33:37 UTC 2016
> 
> Modified Files:
>   src/tests/dev/cgd: Makefile
> 
> Log Message:
> Only build t_cgd_aes if MKCRYPTO==yes and MKRUMP==yes.

In my opinion, the whole directory should be excluded if MKRUMP=no.

Alex


CVS commit: src/tests/dev/cgd

2016-11-07 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Mon Nov  7 18:11:45 UTC 2016

Modified Files:
src/tests/dev/cgd: t_cgd_aes.c

Log Message:
Don't use mktemp.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/dev/cgd/t_cgd_aes.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/dev/cgd/t_cgd_aes.c
diff -u src/tests/dev/cgd/t_cgd_aes.c:1.1 src/tests/dev/cgd/t_cgd_aes.c:1.2
--- src/tests/dev/cgd/t_cgd_aes.c:1.1	Sun Nov  6 10:54:42 2016
+++ src/tests/dev/cgd/t_cgd_aes.c	Mon Nov  7 18:11:45 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_cgd_aes.c,v 1.1 2016/11/06 10:54:42 alnsn Exp $	*/
+/*	$NetBSD: t_cgd_aes.c,v 1.2 2016/11/07 18:11:45 alnsn Exp $	*/
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
  * Copyright (c) 2007 The Institute of Electrical and Electronics Engineers, Inc
@@ -1232,7 +1232,7 @@ open_disk(const char *devpath, const cha
 {
 	int fd;
 
-	fd = open(imgpath, O_CREAT | O_RDWR | O_EXCL, 0600);
+	fd = open(imgpath, O_CREAT | O_RDWR | O_TRUNC, 0600);
 	if (fd < 0)
 		return -1;
 
@@ -1352,7 +1352,7 @@ ATF_TC_HEAD(cgd_aes_xts_256, tc)
 
 ATF_TC_BODY(cgd_aes_xts_256, tc)
 {
-	char imgpath[] = "aes-xts-256.XX";
+	const char imgpath[] = "aes-xts-256.img";
 	const char *dkpath = "/dev/dk";
 	const size_t dksize = 256 * SECSIZE; /* Last blkno is 0xff. */
 	int dkfd, cgdfd;
@@ -1361,7 +1361,6 @@ ATF_TC_BODY(cgd_aes_xts_256, tc)
 
 	rump_init();
 
-	mktemp(imgpath);
 	RL(dkfd = open_disk(dkpath, imgpath, dksize));
 
 	RL(cgdfd = open_cgd(0));
@@ -1407,7 +1406,7 @@ ATF_TC_HEAD(cgd_aes_xts_512, tc)
 
 ATF_TC_BODY(cgd_aes_xts_512, tc)
 {
-	char imgpath[] = "aes-xts-512.XX";
+	const char imgpath[] = "aes-xts-512.img";
 	const char *dkpath = "/dev/dk";
 	const size_t dksize = 65536 * SECSIZE; /* Last blkno is 0x. */
 	int dkfd, cgdfd;
@@ -1416,7 +1415,6 @@ ATF_TC_BODY(cgd_aes_xts_512, tc)
 
 	rump_init();
 
-	mktemp(imgpath);
 	RL(dkfd = open_disk(dkpath, imgpath, dksize));
 
 	RL(cgdfd = open_cgd(0));



CVS commit: src/tests/dev/cgd

2016-11-06 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sun Nov  6 21:29:54 UTC 2016

Modified Files:
src/tests/dev/cgd: Makefile

Log Message:
Don't build t_cgd_aes if ${MKCRYPTO} == "no".


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/dev/cgd/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/dev/cgd/Makefile
diff -u src/tests/dev/cgd/Makefile:1.3 src/tests/dev/cgd/Makefile:1.4
--- src/tests/dev/cgd/Makefile:1.3	Sun Nov  6 10:54:42 2016
+++ src/tests/dev/cgd/Makefile	Sun Nov  6 21:29:54 2016
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.3 2016/11/06 10:54:42 alnsn Exp $
+#	$NetBSD: Makefile,v 1.4 2016/11/06 21:29:54 alnsn Exp $
 #
 
 .include 
@@ -8,15 +8,17 @@ FILES=		paramsfile
 FILESDIR=	${TESTSDIR}
 
 TESTS_SH=	t_cgd
+
+.if ${MKCRYPTO} != "no"
 TESTS_C=	t_cgd_aes
 
+WARNS=	4
 CPPFLAGS+=	-D_KERNTYPES
 LDADD+=	-lrumpdev -lrumpdev_disk -lrumpdev_cgd -lrumpkern_crypto -lrumpvfs
 LDADD+=	-lrump
 LDADD+=	-lrumpuser
 LDADD+=	-lrump -lutil
 LDADD+=	-lpthread
-
-WARNS=	4
+.endif
 
 .include 



CVS commit: src/distrib/sets/lists/tests

2016-11-06 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sun Nov  6 17:09:19 UTC 2016

Modified Files:
src/distrib/sets/lists/tests: mi

Log Message:
Add "crypto" category to t_cgd_aes.


To generate a diff of this commit:
cvs rdiff -u -r1.693 -r1.694 src/distrib/sets/lists/tests/mi

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.693 src/distrib/sets/lists/tests/mi:1.694
--- src/distrib/sets/lists/tests/mi:1.693	Sun Nov  6 15:03:30 2016
+++ src/distrib/sets/lists/tests/mi	Sun Nov  6 17:09:19 2016
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.693 2016/11/06 15:03:30 kamil Exp $
+# $NetBSD: mi,v 1.694 2016/11/06 17:09:19 alnsn Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -1366,7 +1366,7 @@
 ./usr/tests/dev/cgd/h_img2cgd/h_img2cgd		tests-obsolete		obsolete
 ./usr/tests/dev/cgd/paramsfile			tests-fs-tests		compattestfile,atf
 ./usr/tests/dev/cgd/t_cgd			tests-fs-tests		compattestfile,atf
-./usr/tests/dev/cgd/t_cgd_aes			tests-fs-tests		compattestfile,atf,rump
+./usr/tests/dev/cgd/t_cgd_aes			tests-fs-tests		atf,compattestfile,crypto,rump
 ./usr/tests/dev/clock_subr			tests-fs-tests		compattestfile,atf
 ./usr/tests/dev/clock_subr/Atffile		tests-fs-tests		compattestfile,atf
 ./usr/tests/dev/clock_subr/Kyuafile		tests-fs-tests		compattestfile,atf,kyua



CVS commit: src/distrib/sets/lists/debug

2016-11-06 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sun Nov  6 17:07:50 UTC 2016

Modified Files:
src/distrib/sets/lists/debug: mi

Log Message:
Debug file for t_cgd_aes.


To generate a diff of this commit:
cvs rdiff -u -r1.171 -r1.172 src/distrib/sets/lists/debug/mi

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/sets/lists/debug/mi
diff -u src/distrib/sets/lists/debug/mi:1.171 src/distrib/sets/lists/debug/mi:1.172
--- src/distrib/sets/lists/debug/mi:1.171	Sun Nov  6 15:03:30 2016
+++ src/distrib/sets/lists/debug/mi	Sun Nov  6 17:07:50 2016
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.171 2016/11/06 15:03:30 kamil Exp $
+# $NetBSD: mi,v 1.172 2016/11/06 17:07:50 alnsn Exp $
 ./etc/mtree/set.debug   comp-sys-root
 ./usr/lib	comp-sys-usr		compatdir
 ./usr/lib/i18n/libBIG5_g.a			comp-c-debuglib		debuglib,compatfile
@@ -1591,6 +1591,7 @@
 ./usr/libdata/debug/usr/tests/crypto/opencrypto/h_xcbcmac.debug		tests-crypto-debug	debug,atf,crypto,compattestfile
 ./usr/libdata/debug/usr/tests/dev/audio/h_pad.debug			tests-fs-debug		debug,atf,rump
 ./usr/libdata/debug/usr/tests/dev/cgd/h_img2cgd/h_img2cgd.debug			tests-obsolete	obsolete,compattestfile
+./usr/libdata/debug/usr/tests/dev/cgd/t_cgd_aes.debug			tests-fs-debug		atf,compattestfile,crypto,debug,rump
 ./usr/libdata/debug/usr/tests/dev/clock_subr/t_clock_subr.debug		tests-fs-debug		debug,atf,rump
 ./usr/libdata/debug/usr/tests/dev/md/h_mdserv.debug	tests-fs-debug	debug,atf,rump
 ./usr/libdata/debug/usr/tests/dev/scsipi/t_cd.debug			tests-fs-debug		debug,atf,rump



CVS commit: src

2016-11-06 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sun Nov  6 10:54:42 UTC 2016

Modified Files:
src/distrib/sets/lists/tests: mi
src/tests/dev/cgd: Makefile
Added Files:
src/tests/dev/cgd: t_cgd_aes.c

Log Message:
Add tests for not-yet-committed cgd algorithm AES-XTS.

The tests are marked as expected failures.


To generate a diff of this commit:
cvs rdiff -u -r1.691 -r1.692 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.2 -r1.3 src/tests/dev/cgd/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/dev/cgd/t_cgd_aes.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.691 src/distrib/sets/lists/tests/mi:1.692
--- src/distrib/sets/lists/tests/mi:1.691	Wed Nov  2 12:51:22 2016
+++ src/distrib/sets/lists/tests/mi	Sun Nov  6 10:54:42 2016
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.691 2016/11/02 12:51:22 kamil Exp $
+# $NetBSD: mi,v 1.692 2016/11/06 10:54:42 alnsn Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -1366,6 +1366,7 @@
 ./usr/tests/dev/cgd/h_img2cgd/h_img2cgd		tests-obsolete		obsolete
 ./usr/tests/dev/cgd/paramsfile			tests-fs-tests		compattestfile,atf
 ./usr/tests/dev/cgd/t_cgd			tests-fs-tests		compattestfile,atf
+./usr/tests/dev/cgd/t_cgd_aes			tests-fs-tests		compattestfile,atf,rump
 ./usr/tests/dev/clock_subr			tests-fs-tests		compattestfile,atf
 ./usr/tests/dev/clock_subr/Atffile		tests-fs-tests		compattestfile,atf
 ./usr/tests/dev/clock_subr/Kyuafile		tests-fs-tests		compattestfile,atf,kyua

Index: src/tests/dev/cgd/Makefile
diff -u src/tests/dev/cgd/Makefile:1.2 src/tests/dev/cgd/Makefile:1.3
--- src/tests/dev/cgd/Makefile:1.2	Tue Dec 14 17:48:31 2010
+++ src/tests/dev/cgd/Makefile	Sun Nov  6 10:54:42 2016
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.2 2010/12/14 17:48:31 pooka Exp $
+#	$NetBSD: Makefile,v 1.3 2016/11/06 10:54:42 alnsn Exp $
 #
 
 .include 
@@ -8,5 +8,15 @@ FILES=		paramsfile
 FILESDIR=	${TESTSDIR}
 
 TESTS_SH=	t_cgd
+TESTS_C=	t_cgd_aes
+
+CPPFLAGS+=	-D_KERNTYPES
+LDADD+=	-lrumpdev -lrumpdev_disk -lrumpdev_cgd -lrumpkern_crypto -lrumpvfs
+LDADD+=	-lrump
+LDADD+=	-lrumpuser
+LDADD+=	-lrump -lutil
+LDADD+=	-lpthread
+
+WARNS=	4
 
 .include 

Added files:

Index: src/tests/dev/cgd/t_cgd_aes.c
diff -u /dev/null src/tests/dev/cgd/t_cgd_aes.c:1.1
--- /dev/null	Sun Nov  6 10:54:42 2016
+++ src/tests/dev/cgd/t_cgd_aes.c	Sun Nov  6 10:54:42 2016
@@ -0,0 +1,1452 @@
+/*	$NetBSD: t_cgd_aes.c,v 1.1 2016/11/06 10:54:42 alnsn Exp $	*/
+/*-
+ * Copyright (c) 2016 The NetBSD Foundation, Inc.
+ * Copyright (c) 2007 The Institute of Electrical and Electronics Engineers, Inc
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Alexander Nasonov.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in
+ *the documentation and/or other materials provided with the
+ *distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+
+#include "../../h_macros.h"
+
+#define SECSIZE 512
+
+struct testvec {
+	unsigned int blkno;
+	const uint8_t *ptxt;	/* PlainText  */
+	const uint8_t *ctxt;	/* CipherText */
+};
+
+/*
+ * 256 bits key from IEEE 1619/D16, NUL terminated.
+ */
+static const char aes_xts_256_key[33] = {
+	0x27, 0x18, 0x28, 0x18, 0x28, 0x45, 0x90, 0x45,
+	0x23, 0x53, 0x60, 0x28, 0x74, 0x71, 0x35, 0x26,
+	0x31, 0x41, 0x59, 0x26, 0x53, 0x58, 0x97, 0x93,
+	0x23, 0x84, 0x62, 0x64, 0x33, 0x83, 0x27, 0x95,
+	0
+};
+
+/*
+ * 512 bits key from IEEE 1619/D16, NUL terminated.
+ */
+static const char aes_xts_512_key[65] = 

CVS commit: src/sys/net

2016-07-29 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Fri Jul 29 20:29:38 UTC 2016

Modified Files:
src/sys/net: bpfjit.c

Log Message:
Don't trigger BJ_ASSERT(false) on invalid BPF_Jxxx opcode in jmp_to_op().

This change helps survive AFL fuzzing without calling bpf_validate() first.

Also change alu_to_op() function to have a similar interface.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/sys/net/bpfjit.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/net/bpfjit.c
diff -u src/sys/net/bpfjit.c:1.45 src/sys/net/bpfjit.c:1.46
--- src/sys/net/bpfjit.c:1.45	Sun May 29 17:20:22 2016
+++ src/sys/net/bpfjit.c	Fri Jul 29 20:29:38 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: bpfjit.c,v 1.45 2016/05/29 17:20:22 alnsn Exp $	*/
+/*	$NetBSD: bpfjit.c,v 1.46 2016/07/29 20:29:38 alnsn Exp $	*/
 
 /*-
  * Copyright (c) 2011-2015 Alexander Nasonov.
@@ -31,9 +31,9 @@
 
 #include 
 #ifdef _KERNEL
-__KERNEL_RCSID(0, "$NetBSD: bpfjit.c,v 1.45 2016/05/29 17:20:22 alnsn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bpfjit.c,v 1.46 2016/07/29 20:29:38 alnsn Exp $");
 #else
-__RCSID("$NetBSD: bpfjit.c,v 1.45 2016/05/29 17:20:22 alnsn Exp $");
+__RCSID("$NetBSD: bpfjit.c,v 1.46 2016/07/29 20:29:38 alnsn Exp $");
 #endif
 
 #include 
@@ -1594,10 +1594,9 @@ optimize(const bpf_ctx_t *bc, const stru
 /*
  * Convert BPF_ALU operations except BPF_NEG and BPF_DIV to sljit operation.
  */
-static int
-bpf_alu_to_sljit_op(const struct bpf_insn *pc)
+static bool
+alu_to_op(const struct bpf_insn *pc, int *res)
 {
-	const int bad = SLJIT_UNUSED;
 	const uint32_t k = pc->k;
 
 	/*
@@ -1605,49 +1604,64 @@ bpf_alu_to_sljit_op(const struct bpf_ins
 	 * instruction so SLJIT_I32_OP doesn't have any overhead.
 	 */
 	switch (BPF_OP(pc->code)) {
-	case BPF_ADD: return SLJIT_ADD;
-	case BPF_SUB: return SLJIT_SUB;
-	case BPF_MUL: return SLJIT_MUL|SLJIT_I32_OP;
-	case BPF_OR:  return SLJIT_OR;
-	case BPF_XOR: return SLJIT_XOR;
-	case BPF_AND: return SLJIT_AND;
-	case BPF_LSH: return (k > 31) ? bad : SLJIT_SHL;
-	case BPF_RSH: return (k > 31) ? bad : SLJIT_LSHR|SLJIT_I32_OP;
+	case BPF_ADD:
+		*res = SLJIT_ADD;
+		return true;
+	case BPF_SUB:
+		*res = SLJIT_SUB;
+		return true;
+	case BPF_MUL:
+		*res = SLJIT_MUL|SLJIT_I32_OP;
+		return true;
+	case BPF_OR:
+		*res = SLJIT_OR;
+		return true;
+	case BPF_XOR:
+		*res = SLJIT_XOR;
+		return true;
+	case BPF_AND:
+		*res = SLJIT_AND;
+		return true;
+	case BPF_LSH:
+		*res = SLJIT_SHL;
+		return k < 32;
+	case BPF_RSH:
+		*res = SLJIT_LSHR|SLJIT_I32_OP;
+		return k < 32;
 	default:
-		return bad;
+		return false;
 	}
 }
 
 /*
  * Convert BPF_JMP operations except BPF_JA to sljit condition.
  */
-static int
-bpf_jmp_to_sljit_cond(const struct bpf_insn *pc, bool negate)
+static bool
+jmp_to_cond(const struct bpf_insn *pc, bool negate, int *res)
 {
+
 	/*
 	 * Note: all supported 64bit arches have 32bit comparison
 	 * instructions so SLJIT_I32_OP doesn't have any overhead.
 	 */
-	int rv = SLJIT_I32_OP;
+	*res = SLJIT_I32_OP;
 
 	switch (BPF_OP(pc->code)) {
 	case BPF_JGT:
-		rv |= negate ? SLJIT_LESS_EQUAL : SLJIT_GREATER;
-		break;
+		*res |= negate ? SLJIT_LESS_EQUAL : SLJIT_GREATER;
+		return true;
 	case BPF_JGE:
-		rv |= negate ? SLJIT_LESS : SLJIT_GREATER_EQUAL;
-		break;
+		*res |= negate ? SLJIT_LESS : SLJIT_GREATER_EQUAL;
+		return true;
 	case BPF_JEQ:
-		rv |= negate ? SLJIT_NOT_EQUAL : SLJIT_EQUAL;
-		break;
+		*res |= negate ? SLJIT_NOT_EQUAL : SLJIT_EQUAL;
+		return true;
 	case BPF_JSET:
-		rv |= negate ? SLJIT_EQUAL : SLJIT_NOT_EQUAL;
-		break;
+		*res |= negate ? SLJIT_EQUAL : SLJIT_NOT_EQUAL;
+		return true;
 	default:
-		BJ_ASSERT(false);
+		return false;
 	}
-
-	return rv;
 }
 
 /*
@@ -1695,9 +1709,9 @@ generate_insn_code(struct sljit_compiler
 	struct sljit_jump *to_mchain_jump;
 
 	size_t i;
-	int status;
-	int branching, negate;
 	unsigned int rval, mode, src, op;
+	int branching, negate;
+	int status, cond, op2;
 	uint32_t jt, jf;
 
 	bool unconditional_ret;
@@ -1935,10 +1949,9 @@ generate_insn_code(struct sljit_compiler
 
 			op = BPF_OP(pc->code);
 			if (op != BPF_DIV && op != BPF_MOD) {
-const int op2 = bpf_alu_to_sljit_op(pc);
-
-if (op2 == SLJIT_UNUSED)
+if (!alu_to_op(pc, ))
 	goto fail;
+
 status = sljit_emit_op2(compiler,
 op2, BJ_AREG, 0, BJ_AREG, 0,
 kx_to_reg(pc), kx_to_reg_arg(pc));
@@ -2005,9 +2018,10 @@ generate_insn_code(struct sljit_compiler
 
 			if (branching) {
 if (op != BPF_JSET) {
+	if (!jmp_to_cond(pc, negate, ))
+		goto fail;
 	jump = sljit_emit_cmp(compiler,
-	bpf_jmp_to_sljit_cond(pc, negate),
-	BJ_AREG, 0,
+	cond, BJ_AREG, 0,
 	kx_to_reg(pc), kx_to_reg_arg(pc));
 } else {
 	status = sljit_emit_op2(compiler,
@@ -2018,10 +2032,10 @@ generate_insn_code(struct sljit_compiler
 	if

CVS commit: src/usr.sbin/installboot

2016-06-21 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Tue Jun 21 21:53:55 UTC 2016

Modified Files:
src/usr.sbin/installboot: installboot.8

Log Message:
Fix a typo: s/can be use/can be used/


To generate a diff of this commit:
cvs rdiff -u -r1.89 -r1.90 src/usr.sbin/installboot/installboot.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/installboot/installboot.8
diff -u src/usr.sbin/installboot/installboot.8:1.89 src/usr.sbin/installboot/installboot.8:1.90
--- src/usr.sbin/installboot/installboot.8:1.89	Sun Mar 22 22:35:08 2015
+++ src/usr.sbin/installboot/installboot.8	Tue Jun 21 21:53:55 2016
@@ -1,4 +1,4 @@
-.\"	$NetBSD: installboot.8,v 1.89 2015/03/22 22:35:08 wiz Exp $
+.\"	$NetBSD: installboot.8,v 1.90 2016/06/21 21:53:55 alnsn Exp $
 .\"
 .\" Copyright (c) 2002-2015 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -172,7 +172,7 @@ Clear (remove) any existing bootstrap in
 .
 .It Fl e
 Edit the options of an existing bootstrap.
-This can be use to change the options in bootxx_xxxfs files,
+This can be used to change the options in bootxx_xxxfs files,
 raw disk partitions, and the
 .Pa pxeboot_ia32.bin
 file.



CVS commit: src/sys/external/bsd/sljit/dist/sljit_src

2016-05-30 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Mon May 30 09:34:39 UTC 2016

Modified Files:
src/sys/external/bsd/sljit/dist/sljit_src: sljitNativePPC_common.c

Log Message:
Reduce diff with mainstream.

In the new sljt version, ppc_cache_flush() is guarded by
SLJIT_CACHE_FLUSH_OWN_IMPL. We can keep is as long as we
don't define SLJIT_CACHE_FLUSH_OWN_IMPL.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 \
src/sys/external/bsd/sljit/dist/sljit_src/sljitNativePPC_common.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/sljit/dist/sljit_src/sljitNativePPC_common.c
diff -u src/sys/external/bsd/sljit/dist/sljit_src/sljitNativePPC_common.c:1.6 src/sys/external/bsd/sljit/dist/sljit_src/sljitNativePPC_common.c:1.7
--- src/sys/external/bsd/sljit/dist/sljit_src/sljitNativePPC_common.c:1.6	Sun May 29 17:17:48 2016
+++ src/sys/external/bsd/sljit/dist/sljit_src/sljitNativePPC_common.c	Mon May 30 09:34:39 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: sljitNativePPC_common.c,v 1.6 2016/05/29 17:17:48 alnsn Exp $	*/
+/*	$NetBSD: sljitNativePPC_common.c,v 1.7 2016/05/30 09:34:39 alnsn Exp $	*/
 
 /*
  *Stack-less Just-In-Time compiler
@@ -48,6 +48,51 @@ typedef sljit_u32 sljit_ins;
 #define SLJIT_PASS_ENTRY_ADDR_TO_CALL 1
 #endif
 
+#if (defined SLJIT_CACHE_FLUSH_OWN_IMPL && SLJIT_CACHE_FLUSH_OWN_IMPL)
+
+static void ppc_cache_flush(sljit_ins *from, sljit_ins *to)
+{
+#ifdef _AIX
+	_sync_cache_range((caddr_t)from, (int)((size_t)to - (size_t)from));
+#elif defined(__GNUC__) || (defined(__IBM_GCC_ASM) && __IBM_GCC_ASM)
+#	if defined(_ARCH_PWR) || defined(_ARCH_PWR2)
+	/* Cache flush for POWER architecture. */
+	while (from < to) {
+		__asm__ volatile (
+			"clf 0, %0\n"
+			"dcs\n"
+			: : "r"(from)
+		);
+		from++;
+	}
+	__asm__ volatile ( "ics" );
+#	elif defined(_ARCH_COM) && !defined(_ARCH_PPC)
+#	error "Cache flush is not implemented for PowerPC/POWER common mode."
+#	else
+	/* Cache flush for PowerPC architecture. */
+	while (from < to) {
+		__asm__ volatile (
+			"dcbf 0, %0\n"
+			"sync\n"
+			"icbi 0, %0\n"
+			: : "r"(from)
+		);
+		from++;
+	}
+	__asm__ volatile ( "isync" );
+#	endif
+#	ifdef __xlc__
+#	warning "This file may fail to compile if -qfuncsect is used"
+#	endif
+#elif defined(__xlc__)
+#error "Please enable GCC syntax for inline assembly statements with -qasm=gcc"
+#else
+#error "This platform requires a cache flush implementation."
+#endif /* _AIX */
+}
+
+#endif /* (defined SLJIT_CACHE_FLUSH_OWN_IMPL && SLJIT_CACHE_FLUSH_OWN_IMPL) */
+
 #define TMP_REG1	(SLJIT_NUMBER_OF_REGISTERS + 2)
 #define TMP_REG2	(SLJIT_NUMBER_OF_REGISTERS + 3)
 #define TMP_REG3	(SLJIT_NUMBER_OF_REGISTERS + 4)



CVS commit: src/doc

2016-05-29 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sun May 29 22:41:55 UTC 2016

Modified Files:
src/doc: 3RDPARTY

Log Message:
Update sljit entry.


To generate a diff of this commit:
cvs rdiff -u -r1.1332 -r1.1333 src/doc/3RDPARTY

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/doc/3RDPARTY
diff -u src/doc/3RDPARTY:1.1332 src/doc/3RDPARTY:1.1333
--- src/doc/3RDPARTY:1.1332	Thu May 26 16:55:08 2016
+++ src/doc/3RDPARTY	Sun May 29 22:41:54 2016
@@ -1,4 +1,4 @@
-#	$NetBSD: 3RDPARTY,v 1.1332 2016/05/26 16:55:08 christos Exp $
+#	$NetBSD: 3RDPARTY,v 1.1333 2016/05/29 22:41:54 alnsn Exp $
 #
 # This file contains a list of the software that has been integrated into
 # NetBSD where we are not the primary maintainer.
@@ -1526,8 +1526,8 @@ Location:	external/cddl/osnet
 Notes:
 
 Package:	sljit
-Version:	0.91 (svn revision 257)
-Current Vers:	svn revision 268
+Version:	svn revision 313
+Current Vers:	svn revision 313
 Maintainer:	Zoltán Herczeg 

CVS commit: src/sys/sys

2016-05-29 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sun May 29 18:22:30 UTC 2016

Modified Files:
src/sys/sys: param.h

Log Message:
Update version in the comment too.


To generate a diff of this commit:
cvs rdiff -u -r1.495 -r1.496 src/sys/sys/param.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/sys/param.h
diff -u src/sys/sys/param.h:1.495 src/sys/sys/param.h:1.496
--- src/sys/sys/param.h:1.495	Sun May 29 18:15:05 2016
+++ src/sys/sys/param.h	Sun May 29 18:22:30 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.495 2016/05/29 18:15:05 alnsn Exp $	*/
+/*	$NetBSD: param.h,v 1.496 2016/05/29 18:22:30 alnsn Exp $	*/
 
 /*-
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -67,7 +67,7 @@
  *	2.99.9		(299000900)
  */
 
-#define	__NetBSD_Version__	799003000	/* NetBSD 7.99.29 */
+#define	__NetBSD_Version__	799003000	/* NetBSD 7.99.30 */
 
 #define __NetBSD_Prereq__(M,m,p) (M) * 1) + \
 (m) * 100) + (p) * 100) <= __NetBSD_Version__)



CVS commit: src/sys/sys

2016-05-29 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sun May 29 18:15:05 UTC 2016

Modified Files:
src/sys/sys: param.h

Log Message:
Version bump after sljit import.

New version of sljit is not binary compatible with the previous
version.


To generate a diff of this commit:
cvs rdiff -u -r1.494 -r1.495 src/sys/sys/param.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/sys/param.h
diff -u src/sys/sys/param.h:1.494 src/sys/sys/param.h:1.495
--- src/sys/sys/param.h:1.494	Fri Apr 29 01:14:23 2016
+++ src/sys/sys/param.h	Sun May 29 18:15:05 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.494 2016/04/29 01:14:23 christos Exp $	*/
+/*	$NetBSD: param.h,v 1.495 2016/05/29 18:15:05 alnsn Exp $	*/
 
 /*-
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -67,7 +67,7 @@
  *	2.99.9		(299000900)
  */
 
-#define	__NetBSD_Version__	799002900	/* NetBSD 7.99.29 */
+#define	__NetBSD_Version__	799003000	/* NetBSD 7.99.29 */
 
 #define __NetBSD_Prereq__(M,m,p) (M) * 1) + \
 (m) * 100) + (p) * 100) <= __NetBSD_Version__)



CVS commit: src/sys/external/bsd/sljit

2016-05-29 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sun May 29 17:56:20 UTC 2016

Modified Files:
src/sys/external/bsd/sljit: README.import

Log Message:
Update sljit revision to r313 after the import.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/external/bsd/sljit/README.import

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/sljit/README.import
diff -u src/sys/external/bsd/sljit/README.import:1.4 src/sys/external/bsd/sljit/README.import:1.5
--- src/sys/external/bsd/sljit/README.import:1.4	Tue Jun 17 16:49:11 2014
+++ src/sys/external/bsd/sljit/README.import	Sun May 29 17:56:20 2016
@@ -1,6 +1,6 @@
 There are no CVS/SVN ids in sljit repository but don't forget to
 remove .svn before importing the new version.
 
-Current sljit import is @ r257:
+Current sljit import is @ r313:
 
-svn co https://sljit.svn.sourceforge.net/svnroot/sljit@257 dist
+svn co https://svn.code.sf.net/p/sljit/code@r313 dist



CVS commit: src/sys/net

2016-05-29 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sun May 29 17:20:22 UTC 2016

Modified Files:
src/sys/net: bpfjit.c

Log Message:
Adapt to the new version of sljit@r313.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/sys/net/bpfjit.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/net/bpfjit.c
diff -u src/sys/net/bpfjit.c:1.44 src/sys/net/bpfjit.c:1.45
--- src/sys/net/bpfjit.c:1.44	Tue Dec 29 21:49:58 2015
+++ src/sys/net/bpfjit.c	Sun May 29 17:20:22 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: bpfjit.c,v 1.44 2015/12/29 21:49:58 alnsn Exp $	*/
+/*	$NetBSD: bpfjit.c,v 1.45 2016/05/29 17:20:22 alnsn Exp $	*/
 
 /*-
  * Copyright (c) 2011-2015 Alexander Nasonov.
@@ -31,9 +31,9 @@
 
 #include 
 #ifdef _KERNEL
-__KERNEL_RCSID(0, "$NetBSD: bpfjit.c,v 1.44 2015/12/29 21:49:58 alnsn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bpfjit.c,v 1.45 2016/05/29 17:20:22 alnsn Exp $");
 #else
-__RCSID("$NetBSD: bpfjit.c,v 1.44 2015/12/29 21:49:58 alnsn Exp $");
+__RCSID("$NetBSD: bpfjit.c,v 1.45 2016/05/29 17:20:22 alnsn Exp $");
 #endif
 
 #include 
@@ -85,20 +85,20 @@ __RCSID("$NetBSD: bpfjit.c,v 1.44 2015/1
  * The first argument is reassigned upon entry
  * to a more frequently used buf argument.
  */
-#define BJ_CTX_ARG	SLJIT_SAVED_REG1
-#define BJ_ARGS		SLJIT_SAVED_REG2
+#define BJ_CTX_ARG	SLJIT_S0
+#define BJ_ARGS		SLJIT_S1
 
 /*
  * Permanent register assignments.
  */
-#define BJ_BUF		SLJIT_SAVED_REG1
-//#define BJ_ARGS	SLJIT_SAVED_REG2
-#define BJ_BUFLEN	SLJIT_SAVED_REG3
-#define BJ_AREG		SLJIT_SCRATCH_REG1
-#define BJ_TMP1REG	SLJIT_SCRATCH_REG2
-#define BJ_TMP2REG	SLJIT_SCRATCH_REG3
-#define BJ_XREG		SLJIT_TEMPORARY_EREG1
-#define BJ_TMP3REG	SLJIT_TEMPORARY_EREG2
+#define BJ_BUF		SLJIT_S0
+//#define BJ_ARGS	SLJIT_S1
+#define BJ_BUFLEN	SLJIT_S2
+#define BJ_AREG		SLJIT_R0
+#define BJ_TMP1REG	SLJIT_R1
+#define BJ_TMP2REG	SLJIT_R2
+#define BJ_XREG		SLJIT_R3
+#define BJ_TMP3REG	SLJIT_R4
 
 #ifdef _KERNEL
 #define MAX_MEMWORDS BPF_MAX_MEMWORDS
@@ -248,10 +248,10 @@ bpfjit_modcmd(modcmd_t cmd, void *arg)
  * Return a number of scratch registers to pass
  * to sljit_emit_enter() function.
  */
-static sljit_si
+static sljit_s32
 nscratches(bpfjit_hint_t hints)
 {
-	sljit_si rv = 2;
+	sljit_s32 rv = 2;
 
 #ifdef _KERNEL
 	if (hints & BJ_HINT_PKT)
@@ -354,11 +354,11 @@ append_jump(struct sljit_jump *jump, str
  * Emit code for BPF_LD+BPF_B+BPF_ABSA <- P[k:1].
  */
 static int
-emit_read8(struct sljit_compiler *compiler, sljit_si src, uint32_t k)
+emit_read8(struct sljit_compiler *compiler, sljit_s32 src, uint32_t k)
 {
 
 	return sljit_emit_op1(compiler,
-	SLJIT_MOV_UB,
+	SLJIT_MOV_U8,
 	BJ_AREG, 0,
 	SLJIT_MEM1(src), k);
 }
@@ -367,7 +367,7 @@ emit_read8(struct sljit_compiler *compil
  * Emit code for BPF_LD+BPF_H+BPF_ABSA <- P[k:2].
  */
 static int
-emit_read16(struct sljit_compiler *compiler, sljit_si src, uint32_t k)
+emit_read16(struct sljit_compiler *compiler, sljit_s32 src, uint32_t k)
 {
 	int status;
 
@@ -375,7 +375,7 @@ emit_read16(struct sljit_compiler *compi
 
 	/* A = buf[k]; */
 	status = sljit_emit_op1(compiler,
-	SLJIT_MOV_UB,
+	SLJIT_MOV_U8,
 	BJ_AREG, 0,
 	SLJIT_MEM1(src), k);
 	if (status != SLJIT_SUCCESS)
@@ -383,7 +383,7 @@ emit_read16(struct sljit_compiler *compi
 
 	/* tmp1 = buf[k+1]; */
 	status = sljit_emit_op1(compiler,
-	SLJIT_MOV_UB,
+	SLJIT_MOV_U8,
 	BJ_TMP1REG, 0,
 	SLJIT_MEM1(src), k+1);
 	if (status != SLJIT_SUCCESS)
@@ -411,7 +411,7 @@ emit_read16(struct sljit_compiler *compi
  * Emit code for BPF_LD+BPF_W+BPF_ABSA <- P[k:4].
  */
 static int
-emit_read32(struct sljit_compiler *compiler, sljit_si src, uint32_t k)
+emit_read32(struct sljit_compiler *compiler, sljit_s32 src, uint32_t k)
 {
 	int status;
 
@@ -419,7 +419,7 @@ emit_read32(struct sljit_compiler *compi
 
 	/* A = buf[k]; */
 	status = sljit_emit_op1(compiler,
-	SLJIT_MOV_UB,
+	SLJIT_MOV_U8,
 	BJ_AREG, 0,
 	SLJIT_MEM1(src), k);
 	if (status != SLJIT_SUCCESS)
@@ -427,7 +427,7 @@ emit_read32(struct sljit_compiler *compi
 
 	/* tmp1 = buf[k+1]; */
 	status = sljit_emit_op1(compiler,
-	SLJIT_MOV_UB,
+	SLJIT_MOV_U8,
 	BJ_TMP1REG, 0,
 	SLJIT_MEM1(src), k+1);
 	if (status != SLJIT_SUCCESS)
@@ -453,7 +453,7 @@ emit_read32(struct sljit_compiler *compi
 
 	/* tmp1 = buf[k+2]; */
 	status = sljit_emit_op1(compiler,
-	SLJIT_MOV_UB,
+	SLJIT_MOV_U8,
 	BJ_TMP1REG, 0,
 	SLJIT_MEM1(src), k+2);
 	if (status != SLJIT_SUCCESS)
@@ -479,7 +479,7 @@ emit_read32(struct sljit_compiler *compi
 
 	/* tmp1 = buf[k+3]; */
 	status = sljit_emit_op1(compiler,
-	SLJIT_MOV_UB,
+	SLJIT_MOV_U8,
 	BJ_TMP1REG, 0,
 	SLJIT_MEM1(src), k+3);
 	if (status != SLJIT_SUCCESS)
@@ -522,13 +522,13 @@ emit_xcall(struct sljit_compiler *compil
 uint32_t (*fn)(const struct mbu

CVS commit: src/sys/external/bsd/sljit/dist/sljit_src

2016-05-29 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sun May 29 17:19:01 UTC 2016

Modified Files:
src/sys/external/bsd/sljit/dist/sljit_src: sljitConfig.h sljitUtils.c

Log Message:
Alloc/free macros in the new sljit version take two arguments.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 \
src/sys/external/bsd/sljit/dist/sljit_src/sljitConfig.h
cvs rdiff -u -r1.8 -r1.9 \
src/sys/external/bsd/sljit/dist/sljit_src/sljitUtils.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/sljit/dist/sljit_src/sljitConfig.h
diff -u src/sys/external/bsd/sljit/dist/sljit_src/sljitConfig.h:1.13 src/sys/external/bsd/sljit/dist/sljit_src/sljitConfig.h:1.14
--- src/sys/external/bsd/sljit/dist/sljit_src/sljitConfig.h:1.13	Sun May 29 17:09:33 2016
+++ src/sys/external/bsd/sljit/dist/sljit_src/sljitConfig.h	Sun May 29 17:19:01 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: sljitConfig.h,v 1.13 2016/05/29 17:09:33 alnsn Exp $	*/
+/*	$NetBSD: sljitConfig.h,v 1.14 2016/05/29 17:19:01 alnsn Exp $	*/
 
 /*
  *Stack-less Just-In-Time compiler
@@ -60,11 +60,11 @@
 #include 
 
 #if defined(_KERNEL) && !defined(SLJIT_MALLOC)
-#define SLJIT_MALLOC(size) malloc((size), M_TEMP, M_WAITOK)
+#define SLJIT_MALLOC(size, allocator_data) malloc((size), M_TEMP, M_WAITOK)
 #endif
 
 #if defined(_KERNEL) && !defined(SLJIT_FREE)
-#define SLJIT_FREE(ptr) free((ptr), M_TEMP)
+#define SLJIT_FREE(ptr, allocator_data) free((ptr), M_TEMP)
 #endif
 
 #if defined(_KERNEL) && !defined(SLJIT_CACHE_FLUSH)

Index: src/sys/external/bsd/sljit/dist/sljit_src/sljitUtils.c
diff -u src/sys/external/bsd/sljit/dist/sljit_src/sljitUtils.c:1.8 src/sys/external/bsd/sljit/dist/sljit_src/sljitUtils.c:1.9
--- src/sys/external/bsd/sljit/dist/sljit_src/sljitUtils.c:1.8	Sun May 29 17:09:33 2016
+++ src/sys/external/bsd/sljit/dist/sljit_src/sljitUtils.c	Sun May 29 17:19:01 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: sljitUtils.c,v 1.8 2016/05/29 17:09:33 alnsn Exp $	*/
+/*	$NetBSD: sljitUtils.c,v 1.9 2016/05/29 17:19:01 alnsn Exp $	*/
 
 /*
  *Stack-less Just-In-Time compiler
@@ -294,7 +294,7 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_st
 	v = uvm_km_alloc(kernel_map, max_limit, PAGE_SIZE, UVM_KMF_WIRED|UVM_KMF_ZERO);
 	base.ptr = (void *)v;
 	if (base.ptr == NULL) {
-		SLJIT_FREE(stack);
+		SLJIT_FREE(stack, allocator_data);
 		return NULL;
 	}
 	stack->base = base.uw;



CVS commit: src/sys/external/bsd/sljit/dist/sljit_src

2016-05-29 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sun May 29 17:17:48 UTC 2016

Modified Files:
src/sys/external/bsd/sljit/dist/sljit_src: sljitNativePPC_common.c

Log Message:
Fix a pilot error in the manual conflict handling..


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 \
src/sys/external/bsd/sljit/dist/sljit_src/sljitNativePPC_common.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/sljit/dist/sljit_src/sljitNativePPC_common.c
diff -u src/sys/external/bsd/sljit/dist/sljit_src/sljitNativePPC_common.c:1.5 src/sys/external/bsd/sljit/dist/sljit_src/sljitNativePPC_common.c:1.6
--- src/sys/external/bsd/sljit/dist/sljit_src/sljitNativePPC_common.c:1.5	Sun May 29 17:09:33 2016
+++ src/sys/external/bsd/sljit/dist/sljit_src/sljitNativePPC_common.c	Sun May 29 17:17:48 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: sljitNativePPC_common.c,v 1.5 2016/05/29 17:09:33 alnsn Exp $	*/
+/*	$NetBSD: sljitNativePPC_common.c,v 1.6 2016/05/29 17:17:48 alnsn Exp $	*/
 
 /*
  *Stack-less Just-In-Time compiler
@@ -48,10 +48,10 @@ typedef sljit_u32 sljit_ins;
 #define SLJIT_PASS_ENTRY_ADDR_TO_CALL 1
 #endif
 
-#define TMP_REG1	(SLJIT_NO_REGISTERS + 1)
-#define TMP_REG2	(SLJIT_NO_REGISTERS + 2)
-#define TMP_REG3	(SLJIT_NO_REGISTERS + 3)
-#define TMP_ZERO	(SLJIT_NO_REGISTERS + 4)
+#define TMP_REG1	(SLJIT_NUMBER_OF_REGISTERS + 2)
+#define TMP_REG2	(SLJIT_NUMBER_OF_REGISTERS + 3)
+#define TMP_REG3	(SLJIT_NUMBER_OF_REGISTERS + 4)
+#define TMP_ZERO	(SLJIT_NUMBER_OF_REGISTERS + 5)
 
 #if (defined SLJIT_PASS_ENTRY_ADDR_TO_CALL && SLJIT_PASS_ENTRY_ADDR_TO_CALL)
 #define TMP_CALL_REG	(SLJIT_NUMBER_OF_REGISTERS + 6)



CVS commit: src/sys/external/bsd/sljit/dist

2016-05-29 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sun May 29 17:09:33 UTC 2016

Modified Files:
src/sys/external/bsd/sljit/dist/sljit_src: sljitConfig.h
sljitConfigInternal.h sljitExecAllocator.c sljitLir.c sljitLir.h
sljitNativeARM_32.c sljitNativeARM_64.c sljitNativeARM_T2_32.c
sljitNativeMIPS_32.c sljitNativeMIPS_64.c sljitNativeMIPS_common.c
sljitNativePPC_32.c sljitNativePPC_64.c sljitNativePPC_common.c
sljitNativeSPARC_32.c sljitNativeSPARC_common.c
sljitNativeTILEGX_64.c sljitNativeX86_32.c sljitNativeX86_64.c
sljitNativeX86_common.c sljitUtils.c
src/sys/external/bsd/sljit/dist/test_src: sljitMain.c sljitTest.c

Log Message:
Resolve conflicts.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 \
src/sys/external/bsd/sljit/dist/sljit_src/sljitConfig.h
cvs rdiff -u -r1.9 -r1.10 \
src/sys/external/bsd/sljit/dist/sljit_src/sljitConfigInternal.h
cvs rdiff -u -r1.4 -r1.5 \
src/sys/external/bsd/sljit/dist/sljit_src/sljitExecAllocator.c \
src/sys/external/bsd/sljit/dist/sljit_src/sljitLir.c \
src/sys/external/bsd/sljit/dist/sljit_src/sljitNativePPC_common.c \
src/sys/external/bsd/sljit/dist/sljit_src/sljitNativeX86_32.c
cvs rdiff -u -r1.2 -r1.3 src/sys/external/bsd/sljit/dist/sljit_src/sljitLir.h \
src/sys/external/bsd/sljit/dist/sljit_src/sljitNativeARM_32.c \
src/sys/external/bsd/sljit/dist/sljit_src/sljitNativeARM_64.c \
src/sys/external/bsd/sljit/dist/sljit_src/sljitNativeARM_T2_32.c \
src/sys/external/bsd/sljit/dist/sljit_src/sljitNativeMIPS_32.c \
src/sys/external/bsd/sljit/dist/sljit_src/sljitNativeMIPS_64.c \
src/sys/external/bsd/sljit/dist/sljit_src/sljitNativeMIPS_common.c \
src/sys/external/bsd/sljit/dist/sljit_src/sljitNativePPC_32.c \
src/sys/external/bsd/sljit/dist/sljit_src/sljitNativePPC_64.c \
src/sys/external/bsd/sljit/dist/sljit_src/sljitNativeSPARC_32.c \
src/sys/external/bsd/sljit/dist/sljit_src/sljitNativeSPARC_common.c \
src/sys/external/bsd/sljit/dist/sljit_src/sljitNativeTILEGX_64.c \
src/sys/external/bsd/sljit/dist/sljit_src/sljitNativeX86_64.c
cvs rdiff -u -r1.7 -r1.8 \
src/sys/external/bsd/sljit/dist/sljit_src/sljitNativeX86_common.c \
src/sys/external/bsd/sljit/dist/sljit_src/sljitUtils.c
cvs rdiff -u -r1.4 -r1.5 src/sys/external/bsd/sljit/dist/test_src/sljitMain.c
cvs rdiff -u -r1.6 -r1.7 src/sys/external/bsd/sljit/dist/test_src/sljitTest.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffs are larger than 1MB and have been omitted


CVS import: src/sys/external/bsd/sljit/dist

2016-05-29 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sun May 29 17:00:38 UTC 2016

Update of /cvsroot/src/sys/external/bsd/sljit/dist
In directory ivanova.netbsd.org:/tmp/cvs-serv561

Log Message:
Import sljit version r313.

Changes since the last import:

r313 Fix a racing condition reported by Mozilla.
r312 Support Android ARM64 cacheflush. Patch by Tavian Barnes.
r311 Update opcode dump.
r310 Better type specification for integer operations and conditional types.
r309 Better type specification for long mul and divide operators.
r308 Better type specification for floating point operations.
r307 Change d and s postfixes to f64 and f32.
r306 Change b,h,i postifxes to 8,16,32.
r305 Fix a wrong immediate number. Reported by Michael McConville.
r304 Make file patch by Michael McConville.
r303 Landed changes created by Michael McConville.
r302 Add support for cmov on x86.
r301 Tile-Gx fixes by Walter Lee
r300 Add WinCE support.
r299 Add a tutorial for SLJIT. Contributed by Wen Xichang.
r298 Improve integer division.
r297 Start reworking the integer division.
r296 Add an overview for SLJIT.
r295 Small optimizations for x86 and ARM64.
r294 Fix ARM64 SP alignment.
r293 Add a new sljit_set_compiler_memory_error function.
r292 Add missing argument on ARM32.
r291 Minor fixes and NOINLINE support.
r290 Support custom memory allocators.
r289 Add SLJIT_DOUBLE_ALIGNMENT support and emit_op_custom size check.
r288 Add suport for SLJIT_ARGUMENT_CHECKS on all architectures.
r287 Add SLJIT_ARGUMENT_CHECKS compiler option and lots of cleanups.
r286 Support the new naming on PPC and MIPS.
r285 Support the new naming on ARM and SPARC.
r284 Move the type letter to the beggining of the floating point opcodes.
r283 Add i_ s_ d_ froms to compare types.
r282 Fix an incorrect form of mul on x86-64.
r281 Refactoring sljitConfigInternal.h header.
r280 Remove variable locals offset.
r279 Test skips are not reported if verbose is disabled.
r278 Add options to sljit_emit_enter and sljit_set_context.
r277 Reindexing opX opcodes.
r276 Some comments are fixed and minor refactors were done.
r275 Minor optimizations.
r274 Extend the register set on ARM.
r273 Extend the register set on PPC, MIPS, SPARC.
r272 Allow remapping of any registers: not just scratch->saved, but 
saved->scratch as well.
r271 Renaming floating point registers to support more of them.
r270 Extend the register set on x86.
r269 Renaming integer registers for preparing the support of any all machine 
registers.
r268 Refactor a macro to work when debug is disabled.
r267 Introduce architecture macros without 32/64 bit postfix.
r266 The floating point conversion operators are finished on PPC, and they are 
supported on all architectures now.
r265 FPU operations support locals access now. CONW is supported on PPC now.
r264 Continue code refactoring, MOVS/MOVD are optimized on all architectures.
r263 SPARC implementation of floating point operators.
r262 Small refactorings.
r261 MIPS implementation of floating point conversion operators.
r260 ARM implementation of floating point operators.
r259 x86 implementation of floating point conversion operators.
r258 Refactoring sljit_emit_fop1 opcodes, inserting placeholders for new ones.

Status:

Vendor Tag: TNF
Release Tags:   SLJIT-r313

N src/sys/external/bsd/sljit/dist/hist
U src/sys/external/bsd/sljit/dist/API_CHANGES
U src/sys/external/bsd/sljit/dist/INTERNAL_CHANGES
U src/sys/external/bsd/sljit/dist/Makefile
U src/sys/external/bsd/sljit/dist/README
U src/sys/external/bsd/sljit/dist/regex_src/regexMain.c
U src/sys/external/bsd/sljit/dist/regex_src/regexJIT.c
U src/sys/external/bsd/sljit/dist/regex_src/regexJIT.h
N src/sys/external/bsd/sljit/dist/doc/overview.txt
N src/sys/external/bsd/sljit/dist/doc/tutorial/first_program.c
N src/sys/external/bsd/sljit/dist/doc/tutorial/array_access.c
N src/sys/external/bsd/sljit/dist/doc/tutorial/99bottles.bf
N src/sys/external/bsd/sljit/dist/doc/tutorial/brainfuck.c
N src/sys/external/bsd/sljit/dist/doc/tutorial/struct_access.c
N src/sys/external/bsd/sljit/dist/doc/tutorial/func_call.c
N src/sys/external/bsd/sljit/dist/doc/tutorial/hello.bf
N src/sys/external/bsd/sljit/dist/doc/tutorial/loop.c
N src/sys/external/bsd/sljit/dist/doc/tutorial/sljit_tutorial.html
N src/sys/external/bsd/sljit/dist/doc/tutorial/README
N src/sys/external/bsd/sljit/dist/doc/tutorial/branch.c
N src/sys/external/bsd/sljit/dist/doc/tutorial/temp_var.c
C src/sys/external/bsd/sljit/dist/test_src/sljitTest.c
C src/sys/external/bsd/sljit/dist/test_src/sljitMain.c
C src/sys/external/bsd/sljit/dist/sljit_src/sljitNativeMIPS_64.c
C src/sys/external/bsd/sljit/dist/sljit_src/sljitNativeARM_32.c
C src/sys/external/bsd/sljit/dist/sljit_src/sljitLir.h
C src/sys/external/bsd/sljit/dist/sljit_src/sljitNativePPC_32.c
C src/sys/external/bsd/sljit/dist/sljit_src/sljitNativeARM_64.c
C src/sys/external/bsd/sljit/dist/sljit_src/sljitNativeARM_T2_32.c
C src/sys/external/bsd/sljit/dist/sljit_src/sljitUtils.c
C 

CVS commit: src/usr.bin/kdump

2016-03-27 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sun Mar 27 21:51:20 UTC 2016

Modified Files:
src/usr.bin/kdump: kdump.c

Log Message:
Don't enter infinite loop on big ktr_len values.

Fixes PR 49460.


To generate a diff of this commit:
cvs rdiff -u -r1.122 -r1.123 src/usr.bin/kdump/kdump.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/kdump/kdump.c
diff -u src/usr.bin/kdump/kdump.c:1.122 src/usr.bin/kdump/kdump.c:1.123
--- src/usr.bin/kdump/kdump.c:1.122	Mon Jan  4 08:24:42 2016
+++ src/usr.bin/kdump/kdump.c	Sun Mar 27 21:51:20 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: kdump.c,v 1.122 2016/01/04 08:24:42 martin Exp $	*/
+/*	$NetBSD: kdump.c,v 1.123 2016/03/27 21:51:20 alnsn Exp $	*/
 
 /*-
  * Copyright (c) 1988, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19
 #if 0
 static char sccsid[] = "@(#)kdump.c	8.4 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: kdump.c,v 1.122 2016/01/04 08:24:42 martin Exp $");
+__RCSID("$NetBSD: kdump.c,v 1.123 2016/03/27 21:51:20 alnsn Exp $");
 #endif
 #endif /* not lint */
 
@@ -109,7 +109,7 @@ static void	ioctldecode(u_long);
 static void	ktrsyscall(struct ktr_syscall *);
 static void	ktrsysret(struct ktr_sysret *, int);
 static void	ktrnamei(char *, int);
-static void	ktremul(char *, int, int);
+static void	ktremul(char *, size_t, size_t);
 static void	ktrgenio(struct ktr_genio *, int);
 static void	ktrpsig(void *, int);
 static void	ktrcsw(struct ktr_csw *);
@@ -126,7 +126,8 @@ static void visdump_buf(const void *, in
 int
 main(int argc, char **argv)
 {
-	int ch, ktrlen, size;
+	unsigned int ktrlen, size;
+	int ch;
 	void *m;
 	int trpoints = 0;
 	int trset = 0;
@@ -249,7 +250,7 @@ main(int argc, char **argv)
 			col = dumpheader(_header);
 		else
 			col = -1;
-		if ((ktrlen = ktr_header.ktr_len) < 0)
+		if ((ktrlen = ktr_header.ktr_len) > INT_MAX)
 			errx(1, "bogus length 0x%x", ktrlen);
 		if (ktrlen > size) {
 			while (ktrlen > size)
@@ -751,7 +752,7 @@ ktrnamei(char *cp, int len)
 }
 
 static void
-ktremul(char *name, int len, int bufsize)
+ktremul(char *name, size_t len, size_t bufsize)
 {
 
 	if (len >= bufsize)



CVS commit: src/sys/net

2015-12-30 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Tue Dec 29 21:49:58 UTC 2015

Modified Files:
src/sys/net: bpfjit.c

Log Message:
Replace the nsaveds() function with #define NSAVEDS 3. No functional change.

Patch from Michael McConville.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/net/bpfjit.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/net/bpfjit.c
diff -u src/sys/net/bpfjit.c:1.43 src/sys/net/bpfjit.c:1.44
--- src/sys/net/bpfjit.c:1.43	Sat Feb 14 21:32:46 2015
+++ src/sys/net/bpfjit.c	Tue Dec 29 21:49:58 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: bpfjit.c,v 1.43 2015/02/14 21:32:46 alnsn Exp $	*/
+/*	$NetBSD: bpfjit.c,v 1.44 2015/12/29 21:49:58 alnsn Exp $	*/
 
 /*-
  * Copyright (c) 2011-2015 Alexander Nasonov.
@@ -31,9 +31,9 @@
 
 #include 
 #ifdef _KERNEL
-__KERNEL_RCSID(0, "$NetBSD: bpfjit.c,v 1.43 2015/02/14 21:32:46 alnsn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bpfjit.c,v 1.44 2015/12/29 21:49:58 alnsn Exp $");
 #else
-__RCSID("$NetBSD: bpfjit.c,v 1.43 2015/02/14 21:32:46 alnsn Exp $");
+__RCSID("$NetBSD: bpfjit.c,v 1.44 2015/12/29 21:49:58 alnsn Exp $");
 #endif
 
 #include 
@@ -76,6 +76,11 @@ __RCSID("$NetBSD: bpfjit.c,v 1.43 2015/0
 #endif
 
 /*
+ * Number of saved registers to pass to sljit_emit_enter() function.
+ */
+#define NSAVEDS		3
+
+/*
  * Arguments of generated bpfjit_func_t.
  * The first argument is reassigned upon entry
  * to a more frequently used buf argument.
@@ -273,18 +278,6 @@ nscratches(bpfjit_hint_t hints)
 	return rv;
 }
 
-/*
- * Return a number of saved registers to pass
- * to sljit_emit_enter() function.
- */
-static sljit_si
-nsaveds(bpfjit_hint_t hints)
-{
-	sljit_si rv = 3;
-
-	return rv;
-}
-
 static uint32_t
 read_width(const struct bpf_insn *pc)
 {
@@ -2192,7 +2185,7 @@ bpfjit_generate_code(const bpf_ctx_t *bc
 #endif
 
 	status = sljit_emit_enter(compiler,
-	2, nscratches(hints), nsaveds(hints), sizeof(struct bpfjit_stack));
+	2, nscratches(hints), NSAVEDS, sizeof(struct bpfjit_stack));
 	if (status != SLJIT_SUCCESS)
 		goto fail;
 



CVS commit: src/sys/arch/amd64/include

2015-06-10 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Wed Jun 10 23:16:27 UTC 2015

Modified Files:
src/sys/arch/amd64/include: sljit_machdep.h

Log Message:
Include i386/sljit_machdep.h for i386 compat build.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/amd64/include/sljit_machdep.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/amd64/include/sljit_machdep.h
diff -u src/sys/arch/amd64/include/sljit_machdep.h:1.1 src/sys/arch/amd64/include/sljit_machdep.h:1.2
--- src/sys/arch/amd64/include/sljit_machdep.h:1.1	Wed Jul 23 18:19:43 2014
+++ src/sys/arch/amd64/include/sljit_machdep.h	Wed Jun 10 23:16:27 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: sljit_machdep.h,v 1.1 2014/07/23 18:19:43 alnsn Exp $	*/
+/*	$NetBSD: sljit_machdep.h,v 1.2 2015/06/10 23:16:27 alnsn Exp $	*/
 
 /*-
  * Copyright (c) 2012-2013 The NetBSD Foundation, Inc.
@@ -29,8 +29,16 @@
 #ifndef _AMD64_SLJITARCH_H
 #define _AMD64_SLJITARCH_H
 
+#if !defined __i386__
+
 #define SLJIT_CONFIG_X86_64 1
 
 #define SLJIT_CACHE_FLUSH(from, to)
 
+#else	/*	!__i386__	*/
+
+#include i386/sljit_machdep.h
+
+#endif
+
 #endif



CVS commit: src/sys/external/bsd/sljit/dist/test_src

2015-02-16 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Mon Feb 16 13:30:15 UTC 2015

Modified Files:
src/sys/external/bsd/sljit/dist/test_src: sljitTest.c

Log Message:
Backport a new testcase from r282 (registers are renamed in the new version).
http://sourceforge.net/p/sljit/code/282/.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/external/bsd/sljit/dist/test_src/sljitTest.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/sljit/dist/test_src/sljitTest.c
diff -u src/sys/external/bsd/sljit/dist/test_src/sljitTest.c:1.4 src/sys/external/bsd/sljit/dist/test_src/sljitTest.c:1.5
--- src/sys/external/bsd/sljit/dist/test_src/sljitTest.c:1.4	Tue Jun 17 19:37:03 2014
+++ src/sys/external/bsd/sljit/dist/test_src/sljitTest.c	Mon Feb 16 13:30:15 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: sljitTest.c,v 1.4 2014/06/17 19:37:03 alnsn Exp $	*/
+/*	$NetBSD: sljitTest.c,v 1.5 2015/02/16 13:30:15 alnsn Exp $	*/
 
 /*
  *Stack-less Just-In-Time compiler
@@ -733,7 +733,7 @@ static void test10(void)
 	/* Test multiplications. */
 	executable_code code;
 	struct sljit_compiler* compiler = sljit_create_compiler();
-	sljit_sw buf[6];
+	sljit_sw buf[7];
 
 	if (verbose)
 		printf(Run test10\n);
@@ -745,6 +745,7 @@ static void test10(void)
 	buf[3] = 6;
 	buf[4] = -10;
 	buf[5] = 0;
+	buf[6] = 0;
 
 	sljit_emit_enter(compiler, 1, 3, 1, 0);
 
@@ -764,6 +765,11 @@ static void test10(void)
 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_SCRATCH_REG1, 0, SLJIT_IMM, 9);
 	sljit_emit_op2(compiler, SLJIT_MUL, SLJIT_SCRATCH_REG1, 0, SLJIT_SCRATCH_REG1, 0, SLJIT_SCRATCH_REG1, 0);
 	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_sw) * 5, SLJIT_SCRATCH_REG1, 0);
+#if (defined SLJIT_64BIT_ARCHITECTURE  SLJIT_64BIT_ARCHITECTURE)
+	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_SCRATCH_REG2, 0, SLJIT_IMM, 3);
+	sljit_emit_op2(compiler, SLJIT_MUL, SLJIT_SCRATCH_REG1, 0, SLJIT_SCRATCH_REG2, 0, SLJIT_IMM, SLJIT_W(0x123456789));
+	sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_sw) * 6, SLJIT_SCRATCH_REG1, 0);
+#endif
 	sljit_emit_op2(compiler, SLJIT_MUL, SLJIT_RETURN_REG, 0, SLJIT_IMM, 11, SLJIT_IMM, 10);
 	sljit_emit_return(compiler, SLJIT_MOV, SLJIT_RETURN_REG, 0);
 
@@ -778,6 +784,9 @@ static void test10(void)
 	FAILED(buf[3] != -12, test10 case 5 failed\n);
 	FAILED(buf[4] != 100, test10 case 6 failed\n);
 	FAILED(buf[5] != 81, test10 case 7 failed\n);
+#if (defined SLJIT_64BIT_ARCHITECTURE  SLJIT_64BIT_ARCHITECTURE)
+	FAILED(buf[6] != SLJIT_W(0x123456789) * 3, test10 case 8 failed\n);
+#endif
 
 	sljit_free_code(code.code);
 	successful_tests++;



CVS commit: src/sys/external/bsd/sljit/dist/sljit_src

2015-02-16 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Mon Feb 16 13:33:24 UTC 2015

Modified Files:
src/sys/external/bsd/sljit/dist/sljit_src: sljitNativeX86_common.c

Log Message:
Apply a bugfix from r282 http://sourceforge.net/p/sljit/code/282/.

The bug was originally reported by me in a newer upstream version.
American fuzzy lop rediscovered it for the version of sljit in the
NetBSD tree.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 \
src/sys/external/bsd/sljit/dist/sljit_src/sljitNativeX86_common.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/sljit/dist/sljit_src/sljitNativeX86_common.c
diff -u src/sys/external/bsd/sljit/dist/sljit_src/sljitNativeX86_common.c:1.6 src/sys/external/bsd/sljit/dist/sljit_src/sljitNativeX86_common.c:1.7
--- src/sys/external/bsd/sljit/dist/sljit_src/sljitNativeX86_common.c:1.6	Tue Jun 17 19:33:20 2014
+++ src/sys/external/bsd/sljit/dist/sljit_src/sljitNativeX86_common.c	Mon Feb 16 13:33:24 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: sljitNativeX86_common.c,v 1.6 2014/06/17 19:33:20 alnsn Exp $	*/
+/*	$NetBSD: sljitNativeX86_common.c,v 1.7 2015/02/16 13:33:24 alnsn Exp $	*/
 
 /*
  *Stack-less Just-In-Time compiler
@@ -1749,7 +1749,7 @@ static sljit_si emit_mul(struct sljit_co
 			*(sljit_si*)inst = (sljit_si)src2w;
 		}
 		else {
-			EMIT_MOV(compiler, TMP_REG2, 0, SLJIT_IMM, src1w);
+			EMIT_MOV(compiler, TMP_REG2, 0, SLJIT_IMM, src2w);
 			if (dst_r != src1)
 EMIT_MOV(compiler, dst_r, 0, src1, src1w);
 			inst = emit_x86_instruction(compiler, 2, dst_r, 0, TMP_REG2, 0);



CVS commit: src/tests/net/bpfjit

2015-02-14 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sat Feb 14 17:28:19 UTC 2015

Modified Files:
src/tests/net/bpfjit: t_bpfjit.c

Log Message:
Avoid testing for zero rv in bpfjit_jmp_x_uninitialised. Unitialised
X isn't a problem for bpf_validate().


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/tests/net/bpfjit/t_bpfjit.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/net/bpfjit/t_bpfjit.c
diff -u src/tests/net/bpfjit/t_bpfjit.c:1.7 src/tests/net/bpfjit/t_bpfjit.c:1.8
--- src/tests/net/bpfjit/t_bpfjit.c:1.7	Sat Feb 14 16:48:30 2015
+++ src/tests/net/bpfjit/t_bpfjit.c	Sat Feb 14 17:28:19 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_bpfjit.c,v 1.7 2015/02/14 16:48:30 alnsn Exp $ */
+/*	$NetBSD: t_bpfjit.c,v 1.8 2015/02/14 17:28:19 alnsn Exp $ */
 
 /*-
  * Copyright (c) 2011-2012, 2014 Alexander Nasonov.
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: t_bpfjit.c,v 1.7 2015/02/14 16:48:30 alnsn Exp $);
+__RCSID($NetBSD: t_bpfjit.c,v 1.8 2015/02/14 17:28:19 alnsn Exp $);
 
 #include sys/param.h
 #include sys/mbuf.h
@@ -2273,8 +2273,8 @@ ATF_TC_BODY(bpfjit_jmp_x_uninitialised, 
 {
 	static struct bpf_insn insns[] = {
 		BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_X, 1, 0, 1),
-		BPF_STMT(BPF_RET+BPF_K, 1),
-		BPF_STMT(BPF_RET+BPF_K, 0)
+		BPF_STMT(BPF_RET+BPF_K, 11),
+		BPF_STMT(BPF_RET+BPF_K, 10)
 	};
 
 	bpfjit_func_t code;
@@ -2284,15 +2284,14 @@ ATF_TC_BODY(bpfjit_jmp_x_uninitialised, 
 
 	RZ(rump_init());
 
-	/* X isn't initialised. */
-	ATF_CHECK(!prog_validate(insns, insn_count));
+	ATF_CHECK(prog_validate(insns, insn_count));
 
 	rump_schedule();
 	code = rumpns_bpfjit_generate_code(NULL, insns, insn_count);
 	rump_unschedule();
 	ATF_REQUIRE(code != NULL);
 
-	ATF_CHECK(jitcall(code, pkt, 1, 1) == 0);
+	ATF_CHECK(jitcall(code, pkt, 1, 1) == 10);
 
 	rump_schedule();
 	rumpns_bpfjit_free_code(code);



CVS commit: src/tests/net/bpfjit

2015-02-14 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sat Feb 14 16:48:30 UTC 2015

Modified Files:
src/tests/net/bpfjit: t_bpfjit.c

Log Message:
Add bpfjit_jmp_x_uninitialised test.

Found by http://lcamtuf.coredump.cx/afl/.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/net/bpfjit/t_bpfjit.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/net/bpfjit/t_bpfjit.c
diff -u src/tests/net/bpfjit/t_bpfjit.c:1.6 src/tests/net/bpfjit/t_bpfjit.c:1.7
--- src/tests/net/bpfjit/t_bpfjit.c:1.6	Wed Feb 11 23:29:48 2015
+++ src/tests/net/bpfjit/t_bpfjit.c	Sat Feb 14 16:48:30 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_bpfjit.c,v 1.6 2015/02/11 23:29:48 alnsn Exp $ */
+/*	$NetBSD: t_bpfjit.c,v 1.7 2015/02/14 16:48:30 alnsn Exp $ */
 
 /*-
  * Copyright (c) 2011-2012, 2014 Alexander Nasonov.
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: t_bpfjit.c,v 1.6 2015/02/11 23:29:48 alnsn Exp $);
+__RCSID($NetBSD: t_bpfjit.c,v 1.7 2015/02/14 16:48:30 alnsn Exp $);
 
 #include sys/param.h
 #include sys/mbuf.h
@@ -2262,6 +2262,43 @@ ATF_TC_BODY(bpfjit_jmp_jset_x, tc)
 	rump_unschedule();
 }
 
+ATF_TC(bpfjit_jmp_x_uninitialised);
+ATF_TC_HEAD(bpfjit_jmp_x_uninitialised, tc)
+{
+	atf_tc_set_md_var(tc, descr, Test JIT compilation 
+	of BPF_JMP+BPF_EQ+BPF_X with uninitialised X);
+}
+
+ATF_TC_BODY(bpfjit_jmp_x_uninitialised, tc)
+{
+	static struct bpf_insn insns[] = {
+		BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_X, 1, 0, 1),
+		BPF_STMT(BPF_RET+BPF_K, 1),
+		BPF_STMT(BPF_RET+BPF_K, 0)
+	};
+
+	bpfjit_func_t code;
+	uint8_t pkt[8]; /* the program doesn't read any data */
+
+	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
+
+	RZ(rump_init());
+
+	/* X isn't initialised. */
+	ATF_CHECK(!prog_validate(insns, insn_count));
+
+	rump_schedule();
+	code = rumpns_bpfjit_generate_code(NULL, insns, insn_count);
+	rump_unschedule();
+	ATF_REQUIRE(code != NULL);
+
+	ATF_CHECK(jitcall(code, pkt, 1, 1) == 0);
+
+	rump_schedule();
+	rumpns_bpfjit_free_code(code);
+	rump_unschedule();
+}
+
 ATF_TC(bpfjit_jmp_modulo_x);
 ATF_TC_HEAD(bpfjit_jmp_modulo_x, tc)
 {
@@ -4531,6 +4568,7 @@ ATF_TP_ADD_TCS(tp)
 	ATF_TP_ADD_TC(tp, bpfjit_jmp_jge_x);
 	ATF_TP_ADD_TC(tp, bpfjit_jmp_jeq_x);
 	ATF_TP_ADD_TC(tp, bpfjit_jmp_jset_x);
+	ATF_TP_ADD_TC(tp, bpfjit_jmp_x_uninitialised);
 	ATF_TP_ADD_TC(tp, bpfjit_jmp_modulo_x);
 	ATF_TP_ADD_TC(tp, bpfjit_ld_abs);
 	ATF_TP_ADD_TC(tp, bpfjit_ld_abs_k_overflow);



CVS commit: src/tests/net/bpfjit

2015-02-14 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sat Feb 14 19:55:05 UTC 2015

Modified Files:
src/tests/net/bpfjit: t_bpfjit.c

Log Message:
BPF_JMP+BPF_JEQ+BPF_X doesn't compare X with k, it compares X with A.
Fix it in the bpfjit_jmp_jeq_x_noinit_ax test.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/tests/net/bpfjit/t_bpfjit.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/net/bpfjit/t_bpfjit.c
diff -u src/tests/net/bpfjit/t_bpfjit.c:1.8 src/tests/net/bpfjit/t_bpfjit.c:1.9
--- src/tests/net/bpfjit/t_bpfjit.c:1.8	Sat Feb 14 17:28:19 2015
+++ src/tests/net/bpfjit/t_bpfjit.c	Sat Feb 14 19:55:05 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_bpfjit.c,v 1.8 2015/02/14 17:28:19 alnsn Exp $ */
+/*	$NetBSD: t_bpfjit.c,v 1.9 2015/02/14 19:55:05 alnsn Exp $ */
 
 /*-
  * Copyright (c) 2011-2012, 2014 Alexander Nasonov.
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: t_bpfjit.c,v 1.8 2015/02/14 17:28:19 alnsn Exp $);
+__RCSID($NetBSD: t_bpfjit.c,v 1.9 2015/02/14 19:55:05 alnsn Exp $);
 
 #include sys/param.h
 #include sys/mbuf.h
@@ -2262,19 +2262,19 @@ ATF_TC_BODY(bpfjit_jmp_jset_x, tc)
 	rump_unschedule();
 }
 
-ATF_TC(bpfjit_jmp_x_uninitialised);
-ATF_TC_HEAD(bpfjit_jmp_x_uninitialised, tc)
+ATF_TC(bpfjit_jmp_jeq_x_noinit_ax);
+ATF_TC_HEAD(bpfjit_jmp_jeq_x_noinit_ax, tc)
 {
 	atf_tc_set_md_var(tc, descr, Test JIT compilation 
-	of BPF_JMP+BPF_EQ+BPF_X with uninitialised X);
+	of BPF_JMP+BPF_EQ+BPF_X with uninitialised A and X);
 }
 
-ATF_TC_BODY(bpfjit_jmp_x_uninitialised, tc)
+ATF_TC_BODY(bpfjit_jmp_jeq_x_noinit_ax, tc)
 {
 	static struct bpf_insn insns[] = {
-		BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_X, 1, 0, 1),
-		BPF_STMT(BPF_RET+BPF_K, 11),
-		BPF_STMT(BPF_RET+BPF_K, 10)
+		BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_X, 0, 0, 1),
+		BPF_STMT(BPF_RET+BPF_K, 10),
+		BPF_STMT(BPF_RET+BPF_K, 11)
 	};
 
 	bpfjit_func_t code;
@@ -4567,7 +4567,7 @@ ATF_TP_ADD_TCS(tp)
 	ATF_TP_ADD_TC(tp, bpfjit_jmp_jge_x);
 	ATF_TP_ADD_TC(tp, bpfjit_jmp_jeq_x);
 	ATF_TP_ADD_TC(tp, bpfjit_jmp_jset_x);
-	ATF_TP_ADD_TC(tp, bpfjit_jmp_x_uninitialised);
+	ATF_TP_ADD_TC(tp, bpfjit_jmp_jeq_x_noinit_ax);
 	ATF_TP_ADD_TC(tp, bpfjit_jmp_modulo_x);
 	ATF_TP_ADD_TC(tp, bpfjit_ld_abs);
 	ATF_TP_ADD_TC(tp, bpfjit_ld_abs_k_overflow);



CVS commit: src/tests/lib/libbpfjit

2015-02-14 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sat Feb 14 20:29:36 UTC 2015

Modified Files:
src/tests/lib/libbpfjit: t_bpfjit.c

Log Message:
Improve libbpfjit_jmp_jeq_x test.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/tests/lib/libbpfjit/t_bpfjit.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libbpfjit/t_bpfjit.c
diff -u src/tests/lib/libbpfjit/t_bpfjit.c:1.11 src/tests/lib/libbpfjit/t_bpfjit.c:1.12
--- src/tests/lib/libbpfjit/t_bpfjit.c:1.11	Wed Feb 11 23:33:16 2015
+++ src/tests/lib/libbpfjit/t_bpfjit.c	Sat Feb 14 20:29:36 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_bpfjit.c,v 1.11 2015/02/11 23:33:16 alnsn Exp $ */
+/*	$NetBSD: t_bpfjit.c,v 1.12 2015/02/14 20:29:36 alnsn Exp $ */
 
 /*-
  * Copyright (c) 2011-2012, 2014 Alexander Nasonov.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: t_bpfjit.c,v 1.11 2015/02/11 23:33:16 alnsn Exp $);
+__RCSID($NetBSD: t_bpfjit.c,v 1.12 2015/02/14 20:29:36 alnsn Exp $);
 
 #include atf-c.h
 #include stdint.h
@@ -2354,26 +2354,26 @@ ATF_TC_BODY(libbpfjit_jmp_jeq_x, tc)
 		BPF_STMT(BPF_LD+BPF_W+BPF_LEN, 0),
 		BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 8),
 		BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_X, 0, 0, 1),
-		BPF_STMT(BPF_RET+BPF_K, 0),
+		BPF_STMT(BPF_RET+BPF_K, 1),
 		BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 3),
 		BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_X, 0, 2, 0),
 		BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 9),
 		BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_X, 0, 1, 1),
-		BPF_STMT(BPF_RET+BPF_K, 1),
-		BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 5),
-		BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_X, 0, 1, 1),
 		BPF_STMT(BPF_RET+BPF_K, 2),
+		BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 5),
+		BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_X, 0, 0, 1),
+		BPF_STMT(BPF_RET+BPF_K, 3),
 		BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 7),
 		BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_X, 0, 2, 3),
-		BPF_STMT(BPF_RET+BPF_K, 3),
 		BPF_STMT(BPF_RET+BPF_K, 4),
 		BPF_STMT(BPF_RET+BPF_K, 5),
+		BPF_STMT(BPF_RET+BPF_K, 6),
 		BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 6),
 		BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_X, 0, 3, 1),
-		BPF_STMT(BPF_RET+BPF_K, 6),
-		BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_X, 1, 0, 0),
 		BPF_STMT(BPF_RET+BPF_K, 7),
-		BPF_STMT(BPF_RET+BPF_K, 8)
+		BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_X, 0, 1, 0),
+		BPF_STMT(BPF_RET+BPF_K, 8),
+		BPF_STMT(BPF_RET+BPF_K, 9)
 	};
 
 	bpfjit_func_t code;
@@ -2386,14 +2386,14 @@ ATF_TC_BODY(libbpfjit_jmp_jeq_x, tc)
 	code = bpfjit_generate_code(NULL, insns, insn_count);
 	ATF_REQUIRE(code != NULL);
 
-	ATF_CHECK(jitcall(code, pkt, 1, 1) == 7);
-	ATF_CHECK(jitcall(code, pkt, 2, 2) == 7);
-	ATF_CHECK(jitcall(code, pkt, 3, 3) == 1);
-	ATF_CHECK(jitcall(code, pkt, 4, 4) == 7);
-	ATF_CHECK(jitcall(code, pkt, 5, 5) == 7);
-	ATF_CHECK(jitcall(code, pkt, 6, 6) == 8);
-	ATF_CHECK(jitcall(code, pkt, 7, 7) == 5);
-	ATF_CHECK(jitcall(code, pkt, 8, 8) == 0);
+	ATF_CHECK(jitcall(code, pkt, 1, 1) == 8);
+	ATF_CHECK(jitcall(code, pkt, 2, 2) == 8);
+	ATF_CHECK(jitcall(code, pkt, 3, 3) == 2);
+	ATF_CHECK(jitcall(code, pkt, 4, 4) == 8);
+	ATF_CHECK(jitcall(code, pkt, 5, 5) == 3);
+	ATF_CHECK(jitcall(code, pkt, 6, 6) == 9);
+	ATF_CHECK(jitcall(code, pkt, 7, 7) == 6);
+	ATF_CHECK(jitcall(code, pkt, 8, 8) == 1);
 
 	bpfjit_free_code(code);
 }
@@ -2455,6 +2455,37 @@ ATF_TC_BODY(libbpfjit_jmp_jset_x, tc)
 	bpfjit_free_code(code);
 }
 
+ATF_TC(libbpfjit_jmp_x_uninitialised);
+ATF_TC_HEAD(libbpfjit_jmp_x_uninitialised, tc)
+{
+	atf_tc_set_md_var(tc, descr, Test JIT compilation 
+	of BPF_JMP+BPF_EQ+BPF_X with uninitialised X);
+}
+
+ATF_TC_BODY(libbpfjit_jmp_x_uninitialised, tc)
+{
+	static struct bpf_insn insns[] = {
+		BPF_STMT(BPF_LD+BPF_W+BPF_LEN, 0), /* A  0 */
+		BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_X, 0, 0, 1),
+		BPF_STMT(BPF_RET+BPF_K, 11),
+		BPF_STMT(BPF_RET+BPF_K, 10)
+	};
+
+	bpfjit_func_t code;
+	uint8_t pkt[8]; /* the program doesn't read any data */
+
+	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
+
+	ATF_CHECK(bpf_validate(insns, insn_count));
+
+	code = bpfjit_generate_code(NULL, insns, insn_count);
+	ATF_REQUIRE(code != NULL);
+
+	ATF_CHECK(jitcall(code, pkt, 1, 1) == 10);
+
+	bpfjit_free_code(code);
+}
+
 ATF_TC(libbpfjit_jmp_modulo_x);
 ATF_TC_HEAD(libbpfjit_jmp_modulo_x, tc)
 {
@@ -4613,6 +4644,7 @@ ATF_TP_ADD_TCS(tp)
 	ATF_TP_ADD_TC(tp, libbpfjit_jmp_jge_x);
 	ATF_TP_ADD_TC(tp, libbpfjit_jmp_jeq_x);
 	ATF_TP_ADD_TC(tp, libbpfjit_jmp_jset_x);
+	ATF_TP_ADD_TC(tp, libbpfjit_jmp_x_uninitialised);
 	ATF_TP_ADD_TC(tp, libbpfjit_jmp_modulo_x);
 	ATF_TP_ADD_TC(tp, libbpfjit_ld_abs);
 	ATF_TP_ADD_TC(tp, libbpfjit_ld_abs_k_overflow);



CVS commit: src/tests/lib/libbpfjit

2015-02-14 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sat Feb 14 20:39:09 UTC 2015

Modified Files:
src/tests/lib/libbpfjit: t_bpfjit.c

Log Message:
Replace accidentally committed test with libbpfjit_jmp_jeq_x_noinit_ax test.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/tests/lib/libbpfjit/t_bpfjit.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libbpfjit/t_bpfjit.c
diff -u src/tests/lib/libbpfjit/t_bpfjit.c:1.12 src/tests/lib/libbpfjit/t_bpfjit.c:1.13
--- src/tests/lib/libbpfjit/t_bpfjit.c:1.12	Sat Feb 14 20:29:36 2015
+++ src/tests/lib/libbpfjit/t_bpfjit.c	Sat Feb 14 20:39:09 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_bpfjit.c,v 1.12 2015/02/14 20:29:36 alnsn Exp $ */
+/*	$NetBSD: t_bpfjit.c,v 1.13 2015/02/14 20:39:09 alnsn Exp $ */
 
 /*-
  * Copyright (c) 2011-2012, 2014 Alexander Nasonov.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: t_bpfjit.c,v 1.12 2015/02/14 20:29:36 alnsn Exp $);
+__RCSID($NetBSD: t_bpfjit.c,v 1.13 2015/02/14 20:39:09 alnsn Exp $);
 
 #include atf-c.h
 #include stdint.h
@@ -2455,20 +2455,19 @@ ATF_TC_BODY(libbpfjit_jmp_jset_x, tc)
 	bpfjit_free_code(code);
 }
 
-ATF_TC(libbpfjit_jmp_x_uninitialised);
-ATF_TC_HEAD(libbpfjit_jmp_x_uninitialised, tc)
+ATF_TC(libbpfjit_jmp_jeq_x_noinit_ax);
+ATF_TC_HEAD(libbpfjit_jmp_jeq_x_noinit_ax, tc)
 {
 	atf_tc_set_md_var(tc, descr, Test JIT compilation 
-	of BPF_JMP+BPF_EQ+BPF_X with uninitialised X);
+	of BPF_JMP+BPF_EQ+BPF_X with uninitialised A and X);
 }
 
-ATF_TC_BODY(libbpfjit_jmp_x_uninitialised, tc)
+ATF_TC_BODY(libbpfjit_jmp_jeq_x_noinit_ax, tc)
 {
 	static struct bpf_insn insns[] = {
-		BPF_STMT(BPF_LD+BPF_W+BPF_LEN, 0), /* A  0 */
 		BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_X, 0, 0, 1),
-		BPF_STMT(BPF_RET+BPF_K, 11),
-		BPF_STMT(BPF_RET+BPF_K, 10)
+		BPF_STMT(BPF_RET+BPF_K, 10),
+		BPF_STMT(BPF_RET+BPF_K, 11)
 	};
 
 	bpfjit_func_t code;
@@ -4644,7 +4643,7 @@ ATF_TP_ADD_TCS(tp)
 	ATF_TP_ADD_TC(tp, libbpfjit_jmp_jge_x);
 	ATF_TP_ADD_TC(tp, libbpfjit_jmp_jeq_x);
 	ATF_TP_ADD_TC(tp, libbpfjit_jmp_jset_x);
-	ATF_TP_ADD_TC(tp, libbpfjit_jmp_x_uninitialised);
+	ATF_TP_ADD_TC(tp, libbpfjit_jmp_jeq_x_noinit_ax);
 	ATF_TP_ADD_TC(tp, libbpfjit_jmp_modulo_x);
 	ATF_TP_ADD_TC(tp, libbpfjit_ld_abs);
 	ATF_TP_ADD_TC(tp, libbpfjit_ld_abs_k_overflow);



CVS commit: src/sys/net

2015-02-14 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sat Feb 14 21:14:56 UTC 2015

Modified Files:
src/sys/net: bpfjit.c

Log Message:
Properly track initialisation of registers for BPF_JMP instructions.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/net/bpfjit.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/net/bpfjit.c
diff -u src/sys/net/bpfjit.c:1.40 src/sys/net/bpfjit.c:1.41
--- src/sys/net/bpfjit.c:1.40	Fri Feb 13 15:59:17 2015
+++ src/sys/net/bpfjit.c	Sat Feb 14 21:14:56 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: bpfjit.c,v 1.40 2015/02/13 15:59:17 alnsn Exp $	*/
+/*	$NetBSD: bpfjit.c,v 1.41 2015/02/14 21:14:56 alnsn Exp $	*/
 
 /*-
  * Copyright (c) 2011-2014 Alexander Nasonov.
@@ -31,9 +31,9 @@
 
 #include sys/cdefs.h
 #ifdef _KERNEL
-__KERNEL_RCSID(0, $NetBSD: bpfjit.c,v 1.40 2015/02/13 15:59:17 alnsn Exp $);
+__KERNEL_RCSID(0, $NetBSD: bpfjit.c,v 1.41 2015/02/14 21:14:56 alnsn Exp $);
 #else
-__RCSID($NetBSD: bpfjit.c,v 1.40 2015/02/13 15:59:17 alnsn Exp $);
+__RCSID($NetBSD: bpfjit.c,v 1.41 2015/02/14 21:14:56 alnsn Exp $);
 #endif
 
 #include sys/types.h
@@ -1419,8 +1419,12 @@ optimize_pass1(const bpf_ctx_t *bc, cons
 			/* Initialize abc_length for ABC pass. */
 			insn_dat[i].u.jdata.abc_length = MAX_ABC_LENGTH;
 
-			if (BPF_SRC(insns[i].code) == BPF_X)
+			*initmask |= invalid  BJ_INIT_ABIT;
+
+			if (BPF_SRC(insns[i].code) == BPF_X) {
 *hints |= BJ_HINT_XREG;
+*initmask |= invalid  BJ_INIT_XBIT;
+			}
 
 			if (BPF_OP(insns[i].code) == BPF_JA) {
 jt = jf = insns[i].k;



CVS commit: src/tests/net/bpfjit

2015-02-14 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sat Feb 14 20:25:08 UTC 2015

Modified Files:
src/tests/net/bpfjit: t_bpfjit.c

Log Message:
Improve bpfjit_jmp_jeq_x test.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/tests/net/bpfjit/t_bpfjit.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/net/bpfjit/t_bpfjit.c
diff -u src/tests/net/bpfjit/t_bpfjit.c:1.9 src/tests/net/bpfjit/t_bpfjit.c:1.10
--- src/tests/net/bpfjit/t_bpfjit.c:1.9	Sat Feb 14 19:55:05 2015
+++ src/tests/net/bpfjit/t_bpfjit.c	Sat Feb 14 20:25:08 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_bpfjit.c,v 1.9 2015/02/14 19:55:05 alnsn Exp $ */
+/*	$NetBSD: t_bpfjit.c,v 1.10 2015/02/14 20:25:08 alnsn Exp $ */
 
 /*-
  * Copyright (c) 2011-2012, 2014 Alexander Nasonov.
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: t_bpfjit.c,v 1.9 2015/02/14 19:55:05 alnsn Exp $);
+__RCSID($NetBSD: t_bpfjit.c,v 1.10 2015/02/14 20:25:08 alnsn Exp $);
 
 #include sys/param.h
 #include sys/mbuf.h
@@ -2149,26 +2149,26 @@ ATF_TC_BODY(bpfjit_jmp_jeq_x, tc)
 		BPF_STMT(BPF_LD+BPF_W+BPF_LEN, 0),
 		BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 8),
 		BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_X, 0, 0, 1),
-		BPF_STMT(BPF_RET+BPF_K, 0),
+		BPF_STMT(BPF_RET+BPF_K, 1),
 		BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 3),
 		BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_X, 0, 2, 0),
 		BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 9),
 		BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_X, 0, 1, 1),
-		BPF_STMT(BPF_RET+BPF_K, 1),
-		BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 5),
-		BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_X, 0, 1, 1),
 		BPF_STMT(BPF_RET+BPF_K, 2),
+		BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 5),
+		BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_X, 0, 0, 1),
+		BPF_STMT(BPF_RET+BPF_K, 3),
 		BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 7),
 		BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_X, 0, 2, 3),
-		BPF_STMT(BPF_RET+BPF_K, 3),
 		BPF_STMT(BPF_RET+BPF_K, 4),
 		BPF_STMT(BPF_RET+BPF_K, 5),
+		BPF_STMT(BPF_RET+BPF_K, 6),
 		BPF_STMT(BPF_LDX+BPF_W+BPF_IMM, 6),
 		BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_X, 0, 3, 1),
-		BPF_STMT(BPF_RET+BPF_K, 6),
-		BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_X, 1, 0, 0),
 		BPF_STMT(BPF_RET+BPF_K, 7),
-		BPF_STMT(BPF_RET+BPF_K, 8)
+		BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_X, 0, 1, 0),
+		BPF_STMT(BPF_RET+BPF_K, 8),
+		BPF_STMT(BPF_RET+BPF_K, 9)
 	};
 
 	bpfjit_func_t code;
@@ -2185,14 +2185,14 @@ ATF_TC_BODY(bpfjit_jmp_jeq_x, tc)
 	rump_unschedule();
 	ATF_REQUIRE(code != NULL);
 
-	ATF_CHECK(jitcall(code, pkt, 1, 1) == 7);
-	ATF_CHECK(jitcall(code, pkt, 2, 2) == 7);
-	ATF_CHECK(jitcall(code, pkt, 3, 3) == 1);
-	ATF_CHECK(jitcall(code, pkt, 4, 4) == 7);
-	ATF_CHECK(jitcall(code, pkt, 5, 5) == 7);
-	ATF_CHECK(jitcall(code, pkt, 6, 6) == 8);
-	ATF_CHECK(jitcall(code, pkt, 7, 7) == 5);
-	ATF_CHECK(jitcall(code, pkt, 8, 8) == 0);
+	ATF_CHECK(jitcall(code, pkt, 1, 1) == 8);
+	ATF_CHECK(jitcall(code, pkt, 2, 2) == 8);
+	ATF_CHECK(jitcall(code, pkt, 3, 3) == 2);
+	ATF_CHECK(jitcall(code, pkt, 4, 4) == 8);
+	ATF_CHECK(jitcall(code, pkt, 5, 5) == 3);
+	ATF_CHECK(jitcall(code, pkt, 6, 6) == 9);
+	ATF_CHECK(jitcall(code, pkt, 7, 7) == 6);
+	ATF_CHECK(jitcall(code, pkt, 8, 8) == 1);
 
 	rump_schedule();
 	rumpns_bpfjit_free_code(code);



CVS commit: src/sys/net

2015-02-14 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sat Feb 14 21:17:05 UTC 2015

Modified Files:
src/sys/net: bpfjit.c

Log Message:
In some implementations pc-k is signed. Cast it to uint32_t before comparing.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/net/bpfjit.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/net/bpfjit.c
diff -u src/sys/net/bpfjit.c:1.41 src/sys/net/bpfjit.c:1.42
--- src/sys/net/bpfjit.c:1.41	Sat Feb 14 21:14:56 2015
+++ src/sys/net/bpfjit.c	Sat Feb 14 21:17:05 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: bpfjit.c,v 1.41 2015/02/14 21:14:56 alnsn Exp $	*/
+/*	$NetBSD: bpfjit.c,v 1.42 2015/02/14 21:17:05 alnsn Exp $	*/
 
 /*-
  * Copyright (c) 2011-2014 Alexander Nasonov.
@@ -31,9 +31,9 @@
 
 #include sys/cdefs.h
 #ifdef _KERNEL
-__KERNEL_RCSID(0, $NetBSD: bpfjit.c,v 1.41 2015/02/14 21:14:56 alnsn Exp $);
+__KERNEL_RCSID(0, $NetBSD: bpfjit.c,v 1.42 2015/02/14 21:17:05 alnsn Exp $);
 #else
-__RCSID($NetBSD: bpfjit.c,v 1.41 2015/02/14 21:14:56 alnsn Exp $);
+__RCSID($NetBSD: bpfjit.c,v 1.42 2015/02/14 21:17:05 alnsn Exp $);
 #endif
 
 #include sys/types.h
@@ -1605,6 +1605,7 @@ static int
 bpf_alu_to_sljit_op(const struct bpf_insn *pc)
 {
 	const int bad = SLJIT_UNUSED;
+	const uint32_t k = pc-k;
 
 	/*
 	 * Note: all supported 64bit arches have 32bit multiply
@@ -1617,8 +1618,8 @@ bpf_alu_to_sljit_op(const struct bpf_ins
 	case BPF_OR:  return SLJIT_OR;
 	case BPF_XOR: return SLJIT_XOR;
 	case BPF_AND: return SLJIT_AND;
-	case BPF_LSH: return (pc-k  31) ? bad : SLJIT_SHL;
-	case BPF_RSH: return (pc-k  31) ? bad : SLJIT_LSHR|SLJIT_INT_OP;
+	case BPF_LSH: return (k  31) ? bad : SLJIT_SHL;
+	case BPF_RSH: return (k  31) ? bad : SLJIT_LSHR|SLJIT_INT_OP;
 	default:
 		return bad;
 	}



CVS commit: src/sys/net

2015-02-14 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sat Feb 14 21:32:46 UTC 2015

Modified Files:
src/sys/net: bpfjit.c

Log Message:
Copyright year.


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sys/net/bpfjit.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/net/bpfjit.c
diff -u src/sys/net/bpfjit.c:1.42 src/sys/net/bpfjit.c:1.43
--- src/sys/net/bpfjit.c:1.42	Sat Feb 14 21:17:05 2015
+++ src/sys/net/bpfjit.c	Sat Feb 14 21:32:46 2015
@@ -1,7 +1,7 @@
-/*	$NetBSD: bpfjit.c,v 1.42 2015/02/14 21:17:05 alnsn Exp $	*/
+/*	$NetBSD: bpfjit.c,v 1.43 2015/02/14 21:32:46 alnsn Exp $	*/
 
 /*-
- * Copyright (c) 2011-2014 Alexander Nasonov.
+ * Copyright (c) 2011-2015 Alexander Nasonov.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -31,9 +31,9 @@
 
 #include sys/cdefs.h
 #ifdef _KERNEL
-__KERNEL_RCSID(0, $NetBSD: bpfjit.c,v 1.42 2015/02/14 21:17:05 alnsn Exp $);
+__KERNEL_RCSID(0, $NetBSD: bpfjit.c,v 1.43 2015/02/14 21:32:46 alnsn Exp $);
 #else
-__RCSID($NetBSD: bpfjit.c,v 1.42 2015/02/14 21:17:05 alnsn Exp $);
+__RCSID($NetBSD: bpfjit.c,v 1.43 2015/02/14 21:32:46 alnsn Exp $);
 #endif
 
 #include sys/types.h



CVS commit: src/tests/net/bpfjit

2015-02-14 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sat Feb 14 22:34:33 UTC 2015

Modified Files:
src/tests/net/bpfjit: t_bpfjit.c

Log Message:
Add two more bpfjit_jmp_jeq_x_noinit_XX tests.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/tests/net/bpfjit/t_bpfjit.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/net/bpfjit/t_bpfjit.c
diff -u src/tests/net/bpfjit/t_bpfjit.c:1.10 src/tests/net/bpfjit/t_bpfjit.c:1.11
--- src/tests/net/bpfjit/t_bpfjit.c:1.10	Sat Feb 14 20:25:08 2015
+++ src/tests/net/bpfjit/t_bpfjit.c	Sat Feb 14 22:34:33 2015
@@ -1,7 +1,7 @@
-/*	$NetBSD: t_bpfjit.c,v 1.10 2015/02/14 20:25:08 alnsn Exp $ */
+/*	$NetBSD: t_bpfjit.c,v 1.11 2015/02/14 22:34:33 alnsn Exp $ */
 
 /*-
- * Copyright (c) 2011-2012, 2014 Alexander Nasonov.
+ * Copyright (c) 2011-2012, 2014-2015 Alexander Nasonov.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: t_bpfjit.c,v 1.10 2015/02/14 20:25:08 alnsn Exp $);
+__RCSID($NetBSD: t_bpfjit.c,v 1.11 2015/02/14 22:34:33 alnsn Exp $);
 
 #include sys/param.h
 #include sys/mbuf.h
@@ -2298,6 +2298,80 @@ ATF_TC_BODY(bpfjit_jmp_jeq_x_noinit_ax, 
 	rump_unschedule();
 }
 
+ATF_TC(bpfjit_jmp_jeq_x_noinit_a);
+ATF_TC_HEAD(bpfjit_jmp_jeq_x_noinit_a, tc)
+{
+	atf_tc_set_md_var(tc, descr, Test JIT compilation 
+	of BPF_JMP+BPF_EQ+BPF_X with uninitialised A);
+}
+
+ATF_TC_BODY(bpfjit_jmp_jeq_x_noinit_a, tc)
+{
+	static struct bpf_insn insns[] = {
+		BPF_STMT(BPF_LDX+BPF_W+BPF_LEN, 0), /* X  0 */
+		BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_X, 0, 0, 1),
+		BPF_STMT(BPF_RET+BPF_K, 10),
+		BPF_STMT(BPF_RET+BPF_K, 11)
+	};
+
+	bpfjit_func_t code;
+	uint8_t pkt[8]; /* the program doesn't read any data */
+
+	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
+
+	RZ(rump_init());
+
+	ATF_CHECK(prog_validate(insns, insn_count));
+
+	rump_schedule();
+	code = rumpns_bpfjit_generate_code(NULL, insns, insn_count);
+	rump_unschedule();
+	ATF_REQUIRE(code != NULL);
+
+	ATF_CHECK(jitcall(code, pkt, 1, 1) == 11);
+
+	rump_schedule();
+	rumpns_bpfjit_free_code(code);
+	rump_unschedule();
+}
+
+ATF_TC(bpfjit_jmp_jeq_x_noinit_x);
+ATF_TC_HEAD(bpfjit_jmp_jeq_x_noinit_x, tc)
+{
+	atf_tc_set_md_var(tc, descr, Test JIT compilation 
+	of BPF_JMP+BPF_EQ+BPF_X with uninitialised X);
+}
+
+ATF_TC_BODY(bpfjit_jmp_jeq_x_noinit_x, tc)
+{
+	static struct bpf_insn insns[] = {
+		BPF_STMT(BPF_LD+BPF_LEN, 0), /* A  0 */
+		BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_X, 0, 0, 1),
+		BPF_STMT(BPF_RET+BPF_K, 10),
+		BPF_STMT(BPF_RET+BPF_K, 11)
+	};
+
+	bpfjit_func_t code;
+	uint8_t pkt[8]; /* the program doesn't read any data */
+
+	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
+
+	RZ(rump_init());
+
+	ATF_CHECK(prog_validate(insns, insn_count));
+
+	rump_schedule();
+	code = rumpns_bpfjit_generate_code(NULL, insns, insn_count);
+	rump_unschedule();
+	ATF_REQUIRE(code != NULL);
+
+	ATF_CHECK(jitcall(code, pkt, 1, 1) == 11);
+
+	rump_schedule();
+	rumpns_bpfjit_free_code(code);
+	rump_unschedule();
+}
+
 ATF_TC(bpfjit_jmp_modulo_x);
 ATF_TC_HEAD(bpfjit_jmp_modulo_x, tc)
 {
@@ -4568,6 +4642,8 @@ ATF_TP_ADD_TCS(tp)
 	ATF_TP_ADD_TC(tp, bpfjit_jmp_jeq_x);
 	ATF_TP_ADD_TC(tp, bpfjit_jmp_jset_x);
 	ATF_TP_ADD_TC(tp, bpfjit_jmp_jeq_x_noinit_ax);
+	ATF_TP_ADD_TC(tp, bpfjit_jmp_jeq_x_noinit_a);
+	ATF_TP_ADD_TC(tp, bpfjit_jmp_jeq_x_noinit_x);
 	ATF_TP_ADD_TC(tp, bpfjit_jmp_modulo_x);
 	ATF_TP_ADD_TC(tp, bpfjit_ld_abs);
 	ATF_TP_ADD_TC(tp, bpfjit_ld_abs_k_overflow);



CVS commit: src/tests/lib/libbpfjit

2015-02-14 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sat Feb 14 22:40:18 UTC 2015

Modified Files:
src/tests/lib/libbpfjit: t_bpfjit.c

Log Message:
Add two more libbpfjit_jmp_jeq_x_noinit_XX tests.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/tests/lib/libbpfjit/t_bpfjit.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libbpfjit/t_bpfjit.c
diff -u src/tests/lib/libbpfjit/t_bpfjit.c:1.13 src/tests/lib/libbpfjit/t_bpfjit.c:1.14
--- src/tests/lib/libbpfjit/t_bpfjit.c:1.13	Sat Feb 14 20:39:09 2015
+++ src/tests/lib/libbpfjit/t_bpfjit.c	Sat Feb 14 22:40:18 2015
@@ -1,7 +1,7 @@
-/*	$NetBSD: t_bpfjit.c,v 1.13 2015/02/14 20:39:09 alnsn Exp $ */
+/*	$NetBSD: t_bpfjit.c,v 1.14 2015/02/14 22:40:18 alnsn Exp $ */
 
 /*-
- * Copyright (c) 2011-2012, 2014 Alexander Nasonov.
+ * Copyright (c) 2011-2012, 2014-2015 Alexander Nasonov.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: t_bpfjit.c,v 1.13 2015/02/14 20:39:09 alnsn Exp $);
+__RCSID($NetBSD: t_bpfjit.c,v 1.14 2015/02/14 22:40:18 alnsn Exp $);
 
 #include atf-c.h
 #include stdint.h
@@ -2485,6 +2485,68 @@ ATF_TC_BODY(libbpfjit_jmp_jeq_x_noinit_a
 	bpfjit_free_code(code);
 }
 
+ATF_TC(libbpfjit_jmp_jeq_x_noinit_a);
+ATF_TC_HEAD(libbpfjit_jmp_jeq_x_noinit_a, tc)
+{
+	atf_tc_set_md_var(tc, descr, Test JIT compilation 
+	of BPF_JMP+BPF_EQ+BPF_X with uninitialised A);
+}
+
+ATF_TC_BODY(libbpfjit_jmp_jeq_x_noinit_a, tc)
+{
+	static struct bpf_insn insns[] = {
+		BPF_STMT(BPF_LDX+BPF_W+BPF_LEN, 0), /* X  0 */
+		BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_X, 0, 0, 1),
+		BPF_STMT(BPF_RET+BPF_K, 10),
+		BPF_STMT(BPF_RET+BPF_K, 11)
+	};
+
+	bpfjit_func_t code;
+	uint8_t pkt[8]; /* the program doesn't read any data */
+
+	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
+
+	ATF_CHECK(bpf_validate(insns, insn_count));
+
+	code = bpfjit_generate_code(NULL, insns, insn_count);
+	ATF_REQUIRE(code != NULL);
+
+	ATF_CHECK(jitcall(code, pkt, 1, 1) == 11);
+
+	bpfjit_free_code(code);
+}
+
+ATF_TC(libbpfjit_jmp_jeq_x_noinit_x);
+ATF_TC_HEAD(libbpfjit_jmp_jeq_x_noinit_x, tc)
+{
+	atf_tc_set_md_var(tc, descr, Test JIT compilation 
+	of BPF_JMP+BPF_EQ+BPF_X with uninitialised X);
+}
+
+ATF_TC_BODY(libbpfjit_jmp_jeq_x_noinit_x, tc)
+{
+	static struct bpf_insn insns[] = {
+		BPF_STMT(BPF_LD+BPF_LEN, 0), /* A  0 */
+		BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_X, 0, 0, 1),
+		BPF_STMT(BPF_RET+BPF_K, 10),
+		BPF_STMT(BPF_RET+BPF_K, 11)
+	};
+
+	bpfjit_func_t code;
+	uint8_t pkt[8]; /* the program doesn't read any data */
+
+	size_t insn_count = sizeof(insns) / sizeof(insns[0]);
+
+	ATF_CHECK(bpf_validate(insns, insn_count));
+
+	code = bpfjit_generate_code(NULL, insns, insn_count);
+	ATF_REQUIRE(code != NULL);
+
+	ATF_CHECK(jitcall(code, pkt, 1, 1) == 11);
+
+	bpfjit_free_code(code);
+}
+
 ATF_TC(libbpfjit_jmp_modulo_x);
 ATF_TC_HEAD(libbpfjit_jmp_modulo_x, tc)
 {
@@ -4644,6 +4706,8 @@ ATF_TP_ADD_TCS(tp)
 	ATF_TP_ADD_TC(tp, libbpfjit_jmp_jeq_x);
 	ATF_TP_ADD_TC(tp, libbpfjit_jmp_jset_x);
 	ATF_TP_ADD_TC(tp, libbpfjit_jmp_jeq_x_noinit_ax);
+	ATF_TP_ADD_TC(tp, libbpfjit_jmp_jeq_x_noinit_a);
+	ATF_TP_ADD_TC(tp, libbpfjit_jmp_jeq_x_noinit_x);
 	ATF_TP_ADD_TC(tp, libbpfjit_jmp_modulo_x);
 	ATF_TP_ADD_TC(tp, libbpfjit_ld_abs);
 	ATF_TP_ADD_TC(tp, libbpfjit_ld_abs_k_overflow);



CVS commit: src/sys/net

2015-02-13 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Fri Feb 13 15:59:17 UTC 2015

Modified Files:
src/sys/net: bpfjit.c

Log Message:
Don't emit wrapped-around reads. They're dead code but dead code elimination
logic isn't smart enough to figure it out.

Found by afl fuzzer http://lcamtuf.coredump.cx/afl/.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/sys/net/bpfjit.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/net/bpfjit.c
diff -u src/sys/net/bpfjit.c:1.39 src/sys/net/bpfjit.c:1.40
--- src/sys/net/bpfjit.c:1.39	Thu Feb 12 23:09:55 2015
+++ src/sys/net/bpfjit.c	Fri Feb 13 15:59:17 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: bpfjit.c,v 1.39 2015/02/12 23:09:55 alnsn Exp $	*/
+/*	$NetBSD: bpfjit.c,v 1.40 2015/02/13 15:59:17 alnsn Exp $	*/
 
 /*-
  * Copyright (c) 2011-2014 Alexander Nasonov.
@@ -31,9 +31,9 @@
 
 #include sys/cdefs.h
 #ifdef _KERNEL
-__KERNEL_RCSID(0, $NetBSD: bpfjit.c,v 1.39 2015/02/12 23:09:55 alnsn Exp $);
+__KERNEL_RCSID(0, $NetBSD: bpfjit.c,v 1.40 2015/02/13 15:59:17 alnsn Exp $);
 #else
-__RCSID($NetBSD: bpfjit.c,v 1.39 2015/02/12 23:09:55 alnsn Exp $);
+__RCSID($NetBSD: bpfjit.c,v 1.40 2015/02/13 15:59:17 alnsn Exp $);
 #endif
 
 #include sys/types.h
@@ -868,20 +868,27 @@ emit_pkt_read(struct sljit_compiler *com
 			return SLJIT_ERR_ALLOC_FAILED;
 	}
 
-	switch (width) {
-	case 4:
-		status = emit_read32(compiler, ld_reg, k);
-		break;
-	case 2:
-		status = emit_read16(compiler, ld_reg, k);
-		break;
-	case 1:
-		status = emit_read8(compiler, ld_reg, k);
-		break;
-	}
+	/*
+	 * Don't emit wrapped-around reads. They're dead code but
+	 * dead code elimination logic isn't smart enough to figure
+	 * it out.
+	 */
+	if (k = UINT32_MAX - width + 1) {
+		switch (width) {
+		case 4:
+			status = emit_read32(compiler, ld_reg, k);
+			break;
+		case 2:
+			status = emit_read16(compiler, ld_reg, k);
+			break;
+		case 1:
+			status = emit_read8(compiler, ld_reg, k);
+			break;
+		}
 
-	if (status != SLJIT_SUCCESS)
-		return status;
+		if (status != SLJIT_SUCCESS)
+			return status;
+	}
 
 #ifdef _KERNEL
 	over_mchain_jump = sljit_emit_jump(compiler, SLJIT_JUMP);



  1   2   3   4   >