CVS commit: src/sys/dev/pci

2017-03-25 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Mar 25 23:58:35 UTC 2017

Modified Files:
src/sys/dev/pci: vioscsi.c

Log Message:
fix printf format.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/dev/pci/vioscsi.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/pci/vioscsi.c
diff -u src/sys/dev/pci/vioscsi.c:1.15 src/sys/dev/pci/vioscsi.c:1.16
--- src/sys/dev/pci/vioscsi.c:1.15	Sat Mar 25 14:15:31 2017
+++ src/sys/dev/pci/vioscsi.c	Sat Mar 25 19:58:35 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vioscsi.c,v 1.15 2017/03/25 18:15:31 jdolecek Exp $	*/
+/*	$NetBSD: vioscsi.c,v 1.16 2017/03/25 23:58:35 christos Exp $	*/
 /*	$OpenBSD: vioscsi.c,v 1.3 2015/03/14 03:38:49 jsg Exp $	*/
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vioscsi.c,v 1.15 2017/03/25 18:15:31 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vioscsi.c,v 1.16 2017/03/25 23:58:35 christos Exp $");
 
 #include 
 #include 
@@ -171,8 +171,8 @@ vioscsi_attach(device_t parent, device_t
 		goto err;
 
 	aprint_normal_dev(sc->sc_dev,
-	"cmd_per_lun %zu qsize %zu seg_max %zu max_target %zu"
-	" max_lun %zu\n",
+	"cmd_per_lun %u qsize %d seg_max %u max_target %hu"
+	" max_lun %u\n",
 	cmd_per_lun, qsize, seg_max, max_target, max_lun);
 
 	if (virtio_child_attach_finish(vsc) != 0)



CVS commit: src/sys/dev/pci

2017-03-25 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Mar 25 23:58:35 UTC 2017

Modified Files:
src/sys/dev/pci: vioscsi.c

Log Message:
fix printf format.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/dev/pci/vioscsi.c

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



CVS commit: src/distrib/notes/hp300

2017-03-25 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Mar 25 23:33:11 UTC 2017

Modified Files:
src/distrib/notes/hp300: hardware

Log Message:
Sync description of "supported hardware" with reality.

- internal video on 362 and 382 works (no palette support)
- framebuffer 425e works (console text only)
- serial console for 425e on bootloader works
- Tigershark PersonalVRX was ported from OpenBSD (untested)
- Apollo Domain keyboard and mouse work
- ARCOFI audio on 425e works
- internal SCSI floppy is recognized as usual removable disk by MI SCSI


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/distrib/notes/hp300/hardware

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

Modified files:

Index: src/distrib/notes/hp300/hardware
diff -u src/distrib/notes/hp300/hardware:1.19 src/distrib/notes/hp300/hardware:1.20
--- src/distrib/notes/hp300/hardware:1.19	Fri Dec 14 21:15:58 2007
+++ src/distrib/notes/hp300/hardware	Sat Mar 25 23:33:11 2017
@@ -1,4 +1,4 @@
-.\"	$NetBSD: hardware,v 1.19 2007/12/14 21:15:58 pavel Exp $
+.\"	$NetBSD: hardware,v 1.20 2017/03/25 23:33:11 tsutsui Exp $
 .
 .Nx*M
 \*V will run on most HP 9000/300- and 400-series machines.
@@ -35,7 +35,6 @@ CPUs
 .It
 362 (25 MHz 68030, up to 16 MB RAM, built-in SCSI)
 .br
-.Em "Framebuffer is unsupported, you must use a serial console"
 .It
 370 (33 MHz 68030, 64 KB L2 cache, up to 48 MB RAM)
 .br
@@ -47,7 +46,6 @@ CPUs
 .It
 382 (25 MHz 68040, up to 32 MB RAM, built-in SCSI)
 .br
-.Em "Framebuffer is unsupported, you must use a serial console"
 .It
 385 (33 MHz 68040, up to 128 MB RAM, built-in SCSI)
 .It
@@ -58,11 +56,14 @@ up to 128 MB RAM)
 .It
 425e (25 MHz 68040, built-in SCSI)
 .br
-.Em "The BootROM does not support serial console and"
+.Em "The BootROM does not support serial console."
+.Em "The"
 .Nx*M
-.Em "does not support the 425e framebuffer.  When the"
-.Nx
-.Em "kernel begins to boot it will default to using the serial port for console"
+.Em "bootloader and kernel will use the serial port for console if"
+.Ql SERVICE/NORMAL
+.Em "switch on the back panel is turned to"
+.Ql SERVICE
+.Em "potision."
 .It
 433s, 433t, 433dl (33 MHz 68040 with built-in SCSI, up to 128 MB RAM)
 .bullet)
@@ -173,6 +174,18 @@ Graphics Devices
 A1096A monochrome Hyperion (1280x1024, 1 bit)
 .It
 A1416A Kathmandu (a.k.a. Color VRX) (1280x1024 @ 60 hz, 8 bits, DIO-II)
+.It
+98705 Tigershark PersonalVRX DIO-II graphics device
+.br
+.Em "Untested"
+.It
+internal video on models 362/382 (A1474-69511 and A147x-69510)
+.br
+.Em "No X server support"
+.It
+425e built-in EVRX framebuffer
+.br
+.Em "No X server support"
 .bullet)
 .It
 HP-HIL devices
@@ -206,6 +219,11 @@ daughterboard)
 .It
 98625A and 98625B 'fast' HP-IB interface (DIO-I board or
 daughtercard for 98562)
+.It
+Apollo Domain keyboard and mouse on Series 400 workstations
+.It
+.Dq ARCOFI
+audio device on 425e
 .bullet)
 .bullet)
 .Pp
@@ -233,22 +251,13 @@ CPUs
 .It
 Graphics Devices
 .(bullet -compact
-SGC support (for 425e built-in EVRX framebuffer)
-.It
-SGC support (for some rare configurations of 4XXt and 4XXdl workstations)
+SGC support for some rare configurations of 4XXt and 4XXdl workstations
 .It
 98702 TurboVRX DIO-II graphics device
-.It
-98705 Tigershark PersonalVRX DIO-II graphics device
-.It
-internal video on models 362/382
 .bullet)
 .It
 Miscellaneous boards/interfaces
 .(bullet -compact
-domain keyboard and mouse, on Series 400 workstations.
-Needs wscons
-.It
 parallel port, on 345, 362, 375, 380, 382, 382, and Series 400 workstations
 .It
 EISA support, on Series 400 workstations
@@ -260,7 +269,5 @@ VME bus adapter, on Series 300 workstati
 98628A single port dcl (DIO-I board)
 .It
 98625C fast HP-IB option on models 345 and 375
-.It
-internal SCSI floppy drive on 362, 382, and 425e
 .bullet)
 .bullet)



CVS commit: src/distrib/notes/hp300

2017-03-25 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Mar 25 23:33:11 UTC 2017

Modified Files:
src/distrib/notes/hp300: hardware

Log Message:
Sync description of "supported hardware" with reality.

- internal video on 362 and 382 works (no palette support)
- framebuffer 425e works (console text only)
- serial console for 425e on bootloader works
- Tigershark PersonalVRX was ported from OpenBSD (untested)
- Apollo Domain keyboard and mouse work
- ARCOFI audio on 425e works
- internal SCSI floppy is recognized as usual removable disk by MI SCSI


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/distrib/notes/hp300/hardware

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



CVS commit: src/sys/modules

2017-03-25 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sat Mar 25 23:17:07 UTC 2017

Modified Files:
src/sys/modules: Makefile

Log Message:
add vioscsi to the list (disabled)


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

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

Modified files:

Index: src/sys/modules/Makefile
diff -u src/sys/modules/Makefile:1.189 src/sys/modules/Makefile:1.190
--- src/sys/modules/Makefile:1.189	Thu Feb 16 08:12:43 2017
+++ src/sys/modules/Makefile	Sat Mar 25 23:17:07 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.189 2017/02/16 08:12:43 knakahara Exp $
+#	$NetBSD: Makefile,v 1.190 2017/03/25 23:17:07 jdolecek Exp $
 
 .include 
 
@@ -405,6 +405,7 @@ SUBDIR+=	twa
 SUBDIR+=	twe
 SUBDIR+=	viomb
 SUBDIR+=	virtio
+SUBDIR+=	vioscsi
 .endif
 
 SUBDIR+=	examples	# build these regularly to avoid bit-rot



CVS commit: src/sys/modules

2017-03-25 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sat Mar 25 23:17:07 UTC 2017

Modified Files:
src/sys/modules: Makefile

Log Message:
add vioscsi to the list (disabled)


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

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



CVS commit: src/games/fortune/datfiles

2017-03-25 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sat Mar 25 22:33:16 UTC 2017

Modified Files:
src/games/fortune/datfiles: fortunes

Log Message:
add somethign


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/games/fortune/datfiles/fortunes

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

Modified files:

Index: src/games/fortune/datfiles/fortunes
diff -u src/games/fortune/datfiles/fortunes:1.61 src/games/fortune/datfiles/fortunes:1.62
--- src/games/fortune/datfiles/fortunes:1.61	Fri Oct 14 03:20:04 2016
+++ src/games/fortune/datfiles/fortunes	Sat Mar 25 22:33:16 2017
@@ -16198,3 +16198,5 @@ Somebody has mail.
 %
 'Agnosis' is when you don't know. 'Diagnosis' is when you don't know
 twice.
+%
+An assortment of ways to be assimilated is a "smorgasborg".



CVS commit: src/games/fortune/datfiles

2017-03-25 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sat Mar 25 22:33:16 UTC 2017

Modified Files:
src/games/fortune/datfiles: fortunes

Log Message:
add somethign


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/games/fortune/datfiles/fortunes

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



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

2017-03-25 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Mar 25 22:09:45 UTC 2017

Modified Files:
src/sys/arch/hp300/dev: ppi.c

Log Message:
Include  for hz.

Compile test only. (no HP-IB devices here)


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/sys/arch/hp300/dev/ppi.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/hp300/dev/ppi.c
diff -u src/sys/arch/hp300/dev/ppi.c:1.45 src/sys/arch/hp300/dev/ppi.c:1.46
--- src/sys/arch/hp300/dev/ppi.c:1.45	Fri Jul 25 08:10:33 2014
+++ src/sys/arch/hp300/dev/ppi.c	Sat Mar 25 22:09:45 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ppi.c,v 1.45 2014/07/25 08:10:33 dholland Exp $	*/
+/*	$NetBSD: ppi.c,v 1.46 2017/03/25 22:09:45 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -65,10 +65,11 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ppi.c,v 1.45 2014/07/25 08:10:33 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ppi.c,v 1.46 2017/03/25 22:09:45 tsutsui Exp $");
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -486,7 +487,6 @@ ppiioctl(dev_t dev, u_long cmd, void *da
 static int
 ppihztoms(int h)
 {
-	extern int hz;
 	int m = h;
 
 	if (m > 0)
@@ -497,7 +497,6 @@ ppihztoms(int h)
 static int
 ppimstohz(int m)
 {
-	extern int hz;
 	int h = m;
 
 	if (h > 0) {



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

2017-03-25 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Mar 25 22:09:45 UTC 2017

Modified Files:
src/sys/arch/hp300/dev: ppi.c

Log Message:
Include  for hz.

Compile test only. (no HP-IB devices here)


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/sys/arch/hp300/dev/ppi.c

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



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

2017-03-25 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Mar 25 22:08:27 UTC 2017

Modified Files:
src/sys/arch/hp300/dev: dnkbd.c

Log Message:
In RAWKBD mode, don't schedule autorepeat callout(9) after KEY_UP events.

Now Apollo Domain keyboard works propery on Xorg server on my 425t.
Changes are taken from sys/dev/hil/hilkbd.c.

Note as OpenBSD says in the following commit log:
 
http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/sys/arch/hp300/dev/Attic/dnkbd.c#rev1.18
>> Auto-repeat keys in WSKBD_RAW mode is not needed.
>> WSKBD_RAW mode used in X, but X independently implements auto-repeat keys.
these autorepeat code will be removed later, but I commit this fix first
for the record.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/hp300/dev/dnkbd.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/hp300/dev/dnkbd.c
diff -u src/sys/arch/hp300/dev/dnkbd.c:1.8 src/sys/arch/hp300/dev/dnkbd.c:1.9
--- src/sys/arch/hp300/dev/dnkbd.c:1.8	Sat Mar 25 01:48:31 2017
+++ src/sys/arch/hp300/dev/dnkbd.c	Sat Mar 25 22:08:27 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: dnkbd.c,v 1.8 2017/03/25 01:48:31 tsutsui Exp $	*/
+/*	$NetBSD: dnkbd.c,v 1.9 2017/03/25 22:08:27 tsutsui Exp $	*/
 /*	$OpenBSD: dnkbd.c,v 1.17 2009/07/23 21:05:56 blambert Exp $	*/
 
 /*
@@ -706,8 +706,9 @@ dnevent_kbd_internal(struct dnkbd_softc 
 #ifdef WSDISPLAY_COMPAT_RAWKBD
 	if (sc->sc_rawkbd) {
 		u_char cbuf[2];
-		int c, j = 0;
+		int c, j, npress;
 
+		npress = j = 0;
 		c = dnkbd_raw[key];
 		if (c != 0) {
 			/* fake extended scancode if necessary */
@@ -718,7 +719,9 @@ dnevent_kbd_internal(struct dnkbd_softc 
 cbuf[j] |= 0x80;
 			else {
 /* remember pressed key for autorepeat */
-memcpy(sc->sc_rep, cbuf, sizeof(sc->sc_rep));
+if (c & 0x80)
+	sc->sc_rep[npress++] = 0xe0;
+sc->sc_rep[npress++] = c & 0x7f;
 			}
 			j++;
 		}
@@ -728,9 +731,11 @@ dnevent_kbd_internal(struct dnkbd_softc 
 			wskbd_rawinput(sc->sc_wskbddev, cbuf, j);
 			splx(s);
 			callout_stop(>sc_rawrepeat_ch);
-			sc->sc_nrep = j;
-			callout_schedule(>sc_rawrepeat_ch,
-			mstohz(REP_DELAY1));
+			sc->sc_nrep = npress;
+			if (npress != 0) {
+callout_schedule(>sc_rawrepeat_ch,
+mstohz(REP_DELAY1));
+			}
 		}
 	} else
 #endif



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

2017-03-25 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Mar 25 22:08:27 UTC 2017

Modified Files:
src/sys/arch/hp300/dev: dnkbd.c

Log Message:
In RAWKBD mode, don't schedule autorepeat callout(9) after KEY_UP events.

Now Apollo Domain keyboard works propery on Xorg server on my 425t.
Changes are taken from sys/dev/hil/hilkbd.c.

Note as OpenBSD says in the following commit log:
 
http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/sys/arch/hp300/dev/Attic/dnkbd.c#rev1.18
>> Auto-repeat keys in WSKBD_RAW mode is not needed.
>> WSKBD_RAW mode used in X, but X independently implements auto-repeat keys.
these autorepeat code will be removed later, but I commit this fix first
for the record.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/hp300/dev/dnkbd.c

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



CVS commit: src/sys

2017-03-25 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sat Mar 25 18:15:31 UTC 2017

Modified Files:
src/sys/dev/pci: vioscsi.c
Added Files:
src/sys/modules/vioscsi: Makefile vioscsi.ioconf

Log Message:
add support for loading vioscsi driver dynamically


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/pci/vioscsi.c
cvs rdiff -u -r0 -r1.1 src/sys/modules/vioscsi/Makefile \
src/sys/modules/vioscsi/vioscsi.ioconf

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



CVS commit: src/sys

2017-03-25 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sat Mar 25 18:15:31 UTC 2017

Modified Files:
src/sys/dev/pci: vioscsi.c
Added Files:
src/sys/modules/vioscsi: Makefile vioscsi.ioconf

Log Message:
add support for loading vioscsi driver dynamically


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/pci/vioscsi.c
cvs rdiff -u -r0 -r1.1 src/sys/modules/vioscsi/Makefile \
src/sys/modules/vioscsi/vioscsi.ioconf

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/vioscsi.c
diff -u src/sys/dev/pci/vioscsi.c:1.14 src/sys/dev/pci/vioscsi.c:1.15
--- src/sys/dev/pci/vioscsi.c:1.14	Sat Mar 25 18:13:53 2017
+++ src/sys/dev/pci/vioscsi.c	Sat Mar 25 18:15:31 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vioscsi.c,v 1.14 2017/03/25 18:13:53 jdolecek Exp $	*/
+/*	$NetBSD: vioscsi.c,v 1.15 2017/03/25 18:15:31 jdolecek Exp $	*/
 /*	$OpenBSD: vioscsi.c,v 1.3 2015/03/14 03:38:49 jsg Exp $	*/
 
 /*
@@ -18,13 +18,14 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vioscsi.c,v 1.14 2017/03/25 18:13:53 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vioscsi.c,v 1.15 2017/03/25 18:15:31 jdolecek Exp $");
 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -66,6 +67,8 @@ struct vioscsi_softc {
 	bus_dma_segment_tsc_reqs_segs[1];
 
 	u_int32_t		 sc_seg_max;
+
+	kmutex_t		 sc_mutex;
 };
 
 /*  
@@ -76,9 +79,10 @@ struct vioscsi_softc {
 
 static int	 vioscsi_match(device_t, cfdata_t, void *);
 static void	 vioscsi_attach(device_t, device_t, void *);
+static int	 vioscsi_detach(device_t, int);
 
 static int	 vioscsi_alloc_reqs(struct vioscsi_softc *,
-struct virtio_softc *, int, uint32_t);
+struct virtio_softc *, int);
 static void	 vioscsi_free_reqs(struct vioscsi_softc *,
 struct virtio_softc *);
 static void	 vioscsi_scsipi_request(struct scsipi_channel *,
@@ -87,6 +91,7 @@ static int	 vioscsi_vq_done(struct virtq
 static void	 vioscsi_req_done(struct vioscsi_softc *, struct virtio_softc *,
 struct vioscsi_req *);
 static struct vioscsi_req *vioscsi_req_get(struct vioscsi_softc *);
+static void	 vioscsi_bad_target(struct scsipi_xfer *);
 
 static const char *const vioscsi_vq_names[] = {
 	"control",
@@ -94,8 +99,9 @@ static const char *const vioscsi_vq_name
 	"request",
 };
 
-CFATTACH_DECL_NEW(vioscsi, sizeof(struct vioscsi_softc),
-vioscsi_match, vioscsi_attach, NULL, NULL);
+CFATTACH_DECL3_NEW(vioscsi, sizeof(struct vioscsi_softc),
+vioscsi_match, vioscsi_attach, vioscsi_detach, NULL, NULL, NULL,
+DVF_DETACH_SHUTDOWN);
 
 static int
 vioscsi_match(device_t parent, cfdata_t match, void *aux)
@@ -127,9 +133,11 @@ vioscsi_attach(device_t parent, device_t
 	sc->sc_dev = self;
 
 	virtio_child_attach_start(vsc, self, ipl, sc->sc_vqs,
-	NULL, virtio_vq_intr, VIRTIO_F_PCI_INTR_MSIX,
+	NULL, virtio_vq_intr, VIRTIO_F_PCI_INTR_MSIX,
 	0, VIRTIO_COMMON_FLAG_BITS);
 
+	mutex_init(>sc_mutex, MUTEX_DEFAULT, ipl);
+
 	uint32_t cmd_per_lun = virtio_read_device_config_4(vsc,
 	VIRTIO_SCSI_CONFIG_CMD_PER_LUN);
 
@@ -144,13 +152,14 @@ vioscsi_attach(device_t parent, device_t
 
 	sc->sc_seg_max = seg_max;
 
-	for (i = 0; i < __arraycount(sc->sc_vqs); i++) {
+	for(i=0; i < __arraycount(sc->sc_vqs); i++) {
 		rv = virtio_alloc_vq(vsc, >sc_vqs[i], i, MAXPHYS,
-		1 + howmany(MAXPHYS, NBPG), vioscsi_vq_names[i]);
+		1 + howmany(MAXPHYS, NBPG),
+		vioscsi_vq_names[i]);
 		if (rv) {
 			aprint_error_dev(sc->sc_dev,
-			"failed to allocate virtqueue %zu\n", i);
-			return;
+			"failed to allocate virtqueue %d\n", i);
+			goto err;
 		}
 
 		if (i == VIOSCSI_VQ_REQUEST)
@@ -158,8 +167,8 @@ vioscsi_attach(device_t parent, device_t
 	}
 
 	qsize = sc->sc_vqs[VIOSCSI_VQ_REQUEST].vq_num;
-	if (vioscsi_alloc_reqs(sc, vsc, qsize, seg_max))
-		return;
+	if (vioscsi_alloc_reqs(sc, vsc, qsize))
+		goto err;
 
 	aprint_normal_dev(sc->sc_dev,
 	"cmd_per_lun %zu qsize %zu seg_max %zu max_target %zu"
@@ -188,7 +197,7 @@ vioscsi_attach(device_t parent, device_t
 	chan->chan_bustype = _bustype;
 	chan->chan_channel = 0;
 	chan->chan_ntargets = MIN(max_target, 16);	/* cap reasonably */
-	chan->chan_nluns = MIN(max_lun, 16);		/* cap reasonably */
+	chan->chan_nluns = MIN(max_lun, 1024);		/* cap reasonably */
 	chan->chan_id = 0;
 	chan->chan_flags = SCSIPI_CHAN_NOSETTLE;
 
@@ -205,7 +214,40 @@ err:
 	}
 
 	virtio_child_attach_failed(vsc);
+}
+
+static int
+vioscsi_detach(device_t self, int flags)
+{
+	struct vioscsi_softc *sc = device_private(self);
+	struct virtio_softc *vsc = device_private(device_parent(sc->sc_dev));
+	int rc, i;
+
+	/*
+	 * Dequeue all pending finished requests. Must be done
+	 * before we try to detach children so that we process
+	 * their pending requests while they still exist.
+	 */
+	if (sc->sc_vqs[VIOSCSI_VQ_REQUEST].vq_num > 0)
+		vioscsi_vq_done(>sc_vqs[VIOSCSI_VQ_REQUEST]);
 

CVS commit: src/sys/dev/pci

2017-03-25 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sat Mar 25 18:13:53 UTC 2017

Modified Files:
src/sys/dev/pci: vioscsi.c

Log Message:
cap also adapt_nchannels to 1, we only attach one


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/dev/pci/vioscsi.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/pci/vioscsi.c
diff -u src/sys/dev/pci/vioscsi.c:1.13 src/sys/dev/pci/vioscsi.c:1.14
--- src/sys/dev/pci/vioscsi.c:1.13	Sat Mar 25 18:09:44 2017
+++ src/sys/dev/pci/vioscsi.c	Sat Mar 25 18:13:53 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vioscsi.c,v 1.13 2017/03/25 18:09:44 jdolecek Exp $	*/
+/*	$NetBSD: vioscsi.c,v 1.14 2017/03/25 18:13:53 jdolecek Exp $	*/
 /*	$OpenBSD: vioscsi.c,v 1.3 2015/03/14 03:38:49 jsg Exp $	*/
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vioscsi.c,v 1.13 2017/03/25 18:09:44 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vioscsi.c,v 1.14 2017/03/25 18:13:53 jdolecek Exp $");
 
 #include 
 #include 
@@ -139,9 +139,6 @@ vioscsi_attach(device_t parent, device_t
 	uint16_t max_target = virtio_read_device_config_2(vsc,
 	VIRTIO_SCSI_CONFIG_MAX_TARGET);
 
-	uint16_t max_channel = virtio_read_device_config_2(vsc,
-	VIRTIO_SCSI_CONFIG_MAX_CHANNEL);
-
 	uint32_t max_lun = virtio_read_device_config_4(vsc,
 	VIRTIO_SCSI_CONFIG_MAX_LUN);
 
@@ -177,7 +174,7 @@ vioscsi_attach(device_t parent, device_t
 	 */
 	memset(adapt, 0, sizeof(*adapt));
 	adapt->adapt_dev = sc->sc_dev;
-	adapt->adapt_nchannels = max_channel;
+	adapt->adapt_nchannels = 1;
 	adapt->adapt_openings = MIN(qsize, cmd_per_lun);
 	adapt->adapt_max_periph = adapt->adapt_openings;
 	adapt->adapt_request = vioscsi_scsipi_request;



CVS commit: src/sys/dev/pci

2017-03-25 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sat Mar 25 18:13:53 UTC 2017

Modified Files:
src/sys/dev/pci: vioscsi.c

Log Message:
cap also adapt_nchannels to 1, we only attach one


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/dev/pci/vioscsi.c

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



CVS commit: src/sys/dev/pci

2017-03-25 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sat Mar 25 18:09:44 UTC 2017

Modified Files:
src/sys/dev/pci: vioscsi.c

Log Message:
cap adapt_openings to minimum of cmd_per_lun and qsize, so that we don't
overpromise to the upper layer

cap ntargets and nluns to 16 and 1024 as avoid spending excessive time
probing for nonexistent devices; e.g. qemu defaults to 255/16383 causing
the probe to take about a minute


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/dev/pci/vioscsi.c

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



CVS commit: src/sys/dev/pci

2017-03-25 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sat Mar 25 18:09:44 UTC 2017

Modified Files:
src/sys/dev/pci: vioscsi.c

Log Message:
cap adapt_openings to minimum of cmd_per_lun and qsize, so that we don't
overpromise to the upper layer

cap ntargets and nluns to 16 and 1024 as avoid spending excessive time
probing for nonexistent devices; e.g. qemu defaults to 255/16383 causing
the probe to take about a minute


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/dev/pci/vioscsi.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/pci/vioscsi.c
diff -u src/sys/dev/pci/vioscsi.c:1.12 src/sys/dev/pci/vioscsi.c:1.13
--- src/sys/dev/pci/vioscsi.c:1.12	Sat Mar 25 18:02:06 2017
+++ src/sys/dev/pci/vioscsi.c	Sat Mar 25 18:09:44 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vioscsi.c,v 1.12 2017/03/25 18:02:06 jdolecek Exp $	*/
+/*	$NetBSD: vioscsi.c,v 1.13 2017/03/25 18:09:44 jdolecek Exp $	*/
 /*	$OpenBSD: vioscsi.c,v 1.3 2015/03/14 03:38:49 jsg Exp $	*/
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vioscsi.c,v 1.12 2017/03/25 18:02:06 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vioscsi.c,v 1.13 2017/03/25 18:09:44 jdolecek Exp $");
 
 #include 
 #include 
@@ -178,7 +178,7 @@ vioscsi_attach(device_t parent, device_t
 	memset(adapt, 0, sizeof(*adapt));
 	adapt->adapt_dev = sc->sc_dev;
 	adapt->adapt_nchannels = max_channel;
-	adapt->adapt_openings = cmd_per_lun;
+	adapt->adapt_openings = MIN(qsize, cmd_per_lun);
 	adapt->adapt_max_periph = adapt->adapt_openings;
 	adapt->adapt_request = vioscsi_scsipi_request;
 	adapt->adapt_minphys = minphys;
@@ -190,8 +190,8 @@ vioscsi_attach(device_t parent, device_t
 	chan->chan_adapter = adapt;
 	chan->chan_bustype = _bustype;
 	chan->chan_channel = 0;
-	chan->chan_ntargets = MIN(max_target + 1, 8);
-	chan->chan_nluns = MIN(max_lun + 1, 8);
+	chan->chan_ntargets = MIN(max_target, 16);	/* cap reasonably */
+	chan->chan_nluns = MIN(max_lun, 16);		/* cap reasonably */
 	chan->chan_id = 0;
 	chan->chan_flags = SCSIPI_CHAN_NOSETTLE;
 



CVS commit: src/sys/dev/pci

2017-03-25 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sat Mar 25 18:02:06 UTC 2017

Modified Files:
src/sys/dev/pci: if_vioif.c ld_virtio.c viomb.c viornd.c vioscsi.c
virtio.c virtiovar.h

Log Message:
reorganize the attachment process for virtio child devices, so that
more common code is shared among the drivers, and it's possible for
the drivers to be correctly dynamically loaded; forbid direct access
to struct virtio_softc from the child driver code


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/dev/pci/if_vioif.c
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/pci/ld_virtio.c
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/pci/viomb.c
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/pci/viornd.c
cvs rdiff -u -r1.11 -r1.12 src/sys/dev/pci/vioscsi.c
cvs rdiff -u -r1.21 -r1.22 src/sys/dev/pci/virtio.c
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/pci/virtiovar.h

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

Modified files:

Index: src/sys/dev/pci/if_vioif.c
diff -u src/sys/dev/pci/if_vioif.c:1.31 src/sys/dev/pci/if_vioif.c:1.32
--- src/sys/dev/pci/if_vioif.c:1.31	Tue Jan 17 01:25:21 2017
+++ src/sys/dev/pci/if_vioif.c	Sat Mar 25 18:02:06 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vioif.c,v 1.31 2017/01/17 01:25:21 ozaki-r Exp $	*/
+/*	$NetBSD: if_vioif.c,v 1.32 2017/03/25 18:02:06 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 2010 Minoura Makoto.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.31 2017/01/17 01:25:21 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.32 2017/03/25 18:02:06 jdolecek Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -227,6 +227,8 @@ struct vioif_softc {
 	kmutex_t		*sc_tx_lock;
 	kmutex_t		*sc_rx_lock;
 	bool			sc_stopping;
+
+	bool			sc_has_ctrl;
 };
 #define VIRTIO_NET_TX_MAXNSEGS		(16) /* XXX */
 #define VIRTIO_NET_CTRL_MAC_MAXENTRIES	(64) /* XXX */
@@ -281,7 +283,7 @@ CFATTACH_DECL_NEW(vioif, sizeof(struct v
 static int
 vioif_match(device_t parent, cfdata_t match, void *aux)
 {
-	struct virtio_softc *va = aux;
+	struct virtio_attach_args *va = aux;
 
 	if (va->sc_childdevid == PCI_PRODUCT_VIRTIO_NETWORK)
 		return 1;
@@ -323,12 +325,12 @@ vioif_alloc_mems(struct vioif_softc *sc)
 	intptr_t p;
 	int rxqsize, txqsize;
 
-	rxqsize = vsc->sc_vqs[VQ_RX].vq_num;
-	txqsize = vsc->sc_vqs[VQ_TX].vq_num;
+	rxqsize = sc->sc_vq[VQ_RX].vq_num;
+	txqsize = sc->sc_vq[VQ_TX].vq_num;
 
 	allocsize = sizeof(struct virtio_net_hdr) * rxqsize;
 	allocsize += sizeof(struct virtio_net_hdr) * txqsize;
-	if (vsc->sc_nvqs == 3) {
+	if (sc->sc_has_ctrl) {
 		allocsize += sizeof(struct virtio_net_ctrl_cmd) * 1;
 		allocsize += sizeof(struct virtio_net_ctrl_status) * 1;
 		allocsize += sizeof(struct virtio_net_ctrl_rx) * 1;
@@ -336,7 +338,7 @@ vioif_alloc_mems(struct vioif_softc *sc)
 			+ sizeof(struct virtio_net_ctrl_mac_tbl)
 			+ ETHER_ADDR_LEN * VIRTIO_NET_CTRL_MAC_MAXENTRIES;
 	}
-	r = bus_dmamem_alloc(vsc->sc_dmat, allocsize, 0, 0,
+	r = bus_dmamem_alloc(virtio_dmat(vsc), allocsize, 0, 0,
 			 >sc_hdr_segs[0], 1, , BUS_DMA_NOWAIT);
 	if (r != 0) {
 		aprint_error_dev(sc->sc_dev,
@@ -344,7 +346,7 @@ vioif_alloc_mems(struct vioif_softc *sc)
  "error code %d\n", allocsize, r);
 		goto err_none;
 	}
-	r = bus_dmamem_map(vsc->sc_dmat,
+	r = bus_dmamem_map(virtio_dmat(vsc),
 			   >sc_hdr_segs[0], 1, allocsize,
 			   , BUS_DMA_NOWAIT);
 	if (r != 0) {
@@ -360,7 +362,7 @@ vioif_alloc_mems(struct vioif_softc *sc)
 #define P(name,size)	do { sc->sc_ ##name = (void*) p;	\
 			 p += size; } while (0)
 	P(tx_hdrs, sizeof(struct virtio_net_hdr) * txqsize);
-	if (vsc->sc_nvqs == 3) {
+	if (sc->sc_has_ctrl) {
 		P(ctrl_cmd, sizeof(struct virtio_net_ctrl_cmd));
 		P(ctrl_status, sizeof(struct virtio_net_ctrl_status));
 		P(ctrl_rx, sizeof(struct virtio_net_ctrl_rx));
@@ -385,7 +387,7 @@ vioif_alloc_mems(struct vioif_softc *sc)
 
 #define C(map, buf, size, nsegs, rw, usage)\
 	do {\
-		r = bus_dmamap_create(vsc->sc_dmat, size, nsegs, size, 0, \
+		r = bus_dmamap_create(virtio_dmat(vsc), size, nsegs, size, 0, \
   BUS_DMA_NOWAIT|BUS_DMA_ALLOCNOW,	\
   >sc_ ##map);			\
 		if (r != 0) {		\
@@ -398,7 +400,7 @@ vioif_alloc_mems(struct vioif_softc *sc)
 #define C_L1(map, buf, size, nsegs, rw, usage)\
 	C(map, buf, size, nsegs, rw, usage);\
 	do {\
-		r = bus_dmamap_load(vsc->sc_dmat, sc->sc_ ##map,	\
+		r = bus_dmamap_load(virtio_dmat(vsc), sc->sc_ ##map,	\
 >sc_ ##buf, size, NULL,		\
 BUS_DMA_ ##rw | BUS_DMA_NOWAIT);	\
 		if (r != 0) {		\
@@ -411,7 +413,7 @@ vioif_alloc_mems(struct vioif_softc *sc)
 #define C_L2(map, buf, size, nsegs, rw, usage)\
 	C(map, buf, size, nsegs, rw, usage);\
 	do {\
-		r = bus_dmamap_load(vsc->sc_dmat, sc->sc_ ##map,	\
+		r = bus_dmamap_load(virtio_dmat(vsc), sc->sc_ ##map,	\
 sc->sc_ ##buf, size, NULL,		\
 BUS_DMA_ ##rw | BUS_DMA_NOWAIT);	\
 		if (r 

CVS commit: src/sys/dev/pci

2017-03-25 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sat Mar 25 18:02:06 UTC 2017

Modified Files:
src/sys/dev/pci: if_vioif.c ld_virtio.c viomb.c viornd.c vioscsi.c
virtio.c virtiovar.h

Log Message:
reorganize the attachment process for virtio child devices, so that
more common code is shared among the drivers, and it's possible for
the drivers to be correctly dynamically loaded; forbid direct access
to struct virtio_softc from the child driver code


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/dev/pci/if_vioif.c
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/pci/ld_virtio.c
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/pci/viomb.c
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/pci/viornd.c
cvs rdiff -u -r1.11 -r1.12 src/sys/dev/pci/vioscsi.c
cvs rdiff -u -r1.21 -r1.22 src/sys/dev/pci/virtio.c
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/pci/virtiovar.h

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



CVS commit: [netbsd-6] src/doc

2017-03-25 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sat Mar 25 17:58:44 UTC 2017

Modified Files:
src/doc [netbsd-6]: CHANGES-6.2

Log Message:
1444, 1445, 1439, 1387


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.279 -r1.1.2.280 src/doc/CHANGES-6.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-6.2
diff -u src/doc/CHANGES-6.2:1.1.2.279 src/doc/CHANGES-6.2:1.1.2.280
--- src/doc/CHANGES-6.2:1.1.2.279	Sat Mar 25 17:18:57 2017
+++ src/doc/CHANGES-6.2	Sat Mar 25 17:58:44 2017
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-6.2,v 1.1.2.279 2017/03/25 17:18:57 snj Exp $
+# $NetBSD: CHANGES-6.2,v 1.1.2.280 2017/03/25 17:58:44 snj Exp $
 
 A complete list of changes from the 6.1 release until the 6.2 release:
 
@@ -16460,3 +16460,25 @@ sys/arch/i386/i386/trap.c			1.287
 	Handle #SS faults on iret properly.
 	[maxv, ticket #1446]
 
+sys/dev/usb/uplcom.c1.76
+
+	Avoid a kernel page fault when opening the device.
+	[bad, ticket #1444]
+
+sys/dev/usb/uplcom.c1.75
+
+	Null suspend/resume handler for uplcom(4).
+	[bad, ticket #1445]
+
+sys/dev/pci/ixgbe/ixgbe.c			1.60 via patch
+
+	Use 64bit DMA tag. If not, a lot of bounce buffer is allocated.
+	PR kern/49968.
+	[msaitoh, ticket #1439]
+
+bin/cat/cat.c	1.57
+
+	When invoked with -se, print a '$' on blank lines.
+	PR bin/51250.
+	[sevan, ticket #1387]
+



CVS commit: src/sys/dev/pci

2017-03-25 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sat Mar 25 17:50:51 UTC 2017

Modified Files:
src/sys/dev/pci: virtio.c

Log Message:
use ipl level specified by child when attaching interrupts, instead of always
using IPL_NET


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/dev/pci/virtio.c

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



CVS commit: src/sys/dev/pci

2017-03-25 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sat Mar 25 17:50:51 UTC 2017

Modified Files:
src/sys/dev/pci: virtio.c

Log Message:
use ipl level specified by child when attaching interrupts, instead of always
using IPL_NET


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/dev/pci/virtio.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/pci/virtio.c
diff -u src/sys/dev/pci/virtio.c:1.20 src/sys/dev/pci/virtio.c:1.21
--- src/sys/dev/pci/virtio.c:1.20	Sat Mar 25 13:05:09 2017
+++ src/sys/dev/pci/virtio.c	Sat Mar 25 17:50:51 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: virtio.c,v 1.20 2017/03/25 13:05:09 martin Exp $	*/
+/*	$NetBSD: virtio.c,v 1.21 2017/03/25 17:50:51 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 2010 Minoura Makoto.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: virtio.c,v 1.20 2017/03/25 13:05:09 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: virtio.c,v 1.21 2017/03/25 17:50:51 jdolecek Exp $");
 
 #include 
 #include 
@@ -204,8 +204,8 @@ virtio_setup_msix_interrupts(struct virt
 	if (sc->sc_flags & VIRTIO_F_PCI_INTR_MPSAFE)
 		pci_intr_setattr(pc, >sc_ihp[idx], PCI_INTR_MPSAFE, true);
 
-	sc->sc_ihs[idx] = pci_intr_establish_xname(pc, sc->sc_ihp[idx], IPL_NET,
-	virtio_msix_config_intr, sc, device_xname(sc->sc_dev));
+	sc->sc_ihs[idx] = pci_intr_establish_xname(pc, sc->sc_ihp[idx],
+	sc->sc_ipl, virtio_msix_config_intr, sc, device_xname(sc->sc_dev));
 	if (sc->sc_ihs[idx] == NULL) {
 		aprint_error_dev(self, "couldn't establish MSI-X for config\n");
 		goto error;
@@ -215,8 +215,8 @@ virtio_setup_msix_interrupts(struct virt
 	if (sc->sc_flags & VIRTIO_F_PCI_INTR_MPSAFE)
 		pci_intr_setattr(pc, >sc_ihp[idx], PCI_INTR_MPSAFE, true);
 
-	sc->sc_ihs[idx] = pci_intr_establish_xname(pc, sc->sc_ihp[idx], IPL_NET,
-	virtio_msix_queue_intr, sc, device_xname(sc->sc_dev));
+	sc->sc_ihs[idx] = pci_intr_establish_xname(pc, sc->sc_ihp[idx],
+	sc->sc_ipl, virtio_msix_queue_intr, sc, device_xname(sc->sc_dev));
 	if (sc->sc_ihs[idx] == NULL) {
 		aprint_error_dev(self, "couldn't establish MSI-X for queues\n");
 		goto error;
@@ -260,7 +260,7 @@ virtio_setup_intx_interrupt(struct virti
 		pci_intr_setattr(pc, >sc_ihp[0], PCI_INTR_MPSAFE, true);
 
 	sc->sc_ihs[0] = pci_intr_establish_xname(pc, sc->sc_ihp[0],
-	IPL_NET, virtio_intr, sc, device_xname(sc->sc_dev));
+	sc->sc_ipl, virtio_intr, sc, device_xname(sc->sc_dev));
 	if (sc->sc_ihs[0] == NULL) {
 		aprint_error_dev(self, "couldn't establish INTx\n");
 		return -1;



Re: CVS commit: src/share/misc

2017-03-25 Thread David Holland
On Fri, Mar 24, 2017 at 12:49:43PM +, Brian Ginsbach wrote:
 > Modified Files:
 >  src/share/misc: acronyms.comp
 > 
 > Log Message:
 > Add the more prevalent media access control (MAC) in addition to
 > medium access control

It doesn't really need both...

-- 
David A. Holland
dholl...@netbsd.org


CVS commit: [netbsd-6] src/bin/cat

2017-03-25 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sat Mar 25 17:41:48 UTC 2017

Modified Files:
src/bin/cat [netbsd-6]: cat.c

Log Message:
Pull up following revision(s) (requested by sevan in ticket #1387):
bin/cat/cat.c: revision 1.57
When invoked with -se, print a '$' on blank lines
Obtained from OpenBSD r1.13 of src/bin/cat/cat.c
Closes PR bin/51250
Reviewed by Christos@


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.47.20.1 src/bin/cat/cat.c

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



CVS commit: [netbsd-6] src/bin/cat

2017-03-25 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sat Mar 25 17:41:48 UTC 2017

Modified Files:
src/bin/cat [netbsd-6]: cat.c

Log Message:
Pull up following revision(s) (requested by sevan in ticket #1387):
bin/cat/cat.c: revision 1.57
When invoked with -se, print a '$' on blank lines
Obtained from OpenBSD r1.13 of src/bin/cat/cat.c
Closes PR bin/51250
Reviewed by Christos@


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.47.20.1 src/bin/cat/cat.c

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

Modified files:

Index: src/bin/cat/cat.c
diff -u src/bin/cat/cat.c:1.47 src/bin/cat/cat.c:1.47.20.1
--- src/bin/cat/cat.c:1.47	Sun Jul 20 00:52:39 2008
+++ src/bin/cat/cat.c	Sat Mar 25 17:41:48 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: cat.c,v 1.47 2008/07/20 00:52:39 lukem Exp $	*/
+/* $NetBSD: cat.c,v 1.47.20.1 2017/03/25 17:41:48 snj Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -44,7 +44,7 @@ __COPYRIGHT(
 #if 0
 static char sccsid[] = "@(#)cat.c	8.2 (Berkeley) 4/27/95";
 #else
-__RCSID("$NetBSD: cat.c,v 1.47 2008/07/20 00:52:39 lukem Exp $");
+__RCSID("$NetBSD: cat.c,v 1.47.20.1 2017/03/25 17:41:48 snj Exp $");
 #endif
 #endif /* not lint */
 
@@ -172,18 +172,16 @@ cook_buf(FILE *fp)
 	line = gobble = 0;
 	for (prev = '\n'; (ch = getc(fp)) != EOF; prev = ch) {
 		if (prev == '\n') {
-			if (ch == '\n') {
-if (sflag) {
-	if (!gobble && nflag && !bflag)
-		(void)fprintf(stdout,
-			"%6d\t\n", ++line);
-	else if (!gobble && putchar(ch) == EOF)
-		break;
+			if (sflag) {
+if (ch == '\n') {
+	if (gobble)
+		continue;
 	gobble = 1;
-	continue;
+} else
+	gobble = 0;
 }
 if (nflag) {
-	if (!bflag) {
+	if (!bflag || ch != '\n') {
 		(void)fprintf(stdout,
 		"%6d\t", ++line);
 		if (ferror(stdout))
@@ -195,13 +193,7 @@ cook_buf(FILE *fp)
 			break;
 	}
 }
-			} else if (nflag) {
-(void)fprintf(stdout, "%6d\t", ++line);
-if (ferror(stdout))
-	break;
 			}
-		}
-		gobble = 0;
 		if (ch == '\n') {
 			if (eflag)
 if (putchar('$') == EOF)



CVS commit: [netbsd-6] src/sys/dev/pci/ixgbe

2017-03-25 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sat Mar 25 17:35:56 UTC 2017

Modified Files:
src/sys/dev/pci/ixgbe [netbsd-6]: ixgbe.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #1439):
sys/dev/pci/ixgbe/ixgbe.c: revision 1.60 via patch
Use 64bit DMA tag. If not, a lot of bounce buffer is allocated.
Fixes PR#49968 reported by Hauke.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.2.4.1 src/sys/dev/pci/ixgbe/ixgbe.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/pci/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.2 src/sys/dev/pci/ixgbe/ixgbe.c:1.2.4.1
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.2	Sat Nov 19 22:51:24 2011
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Sat Mar 25 17:35:56 2017
@@ -59,7 +59,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 /*$FreeBSD: src/sys/dev/ixgbe/ixgbe.c,v 1.51 2011/04/25 23:34:21 jfv Exp $*/
-/*$NetBSD: ixgbe.c,v 1.2 2011/11/19 22:51:24 tls Exp $*/
+/*$NetBSD: ixgbe.c,v 1.2.4.1 2017/03/25 17:35:56 snj Exp $*/
 
 #include "opt_inet.h"
 
@@ -475,6 +475,10 @@ ixgbe_attach(device_t parent, device_t d
 	adapter->osdep.pc = pa->pa_pc;
 	adapter->osdep.tag = pa->pa_tag;
 	adapter->osdep.dmat = pa->pa_dmat;
+	if (pci_dma64_available(pa))
+		adapter->osdep.dmat = pa->pa_dmat64;
+	else
+		adapter->osdep.dmat = pa->pa_dmat;
 
 	ent = ixgbe_lookup(pa);
 



CVS commit: [netbsd-6] src/sys/dev/usb

2017-03-25 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sat Mar 25 17:30:18 UTC 2017

Modified Files:
src/sys/dev/usb [netbsd-6]: uplcom.c

Log Message:
Pull up following revision(s) (requested by bad in ticket #1445):
sys/dev/usb/uplcom.c: revision 1.75
Null suspend/resume handler for uplcom(4).


To generate a diff of this commit:
cvs rdiff -u -r1.73.2.1 -r1.73.2.2 src/sys/dev/usb/uplcom.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/usb/uplcom.c
diff -u src/sys/dev/usb/uplcom.c:1.73.2.1 src/sys/dev/usb/uplcom.c:1.73.2.2
--- src/sys/dev/usb/uplcom.c:1.73.2.1	Sat Mar 25 17:26:53 2017
+++ src/sys/dev/usb/uplcom.c	Sat Mar 25 17:30:18 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: uplcom.c,v 1.73.2.1 2017/03/25 17:26:53 snj Exp $	*/
+/*	$NetBSD: uplcom.c,v 1.73.2.2 2017/03/25 17:30:18 snj Exp $	*/
 /*
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uplcom.c,v 1.73.2.1 2017/03/25 17:26:53 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uplcom.c,v 1.73.2.2 2017/03/25 17:30:18 snj Exp $");
 
 #include 
 #include 
@@ -416,6 +416,9 @@ uplcom_attach(device_t parent, device_t 
 	sc->sc_subdev = config_found_sm_loc(self, "ucombus", NULL, ,
 	ucomprint, ucomsubmatch);
 
+	if (!pmf_device_register(self, NULL, NULL))
+		aprint_error_dev(self, "couldn't establish power handler\n");
+
 	return;
 }
 
@@ -450,6 +453,9 @@ uplcom_detach(device_t self, int flags)
 	usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev,
 			   sc->sc_dev);
 
+	if (rv == 0)
+		pmf_device_deregister(self);
+
 	return (rv);
 }
 



CVS commit: [netbsd-6] src/sys/dev/usb

2017-03-25 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sat Mar 25 17:30:18 UTC 2017

Modified Files:
src/sys/dev/usb [netbsd-6]: uplcom.c

Log Message:
Pull up following revision(s) (requested by bad in ticket #1445):
sys/dev/usb/uplcom.c: revision 1.75
Null suspend/resume handler for uplcom(4).


To generate a diff of this commit:
cvs rdiff -u -r1.73.2.1 -r1.73.2.2 src/sys/dev/usb/uplcom.c

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



CVS commit: [netbsd-6] src/sys/dev/usb

2017-03-25 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sat Mar 25 17:26:53 UTC 2017

Modified Files:
src/sys/dev/usb [netbsd-6]: uplcom.c

Log Message:
Pull up following revision(s) (requested by bad in ticket #1444):
sys/dev/usb/uplcom.c: revision 1.76
Don't pretend to do zero length IN control transfers as dwctwo(4)
(correctly according to usb 2.0 specification 8.5.3) uses IN status stage
when no (zero length) data stage.  Instead read into a 1 byte array.
My uplcom(4) now works on RPI.


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.73.2.1 src/sys/dev/usb/uplcom.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/usb/uplcom.c
diff -u src/sys/dev/usb/uplcom.c:1.73 src/sys/dev/usb/uplcom.c:1.73.2.1
--- src/sys/dev/usb/uplcom.c:1.73	Fri Dec 23 00:51:48 2011
+++ src/sys/dev/usb/uplcom.c	Sat Mar 25 17:26:53 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: uplcom.c,v 1.73 2011/12/23 00:51:48 jakllsch Exp $	*/
+/*	$NetBSD: uplcom.c,v 1.73.2.1 2017/03/25 17:26:53 snj Exp $	*/
 /*
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uplcom.c,v 1.73 2011/12/23 00:51:48 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uplcom.c,v 1.73.2.1 2017/03/25 17:26:53 snj Exp $");
 
 #include 
 #include 
@@ -491,21 +491,20 @@ struct pl2303x_init {
 	uint8_t		request;
 	uint16_t	value;
 	uint16_t	index;
-	uint16_t	length;
 };
 
 static const struct pl2303x_init pl2303x[] = {
-	{ UT_READ_VENDOR_DEVICE,  UPLCOM_SET_REQUEST, 0x8484,0, 0 },
-	{ UT_WRITE_VENDOR_DEVICE, UPLCOM_SET_REQUEST, 0x0404,0, 0 },
-	{ UT_READ_VENDOR_DEVICE,  UPLCOM_SET_REQUEST, 0x8484,0, 0 },
-	{ UT_READ_VENDOR_DEVICE,  UPLCOM_SET_REQUEST, 0x8383,0, 0 },
-	{ UT_READ_VENDOR_DEVICE,  UPLCOM_SET_REQUEST, 0x8484,0, 0 },
-	{ UT_WRITE_VENDOR_DEVICE, UPLCOM_SET_REQUEST, 0x0404,1, 0 },
-	{ UT_READ_VENDOR_DEVICE,  UPLCOM_SET_REQUEST, 0x8484,0, 0 },
-	{ UT_READ_VENDOR_DEVICE,  UPLCOM_SET_REQUEST, 0x8383,0, 0 },
-	{ UT_WRITE_VENDOR_DEVICE, UPLCOM_SET_REQUEST,  0,1, 0 },
-	{ UT_WRITE_VENDOR_DEVICE, UPLCOM_SET_REQUEST,  1,0, 0 },
-	{ UT_WRITE_VENDOR_DEVICE, UPLCOM_SET_REQUEST,  2, 0x44, 0 }
+	{ UT_READ_VENDOR_DEVICE,  UPLCOM_SET_REQUEST, 0x8484,0 },
+	{ UT_WRITE_VENDOR_DEVICE, UPLCOM_SET_REQUEST, 0x0404,0 },
+	{ UT_READ_VENDOR_DEVICE,  UPLCOM_SET_REQUEST, 0x8484,0 },
+	{ UT_READ_VENDOR_DEVICE,  UPLCOM_SET_REQUEST, 0x8383,0 },
+	{ UT_READ_VENDOR_DEVICE,  UPLCOM_SET_REQUEST, 0x8484,0 },
+	{ UT_WRITE_VENDOR_DEVICE, UPLCOM_SET_REQUEST, 0x0404,1 },
+	{ UT_READ_VENDOR_DEVICE,  UPLCOM_SET_REQUEST, 0x8484,0 },
+	{ UT_READ_VENDOR_DEVICE,  UPLCOM_SET_REQUEST, 0x8383,0 },
+	{ UT_WRITE_VENDOR_DEVICE, UPLCOM_SET_REQUEST,  0,1 },
+	{ UT_WRITE_VENDOR_DEVICE, UPLCOM_SET_REQUEST,  1,0 },
+	{ UT_WRITE_VENDOR_DEVICE, UPLCOM_SET_REQUEST,  2, 0x44 }
 };
 #define N_PL2302X_INIT  (sizeof(pl2303x)/sizeof(pl2303x[0]))
 
@@ -517,13 +516,22 @@ uplcom_pl2303x_init(struct uplcom_softc 
 	int i;
 
 	for (i = 0; i < N_PL2302X_INIT; i++) {
+		char buf[1];
+		void *b;
+
 		req.bmRequestType = pl2303x[i].req_type;
 		req.bRequest = pl2303x[i].request;
 		USETW(req.wValue, pl2303x[i].value);
 		USETW(req.wIndex, pl2303x[i].index);
-		USETW(req.wLength, pl2303x[i].length);
+		if (UT_GET_DIR(req.bmRequestType) == UT_READ) {
+			b = buf;
+			USETW(req.wLength, sizeof(buf));
+		} else {
+			b = NULL;
+			USETW(req.wLength, 0);
+		}
 
-		err = usbd_do_request(sc->sc_udev, , 0);
+		err = usbd_do_request(sc->sc_udev, , b);
 		if (err) {
 			aprint_error_dev(sc->sc_dev,
 			"uplcom_pl2303x_init failed: %s\n",



CVS commit: [netbsd-6] src/sys/dev/usb

2017-03-25 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sat Mar 25 17:26:53 UTC 2017

Modified Files:
src/sys/dev/usb [netbsd-6]: uplcom.c

Log Message:
Pull up following revision(s) (requested by bad in ticket #1444):
sys/dev/usb/uplcom.c: revision 1.76
Don't pretend to do zero length IN control transfers as dwctwo(4)
(correctly according to usb 2.0 specification 8.5.3) uses IN status stage
when no (zero length) data stage.  Instead read into a 1 byte array.
My uplcom(4) now works on RPI.


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.73.2.1 src/sys/dev/usb/uplcom.c

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



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

2017-03-25 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sat Mar 25 17:20:30 UTC 2017

Modified Files:
src/doc [netbsd-6-0]: CHANGES-6.0.7

Log Message:
1446


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.88 -r1.1.2.89 src/doc/CHANGES-6.0.7

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-6.0.7
diff -u src/doc/CHANGES-6.0.7:1.1.2.88 src/doc/CHANGES-6.0.7:1.1.2.89
--- src/doc/CHANGES-6.0.7:1.1.2.88	Wed Mar  8 14:57:26 2017
+++ src/doc/CHANGES-6.0.7	Sat Mar 25 17:20:29 2017
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-6.0.7,v 1.1.2.88 2017/03/08 14:57:26 martin Exp $
+# $NetBSD: CHANGES-6.0.7,v 1.1.2.89 2017/03/25 17:20:29 snj Exp $
 
 A complete list of changes from the NetBSD 6.0.6 release to the NetBSD 6.0.7
 release:
@@ -10375,3 +10375,9 @@ external/mit/xorg/server/xorg-server/os/
 	MIT-MAGIC-COOKIES, fixing CVE-2017-2624
 	[mrg, ticket #1443]
 
+sys/arch/amd64/amd64/trap.c			1.94
+sys/arch/i386/i386/trap.c			1.287
+
+	Handle #SS faults on iret properly.
+	[maxv, ticket #1446]
+



CVS commit: [netbsd-6-0] src/sys/arch

2017-03-25 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sat Mar 25 17:20:07 UTC 2017

Modified Files:
src/sys/arch/amd64/amd64 [netbsd-6-0]: trap.c
src/sys/arch/i386/i386 [netbsd-6-0]: trap.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #1446):
sys/arch/amd64/amd64/trap.c: revision 1.94
sys/arch/i386/i386/trap.c: revision 1.287
Mmh, allow iret to be handled when an #SS fault (T_STKFLT) happens. Even
if the sdm is far from being clear, it appears that iret can trigger an #SS
fault if %ss points to a writable but non-present segment; in which case
the kernel would panic, thinking the fault was internal to it.
In particular, userland can create a broken segment in the ldt with
USER_LDT, update its %ss with setcontext and trigger the panic. I don't
think amd64 is affected since USER_LDT does not exist there, and the
changes on tf_ss seem correct - but I'm still adding T_STKFLT for safety.


To generate a diff of this commit:
cvs rdiff -u -r1.69.2.1 -r1.69.2.1.4.1 src/sys/arch/amd64/amd64/trap.c
cvs rdiff -u -r1.262 -r1.262.12.1 src/sys/arch/i386/i386/trap.c

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



CVS commit: [netbsd-6-0] src/sys/arch

2017-03-25 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sat Mar 25 17:20:07 UTC 2017

Modified Files:
src/sys/arch/amd64/amd64 [netbsd-6-0]: trap.c
src/sys/arch/i386/i386 [netbsd-6-0]: trap.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #1446):
sys/arch/amd64/amd64/trap.c: revision 1.94
sys/arch/i386/i386/trap.c: revision 1.287
Mmh, allow iret to be handled when an #SS fault (T_STKFLT) happens. Even
if the sdm is far from being clear, it appears that iret can trigger an #SS
fault if %ss points to a writable but non-present segment; in which case
the kernel would panic, thinking the fault was internal to it.
In particular, userland can create a broken segment in the ldt with
USER_LDT, update its %ss with setcontext and trigger the panic. I don't
think amd64 is affected since USER_LDT does not exist there, and the
changes on tf_ss seem correct - but I'm still adding T_STKFLT for safety.


To generate a diff of this commit:
cvs rdiff -u -r1.69.2.1 -r1.69.2.1.4.1 src/sys/arch/amd64/amd64/trap.c
cvs rdiff -u -r1.262 -r1.262.12.1 src/sys/arch/i386/i386/trap.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/trap.c
diff -u src/sys/arch/amd64/amd64/trap.c:1.69.2.1 src/sys/arch/amd64/amd64/trap.c:1.69.2.1.4.1
--- src/sys/arch/amd64/amd64/trap.c:1.69.2.1	Sun Jun  3 21:45:10 2012
+++ src/sys/arch/amd64/amd64/trap.c	Sat Mar 25 17:20:07 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.69.2.1 2012/06/03 21:45:10 jdc Exp $	*/
+/*	$NetBSD: trap.c,v 1.69.2.1.4.1 2017/03/25 17:20:07 snj Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.69.2.1 2012/06/03 21:45:10 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.69.2.1.4.1 2017/03/25 17:20:07 snj Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -294,6 +294,7 @@ trap(struct trapframe *frame)
 	case T_PROTFLT:
 	case T_SEGNPFLT:
 	case T_ALIGNFLT:
+	case T_STKFLT:
 	case T_TSSFLT:
 		if (p == NULL)
 			goto we_re_toast;

Index: src/sys/arch/i386/i386/trap.c
diff -u src/sys/arch/i386/i386/trap.c:1.262 src/sys/arch/i386/i386/trap.c:1.262.12.1
--- src/sys/arch/i386/i386/trap.c:1.262	Wed Sep  7 09:24:55 2011
+++ src/sys/arch/i386/i386/trap.c	Sat Mar 25 17:20:07 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.262 2011/09/07 09:24:55 reinoud Exp $	*/
+/*	$NetBSD: trap.c,v 1.262.12.1 2017/03/25 17:20:07 snj Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000, 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.262 2011/09/07 09:24:55 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.262.12.1 2017/03/25 17:20:07 snj Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -405,6 +405,7 @@ trap(struct trapframe *frame)
 #endif
 	case T_SEGNPFLT:
 	case T_ALIGNFLT:
+	case T_STKFLT:
 	case T_TSSFLT:
 		if (p == NULL)
 			goto we_re_toast;



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

2017-03-25 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sat Mar 25 17:20:30 UTC 2017

Modified Files:
src/doc [netbsd-6-0]: CHANGES-6.0.7

Log Message:
1446


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.88 -r1.1.2.89 src/doc/CHANGES-6.0.7

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



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

2017-03-25 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sat Mar 25 17:19:47 UTC 2017

Modified Files:
src/doc [netbsd-6-1]: CHANGES-6.1.6

Log Message:
1446


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

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-6.1.6
diff -u src/doc/CHANGES-6.1.6:1.1.2.86 src/doc/CHANGES-6.1.6:1.1.2.87
--- src/doc/CHANGES-6.1.6:1.1.2.86	Wed Mar  8 14:52:07 2017
+++ src/doc/CHANGES-6.1.6	Sat Mar 25 17:19:47 2017
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-6.1.6,v 1.1.2.86 2017/03/08 14:52:07 martin Exp $
+# $NetBSD: CHANGES-6.1.6,v 1.1.2.87 2017/03/25 17:19:47 snj Exp $
 
 A complete list of changes from the NetBSD 6.1.5 release to the NetBSD 6.1.6
 release:
@@ -10095,3 +10095,9 @@ external/mit/xorg/server/xorg-server/os/
 	MIT-MAGIC-COOKIES, fixing CVE-2017-2624
 	[mrg, ticket #1443]
 
+sys/arch/amd64/amd64/trap.c			1.94
+sys/arch/i386/i386/trap.c			1.287
+
+	Handle #SS faults on iret properly.
+	[maxv, ticket #1446]
+



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

2017-03-25 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sat Mar 25 17:19:47 UTC 2017

Modified Files:
src/doc [netbsd-6-1]: CHANGES-6.1.6

Log Message:
1446


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

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



CVS commit: [netbsd-6-1] src/sys/arch

2017-03-25 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sat Mar 25 17:19:32 UTC 2017

Modified Files:
src/sys/arch/amd64/amd64 [netbsd-6-1]: trap.c
src/sys/arch/i386/i386 [netbsd-6-1]: trap.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #1446):
sys/arch/amd64/amd64/trap.c: revision 1.94
sys/arch/i386/i386/trap.c: revision 1.287
Mmh, allow iret to be handled when an #SS fault (T_STKFLT) happens. Even
if the sdm is far from being clear, it appears that iret can trigger an #SS
fault if %ss points to a writable but non-present segment; in which case
the kernel would panic, thinking the fault was internal to it.
In particular, userland can create a broken segment in the ldt with
USER_LDT, update its %ss with setcontext and trigger the panic. I don't
think amd64 is affected since USER_LDT does not exist there, and the
changes on tf_ss seem correct - but I'm still adding T_STKFLT for safety.


To generate a diff of this commit:
cvs rdiff -u -r1.69.2.1 -r1.69.2.1.6.1 src/sys/arch/amd64/amd64/trap.c
cvs rdiff -u -r1.262 -r1.262.14.1 src/sys/arch/i386/i386/trap.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/trap.c
diff -u src/sys/arch/amd64/amd64/trap.c:1.69.2.1 src/sys/arch/amd64/amd64/trap.c:1.69.2.1.6.1
--- src/sys/arch/amd64/amd64/trap.c:1.69.2.1	Sun Jun  3 21:45:10 2012
+++ src/sys/arch/amd64/amd64/trap.c	Sat Mar 25 17:19:32 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.69.2.1 2012/06/03 21:45:10 jdc Exp $	*/
+/*	$NetBSD: trap.c,v 1.69.2.1.6.1 2017/03/25 17:19:32 snj Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.69.2.1 2012/06/03 21:45:10 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.69.2.1.6.1 2017/03/25 17:19:32 snj Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -294,6 +294,7 @@ trap(struct trapframe *frame)
 	case T_PROTFLT:
 	case T_SEGNPFLT:
 	case T_ALIGNFLT:
+	case T_STKFLT:
 	case T_TSSFLT:
 		if (p == NULL)
 			goto we_re_toast;

Index: src/sys/arch/i386/i386/trap.c
diff -u src/sys/arch/i386/i386/trap.c:1.262 src/sys/arch/i386/i386/trap.c:1.262.14.1
--- src/sys/arch/i386/i386/trap.c:1.262	Wed Sep  7 09:24:55 2011
+++ src/sys/arch/i386/i386/trap.c	Sat Mar 25 17:19:32 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.262 2011/09/07 09:24:55 reinoud Exp $	*/
+/*	$NetBSD: trap.c,v 1.262.14.1 2017/03/25 17:19:32 snj Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000, 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.262 2011/09/07 09:24:55 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.262.14.1 2017/03/25 17:19:32 snj Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -405,6 +405,7 @@ trap(struct trapframe *frame)
 #endif
 	case T_SEGNPFLT:
 	case T_ALIGNFLT:
+	case T_STKFLT:
 	case T_TSSFLT:
 		if (p == NULL)
 			goto we_re_toast;



CVS commit: [netbsd-6-1] src/sys/arch

2017-03-25 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sat Mar 25 17:19:32 UTC 2017

Modified Files:
src/sys/arch/amd64/amd64 [netbsd-6-1]: trap.c
src/sys/arch/i386/i386 [netbsd-6-1]: trap.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #1446):
sys/arch/amd64/amd64/trap.c: revision 1.94
sys/arch/i386/i386/trap.c: revision 1.287
Mmh, allow iret to be handled when an #SS fault (T_STKFLT) happens. Even
if the sdm is far from being clear, it appears that iret can trigger an #SS
fault if %ss points to a writable but non-present segment; in which case
the kernel would panic, thinking the fault was internal to it.
In particular, userland can create a broken segment in the ldt with
USER_LDT, update its %ss with setcontext and trigger the panic. I don't
think amd64 is affected since USER_LDT does not exist there, and the
changes on tf_ss seem correct - but I'm still adding T_STKFLT for safety.


To generate a diff of this commit:
cvs rdiff -u -r1.69.2.1 -r1.69.2.1.6.1 src/sys/arch/amd64/amd64/trap.c
cvs rdiff -u -r1.262 -r1.262.14.1 src/sys/arch/i386/i386/trap.c

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



CVS commit: [netbsd-6] src/doc

2017-03-25 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sat Mar 25 17:18:57 UTC 2017

Modified Files:
src/doc [netbsd-6]: CHANGES-6.2

Log Message:
1446


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.278 -r1.1.2.279 src/doc/CHANGES-6.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-6.2
diff -u src/doc/CHANGES-6.2:1.1.2.278 src/doc/CHANGES-6.2:1.1.2.279
--- src/doc/CHANGES-6.2:1.1.2.278	Wed Mar  8 14:55:09 2017
+++ src/doc/CHANGES-6.2	Sat Mar 25 17:18:57 2017
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-6.2,v 1.1.2.278 2017/03/08 14:55:09 martin Exp $
+# $NetBSD: CHANGES-6.2,v 1.1.2.279 2017/03/25 17:18:57 snj Exp $
 
 A complete list of changes from the 6.1 release until the 6.2 release:
 
@@ -16454,4 +16454,9 @@ external/mit/xorg/server/xorg-server/os/
 	MIT-MAGIC-COOKIES, fixing CVE-2017-2624
 	[mrg, ticket #1443]
 
+sys/arch/amd64/amd64/trap.c			1.94
+sys/arch/i386/i386/trap.c			1.287
+
+	Handle #SS faults on iret properly.
+	[maxv, ticket #1446]
 



CVS commit: [netbsd-6] src/doc

2017-03-25 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sat Mar 25 17:18:57 UTC 2017

Modified Files:
src/doc [netbsd-6]: CHANGES-6.2

Log Message:
1446


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.278 -r1.1.2.279 src/doc/CHANGES-6.2

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



CVS commit: [netbsd-6] src/sys/arch

2017-03-25 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sat Mar 25 17:18:25 UTC 2017

Modified Files:
src/sys/arch/amd64/amd64 [netbsd-6]: trap.c
src/sys/arch/i386/i386 [netbsd-6]: trap.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #1446):
sys/arch/amd64/amd64/trap.c: revision 1.94
sys/arch/i386/i386/trap.c: revision 1.287
Mmh, allow iret to be handled when an #SS fault (T_STKFLT) happens. Even
if the sdm is far from being clear, it appears that iret can trigger an #SS
fault if %ss points to a writable but non-present segment; in which case
the kernel would panic, thinking the fault was internal to it.
In particular, userland can create a broken segment in the ldt with
USER_LDT, update its %ss with setcontext and trigger the panic. I don't
think amd64 is affected since USER_LDT does not exist there, and the
changes on tf_ss seem correct - but I'm still adding T_STKFLT for safety.


To generate a diff of this commit:
cvs rdiff -u -r1.69.2.1 -r1.69.2.2 src/sys/arch/amd64/amd64/trap.c
cvs rdiff -u -r1.262 -r1.262.8.1 src/sys/arch/i386/i386/trap.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/trap.c
diff -u src/sys/arch/amd64/amd64/trap.c:1.69.2.1 src/sys/arch/amd64/amd64/trap.c:1.69.2.2
--- src/sys/arch/amd64/amd64/trap.c:1.69.2.1	Sun Jun  3 21:45:10 2012
+++ src/sys/arch/amd64/amd64/trap.c	Sat Mar 25 17:18:25 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.69.2.1 2012/06/03 21:45:10 jdc Exp $	*/
+/*	$NetBSD: trap.c,v 1.69.2.2 2017/03/25 17:18:25 snj Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.69.2.1 2012/06/03 21:45:10 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.69.2.2 2017/03/25 17:18:25 snj Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -294,6 +294,7 @@ trap(struct trapframe *frame)
 	case T_PROTFLT:
 	case T_SEGNPFLT:
 	case T_ALIGNFLT:
+	case T_STKFLT:
 	case T_TSSFLT:
 		if (p == NULL)
 			goto we_re_toast;

Index: src/sys/arch/i386/i386/trap.c
diff -u src/sys/arch/i386/i386/trap.c:1.262 src/sys/arch/i386/i386/trap.c:1.262.8.1
--- src/sys/arch/i386/i386/trap.c:1.262	Wed Sep  7 09:24:55 2011
+++ src/sys/arch/i386/i386/trap.c	Sat Mar 25 17:18:25 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.262 2011/09/07 09:24:55 reinoud Exp $	*/
+/*	$NetBSD: trap.c,v 1.262.8.1 2017/03/25 17:18:25 snj Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000, 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.262 2011/09/07 09:24:55 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.262.8.1 2017/03/25 17:18:25 snj Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -405,6 +405,7 @@ trap(struct trapframe *frame)
 #endif
 	case T_SEGNPFLT:
 	case T_ALIGNFLT:
+	case T_STKFLT:
 	case T_TSSFLT:
 		if (p == NULL)
 			goto we_re_toast;



CVS commit: [netbsd-6] src/sys/arch

2017-03-25 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sat Mar 25 17:18:25 UTC 2017

Modified Files:
src/sys/arch/amd64/amd64 [netbsd-6]: trap.c
src/sys/arch/i386/i386 [netbsd-6]: trap.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #1446):
sys/arch/amd64/amd64/trap.c: revision 1.94
sys/arch/i386/i386/trap.c: revision 1.287
Mmh, allow iret to be handled when an #SS fault (T_STKFLT) happens. Even
if the sdm is far from being clear, it appears that iret can trigger an #SS
fault if %ss points to a writable but non-present segment; in which case
the kernel would panic, thinking the fault was internal to it.
In particular, userland can create a broken segment in the ldt with
USER_LDT, update its %ss with setcontext and trigger the panic. I don't
think amd64 is affected since USER_LDT does not exist there, and the
changes on tf_ss seem correct - but I'm still adding T_STKFLT for safety.


To generate a diff of this commit:
cvs rdiff -u -r1.69.2.1 -r1.69.2.2 src/sys/arch/amd64/amd64/trap.c
cvs rdiff -u -r1.262 -r1.262.8.1 src/sys/arch/i386/i386/trap.c

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



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

2017-03-25 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sat Mar 25 16:59:46 UTC 2017

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

Log Message:
1391


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.35 -r1.1.2.36 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.35 src/doc/CHANGES-7.0.3:1.1.2.36
--- src/doc/CHANGES-7.0.3:1.1.2.35	Mon Mar 20 10:55:38 2017
+++ src/doc/CHANGES-7.0.3	Sat Mar 25 16:59:46 2017
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-7.0.3,v 1.1.2.35 2017/03/20 10:55:38 martin Exp $
+# $NetBSD: CHANGES-7.0.3,v 1.1.2.36 2017/03/25 16:59:46 snj Exp $
 
 A complete list of changes from the NetBSD 7.0.2 release to the NetBSD 7.0.3
 release:
@@ -1501,3 +1501,9 @@ external/bsd/ntp/scripts/mkver  
 	Update ntp to 4.2.8p9.
 	[snj, ticket #1389]
 
+sys/arch/amd64/amd64/trap.c			1.94
+sys/arch/i386/i386/trap.c			1.287
+
+	Handle #SS faults on iret properly.
+	[maxv, ticket #1391]
+



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

2017-03-25 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sat Mar 25 16:59:01 UTC 2017

Modified Files:
src/sys/arch/amd64/amd64 [netbsd-7-0]: trap.c
src/sys/arch/i386/i386 [netbsd-7-0]: trap.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #1391):
sys/arch/amd64/amd64/trap.c: revision 1.94
sys/arch/i386/i386/trap.c: revision 1.287
Mmh, allow iret to be handled when an #SS fault (T_STKFLT) happens. Even
if the sdm is far from being clear, it appears that iret can trigger an #SS
fault if %ss points to a writable but non-present segment; in which case
the kernel would panic, thinking the fault was internal to it.
In particular, userland can create a broken segment in the ldt with
USER_LDT, update its %ss with setcontext and trigger the panic. I don't
think amd64 is affected since USER_LDT does not exist there, and the
changes on tf_ss seem correct - but I'm still adding T_STKFLT for safety.


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.78.6.1 src/sys/arch/amd64/amd64/trap.c
cvs rdiff -u -r1.272 -r1.272.6.1 src/sys/arch/i386/i386/trap.c

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



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

2017-03-25 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sat Mar 25 16:59:01 UTC 2017

Modified Files:
src/sys/arch/amd64/amd64 [netbsd-7-0]: trap.c
src/sys/arch/i386/i386 [netbsd-7-0]: trap.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #1391):
sys/arch/amd64/amd64/trap.c: revision 1.94
sys/arch/i386/i386/trap.c: revision 1.287
Mmh, allow iret to be handled when an #SS fault (T_STKFLT) happens. Even
if the sdm is far from being clear, it appears that iret can trigger an #SS
fault if %ss points to a writable but non-present segment; in which case
the kernel would panic, thinking the fault was internal to it.
In particular, userland can create a broken segment in the ldt with
USER_LDT, update its %ss with setcontext and trigger the panic. I don't
think amd64 is affected since USER_LDT does not exist there, and the
changes on tf_ss seem correct - but I'm still adding T_STKFLT for safety.


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.78.6.1 src/sys/arch/amd64/amd64/trap.c
cvs rdiff -u -r1.272 -r1.272.6.1 src/sys/arch/i386/i386/trap.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/trap.c
diff -u src/sys/arch/amd64/amd64/trap.c:1.78 src/sys/arch/amd64/amd64/trap.c:1.78.6.1
--- src/sys/arch/amd64/amd64/trap.c:1.78	Tue Mar 11 20:54:29 2014
+++ src/sys/arch/amd64/amd64/trap.c	Sat Mar 25 16:59:01 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.78 2014/03/11 20:54:29 para Exp $	*/
+/*	$NetBSD: trap.c,v 1.78.6.1 2017/03/25 16:59:01 snj Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.78 2014/03/11 20:54:29 para Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.78.6.1 2017/03/25 16:59:01 snj Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -301,6 +301,7 @@ trap(struct trapframe *frame)
 	case T_PROTFLT:
 	case T_SEGNPFLT:
 	case T_ALIGNFLT:
+	case T_STKFLT:
 	case T_TSSFLT:
 		if (p == NULL)
 			goto we_re_toast;

Index: src/sys/arch/i386/i386/trap.c
diff -u src/sys/arch/i386/i386/trap.c:1.272 src/sys/arch/i386/i386/trap.c:1.272.6.1
--- src/sys/arch/i386/i386/trap.c:1.272	Wed Mar 12 18:59:07 2014
+++ src/sys/arch/i386/i386/trap.c	Sat Mar 25 16:59:01 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.272 2014/03/12 18:59:07 martin Exp $	*/
+/*	$NetBSD: trap.c,v 1.272.6.1 2017/03/25 16:59:01 snj Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000, 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.272 2014/03/12 18:59:07 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.272.6.1 2017/03/25 16:59:01 snj Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -349,6 +349,7 @@ trap(struct trapframe *frame)
 	case T_PROTFLT:
 	case T_SEGNPFLT:
 	case T_ALIGNFLT:
+	case T_STKFLT:
 	case T_TSSFLT:
 		if (p == NULL)
 			goto we_re_toast;



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

2017-03-25 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sat Mar 25 16:58:25 UTC 2017

Modified Files:
src/sys/arch/amd64/amd64 [netbsd-7-1]: trap.c
src/sys/arch/i386/i386 [netbsd-7-1]: trap.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #1391):
sys/arch/amd64/amd64/trap.c: revision 1.94
sys/arch/i386/i386/trap.c: revision 1.287
Mmh, allow iret to be handled when an #SS fault (T_STKFLT) happens. Even
if the sdm is far from being clear, it appears that iret can trigger an #SS
fault if %ss points to a writable but non-present segment; in which case
the kernel would panic, thinking the fault was internal to it.
In particular, userland can create a broken segment in the ldt with
USER_LDT, update its %ss with setcontext and trigger the panic. I don't
think amd64 is affected since USER_LDT does not exist there, and the
changes on tf_ss seem correct - but I'm still adding T_STKFLT for safety.


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.78.10.1 src/sys/arch/amd64/amd64/trap.c
cvs rdiff -u -r1.272 -r1.272.10.1 src/sys/arch/i386/i386/trap.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/trap.c
diff -u src/sys/arch/amd64/amd64/trap.c:1.78 src/sys/arch/amd64/amd64/trap.c:1.78.10.1
--- src/sys/arch/amd64/amd64/trap.c:1.78	Tue Mar 11 20:54:29 2014
+++ src/sys/arch/amd64/amd64/trap.c	Sat Mar 25 16:58:24 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.78 2014/03/11 20:54:29 para Exp $	*/
+/*	$NetBSD: trap.c,v 1.78.10.1 2017/03/25 16:58:24 snj Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.78 2014/03/11 20:54:29 para Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.78.10.1 2017/03/25 16:58:24 snj Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -301,6 +301,7 @@ trap(struct trapframe *frame)
 	case T_PROTFLT:
 	case T_SEGNPFLT:
 	case T_ALIGNFLT:
+	case T_STKFLT:
 	case T_TSSFLT:
 		if (p == NULL)
 			goto we_re_toast;

Index: src/sys/arch/i386/i386/trap.c
diff -u src/sys/arch/i386/i386/trap.c:1.272 src/sys/arch/i386/i386/trap.c:1.272.10.1
--- src/sys/arch/i386/i386/trap.c:1.272	Wed Mar 12 18:59:07 2014
+++ src/sys/arch/i386/i386/trap.c	Sat Mar 25 16:58:25 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.272 2014/03/12 18:59:07 martin Exp $	*/
+/*	$NetBSD: trap.c,v 1.272.10.1 2017/03/25 16:58:25 snj Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000, 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.272 2014/03/12 18:59:07 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.272.10.1 2017/03/25 16:58:25 snj Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -349,6 +349,7 @@ trap(struct trapframe *frame)
 	case T_PROTFLT:
 	case T_SEGNPFLT:
 	case T_ALIGNFLT:
+	case T_STKFLT:
 	case T_TSSFLT:
 		if (p == NULL)
 			goto we_re_toast;



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

2017-03-25 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sat Mar 25 16:58:41 UTC 2017

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

Log Message:
1391


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.2 -r1.1.2.3 src/doc/CHANGES-7.1.1

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.1
diff -u src/doc/CHANGES-7.1.1:1.1.2.2 src/doc/CHANGES-7.1.1:1.1.2.3
--- src/doc/CHANGES-7.1.1:1.1.2.2	Mon Mar 20 10:58:16 2017
+++ src/doc/CHANGES-7.1.1	Sat Mar 25 16:58:41 2017
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-7.1.1,v 1.1.2.2 2017/03/20 10:58:16 martin Exp $
+# $NetBSD: CHANGES-7.1.1,v 1.1.2.3 2017/03/25 16:58:41 snj Exp $
 
 A complete list of changes from the NetBSD 7.1 release to the NetBSD 7.1.1
 release:
@@ -194,3 +194,9 @@ external/bsd/ntp/scripts/mkver  
 	Update ntp to 4.2.8p9.
 	[snj, ticket #1389]
 
+sys/arch/amd64/amd64/trap.c			1.94
+sys/arch/i386/i386/trap.c			1.287
+
+	Handle #SS faults on iret properly.
+	[maxv, ticket #1391]
+



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

2017-03-25 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sat Mar 25 16:58:25 UTC 2017

Modified Files:
src/sys/arch/amd64/amd64 [netbsd-7-1]: trap.c
src/sys/arch/i386/i386 [netbsd-7-1]: trap.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #1391):
sys/arch/amd64/amd64/trap.c: revision 1.94
sys/arch/i386/i386/trap.c: revision 1.287
Mmh, allow iret to be handled when an #SS fault (T_STKFLT) happens. Even
if the sdm is far from being clear, it appears that iret can trigger an #SS
fault if %ss points to a writable but non-present segment; in which case
the kernel would panic, thinking the fault was internal to it.
In particular, userland can create a broken segment in the ldt with
USER_LDT, update its %ss with setcontext and trigger the panic. I don't
think amd64 is affected since USER_LDT does not exist there, and the
changes on tf_ss seem correct - but I'm still adding T_STKFLT for safety.


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.78.10.1 src/sys/arch/amd64/amd64/trap.c
cvs rdiff -u -r1.272 -r1.272.10.1 src/sys/arch/i386/i386/trap.c

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



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

2017-03-25 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sat Mar 25 16:58:41 UTC 2017

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

Log Message:
1391


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.2 -r1.1.2.3 src/doc/CHANGES-7.1.1

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



CVS commit: [netbsd-7] src/doc

2017-03-25 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sat Mar 25 16:58:10 UTC 2017

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

Log Message:
1391


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.3 -r1.1.2.4 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.3 src/doc/CHANGES-7.2:1.1.2.4
--- src/doc/CHANGES-7.2:1.1.2.3	Mon Mar 20 11:01:22 2017
+++ src/doc/CHANGES-7.2	Sat Mar 25 16:58:10 2017
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-7.2,v 1.1.2.3 2017/03/20 11:01:22 martin Exp $
+# $NetBSD: CHANGES-7.2,v 1.1.2.4 2017/03/25 16:58:10 snj Exp $
 
 A complete list of changes from the NetBSD 7.1 release to the NetBSD 7.2
 release:
@@ -214,3 +214,9 @@ external/bsd/ntp/scripts/mkver  
 	Update ntp to 4.2.8p9.
 	[snj, ticket #1389]
 
+sys/arch/amd64/amd64/trap.c			1.94
+sys/arch/i386/i386/trap.c			1.287
+
+	Handle #SS faults on iret properly.
+	[maxv, ticket #1391]
+



CVS commit: [netbsd-7] src/doc

2017-03-25 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sat Mar 25 16:58:10 UTC 2017

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

Log Message:
1391


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

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



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

2017-03-25 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sat Mar 25 16:57:40 UTC 2017

Modified Files:
src/sys/arch/amd64/amd64 [netbsd-7]: trap.c
src/sys/arch/i386/i386 [netbsd-7]: trap.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #1391):
sys/arch/amd64/amd64/trap.c: revision 1.94
sys/arch/i386/i386/trap.c: revision 1.287
Mmh, allow iret to be handled when an #SS fault (T_STKFLT) happens. Even
if the sdm is far from being clear, it appears that iret can trigger an #SS
fault if %ss points to a writable but non-present segment; in which case
the kernel would panic, thinking the fault was internal to it.
In particular, userland can create a broken segment in the ldt with
USER_LDT, update its %ss with setcontext and trigger the panic. I don't
think amd64 is affected since USER_LDT does not exist there, and the
changes on tf_ss seem correct - but I'm still adding T_STKFLT for safety.


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.78.4.1 src/sys/arch/amd64/amd64/trap.c
cvs rdiff -u -r1.272 -r1.272.4.1 src/sys/arch/i386/i386/trap.c

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



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

2017-03-25 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sat Mar 25 16:57:40 UTC 2017

Modified Files:
src/sys/arch/amd64/amd64 [netbsd-7]: trap.c
src/sys/arch/i386/i386 [netbsd-7]: trap.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #1391):
sys/arch/amd64/amd64/trap.c: revision 1.94
sys/arch/i386/i386/trap.c: revision 1.287
Mmh, allow iret to be handled when an #SS fault (T_STKFLT) happens. Even
if the sdm is far from being clear, it appears that iret can trigger an #SS
fault if %ss points to a writable but non-present segment; in which case
the kernel would panic, thinking the fault was internal to it.
In particular, userland can create a broken segment in the ldt with
USER_LDT, update its %ss with setcontext and trigger the panic. I don't
think amd64 is affected since USER_LDT does not exist there, and the
changes on tf_ss seem correct - but I'm still adding T_STKFLT for safety.


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.78.4.1 src/sys/arch/amd64/amd64/trap.c
cvs rdiff -u -r1.272 -r1.272.4.1 src/sys/arch/i386/i386/trap.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/trap.c
diff -u src/sys/arch/amd64/amd64/trap.c:1.78 src/sys/arch/amd64/amd64/trap.c:1.78.4.1
--- src/sys/arch/amd64/amd64/trap.c:1.78	Tue Mar 11 20:54:29 2014
+++ src/sys/arch/amd64/amd64/trap.c	Sat Mar 25 16:57:39 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.78 2014/03/11 20:54:29 para Exp $	*/
+/*	$NetBSD: trap.c,v 1.78.4.1 2017/03/25 16:57:39 snj Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.78 2014/03/11 20:54:29 para Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.78.4.1 2017/03/25 16:57:39 snj Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -301,6 +301,7 @@ trap(struct trapframe *frame)
 	case T_PROTFLT:
 	case T_SEGNPFLT:
 	case T_ALIGNFLT:
+	case T_STKFLT:
 	case T_TSSFLT:
 		if (p == NULL)
 			goto we_re_toast;

Index: src/sys/arch/i386/i386/trap.c
diff -u src/sys/arch/i386/i386/trap.c:1.272 src/sys/arch/i386/i386/trap.c:1.272.4.1
--- src/sys/arch/i386/i386/trap.c:1.272	Wed Mar 12 18:59:07 2014
+++ src/sys/arch/i386/i386/trap.c	Sat Mar 25 16:57:40 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.272 2014/03/12 18:59:07 martin Exp $	*/
+/*	$NetBSD: trap.c,v 1.272.4.1 2017/03/25 16:57:40 snj Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000, 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.272 2014/03/12 18:59:07 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.272.4.1 2017/03/25 16:57:40 snj Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -349,6 +349,7 @@ trap(struct trapframe *frame)
 	case T_PROTFLT:
 	case T_SEGNPFLT:
 	case T_ALIGNFLT:
+	case T_STKFLT:
 	case T_TSSFLT:
 		if (p == NULL)
 			goto we_re_toast;



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

2017-03-25 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Mar 25 15:07:21 UTC 2017

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

Log Message:
Don't need gdtstore here.


To generate a diff of this commit:
cvs rdiff -u -r1.122 -r1.123 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.122 src/sys/arch/amd64/amd64/locore.S:1.123
--- src/sys/arch/amd64/amd64/locore.S:1.122	Thu Mar 23 17:25:51 2017
+++ src/sys/arch/amd64/amd64/locore.S	Sat Mar 25 15:07:21 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.122 2017/03/23 17:25:51 maxv Exp $	*/
+/*	$NetBSD: locore.S,v 1.123 2017/03/25 15:07:21 maxv Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -329,7 +329,6 @@
 	.globl	_C_LABEL(bootinfo)
 	.globl	_C_LABEL(biosbasemem)
 	.globl	_C_LABEL(biosextmem)
-	.globl	_C_LABEL(gdtstore)
 
 	.type	_C_LABEL(tablesize), @object
 _C_LABEL(tablesize):	.long	TABLESIZE



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

2017-03-25 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Mar 25 15:07:21 UTC 2017

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

Log Message:
Don't need gdtstore here.


To generate a diff of this commit:
cvs rdiff -u -r1.122 -r1.123 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.



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

2017-03-25 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Mar 25 15:05:16 UTC 2017

Modified Files:
src/sys/arch/amd64/amd64: gdt.c

Log Message:
Use a bitmap-based allocator, will be easier to share with i386.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/arch/amd64/amd64/gdt.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/gdt.c
diff -u src/sys/arch/amd64/amd64/gdt.c:1.37 src/sys/arch/amd64/amd64/gdt.c:1.38
--- src/sys/arch/amd64/amd64/gdt.c:1.37	Wed Feb  8 18:50:51 2017
+++ src/sys/arch/amd64/amd64/gdt.c	Sat Mar 25 15:05:16 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: gdt.c,v 1.37 2017/02/08 18:50:51 kre Exp $	*/
+/*	$NetBSD: gdt.c,v 1.38 2017/03/25 15:05:16 maxv Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 2009 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gdt.c,v 1.37 2017/02/08 18:50:51 kre Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gdt.c,v 1.38 2017/03/25 15:05:16 maxv Exp $");
 
 #include "opt_multiprocessor.h"
 #include "opt_xen.h"
@@ -57,16 +57,20 @@ __KERNEL_RCSID(0, "$NetBSD: gdt.c,v 1.37
 #include 
 #endif
 
-int gdt_size;		/* size of GDT in bytes */
-int gdt_dyncount;	/* number of dyn. allocated GDT entries in use */
-int gdt_dynavail;
-int gdt_next;		/* next available slot for sweeping */
-int gdt_free;		/* next free slot; terminated with GNULL_SEL */
+#define NDYNSLOTS \
+	((MAXGDTSIZ - DYNSEL_START) / sizeof(struct sys_segment_descriptor))
+
+typedef struct {
+	bool busy[NDYNSLOTS];
+	size_t nslots;
+} gdt_bitmap_t;
+
+size_t gdt_size;			/* size of GDT in bytes */		
+static gdt_bitmap_t gdt_bitmap;		/* bitmap of busy slots */
 
 #if defined(USER_LDT) || !defined(XEN)
 static void set_sys_gdt(int, void *, size_t, int, int, int);
 #endif
-void gdt_init(void);
 
 void
 update_descriptor(void *tp, void *ep)
@@ -83,7 +87,7 @@ update_descriptor(void *tp, void *ep)
 
 	if (!pmap_extract_ma(pmap_kernel(), (vaddr_t)table, ) ||
 	HYPERVISOR_update_descriptor(pa, *entry))
-		panic("HYPERVISOR_update_descriptor failed\n");
+		panic("HYPERVISOR_update_descriptor failed");
 #endif
 }
 
@@ -124,11 +128,10 @@ gdt_init(void)
 	vaddr_t va;
 	struct cpu_info *ci = _info_primary;
 
+	/* Initialize the global values */
 	gdt_size = MINGDTSIZ;
-	gdt_dyncount = 0;
-	gdt_next = 0;
-	gdt_free = GNULL_SEL;
-	gdt_dynavail =
+	memset(_bitmap.busy, 0, sizeof(gdt_bitmap.busy));
+	gdt_bitmap.nslots =
 	(gdt_size - DYNSEL_START) / sizeof(struct sys_segment_descriptor);
 
 	old_gdt = gdtstore;
@@ -228,10 +231,10 @@ gdt_grow(void)
 	vaddr_t va;
 
 	old_size = gdt_size;
-	gdt_size <<= 1;
+	gdt_size *= 2;
 	if (gdt_size > MAXGDTSIZ)
 		gdt_size = MAXGDTSIZ;
-	gdt_dynavail =
+	gdt_bitmap.nslots =
 	(gdt_size - DYNSEL_START) / sizeof(struct sys_segment_descriptor);
 
 	for (CPU_INFO_FOREACH(cii, ci)) {
@@ -250,57 +253,34 @@ gdt_grow(void)
 	pmap_update(pmap_kernel());
 }
 
-/*
- * Allocate a GDT slot as follows:
- * 1) If there are entries on the free list, use those.
- * 2) If there are fewer than gdt_dynavail entries in use, there are free slots
- *near the end that we can sweep through.
- * 3) As a last resort, we increase the size of the GDT, and sweep through
- *the new slots.
- */
 static int
 gdt_get_slot(void)
 {
-	int slot;
-	struct sys_segment_descriptor *gdt;
-
-	gdt = (struct sys_segment_descriptor *)[DYNSEL_START];
+	size_t i;
 
 	KASSERT(mutex_owned(_lock));
 
-	if (gdt_free != GNULL_SEL) {
-		slot = gdt_free;
-		gdt_free = gdt[slot].sd_xx3;	/* XXXfvdl res. field abuse */
-	} else {
-		KASSERT(gdt_next == gdt_dyncount);
-		if (gdt_next >= gdt_dynavail) {
-			if (gdt_size >= MAXGDTSIZ)
-panic("gdt_get_slot: out of memory");
-			gdt_grow();
+	while (1) {
+		for (i = 0; i < gdt_bitmap.nslots; i++) {
+			if (!gdt_bitmap.busy[i]) {
+gdt_bitmap.busy[i] = true;
+return (int)i;
+			}
 		}
-		slot = gdt_next++;
+		if (gdt_size >= MAXGDTSIZ)
+			panic("gdt_get_slot: out of memory");
+		gdt_grow();
 	}
-
-	gdt_dyncount++;
-	return slot;
+	/* NOTREACHED */
+	return 0;
 }
 
-/*
- * Deallocate a GDT slot, putting it on the free list.
- */
 static void
 gdt_put_slot(int slot)
 {
-	struct sys_segment_descriptor *gdt;
-
 	KASSERT(mutex_owned(_lock));
-
-	gdt = (struct sys_segment_descriptor *)[DYNSEL_START];
-
-	gdt_dyncount--;
-	gdt[slot].sd_type = SDT_SYSNULL;
-	gdt[slot].sd_xx3 = gdt_free;
-	gdt_free = slot;
+	KASSERT(slot < gdt_bitmap.nslots);
+	gdt_bitmap.busy[slot] = false;
 }
 #endif
 
@@ -319,7 +299,7 @@ tss_alloc(struct x86_64_tss *tss)
 	mutex_exit(_lock);
 
 	return GDYNSEL(slot, SEL_KPL);
-#else  /* XEN */
+#else
 	/* TSS, what for? */
 	return GSEL(GNULL_SEL, SEL_KPL);
 #endif
@@ -338,9 +318,6 @@ tss_free(int sel)
 }
 
 #ifdef USER_LDT
-/*
- * XXX: USER_LDT is not implemented on amd64.
- */
 int
 ldt_alloc(void *ldtp, size_t len)
 {
@@ -380,25 +357,19 @@ lgdt(struct region_descriptor *desc)
 	 * Zero out 

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

2017-03-25 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Mar 25 15:05:16 UTC 2017

Modified Files:
src/sys/arch/amd64/amd64: gdt.c

Log Message:
Use a bitmap-based allocator, will be easier to share with i386.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/arch/amd64/amd64/gdt.c

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



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

2017-03-25 Thread Maxime Villard

e 24/03/2017 à 21:32, co...@sdf.org a écrit :

cool!

I see in arch/i386/i386/locore.S that there is another call gate and
there's:

1246 IDTVEC(osyscall)
1247 #ifndef XEN
1248 /* XXX we are in trouble! interrupts be off here. */
1249 cli /* must be first instruction */
1250 #endif
1251 pushfl  /* set eflags in trap frame */

Is 'cli' as first instruction what should've been done here, if it
wasn't been otherwise useless? can xen not do it?


Yes, I saw that too. In fact, I didn't understand how putting 'cli' fixed
the issue, since an interrupt can still happen before this instruction.
Given that it was committed by ad@, he probably must have thought about
this too; so it perhaps means that call gates on i386 disable interrupt for
the first instruction or something like that, but I was unable to find any
reference to this in the SDMs.

For Xen, there is no documentation, so if you want to find out what happens
you need to dig into the Xen source code. As far as I can test, it seems
that Xen disables interrupts on call gates.

There is still at least one bug here: now that pushfl is the second
instruction, the first two single-steps should be ignored, and this [1]
branch should be 'osyscall + 2', otherwise we may unintentionnally disable
single-stepping when returing to userland.

[1] https://nxr.netbsd.org/xref/src/sys/arch/i386/i386/trap.c#716


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

2017-03-25 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Mar 25 13:24:08 UTC 2017

Modified Files:
src/sys/arch/sparc64/conf: GENERIC

Log Message:
Add virtio PCI devices, some of them mostly untested so far


To generate a diff of this commit:
cvs rdiff -u -r1.197 -r1.198 src/sys/arch/sparc64/conf/GENERIC

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



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

2017-03-25 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Mar 25 13:24:08 UTC 2017

Modified Files:
src/sys/arch/sparc64/conf: GENERIC

Log Message:
Add virtio PCI devices, some of them mostly untested so far


To generate a diff of this commit:
cvs rdiff -u -r1.197 -r1.198 src/sys/arch/sparc64/conf/GENERIC

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/sparc64/conf/GENERIC
diff -u src/sys/arch/sparc64/conf/GENERIC:1.197 src/sys/arch/sparc64/conf/GENERIC:1.198
--- src/sys/arch/sparc64/conf/GENERIC:1.197	Thu Mar 23 11:00:03 2017
+++ src/sys/arch/sparc64/conf/GENERIC	Sat Mar 25 13:24:08 2017
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.197 2017/03/23 11:00:03 martin Exp $
+# $NetBSD: GENERIC,v 1.198 2017/03/25 13:24:08 martin Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@ include 	"arch/sparc64/conf/std.sparc64"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident		"GENERIC-$Revision: 1.197 $"
+#ident		"GENERIC-$Revision: 1.198 $"
 
 maxusers	64
 
@@ -424,6 +424,15 @@ ld*	at cac? unit ?			# logical disk devi
 ld*	at twe? unit ?
 ld*	at mlx? unit ?
 
+# Virtio devices
+virtio* at pci? dev ? function ?	# Virtio PCI device
+# the baloon driver can not work on machines with non-4k pages
+#viomb*	at virtio?			# Virtio memory balloon device
+ld*	at virtio?			# Virtio disk device
+vioif*	at virtio?			# Virtio network device
+viornd* at virtio?			# Virtio entropy device
+vioscsi* at virtio?			# Virtio SCSI device
+
 ## Floppy controller and drive found on SPARCstations.
 
 # need share with the sparc, and everyone else.  needs to use auxio.



CVS commit: src/sys/arch/sparc64/sparc64

2017-03-25 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Mar 25 13:08:38 UTC 2017

Modified Files:
src/sys/arch/sparc64/sparc64: autoconf.c

Log Message:
Add boot device recognition for ld @ virtio.


To generate a diff of this commit:
cvs rdiff -u -r1.208 -r1.209 src/sys/arch/sparc64/sparc64/autoconf.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/sparc64/sparc64/autoconf.c
diff -u src/sys/arch/sparc64/sparc64/autoconf.c:1.208 src/sys/arch/sparc64/sparc64/autoconf.c:1.209
--- src/sys/arch/sparc64/sparc64/autoconf.c:1.208	Fri Aug 19 19:02:07 2016
+++ src/sys/arch/sparc64/sparc64/autoconf.c	Sat Mar 25 13:08:38 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.208 2016/08/19 19:02:07 palle Exp $ */
+/*	$NetBSD: autoconf.c,v 1.209 2017/03/25 13:08:38 martin Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.208 2016/08/19 19:02:07 palle Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.209 2017/03/25 13:08:38 martin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -97,6 +97,7 @@ __KERNEL_RCSID(0, "$NetBSD: autoconf.c,v
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -931,6 +932,10 @@ device_register(device_t dev, void *aux)
 		struct pci_attach_args *pa = aux;
 
 		ofnode = PCITAG_NODE(pa->pa_tag);
+	} else if (device_is_a(busdev, "virtio")) {
+		struct virtio_softc *va = aux;
+
+		ofnode = PCITAG_NODE(va->sc_pa.pa_tag);
 	} else if (device_is_a(busdev, "sbus") || device_is_a(busdev, "dma")
 	|| device_is_a(busdev, "ledma")) {
 		struct sbus_attach_args *sa = aux;



CVS commit: src/sys/arch/sparc64/sparc64

2017-03-25 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Mar 25 13:08:38 UTC 2017

Modified Files:
src/sys/arch/sparc64/sparc64: autoconf.c

Log Message:
Add boot device recognition for ld @ virtio.


To generate a diff of this commit:
cvs rdiff -u -r1.208 -r1.209 src/sys/arch/sparc64/sparc64/autoconf.c

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



CVS commit: src/sys/dev/pci

2017-03-25 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Mar 25 13:05:09 UTC 2017

Modified Files:
src/sys/dev/pci: virtio.c

Log Message:
PR kern/52107: for now (while we still use the legacy virtio spec) at least
hack around the endianess issues with that.


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

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



CVS commit: src/sys/dev/pci

2017-03-25 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Mar 25 13:05:09 UTC 2017

Modified Files:
src/sys/dev/pci: virtio.c

Log Message:
PR kern/52107: for now (while we still use the legacy virtio spec) at least
hack around the endianess issues with that.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/dev/pci/virtio.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/pci/virtio.c
diff -u src/sys/dev/pci/virtio.c:1.19 src/sys/dev/pci/virtio.c:1.20
--- src/sys/dev/pci/virtio.c:1.19	Tue Nov 29 22:04:42 2016
+++ src/sys/dev/pci/virtio.c	Sat Mar 25 13:05:09 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: virtio.c,v 1.19 2016/11/29 22:04:42 uwe Exp $	*/
+/*	$NetBSD: virtio.c,v 1.20 2017/03/25 13:05:09 martin Exp $	*/
 
 /*
  * Copyright (c) 2010 Minoura Makoto.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: virtio.c,v 1.19 2016/11/29 22:04:42 uwe Exp $");
+__KERNEL_RCSID(0, "$NetBSD: virtio.c,v 1.20 2017/03/25 13:05:09 martin Exp $");
 
 #include 
 #include 
@@ -67,6 +67,45 @@ CFATTACH_DECL3_NEW(virtio, sizeof(struct
 virtio_match, virtio_attach, virtio_detach, NULL, virtio_rescan, NULL,
 DVF_DETACH_SHUTDOWN);
 
+/* we use the legacy virtio spec, so the pci registers are host native
+ * byte order, not pci (i.e. LE) byte order */
+static inline uint16_t
+nbo_bus_space_read_2(bus_space_tag_t space, bus_space_handle_t handle,
+ bus_size_t offset)
+{
+	return le16toh(bus_space_read_2(space, handle, offset));
+}
+
+static inline uint32_t
+nbo_bus_space_read_4(bus_space_tag_t space, bus_space_handle_t handle,
+	bus_size_t offset)
+{
+	return le32toh(bus_space_read_4(space, handle, offset));
+}
+
+static void
+nbo_bus_space_write_2(bus_space_tag_t space, bus_space_handle_t handle,
+	bus_size_t offset, uint16_t value)
+{
+	bus_space_write_2(space, handle, offset, htole16(value));
+}
+
+static void
+nbo_bus_space_write_4(bus_space_tag_t space, bus_space_handle_t handle,
+	bus_size_t offset, uint16_t value)
+{
+	bus_space_write_4(space, handle, offset, htole32(value));
+}
+
+/* some functions access registers at 4 byte offset for little/high halves */
+#if BYTE_ORDER == BIG_ENDIAN
+#define REG_HI_OFF	0
+#define	REG_LO_OFF	4
+#else
+#define REG_HI_OFF	4
+#define	REG_LO_OFF	0
+#endif
+
 static void
 virtio_set_status(struct virtio_softc *sc, int status)
 {
@@ -126,8 +165,8 @@ virtio_setup_msix_vectors(struct virtio_
 	offset = VIRTIO_CONFIG_MSI_CONFIG_VECTOR;
 	vector = VIRTIO_MSIX_CONFIG_VECTOR_INDEX;
 
-	bus_space_write_2(sc->sc_iot, sc->sc_ioh, offset, vector);
-	ret = bus_space_read_2(sc->sc_iot, sc->sc_ioh, offset);
+	nbo_bus_space_write_2(sc->sc_iot, sc->sc_ioh, offset, vector);
+	ret = nbo_bus_space_read_2(sc->sc_iot, sc->sc_ioh, offset);
 	aprint_debug_dev(sc->sc_dev, "expected=%d, actual=%d\n",
 	vector, ret);
 	if (ret != vector)
@@ -135,13 +174,13 @@ virtio_setup_msix_vectors(struct virtio_
 
 	for (qid = 0; qid < sc->sc_nvqs; qid++) {
 		offset = VIRTIO_CONFIG_QUEUE_SELECT;
-		bus_space_write_2(sc->sc_iot, sc->sc_ioh, offset, qid);
+		nbo_bus_space_write_2(sc->sc_iot, sc->sc_ioh, offset, qid);
 
 		offset = VIRTIO_CONFIG_MSI_QUEUE_VECTOR;
 		vector = VIRTIO_MSIX_QUEUE_VECTOR_INDEX;
 
-		bus_space_write_2(sc->sc_iot, sc->sc_ioh, offset, vector);
-		ret = bus_space_read_2(sc->sc_iot, sc->sc_ioh, offset);
+		nbo_bus_space_write_2(sc->sc_iot, sc->sc_ioh, offset, vector);
+		ret = nbo_bus_space_read_2(sc->sc_iot, sc->sc_ioh, offset);
 		aprint_debug_dev(sc->sc_dev, "expected=%d, actual=%d\n",
 		vector, ret);
 		if (ret != vector)
@@ -473,10 +512,10 @@ virtio_reinit_start(struct virtio_softc 
 	for (i = 0; i < sc->sc_nvqs; i++) {
 		int n;
 		struct virtqueue *vq = >sc_vqs[i];
-		bus_space_write_2(sc->sc_iot, sc->sc_ioh,
+		nbo_bus_space_write_2(sc->sc_iot, sc->sc_ioh,
   VIRTIO_CONFIG_QUEUE_SELECT,
   vq->vq_index);
-		n = bus_space_read_2(sc->sc_iot, sc->sc_ioh,
+		n = nbo_bus_space_read_2(sc->sc_iot, sc->sc_ioh,
  VIRTIO_CONFIG_QUEUE_SIZE);
 		if (n == 0)	/* vq disappeared */
 			continue;
@@ -486,7 +525,7 @@ virtio_reinit_start(struct virtio_softc 
 			  vq->vq_index);
 		}
 		virtio_init_vq(sc, vq, true);
-		bus_space_write_4(sc->sc_iot, sc->sc_ioh,
+		nbo_bus_space_write_4(sc->sc_iot, sc->sc_ioh,
   VIRTIO_CONFIG_QUEUE_ADDRESS,
   (vq->vq_dmamap->dm_segs[0].ds_addr
    / VIRTIO_PAGE_SIZE));
@@ -519,10 +558,10 @@ virtio_negotiate_features(struct virtio_
 	if (!(device_cfdata(sc->sc_dev)->cf_flags & 1) &&
 	!(device_cfdata(sc->sc_child)->cf_flags & 1)) /* XXX */
 		guest_features |= VIRTIO_F_RING_INDIRECT_DESC;
-	r = bus_space_read_4(sc->sc_iot, sc->sc_ioh,
+	r = nbo_bus_space_read_4(sc->sc_iot, sc->sc_ioh,
 			 VIRTIO_CONFIG_DEVICE_FEATURES);
 	r &= guest_features;
-	bus_space_write_4(sc->sc_iot, sc->sc_ioh,
+	nbo_bus_space_write_4(sc->sc_iot, sc->sc_ioh,
 			  VIRTIO_CONFIG_GUEST_FEATURES, r);
 	

CVS commit: src/usr.sbin/npf/npfd

2017-03-25 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Mar 25 11:00:27 UTC 2017

Modified Files:
src/usr.sbin/npf/npfd: npfd_log.c

Log Message:
can't call pcap_datalink before activate.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/usr.sbin/npf/npfd/npfd_log.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/npf/npfd/npfd_log.c
diff -u src/usr.sbin/npf/npfd/npfd_log.c:1.9 src/usr.sbin/npf/npfd/npfd_log.c:1.10
--- src/usr.sbin/npf/npfd/npfd_log.c:1.9	Tue Jan 24 15:25:08 2017
+++ src/usr.sbin/npf/npfd/npfd_log.c	Sat Mar 25 07:00:27 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: npfd_log.c,v 1.9 2017/01/24 20:25:08 christos Exp $	*/
+/*	$NetBSD: npfd_log.c,v 1.10 2017/03/25 11:00:27 christos Exp $	*/
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: npfd_log.c,v 1.9 2017/01/24 20:25:08 christos Exp $");
+__RCSID("$NetBSD: npfd_log.c,v 1.10 2017/03/25 11:00:27 christos Exp $");
 
 #include 
 #include 
@@ -91,7 +91,6 @@ npfd_log_gethdr(npfd_log_t *ctx, struct 
 		if (hdr->magic != TCPDUMP_MAGIC ||
 		hdr->version_major != PCAP_VERSION_MAJOR ||
 		hdr->version_minor != PCAP_VERSION_MINOR ||
-		hdr->linktype != (u_int)pcap_datalink(ctx->pcap) ||
 		hdr->sigfigs != (u_int)pcap_get_tstamp_precision(ctx->pcap))
 			goto out;
 		break;



CVS commit: src/usr.sbin/npf/npfd

2017-03-25 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Mar 25 11:00:27 UTC 2017

Modified Files:
src/usr.sbin/npf/npfd: npfd_log.c

Log Message:
can't call pcap_datalink before activate.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/usr.sbin/npf/npfd/npfd_log.c

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



CVS commit: src/tests/kernel

2017-03-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Mar 25 10:07:55 UTC 2017

Modified Files:
src/tests/kernel: t_ptrace_wait.c

Log Message:
kern/52012 kern/52018 kern/52019 were all fixed by christos


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 src/tests/kernel/t_ptrace_wait.c

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



CVS commit: src/tests/kernel

2017-03-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Mar 25 10:07:55 UTC 2017

Modified Files:
src/tests/kernel: t_ptrace_wait.c

Log Message:
kern/52012 kern/52018 kern/52019 were all fixed by christos


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 src/tests/kernel/t_ptrace_wait.c

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

Modified files:

Index: src/tests/kernel/t_ptrace_wait.c
diff -u src/tests/kernel/t_ptrace_wait.c:1.77 src/tests/kernel/t_ptrace_wait.c:1.78
--- src/tests/kernel/t_ptrace_wait.c:1.77	Fri Mar  3 12:23:26 2017
+++ src/tests/kernel/t_ptrace_wait.c	Sat Mar 25 10:07:55 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.c,v 1.77 2017/03/03 12:23:26 kre Exp $	*/
+/*	$NetBSD: t_ptrace_wait.c,v 1.78 2017/03/25 10:07:55 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.77 2017/03/03 12:23:26 kre Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.78 2017/03/25 10:07:55 skrll Exp $");
 
 #include 
 #include 
@@ -7422,8 +7422,6 @@ ATF_TC_BODY(syscall1, tc)
 	struct ptrace_siginfo info;
 	memset(, 0, sizeof(info));
 
-	atf_tc_expect_fail("PR kern/52012 PR kern/52018 PR kern/52019");
-
 	printf("Before forking process PID=%d\n", getpid());
 	ATF_REQUIRE((child = fork()) != -1);
 	if (child == 0) {
@@ -7505,8 +7503,6 @@ ATF_TC_BODY(syscallemu1, tc)
 	int status;
 #endif
 
-	atf_tc_expect_fail("PR kern/52012");
-
 	printf("Before forking process PID=%d\n", getpid());
 	ATF_REQUIRE((child = fork()) != -1);
 	if (child == 0) {



CVS commit: src/sys

2017-03-25 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Mar 25 09:21:21 UTC 2017

Modified Files:
src/sys/arch/sparc/stand/common: promdev.c
src/sys/arch/sparc/stand/ofwboot: ofdev.c
src/sys/dev/ofw: ofdisk.c

Log Message:
Virtio block devices may have a "scsi" device_type instead of "block",
so accept both.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/sparc/stand/common/promdev.c
cvs rdiff -u -r1.35 -r1.36 src/sys/arch/sparc/stand/ofwboot/ofdev.c
cvs rdiff -u -r1.51 -r1.52 src/sys/dev/ofw/ofdisk.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/sparc/stand/common/promdev.c
diff -u src/sys/arch/sparc/stand/common/promdev.c:1.27 src/sys/arch/sparc/stand/common/promdev.c:1.28
--- src/sys/arch/sparc/stand/common/promdev.c:1.27	Mon Dec 30 08:43:28 2013
+++ src/sys/arch/sparc/stand/common/promdev.c	Sat Mar 25 09:21:21 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: promdev.c,v 1.27 2013/12/30 08:43:28 martin Exp $ */
+/*	$NetBSD: promdev.c,v 1.28 2017/03/25 09:21:21 martin Exp $ */
 
 /*
  * Copyright (c) 1993 Paul Kranenburg
@@ -562,6 +562,8 @@ getdevtype(int fd, char *name)
 		cp = mygetpropstring(node, "device_type");
 		if (strcmp(cp, "block") == 0)
 			return (DT_BLOCK);
+		if (strcmp(cp, "scsi") == 0)
+			return (DT_BLOCK);
 		else if (strcmp(cp, "network") == 0)
 			return (DT_NET);
 		else if (strcmp(cp, "byte") == 0)

Index: src/sys/arch/sparc/stand/ofwboot/ofdev.c
diff -u src/sys/arch/sparc/stand/ofwboot/ofdev.c:1.35 src/sys/arch/sparc/stand/ofwboot/ofdev.c:1.36
--- src/sys/arch/sparc/stand/ofwboot/ofdev.c:1.35	Thu Feb 20 15:11:36 2014
+++ src/sys/arch/sparc/stand/ofwboot/ofdev.c	Sat Mar 25 09:21:21 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ofdev.c,v 1.35 2014/02/20 15:11:36 joerg Exp $	*/
+/*	$NetBSD: ofdev.c,v 1.36 2017/03/25 09:21:21 martin Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -94,7 +94,8 @@ filename(char *str, char *ppart)
 			 * if not, lp is the delimiter between device and
 			 * path.  if the last component was a block device.
 			 */
-			if (!strcmp(devtype, "block")) {
+			if (strcmp(devtype, "block") == 0
+			|| strcmp(devtype, "scsi") == 0) {
 /* search for arguments */
 DPRINTF(("filename: hunting for arguments "
    "in %s\n", lp));
@@ -410,7 +411,7 @@ devopen(struct open_file *of, const char
 	if (_prom_getprop(handle, "device_type", b.buf, sizeof b.buf) < 0)
 		return ENXIO;
 	DPRINTF(("devopen: %s is a %s device\n", fname, b.buf));
-	if (!strcmp(b.buf, "block")) {
+	if (strcmp(b.buf, "block") == 0 || strcmp(b.buf, "scsi") == 0) {
 		pp = strrchr(fname, ':');
 		if (pp && pp[1] >= 'a' && pp[1] <= 'f' && pp[2] == 0) {
 			savedpart = pp[1];
@@ -459,7 +460,7 @@ open_again:
 	DPRINTF(("devopen: %s is now open\n", fname));
 	memset(, 0, sizeof ofdev);
 	ofdev.handle = handle;
-	if (!strcmp(b.buf, "block")) {
+	if (strcmp(b.buf, "block") == 0 || strcmp(b.buf, "scsi") == 0) {
 		ofdev.type = OFDEV_DISK;
 		ofdev.bsize = DEV_BSIZE;
 		/* First try to find a disklabel without MBR partitions */

Index: src/sys/dev/ofw/ofdisk.c
diff -u src/sys/dev/ofw/ofdisk.c:1.51 src/sys/dev/ofw/ofdisk.c:1.52
--- src/sys/dev/ofw/ofdisk.c:1.51	Sun Apr 26 15:15:20 2015
+++ src/sys/dev/ofw/ofdisk.c	Sat Mar 25 09:21:21 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ofdisk.c,v 1.51 2015/04/26 15:15:20 mlelstv Exp $	*/
+/*	$NetBSD: ofdisk.c,v 1.52 2017/03/25 09:21:21 martin Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ofdisk.c,v 1.51 2015/04/26 15:15:20 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofdisk.c,v 1.52 2017/03/25 09:21:21 martin Exp $");
 
 #include 
 #include 
@@ -131,7 +131,7 @@ ofdisk_match(device_t parent, cfdata_t m
 	if (l >= sizeof type)
 		return 0;
 	type[l] = 0;
-	return !strcmp(type, "block");
+	return strcmp(type, "block") == 0 || strcmp(type, "scsi") == 0;
 }
 
 static void



CVS commit: src/sys/arch/sparc/stand/ofwboot

2017-03-25 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Mar 25 09:22:02 UTC 2017

Modified Files:
src/sys/arch/sparc/stand/ofwboot: version

Log Message:
Bump version - virtio support added


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/sparc/stand/ofwboot/version

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/sparc/stand/ofwboot/version
diff -u src/sys/arch/sparc/stand/ofwboot/version:1.21 src/sys/arch/sparc/stand/ofwboot/version:1.22
--- src/sys/arch/sparc/stand/ofwboot/version:1.21	Sun Jun 14 18:40:10 2015
+++ src/sys/arch/sparc/stand/ofwboot/version	Sat Mar 25 09:22:02 2017
@@ -1,4 +1,4 @@
-$NetBSD: version,v 1.21 2015/06/14 18:40:10 martin Exp $
+$NetBSD: version,v 1.22 2017/03/25 09:22:02 martin Exp $
 
 NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE.  The format of this
 file is important - make sure the entries are appended on end, last item
@@ -22,3 +22,4 @@ is taken as the current.
 1.16:	Add support to boot with root on cd9660
 1.17:	Add support for sun4v architecture
 1.18:	Fix loading of kernels with huge .bss
+1.19:	Support booting from virtio devices



CVS commit: src/sys/arch/sparc/stand/ofwboot

2017-03-25 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Mar 25 09:22:02 UTC 2017

Modified Files:
src/sys/arch/sparc/stand/ofwboot: version

Log Message:
Bump version - virtio support added


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/sparc/stand/ofwboot/version

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



CVS commit: src/sys

2017-03-25 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Mar 25 09:21:21 UTC 2017

Modified Files:
src/sys/arch/sparc/stand/common: promdev.c
src/sys/arch/sparc/stand/ofwboot: ofdev.c
src/sys/dev/ofw: ofdisk.c

Log Message:
Virtio block devices may have a "scsi" device_type instead of "block",
so accept both.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/sparc/stand/common/promdev.c
cvs rdiff -u -r1.35 -r1.36 src/sys/arch/sparc/stand/ofwboot/ofdev.c
cvs rdiff -u -r1.51 -r1.52 src/sys/dev/ofw/ofdisk.c

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



CVS commit: src/sys/dev

2017-03-25 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Sat Mar 25 07:00:33 UTC 2017

Modified Files:
src/sys/dev: vnd.c

Log Message:
Don't display step-by-step detailed error messages unless DIAGNOSTIC.

Among other things, this avoids expected "error messages" when the
module is being auto-unloaded while one or more units are still in
use.


To generate a diff of this commit:
cvs rdiff -u -r1.258 -r1.259 src/sys/dev/vnd.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/vnd.c
diff -u src/sys/dev/vnd.c:1.258 src/sys/dev/vnd.c:1.259
--- src/sys/dev/vnd.c:1.258	Fri Aug  5 08:21:24 2016
+++ src/sys/dev/vnd.c	Sat Mar 25 07:00:33 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vnd.c,v 1.258 2016/08/05 08:21:24 pgoyette Exp $	*/
+/*	$NetBSD: vnd.c,v 1.259 2017/03/25 07:00:33 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc.
@@ -91,7 +91,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.258 2016/08/05 08:21:24 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.259 2017/03/25 07:00:33 pgoyette Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_vnd.h"
@@ -2071,8 +2071,10 @@ vnd_modcmd(modcmd_t cmd, void *arg)
 		error = config_cfattach_attach(vnd_cd.cd_name, _ca);
 	if (error) {
 			config_cfdriver_detach(_cd);
+#ifdef DIAGNOSTIC
 			aprint_error("%s: unable to register cfattach for \n"
 			"%s, error %d", __func__, vnd_cd.cd_name, error);
+#endif
 			break;
 		}
 
@@ -2087,8 +2089,10 @@ vnd_modcmd(modcmd_t cmd, void *arg)
 		if (error) {
 			config_cfattach_detach(vnd_cd.cd_name, _ca);
 			config_cfdriver_detach(_cd);
+#ifdef DIAGNOSTIC
 aprint_error("%s: unable to attach %s devsw, "
 "error %d", __func__, vnd_cd.cd_name, error);
+#endif
 			break;
 		}
 #endif
@@ -2108,8 +2112,10 @@ vnd_modcmd(modcmd_t cmd, void *arg)
 if (error) { 
 (void)devsw_attach("vnd", _bdevsw, _bmajor,
 _cdevsw, _cmajor);
+#ifdef DIAGNOSTIC
 aprint_error("%s: failed to detach %s cfattach, "
 "error %d\n", __func__, vnd_cd.cd_name, error);
+#endif
 break;
 }
 error = config_cfdriver_detach(_cd);
@@ -2117,9 +2123,11 @@ vnd_modcmd(modcmd_t cmd, void *arg)
 (void)config_cfattach_attach(vnd_cd.cd_name, _ca); 
 (void)devsw_attach("vnd", _bdevsw, _bmajor,
 _cdevsw, _cmajor);
+#ifdef DIAGNOSTIC
 aprint_error("%s: failed to detach %s cfdriver, "
 "error %d\n", __func__, vnd_cd.cd_name, error);
 break;
+#endif
 }
 #endif
 		break;



CVS commit: src/sys/dev

2017-03-25 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Sat Mar 25 07:00:33 UTC 2017

Modified Files:
src/sys/dev: vnd.c

Log Message:
Don't display step-by-step detailed error messages unless DIAGNOSTIC.

Among other things, this avoids expected "error messages" when the
module is being auto-unloaded while one or more units are still in
use.


To generate a diff of this commit:
cvs rdiff -u -r1.258 -r1.259 src/sys/dev/vnd.c

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