CVS commit: src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common

2018-02-24 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sun Feb 25 01:05:09 UTC 2018

Modified Files:
src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common:
sanitizer_unwind_linux_libcdep.cc

Log Message:
fix some types of netbsd arm builds.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \

src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_unwind_linux_libcdep.cc

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

Modified files:

Index: src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_unwind_linux_libcdep.cc
diff -u src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_unwind_linux_libcdep.cc:1.2 src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_unwind_linux_libcdep.cc:1.3
--- src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_unwind_linux_libcdep.cc:1.2	Wed Feb 14 02:10:06 2018
+++ src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_unwind_linux_libcdep.cc	Sun Feb 25 01:05:09 2018
@@ -80,7 +80,7 @@ void SanitizerInitializeUnwinder() {
 #endif
 
 uptr Unwind_GetIP(struct _Unwind_Context *ctx) {
-#if defined(__arm__) && !SANITIZER_MAC
+#if defined(__arm__) && !SANITIZER_MAC && !SANITIZER_NETBSD
   uptr val;
   _Unwind_VRS_Result res = _Unwind_VRS_Get(ctx, _UVRSC_CORE,
   15 /* r15 = PC */, _UVRSD_UINT32, );



CVS commit: src/sys/arch

2018-02-24 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sun Feb 25 00:27:16 UTC 2018

Modified Files:
src/sys/arch/atari/conf: Makefile.atari files.atari
src/sys/arch/hp300/conf: Makefile.hp300 files.hp300
src/sys/arch/luna68k/conf: Makefile.luna68k files.luna68k
src/sys/arch/mac68k/conf: Makefile.mac68k files.mac68k
src/sys/arch/sun3/conf: Makefile.sun3 files.sun3
src/sys/arch/x68k/conf: Makefile.x68k files.x68k
Added Files:
src/sys/arch/m68k/conf: Makefile.kern.m68k.inc

Log Message:
add a special rule to build m68k/fpu.c to avoid passing -msoft-float.
fixes GCC 6 kernel builds that use this file.


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sys/arch/atari/conf/Makefile.atari
cvs rdiff -u -r1.120 -r1.121 src/sys/arch/atari/conf/files.atari
cvs rdiff -u -r1.92 -r1.93 src/sys/arch/hp300/conf/Makefile.hp300
cvs rdiff -u -r1.89 -r1.90 src/sys/arch/hp300/conf/files.hp300
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/luna68k/conf/Makefile.luna68k
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/luna68k/conf/files.luna68k
cvs rdiff -u -r0 -r1.1 src/sys/arch/m68k/conf/Makefile.kern.m68k.inc
cvs rdiff -u -r1.91 -r1.92 src/sys/arch/mac68k/conf/Makefile.mac68k
cvs rdiff -u -r1.125 -r1.126 src/sys/arch/mac68k/conf/files.mac68k
cvs rdiff -u -r1.104 -r1.105 src/sys/arch/sun3/conf/Makefile.sun3
cvs rdiff -u -r1.81 -r1.82 src/sys/arch/sun3/conf/files.sun3
cvs rdiff -u -r1.64 -r1.65 src/sys/arch/x68k/conf/Makefile.x68k
cvs rdiff -u -r1.79 -r1.80 src/sys/arch/x68k/conf/files.x68k

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/atari/conf/Makefile.atari
diff -u src/sys/arch/atari/conf/Makefile.atari:1.76 src/sys/arch/atari/conf/Makefile.atari:1.77
--- src/sys/arch/atari/conf/Makefile.atari:1.76	Sun Sep  6 02:17:30 2015
+++ src/sys/arch/atari/conf/Makefile.atari	Sun Feb 25 00:27:16 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.atari,v 1.76 2015/09/06 02:17:30 uebayasi Exp $
+#	$NetBSD: Makefile.atari,v 1.77 2018/02/25 00:27:16 mrg Exp $
 
 # Makefile for NetBSD
 #
@@ -58,6 +58,8 @@ copy.o copypage.o lock_stubs.o: assym.h
 locore.o: ${ATARI}/atari/locore.s assym.h
 	${NORMAL_S}
 
+.include "$S/arch/m68k/conf/Makefile.kern.m68k.inc"
+
 ##
 ## (5) link settings
 ##

Index: src/sys/arch/atari/conf/files.atari
diff -u src/sys/arch/atari/conf/files.atari:1.120 src/sys/arch/atari/conf/files.atari:1.121
--- src/sys/arch/atari/conf/files.atari:1.120	Tue Nov 15 12:23:21 2011
+++ src/sys/arch/atari/conf/files.atari	Sun Feb 25 00:27:16 2018
@@ -1,5 +1,5 @@
 #
-#	$NetBSD: files.atari,v 1.120 2011/11/15 12:23:21 tsutsui Exp $
+#	$NetBSD: files.atari,v 1.121 2018/02/25 00:27:16 mrg Exp $
 
 maxpartitions 16
 
@@ -217,7 +217,7 @@ file	arch/atari/dev/ym2149.c			_atarihw_
 file	arch/atari/atari/intr.c
 file	arch/m68k/m68k/cacheops.c
 file	arch/m68k/m68k/db_memrw.c		ddb
-file	arch/m68k/m68k/fpu.c
+file	arch/m68k/m68k/fpu.c			compile-with "${M68K_KERN_FPU}"
 file	arch/m68k/m68k/pmap_motorola.c
 file	arch/m68k/m68k/procfs_machdep.c		procfs
 file	arch/m68k/m68k/sys_machdep.c

Index: src/sys/arch/hp300/conf/Makefile.hp300
diff -u src/sys/arch/hp300/conf/Makefile.hp300:1.92 src/sys/arch/hp300/conf/Makefile.hp300:1.93
--- src/sys/arch/hp300/conf/Makefile.hp300:1.92	Sun Sep  6 02:17:30 2015
+++ src/sys/arch/hp300/conf/Makefile.hp300	Sun Feb 25 00:27:16 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.hp300,v 1.92 2015/09/06 02:17:30 uebayasi Exp $
+#	$NetBSD: Makefile.hp300,v 1.93 2018/02/25 00:27:16 mrg Exp $
 
 # Makefile for NetBSD
 #
@@ -54,6 +54,8 @@ MD_SFILES=	${HP300}/hp300/locore.s
 locore.o: ${HP300}/hp300/locore.s assym.h
 	${NORMAL_S}
 
+.include "$S/arch/m68k/conf/Makefile.kern.m68k.inc"
+
 ##
 ## (5) link settings
 ##

Index: src/sys/arch/hp300/conf/files.hp300
diff -u src/sys/arch/hp300/conf/files.hp300:1.89 src/sys/arch/hp300/conf/files.hp300:1.90
--- src/sys/arch/hp300/conf/files.hp300:1.89	Sun Aug 24 08:17:44 2014
+++ src/sys/arch/hp300/conf/files.hp300	Sun Feb 25 00:27:16 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: files.hp300,v 1.89 2014/08/24 08:17:44 tsutsui Exp $
+#	$NetBSD: files.hp300,v 1.90 2018/02/25 00:27:16 mrg Exp $
 #
 # hp300-specific configuration info
 
@@ -217,7 +217,7 @@ file	arch/hp300/hp300/trap.c
 file	arch/hp300/hp300/disksubr.c
 file	arch/m68k/m68k/cacheops.c
 file	arch/m68k/m68k/db_memrw.c		ddb | kgdb
-file	arch/m68k/m68k/fpu.c
+file	arch/m68k/m68k/fpu.c			compile-with "${M68K_KERN_FPU}"
 file	arch/m68k/m68k/kgdb_machdep.c		kgdb
 file	arch/m68k/m68k/pmap_motorola.c
 file	arch/m68k/m68k/procfs_machdep.c		procfs

Index: src/sys/arch/luna68k/conf/Makefile.luna68k
diff -u src/sys/arch/luna68k/conf/Makefile.luna68k:1.27 src/sys/arch/luna68k/conf/Makefile.luna68k:1.28
--- src/sys/arch/luna68k/conf/Makefile.luna68k:1.27	Sun Sep  6 02:17:30 2015
+++ src/sys/arch/luna68k/conf/Makefile.luna68k	Sun Feb 25 00:27:16 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.luna68k,v 1.27 

CVS commit: src

2018-02-24 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sun Feb 25 00:16:49 UTC 2018

Modified Files:
src/crypto/external/bsd/heimdal/bin: Makefile.inc
src/crypto/external/bsd/heimdal/libexec: Makefile.inc
src/crypto/external/bsd/heimdal/sbin: Makefile.inc
src/crypto/external/bsd/openssh/bin/ssh: Makefile
src/crypto/external/bsd/openssh/bin/sshd: Makefile
src/external/bsd/bind: Makefile.inc
src/external/bsd/dhcp: Makefile.inc
src/external/gpl2/xcvs/bin/xcvs: Makefile
src/libexec/ftpd: Makefile
src/libexec/telnetd: Makefile
src/share/mk: bsd.prog.mk
src/usr.bin/login: Makefile
src/usr.bin/passwd: Makefile
src/usr.bin/su: Makefile
src/usr.bin/telnet: Makefile
src/usr.sbin/racoon: Makefile

Log Message:
add LIBKRB5_LDADD/LIBKRB5_DPADD and their static counterparts
to bsd.prog.mk.  use them instead of hard coding various lists
of libraries for krb5.

this fixes static builds.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/crypto/external/bsd/heimdal/bin/Makefile.inc
cvs rdiff -u -r1.5 -r1.6 src/crypto/external/bsd/heimdal/libexec/Makefile.inc
cvs rdiff -u -r1.4 -r1.5 src/crypto/external/bsd/heimdal/sbin/Makefile.inc
cvs rdiff -u -r1.12 -r1.13 src/crypto/external/bsd/openssh/bin/ssh/Makefile
cvs rdiff -u -r1.15 -r1.16 src/crypto/external/bsd/openssh/bin/sshd/Makefile
cvs rdiff -u -r1.29 -r1.30 src/external/bsd/bind/Makefile.inc
cvs rdiff -u -r1.18 -r1.19 src/external/bsd/dhcp/Makefile.inc
cvs rdiff -u -r1.5 -r1.6 src/external/gpl2/xcvs/bin/xcvs/Makefile
cvs rdiff -u -r1.64 -r1.65 src/libexec/ftpd/Makefile
cvs rdiff -u -r1.52 -r1.53 src/libexec/telnetd/Makefile
cvs rdiff -u -r1.310 -r1.311 src/share/mk/bsd.prog.mk
cvs rdiff -u -r1.56 -r1.57 src/usr.bin/login/Makefile
cvs rdiff -u -r1.45 -r1.46 src/usr.bin/passwd/Makefile
cvs rdiff -u -r1.50 -r1.51 src/usr.bin/su/Makefile
cvs rdiff -u -r1.52 -r1.53 src/usr.bin/telnet/Makefile
cvs rdiff -u -r1.33 -r1.34 src/usr.sbin/racoon/Makefile

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

Modified files:

Index: src/crypto/external/bsd/heimdal/bin/Makefile.inc
diff -u src/crypto/external/bsd/heimdal/bin/Makefile.inc:1.3 src/crypto/external/bsd/heimdal/bin/Makefile.inc:1.4
--- src/crypto/external/bsd/heimdal/bin/Makefile.inc:1.3	Sat Jan 28 21:31:43 2017
+++ src/crypto/external/bsd/heimdal/bin/Makefile.inc	Sun Feb 25 00:16:48 2018
@@ -1,13 +1,9 @@
-# $NetBSD: Makefile.inc,v 1.3 2017/01/28 21:31:43 christos Exp $
+# $NetBSD: Makefile.inc,v 1.4 2018/02/25 00:16:48 mrg Exp $
 
 BINDIR=/usr/bin
 
-LDADD+= -lkrb5 -lhx509 -lasn1 -lroken -lcom_err -lwind
-LDADD+= -lheimbase ${LIBVERS}
-LDADD+= -lcrypto -lcrypt
-LDADD+= -lsqlite3
+LDADD+= ${LIBKRB5_LDADD}
+DPADD+= ${LIBKRB5_DPADD}
 
-DPADD+= ${LIBKRB5} ${LIBHX509} ${LIBASN1} ${LIBROKEN} ${LIBCOM_ERR} ${LIBWIND}
+LDADD+= -lheimbase ${LIBVERS}
 DPADD+= ${LIBHEIMBASE} ${LIBVERS}
-DPADD+= ${LIBCRYPTO} ${LIBCRYPT}
-DPADD+= ${LIBSQLITE3}

Index: src/crypto/external/bsd/heimdal/libexec/Makefile.inc
diff -u src/crypto/external/bsd/heimdal/libexec/Makefile.inc:1.5 src/crypto/external/bsd/heimdal/libexec/Makefile.inc:1.6
--- src/crypto/external/bsd/heimdal/libexec/Makefile.inc:1.5	Sun Jan 29 22:09:06 2017
+++ src/crypto/external/bsd/heimdal/libexec/Makefile.inc	Sun Feb 25 00:16:48 2018
@@ -1,15 +1,9 @@
-# $NetBSD: Makefile.inc,v 1.5 2017/01/29 22:09:06 christos Exp $
+# $NetBSD: Makefile.inc,v 1.6 2018/02/25 00:16:48 mrg Exp $
 
 BINDIR=/usr/libexec
 
-LDADD+= -lheimntlm -lkrb5 -lhx509 -lheimbase
-LDADD+= -lasn1 -lcom_err -lroken ${LIBVERS}
-LDADD+= -lwind
-LDADD+= -lcrypto -lcrypt
-LDADD+= -lsqlite3 -lutil
+LDADD+= ${LIBKRB5_LDADD}
+DPADD+= ${LIBKRB5_DPADD}
 
-DPADD+= ${LIBKRB5} ${LIBHX509}
-DPADD+= ${LIBASN1} ${LIBCOM_ERR} ${LIBROKEN} ${LIBVERS}
-DPADD+= ${LIBHEIMBASE} ${LIBHEIMNTLM} ${LIBWIND}
-DPADD+= ${LIBCRYPTO} ${LIBCRYPT}
-DPADD+= ${LIBSQLITE3} ${LIBUTIL}
+LDADD+= -lheimntlm ${LIBVERS}
+DPADD+= ${LIBHEIMNTLM} ${LIBVERS}

Index: src/crypto/external/bsd/heimdal/sbin/Makefile.inc
diff -u src/crypto/external/bsd/heimdal/sbin/Makefile.inc:1.4 src/crypto/external/bsd/heimdal/sbin/Makefile.inc:1.5
--- src/crypto/external/bsd/heimdal/sbin/Makefile.inc:1.4	Sun Jan 29 22:09:06 2017
+++ src/crypto/external/bsd/heimdal/sbin/Makefile.inc	Sun Feb 25 00:16:48 2018
@@ -1,13 +1,9 @@
-# $NetBSD: Makefile.inc,v 1.4 2017/01/29 22:09:06 christos Exp $
+# $NetBSD: Makefile.inc,v 1.5 2018/02/25 00:16:48 mrg Exp $
 
 BINDIR=/usr/sbin
 
-LDADD+= -lkrb5 -lhx509 -lasn1 -lwind
-LDADD+= -lcom_err -lroken -lheimbase ${LIBVERS}
-LDADD+= -lcrypto -lcrypt
-LDADD+= -lsqlite3 -lutil
+LDADD+= ${LIBKRB5_LDADD}
+DPADD+= ${LIBKRB5_DPADD}
 
-DPADD+= ${LIBKRB5} ${LIBHX509} ${LIBASN1} ${LIBWIND}
-DPADD+= ${LIBCOM_ERR} ${LIBROKEN} ${LIBHEIMBASE} ${LIBVERS}
-DPADD+= ${LIBCRYPTO} ${LIBCRYPT}
-DPADD+= ${LIBSQLITE3} ${LIBUTIL}
+LDADD+= -lheimbase ${LIBVERS}
+DPADD+= 

CVS commit: src/crypto/external/bsd/openssl/lib/libcrypto/arch/sparc

2018-02-24 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Feb 24 21:51:22 UTC 2018

Modified Files:
src/crypto/external/bsd/openssl/lib/libcrypto/arch/sparc: crypto.inc

Log Message:
dedup


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 \
src/crypto/external/bsd/openssl/lib/libcrypto/arch/sparc/crypto.inc

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

Modified files:

Index: src/crypto/external/bsd/openssl/lib/libcrypto/arch/sparc/crypto.inc
diff -u src/crypto/external/bsd/openssl/lib/libcrypto/arch/sparc/crypto.inc:1.5 src/crypto/external/bsd/openssl/lib/libcrypto/arch/sparc/crypto.inc:1.6
--- src/crypto/external/bsd/openssl/lib/libcrypto/arch/sparc/crypto.inc:1.5	Sat Feb 24 16:45:57 2018
+++ src/crypto/external/bsd/openssl/lib/libcrypto/arch/sparc/crypto.inc	Sat Feb 24 16:51:22 2018
@@ -1,15 +1,15 @@
 .PATH.S: ${.PARSEDIR}
+CPUID = yes
+CPUID_SRCS += sparccpuid.S
+
 .if ${MACHINE} == "sparc64"
-CPUID_SRCS = sparcv9cap.c sparccpuid.S sparcv9-mont.S sparcv9a-mont.S 
+CPUID_SRCS += sparcv9cap.c sparcv9-mont.S sparcv9a-mont.S 
 CPUID_SRCS += sparct4-mont.S vis3-mont.S
-CPUID = yes
 #CPPFLAGS += -DOPENSSL_BN_ASM_MONT
 AFLAGS.sparcv9-mont.S+= -Wa,-Av9
 AFLAGS.sparcv9a-mont.S+= -Wa,-Av9a
 AFLAGS.sparct4-mont.S+= -Wa,-Av9a
 AFLAGS.vis3-mont.S+= -Wa,-Av9a
-.else
-CPUID = yes
-CPUID_SRCS = sparccpuid.S
 .endif
+
 .include "../../crypto.inc"



CVS commit: src/crypto/external/bsd/openssl/dist/crypto

2018-02-24 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Feb 24 21:47:34 UTC 2018

Modified Files:
src/crypto/external/bsd/openssl/dist/crypto: threads_pthread.c

Log Message:
we don't yet have __atomic_is_lock_free


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.2 \
src/crypto/external/bsd/openssl/dist/crypto/threads_pthread.c

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

Modified files:

Index: src/crypto/external/bsd/openssl/dist/crypto/threads_pthread.c
diff -u src/crypto/external/bsd/openssl/dist/crypto/threads_pthread.c:1.1.1.1 src/crypto/external/bsd/openssl/dist/crypto/threads_pthread.c:1.2
--- src/crypto/external/bsd/openssl/dist/crypto/threads_pthread.c:1.1.1.1	Thu Feb  8 15:56:48 2018
+++ src/crypto/external/bsd/openssl/dist/crypto/threads_pthread.c	Sat Feb 24 16:47:34 2018
@@ -150,12 +150,15 @@ int CRYPTO_THREAD_compare_id(CRYPTO_THRE
 
 int CRYPTO_atomic_add(int *val, int amount, int *ret, CRYPTO_RWLOCK *lock)
 {
+#ifdef notyet
+// We don't provide yet __atomic_is_lock_free
 # if defined(__GNUC__) && defined(__ATOMIC_ACQ_REL)
 if (__atomic_is_lock_free(sizeof(*val), val)) {
 *ret = __atomic_add_fetch(val, amount, __ATOMIC_ACQ_REL);
 return 1;
 }
 # endif
+#endif
 if (!CRYPTO_THREAD_write_lock(lock))
 return 0;
 



CVS commit: src/crypto/external/bsd/openssl/lib/libcrypto

2018-02-24 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Feb 24 21:45:57 UTC 2018

Modified Files:
src/crypto/external/bsd/openssl/lib/libcrypto: ec.inc
src/crypto/external/bsd/openssl/lib/libcrypto/arch/sparc: crypto.inc
ec.inc poly1305.inc

Log Message:
fix sparc.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/crypto/external/bsd/openssl/lib/libcrypto/ec.inc
cvs rdiff -u -r1.4 -r1.5 \
src/crypto/external/bsd/openssl/lib/libcrypto/arch/sparc/crypto.inc \
src/crypto/external/bsd/openssl/lib/libcrypto/arch/sparc/ec.inc \
src/crypto/external/bsd/openssl/lib/libcrypto/arch/sparc/poly1305.inc

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

Modified files:

Index: src/crypto/external/bsd/openssl/lib/libcrypto/ec.inc
diff -u src/crypto/external/bsd/openssl/lib/libcrypto/ec.inc:1.5 src/crypto/external/bsd/openssl/lib/libcrypto/ec.inc:1.6
--- src/crypto/external/bsd/openssl/lib/libcrypto/ec.inc:1.5	Sun Feb 18 18:41:44 2018
+++ src/crypto/external/bsd/openssl/lib/libcrypto/ec.inc	Sat Feb 24 16:45:57 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: ec.inc,v 1.5 2018/02/18 23:41:44 christos Exp $
+#	$NetBSD: ec.inc,v 1.6 2018/02/24 21:45:57 christos Exp $
 #
 #	@(#) Copyright (c) 1995 Simon J. Gerraty
 #
@@ -38,15 +38,17 @@ ecp_nistp224.c \
 ecp_nistp256.c \
 ecp_nistp521.c \
 ecp_nistputil.c \
-ecp_nistz256.c \
 ecp_oct.c \
 ecp_smpl.c \
 ecx_meth.c
 
 SRCS += ${EC_SRCS}
 
+.if defined(ECNI)
 COPTS.ecp_nistz256.c+=-Wno-error=stack-protector
+SRCS+= ecp_nistz256.c
+.endif
 
 .for cryptosrc in ${EC_SRCS}
-CPPFLAGS.${cryptosrc} = -I${OPENSSLSRC}/crypto/ec
+CPPFLAGS.${cryptosrc} = -I${OPENSSLSRC}/crypto/ec ${ECCPPFLAGS}
 .endfor

Index: src/crypto/external/bsd/openssl/lib/libcrypto/arch/sparc/crypto.inc
diff -u src/crypto/external/bsd/openssl/lib/libcrypto/arch/sparc/crypto.inc:1.4 src/crypto/external/bsd/openssl/lib/libcrypto/arch/sparc/crypto.inc:1.5
--- src/crypto/external/bsd/openssl/lib/libcrypto/arch/sparc/crypto.inc:1.4	Thu Nov  3 18:18:29 2016
+++ src/crypto/external/bsd/openssl/lib/libcrypto/arch/sparc/crypto.inc	Sat Feb 24 16:45:57 2018
@@ -1,5 +1,5 @@
-.if ${MACHINE} == "sparc64"
 .PATH.S: ${.PARSEDIR}
+.if ${MACHINE} == "sparc64"
 CPUID_SRCS = sparcv9cap.c sparccpuid.S sparcv9-mont.S sparcv9a-mont.S 
 CPUID_SRCS += sparct4-mont.S vis3-mont.S
 CPUID = yes
@@ -8,5 +8,8 @@ AFLAGS.sparcv9-mont.S+= -Wa,-Av9
 AFLAGS.sparcv9a-mont.S+= -Wa,-Av9a
 AFLAGS.sparct4-mont.S+= -Wa,-Av9a
 AFLAGS.vis3-mont.S+= -Wa,-Av9a
+.else
+CPUID = yes
+CPUID_SRCS = sparccpuid.S
 .endif
 .include "../../crypto.inc"
Index: src/crypto/external/bsd/openssl/lib/libcrypto/arch/sparc/ec.inc
diff -u src/crypto/external/bsd/openssl/lib/libcrypto/arch/sparc/ec.inc:1.4 src/crypto/external/bsd/openssl/lib/libcrypto/arch/sparc/ec.inc:1.5
--- src/crypto/external/bsd/openssl/lib/libcrypto/arch/sparc/ec.inc:1.4	Sat Feb 24 15:23:58 2018
+++ src/crypto/external/bsd/openssl/lib/libcrypto/arch/sparc/ec.inc	Sat Feb 24 16:45:57 2018
@@ -1,7 +1,12 @@
+.if ${MACHINE} == "sparc64"
 .PATH.S: ${.PARSEDIR}
 EC_SRCS += \
+	ecp_nistz256-sparcv9.S
 
 ECNI = yes
 AFLAGS.ecp_nistz256-sparcv9.S += -Wa,-Av9
+.else
+ECCPPFLAGS+=-DECP_NISTZ256_REFERENCE_IMPLEMENTATION
+.endif
 
 .include "../../ec.inc"
Index: src/crypto/external/bsd/openssl/lib/libcrypto/arch/sparc/poly1305.inc
diff -u src/crypto/external/bsd/openssl/lib/libcrypto/arch/sparc/poly1305.inc:1.4 src/crypto/external/bsd/openssl/lib/libcrypto/arch/sparc/poly1305.inc:1.5
--- src/crypto/external/bsd/openssl/lib/libcrypto/arch/sparc/poly1305.inc:1.4	Sat Feb 24 15:23:58 2018
+++ src/crypto/external/bsd/openssl/lib/libcrypto/arch/sparc/poly1305.inc	Sat Feb 24 16:45:57 2018
@@ -1,8 +1,10 @@
+.if ${MACHINE} == "sparc64"
 .PATH.S: ${.PARSEDIR}
 
 POLY1305_SRCS = poly1305-sparcv9.S
 POLY1305_CPPFLAGS+=-DPOLY1305_ASM
 
 AFLAGS.poly1305-sparcv9.S+= -Wa,-Av9
+.endif
 
 .include "../../poly1305.inc"



CVS commit: src/crypto/external/bsd/openssl/lib/libcrypto/arch/sparc

2018-02-24 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Feb 24 20:23:58 UTC 2018

Modified Files:
src/crypto/external/bsd/openssl/lib/libcrypto/arch/sparc: ec.inc
poly1305.inc

Log Message:
add the right assembler flags for the two new files.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 \
src/crypto/external/bsd/openssl/lib/libcrypto/arch/sparc/ec.inc \
src/crypto/external/bsd/openssl/lib/libcrypto/arch/sparc/poly1305.inc

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

Modified files:

Index: src/crypto/external/bsd/openssl/lib/libcrypto/arch/sparc/ec.inc
diff -u src/crypto/external/bsd/openssl/lib/libcrypto/arch/sparc/ec.inc:1.3 src/crypto/external/bsd/openssl/lib/libcrypto/arch/sparc/ec.inc:1.4
--- src/crypto/external/bsd/openssl/lib/libcrypto/arch/sparc/ec.inc:1.3	Tue Feb 20 08:14:02 2018
+++ src/crypto/external/bsd/openssl/lib/libcrypto/arch/sparc/ec.inc	Sat Feb 24 15:23:58 2018
@@ -1,6 +1,7 @@
 .PATH.S: ${.PARSEDIR}
 EC_SRCS += \
-ecp_nistz256-sparcv9.S 
 
 ECNI = yes
+AFLAGS.ecp_nistz256-sparcv9.S += -Wa,-Av9
+
 .include "../../ec.inc"
Index: src/crypto/external/bsd/openssl/lib/libcrypto/arch/sparc/poly1305.inc
diff -u src/crypto/external/bsd/openssl/lib/libcrypto/arch/sparc/poly1305.inc:1.3 src/crypto/external/bsd/openssl/lib/libcrypto/arch/sparc/poly1305.inc:1.4
--- src/crypto/external/bsd/openssl/lib/libcrypto/arch/sparc/poly1305.inc:1.3	Tue Feb 20 08:14:02 2018
+++ src/crypto/external/bsd/openssl/lib/libcrypto/arch/sparc/poly1305.inc	Sat Feb 24 15:23:58 2018
@@ -3,4 +3,6 @@
 POLY1305_SRCS = poly1305-sparcv9.S
 POLY1305_CPPFLAGS+=-DPOLY1305_ASM
 
+AFLAGS.poly1305-sparcv9.S+= -Wa,-Av9
+
 .include "../../poly1305.inc"



CVS commit: src/sys/arch/x86/x86

2018-02-24 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Feb 24 19:52:46 UTC 2018

Modified Files:
src/sys/arch/x86/x86: svs.c

Log Message:
Fix one thing in the documentation, I meant to say only SVS_UTLS.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/x86/x86/svs.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/x86/x86/svs.c
diff -u src/sys/arch/x86/x86/svs.c:1.10 src/sys/arch/x86/x86/svs.c:1.11
--- src/sys/arch/x86/x86/svs.c:1.10	Sat Feb 24 10:31:30 2018
+++ src/sys/arch/x86/x86/svs.c	Sat Feb 24 19:52:46 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: svs.c,v 1.10 2018/02/24 10:31:30 maxv Exp $	*/
+/*	$NetBSD: svs.c,v 1.11 2018/02/24 19:52:46 maxv Exp $	*/
 
 /*
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: svs.c,v 1.10 2018/02/24 10:31:30 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: svs.c,v 1.11 2018/02/24 19:52:46 maxv Exp $");
 
 #include "opt_svs.h"
 
@@ -61,9 +61,9 @@ __KERNEL_RCSID(0, "$NetBSD: svs.c,v 1.10
  * Storage. Each CPU has one UTLS page. This page has two VAs:
  *
  *  o When the user page tables are loaded in CR3, the VA to access this
- *page is >utls, defined as SVS_UTLS+UTLS_KPDIRPA in assembly.
- *This VA is _constant_ across CPUs, but in the user page tables this
- *VA points to the physical page of the UTLS that is _local_ to the CPU.
+ *page is >utls, defined as SVS_UTLS in assembly. This VA is
+ *_constant_ across CPUs, but in the user page tables this VA points to
+ *the physical page of the UTLS that is _local_ to the CPU.
  *
  *  o When the kernel page tables are loaded in CR3, the VA to access this
  *page is ci->ci_svs_utls.
@@ -71,7 +71,7 @@ __KERNEL_RCSID(0, "$NetBSD: svs.c,v 1.10
  * +--+
  * | CPU0 Local Data  (Physical Page) |
  * | +--+ +-+ |
- * | | User Page Tables | SVS_UTLS+UTLS_KPDIRPA > | cpu0's UTLS | |
+ * | | User Page Tables | SVS_UTLS -> | cpu0's UTLS | |
  * | +--+ +-+ |
  * +-^+
  *   |
@@ -80,7 +80,7 @@ __KERNEL_RCSID(0, "$NetBSD: svs.c,v 1.10
  * +--+ |
  * | CPU1 Local Data  (Physical Page) | |
  * | +--+ +-+ | |
- * | | User Page Tables | SVS_UTLS+UTLS_KPDIRPA > | cpu1's UTLS | | |
+ * | | User Page Tables | SVS_UTLS -> | cpu1's UTLS | | |
  * | +--+ +-+ | |
  * +-^+ |
  *   |  |



CVS commit: src/sys/arch/macppc/conf

2018-02-24 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Sat Feb 24 18:58:00 UTC 2018

Modified Files:
src/sys/arch/macppc/conf: GENERIC GENERIC_601 MAMBO

Log Message:
Remove legacy comment regarding the instability of awacs(4)
Enable awacs(4), skipping MAMBO config as it is for an emulator.

>From 
"that warning about the awacs driver making some
machines lock up can probably go. It's ancient and I've never seen it
actually happen, I have several oldish macs with different awacs
variants and it's enabled in all my configs. In fact it predates my
macppc interrupt cleanup ( I think I did that in 2005 or so ) and I
strongly suspect that fixed the problem.
( the ancient code didn't properly distinguish between edge and level
triggered interrupts on grand central / heathrow type hardware, IIRC it
always just checked the level register(s) which resulted in edge
triggered interrupts being missed or misdetected. Most of the mac-io
goop from that time uses edge triggered interrupts, which includes
awacs )

If this actually happens to anyone I'd like to know about it"


To generate a diff of this commit:
cvs rdiff -u -r1.342 -r1.343 src/sys/arch/macppc/conf/GENERIC
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/macppc/conf/GENERIC_601
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/macppc/conf/MAMBO

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/macppc/conf/GENERIC
diff -u src/sys/arch/macppc/conf/GENERIC:1.342 src/sys/arch/macppc/conf/GENERIC:1.343
--- src/sys/arch/macppc/conf/GENERIC:1.342	Fri Feb 23 03:04:01 2018
+++ src/sys/arch/macppc/conf/GENERIC	Sat Feb 24 18:58:00 2018
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.342 2018/02/23 03:04:01 sevan Exp $
+# $NetBSD: GENERIC,v 1.343 2018/02/24 18:58:00 sevan Exp $
 #
 # GENERIC machine description file
 # 
@@ -22,7 +22,7 @@ include		"arch/macppc/conf/std.macppc"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident 		"GENERIC-$Revision: 1.342 $"
+#ident 		"GENERIC-$Revision: 1.343 $"
 
 maxusers	32
 
@@ -389,11 +389,7 @@ zsc*	at obio?
 zstty*	at zsc? channel ?
 mediabay* at obio?
 wdc*	at mediabay? flags 0
-# awacs is disabled because on most systems (7300 - 9600 PowerMacs,
-# many kinds of G4s), very heavy load can cause the machine to lock
-# up. ONLY enable this if your machine is never under heavy load, or
-# you'd rather have audio than worry about occasional lockups.
-#awacs*	at obio?			# Apple audio device
+awacs*	at obio?			# Apple audio device
 ki2c*	at obio?			# Keywest I2C
 ki2c*	at uni_n?			# Keywest I2C
 iic*	at ki2c?

Index: src/sys/arch/macppc/conf/GENERIC_601
diff -u src/sys/arch/macppc/conf/GENERIC_601:1.18 src/sys/arch/macppc/conf/GENERIC_601:1.19
--- src/sys/arch/macppc/conf/GENERIC_601:1.18	Fri Feb 23 03:04:01 2018
+++ src/sys/arch/macppc/conf/GENERIC_601	Sat Feb 24 18:58:00 2018
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC_601,v 1.18 2018/02/23 03:04:01 sevan Exp $
+# $NetBSD: GENERIC_601,v 1.19 2018/02/24 18:58:00 sevan Exp $
 #
 # GENERIC machine description file
 # 
@@ -28,7 +28,7 @@ include 	"arch/macppc/conf/std.macppc.60
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-ident 		"GENERIC-$Revision: 1.18 $"
+ident 		"GENERIC-$Revision: 1.19 $"
 
 maxusers	32
 
@@ -264,10 +264,6 @@ iic0	at cuda0		# CUDA's IIC bus
 zsc*	at obio?
 zstty*	at zsc? channel ?
 
-# awacs is disabled because on most systems (7300 - 9600 PowerMacs,
-# many kinds of G4s), very heavy load can cause the machine to lock
-# up. ONLY enable this if your machine is never under heavy load, or
-# you'd rather have audio than worry about occasional lockups.
 awacs*	at obio?			# Apple audio device
 
 # Cryptographic Devices

Index: src/sys/arch/macppc/conf/MAMBO
diff -u src/sys/arch/macppc/conf/MAMBO:1.29 src/sys/arch/macppc/conf/MAMBO:1.30
--- src/sys/arch/macppc/conf/MAMBO:1.29	Fri Feb 23 03:04:01 2018
+++ src/sys/arch/macppc/conf/MAMBO	Sat Feb 24 18:58:00 2018
@@ -6,7 +6,7 @@ include 	"arch/macppc/conf/std.macppc.g5
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident 		"GENERIC-$Revision: 1.29 $"
+#ident 		"GENERIC-$Revision: 1.30 $"
 
 maxusers	32
 
@@ -138,10 +138,6 @@ macofcons0 at pci? dev ? function ?	# Op
 
 # PCI serial interfaces
 nvram*	at obio?			# nvram
-# awacs is disabled because on most systems (7300 - 9600 PowerMacs,
-# many kinds of G4s), very heavy load can cause the machine to lock
-# up. ONLY enable this if your machine is never under heavy load, or
-# you'd rather have audio than worry about occasional lockups.
 #awacs*	at obio?			# Apple audio device
 #ki2c*	at obio?			# Keywest I2C
 wi*	at obio?			# AirMac



CVS commit: [netbsd-7] src/doc

2018-02-24 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sat Feb 24 18:30:57 UTC 2018

Modified Files:
src/doc [netbsd-7]: CHANGES-7.2

Log Message:
1571


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.71 -r1.1.2.72 src/doc/CHANGES-7.2

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-7.2
diff -u src/doc/CHANGES-7.2:1.1.2.71 src/doc/CHANGES-7.2:1.1.2.72
--- src/doc/CHANGES-7.2:1.1.2.71	Mon Feb 19 19:46:26 2018
+++ src/doc/CHANGES-7.2	Sat Feb 24 18:30:56 2018
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-7.2,v 1.1.2.71 2018/02/19 19:46:26 snj Exp $
+# $NetBSD: CHANGES-7.2,v 1.1.2.72 2018/02/24 18:30:56 snj Exp $
 
 A complete list of changes from the NetBSD 7.1 release to the NetBSD 7.2
 release:
@@ -5217,3 +5217,9 @@ usr.sbin/ypserv/ypserv/ypserv_proc.c		1.
 	to avoid returning stale request data to the client.
 	[christos, ticket #1566]
 
+sys/net/if_mpls.c1.31-1.33 via patch
+sys/netmpls/mpls_ttl.c1.9
+
+   	Fix several memory corruptions and inconsistencies in MPLS.
+	[maxv, ticket #1571]
+



CVS commit: [netbsd-7-1] src/doc

2018-02-24 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sat Feb 24 18:30:46 UTC 2018

Modified Files:
src/doc [netbsd-7-1]: CHANGES-7.1.2

Log Message:
1571


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.15 -r1.1.2.16 src/doc/CHANGES-7.1.2

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-7.1.2
diff -u src/doc/CHANGES-7.1.2:1.1.2.15 src/doc/CHANGES-7.1.2:1.1.2.16
--- src/doc/CHANGES-7.1.2:1.1.2.15	Mon Feb 19 19:48:49 2018
+++ src/doc/CHANGES-7.1.2	Sat Feb 24 18:30:46 2018
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-7.1.2,v 1.1.2.15 2018/02/19 19:48:49 snj Exp $
+# $NetBSD: CHANGES-7.1.2,v 1.1.2.16 2018/02/24 18:30:46 snj Exp $
 
 A complete list of changes from the NetBSD 7.1.1 release to the NetBSD 7.1.2
 release:
@@ -151,3 +151,9 @@ usr.sbin/ypserv/ypserv/ypserv_proc.c		1.
 	procs to avoid returning stale request data to the client.
 	[christos, ticket #1566]
 
+sys/net/if_mpls.c1.31-1.33 via patch
+sys/netmpls/mpls_ttl.c1.9
+
+   	Fix several memory corruptions and inconsistencies in MPLS.
+	[maxv, ticket #1571]
+



CVS commit: [netbsd-7-0] src/doc

2018-02-24 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sat Feb 24 18:30:39 UTC 2018

Modified Files:
src/doc [netbsd-7-0]: CHANGES-7.0.3

Log Message:
1571


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.85 -r1.1.2.86 src/doc/CHANGES-7.0.3

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-7.0.3
diff -u src/doc/CHANGES-7.0.3:1.1.2.85 src/doc/CHANGES-7.0.3:1.1.2.86
--- src/doc/CHANGES-7.0.3:1.1.2.85	Mon Feb 19 19:50:53 2018
+++ src/doc/CHANGES-7.0.3	Sat Feb 24 18:30:39 2018
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-7.0.3,v 1.1.2.85 2018/02/19 19:50:53 snj Exp $
+# $NetBSD: CHANGES-7.0.3,v 1.1.2.86 2018/02/24 18:30:39 snj Exp $
 
 A complete list of changes from the NetBSD 7.0.2 release to the NetBSD 7.0.3
 release:
@@ -5263,3 +5263,9 @@ usr.sbin/ypserv/ypserv/ypserv_proc.c		1.
 	procs to avoid returning stale request data to the client.
 	[christos, ticket #1566]
 
+sys/net/if_mpls.c1.31-1.33 via patch
+sys/netmpls/mpls_ttl.c1.9
+
+   	Fix several memory corruptions and inconsistencies in MPLS.
+	[maxv, ticket #1571]
+



CVS commit: [netbsd-7-0] src/sys

2018-02-24 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sat Feb 24 18:29:37 UTC 2018

Modified Files:
src/sys/net [netbsd-7-0]: if_mpls.c
src/sys/netmpls [netbsd-7-0]: mpls_ttl.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #1571):
sys/net/if_mpls.c: 1.31-1.33 via patch
sys/netmpls/mpls_ttl.c: 1.9
Style, and fix several bugs:
 - ip4_check(), mpls_unlabel_inet() and mpls_unlabel_inet6() perform
   pullups, so we need to pass the updated pointers back
 - in mpls_lse() the route is not always freed
Looks a little better now.
--
Kick MPLS packets earlier.
--
Several changes:
 * Declare TRIM_LABEL as a function.
 * In mpls_unlabel_inet, copy the label locally. It's not incorrect to
   keep a pointer on the mbuf, but it's bug-friendly.
 * In mpls_label_inetX, fix the length check. Meanwhile add an XXX: we
   just want to make sure that m_copydata won't fail, but if we were
   guaranteed that m has M_PKTHDR set, we could simply check the length
   against m->m_pkthdr.len.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.16.6.1 src/sys/net/if_mpls.c
cvs rdiff -u -r1.4 -r1.4.8.1 src/sys/netmpls/mpls_ttl.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/if_mpls.c
diff -u src/sys/net/if_mpls.c:1.16 src/sys/net/if_mpls.c:1.16.6.1
--- src/sys/net/if_mpls.c:1.16	Thu Jul 17 10:46:57 2014
+++ src/sys/net/if_mpls.c	Sat Feb 24 18:29:36 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_mpls.c,v 1.16 2014/07/17 10:46:57 bouyer Exp $ */
+/*	$NetBSD: if_mpls.c,v 1.16.6.1 2018/02/24 18:29:36 snj Exp $ */
 
 /*
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_mpls.c,v 1.16 2014/07/17 10:46:57 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_mpls.c,v 1.16.6.1 2018/02/24 18:29:36 snj Exp $");
 
 #include "opt_inet.h"
 #include "opt_mpls.h"
@@ -92,12 +92,12 @@ static int mpls_send_frame(struct mbuf *
 static int mpls_lse(struct mbuf *);
 
 #ifdef INET
-static int mpls_unlabel_inet(struct mbuf *);
+static struct mbuf *mpls_unlabel_inet(struct mbuf *, int *error);
 static struct mbuf *mpls_label_inet(struct mbuf *, union mpls_shim *, uint);
 #endif
 
 #ifdef INET6
-static int mpls_unlabel_inet6(struct mbuf *);
+static struct mbuf *mpls_unlabel_inet6(struct mbuf *, int *error);
 static struct mbuf *mpls_label_inet6(struct mbuf *, union mpls_shim *, uint);
 #endif
 
@@ -321,6 +321,12 @@ mpls_lse(struct mbuf *m)
 	uint psize = sizeof(struct sockaddr_mpls);
 	bool push_back_alert = false;
 
+	/* If we're not accepting MPLS frames, leave now. */
+	if (!mpls_frame_accept) {
+		error = EINVAL;
+		goto done;
+	}
+
 	if (m->m_len < sizeof(union mpls_shim) &&
 	(m = m_pullup(m, sizeof(union mpls_shim))) == NULL)
 		goto done;
@@ -329,21 +335,19 @@ mpls_lse(struct mbuf *m)
 	dst.smpls_family = AF_MPLS;
 	dst.smpls_addr.s_addr = ntohl(mtod(m, union mpls_shim *)->s_addr);
 
-	/* Check if we're accepting MPLS Frames */
 	error = EINVAL;
-	if (!mpls_frame_accept)
-		goto done;
 
 	/* TTL decrement */
 	if ((m = mpls_ttl_dec(m)) == NULL)
 		goto done;
 
 	/* RFC 4182 */
-	if (mpls_rfc4182 != 0)
-		while((dst.smpls_addr.shim.label == MPLS_LABEL_IPV4NULL ||
+	if (mpls_rfc4182 != 0) {
+		while ((dst.smpls_addr.shim.label == MPLS_LABEL_IPV4NULL ||
 		dst.smpls_addr.shim.label == MPLS_LABEL_IPV6NULL) &&
 		__predict_false(dst.smpls_addr.shim.bos == 0))
 			TRIM_LABEL;
+	}
 
 	/* RFC 3032 Section 2.1 Page 4 */
 	if (__predict_false(dst.smpls_addr.shim.label == MPLS_LABEL_RTALERT) &&
@@ -358,15 +362,17 @@ mpls_lse(struct mbuf *m)
 #ifdef INET
 		case MPLS_LABEL_IPV4NULL:
 			/* Pop shim and push mbuf to IP stack */
-			if (dst.smpls_addr.shim.bos)
-error = mpls_unlabel_inet(m);
+			if (dst.smpls_addr.shim.bos) {
+m = mpls_unlabel_inet(m, );
+			}
 			break;
 #endif
 #ifdef INET6
 		case MPLS_LABEL_IPV6NULL:
 			/* Pop shim and push mbuf to IPv6 stack */
-			if (dst.smpls_addr.shim.bos)
-error = mpls_unlabel_inet6(m);
+			if (dst.smpls_addr.shim.bos) {
+m = mpls_unlabel_inet6(m, );
+			}
 			break;
 #endif
 		case MPLS_LABEL_RTALERT:	/* Yeah, I'm all alerted */
@@ -420,8 +426,10 @@ mpls_lse(struct mbuf *m)
 		tshim.shim.bos = tshim.shim.exp = 0;
 		tshim.shim.ttl = mpls_defttl;
 		if (tshim.shim.label != MPLS_LABEL_IMPLNULL &&
-		((m = mpls_prepend_shim(m, )) == NULL))
-			return ENOBUFS;
+		((m = mpls_prepend_shim(m, )) == NULL)) {
+			error = ENOBUFS;
+			goto done;
+		}
 		psize += sizeof(tshim);
 	}
 
@@ -431,8 +439,10 @@ mpls_lse(struct mbuf *m)
 		tshim.s_addr = MPLS_LABEL_RTALERT;
 		tshim.shim.bos = tshim.shim.exp = 0;
 		tshim.shim.ttl = mpls_defttl;
-		if ((m = mpls_prepend_shim(m, )) == NULL)
-			return ENOBUFS;
+		if ((m = mpls_prepend_shim(m, )) == NULL) {
+			error = ENOBUFS;
+			goto done;
+		}
 	}
 
 	error = mpls_send_frame(m, rt->rt_ifp, rt);
@@ -480,18 +490,15 @@ 

CVS commit: [netbsd-7-1] src/sys

2018-02-24 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sat Feb 24 18:29:39 UTC 2018

Modified Files:
src/sys/net [netbsd-7-1]: if_mpls.c
src/sys/netmpls [netbsd-7-1]: mpls_ttl.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #1571):
sys/net/if_mpls.c: 1.31-1.33 via patch
sys/netmpls/mpls_ttl.c: 1.9
Style, and fix several bugs:
 - ip4_check(), mpls_unlabel_inet() and mpls_unlabel_inet6() perform
   pullups, so we need to pass the updated pointers back
 - in mpls_lse() the route is not always freed
Looks a little better now.
--
Kick MPLS packets earlier.
--
Several changes:
 * Declare TRIM_LABEL as a function.
 * In mpls_unlabel_inet, copy the label locally. It's not incorrect to
   keep a pointer on the mbuf, but it's bug-friendly.
 * In mpls_label_inetX, fix the length check. Meanwhile add an XXX: we
   just want to make sure that m_copydata won't fail, but if we were
   guaranteed that m has M_PKTHDR set, we could simply check the length
   against m->m_pkthdr.len.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.16.10.1 src/sys/net/if_mpls.c
cvs rdiff -u -r1.4 -r1.4.12.1 src/sys/netmpls/mpls_ttl.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/if_mpls.c
diff -u src/sys/net/if_mpls.c:1.16 src/sys/net/if_mpls.c:1.16.10.1
--- src/sys/net/if_mpls.c:1.16	Thu Jul 17 10:46:57 2014
+++ src/sys/net/if_mpls.c	Sat Feb 24 18:29:38 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_mpls.c,v 1.16 2014/07/17 10:46:57 bouyer Exp $ */
+/*	$NetBSD: if_mpls.c,v 1.16.10.1 2018/02/24 18:29:38 snj Exp $ */
 
 /*
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_mpls.c,v 1.16 2014/07/17 10:46:57 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_mpls.c,v 1.16.10.1 2018/02/24 18:29:38 snj Exp $");
 
 #include "opt_inet.h"
 #include "opt_mpls.h"
@@ -92,12 +92,12 @@ static int mpls_send_frame(struct mbuf *
 static int mpls_lse(struct mbuf *);
 
 #ifdef INET
-static int mpls_unlabel_inet(struct mbuf *);
+static struct mbuf *mpls_unlabel_inet(struct mbuf *, int *error);
 static struct mbuf *mpls_label_inet(struct mbuf *, union mpls_shim *, uint);
 #endif
 
 #ifdef INET6
-static int mpls_unlabel_inet6(struct mbuf *);
+static struct mbuf *mpls_unlabel_inet6(struct mbuf *, int *error);
 static struct mbuf *mpls_label_inet6(struct mbuf *, union mpls_shim *, uint);
 #endif
 
@@ -321,6 +321,12 @@ mpls_lse(struct mbuf *m)
 	uint psize = sizeof(struct sockaddr_mpls);
 	bool push_back_alert = false;
 
+	/* If we're not accepting MPLS frames, leave now. */
+	if (!mpls_frame_accept) {
+		error = EINVAL;
+		goto done;
+	}
+
 	if (m->m_len < sizeof(union mpls_shim) &&
 	(m = m_pullup(m, sizeof(union mpls_shim))) == NULL)
 		goto done;
@@ -329,21 +335,19 @@ mpls_lse(struct mbuf *m)
 	dst.smpls_family = AF_MPLS;
 	dst.smpls_addr.s_addr = ntohl(mtod(m, union mpls_shim *)->s_addr);
 
-	/* Check if we're accepting MPLS Frames */
 	error = EINVAL;
-	if (!mpls_frame_accept)
-		goto done;
 
 	/* TTL decrement */
 	if ((m = mpls_ttl_dec(m)) == NULL)
 		goto done;
 
 	/* RFC 4182 */
-	if (mpls_rfc4182 != 0)
-		while((dst.smpls_addr.shim.label == MPLS_LABEL_IPV4NULL ||
+	if (mpls_rfc4182 != 0) {
+		while ((dst.smpls_addr.shim.label == MPLS_LABEL_IPV4NULL ||
 		dst.smpls_addr.shim.label == MPLS_LABEL_IPV6NULL) &&
 		__predict_false(dst.smpls_addr.shim.bos == 0))
 			TRIM_LABEL;
+	}
 
 	/* RFC 3032 Section 2.1 Page 4 */
 	if (__predict_false(dst.smpls_addr.shim.label == MPLS_LABEL_RTALERT) &&
@@ -358,15 +362,17 @@ mpls_lse(struct mbuf *m)
 #ifdef INET
 		case MPLS_LABEL_IPV4NULL:
 			/* Pop shim and push mbuf to IP stack */
-			if (dst.smpls_addr.shim.bos)
-error = mpls_unlabel_inet(m);
+			if (dst.smpls_addr.shim.bos) {
+m = mpls_unlabel_inet(m, );
+			}
 			break;
 #endif
 #ifdef INET6
 		case MPLS_LABEL_IPV6NULL:
 			/* Pop shim and push mbuf to IPv6 stack */
-			if (dst.smpls_addr.shim.bos)
-error = mpls_unlabel_inet6(m);
+			if (dst.smpls_addr.shim.bos) {
+m = mpls_unlabel_inet6(m, );
+			}
 			break;
 #endif
 		case MPLS_LABEL_RTALERT:	/* Yeah, I'm all alerted */
@@ -420,8 +426,10 @@ mpls_lse(struct mbuf *m)
 		tshim.shim.bos = tshim.shim.exp = 0;
 		tshim.shim.ttl = mpls_defttl;
 		if (tshim.shim.label != MPLS_LABEL_IMPLNULL &&
-		((m = mpls_prepend_shim(m, )) == NULL))
-			return ENOBUFS;
+		((m = mpls_prepend_shim(m, )) == NULL)) {
+			error = ENOBUFS;
+			goto done;
+		}
 		psize += sizeof(tshim);
 	}
 
@@ -431,8 +439,10 @@ mpls_lse(struct mbuf *m)
 		tshim.s_addr = MPLS_LABEL_RTALERT;
 		tshim.shim.bos = tshim.shim.exp = 0;
 		tshim.shim.ttl = mpls_defttl;
-		if ((m = mpls_prepend_shim(m, )) == NULL)
-			return ENOBUFS;
+		if ((m = mpls_prepend_shim(m, )) == NULL) {
+			error = ENOBUFS;
+			goto done;
+		}
 	}
 
 	error = mpls_send_frame(m, rt->rt_ifp, rt);
@@ -480,18 +490,15 @@ 

CVS commit: [netbsd-7] src/sys

2018-02-24 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sat Feb 24 18:29:41 UTC 2018

Modified Files:
src/sys/net [netbsd-7]: if_mpls.c
src/sys/netmpls [netbsd-7]: mpls_ttl.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #1571):
sys/net/if_mpls.c: 1.31-1.33 via patch
sys/netmpls/mpls_ttl.c: 1.9
Style, and fix several bugs:
 - ip4_check(), mpls_unlabel_inet() and mpls_unlabel_inet6() perform
   pullups, so we need to pass the updated pointers back
 - in mpls_lse() the route is not always freed
Looks a little better now.
--
Kick MPLS packets earlier.
--
Several changes:
 * Declare TRIM_LABEL as a function.
 * In mpls_unlabel_inet, copy the label locally. It's not incorrect to
   keep a pointer on the mbuf, but it's bug-friendly.
 * In mpls_label_inetX, fix the length check. Meanwhile add an XXX: we
   just want to make sure that m_copydata won't fail, but if we were
   guaranteed that m has M_PKTHDR set, we could simply check the length
   against m->m_pkthdr.len.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.16.2.1 src/sys/net/if_mpls.c
cvs rdiff -u -r1.4 -r1.4.4.1 src/sys/netmpls/mpls_ttl.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/if_mpls.c
diff -u src/sys/net/if_mpls.c:1.16 src/sys/net/if_mpls.c:1.16.2.1
--- src/sys/net/if_mpls.c:1.16	Thu Jul 17 10:46:57 2014
+++ src/sys/net/if_mpls.c	Sat Feb 24 18:29:40 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_mpls.c,v 1.16 2014/07/17 10:46:57 bouyer Exp $ */
+/*	$NetBSD: if_mpls.c,v 1.16.2.1 2018/02/24 18:29:40 snj Exp $ */
 
 /*
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_mpls.c,v 1.16 2014/07/17 10:46:57 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_mpls.c,v 1.16.2.1 2018/02/24 18:29:40 snj Exp $");
 
 #include "opt_inet.h"
 #include "opt_mpls.h"
@@ -92,12 +92,12 @@ static int mpls_send_frame(struct mbuf *
 static int mpls_lse(struct mbuf *);
 
 #ifdef INET
-static int mpls_unlabel_inet(struct mbuf *);
+static struct mbuf *mpls_unlabel_inet(struct mbuf *, int *error);
 static struct mbuf *mpls_label_inet(struct mbuf *, union mpls_shim *, uint);
 #endif
 
 #ifdef INET6
-static int mpls_unlabel_inet6(struct mbuf *);
+static struct mbuf *mpls_unlabel_inet6(struct mbuf *, int *error);
 static struct mbuf *mpls_label_inet6(struct mbuf *, union mpls_shim *, uint);
 #endif
 
@@ -321,6 +321,12 @@ mpls_lse(struct mbuf *m)
 	uint psize = sizeof(struct sockaddr_mpls);
 	bool push_back_alert = false;
 
+	/* If we're not accepting MPLS frames, leave now. */
+	if (!mpls_frame_accept) {
+		error = EINVAL;
+		goto done;
+	}
+
 	if (m->m_len < sizeof(union mpls_shim) &&
 	(m = m_pullup(m, sizeof(union mpls_shim))) == NULL)
 		goto done;
@@ -329,21 +335,19 @@ mpls_lse(struct mbuf *m)
 	dst.smpls_family = AF_MPLS;
 	dst.smpls_addr.s_addr = ntohl(mtod(m, union mpls_shim *)->s_addr);
 
-	/* Check if we're accepting MPLS Frames */
 	error = EINVAL;
-	if (!mpls_frame_accept)
-		goto done;
 
 	/* TTL decrement */
 	if ((m = mpls_ttl_dec(m)) == NULL)
 		goto done;
 
 	/* RFC 4182 */
-	if (mpls_rfc4182 != 0)
-		while((dst.smpls_addr.shim.label == MPLS_LABEL_IPV4NULL ||
+	if (mpls_rfc4182 != 0) {
+		while ((dst.smpls_addr.shim.label == MPLS_LABEL_IPV4NULL ||
 		dst.smpls_addr.shim.label == MPLS_LABEL_IPV6NULL) &&
 		__predict_false(dst.smpls_addr.shim.bos == 0))
 			TRIM_LABEL;
+	}
 
 	/* RFC 3032 Section 2.1 Page 4 */
 	if (__predict_false(dst.smpls_addr.shim.label == MPLS_LABEL_RTALERT) &&
@@ -358,15 +362,17 @@ mpls_lse(struct mbuf *m)
 #ifdef INET
 		case MPLS_LABEL_IPV4NULL:
 			/* Pop shim and push mbuf to IP stack */
-			if (dst.smpls_addr.shim.bos)
-error = mpls_unlabel_inet(m);
+			if (dst.smpls_addr.shim.bos) {
+m = mpls_unlabel_inet(m, );
+			}
 			break;
 #endif
 #ifdef INET6
 		case MPLS_LABEL_IPV6NULL:
 			/* Pop shim and push mbuf to IPv6 stack */
-			if (dst.smpls_addr.shim.bos)
-error = mpls_unlabel_inet6(m);
+			if (dst.smpls_addr.shim.bos) {
+m = mpls_unlabel_inet6(m, );
+			}
 			break;
 #endif
 		case MPLS_LABEL_RTALERT:	/* Yeah, I'm all alerted */
@@ -420,8 +426,10 @@ mpls_lse(struct mbuf *m)
 		tshim.shim.bos = tshim.shim.exp = 0;
 		tshim.shim.ttl = mpls_defttl;
 		if (tshim.shim.label != MPLS_LABEL_IMPLNULL &&
-		((m = mpls_prepend_shim(m, )) == NULL))
-			return ENOBUFS;
+		((m = mpls_prepend_shim(m, )) == NULL)) {
+			error = ENOBUFS;
+			goto done;
+		}
 		psize += sizeof(tshim);
 	}
 
@@ -431,8 +439,10 @@ mpls_lse(struct mbuf *m)
 		tshim.s_addr = MPLS_LABEL_RTALERT;
 		tshim.shim.bos = tshim.shim.exp = 0;
 		tshim.shim.ttl = mpls_defttl;
-		if ((m = mpls_prepend_shim(m, )) == NULL)
-			return ENOBUFS;
+		if ((m = mpls_prepend_shim(m, )) == NULL) {
+			error = ENOBUFS;
+			goto done;
+		}
 	}
 
 	error = mpls_send_frame(m, rt->rt_ifp, rt);
@@ -480,18 +490,15 @@ 

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

2018-02-24 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Feb 24 17:12:10 UTC 2018

Modified Files:
src/sys/arch/amd64/amd64: locore.S

Log Message:
Use %rax instead of %r15 in the non-SVS case, to reduce the diff against
SVS. In SVS we use %rax instead of %r15 because the following instructions
cannot be encoded:

movq%r15,SVS_UTLS+UTLS_SCRATCH
movqSVS_UTLS+UTLS_RSP0,%r15


To generate a diff of this commit:
cvs rdiff -u -r1.155 -r1.156 src/sys/arch/amd64/amd64/locore.S

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/amd64/locore.S
diff -u src/sys/arch/amd64/amd64/locore.S:1.155 src/sys/arch/amd64/amd64/locore.S:1.156
--- src/sys/arch/amd64/amd64/locore.S:1.155	Thu Feb 22 14:57:11 2018
+++ src/sys/arch/amd64/amd64/locore.S	Sat Feb 24 17:12:10 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.155 2018/02/22 14:57:11 maxv Exp $	*/
+/*	$NetBSD: locore.S,v 1.156 2018/02/24 17:12:10 maxv Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -1358,6 +1358,7 @@ END(lwp_trampoline)
  * Entry points of the 'syscall' instruction, 64bit and 32bit mode.
  */
 
+#define SP(x)	(x)-(TF_SS+8)(%rax)
 
 .macro	SYSCALL_ENTRY	name,is_svs
 IDTVEC(\name)
@@ -1376,40 +1377,32 @@ IDTVEC(\name)
 	 */
 	swapgs
 
-#define SP(x,reg)	(x)-(TF_SS+8)(reg)
-
+	/* Get the LWP's kernel stack pointer in %rax */
 	.if	\is_svs
 		movq	%rax,SVS_UTLS+UTLS_SCRATCH
 		movq	SVS_UTLS+UTLS_RSP0,%rax
+	.else
+		movq	%rax,CPUVAR(SCRATCH)
+		movq	CPUVAR(CURLWP),%rax
+		movq	L_PCB(%rax),%rax
+		movq	PCB_RSP0(%rax),%rax
+	.endif
 
-		/* Make stack look like an 'int nn' frame */
-		movq	$(LSEL(LUDATA_SEL, SEL_UPL)),SP(TF_SS,%rax)	/* user %ss */
-		movq	%rsp,SP(TF_RSP,%rax)/* user %rsp */
-		movq	%r11,SP(TF_RFLAGS,%rax)/* user %rflags */
-		movq	$(LSEL(LUCODE_SEL, SEL_UPL)),SP(TF_CS,%rax)	/* user %cs */
-		movq	%rcx,SP(TF_RIP,%rax)/* user %rip */
-		leaq	SP(0,%rax),%rsp			/* %rsp now valid after frame */
+	/* Make stack look like an 'int nn' frame */
+	movq	$(LSEL(LUDATA_SEL, SEL_UPL)),SP(TF_SS)	/* user %ss */
+	movq	%rsp,SP(TF_RSP)/* user %rsp */
+	movq	%r11,SP(TF_RFLAGS)			/* user %rflags */
+	movq	$(LSEL(LUCODE_SEL, SEL_UPL)),SP(TF_CS)	/* user %cs */
+	movq	%rcx,SP(TF_RIP)/* user %rip */
+	leaq	SP(0),%rsp		/* %rsp now valid after frame */
 
+	/* Restore %rax */
+	.if	\is_svs
 		movq	SVS_UTLS+UTLS_SCRATCH,%rax
 	.else
-		movq	%r15,CPUVAR(SCRATCH)
-		movq	CPUVAR(CURLWP),%r15
-		movq	L_PCB(%r15),%r15
-		movq	PCB_RSP0(%r15),%r15	/* LWP's kernel stack pointer */
-
-		/* Make stack look like an 'int nn' frame */
-		movq	$(LSEL(LUDATA_SEL, SEL_UPL)),SP(TF_SS,%r15)	/* user %ss */
-		movq	%rsp,SP(TF_RSP,%r15)/* user %rsp */
-		movq	%r11,SP(TF_RFLAGS,%r15)/* user %rflags */
-		movq	$(LSEL(LUCODE_SEL, SEL_UPL)),SP(TF_CS,%r15)	/* user %cs */
-		movq	%rcx,SP(TF_RIP,%r15)/* user %rip */
-		leaq	SP(0,%r15),%rsp			/* %rsp now valid after frame */
-
-		movq	CPUVAR(SCRATCH),%r15
+		movq	CPUVAR(SCRATCH),%rax
 	.endif
 
-#undef SP
-
 	movq	$2,TF_ERR(%rsp)		/* syscall instruction size */
 	movq	$T_ASTFLT,TF_TRAPNO(%rsp)
 #else



CVS commit: src/sys/dev/pci

2018-02-24 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Feb 24 14:05:46 UTC 2018

Modified Files:
src/sys/dev/pci: pcidevs

Log Message:
Add AMD KERNCZ chipset for Zen processors.


To generate a diff of this commit:
cvs rdiff -u -r1.1315 -r1.1316 src/sys/dev/pci/pcidevs

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/pci/pcidevs
diff -u src/sys/dev/pci/pcidevs:1.1315 src/sys/dev/pci/pcidevs:1.1316
--- src/sys/dev/pci/pcidevs:1.1315	Thu Feb 22 07:52:46 2018
+++ src/sys/dev/pci/pcidevs	Sat Feb 24 14:05:46 2018
@@ -1,4 +1,4 @@
-$NetBSD: pcidevs,v 1.1315 2018/02/22 07:52:46 msaitoh Exp $
+$NetBSD: pcidevs,v 1.1316 2018/02/24 14:05:46 mlelstv Exp $
 
 /*
  * Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -1115,6 +1115,7 @@ product AMD HUDSON_PCI		0x780f	Hudson PC
 product AMD HUDSON_XHCI		0x7812	Hudson USB xHCI Controller
 product AMD FCH_SDHC		0x7813	FCH SD Flash Controller
 product AMD FCH_XHCI		0x7814	FCH USB xHCI Controller
+product AMD KERNCZ_SMB		0x790b	X370/X399 SMBus Controller
 product AMD RS780_HB		0x9600	RS780 Host Bridge
 product AMD RS880_HB		0x9601	RS785/RS880 Host Bridge
 product AMD RS780_PPB_GFX	0x9602	RS780/RS880 PCI-PCI Bridge (int gfx)



CVS commit: src/sys/arch/x86/x86

2018-02-24 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Feb 24 10:31:30 UTC 2018

Modified Files:
src/sys/arch/x86/x86: svs.c

Log Message:
Document SVS. Also, remove an entry from the todo list.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/x86/x86/svs.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/x86/x86/svs.c
diff -u src/sys/arch/x86/x86/svs.c:1.9 src/sys/arch/x86/x86/svs.c:1.10
--- src/sys/arch/x86/x86/svs.c:1.9	Fri Feb 23 19:39:27 2018
+++ src/sys/arch/x86/x86/svs.c	Sat Feb 24 10:31:30 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: svs.c,v 1.9 2018/02/23 19:39:27 maxv Exp $	*/
+/*	$NetBSD: svs.c,v 1.10 2018/02/24 10:31:30 maxv Exp $	*/
 
 /*
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: svs.c,v 1.9 2018/02/23 19:39:27 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: svs.c,v 1.10 2018/02/24 10:31:30 maxv Exp $");
 
 #include "opt_svs.h"
 
@@ -52,48 +52,179 @@ __KERNEL_RCSID(0, "$NetBSD: svs.c,v 1.9 
  * Separate Virtual Space
  *
  * A per-cpu L4 page is maintained in ci_svs_updirpa. During each context
- * switch to a user pmap, updirpa is populated with the entries of the new
- * pmap, minus what we don't want to have mapped in userland.
+ * switch to a user pmap, the lower half of updirpa is populated with the
+ * entries containing the userland pages.
  *
- * Note on locking/synchronization here:
+ * ~~ The UTLS Page ~~
+ * 
+ * We use a special per-cpu page that we call UTLS, for User Thread Local
+ * Storage. Each CPU has one UTLS page. This page has two VAs:
+ *
+ *  o When the user page tables are loaded in CR3, the VA to access this
+ *page is >utls, defined as SVS_UTLS+UTLS_KPDIRPA in assembly.
+ *This VA is _constant_ across CPUs, but in the user page tables this
+ *VA points to the physical page of the UTLS that is _local_ to the CPU.
+ *
+ *  o When the kernel page tables are loaded in CR3, the VA to access this
+ *page is ci->ci_svs_utls.
+ *
+ * +--+
+ * | CPU0 Local Data  (Physical Page) |
+ * | +--+ +-+ |
+ * | | User Page Tables | SVS_UTLS+UTLS_KPDIRPA > | cpu0's UTLS | |
+ * | +--+ +-+ |
+ * +-^+
+ *   |
+ *   +--+
+ *  |
+ * +--+ |
+ * | CPU1 Local Data  (Physical Page) | |
+ * | +--+ +-+ | |
+ * | | User Page Tables | SVS_UTLS+UTLS_KPDIRPA > | cpu1's UTLS | | |
+ * | +--+ +-+ | |
+ * +-^+ |
+ *   |  |
+ *   +--+ /--+  |
+ *   | Kern Page Tables | ci->ci_svs_utls   |
+ *   +--+ \-+
+ *
+ * The goal of the UTLS page is to provide an area where we can store whatever
+ * we want, in a way that it is accessible both when the Kernel and when the
+ * User page tables are loaded in CR3.
+ *
+ * We store in the UTLS page three 64bit values:
+ *
+ *  o UTLS_KPDIRPA: the value we must put in CR3 in order to load the kernel
+ *page tables.
+ *
+ *  o UTLS_SCRATCH: a dummy place where we temporarily store a value during
+ *the syscall entry procedure.
+ *
+ *  o UTLS_RSP0: the value we must put in RSP in order to have a stack where
+ *we can push the register states. This is used only during the syscall
+ *entry procedure, because there the CPU does not automatically switch
+ *RSP (it does not use the TSS.rsp0 mechanism described below).
+ *
+ * ~~ The Stack Switching Mechanism Without SVS ~~
+ *
+ * The kernel stack is per-lwp (pcb_rsp0). When doing a context switch between
+ * two user LWPs, the kernel updates TSS.rsp0 (which is per-cpu) to point to
+ * the stack of the new LWP. Then the execution continues. At some point, the
+ * user LWP we context-switched to will perform a syscall or will receive an
+ * interrupt. There, the CPU will automatically read TSS.rsp0 and use it as a
+ * stack. The kernel then pushes the register states on this stack, and
+ * executes in