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

2018-03-28 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Thu Mar 29 04:43:55 UTC 2018

Modified Files:
src/distrib/sets/lists/xetc: md.x68k mi

Log Message:
remove lingering x11 (xfree86) entries.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/distrib/sets/lists/xetc/md.x68k
cvs rdiff -u -r1.29 -r1.30 src/distrib/sets/lists/xetc/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/xetc/md.x68k
diff -u src/distrib/sets/lists/xetc/md.x68k:1.4 src/distrib/sets/lists/xetc/md.x68k:1.5
--- src/distrib/sets/lists/xetc/md.x68k:1.4	Sat Mar  1 19:46:43 2014
+++ src/distrib/sets/lists/xetc/md.x68k	Thu Mar 29 04:43:55 2018
@@ -1,3 +1,2 @@
-# $NetBSD: md.x68k,v 1.4 2014/03/01 19:46:43 tsutsui Exp $
-./etc/X11/X68kConfig	-unknown-	x11
+# $NetBSD: md.x68k,v 1.5 2018/03/29 04:43:55 snj Exp $
 ./etc/X11/X68kConfig	-unknown-	xorg

Index: src/distrib/sets/lists/xetc/mi
diff -u src/distrib/sets/lists/xetc/mi:1.29 src/distrib/sets/lists/xetc/mi:1.30
--- src/distrib/sets/lists/xetc/mi:1.29	Tue Aug 29 15:50:57 2017
+++ src/distrib/sets/lists/xetc/mi	Thu Mar 29 04:43:55 2018
@@ -1,60 +1,28 @@
-# $NetBSD: mi,v 1.29 2017/08/29 15:50:57 maya Exp $
+# $NetBSD: mi,v 1.30 2018/03/29 04:43:55 snj Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
 ./etc/X11/ctwm/system.ctwmrc-unknown-	xorg
-./etc/X11/fs/config	-unknown-	x11
 ./etc/X11/fs/config	-unknown-	xorg
 ./etc/X11/lbxproxy/AtomControl-obsolete-	obsolete,xorg
-./etc/X11/lbxproxy/AtomControl-unknown-	x11
-./etc/X11/proxymngr/pmconfig-unknown-	x11
 ./etc/X11/proxymngr/pmconfig-unknown-	xorg
-./etc/X11/rstart/commands/@List-unknown-	x11
-./etc/X11/rstart/commands/ListContexts			-unknown-	x11
-./etc/X11/rstart/commands/ListGenericCommands		-unknown-	x11
-./etc/X11/rstart/commands/x-unknown-	x11
-./etc/X11/rstart/commands/x11-unknown-	x11
-./etc/X11/rstart/commands/x11r6/@List			-unknown-	x11
-./etc/X11/rstart/commands/x11r6/LoadMonitor		-unknown-	x11
-./etc/X11/rstart/commands/x11r6/Terminal		-unknown-	x11
-./etc/X11/rstart/config	-unknown-	x11
-./etc/X11/rstart/contexts/@List-unknown-	x11
-./etc/X11/rstart/contexts/default			-unknown-	x11
-./etc/X11/rstart/contexts/x-unknown-	x11
-./etc/X11/rstart/contexts/x11-unknown-	x11
-./etc/X11/rstart/contexts/x11r6-unknown-	x11
-./etc/X11/twm/system.twmrc-unknown-	x11
 ./etc/X11/twm/system.twmrc-unknown-	xorg
-./etc/X11/xdm/GiveConsole-unknown-	x11
 ./etc/X11/xdm/GiveConsole-unknown-	xorg
-./etc/X11/xdm/TakeConsole-unknown-	x11
 ./etc/X11/xdm/TakeConsole-unknown-	xorg
-./etc/X11/xdm/Xaccess	-unknown-	x11
 ./etc/X11/xdm/Xaccess	-unknown-	xorg
 ./etc/X11/xdm/Xreset	-unknown-	xorg
-./etc/X11/xdm/Xresources-unknown-	x11
 ./etc/X11/xdm/Xresources-unknown-	xorg
-./etc/X11/xdm/Xservers	-unknown-	x11
 ./etc/X11/xdm/Xservers	-unknown-	xorg
-./etc/X11/xdm/Xservers.fs-unknown-	x11
 ./etc/X11/xdm/Xservers.fs-unknown-	xorg
-./etc/X11/xdm/Xservers.ws-unknown-	x11
 ./etc/X11/xdm/Xservers.ws-unknown-	xorg
-./etc/X11/xdm/Xsession	-unknown-	x11
 ./etc/X11/xdm/Xsession	-unknown-	xorg
-./etc/X11/xdm/Xsetup_0	-unknown-	x11
 ./etc/X11/xdm/Xsetup_0	-unknown-	xorg
 ./etc/X11/xdm/Xstartup	-unknown-	xorg
-./etc/X11/xdm/Xwilling	-unknown-	x11
 ./etc/X11/xdm/Xwilling	-unknown-	xorg
-./etc/X11/xdm/xdm-config-unknown-	x11
 ./etc/X11/xdm/xdm-config-unknown-	xorg
 ./etc/X11/xdm/xorg-bw.xpmxetc-obsolete	obsolete
 ./etc/X11/xdm/xorg.xpm	xetc-obsolete	obsolete
-./etc/X11/xinit/xinitrc	-unknown-	x11
 ./etc/X11/xinit/xinitrc	-unknown-	xorg
-./etc/X11/xserver/SecurityPolicy			-unknown-	x11
-./etc/X11/xsm/system.xsm-unknown-	x11
 ./etc/X11/xsm/system.xsm-unknown-	xorg
 ./etc/drirc		-unknown-	xorg
 ./etc/fonts/conf.avail/10-autohint.conf			-unknown-	xorg
@@ -109,16 +77,10 @@
 ./etc/fonts/conf.d/70-no-bitmaps.conf			-unknown-	xorg
 ./etc/fonts/conf.d/80-delicious.conf			-unknown-	xorg
 ./etc/fonts/conf.d/90-synthetic.conf			-unknown-	xorg
-./etc/fonts/fonts.conf	-unknown-	x11
 ./etc/fonts/fonts.conf	-unknown-	xorg
-./etc/fonts/fonts.dtd	-unknown-	x11
 ./etc/fonts/fonts.dtd	-unknown-	xorg
-./etc/mtree/set.xetc	xetc-sys-root	x11
 ./etc/mtree/set.xetc	xetc-sys-root	xorg
-./etc/rc.d/fccache	etc-x11-rc	x11
 ./etc/rc.d/fccache	etc-x11-rc	xorg
-./etc/rc.d/xdm		etc-x11-rc	x11
 ./etc/rc.d/xdm		etc-x11-rc	xorg
-./etc/rc.d/xfs		etc-x11-rc	x11
 ./etc/rc.d/xfs		etc-x11-rc	xorg
 ./var/db/obsolete/xetc	xbase-sys-root	xorg



CVS commit: xsrc/external/mit/rstart/dist

2018-03-28 Thread Soren Jacobsen
Module Name:xsrc
Committed By:   snj
Date:   Thu Mar 29 04:25:43 UTC 2018

Removed Files:
xsrc/external/mit/rstart/dist: COPYING ChangeLog INSTALL Makefile.am
Makefile.in README aclocal.m4 auth.c config.guess config.h.in
config.sub configure configure.ac depcomp install-sh missing
server.c server.h server.os2
xsrc/external/mit/rstart/dist/commands: @List ListContexts
ListGenericCommands Makefile.am Makefile.in
xsrc/external/mit/rstart/dist/commands/x11r6: @List LoadMonitor
Terminal
xsrc/external/mit/rstart/dist/contexts: @Aliases @List Makefile.am
Makefile.in default x11r6.in
xsrc/external/mit/rstart/dist/man: Makefile.am Makefile.in rstart.man
rstartd.man
xsrc/external/mit/rstart/dist/samples: Makefile.am Makefile.in
xsrc/external/mit/rstart/dist/samples/commands: @List ListContexts
ListGenericCommands
xsrc/external/mit/rstart/dist/samples/commands/odt1: @List LoadMonitor
Terminal
xsrc/external/mit/rstart/dist/samples/commands/openwindows2: @List
LoadMonitor Terminal
xsrc/external/mit/rstart/dist/samples/commands/openwindows3: @List
LoadMonitor Terminal
xsrc/external/mit/rstart/dist/samples/commands/x11r5: @List LoadMonitor
Terminal
xsrc/external/mit/rstart/dist/samples/contexts.odt1: @Aliases @List
default odt1 openwindows2 openwindows3 x11r5 x11r6
xsrc/external/mit/rstart/dist/scripts: Makefile.am Makefile.in
config.in rstart.in rstartd.in
xsrc/external/mit/rstart/dist/specs: Makefile.am Makefile.in fix.awk
fix.nawk fix.sed rstart.ms rstartd.txt tmac.rfc

Log Message:
remove rstart, which hasn't been used since the xfree86 days.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r0 xsrc/external/mit/rstart/dist/COPYING \
xsrc/external/mit/rstart/dist/ChangeLog \
xsrc/external/mit/rstart/dist/INSTALL \
xsrc/external/mit/rstart/dist/Makefile.am \
xsrc/external/mit/rstart/dist/Makefile.in \
xsrc/external/mit/rstart/dist/README \
xsrc/external/mit/rstart/dist/aclocal.m4 \
xsrc/external/mit/rstart/dist/auth.c \
xsrc/external/mit/rstart/dist/config.guess \
xsrc/external/mit/rstart/dist/config.h.in \
xsrc/external/mit/rstart/dist/config.sub \
xsrc/external/mit/rstart/dist/configure \
xsrc/external/mit/rstart/dist/configure.ac \
xsrc/external/mit/rstart/dist/depcomp \
xsrc/external/mit/rstart/dist/install-sh \
xsrc/external/mit/rstart/dist/missing \
xsrc/external/mit/rstart/dist/server.c \
xsrc/external/mit/rstart/dist/server.h \
xsrc/external/mit/rstart/dist/server.os2
cvs rdiff -u -r1.1.1.1 -r0 xsrc/external/mit/rstart/dist/commands/@List \
xsrc/external/mit/rstart/dist/commands/ListContexts \
xsrc/external/mit/rstart/dist/commands/ListGenericCommands \
xsrc/external/mit/rstart/dist/commands/Makefile.am \
xsrc/external/mit/rstart/dist/commands/Makefile.in
cvs rdiff -u -r1.1.1.1 -r0 xsrc/external/mit/rstart/dist/commands/x11r6/@List \
xsrc/external/mit/rstart/dist/commands/x11r6/LoadMonitor \
xsrc/external/mit/rstart/dist/commands/x11r6/Terminal
cvs rdiff -u -r1.1.1.1 -r0 xsrc/external/mit/rstart/dist/contexts/@Aliases \
xsrc/external/mit/rstart/dist/contexts/@List \
xsrc/external/mit/rstart/dist/contexts/Makefile.am \
xsrc/external/mit/rstart/dist/contexts/Makefile.in \
xsrc/external/mit/rstart/dist/contexts/default \
xsrc/external/mit/rstart/dist/contexts/x11r6.in
cvs rdiff -u -r1.1.1.1 -r0 xsrc/external/mit/rstart/dist/man/Makefile.am \
xsrc/external/mit/rstart/dist/man/Makefile.in \
xsrc/external/mit/rstart/dist/man/rstart.man \
xsrc/external/mit/rstart/dist/man/rstartd.man
cvs rdiff -u -r1.1.1.1 -r0 xsrc/external/mit/rstart/dist/samples/Makefile.am \
xsrc/external/mit/rstart/dist/samples/Makefile.in
cvs rdiff -u -r1.1.1.1 -r0 \
xsrc/external/mit/rstart/dist/samples/commands/@List \
xsrc/external/mit/rstart/dist/samples/commands/ListContexts \
xsrc/external/mit/rstart/dist/samples/commands/ListGenericCommands
cvs rdiff -u -r1.1.1.1 -r0 \
xsrc/external/mit/rstart/dist/samples/commands/odt1/@List \
xsrc/external/mit/rstart/dist/samples/commands/odt1/LoadMonitor \
xsrc/external/mit/rstart/dist/samples/commands/odt1/Terminal
cvs rdiff -u -r1.1.1.1 -r0 \
xsrc/external/mit/rstart/dist/samples/commands/openwindows2/@List \
xsrc/external/mit/rstart/dist/samples/commands/openwindows2/LoadMonitor \
xsrc/external/mit/rstart/dist/samples/commands/openwindows2/Terminal
cvs rdiff -u -r1.1.1.1 -r0 \
xsrc/external/mit/rstart/dist/samples/commands/openwindows3/@List \
xsrc/external/mit/rstart/dist/samples/commands/openwindows3/LoadMonitor \
xsrc/external/mit/rstart/dist/samples/commands/openwindows3/Terminal
cvs rdiff -u -r1.1.1.1 -r0 \
 

CVS commit: src

2018-03-28 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Thu Mar 29 04:19:55 UTC 2018

Modified Files:
src/distrib/sets/lists/base: mi
src/etc/mtree: NetBSD.dist.base
Removed Files:
src/external/mit/xorg/bin/rstart: Makefile Makefile.rstart
src/external/mit/xorg/bin/rstart/commands: Makefile
src/external/mit/xorg/bin/rstart/commands/x11r6: Makefile
src/external/mit/xorg/bin/rstart/contexts: Makefile

Log Message:
remove rstart, which hasn't been used since the xfree86 days.


To generate a diff of this commit:
cvs rdiff -u -r1.1172 -r1.1173 src/distrib/sets/lists/base/mi
cvs rdiff -u -r1.169 -r1.170 src/etc/mtree/NetBSD.dist.base
cvs rdiff -u -r1.1 -r0 src/external/mit/xorg/bin/rstart/Makefile \
src/external/mit/xorg/bin/rstart/Makefile.rstart
cvs rdiff -u -r1.1 -r0 src/external/mit/xorg/bin/rstart/commands/Makefile
cvs rdiff -u -r1.1 -r0 \
src/external/mit/xorg/bin/rstart/commands/x11r6/Makefile
cvs rdiff -u -r1.1 -r0 src/external/mit/xorg/bin/rstart/contexts/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/base/mi
diff -u src/distrib/sets/lists/base/mi:1.1172 src/distrib/sets/lists/base/mi:1.1173
--- src/distrib/sets/lists/base/mi:1.1172	Sat Feb  3 21:27:45 2018
+++ src/distrib/sets/lists/base/mi	Thu Mar 29 04:19:54 2018
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1172 2018/02/03 21:27:45 mrg Exp $
+# $NetBSD: mi,v 1.1173 2018/03/29 04:19:54 snj Exp $
 #
 # Note:	Don't delete entries from here - mark them as "obsolete" instead,
 #	unless otherwise stated below.
@@ -81,10 +81,10 @@
 ./etc/X11/fs	base-x11-root
 ./etc/X11/lbxproxybase-x11-root
 ./etc/X11/proxymngrbase-x11-root
-./etc/X11/rstartbase-x11-root
-./etc/X11/rstart/commands			base-x11-root
-./etc/X11/rstart/commands/x11r6			base-x11-root
-./etc/X11/rstart/contexts			base-x11-root
+./etc/X11/rstartbase-x11-root		obsolete
+./etc/X11/rstart/commands			base-x11-root		obsolete
+./etc/X11/rstart/commands/x11r6			base-x11-root		obsolete
+./etc/X11/rstart/contexts			base-x11-root		obsolete
 ./etc/X11/twm	base-x11-root
 ./etc/X11/xdm	base-x11-root
 ./etc/X11/xinit	base-x11-root

Index: src/etc/mtree/NetBSD.dist.base
diff -u src/etc/mtree/NetBSD.dist.base:1.169 src/etc/mtree/NetBSD.dist.base:1.170
--- src/etc/mtree/NetBSD.dist.base:1.169	Sat Feb  3 21:27:45 2018
+++ src/etc/mtree/NetBSD.dist.base	Thu Mar 29 04:19:55 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: NetBSD.dist.base,v 1.169 2018/02/03 21:27:45 mrg Exp $
+#	$NetBSD: NetBSD.dist.base,v 1.170 2018/03/29 04:19:55 snj Exp $
 #	@(#)4.4BSD.dist	8.1 (Berkeley) 6/13/93
 
 # Do not customize this file as it may be overwritten on upgrades.
@@ -18,10 +18,6 @@
 ./etc/X11/fs
 ./etc/X11/lbxproxy
 ./etc/X11/proxymngr
-./etc/X11/rstart
-./etc/X11/rstart/commands
-./etc/X11/rstart/commands/x11r6
-./etc/X11/rstart/contexts
 ./etc/X11/twm
 ./etc/X11/ctwm
 ./etc/X11/xdm



CVS commit: src/distrib/amd64/uefi-installimage

2018-03-28 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Wed Mar 28 22:38:48 UTC 2018

Modified Files:
src/distrib/amd64/uefi-installimage: Makefile

Log Message:
Bump image to 1550MB to unbreak the LLVM build.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/distrib/amd64/uefi-installimage/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/amd64/uefi-installimage/Makefile
diff -u src/distrib/amd64/uefi-installimage/Makefile:1.4 src/distrib/amd64/uefi-installimage/Makefile:1.5
--- src/distrib/amd64/uefi-installimage/Makefile:1.4	Fri Jan  5 01:33:11 2018
+++ src/distrib/amd64/uefi-installimage/Makefile	Wed Mar 28 22:38:47 2018
@@ -1,11 +1,11 @@
-#	$NetBSD: Makefile,v 1.4 2018/01/05 01:33:11 pgoyette Exp $
+#	$NetBSD: Makefile,v 1.5 2018/03/28 22:38:47 joerg Exp $
 
 .include 
 
 INSTIMGBASE=	NetBSD-${DISTRIBVER}-amd64-uefi-install	# gives ${IMGBASE}.img
 
 BOOTDISK=	dk1			# unused (use GUID)
-INSTIMAGEMB?=	1500			# for all installation binaries
+INSTIMAGEMB?=	1550			# for all installation binaries
 
 PRIMARY_BOOT=		bootxx_ffsv1
 SECONDARY_BOOT=		boot



CVS commit: [pgoyette-compat] src/sys/arch/x86/x86

2018-03-28 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed Mar 28 22:10:16 UTC 2018

Modified Files:
src/sys/arch/x86/x86 [pgoyette-compat]: cpu_ucode.c

Log Message:
Track changes from HEAD


To generate a diff of this commit:
cvs rdiff -u -r1.5.16.5 -r1.5.16.6 src/sys/arch/x86/x86/cpu_ucode.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/cpu_ucode.c
diff -u src/sys/arch/x86/x86/cpu_ucode.c:1.5.16.5 src/sys/arch/x86/x86/cpu_ucode.c:1.5.16.6
--- src/sys/arch/x86/x86/cpu_ucode.c:1.5.16.5	Thu Mar 22 01:44:47 2018
+++ src/sys/arch/x86/x86/cpu_ucode.c	Wed Mar 28 22:10:15 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu_ucode.c,v 1.5.16.5 2018/03/22 01:44:47 pgoyette Exp $ */
+/* $NetBSD: cpu_ucode.c,v 1.5.16.6 2018/03/28 22:10:15 pgoyette Exp $ */
 /*
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu_ucode.c,v 1.5.16.5 2018/03/22 01:44:47 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu_ucode.c,v 1.5.16.6 2018/03/28 22:10:15 pgoyette Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_cpu_ucode.h"
@@ -69,9 +69,13 @@ cpu_ucode_get_version(struct cpu_ucode_v
 
 	switch (cpu_vendor) {
 	case CPUVENDOR_AMD:
-		error = cpu_ucode_amd_get_version(data, , l = sizeof(v.a));
+		l = sizeof(v.a);
+		error = cpu_ucode_amd_get_version(data, , l);
+		break;
 	case CPUVENDOR_INTEL:
-		error = cpu_ucode_intel_get_version(data, , l = sizeof(v.i));
+		l = sizeof(v.i);
+		error = cpu_ucode_intel_get_version(data, , l);
+		break;
 	default:
 		return EOPNOTSUPP;
 	}



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

2018-03-28 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed Mar 28 19:56:40 UTC 2018

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

Log Message:
The call to svs_lwp_switch can clobber %rdi/%rsi, so restore them before
calling speculation_barrier.


To generate a diff of this commit:
cvs rdiff -u -r1.160 -r1.161 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.160 src/sys/arch/amd64/amd64/locore.S:1.161
--- src/sys/arch/amd64/amd64/locore.S:1.160	Wed Mar 28 16:02:49 2018
+++ src/sys/arch/amd64/amd64/locore.S	Wed Mar 28 19:56:40 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.160 2018/03/28 16:02:49 maxv Exp $	*/
+/*	$NetBSD: locore.S,v 1.161 2018/03/28 19:56:40 maxv Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -1096,6 +1096,10 @@ ENTRY(cpu_switchto)
 	callq	_C_LABEL(svs_lwp_switch)
 .Lskip_svs:
 	popq	%rdx
+
+	/* Restore rdi/rsi for speculation_barrier */
+	movq	%r13,%rdi
+	movq	%r12,%rsi
 #endif
 
 	pushq	%rdx



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

2018-03-28 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed Mar 28 19:50:57 UTC 2018

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

Log Message:
oldlwp can be NULL, so ensure it isn't.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/x86/x86/spectre.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/spectre.c
diff -u src/sys/arch/x86/x86/spectre.c:1.2 src/sys/arch/x86/x86/spectre.c:1.3
--- src/sys/arch/x86/x86/spectre.c:1.2	Wed Mar 28 16:02:49 2018
+++ src/sys/arch/x86/x86/spectre.c	Wed Mar 28 19:50:57 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: spectre.c,v 1.2 2018/03/28 16:02:49 maxv Exp $	*/
+/*	$NetBSD: spectre.c,v 1.3 2018/03/28 19:50:57 maxv Exp $	*/
 
 /*
  * Copyright (c) 2018 NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: spectre.c,v 1.2 2018/03/28 16:02:49 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spectre.c,v 1.3 2018/03/28 19:50:57 maxv Exp $");
 
 #include 
 #include 
@@ -69,7 +69,7 @@ speculation_barrier(struct lwp *oldlwp, 
 	/*
 	 * From kernel thread to kernel thread, no need for a barrier.
 	 */
-	if ((oldlwp->l_flag & LW_SYSTEM) &&
+	if ((oldlwp != NULL && (oldlwp->l_flag & LW_SYSTEM)) &&
 	(newlwp->l_flag & LW_SYSTEM))
 		return;
 



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

2018-03-28 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed Mar 28 19:47:54 UTC 2018

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

Log Message:
Add 'break', otherwise we're not gonna go very far. While here use a less
error-prone syntax.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/x86/x86/cpu_ucode.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/cpu_ucode.c
diff -u src/sys/arch/x86/x86/cpu_ucode.c:1.8 src/sys/arch/x86/x86/cpu_ucode.c:1.9
--- src/sys/arch/x86/x86/cpu_ucode.c:1.8	Sun Mar 18 00:17:18 2018
+++ src/sys/arch/x86/x86/cpu_ucode.c	Wed Mar 28 19:47:54 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu_ucode.c,v 1.8 2018/03/18 00:17:18 christos Exp $ */
+/* $NetBSD: cpu_ucode.c,v 1.9 2018/03/28 19:47:54 maxv Exp $ */
 /*
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu_ucode.c,v 1.8 2018/03/18 00:17:18 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu_ucode.c,v 1.9 2018/03/28 19:47:54 maxv Exp $");
 
 #include "opt_cpu_ucode.h"
 #include "opt_xen.h"
@@ -67,9 +67,13 @@ cpu_ucode_get_version(struct cpu_ucode_v
 
 	switch (cpu_vendor) {
 	case CPUVENDOR_AMD:
-		error = cpu_ucode_amd_get_version(data, , l = sizeof(v.a));
+		l = sizeof(v.a);
+		error = cpu_ucode_amd_get_version(data, , l);
+		break;
 	case CPUVENDOR_INTEL:
-		error = cpu_ucode_intel_get_version(data, , l = sizeof(v.i));
+		l = sizeof(v.i);
+		error = cpu_ucode_intel_get_version(data, , l);
+		break;
 	default:
 		return EOPNOTSUPP;
 	}



CVS commit: src/tools/gcc

2018-03-28 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Mar 28 19:30:41 UTC 2018

Modified Files:
src/tools/gcc: gcc-version.mk

Log Message:
bump the NetBSD GCC version.  both GCC 5 and 6 got x86 spectre
mitigation code, and both are now "nb2 20180327".


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/tools/gcc/gcc-version.mk

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

Modified files:

Index: src/tools/gcc/gcc-version.mk
diff -u src/tools/gcc/gcc-version.mk:1.9 src/tools/gcc/gcc-version.mk:1.10
--- src/tools/gcc/gcc-version.mk:1.9	Mon Feb  5 06:22:27 2018
+++ src/tools/gcc/gcc-version.mk	Wed Mar 28 19:30:41 2018
@@ -1,9 +1,9 @@
-#	$NetBSD: gcc-version.mk,v 1.9 2018/02/05 06:22:27 mrg Exp $
+#	$NetBSD: gcc-version.mk,v 1.10 2018/03/28 19:30:41 mrg Exp $
 
 # common location for tools and native build
 
 .if ${HAVE_GCC} == 5
-NETBSD_GCC_VERSION=nb1 20171112
+NETBSD_GCC_VERSION=nb2 20180327
 .elif ${HAVE_GCC} == 6
-NETBSD_GCC_VERSION=nb1 20180203
+NETBSD_GCC_VERSION=nb2 20180327
 .endif



CVS commit: src/external/gpl3/gcc.old/dist/gcc

2018-03-28 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Mar 28 19:24:52 UTC 2018

Modified Files:
src/external/gpl3/gcc.old/dist/gcc/config/i386: constraints.md
i386-opts.h i386-protos.h i386.c i386.h i386.md i386.opt
predicates.md
src/external/gpl3/gcc.old/dist/gcc/doc: extend.texi invoke.texi

Log Message:
add the spectre mitigation options for x86:

  -mindirect-branch=
  -mfunction-return=
  -mindirect-branch-register

the values for 'choice' are "keep" (default, existing behaviour),
"thunk", "thunk-inline", and "thunk-extern".

as taken from the Ubuntu port of these changes in their
ubuntu:gcc-5_5.5.0-8ubuntu1.diff.  i've also included the doc
updates that are missing from ubuntu from gcc itself.

i've tested both i386 and amd64 fairly heavily with these options
enabled in both kernels and userland, atf runs and hundreds of
package builds.

XXX: pullup-8 to gcc/ not gcc.old/


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 \
src/external/gpl3/gcc.old/dist/gcc/config/i386/constraints.md \
src/external/gpl3/gcc.old/dist/gcc/config/i386/i386-protos.h \
src/external/gpl3/gcc.old/dist/gcc/config/i386/predicates.md
cvs rdiff -u -r1.3 -r1.4 \
src/external/gpl3/gcc.old/dist/gcc/config/i386/i386-opts.h
cvs rdiff -u -r1.9 -r1.10 \
src/external/gpl3/gcc.old/dist/gcc/config/i386/i386.c
cvs rdiff -u -r1.6 -r1.7 \
src/external/gpl3/gcc.old/dist/gcc/config/i386/i386.h \
src/external/gpl3/gcc.old/dist/gcc/config/i386/i386.md \
src/external/gpl3/gcc.old/dist/gcc/config/i386/i386.opt
cvs rdiff -u -r1.6 -r1.7 src/external/gpl3/gcc.old/dist/gcc/doc/extend.texi \
src/external/gpl3/gcc.old/dist/gcc/doc/invoke.texi

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.old/dist/gcc/config/i386/constraints.md
diff -u src/external/gpl3/gcc.old/dist/gcc/config/i386/constraints.md:1.5 src/external/gpl3/gcc.old/dist/gcc/config/i386/constraints.md:1.6
--- src/external/gpl3/gcc.old/dist/gcc/config/i386/constraints.md:1.5	Sun Jul 23 01:11:06 2017
+++ src/external/gpl3/gcc.old/dist/gcc/config/i386/constraints.md	Wed Mar 28 19:24:52 2018
@@ -157,12 +157,14 @@
 
 (define_constraint "Bs"
   "@internal Sibcall memory operand."
-  (and (not (match_test "TARGET_X32"))
+  (and (not (match_test "ix86_indirect_branch_register"))
+   (not (match_test "TARGET_X32"))
(match_operand 0 "sibcall_memory_operand")))
 
 (define_constraint "Bw"
   "@internal Call memory operand."
-  (and (not (match_test "TARGET_X32"))
+  (and (not (match_test "ix86_indirect_branch_register"))
+   (not (match_test "TARGET_X32"))
(match_operand 0 "memory_operand")))
 
 (define_constraint "Bz"
Index: src/external/gpl3/gcc.old/dist/gcc/config/i386/i386-protos.h
diff -u src/external/gpl3/gcc.old/dist/gcc/config/i386/i386-protos.h:1.5 src/external/gpl3/gcc.old/dist/gcc/config/i386/i386-protos.h:1.6
--- src/external/gpl3/gcc.old/dist/gcc/config/i386/i386-protos.h:1.5	Sun Jul 23 01:11:06 2017
+++ src/external/gpl3/gcc.old/dist/gcc/config/i386/i386-protos.h	Wed Mar 28 19:24:52 2018
@@ -306,6 +306,8 @@ extern enum attr_cpu ix86_schedule;
 #endif
 
 extern const char * ix86_output_call_insn (rtx_insn *insn, rtx call_op);
+extern const char * ix86_output_indirect_jmp (rtx call_op, bool ret_p);
+extern const char * ix86_output_function_return (bool long_p);
 
 #ifdef RTX_CODE
 /* Target data for multipass lookahead scheduling.
Index: src/external/gpl3/gcc.old/dist/gcc/config/i386/predicates.md
diff -u src/external/gpl3/gcc.old/dist/gcc/config/i386/predicates.md:1.5 src/external/gpl3/gcc.old/dist/gcc/config/i386/predicates.md:1.6
--- src/external/gpl3/gcc.old/dist/gcc/config/i386/predicates.md:1.5	Sun Jul 23 01:11:06 2017
+++ src/external/gpl3/gcc.old/dist/gcc/config/i386/predicates.md	Wed Mar 28 19:24:52 2018
@@ -607,7 +607,8 @@
 ;; Test for a valid operand for indirect branch.
 (define_predicate "indirect_branch_operand"
   (ior (match_operand 0 "register_operand")
-   (and (not (match_test "TARGET_X32"))
+   (and (not (match_test "ix86_indirect_branch_register"))
+	(not (match_test "TARGET_X32"))
 	(match_operand 0 "memory_operand"
 
 ;; Test for a valid operand for a call instruction.
@@ -616,7 +617,8 @@
   (ior (match_test "constant_call_address_operand
 		 (op, mode == VOIDmode ? mode : Pmode)")
(match_operand 0 "call_register_no_elim_operand")
-   (and (not (match_test "TARGET_X32"))
+   (and (not (match_test "ix86_indirect_branch_register"))
+	(not (match_test "TARGET_X32"))
 	(match_operand 0 "memory_operand"
 
 ;; Similarly, but for tail calls, in which we cannot allow memory references.
@@ -624,7 +626,8 @@
   (ior (match_test "constant_call_address_operand
 		 (op, mode == VOIDmode ? mode : Pmode)")
(match_operand 0 "register_no_elim_operand")
-   (and (not (match_test "TARGET_X32"))
+ 

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

2018-03-28 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Mar 28 19:22:32 UTC 2018

Modified Files:
src/external/gpl3/gcc/dist/gcc/config/i386: constraints.md i386-opts.h
i386-protos.h i386.c i386.h i386.md i386.opt predicates.md
src/external/gpl3/gcc/dist/gcc/doc: extend.texi invoke.texi

Log Message:
add the spectre mitigation options for x86:

  -mindirect-branch=
  -mfunction-return=
  -mindirect-branch-register

the values for 'choice' are "keep" (default, existing behaviour),
"thunk", "thunk-inline", and "thunk-extern".

as taken from the Debian port of these changes in their
debian:gcc-6_6.3.0-18+deb9u1.diff.  i've also included the doc
updates that are missing from debian from gcc itself.

i've tested both i386 and amd64 fairly heavily with these options
enabled in both kernels and userland, atf runs and hundreds of
package builds.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.6 -r1.2 \
src/external/gpl3/gcc/dist/gcc/config/i386/constraints.md
cvs rdiff -u -r1.1.1.3 -r1.2 \
src/external/gpl3/gcc/dist/gcc/config/i386/i386-opts.h
cvs rdiff -u -r1.1.1.5 -r1.2 \
src/external/gpl3/gcc/dist/gcc/config/i386/i386-protos.h \
src/external/gpl3/gcc/dist/gcc/config/i386/i386.opt \
src/external/gpl3/gcc/dist/gcc/config/i386/predicates.md
cvs rdiff -u -r1.16 -r1.17 src/external/gpl3/gcc/dist/gcc/config/i386/i386.c
cvs rdiff -u -r1.7 -r1.8 src/external/gpl3/gcc/dist/gcc/config/i386/i386.h
cvs rdiff -u -r1.1.1.10 -r1.2 \
src/external/gpl3/gcc/dist/gcc/config/i386/i386.md
cvs rdiff -u -r1.1.1.9 -r1.2 src/external/gpl3/gcc/dist/gcc/doc/extend.texi
cvs rdiff -u -r1.14 -r1.15 src/external/gpl3/gcc/dist/gcc/doc/invoke.texi

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/gcc/config/i386/constraints.md
diff -u src/external/gpl3/gcc/dist/gcc/config/i386/constraints.md:1.1.1.6 src/external/gpl3/gcc/dist/gcc/config/i386/constraints.md:1.2
--- src/external/gpl3/gcc/dist/gcc/config/i386/constraints.md:1.1.1.6	Fri Feb  2 01:59:53 2018
+++ src/external/gpl3/gcc/dist/gcc/config/i386/constraints.md	Wed Mar 28 19:22:32 2018
@@ -172,14 +172,16 @@
 
 (define_constraint "Bs"
   "@internal Sibcall memory operand."
-  (ior (and (not (match_test "TARGET_X32"))
+  (ior (and (not (match_test "ix86_indirect_branch_register"))
+	(not (match_test "TARGET_X32"))
 	(match_operand 0 "sibcall_memory_operand"))
(and (match_test "TARGET_X32 && Pmode == DImode")
 	(match_operand 0 "GOT_memory_operand"
 
 (define_constraint "Bw"
   "@internal Call memory operand."
-  (ior (and (not (match_test "TARGET_X32"))
+  (ior (and (not (match_test "ix86_indirect_branch_register"))
+	(not (match_test "TARGET_X32"))
 	(match_operand 0 "memory_operand"))
(and (match_test "TARGET_X32 && Pmode == DImode")
 	(match_operand 0 "GOT_memory_operand"

Index: src/external/gpl3/gcc/dist/gcc/config/i386/i386-opts.h
diff -u src/external/gpl3/gcc/dist/gcc/config/i386/i386-opts.h:1.1.1.3 src/external/gpl3/gcc/dist/gcc/config/i386/i386-opts.h:1.2
--- src/external/gpl3/gcc/dist/gcc/config/i386/i386-opts.h:1.1.1.3	Fri Feb  2 01:59:52 2018
+++ src/external/gpl3/gcc/dist/gcc/config/i386/i386-opts.h	Wed Mar 28 19:22:32 2018
@@ -99,4 +99,17 @@ enum stack_protector_guard {
   SSP_GLOBAL/* global canary */
 };
 
+/* This is used to mitigate variant #2 of the speculative execution
+   vulnerabilities on x86 processors identified by CVE-2017-5715, aka
+   Spectre.  They convert indirect branches and function returns to
+   call and return thunks to avoid speculative execution via indirect
+   call, jmp and ret.  */
+enum indirect_branch {
+  indirect_branch_unset = 0,
+  indirect_branch_keep,
+  indirect_branch_thunk,
+  indirect_branch_thunk_inline,
+  indirect_branch_thunk_extern
+};
+
 #endif

Index: src/external/gpl3/gcc/dist/gcc/config/i386/i386-protos.h
diff -u src/external/gpl3/gcc/dist/gcc/config/i386/i386-protos.h:1.1.1.5 src/external/gpl3/gcc/dist/gcc/config/i386/i386-protos.h:1.2
--- src/external/gpl3/gcc/dist/gcc/config/i386/i386-protos.h:1.1.1.5	Fri Feb  2 01:59:53 2018
+++ src/external/gpl3/gcc/dist/gcc/config/i386/i386-protos.h	Wed Mar 28 19:22:32 2018
@@ -311,6 +311,8 @@ extern enum attr_cpu ix86_schedule;
 #endif
 
 extern const char * ix86_output_call_insn (rtx_insn *insn, rtx call_op);
+extern const char * ix86_output_indirect_jmp (rtx call_op, bool ret_p);
+extern const char * ix86_output_function_return (bool long_p);
 extern bool ix86_operands_ok_for_move_multiple (rtx *operands, bool load,
 		enum machine_mode mode);
 
Index: src/external/gpl3/gcc/dist/gcc/config/i386/i386.opt
diff -u src/external/gpl3/gcc/dist/gcc/config/i386/i386.opt:1.1.1.5 src/external/gpl3/gcc/dist/gcc/config/i386/i386.opt:1.2
--- src/external/gpl3/gcc/dist/gcc/config/i386/i386.opt:1.1.1.5	Fri Feb  2 01:59:53 2018
+++ 

CVS commit: src/sys/arch/mips/mips

2018-03-28 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Wed Mar 28 17:56:52 UTC 2018

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

Log Message:
Leave TS and RE alone for the benefit of emips, which failed
to boot even earlier after locore.S:1.211.

Do this unconditionally to avoid introducing more ifdefs.
Also tested on ci20 and erlite.


To generate a diff of this commit:
cvs rdiff -u -r1.217 -r1.218 src/sys/arch/mips/mips/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/mips/mips/locore.S
diff -u src/sys/arch/mips/mips/locore.S:1.217 src/sys/arch/mips/mips/locore.S:1.218
--- src/sys/arch/mips/mips/locore.S:1.217	Wed Mar  7 20:48:00 2018
+++ src/sys/arch/mips/mips/locore.S	Wed Mar 28 17:56:52 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.217 2018/03/07 20:48:00 maya Exp $	*/
+/*	$NetBSD: locore.S,v 1.218 2018/03/28 17:56:52 maya Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -63,7 +63,7 @@
 #include 
 #include 
 
-RCSID("$NetBSD: locore.S,v 1.217 2018/03/07 20:48:00 maya Exp $")
+RCSID("$NetBSD: locore.S,v 1.218 2018/03/28 17:56:52 maya Exp $")
 
 #include "assym.h"
 
@@ -73,16 +73,18 @@ RCSID("$NetBSD: locore.S,v 1.217 2018/03
 	.globl	_C_LABEL(kernel_text)		# libkvm refers this
 start:
 _C_LABEL(kernel_text):
-	/* First disable the interrupts only, for safety */
 	mfc0	k0, MIPS_COP_0_STATUS
 	MFC0_HAZARD
+
+	/* First disable the interrupts only, for safety */
 	and	k0, ~MIPS_SR_INT_IE
 	mtc0	k0, MIPS_COP_0_STATUS
 	COP0_SYNC
 
-	/* Known state: BEV, coprocessors disabled */
-	mtc0	zero, MIPS_COP_0_STATUS
-	mtc0	zero, MIPS_COP_0_CAUSE
+	/* Known state: BEV, coprocessors disabled. */
+	/* Leaving TS | RE alone (for emips) */
+	and	k0, MIPS_SR_TS | MIPS3_SR_RE
+	mtc0	k0, MIPS_COP_0_STATUS
 	COP0_SYNC
 
 #ifdef _LP64



CVS commit: src/sys/arch

2018-03-28 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed Mar 28 16:02:49 UTC 2018

Modified Files:
src/sys/arch/amd64/amd64: amd64_trap.S locore.S
src/sys/arch/amd64/include: frameasm.h
src/sys/arch/x86/x86: spectre.c

Log Message:
Add the IBRS mitigation for SpectreV2 on amd64.

Different operations are performed during context transitions:

user->kernel: IBRS <- 1
kernel->user: IBRS <- 0

And during context switches:

user->user:   IBPB <- 0
kernel->user: IBPB <- 0
[user->kernel:IBPB <- 0 this one may not be needed]

We use two macros, IBRS_ENTER and IBRS_LEAVE, to set the IBRS bit. The
thing is hotpatched for better performance, like SVS.

The idea is that IBRS is a "privileged" bit, which is set to 1 in kernel
mode and 0 in user mode. To protect the branch predictor between user
processes (which are of the same privilege), we use the IBPB barrier.

The Intel manual also talks about (MWAIT/HLT)+HyperThreading, and says
that when using either of the two instructions IBRS must be disabled for
better performance on the core. I'm not totally sure about this part, so
I'm not adding it now.

IBRS is available only when the Intel microcode update is applied. The
mitigation must be enabled manually with machdep.spectreV2.mitigated.

Tested by msaitoh a week ago (but I adapted a few things since). Probably
more changes to come.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/sys/arch/amd64/amd64/amd64_trap.S
cvs rdiff -u -r1.159 -r1.160 src/sys/arch/amd64/amd64/locore.S
cvs rdiff -u -r1.37 -r1.38 src/sys/arch/amd64/include/frameasm.h
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/x86/x86/spectre.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/amd64/amd64/amd64_trap.S
diff -u src/sys/arch/amd64/amd64/amd64_trap.S:1.39 src/sys/arch/amd64/amd64/amd64_trap.S:1.40
--- src/sys/arch/amd64/amd64/amd64_trap.S:1.39	Tue Mar 20 18:27:58 2018
+++ src/sys/arch/amd64/amd64/amd64_trap.S	Wed Mar 28 16:02:49 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: amd64_trap.S,v 1.39 2018/03/20 18:27:58 maxv Exp $	*/
+/*	$NetBSD: amd64_trap.S,v 1.40 2018/03/28 16:02:49 maxv Exp $	*/
 
 /*
  * Copyright (c) 1998, 2007, 2008, 2017 The NetBSD Foundation, Inc.
@@ -134,6 +134,7 @@ IDTVEC(trap02)
 	ZTRAP_NJ(T_NMI)
 	subq	$TF_REGSIZE,%rsp
 	INTR_SAVE_GPRS
+	IBRS_ENTER
 	SVS_ENTER_ALTSTACK
 	cld
 	SMAP_ENABLE
@@ -162,6 +163,7 @@ IDTVEC(trap02)
 	SVS_LEAVE_ALTSTACK
 
 .Lnmileave:
+	IBRS_LEAVE
 	INTR_RESTORE_GPRS
 	addq	$TF_REGSIZE+16,%rsp
 	iretq
@@ -231,6 +233,7 @@ IDTVEC(trap08)
 	TRAP_NJ(T_DOUBLEFLT)
 	subq	$TF_REGSIZE,%rsp
 	INTR_SAVE_GPRS
+	IBRS_ENTER
 	SVS_ENTER_ALTSTACK
 	testb	$SEL_UPL,TF_CS(%rsp)
 	jz	1f
@@ -248,6 +251,7 @@ IDTVEC(trap08)
 	call	_C_LABEL(doubletrap)
 
 	SVS_LEAVE_ALTSTACK
+	IBRS_LEAVE
 	INTR_RESTORE_GPRS
 
 	testb	$SEL_UPL,TF_CS(%rsp)

Index: src/sys/arch/amd64/amd64/locore.S
diff -u src/sys/arch/amd64/amd64/locore.S:1.159 src/sys/arch/amd64/amd64/locore.S:1.160
--- src/sys/arch/amd64/amd64/locore.S:1.159	Tue Mar 20 18:27:58 2018
+++ src/sys/arch/amd64/amd64/locore.S	Wed Mar 28 16:02:49 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.159 2018/03/20 18:27:58 maxv Exp $	*/
+/*	$NetBSD: locore.S,v 1.160 2018/03/28 16:02:49 maxv Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -1098,6 +1098,10 @@ ENTRY(cpu_switchto)
 	popq	%rdx
 #endif
 
+	pushq	%rdx
+	callq	_C_LABEL(speculation_barrier)
+	popq	%rdx
+
 	/* Switch to newlwp's stack. */
 	movq	L_PCB(%r12),%r14
 	movq	PCB_RSP(%r14),%rsp
@@ -1413,6 +1417,7 @@ IDTVEC(\name)
 	cld
 #endif
 	INTR_SAVE_GPRS
+	IBRS_ENTER
 	movw	$GSEL(GUDATA_SEL, SEL_UPL),TF_DS(%rsp)
 	movw	$GSEL(GUDATA_SEL, SEL_UPL),TF_ES(%rsp)
 	movw	$0,TF_FS(%rsp)
@@ -1464,6 +1469,7 @@ IDTVEC_END(osyscall)
 	_ALIGN_TEXT
 LABEL(syscall_sysret)
 	SVS_LEAVE
+	IBRS_LEAVE
 	INTR_RESTORE_GPRS
 	SWAPGS
 #ifndef XEN
@@ -1554,6 +1560,7 @@ END(pagezero)
 LABEL(intrfastexit)
 	NOT_XEN(cli;)
 	SVS_LEAVE
+	IBRS_LEAVE
 	INTR_RESTORE_GPRS
 	addq	$(TF_REGSIZE+16),%rsp	/* iret frame */
 
@@ -1649,3 +1656,25 @@ LABEL(nosvs_leave_altstack)
 	NOSVS_LEAVE_ALTSTACK
 LABEL(nosvs_leave_altstack_end)
 #endif
+
+	.globl	ibrs_enter, ibrs_enter_end
+	.globl	ibrs_leave, ibrs_leave_end
+
+	/* IBRS <- 1 */
+LABEL(ibrs_enter)
+	movl	$MSR_IA32_SPEC_CTRL,%ecx
+	movl	$IA32_SPEC_CTRL_IBRS,%eax
+	movl	$(IA32_SPEC_CTRL_IBRS >> 32),%edx
+	wrmsr
+LABEL(ibrs_enter_end)
+
+	/* IBRS <- 0 */
+LABEL(ibrs_leave)
+	testb	$SEL_UPL,TF_CS(%rsp)
+	jz	1234f
+	movl	$MSR_IA32_SPEC_CTRL,%ecx
+	xorl	%eax,%eax
+	xorl	%edx,%edx
+	wrmsr
+1234:
+LABEL(ibrs_leave_end)

Index: src/sys/arch/amd64/include/frameasm.h
diff -u src/sys/arch/amd64/include/frameasm.h:1.37 src/sys/arch/amd64/include/frameasm.h:1.38
--- src/sys/arch/amd64/include/frameasm.h:1.37	Sun Feb 25 13:14:27 2018
+++ src/sys/arch/amd64/include/frameasm.h	Wed Mar 28 16:02:49 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: frameasm.h,v 1.37 2018/02/25 13:14:27 maxv Exp $	

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

2018-03-28 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Mar 28 15:34:29 UTC 2018

Modified Files:
src/sys/arch/macppc/dev: pmu.c

Log Message:
be less spammy on i2c errors


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/arch/macppc/dev/pmu.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/macppc/dev/pmu.c
diff -u src/sys/arch/macppc/dev/pmu.c:1.30 src/sys/arch/macppc/dev/pmu.c:1.31
--- src/sys/arch/macppc/dev/pmu.c:1.30	Fri Feb 16 18:07:05 2018
+++ src/sys/arch/macppc/dev/pmu.c	Wed Mar 28 15:34:29 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmu.c,v 1.30 2018/02/16 18:07:05 macallan Exp $ */
+/*	$NetBSD: pmu.c,v 1.31 2018/03/28 15:34:29 macallan Exp $ */
 
 /*-
  * Copyright (c) 2006 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmu.c,v 1.30 2018/02/16 18:07:05 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmu.c,v 1.31 2018/03/28 15:34:29 macallan Exp $");
 
 #include 
 #include 
@@ -990,7 +990,8 @@ pmu_i2c_exec(void *cookie, i2c_op_t op, 
 		DPRINTF("resp3(%d): %2x %2x %2x\n", len, resp[0], resp[1],
 			resp[2]);
 		if ((len - 2) != recv_len) {
-			aprint_error_dev(sc->sc_dev, "%s(%d) - got %d\n",
+			DPRINTF("%s: %s(%d) - got %d\n",
+			device_xname(sc->sc_dev),
 			__func__, recv_len, len - 2);
 			return -1;
 		}



CVS commit: src/sys/dev/sbus

2018-03-28 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Mar 28 15:33:44 UTC 2018

Modified Files:
src/sys/dev/sbus: mgx.c

Log Message:
set WSSCREEN_RESIZE


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/dev/sbus/mgx.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/dev/sbus/mgx.c
diff -u src/sys/dev/sbus/mgx.c:1.12 src/sys/dev/sbus/mgx.c:1.13
--- src/sys/dev/sbus/mgx.c:1.12	Fri Aug  4 23:54:46 2017
+++ src/sys/dev/sbus/mgx.c	Wed Mar 28 15:33:44 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: mgx.c,v 1.12 2017/08/04 23:54:46 macallan Exp $ */
+/*	$NetBSD: mgx.c,v 1.13 2018/03/28 15:33:44 macallan Exp $ */
 
 /*-
  * Copyright (c) 2014 Michael Lorenz
@@ -29,7 +29,7 @@
 /* a console driver for the SSB 4096V-MGX graphics card */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mgx.c,v 1.12 2017/08/04 23:54:46 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mgx.c,v 1.13 2018/03/28 15:33:44 macallan Exp $");
 
 #include 
 #include 
@@ -941,7 +941,8 @@ mgx_init_screen(void *cookie, struct vco
 
 	rasops_init(ri, 0, 0);
 
-	ri->ri_caps = WSSCREEN_REVERSE | WSSCREEN_WSCOLORS | WSSCREEN_UNDERLINE;
+	ri->ri_caps = WSSCREEN_REVERSE | WSSCREEN_WSCOLORS |
+		  WSSCREEN_UNDERLINE | WSSCREEN_RESIZE;
 
 	rasops_reconfig(ri, ri->ri_height / ri->ri_font->fontheight,
 		ri->ri_width / ri->ri_font->fontwidth);



CVS commit: src/sys/arch/x86

2018-03-28 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed Mar 28 14:56:59 UTC 2018

Modified Files:
src/sys/arch/x86/conf: files.x86
src/sys/arch/x86/x86: cpu.c
Added Files:
src/sys/arch/x86/x86: spectre.c

Log Message:
Move the SpectreV2 mitigation code into a dedicated spectre.c file. The
content of the file is taken from the end of cpu.c, and is copied as-is.


To generate a diff of this commit:
cvs rdiff -u -r1.98 -r1.99 src/sys/arch/x86/conf/files.x86
cvs rdiff -u -r1.152 -r1.153 src/sys/arch/x86/x86/cpu.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/x86/x86/spectre.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/conf/files.x86
diff -u src/sys/arch/x86/conf/files.x86:1.98 src/sys/arch/x86/conf/files.x86:1.99
--- src/sys/arch/x86/conf/files.x86:1.98	Sun Mar 18 00:17:17 2018
+++ src/sys/arch/x86/conf/files.x86	Wed Mar 28 14:56:59 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: files.x86,v 1.98 2018/03/18 00:17:17 christos Exp $
+#	$NetBSD: files.x86,v 1.99 2018/03/28 14:56:59 maxv Exp $
 
 # options for MP configuration through the MP spec
 defflag opt_mpbios.h MPBIOS MPVERBOSE MPDEBUG MPBIOS_SCANPCI
@@ -97,6 +97,7 @@ file 	arch/x86/x86/pmap.c		machdep
 file 	arch/x86/x86/x86_tlb.c		machdep
 file 	arch/x86/x86/pmc.c		machdep
 file	arch/x86/x86/procfs_machdep.c	procfs
+file	arch/x86/x86/spectre.c		machdep
 file 	arch/x86/x86/svs.c		machdep & svs
 file	arch/x86/x86/sys_machdep.c	machdep
 file	arch/x86/x86/syscall.c		machdep

Index: src/sys/arch/x86/x86/cpu.c
diff -u src/sys/arch/x86/x86/cpu.c:1.152 src/sys/arch/x86/x86/cpu.c:1.153
--- src/sys/arch/x86/x86/cpu.c:1.152	Thu Mar 15 09:17:31 2018
+++ src/sys/arch/x86/x86/cpu.c	Wed Mar 28 14:56:59 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.152 2018/03/15 09:17:31 maxv Exp $	*/
+/*	$NetBSD: cpu.c,v 1.153 2018/03/28 14:56:59 maxv Exp $	*/
 
 /*
  * Copyright (c) 2000-2012 NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.152 2018/03/15 09:17:31 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.153 2018/03/28 14:56:59 maxv Exp $");
 
 #include "opt_ddb.h"
 #include "opt_mpbios.h"		/* for MPDEBUG */
@@ -82,8 +82,6 @@ __KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.15
 #include 
 #include 
 #include 
-#include 
-#include 
 
 #include 
 
@@ -106,7 +104,6 @@ __KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.15
 #include 
 
 #include 
-#include 
 
 #if NLAPIC > 0
 #include 
@@ -1337,175 +1334,3 @@ cpu_kick(struct cpu_info *ci)
 {
 	x86_send_ipi(ci, 0);
 }
-
-/* - */
-
-/*
- * Speculation-related mitigations.
- */
-
-enum spec_mitigation {
-	MITIGATION_NONE,
-	MITIGATION_AMD_DIS_IND,
-	MITIGATION_INTEL_IBRS
-};
-
-bool spec_mitigation_enabled __read_mostly = false;
-static enum spec_mitigation mitigation_method = MITIGATION_NONE;
-
-static void
-speculation_detect_method(void)
-{
-	struct cpu_info *ci = curcpu();
-
-	if (cpu_vendor == CPUVENDOR_INTEL) {
-		/* TODO: detect MITIGATION_INTEL_IBRS */
-		mitigation_method = MITIGATION_NONE;
-	} else if (cpu_vendor == CPUVENDOR_AMD) {
-		/*
-		 * The AMD Family 10h manual documents the IC_CFG.DIS_IND bit.
-		 * This bit disables the Indirect Branch Predictor.
-		 *
-		 * Families 12h and 16h are believed to have this bit too, but
-		 * their manuals don't document it.
-		 */
-		switch (CPUID_TO_FAMILY(ci->ci_signature)) {
-		case 0x10:
-		case 0x12:
-		case 0x16:
-			mitigation_method = MITIGATION_AMD_DIS_IND;
-			break;
-		default:
-			mitigation_method = MITIGATION_NONE;
-			break;
-		}
-	} else {
-		mitigation_method = MITIGATION_NONE;
-	}
-}
-
-static void
-mitigation_disable_cpu(void *arg1, void *arg2)
-{
-	uint64_t msr;
-
-	switch (mitigation_method) {
-	case MITIGATION_NONE:
-		panic("impossible");
-		break;
-	case MITIGATION_AMD_DIS_IND:
-		msr = rdmsr(MSR_IC_CFG);
-		msr &= ~IC_CFG_DIS_IND;
-		wrmsr(MSR_IC_CFG, msr);
-		break;
-	case MITIGATION_INTEL_IBRS:
-		/* ibrs_disable() TODO */
-		break;
-	}
-}
-
-static void
-mitigation_enable_cpu(void *arg1, void *arg2)
-{
-	uint64_t msr;
-
-	switch (mitigation_method) {
-	case MITIGATION_NONE:
-		panic("impossible");
-		break;
-	case MITIGATION_AMD_DIS_IND:
-		msr = rdmsr(MSR_IC_CFG);
-		msr |= IC_CFG_DIS_IND;
-		wrmsr(MSR_IC_CFG, msr);
-		break;
-	case MITIGATION_INTEL_IBRS:
-		/* ibrs_enable() TODO */
-		break;
-	}
-}
-
-static int
-mitigation_disable(void)
-{
-	uint64_t xc;
-
-	speculation_detect_method();
-
-	switch (mitigation_method) {
-	case MITIGATION_NONE:
-		printf("[!] No mitigation available\n");
-		return EOPNOTSUPP;
-	case MITIGATION_AMD_DIS_IND:
-		printf("[+] Disabling SpectreV2 Mitigation...");
-		xc = xc_broadcast(0, mitigation_disable_cpu,
-		NULL, NULL);
-		xc_wait(xc);
-		printf(" done!\n");
-		spec_mitigation_enabled = false;
-		return 0;
-	case MITIGATION_INTEL_IBRS:
-		/* TODO */
-		return 0;
-	default:
-		panic("impossible");
-	}
-}
-

CVS commit: src/sys/netinet

2018-03-28 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed Mar 28 14:43:55 UTC 2018

Modified Files:
src/sys/netinet: tcp_input.c

Log Message:
Several changes in syn_cache_respond:

 * Replace idiotic diagnostic check by KASSERT. max_linkhdr+tlen<=MCLBYTES
   is a widespread assumption.

 * Improve initialization of 'tp'.

 * Put panics in dead branches.

 * Merge two switches.


To generate a diff of this commit:
cvs rdiff -u -r1.392 -r1.393 src/sys/netinet/tcp_input.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/netinet/tcp_input.c
diff -u src/sys/netinet/tcp_input.c:1.392 src/sys/netinet/tcp_input.c:1.393
--- src/sys/netinet/tcp_input.c:1.392	Wed Mar 28 14:30:42 2018
+++ src/sys/netinet/tcp_input.c	Wed Mar 28 14:43:55 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: tcp_input.c,v 1.392 2018/03/28 14:30:42 maxv Exp $	*/
+/*	$NetBSD: tcp_input.c,v 1.393 2018/03/28 14:43:55 maxv Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -148,7 +148,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.392 2018/03/28 14:30:42 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.393 2018/03/28 14:43:55 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -4370,7 +4370,7 @@ syn_cache_respond(struct syn_cache *sc)
 #ifdef INET6
 	struct ip6_hdr *ip6 = NULL;
 #endif
-	struct tcpcb *tp = NULL;
+	struct tcpcb *tp;
 	struct tcphdr *th;
 	struct mbuf *m;
 	u_int hlen;
@@ -4393,17 +4393,13 @@ syn_cache_respond(struct syn_cache *sc)
 		return EAFNOSUPPORT;
 	}
 
-	/* worst case scanario, since we don't know the option size yet  */
+	/* Worst case scanario, since we don't know the option size yet. */
 	tlen = hlen + sizeof(struct tcphdr) + MAX_TCPOPTLEN;
+	KASSERT(max_linkhdr + tlen <= MCLBYTES);
 
 	/*
 	 * Create the IP+TCP header from scratch.
 	 */
-#ifdef DIAGNOSTIC
-	if (max_linkhdr + tlen > MCLBYTES)
-		return ENOBUFS;
-#endif  
-
 	MGETHDR(m, M_DONTWAIT, MT_DATA);
 	if (m && (max_linkhdr + tlen) > MHLEN) {
 		MCLGET(m, M_DONTWAIT);
@@ -4416,12 +4412,12 @@ syn_cache_respond(struct syn_cache *sc)
 		return ENOBUFS;
 	MCLAIM(m, _tx_mowner);
 
+	tp = sc->sc_tp;
+
 	/* Fixup the mbuf. */
 	m->m_data += max_linkhdr;
-	if (sc->sc_tp)
-		tp = sc->sc_tp;
 	m_reset_rcvif(m);
-	memset(mtod(m, u_char *), 0, tlen);
+	memset(mtod(m, void *), 0, tlen);
 
 	switch (sc->sc_src.sa.sa_family) {
 	case AF_INET:
@@ -4448,7 +,7 @@ syn_cache_respond(struct syn_cache *sc)
 		break;
 #endif
 	default:
-		return ENOBUFS;
+		panic("%s: impossible (1)", __func__);
 	}
 
 	th->th_seq = htonl(sc->sc_iss);
@@ -4590,34 +4586,26 @@ syn_cache_respond(struct syn_cache *sc)
 	}
 
 
-	/* Compute the packet's checksum. */
-	switch (sc->sc_src.sa.sa_family) {
-	case AF_INET:
-		ip->ip_len = htons(tlen - hlen);
-		th->th_sum = 0;
-		th->th_sum = in4_cksum(m, IPPROTO_TCP, hlen, tlen - hlen);
-		break;
-#ifdef INET6
-	case AF_INET6:
-		ip6->ip6_plen = htons(tlen - hlen);
-		th->th_sum = 0;
-		th->th_sum = in6_cksum(m, IPPROTO_TCP, hlen, tlen - hlen);
-		break;
-#endif
-	}
-
 	/*
+	 * Compute the packet's checksum.
+	 *
 	 * Fill in some straggling IP bits.  Note the stack expects
 	 * ip_len to be in host order, for convenience.
 	 */
 	switch (sc->sc_src.sa.sa_family) {
 	case AF_INET:
+		ip->ip_len = htons(tlen - hlen);
+		th->th_sum = 0;
+		th->th_sum = in4_cksum(m, IPPROTO_TCP, hlen, tlen - hlen);
 		ip->ip_len = htons(tlen);
 		ip->ip_ttl = ip_defttl;
 		/* XXX tos? */
 		break;
 #ifdef INET6
 	case AF_INET6:
+		ip6->ip6_plen = htons(tlen - hlen);
+		th->th_sum = 0;
+		th->th_sum = in6_cksum(m, IPPROTO_TCP, hlen, tlen - hlen);
 		ip6->ip6_vfc &= ~IPV6_VERSION_MASK;
 		ip6->ip6_vfc |= IPV6_VERSION;
 		ip6->ip6_plen = htons(tlen - hlen);
@@ -4647,8 +4635,7 @@ syn_cache_respond(struct syn_cache *sc)
 		break;
 #endif
 	default:
-		error = EAFNOSUPPORT;
-		break;
+		panic("%s: impossible (2)", __func__);
 	}
 
 	return error;



CVS commit: src/sys/netinet

2018-03-28 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed Mar 28 14:30:42 UTC 2018

Modified Files:
src/sys/netinet: tcp_input.c

Log Message:
Remove unused variable.


To generate a diff of this commit:
cvs rdiff -u -r1.391 -r1.392 src/sys/netinet/tcp_input.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/netinet/tcp_input.c
diff -u src/sys/netinet/tcp_input.c:1.391 src/sys/netinet/tcp_input.c:1.392
--- src/sys/netinet/tcp_input.c:1.391	Wed Mar 28 14:22:16 2018
+++ src/sys/netinet/tcp_input.c	Wed Mar 28 14:30:42 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: tcp_input.c,v 1.391 2018/03/28 14:22:16 maxv Exp $	*/
+/*	$NetBSD: tcp_input.c,v 1.392 2018/03/28 14:30:42 maxv Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -148,7 +148,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.391 2018/03/28 14:22:16 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.392 2018/03/28 14:30:42 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -4167,13 +4167,10 @@ syn_cache_add(struct sockaddr *src, stru
 	struct syn_cache *sc;
 	struct syn_cache_head *scp;
 	struct mbuf *ipopts;
-	struct tcp_opt_info opti;
 	int s;
 
 	tp = sototcpcb(so);
 
-	memset(, 0, sizeof(opti));
-
 	/*
 	 * Initialize some local state.
 	 */



CVS commit: src/sys/netinet

2018-03-28 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed Mar 28 14:22:16 UTC 2018

Modified Files:
src/sys/netinet: tcp_input.c tcp_var.h

Log Message:
Remove two unused args from syn_cache_get().


To generate a diff of this commit:
cvs rdiff -u -r1.390 -r1.391 src/sys/netinet/tcp_input.c
cvs rdiff -u -r1.184 -r1.185 src/sys/netinet/tcp_var.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/netinet/tcp_input.c
diff -u src/sys/netinet/tcp_input.c:1.390 src/sys/netinet/tcp_input.c:1.391
--- src/sys/netinet/tcp_input.c:1.390	Wed Mar 28 14:16:59 2018
+++ src/sys/netinet/tcp_input.c	Wed Mar 28 14:22:16 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: tcp_input.c,v 1.390 2018/03/28 14:16:59 maxv Exp $	*/
+/*	$NetBSD: tcp_input.c,v 1.391 2018/03/28 14:22:16 maxv Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -148,7 +148,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.390 2018/03/28 14:16:59 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.391 2018/03/28 14:22:16 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1635,8 +1635,7 @@ nosave:;
  */
 goto badsyn;
 			} else if (tiflags & TH_ACK) {
-so = syn_cache_get(, ,
-th, toff, tlen, so, m);
+so = syn_cache_get(, , th, so, m);
 if (so == NULL) {
 	/*
 	 * We don't have a SYN for this ACK;
@@ -3788,8 +3787,7 @@ syn_cache_lookup(const struct sockaddr *
  */
 struct socket *
 syn_cache_get(struct sockaddr *src, struct sockaddr *dst,
-struct tcphdr *th, unsigned int hlen, unsigned int tlen,
-struct socket *so, struct mbuf *m)
+struct tcphdr *th, struct socket *so, struct mbuf *m)
 {
 	struct syn_cache *sc;
 	struct syn_cache_head *scp;

Index: src/sys/netinet/tcp_var.h
diff -u src/sys/netinet/tcp_var.h:1.184 src/sys/netinet/tcp_var.h:1.185
--- src/sys/netinet/tcp_var.h:1.184	Mon Feb 12 08:22:26 2018
+++ src/sys/netinet/tcp_var.h	Wed Mar 28 14:22:16 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: tcp_var.h,v 1.184 2018/02/12 08:22:26 maxv Exp $	*/
+/*	$NetBSD: tcp_var.h,v 1.185 2018/03/28 14:22:16 maxv Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -960,8 +960,7 @@ int	 syn_cache_add(struct sockaddr *, st
 void	 syn_cache_unreach(const struct sockaddr *, const struct sockaddr *,
 	   struct tcphdr *);
 struct socket *syn_cache_get(struct sockaddr *, struct sockaddr *,
-		struct tcphdr *, unsigned int, unsigned int,
-		struct socket *so, struct mbuf *);
+		struct tcphdr *, struct socket *so, struct mbuf *);
 void	 syn_cache_init(void);
 void	 syn_cache_insert(struct syn_cache *, struct tcpcb *);
 struct syn_cache *syn_cache_lookup(const struct sockaddr *, const struct sockaddr *,



CVS commit: src/sys/netinet

2018-03-28 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed Mar 28 14:16:59 UTC 2018

Modified Files:
src/sys/netinet: tcp_input.c

Log Message:
Dedup: introduce tcp_urp_drop() and use it.


To generate a diff of this commit:
cvs rdiff -u -r1.389 -r1.390 src/sys/netinet/tcp_input.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/netinet/tcp_input.c
diff -u src/sys/netinet/tcp_input.c:1.389 src/sys/netinet/tcp_input.c:1.390
--- src/sys/netinet/tcp_input.c:1.389	Wed Mar 28 13:50:14 2018
+++ src/sys/netinet/tcp_input.c	Wed Mar 28 14:16:59 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: tcp_input.c,v 1.389 2018/03/28 13:50:14 maxv Exp $	*/
+/*	$NetBSD: tcp_input.c,v 1.390 2018/03/28 14:16:59 maxv Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -148,7 +148,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.389 2018/03/28 13:50:14 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.390 2018/03/28 14:16:59 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -337,6 +337,17 @@ tcp_fields_to_net(struct tcphdr *th)
 	HTONS(th->th_urp);
 }
 
+static void
+tcp_urp_drop(struct tcphdr *th, int todrop, int *tiflags)
+{
+	if (th->th_urp > 1) {
+		th->th_urp -= todrop;
+	} else {
+		*tiflags &= ~TH_URG;
+		th->th_urp = 0;
+	}
+}
+
 #ifdef TCP_CSUM_COUNTERS
 #include 
 
@@ -1008,14 +1019,9 @@ static void tcp_vtw_input(struct tcphdr 
 	if (todrop > 0) {
 		if (tiflags & TH_SYN) {
 			tiflags &= ~TH_SYN;
-			++th->th_seq;
-			if (th->th_urp > 1)
---th->th_urp;
-			else {
-tiflags &= ~TH_URG;
-th->th_urp = 0;
-			}
-			--todrop;
+			th->th_seq++;
+			tcp_urp_drop(th, 1, );
+			todrop--;
 		}
 		if (todrop > tlen ||
 		(todrop == tlen && (tiflags & TH_FIN) == 0)) {
@@ -1057,13 +1063,7 @@ static void tcp_vtw_input(struct tcphdr 
 
 		th->th_seq += todrop;
 		tlen -= todrop;
-
-		if (th->th_urp > todrop)
-			th->th_urp -= todrop;
-		else {
-			tiflags &= ~TH_URG;
-			th->th_urp = 0;
-		}
+		tcp_urp_drop(th, todrop, );
 	}
 
 	/*
@@ -2264,12 +2264,7 @@ after_listen:
 		if (tiflags & TH_SYN) {
 			tiflags &= ~TH_SYN;
 			th->th_seq++;
-			if (th->th_urp > 1)
-th->th_urp--;
-			else {
-tiflags &= ~TH_URG;
-th->th_urp = 0;
-			}
+			tcp_urp_drop(th, 1, );
 			todrop--;
 		}
 		if (todrop > tlen ||
@@ -2310,12 +2305,7 @@ after_listen:
 		hdroptlen += todrop;	/* drop from head afterwards */
 		th->th_seq += todrop;
 		tlen -= todrop;
-		if (th->th_urp > todrop)
-			th->th_urp -= todrop;
-		else {
-			tiflags &= ~TH_URG;
-			th->th_urp = 0;
-		}
+		tcp_urp_drop(th, todrop, );
 	}
 
 	/*



CVS commit: src/sys/netinet

2018-03-28 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed Mar 28 13:50:14 UTC 2018

Modified Files:
src/sys/netinet: tcp_input.c

Log Message:
Minor changes: style, improve comments (and put them at the correct place),
use NULL for pointers, and add {}s to prevent confusion.


To generate a diff of this commit:
cvs rdiff -u -r1.388 -r1.389 src/sys/netinet/tcp_input.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/netinet/tcp_input.c
diff -u src/sys/netinet/tcp_input.c:1.388 src/sys/netinet/tcp_input.c:1.389
--- src/sys/netinet/tcp_input.c:1.388	Fri Mar 23 09:30:55 2018
+++ src/sys/netinet/tcp_input.c	Wed Mar 28 13:50:14 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: tcp_input.c,v 1.388 2018/03/23 09:30:55 maxv Exp $	*/
+/*	$NetBSD: tcp_input.c,v 1.389 2018/03/28 13:50:14 maxv Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -148,7 +148,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.388 2018/03/23 09:30:55 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.389 2018/03/28 13:50:14 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -458,10 +458,10 @@ tcp_reass(struct tcpcb *tp, const struct
 	TCP_REASS_LOCK_CHECK(tp);
 
 	/*
-	 * Call with th==0 after become established to
+	 * Call with th==NULL after become established to
 	 * force pre-ESTABLISHED data up to user socket.
 	 */
-	if (th == 0)
+	if (th == NULL)
 		goto present;
 
 	m_claimm(m, _reass_mowner);
@@ -847,8 +847,7 @@ tcp4_log_refused(const struct ip *ip, co
 	if (ip) {
 		in_print(src, sizeof(src), >ip_src);
 		in_print(dst, sizeof(dst), >ip_dst);
-	}
-	else {
+	} else {
 		strlcpy(src, "(unknown)", sizeof(src));
 		strlcpy(dst, "(unknown)", sizeof(dst));
 	}
@@ -868,8 +867,7 @@ tcp6_log_refused(const struct ip6_hdr *i
 	if (ip6) {
 		in6_print(src, sizeof(src), >ip6_src);
 		in6_print(dst, sizeof(dst), >ip6_dst);
-	}
-	else {
+	} else {
 		strlcpy(src, "(unknown v6)", sizeof(src));
 		strlcpy(dst, "(unknown v6)", sizeof(dst));
 	}
@@ -990,16 +988,19 @@ badcsum:
 	return -1;
 }
 
-/* When a packet arrives addressed to a vestigial tcpbp, we
+/*
+ * When a packet arrives addressed to a vestigial tcpbp, we
  * nevertheless have to respond to it per the spec.
+ *
+ * This code is duplicated from the one in tcp_input().
  */
 static void tcp_vtw_input(struct tcphdr *th, vestigial_inpcb_t *vp,
 struct mbuf *m, int tlen)
 {
-	int		tiflags;
-	int		todrop;
-	uint32_t	t_flags = 0;
-	uint64_t	*tcps;
+	int tiflags;
+	int todrop;
+	uint32_t t_flags = 0;
+	uint64_t *tcps;
 
 	tiflags = th->th_flags;
 	todrop  = vp->rcv_nxt - th->th_seq;
@@ -1026,6 +1027,7 @@ static void tcp_vtw_input(struct tcphdr 
 			if (tiflags & TH_RST)
 goto drop;
 			tiflags &= ~(TH_FIN|TH_RST);
+
 			/*
 			 * Send an ACK to resynchronize and drop any data.
 			 * But keep on processing for RST or ACK.
@@ -1036,8 +1038,8 @@ static void tcp_vtw_input(struct tcphdr 
 			tcps[TCP_STAT_RCVDUPPACK] += 1;
 			tcps[TCP_STAT_RCVDUPBYTE] += todrop;
 			TCP_STAT_PUTREF();
-		} else if ((tiflags & TH_RST)
-			   && th->th_seq != vp->rcv_nxt) {
+		} else if ((tiflags & TH_RST) &&
+		th->th_seq != vp->rcv_nxt) {
 			/*
 			 * Test for reset before adjusting the sequence
 			 * number for overlapping data.
@@ -1077,7 +1079,7 @@ static void tcp_vtw_input(struct tcphdr 
 	 * If segment ends after window, drop trailing data
 	 * (and PUSH and FIN); if nothing left, just ACK.
 	 */
-	todrop = (th->th_seq + tlen) - (vp->rcv_nxt+vp->rcv_wnd);
+	todrop = (th->th_seq + tlen) - (vp->rcv_nxt + vp->rcv_wnd);
 
 	if (todrop > 0) {
 		TCP_STATINC(TCP_STAT_RCVPACKAFTERWIN);
@@ -1089,19 +1091,22 @@ static void tcp_vtw_input(struct tcphdr 
 			 * th->th_seq >= vp->rcv_nxt + vp->rcv_wnd
 			 */
 			TCP_STATADD(TCP_STAT_RCVBYTEAFTERWIN, tlen);
+
 			/*
 			 * If a new connection request is received
 			 * while in TIME_WAIT, drop the old connection
 			 * and start over if the sequence numbers
 			 * are above the previous ones.
 			 */
-			if ((tiflags & TH_SYN)
-			&& SEQ_GT(th->th_seq, vp->rcv_nxt)) {
-/* We only support this in the !NOFDREF case, which
+			if ((tiflags & TH_SYN) &&
+			SEQ_GT(th->th_seq, vp->rcv_nxt)) {
+/*
+ * We only support this in the !NOFDREF case, which
  * is to say: not here.
  */
 goto dropwithreset;
 			}
+
 			/*
 			 * If window is closed can only take segments at
 			 * window edge, and have to drop data and PUSH from
@@ -1112,10 +1117,12 @@ static void tcp_vtw_input(struct tcphdr 
 			if (vp->rcv_wnd == 0 && th->th_seq == vp->rcv_nxt) {
 t_flags |= TF_ACKNOW;
 TCP_STATINC(TCP_STAT_RCVWINPROBE);
-			} else
+			} else {
 goto dropafterack;
-		} else
+			}
+		} else {
 			TCP_STATADD(TCP_STAT_RCVBYTEAFTERWIN, todrop);
+		}
 		m_adj(m, -todrop);
 		tlen -= todrop;
 		tiflags &= ~(TH_PUSH|TH_FIN);
@@ -1161,15 +1168,14 @@ dropafterack_ratelim:
 	 * We may want to 

CVS commit: [pgoyette-compat] src/sys

2018-03-28 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed Mar 28 07:51:09 UTC 2018

Modified Files:
src/sys/compat/common [pgoyette-compat]: Makefile.sysio compat_30_mod.c
compat_mod.h files.common
src/sys/dev [pgoyette-compat]: vnd.c
src/sys/kern [pgoyette-compat]: compat_stub.c
src/sys/modules/compat_30 [pgoyette-compat]: Makefile
src/sys/sys [pgoyette-compat]: compat_stub.h
Added Files:
src/sys/compat/common [pgoyette-compat]: vnd_30.c

Log Message:
Split vnd compat_30 code out of the main driver and into the compat_30
module


To generate a diff of this commit:
cvs rdiff -u -r1.7.18.17 -r1.7.18.18 src/sys/compat/common/Makefile.sysio
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 src/sys/compat/common/compat_30_mod.c
cvs rdiff -u -r1.1.42.10 -r1.1.42.11 src/sys/compat/common/compat_mod.h
cvs rdiff -u -r1.1.2.20 -r1.1.2.21 src/sys/compat/common/files.common
cvs rdiff -u -r0 -r1.1.2.1 src/sys/compat/common/vnd_30.c
cvs rdiff -u -r1.263 -r1.263.2.1 src/sys/dev/vnd.c
cvs rdiff -u -r1.1.2.9 -r1.1.2.10 src/sys/kern/compat_stub.c
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 src/sys/modules/compat_30/Makefile
cvs rdiff -u -r1.1.2.9 -r1.1.2.10 src/sys/sys/compat_stub.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/compat/common/Makefile.sysio
diff -u src/sys/compat/common/Makefile.sysio:1.7.18.17 src/sys/compat/common/Makefile.sysio:1.7.18.18
--- src/sys/compat/common/Makefile.sysio:1.7.18.17	Wed Mar 28 04:18:24 2018
+++ src/sys/compat/common/Makefile.sysio	Wed Mar 28 07:51:09 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.sysio,v 1.7.18.17 2018/03/28 04:18:24 pgoyette Exp $
+#	$NetBSD: Makefile.sysio,v 1.7.18.18 2018/03/28 07:51:09 pgoyette Exp $
 
 # Sources for syscall and ioctl compatibility across the versions.
 
@@ -28,7 +28,7 @@ SRCS+=	rtsock_14.c
 SRCS+=	vfs_syscalls_20.c
 
 # Compatibility code for NetBSD 3.0
-SRCS+=	kern_time_30.c vfs_syscalls_30.c uipc_syscalls_30.c bio_30.c
+SRCS+=	kern_time_30.c vfs_syscalls_30.c uipc_syscalls_30.c bio_30.c vnd_30.c
 
 # Compatibility code for NetBSD 4.0
 SRCS+=	vfs_syscalls_40.c uipc_syscalls_40.c

Index: src/sys/compat/common/compat_30_mod.c
diff -u src/sys/compat/common/compat_30_mod.c:1.1.2.1 src/sys/compat/common/compat_30_mod.c:1.1.2.2
--- src/sys/compat/common/compat_30_mod.c:1.1.2.1	Wed Mar 28 04:18:24 2018
+++ src/sys/compat/common/compat_30_mod.c	Wed Mar 28 07:51:09 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat_30_mod.c,v 1.1.2.1 2018/03/28 04:18:24 pgoyette Exp $	*/
+/*	$NetBSD: compat_30_mod.c,v 1.1.2.2 2018/03/28 07:51:09 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: compat_30_mod.c,v 1.1.2.1 2018/03/28 04:18:24 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: compat_30_mod.c,v 1.1.2.2 2018/03/28 07:51:09 pgoyette Exp $");
 
 #include 
 #include 
@@ -63,6 +63,7 @@ compat_30_init(void)
 		return error;
 	}
 	bio_30_init();
+	vnd_30_init();
 
 	return error;
 }
@@ -72,17 +73,20 @@ compat_30_fini(void)
 {
 	int error = 0;
 
+	vnd_30_fini();
 	bio_30_fini();
 
 	error = kern_time_30_fini();
 	if (error != 0) {
 		bio_30_init();
+		vnd_30_init();
 		return error;
 	}
 
 	error = vfs_syscalls_30_fini();
 	if (error != 0) {
 		bio_30_init();
+		vnd_30_init();
 		kern_time_30_init();
 		return error;
 	}

Index: src/sys/compat/common/compat_mod.h
diff -u src/sys/compat/common/compat_mod.h:1.1.42.10 src/sys/compat/common/compat_mod.h:1.1.42.11
--- src/sys/compat/common/compat_mod.h:1.1.42.10	Wed Mar 28 04:18:24 2018
+++ src/sys/compat/common/compat_mod.h	Wed Mar 28 07:51:09 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat_mod.h,v 1.1.42.10 2018/03/28 04:18:24 pgoyette Exp $	*/
+/*	$NetBSD: compat_mod.h,v 1.1.42.11 2018/03/28 07:51:09 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -99,6 +99,8 @@ int uipc_syscalls_30_init(void);
 int uipc_syscalls_30_fini(void);
 void bio_30_init(void);
 void bio_30_fini(void);
+void vnd_30_init(void);
+void vnd_30_fini(void);
 #endif
 
 #endif /* !_COMPAT_MOD_H_ */

Index: src/sys/compat/common/files.common
diff -u src/sys/compat/common/files.common:1.1.2.20 src/sys/compat/common/files.common:1.1.2.21
--- src/sys/compat/common/files.common:1.1.2.20	Wed Mar 28 04:18:24 2018
+++ src/sys/compat/common/files.common	Wed Mar 28 07:51:09 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: files.common,v 1.1.2.20 2018/03/28 04:18:24 pgoyette Exp $
+#	$NetBSD: files.common,v 1.1.2.21 2018/03/28 07:51:09 pgoyette Exp $
 
 #
 # Generic files, used by all compat options.
@@ -52,6 +52,7 @@ file	compat/common/kern_time_30.c		compa
 file	compat/common/vfs_syscalls_30.c		compat_30
 file	compat/common/uipc_syscalls_30.c	compat_30
 file	compat/common/bio_30.c			compat_30
+file	compat/common/vnd_30.c			compat_30
 
 # Compatibility code for NetBSD 4.0
 file	compat/common/compat_40_mod.c		compat_40

Index: src/sys/dev/vnd.c

CVS commit: src/usr.sbin/makefs/cd9660

2018-03-28 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Wed Mar 28 06:48:55 UTC 2018

Modified Files:
src/usr.sbin/makefs/cd9660: cd9660_eltorito.c

Log Message:
Correctly mark the last El Torito section header.

Pointed out by Benno Rice via DM.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/usr.sbin/makefs/cd9660/cd9660_eltorito.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/makefs/cd9660/cd9660_eltorito.c
diff -u src/usr.sbin/makefs/cd9660/cd9660_eltorito.c:1.22 src/usr.sbin/makefs/cd9660/cd9660_eltorito.c:1.23
--- src/usr.sbin/makefs/cd9660/cd9660_eltorito.c:1.22	Thu Nov  9 01:28:05 2017
+++ src/usr.sbin/makefs/cd9660/cd9660_eltorito.c	Wed Mar 28 06:48:55 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: cd9660_eltorito.c,v 1.22 2017/11/09 01:28:05 nonaka Exp $	*/
+/*	$NetBSD: cd9660_eltorito.c,v 1.23 2018/03/28 06:48:55 nonaka Exp $	*/
 
 /*
  * Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
@@ -40,7 +40,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: cd9660_eltorito.c,v 1.22 2017/11/09 01:28:05 nonaka Exp $");
+__RCSID("$NetBSD: cd9660_eltorito.c,v 1.23 2018/03/28 06:48:55 nonaka Exp $");
 #endif  /* !__lint */
 
 #ifdef DEBUG
@@ -497,6 +497,12 @@ cd9660_setup_boot(iso9660_disk *diskStru
 		LIST_INSERT_AFTER(head, temp, ll_struct);
 	}
 
+	/* Find the last Section Header entry and mark it as the last. */
+	head = NULL;
+	LIST_FOREACH(next, >boot_entries, ll_struct) {
+		if (next->entry_type == ET_ENTRY_SH)
+			head = next;
+	}
 	if (head != NULL)
 		head->entry_data.SH.header_indicator[0] = ET_SECTION_HEADER_LAST;