CVS commit: src/sys/dev/pci

2018-08-22 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Aug 23 05:18:45 UTC 2018

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

Log Message:
- Add C62x to the descriptions of Intel C620 series devices.
- Add 0xa1ca for Intel C629 LPC or eSPI.


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

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

Modified files:

Index: src/sys/dev/pci/pcidevs
diff -u src/sys/dev/pci/pcidevs:1.1346 src/sys/dev/pci/pcidevs:1.1347
--- src/sys/dev/pci/pcidevs:1.1346	Mon Jul 30 05:59:57 2018
+++ src/sys/dev/pci/pcidevs	Thu Aug 23 05:18:45 2018
@@ -1,4 +1,4 @@
-$NetBSD: pcidevs,v 1.1346 2018/07/30 05:59:57 msaitoh Exp $
+$NetBSD: pcidevs,v 1.1347 2018/08/23 05:18:45 msaitoh Exp $
 
 /*
  * Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -4326,14 +4326,14 @@ product INTEL E7520_PCIE_C1	0x359a	E7520
 product INTEL E7520_CFG		0x359b	E7520 Extended Configuration
 product INTEL X722_A0		0x374c	X722 A0 10GbE
 product INTEL X722_A0_VF	0x374d	X722 A0 10GbE VF
-product INTEL C620_THERM_SENS	0x37b1	Thermal Sensor
-product INTEL C620_NPX16	0x37c0	PCIe x16 Uplink (NPX16)
-product INTEL C620_NPX8		0x37c1	PCIe x8 Uplink (NPX8)
-product INTEL C620_VSWP_0	0x37c2	Virtual Switch Port (for QAT 0)
-product INTEL C620_VSWP_1	0x37c3	Virtual Switch Port (for QAT 1)
-product INTEL C620_VSWP_2	0x37c4	Virtual Switch Port (for QAT 2)
-product INTEL C620_VSWP_3	0x37c5	Virtual Switch Port (for 10GbE LAN)
-product INTEL C620_VSWP_4	0x37c6	Virtual Switch Port (for Termal Sensor)
+product INTEL C620_THERM_SENS	0x37b1	C620 Thermal Sensor
+product INTEL C620_NPX16	0x37c0	C620 PCIe x16 Uplink (NPX16)
+product INTEL C620_NPX8		0x37c1	C620 PCIe x8 Uplink (NPX8)
+product INTEL C620_VSWP_0	0x37c2	C620 Virtual Switch Port (for QAT 0)
+product INTEL C620_VSWP_1	0x37c3	C620 Virtual Switch Port (for QAT 1)
+product INTEL C620_VSWP_2	0x37c4	C620 Virtual Switch Port (for QAT 2)
+product INTEL C620_VSWP_3	0x37c5	C620 Virtual Switch Port (for 10GbE LAN)
+product INTEL C620_VSWP_4	0x37c6	C620 Virtual Switch Port (for Termal Sensor)
 product INTEL C620_QAT		0x37c8	C620 QAT
 product INTEL C620_QAT_VF	0x37c9	C620 QAT Virtual Function
 product INTEL X722		0x37cc	X722 10GbE
@@ -5101,106 +5101,107 @@ product INTEL 100SERIES_PCIE_18	0xa168	1
 product INTEL 100SERIES_PCIE_19	0xa169	100 Series PCIE
 product INTEL 100SERIES_PCIE_20	0xa16a	100 Series PCIE
 product INTEL 100SERIES_HDA	0xa170	100 Series HD Audio
-product INTEL C620_AHCI		0xa182	AHCI
-product INTEL C620_3RD_RAID	0xa186	3rd Party RAID
-product INTEL C620_PCIE_0	0xa190	PCIe Root Port
-product INTEL C620_PCIE_1	0xa191	PCIe Root Port
-product INTEL C620_PCIE_2	0xa192	PCIe Root Port
-product INTEL C620_PCIE_3	0xa193	PCIe Root Port
-product INTEL C620_PCIE_4	0xa194	PCIe Root Port
-product INTEL C620_PCIE_5	0xa195	PCIe Root Port
-product INTEL C620_PCIE_6	0xa196	PCIe Root Port
-product INTEL C620_PCIE_7	0xa197	PCIe Root Port
-product INTEL C620_PCIE_8	0xa198	PCIe Root Port
-product INTEL C620_PCIE_9	0xa199	PCIe Root Port
-product INTEL C620_PCIE_10	0xa19a	PCIe Root Port
-product INTEL C620_PCIE_11	0xa19b	PCIe Root Port
-product INTEL C620_PCIE_12	0xa19c	PCIe Root Port
-product INTEL C620_PCIE_13	0xa19d	PCIe Root Port
-product INTEL C620_PCIE_14	0xa19e	PCIe Root Port
-product INTEL C620_PCIE_15	0xa19f	PCIe Root Port
-product INTEL C620_P2SB		0xa1a0	P2SB
-product INTEL C620_PMC		0xa1a1	PMC
-product INTEL C620_SMB		0xa1a3	SMBus
-product INTEL C620_SPI		0xa1a4	SPI
-product INTEL C620_TRACE	0xa1a6	Trace Hub
-product INTEL C620_XHCI		0xa1af	xHCI
-product INTEL C620_THERM	0xa1b1	Thermal Subsystem
-product INTEL C620_ME_HCI_1	0xa1ba	ME HCI
-product INTEL C620_ME_HCI_2	0xa1bb	ME HCI
-product INTEL C620_ME_IDER	0xa1bc	ME IDER
-product INTEL C620_ME_KT	0xa1bd	ME KT
-product INTEL C620_ME_HCI_3	0xa1be	ME HECI
-product INTEL C620_LPC_1	0xa1c1	LPC or eSPI
-product INTEL C620_LPC_2	0xa1c2	LPC or eSPI
-product INTEL C620_LPC_3	0xa1c3	LPC or eSPI
-product INTEL C620_LPC_4	0xa1c4	LPC or eSPI
-product INTEL C620_LPC_5	0xa1c5	LPC or eSPI
-product INTEL C620_LPC_6	0xa1c6	LPC or eSPI
-product INTEL C620_LPC_7	0xa1c7	LPC or eSPI
-product INTEL C620_SSATA_AHCI	0xa1d2	sSATA AHCI
-product INTEL C620_SSATA_RAID	0xa1d6	sSATA 3rd Party RAID
-product INTEL C620_PCIE_16	0xa1e7	PCIe Root Port
-product INTEL C620_PCIE_17	0xa1e8	PCIe Root Port
-product INTEL C620_PCIE_18	0xa1e9	PCIe Root Port
-product INTEL C620_PCIE_19	0xa1ea	PCIe Root Port
-product INTEL C620_MROM_0	0xa1ec	MROM
-product INTEL C620_MROM_1	0xa1ed	MROM
-product INTEL C620_HDA		0xa1f0	HD Audio
-product INTEL C620_IE_HECI_1	0xa1f8	IE HECI
-product INTEL C620_IE_HECI_2	0xa1f9	IE HECI
-product INTEL C620_IE_IDER	0xa1fa	IE IDER
-product INTEL C620_IE_KT	0xa1fb	IE KT
-product INTEL C620_IE_HECI_3	0xa1fc	IE HECI
-product INTEL C620_AHCI_S	0xa202	AHCI
-product INTEL C620_3RD_RAID_S	0xa206	3rd Party RAID
-product INTEL C620_PCIE_S_0	0xa210	

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

2018-08-22 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Aug 23 04:04:35 UTC 2018

Modified Files:
src/sys/arch/sun68k/include: cpu.h

Log Message:
Remove inclusion of old m68k/sysctl.h


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/sun68k/include/cpu.h

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

Modified files:

Index: src/sys/arch/sun68k/include/cpu.h
diff -u src/sys/arch/sun68k/include/cpu.h:1.23 src/sys/arch/sun68k/include/cpu.h:1.24
--- src/sys/arch/sun68k/include/cpu.h:1.23	Sat Oct 19 19:20:59 2013
+++ src/sys/arch/sun68k/include/cpu.h	Thu Aug 23 04:04:34 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.h,v 1.23 2013/10/19 19:20:59 christos Exp $	*/
+/*	$NetBSD: cpu.h,v 1.24 2018/08/23 04:04:34 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 1982, 1990 The Regents of the University of California.
@@ -167,5 +167,4 @@ void	fb_unblank(void);
 
 #endif	/* _KERNEL */
 
-#include 
 #endif /* _CPU_H_ */



CVS commit: src/sys/netipsec

2018-08-22 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Thu Aug 23 01:55:38 UTC 2018

Modified Files:
src/sys/netipsec: key.c

Log Message:
Don't call key_ismyaddr, which may sleep, in a pserialize read section

Use mutex here instead of pserialize because using mutex is simpler than
using psz+ref, which is another solution, and key_checkspidup isn't called in
any performance-sensitive paths.


To generate a diff of this commit:
cvs rdiff -u -r1.256 -r1.257 src/sys/netipsec/key.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/netipsec/key.c
diff -u src/sys/netipsec/key.c:1.256 src/sys/netipsec/key.c:1.257
--- src/sys/netipsec/key.c:1.256	Wed Jul  4 19:20:25 2018
+++ src/sys/netipsec/key.c	Thu Aug 23 01:55:38 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: key.c,v 1.256 2018/07/04 19:20:25 christos Exp $	*/
+/*	$NetBSD: key.c,v 1.257 2018/08/23 01:55:38 ozaki-r Exp $	*/
 /*	$FreeBSD: key.c,v 1.3.2.3 2004/02/14 22:23:23 bms Exp $	*/
 /*	$KAME: key.c,v 1.191 2001/06/27 10:46:49 sakane Exp $	*/
 
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.256 2018/07/04 19:20:25 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.257 2018/08/23 01:55:38 ozaki-r Exp $");
 
 /*
  * This code is referred to RFC 2367
@@ -3455,7 +3455,6 @@ key_checkspidup(const struct secasindex 
 {
 	struct secashead *sah;
 	struct secasvar *sav;
-	int s;
 
 	/* check address family */
 	if (saidx->src.sa.sa_family != saidx->dst.sa.sa_family) {
@@ -3466,18 +3465,19 @@ key_checkspidup(const struct secasindex 
 	}
 
 	/* check all SAD */
-	s = pserialize_read_enter();
-	SAHLIST_READER_FOREACH(sah) {
+	/* key_ismyaddr may sleep, so use mutex, not pserialize, here. */
+	mutex_enter(_sad.lock);
+	SAHLIST_WRITER_FOREACH(sah) {
 		if (!key_ismyaddr((struct sockaddr *)>saidx.dst))
 			continue;
 		sav = key_getsavbyspi(sah, spi);
 		if (sav != NULL) {
-			pserialize_read_exit(s);
 			KEY_SA_UNREF();
+			mutex_exit(_sad.lock);
 			return true;
 		}
 	}
-	pserialize_read_exit(s);
+	mutex_exit(_sad.lock);
 
 	return false;
 }



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

2018-08-22 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Aug 23 01:25:22 UTC 2018

Modified Files:
src/sys/external/bsd/libfdt/dist: libfdt_env.h

Log Message:
Support building libfdt with _STANDALONE


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/external/bsd/libfdt/dist/libfdt_env.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/external/bsd/libfdt/dist/libfdt_env.h
diff -u src/sys/external/bsd/libfdt/dist/libfdt_env.h:1.3 src/sys/external/bsd/libfdt/dist/libfdt_env.h:1.4
--- src/sys/external/bsd/libfdt/dist/libfdt_env.h:1.3	Thu Jun  8 15:54:32 2017
+++ src/sys/external/bsd/libfdt/dist/libfdt_env.h	Thu Aug 23 01:25:22 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: libfdt_env.h,v 1.3 2017/06/08 15:54:32 skrll Exp $	*/
+/*	$NetBSD: libfdt_env.h,v 1.4 2018/08/23 01:25:22 jmcneill Exp $	*/
 
 #ifndef _LIBFDT_ENV_H
 #define _LIBFDT_ENV_H
@@ -54,9 +54,10 @@
  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#if defined(_KERNEL)
+#if defined(_KERNEL) || defined(_STANDALONE)
 #include 
 #include 
+#include 
 #else
 #include 
 #include 



CVS commit: src/sys/external/bsd/drm2/dist/drm/nouveau

2018-08-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Aug 23 01:10:28 UTC 2018

Modified Files:
src/sys/external/bsd/drm2/dist/drm/nouveau: nouveau_fence.c

Log Message:
Attempt to make sense of return values of nouveau_fence_wait.

PR kern/53441

XXX pullup-7
XXX pullup-8


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 \
src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fence.c

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

Modified files:

Index: src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fence.c
diff -u src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fence.c:1.7 src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fence.c:1.8
--- src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fence.c:1.7	Thu Aug 23 01:10:21 2018
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fence.c	Thu Aug 23 01:10:28 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: nouveau_fence.c,v 1.7 2018/08/23 01:10:21 riastradh Exp $	*/
+/*	$NetBSD: nouveau_fence.c,v 1.8 2018/08/23 01:10:28 riastradh Exp $	*/
 
 /*
  * Copyright (C) 2007 Ben Skeggs.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nouveau_fence.c,v 1.7 2018/08/23 01:10:21 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_fence.c,v 1.8 2018/08/23 01:10:28 riastradh Exp $");
 
 #include 
 #include 
@@ -446,6 +446,9 @@ nouveau_fence_wait_uevent_handler(void *
  *
  *	Wait using a nouveau event for completion of fence on chan.
  *	Wait interruptibly iff intr is true.
+ *
+ *	Return 0 if fence was signalled, negative error code on
+ *	timeout (-EBUSY) or interrupt (-ERESTARTSYS) or other error.
  */
 static int
 nouveau_fence_wait_uevent(struct nouveau_fence *fence,
@@ -487,12 +490,18 @@ nouveau_fence_wait_uevent(struct nouveau
 			}
 			nouveau_fence_gc_grab(fctx, _list);
 			spin_unlock(>lock);
-		}
-
-		if (ret >= 0) {
-			fence->timeout = jiffies + ret;
-			if (time_after_eq(jiffies, fence->timeout))
+			if (ret < 0) {
+/* error */
+			} else if (ret == 0) {
+/* timeout */
 ret = -EBUSY;
+			} else {
+/* success */
+ret = 0;
+			}
+		} else {
+			/* timeout */
+			ret = -EBUSY;
 		}
 	} else {
 		spin_lock(>lock);
@@ -525,6 +534,9 @@ nouveau_fence_wait_uevent(struct nouveau
  *	Wait for fence to complete.  Wait interruptibly iff intr is
  *	true.  If lazy is true, may sleep, either for a single tick or
  *	for an interrupt; otherwise will busy-wait.
+ *
+ *	Return 0 if fence was signalled, negative error code on
+ *	timeout (-EBUSY) or interrupt (-ERESTARTSYS) or other error.
  */
 int
 nouveau_fence_wait(struct nouveau_fence *fence, bool lazy, bool intr)



CVS commit: src/sys/external/bsd/drm2/dist/drm/nouveau

2018-08-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Aug 23 01:10:36 UTC 2018

Modified Files:
src/sys/external/bsd/drm2/dist/drm/nouveau: nouveau_fence.c

Log Message:
Fix edge case of reference counting, oops.

PR kern/53441

XXX pullup-7
XXX pullup-8


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 \
src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fence.c

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

Modified files:

Index: src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fence.c
diff -u src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fence.c:1.8 src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fence.c:1.9
--- src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fence.c:1.8	Thu Aug 23 01:10:28 2018
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fence.c	Thu Aug 23 01:10:36 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: nouveau_fence.c,v 1.8 2018/08/23 01:10:28 riastradh Exp $	*/
+/*	$NetBSD: nouveau_fence.c,v 1.9 2018/08/23 01:10:36 riastradh Exp $	*/
 
 /*
  * Copyright (C) 2007 Ben Skeggs.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nouveau_fence.c,v 1.8 2018/08/23 01:10:28 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_fence.c,v 1.9 2018/08/23 01:10:36 riastradh Exp $");
 
 #include 
 #include 
@@ -136,7 +136,7 @@ nouveau_fence_channel_release(struct nou
 
 	do {
 		old = fctx->refcnt;
-		if (old == 0) {
+		if (old == 1) {
 			spin_lock(>lock);
 			if (atomic_dec_uint_nv(>refcnt) == 0)
 DRM_SPIN_WAKEUP_ALL(>waitqueue,
@@ -216,8 +216,10 @@ nouveau_fence_context_del(struct nouveau
 	/* Wait for nouveau_fence_channel_acquire to complete on all CPUs.  */
 	xc_wait(xc_broadcast(0, nouveau_fence_context_del_xc, NULL, NULL));
 
-	/* Wait for any references to drain.  */
+	/* Release our reference and wait for any others to drain.  */
 	spin_lock(>lock);
+	KASSERT(fctx->refcnt > 0);
+	atomic_dec_uint(>refcnt);
 	DRM_SPIN_WAIT_NOINTR_UNTIL(ret, >waitqueue, >lock,
 	fctx->refcnt == 0);
 	BUG_ON(ret);
@@ -247,7 +249,7 @@ nouveau_fence_context_new(struct nouveau
 	INIT_LIST_HEAD(>done);
 	spin_lock_init(>lock);
 	DRM_INIT_WAITQUEUE(>waitqueue, "nvfnchan");
-	fctx->refcnt = 0;
+	fctx->refcnt = 1;
 }
 
 /*



CVS commit: src/sys/external/bsd/drm2/dist/drm/nouveau

2018-08-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Aug 23 01:10:21 UTC 2018

Modified Files:
src/sys/external/bsd/drm2/dist/drm/nouveau: nouveau_fence.c
nouveau_fence.h

Log Message:
Defer nouveau_fence_unref until spin unlock.

- kfree while holding a spin lock is not a good idea.
- Make sure we GC every time we might signal fences.

PR kern/53441

XXX pullup-7
XXX pullup-8


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 \
src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fence.c
cvs rdiff -u -r1.4 -r1.5 \
src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fence.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/external/bsd/drm2/dist/drm/nouveau/nouveau_fence.c
diff -u src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fence.c:1.6 src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fence.c:1.7
--- src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fence.c:1.6	Thu Aug 23 01:10:04 2018
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fence.c	Thu Aug 23 01:10:21 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: nouveau_fence.c,v 1.6 2018/08/23 01:10:04 riastradh Exp $	*/
+/*	$NetBSD: nouveau_fence.c,v 1.7 2018/08/23 01:10:21 riastradh Exp $	*/
 
 /*
  * Copyright (C) 2007 Ben Skeggs.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nouveau_fence.c,v 1.6 2018/08/23 01:10:04 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_fence.c,v 1.7 2018/08/23 01:10:21 riastradh Exp $");
 
 #include 
 #include 
@@ -87,6 +87,43 @@ nouveau_fence_channel_acquire(struct nou
 }
 
 /*
+ * nouveau_fence_gc_grab(fctx, list)
+ *
+ *	Move all of channel's done fences to list.
+ *
+ *	Caller must hold channel's fence lock.
+ */
+static void
+nouveau_fence_gc_grab(struct nouveau_fence_chan *fctx, struct list_head *list)
+{
+	struct list_head *node, *next;
+
+	BUG_ON(!spin_is_locked(>lock));
+
+	list_for_each_safe(node, next, >done) {
+		list_move_tail(node, list);
+	}
+}
+
+/*
+ * nouveau_fence_gc_free(list)
+ *
+ *	Unreference all of the fences in the list.
+ *
+ *	Caller MUST NOT hold the fences' channel's fence lock.
+ */
+static void
+nouveau_fence_gc_free(struct list_head *list)
+{
+	struct nouveau_fence *fence, *next;
+
+	list_for_each_entry_safe(fence, next, list, head) {
+		list_del(>head);
+		nouveau_fence_unref();
+	}
+}
+
+/*
  * nouveau_fence_channel_release(channel)
  *
  *	Release the channel acquired with nouveau_fence_channel_acquire.
@@ -114,7 +151,8 @@ nouveau_fence_channel_release(struct nou
 /*
  * nouveau_fence_signal(fence)
  *
- *	Schedule all the work for fence's completion, and mark it done.
+ *	Schedule all the work for fence's completion, mark it done, and
+ *	move it from the pending list to the done list.
  *
  *	Caller must hold fence's channel's fence lock.
  */
@@ -136,7 +174,9 @@ nouveau_fence_signal(struct nouveau_fenc
 
 	/* Note that the fence is done.  */
 	fence->done = true;
-	list_del(>head);
+
+	/* Move it from the pending list to the done list.  */
+	list_move_tail(>head, >done);
 }
 
 static void
@@ -154,16 +194,22 @@ void
 nouveau_fence_context_del(struct nouveau_fence_chan *fctx)
 {
 	struct nouveau_fence *fence, *fnext;
+	struct list_head done_list;
 	int ret __diagused;
 
+	INIT_LIST_HEAD(_list);
+
 	/* Signal all the fences in fctx.  */
 	spin_lock(>lock);
 	list_for_each_entry_safe(fence, fnext, >pending, head) {
 		nouveau_fence_signal(fence);
-		/* XXX Doesn't this leak fence?  */
 	}
+	nouveau_fence_gc_grab(fctx, _list);
 	spin_unlock(>lock);
 
+	/* Release any fences that we signalled.  */
+	nouveau_fence_gc_free(_list);
+
 	/* Wait for the workqueue to drain.  */
 	flush_scheduled_work();
 
@@ -177,6 +223,11 @@ nouveau_fence_context_del(struct nouveau
 	BUG_ON(ret);
 	spin_unlock(>lock);
 
+	/* Make sure there are no more fences on the list.  */
+	BUG_ON(!list_empty(>done));
+	BUG_ON(!list_empty(>flip));
+	BUG_ON(!list_empty(>pending));
+
 	/* Destroy the fence context.  */
 	DRM_DESTROY_WAITQUEUE(>waitqueue);
 	spin_lock_destroy(>lock);
@@ -193,6 +244,7 @@ nouveau_fence_context_new(struct nouveau
 
 	INIT_LIST_HEAD(>flip);
 	INIT_LIST_HEAD(>pending);
+	INIT_LIST_HEAD(>done);
 	spin_lock_init(>lock);
 	DRM_INIT_WAITQUEUE(>waitqueue, "nvfnchan");
 	fctx->refcnt = 0;
@@ -275,7 +327,6 @@ nouveau_fence_update(struct nouveau_chan
 		if (fctx->read(chan) < fence->sequence)
 			break;
 		nouveau_fence_signal(fence);
-		nouveau_fence_unref();
 	}
 	BUG_ON(!spin_is_locked(>lock));
 }
@@ -349,18 +400,24 @@ nouveau_fence_done(struct nouveau_fence 
 {
 	struct nouveau_channel *chan;
 	struct nouveau_fence_chan *fctx;
+	struct list_head done_list;
 	bool done;
 
 	if ((chan = nouveau_fence_channel_acquire(fence)) == NULL)
 		return true;
 
+	INIT_LIST_HEAD(_list);
+
 	fctx = chan->fence;
 	spin_lock(>lock);
 	done = nouveau_fence_done_locked(fence, chan);
+	nouveau_fence_gc_grab(fctx, _list);
 	spin_unlock(>lock);
 
 	

CVS commit: src/sys/external/bsd/drm2/dist/drm/nouveau

2018-08-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Aug 23 01:10:04 UTC 2018

Modified Files:
src/sys/external/bsd/drm2/dist/drm/nouveau: nouveau_fence.c
nouveau_fence.h

Log Message:
Fences may last longer than their channels.

- Use a reference count on the nouveau_fence_chan object.
- Acquire it with kpreemption disabled.
- Use xcall to wait for kpreempt-disabled sections to complete.

PR kern/53441

XXX pullup-7
XXX pullup-8


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 \
src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fence.c
cvs rdiff -u -r1.3 -r1.4 \
src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fence.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/external/bsd/drm2/dist/drm/nouveau/nouveau_fence.c
diff -u src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fence.c:1.5 src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fence.c:1.6
--- src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fence.c:1.5	Thu Aug 23 01:06:50 2018
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fence.c	Thu Aug 23 01:10:04 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: nouveau_fence.c,v 1.5 2018/08/23 01:06:50 riastradh Exp $	*/
+/*	$NetBSD: nouveau_fence.c,v 1.6 2018/08/23 01:10:04 riastradh Exp $	*/
 
 /*
  * Copyright (C) 2007 Ben Skeggs.
@@ -27,7 +27,10 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nouveau_fence.c,v 1.5 2018/08/23 01:06:50 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_fence.c,v 1.6 2018/08/23 01:10:04 riastradh Exp $");
+
+#include 
+#include 
 
 #include 
 
@@ -55,6 +58,60 @@ struct fence_work {
 };
 
 /*
+ * nouveau_fence_channel_acquire(fence)
+ *
+ *	Try to return the channel associated with fence.
+ */
+static struct nouveau_channel *
+nouveau_fence_channel_acquire(struct nouveau_fence *fence)
+{
+	struct nouveau_channel *chan;
+	struct nouveau_fence_chan *fctx;
+
+	/*
+	 * Block cross-calls while we examine fence.  If we observe
+	 * that fence->done is false, then the channel cannot be
+	 * destroyed even by another CPU until after kpreempt_enable.
+	 */
+	kpreempt_disable();
+	if (fence->done) {
+		chan = NULL;
+	} else {
+		chan = fence->channel;
+		fctx = chan->fence;
+		atomic_inc_uint(>refcnt);
+	}
+	kpreempt_enable();
+
+	return chan;
+}
+
+/*
+ * nouveau_fence_channel_release(channel)
+ *
+ *	Release the channel acquired with nouveau_fence_channel_acquire.
+ */
+static void
+nouveau_fence_channel_release(struct nouveau_channel *chan)
+{
+	struct nouveau_fence_chan *fctx = chan->fence;
+	unsigned old, new;
+
+	do {
+		old = fctx->refcnt;
+		if (old == 0) {
+			spin_lock(>lock);
+			if (atomic_dec_uint_nv(>refcnt) == 0)
+DRM_SPIN_WAKEUP_ALL(>waitqueue,
+>lock);
+			spin_unlock(>lock);
+			return;
+		}
+		new = old - 1;
+	} while (atomic_cas_uint(>refcnt, old, new) != old);
+}
+
+/*
  * nouveau_fence_signal(fence)
  *
  *	Schedule all the work for fence's completion, and mark it done.
@@ -82,6 +139,11 @@ nouveau_fence_signal(struct nouveau_fenc
 	list_del(>head);
 }
 
+static void
+nouveau_fence_context_del_xc(void *a, void *b)
+{
+}
+
 /*
  * nouveau_fence_context_del(fctx)
  *
@@ -92,6 +154,7 @@ void
 nouveau_fence_context_del(struct nouveau_fence_chan *fctx)
 {
 	struct nouveau_fence *fence, *fnext;
+	int ret __diagused;
 
 	/* Signal all the fences in fctx.  */
 	spin_lock(>lock);
@@ -104,6 +167,16 @@ nouveau_fence_context_del(struct nouveau
 	/* Wait for the workqueue to drain.  */
 	flush_scheduled_work();
 
+	/* Wait for nouveau_fence_channel_acquire to complete on all CPUs.  */
+	xc_wait(xc_broadcast(0, nouveau_fence_context_del_xc, NULL, NULL));
+
+	/* Wait for any references to drain.  */
+	spin_lock(>lock);
+	DRM_SPIN_WAIT_NOINTR_UNTIL(ret, >waitqueue, >lock,
+	fctx->refcnt == 0);
+	BUG_ON(ret);
+	spin_unlock(>lock);
+
 	/* Destroy the fence context.  */
 	DRM_DESTROY_WAITQUEUE(>waitqueue);
 	spin_lock_destroy(>lock);
@@ -122,6 +195,7 @@ nouveau_fence_context_new(struct nouveau
 	INIT_LIST_HEAD(>pending);
 	spin_lock_init(>lock);
 	DRM_INIT_WAITQUEUE(>waitqueue, "nvfnchan");
+	fctx->refcnt = 0;
 }
 
 /*
@@ -149,29 +223,37 @@ void
 nouveau_fence_work(struct nouveau_fence *fence,
 		   void (*func)(void *), void *data)
 {
-	struct nouveau_channel *chan = fence->channel;
-	struct nouveau_fence_chan *fctx = chan->fence;
+	struct nouveau_channel *chan;
+	struct nouveau_fence_chan *fctx;
 	struct fence_work *work = NULL;
 
+	if ((chan = nouveau_fence_channel_acquire(fence)) == NULL)
+		goto now0;
+	fctx = chan->fence;
+
 	work = kmalloc(sizeof(*work), GFP_KERNEL);
 	if (work == NULL) {
 		WARN_ON(nouveau_fence_wait(fence, false, false));
-		func(data);
-		return;
+		goto now1;
 	}
 
 	spin_lock(>lock);
 	if (fence->done) {
 		spin_unlock(>lock);
-		kfree(work);
-		func(data);
-		return;
+		goto now2;
 	}
 	INIT_WORK(>base, nouveau_fence_work_handler);
 	work->func = func;
 	work->data = data;
 	

CVS commit: src/sys/external/bsd/drm2/dist/drm/nouveau

2018-08-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Aug 23 01:06:51 UTC 2018

Modified Files:
src/sys/external/bsd/drm2/dist/drm/nouveau: nouveau_fence.c
nouveau_fence.h nouveau_nv84_fence.c

Log Message:
Rewrite nouveau_fence in an attempt to make it make sense.

PR kern/53441

XXX pullup-7
XXX pullup-8


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 \
src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fence.c
cvs rdiff -u -r1.2 -r1.3 \
src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fence.h \
src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_nv84_fence.c

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

Modified files:

Index: src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fence.c
diff -u src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fence.c:1.4 src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fence.c:1.5
--- src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fence.c:1.4	Wed Apr 13 07:57:15 2016
+++ src/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_fence.c	Thu Aug 23 01:06:50 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: nouveau_fence.c,v 1.4 2016/04/13 07:57:15 riastradh Exp $	*/
+/*	$NetBSD: nouveau_fence.c,v 1.5 2018/08/23 01:06:50 riastradh Exp $	*/
 
 /*
  * Copyright (C) 2007 Ben Skeggs.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nouveau_fence.c,v 1.4 2016/04/13 07:57:15 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_fence.c,v 1.5 2018/08/23 01:06:50 riastradh Exp $");
 
 #include 
 
@@ -41,6 +41,12 @@ __KERNEL_RCSID(0, "$NetBSD: nouveau_fenc
 
 #include 
 
+/*
+ * struct fence_work
+ *
+ *	State for a work action scheduled when a fence is completed.
+ *	Will call func(data) at some point after that happens.
+ */
 struct fence_work {
 	struct work_struct base;
 	struct list_head head;
@@ -48,77 +54,119 @@ struct fence_work {
 	void *data;
 };
 
+/*
+ * nouveau_fence_signal(fence)
+ *
+ *	Schedule all the work for fence's completion, and mark it done.
+ *
+ *	Caller must hold fence's channel's fence lock.
+ */
 static void
 nouveau_fence_signal(struct nouveau_fence *fence)
 {
+	struct nouveau_channel *chan __diagused = fence->channel;
+	struct nouveau_fence_chan *fctx __diagused = chan->fence;
 	struct fence_work *work, *temp;
 
+	BUG_ON(!spin_is_locked(>lock));
+	BUG_ON(fence->done);
+
+	/* Schedule all the work for this fence.  */
 	list_for_each_entry_safe(work, temp, >work, head) {
 		schedule_work(>base);
 		list_del(>head);
 	}
 
-	fence->channel = NULL;
+	/* Note that the fence is done.  */
+	fence->done = true;
 	list_del(>head);
 }
 
+/*
+ * nouveau_fence_context_del(fctx)
+ *
+ *	Artificially complete all fences in fctx, wait for their work
+ *	to drain, and destroy the memory associated with fctx.
+ */
 void
 nouveau_fence_context_del(struct nouveau_fence_chan *fctx)
 {
 	struct nouveau_fence *fence, *fnext;
+
+	/* Signal all the fences in fctx.  */
 	spin_lock(>lock);
 	list_for_each_entry_safe(fence, fnext, >pending, head) {
 		nouveau_fence_signal(fence);
+		/* XXX Doesn't this leak fence?  */
 	}
 	spin_unlock(>lock);
+
+	/* Wait for the workqueue to drain.  */
+	flush_scheduled_work();
+
+	/* Destroy the fence context.  */
+	DRM_DESTROY_WAITQUEUE(>waitqueue);
 	spin_lock_destroy(>lock);
 }
 
+/*
+ * nouveau_fence_context_new(fctx)
+ *
+ *	Initialize the state fctx for all fences on a channel.
+ */
 void
 nouveau_fence_context_new(struct nouveau_fence_chan *fctx)
 {
+
 	INIT_LIST_HEAD(>flip);
 	INIT_LIST_HEAD(>pending);
 	spin_lock_init(>lock);
+	DRM_INIT_WAITQUEUE(>waitqueue, "nvfnchan");
 }
 
+/*
+ * nouveau_fence_work_handler(kwork)
+ *
+ *	Work handler for nouveau_fence_work.
+ */
 static void
 nouveau_fence_work_handler(struct work_struct *kwork)
 {
 	struct fence_work *work = container_of(kwork, typeof(*work), base);
+
 	work->func(work->data);
 	kfree(work);
 }
 
+/*
+ * nouveau_fence_work(fence, func, data)
+ *
+ *	Arrange to call func(data) after fence is completed.  If fence
+ *	is already completed, call it immediately.  If memory is
+ *	scarce, synchronously wait for the fence and call it.
+ */
 void
 nouveau_fence_work(struct nouveau_fence *fence,
 		   void (*func)(void *), void *data)
 {
 	struct nouveau_channel *chan = fence->channel;
-	struct nouveau_fence_chan *fctx;
+	struct nouveau_fence_chan *fctx = chan->fence;
 	struct fence_work *work = NULL;
 
-	if (nouveau_fence_done(fence)) {
-		func(data);
-		return;
-	}
-
-	fctx = chan->fence;
 	work = kmalloc(sizeof(*work), GFP_KERNEL);
-	if (!work) {
+	if (work == NULL) {
 		WARN_ON(nouveau_fence_wait(fence, false, false));
 		func(data);
 		return;
 	}
 
 	spin_lock(>lock);
-	if (!fence->channel) {
+	if (fence->done) {
 		spin_unlock(>lock);
 		kfree(work);
 		func(data);
 		return;
 	}
-
 	INIT_WORK(>base, nouveau_fence_work_handler);
 	work->func = func;
 	work->data = data;
@@ -126,23 +174,39 @@ nouveau_fence_work(struct nouveau_fence 
 	spin_unlock(>lock);
 }
 

CVS commit: src/bin/sh

2018-08-22 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Wed Aug 22 20:08:54 UTC 2018

Modified Files:
src/bin/sh: eval.c main.c memalloc.c memalloc.h

Log Message:
Fix (hopefully) the problem reported on current-users by Patrick Welche.
we had incorrect usage of setstackmark()/popstackmark()

There was an ancient idiom (imported from CSRG in 1993) where code
can do:
setstackmark(); loop until whatever condition {
/* do lots of code */ popstackmark();
} popstackmark();

The 1st (inner) popstackmark() resets the stack, conserving memory,
The 2nd one is needed just in case the "whatever condition" was never
true, and the first one was never executed.

This is (was) safe as all popstackmark() did was reset the stack.
That could be done over and over again with no harm.

That is, until 2000 when a fix from FreeBSD for another problem was
imported.  That connected all the stack marks as a list (so they can be
located).  That caused the problem, as the idiom was not changed, now
there is this list of marks, and popstackmark() was removing an entry.

It rarely (never?) caused any problems as the idiom was rarely used
(the shell used to do loops like above, mostly, without the inner
popstackmark()).  Further, the stack mark list is only ever used when
a memory block is realloc'd.

That is, until last weekend - with the recent set of changes.

Part of that copied code from FreeBSD introduced the idiom above
into more functions - functions used much more, and with a greater
possibility of stack marks being set on blocks that are realloc'd
and so cause the problem.   In the FreeBSD code, they changed the idiom,
and always do a setstackmark() immediately after the inner popstackmark().
But not for reasons related to a list of stack marks, as in the
intervening period, FreeBSD deleted that, but for another reason.

We do not have their issue, and I did not believe that their
updated idiom was needed (I did some analysis of exactly this issue -
just missed the important part!), and just continued using the old one.
Hence Patrick's core dump

The solution used here is to split popstackmark() into 2 halves,
popstackmark() continues to do what it has (recently) done,
but is now implemented as a call of (a new func) rststackmark()
which does all the original work of popstackmark - but not removing
the entry from the stack mark list (which remains in popstackmark()).
Then in the idiom above, the inner popstackmark() turns into a call of
rststackmark() so the stack is reset, but the stack mark list is
unchanged.  Tail recursion elimination makes this essentially free.


To generate a diff of this commit:
cvs rdiff -u -r1.159 -r1.160 src/bin/sh/eval.c
cvs rdiff -u -r1.75 -r1.76 src/bin/sh/main.c
cvs rdiff -u -r1.31 -r1.32 src/bin/sh/memalloc.c
cvs rdiff -u -r1.17 -r1.18 src/bin/sh/memalloc.h

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

Modified files:

Index: src/bin/sh/eval.c
diff -u src/bin/sh/eval.c:1.159 src/bin/sh/eval.c:1.160
--- src/bin/sh/eval.c:1.159	Sun Aug 19 23:50:27 2018
+++ src/bin/sh/eval.c	Wed Aug 22 20:08:54 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: eval.c,v 1.159 2018/08/19 23:50:27 kre Exp $	*/
+/*	$NetBSD: eval.c,v 1.160 2018/08/22 20:08:54 kre Exp $	*/
 
 /*-
  * Copyright (c) 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)eval.c	8.9 (Berkeley) 6/8/95";
 #else
-__RCSID("$NetBSD: eval.c,v 1.159 2018/08/19 23:50:27 kre Exp $");
+__RCSID("$NetBSD: eval.c,v 1.160 2018/08/22 20:08:54 kre Exp $");
 #endif
 #endif /* not lint */
 
@@ -234,7 +234,7 @@ evalstring(char *s, int flag)
 evaltree(n, flag);
 			any = 1;
 		}
-		popstackmark();
+		rststackmark();
 	}
 	popfile();
 	popstackmark();
@@ -362,7 +362,7 @@ evaltree(union node *n, int flags)
 			break;
 		}
 		n = next;
-		popstackmark();
+		rststackmark();
 	} while(n != NULL);
  out1:
 	popstackmark();

Index: src/bin/sh/main.c
diff -u src/bin/sh/main.c:1.75 src/bin/sh/main.c:1.76
--- src/bin/sh/main.c:1.75	Sun Aug 19 23:50:27 2018
+++ src/bin/sh/main.c	Wed Aug 22 20:08:54 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.75 2018/08/19 23:50:27 kre Exp $	*/
+/*	$NetBSD: main.c,v 1.76 2018/08/22 20:08:54 kre Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1991, 19
 #if 0
 static char sccsid[] = "@(#)main.c	8.7 (Berkeley) 7/19/95";
 #else
-__RCSID("$NetBSD: main.c,v 1.75 2018/08/19 23:50:27 kre Exp $");
+__RCSID("$NetBSD: main.c,v 1.76 2018/08/22 20:08:54 kre Exp $");
 #endif
 #endif /* not lint */
 
@@ -294,8 +294,7 @@ cmdloop(int top)
 			numeof = 0;
 			evaltree(n, 0);
 		}
-		popstackmark();
-		setstackmark();
+		rststackmark();
 
 		/*
 		 * Any SKIP* can occur here!  SKIP(FUNC|BREAK|CONT) occur when

Index: src/bin/sh/memalloc.c
diff -u src/bin/sh/memalloc.c:1.31 src/bin/sh/memalloc.c:1.32
--- src/bin/sh/memalloc.c:1.31	Sun Jul 22 20:37:57 2018
+++ src/bin/sh/memalloc.c	Wed Aug 22 20:08:54 2018
@@ 

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

2018-08-22 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Aug 22 17:38:38 UTC 2018

Modified Files:
src/distrib/sets/lists/comp: ad.arm

Log Message:
lint library for pmc is gone.


To generate a diff of this commit:
cvs rdiff -u -r1.87 -r1.88 src/distrib/sets/lists/comp/ad.arm

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

Modified files:

Index: src/distrib/sets/lists/comp/ad.arm
diff -u src/distrib/sets/lists/comp/ad.arm:1.87 src/distrib/sets/lists/comp/ad.arm:1.88
--- src/distrib/sets/lists/comp/ad.arm:1.87	Tue Jul 17 14:55:24 2018
+++ src/distrib/sets/lists/comp/ad.arm	Wed Aug 22 13:38:38 2018
@@ -1,4 +1,4 @@
-# $NetBSD: ad.arm,v 1.87 2018/07/17 18:55:24 joerg Exp $
+# $NetBSD: ad.arm,v 1.88 2018/08/22 17:38:38 christos Exp $
 ./usr/include/acorn26comp-obsolete		obsolete
 ./usr/include/acorn26/ansi.h			comp-obsolete		obsolete
 ./usr/include/acorn26/aout_machdep.h		comp-obsolete		obsolete
@@ -780,4 +780,4 @@
 ./usr/libdata/ldscripts/armnbsd.xu		-unknown-		binutils
 ./usr/libdata/lint/llib-larm.ln			comp-c-lintlib		lint
 ./usr/libdata/lint/llib-larm32.ln		comp-obsolete		obsolete
-./usr/libdata/lint/llib-lpmc.ln			comp-c-lintlib		lint
+./usr/libdata/lint/llib-lpmc.ln			comp-obsolete		obsolete



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

2018-08-22 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed Aug 22 17:25:02 UTC 2018

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

Log Message:
Unwind the stack on error, to get the full path that led to the illegal
access. Example of output:

kASan: Unauthorized Access In 0x80e6219c: Addr 0xbb007a39fd03 [1 
byte, read]
#0 0x80e6219c in ras_purgeall 
#1 0x80e62330 in sys_rasctl 
#2 0x80265008 in syscall 

(I manually added a one-byte stack read overflow in rasctl to demonstrate.)


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/amd64/amd64/asan.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/asan.c
diff -u src/sys/arch/amd64/amd64/asan.c:1.4 src/sys/arch/amd64/amd64/asan.c:1.5
--- src/sys/arch/amd64/amd64/asan.c:1.4	Wed Aug 22 17:04:36 2018
+++ src/sys/arch/amd64/amd64/asan.c	Wed Aug 22 17:25:02 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: asan.c,v 1.4 2018/08/22 17:04:36 maxv Exp $	*/
+/*	$NetBSD: asan.c,v 1.5 2018/08/22 17:25:02 maxv Exp $	*/
 
 /*
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: asan.c,v 1.4 2018/08/22 17:04:36 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: asan.c,v 1.5 2018/08/22 17:25:02 maxv Exp $");
 
 #include 
 #include 
@@ -40,6 +40,7 @@ __KERNEL_RCSID(0, "$NetBSD: asan.c,v 1.4
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -248,12 +249,69 @@ kasan_init(void)
 
 /* -- */
 
+static inline bool
+kasan_unwind_end(const char *name)
+{
+	if (!strcmp(name, "syscall") ||
+	!strcmp(name, "handle_syscall") ||
+	!strncmp(name, "Xintr", 5) ||
+	!strncmp(name, "Xhandle", 7) ||
+	!strncmp(name, "Xresume", 7) ||
+	!strncmp(name, "Xstray", 6) ||
+	!strncmp(name, "Xhold", 5) ||
+	!strncmp(name, "Xrecurse", 8) ||
+	!strcmp(name, "Xdoreti") ||
+	!strncmp(name, "Xsoft", 5)) {
+		return true;
+	}
+
+	return false;
+}
+
+static void
+kasan_unwind(void)
+{
+	uint64_t *rbp, rip;
+	const char *mod;
+	const char *sym;
+	size_t nsym;
+	int error;
+
+	rbp = (uint64_t *)__builtin_frame_address(0);
+	nsym = 0;
+
+	while (1) {
+		/* 8(%rbp) contains the saved %rip. */
+		rip = *(rbp + 1);
+
+		if (rip < KERNBASE) {
+			break;
+		}
+		error = ksyms_getname(, , (vaddr_t)rip, KSYMS_PROC);
+		if (error) {
+			break;
+		}
+		printf("#%zu %p in %s <%s>\n", nsym, (void *)rip, sym, mod);
+		if (kasan_unwind_end(sym)) {
+			break;
+		}
+
+		rbp = (uint64_t *)*(rbp);
+		nsym++;
+
+		if (nsym >= 15) {
+			break;
+		}
+	}
+}
+
 static void
 kasan_report(unsigned long addr, size_t size, bool write, unsigned long rip)
 {
 	printf("kASan: Unauthorized Access In %p: Addr %p [%zu byte%s, %s]\n",
 	(void *)rip, (void *)addr, size, (size > 1 ? "s" : ""),
 	(write ? "write" : "read"));
+	kasan_unwind();
 }
 
 /* -- */



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

2018-08-22 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed Aug 22 17:04:36 UTC 2018

Modified Files:
src/sys/arch/amd64/amd64: asan.c spl.S

Log Message:
Explicitly unpoison the stack when entering a softint.

Softints are the only place where we "discard" a part of the stack: we may
have left the thread without allowing the asan instrumentation to clear
the poison, and in this case, we can get false positives when we hit a
poisoned area of the stack while executing another handler within the same
softint thread.

(I was actually getting a rare false positive in ip6intr.)


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/amd64/amd64/asan.c
cvs rdiff -u -r1.35 -r1.36 src/sys/arch/amd64/amd64/spl.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/asan.c
diff -u src/sys/arch/amd64/amd64/asan.c:1.3 src/sys/arch/amd64/amd64/asan.c:1.4
--- src/sys/arch/amd64/amd64/asan.c:1.3	Wed Aug 22 12:07:42 2018
+++ src/sys/arch/amd64/amd64/asan.c	Wed Aug 22 17:04:36 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: asan.c,v 1.3 2018/08/22 12:07:42 maxv Exp $	*/
+/*	$NetBSD: asan.c,v 1.4 2018/08/22 17:04:36 maxv Exp $	*/
 
 /*
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: asan.c,v 1.3 2018/08/22 12:07:42 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: asan.c,v 1.4 2018/08/22 17:04:36 maxv Exp $");
 
 #include 
 #include 
@@ -59,6 +59,7 @@ __KERNEL_RCSID(0, "$NetBSD: asan.c,v 1.3
 
 #define __RET_ADDR	(unsigned long)__builtin_return_address(0)
 
+void kasan_softint(struct lwp *);
 void kasan_shadow_map(void *, size_t);
 void kasan_early_init(void);
 void kasan_init(void);
@@ -323,6 +324,14 @@ kasan_markmem(const void *addr, size_t s
 }
 
 void
+kasan_softint(struct lwp *l)
+{
+	const void *stk = (const void *)uvm_lwp_getuarea(l);
+
+	kasan_shadow_fill(stk, USPACE, 0);
+}
+
+void
 kasan_alloc(const void *addr, size_t size, size_t sz_with_redz)
 {
 	kasan_markmem(addr, sz_with_redz, false);

Index: src/sys/arch/amd64/amd64/spl.S
diff -u src/sys/arch/amd64/amd64/spl.S:1.35 src/sys/arch/amd64/amd64/spl.S:1.36
--- src/sys/arch/amd64/amd64/spl.S:1.35	Sat Jul 14 14:29:40 2018
+++ src/sys/arch/amd64/amd64/spl.S	Wed Aug 22 17:04:36 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: spl.S,v 1.35 2018/07/14 14:29:40 maxv Exp $	*/
+/*	$NetBSD: spl.S,v 1.36 2018/08/22 17:04:36 maxv Exp $	*/
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -65,6 +65,7 @@
  */
 
 #include "opt_ddb.h"
+#include "opt_kasan.h"
 
 #define ALIGN_TEXT	.align 16,0x90
 
@@ -105,6 +106,17 @@ IDTVEC(softintr)
 	movq	L_PCB(%r15),%rcx
 	movq	%rdi,CPUVAR(CURLWP)
 
+#ifdef KASAN
+	/* clear the new stack */
+	pushq	%rax
+	pushq	%rdx
+	pushq	%rcx
+	callq	_C_LABEL(kasan_softint)
+	popq	%rcx
+	popq	%rdx
+	popq	%rax
+#endif
+
 	/* save old context */
 	movq	%rsp,PCB_RSP(%rcx)
 	movq	%rbp,PCB_RBP(%rcx)



CVS commit: src/sys/kern

2018-08-22 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Aug 22 14:12:30 UTC 2018

Modified Files:
src/sys/kern: kern_malloc.c subr_kmem.c

Log Message:
- opt_kasan.h is included from 
- now that we are not using inlines, we need one more ifdef.


To generate a diff of this commit:
cvs rdiff -u -r1.152 -r1.153 src/sys/kern/kern_malloc.c
cvs rdiff -u -r1.70 -r1.71 src/sys/kern/subr_kmem.c

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

Modified files:

Index: src/sys/kern/kern_malloc.c
diff -u src/sys/kern/kern_malloc.c:1.152 src/sys/kern/kern_malloc.c:1.153
--- src/sys/kern/kern_malloc.c:1.152	Wed Aug 22 08:42:06 2018
+++ src/sys/kern/kern_malloc.c	Wed Aug 22 10:12:30 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_malloc.c,v 1.152 2018/08/22 12:42:06 maxv Exp $	*/
+/*	$NetBSD: kern_malloc.c,v 1.153 2018/08/22 14:12:30 christos Exp $	*/
 
 /*
  * Copyright (c) 1987, 1991, 1993
@@ -70,11 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_malloc.c,v 1.152 2018/08/22 12:42:06 maxv Exp $");
-
-#ifdef _KERNEL_OPT
-#include "opt_kasan.h"
-#endif
+__KERNEL_RCSID(0, "$NetBSD: kern_malloc.c,v 1.153 2018/08/22 14:12:30 christos Exp $");
 
 #include 
 #include 
@@ -115,9 +111,7 @@ kern_malloc(unsigned long size, int flag
 	struct malloc_header *mh;
 	void *p;
 
-#ifdef KASAN
 	kasan_add_redzone();
-#endif
 
 	if (size >= PAGE_SIZE) {
 		if (size > (ULONG_MAX-PAGE_SIZE))
@@ -144,9 +138,7 @@ kern_malloc(unsigned long size, int flag
 #endif
 	mh++;
 
-#ifdef KASAN
 	kasan_alloc(mh, origsize, size);
-#endif
 
 	return mh;
 }
@@ -159,9 +151,7 @@ kern_free(void *addr)
 	mh = addr;
 	mh--;
 
-#ifdef KASAN
 	kasan_free(addr, mh->mh_size);
-#endif
 
 	if (mh->mh_size >= PAGE_SIZE + sizeof(struct malloc_header))
 		kmem_intr_free((char *)addr - PAGE_SIZE,

Index: src/sys/kern/subr_kmem.c
diff -u src/sys/kern/subr_kmem.c:1.70 src/sys/kern/subr_kmem.c:1.71
--- src/sys/kern/subr_kmem.c:1.70	Wed Aug 22 05:38:21 2018
+++ src/sys/kern/subr_kmem.c	Wed Aug 22 10:12:30 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_kmem.c,v 1.70 2018/08/22 09:38:21 maxv Exp $	*/
+/*	$NetBSD: subr_kmem.c,v 1.71 2018/08/22 14:12:30 christos Exp $	*/
 
 /*-
  * Copyright (c) 2009-2015 The NetBSD Foundation, Inc.
@@ -92,11 +92,10 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_kmem.c,v 1.70 2018/08/22 09:38:21 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_kmem.c,v 1.71 2018/08/22 14:12:30 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_kmem.h"
-#include "opt_kasan.h"
 #endif
 
 #include 
@@ -224,7 +223,9 @@ CTASSERT(KM_NOSLEEP == PR_NOWAIT);
 void *
 kmem_intr_alloc(size_t requested_size, km_flag_t kmflags)
 {
+#ifdef KASAN
 	const size_t origsize = requested_size;
+#endif
 	size_t allocsz, index;
 	size_t size;
 	pool_cache_t pc;



CVS commit: src/sys/sys

2018-08-22 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Aug 22 14:11:26 UTC 2018

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

Log Message:
- since we include asan.h unconditionally now, make sure opt_kasan.h is
  included here, following the practice from other header files.
- don't use inline functions, adds complexity (and broke the build)


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/sys/asan.h

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

Modified files:

Index: src/sys/sys/asan.h
diff -u src/sys/sys/asan.h:1.6 src/sys/sys/asan.h:1.7
--- src/sys/sys/asan.h:1.6	Wed Aug 22 08:42:06 2018
+++ src/sys/sys/asan.h	Wed Aug 22 10:11:26 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: asan.h,v 1.6 2018/08/22 12:42:06 maxv Exp $	*/
+/*	$NetBSD: asan.h,v 1.7 2018/08/22 14:11:26 christos Exp $	*/
 
 /*
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -32,6 +32,10 @@
 #ifndef _SYS_ASAN_H_
 #define _SYS_ASAN_H_
 
+#ifdef _KERNEL_OPT
+#include "opt_kasan.h"
+#endif
+
 #include 
 
 #ifdef KASAN
@@ -39,24 +43,9 @@ void kasan_add_redzone(size_t *);
 void kasan_alloc(const void *, size_t, size_t);
 void kasan_free(const void *, size_t);
 #else
-__inline static void __unused
-kasan_add_redzone(size_t *size __unused)
-{
-	/* nothing */
-}
-
-__inline static void __unused
-kasan_alloc(const void *addr __unused, size_t size __unused,
-size_t sz_with_redz __unused)
-{
-	/* nothing */
-}
-
-__inline static void __unused
-kasan_free(const void *addr __unused, size_t sz_with_redz __unused)
-{
-	/* nothing */
-}
+#define kasan_add_redzone(s)	__nothing
+#define kasan_alloc(p, s, l)	__nothing
+#define kasan_free(p, s)	__nothing
 #endif
 
 #endif /* !_SYS_ASAN_H_ */



CVS commit: src/sys/external/gpl2/dts/dist/arch/arm/boot/dts

2018-08-22 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Aug 22 13:16:41 UTC 2018

Modified Files:
src/sys/external/gpl2/dts/dist/arch/arm/boot/dts: bcm283x.dtsi

Log Message:
Explicitly disable v3d, pixelvalve, and hvs for bcm283x at the moment.

When these devices or hdmi are enabled, firmware turns off GPU functionality of
VideoCore, expecting OS drivers handle it appropriately:

https://github.com/raspberrypi/firmware/issues/763

This breaks userland applications using /dev/vchiq, such as omxplayer.

XXX We need enable them back when we import vc4 drm driver.

Fix PR port-evbarm/52984 and
PR port-arm/53042.

OK jmcneill, skrll


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 \
src/sys/external/gpl2/dts/dist/arch/arm/boot/dts/bcm283x.dtsi

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

Modified files:

Index: src/sys/external/gpl2/dts/dist/arch/arm/boot/dts/bcm283x.dtsi
diff -u src/sys/external/gpl2/dts/dist/arch/arm/boot/dts/bcm283x.dtsi:1.4 src/sys/external/gpl2/dts/dist/arch/arm/boot/dts/bcm283x.dtsi:1.5
--- src/sys/external/gpl2/dts/dist/arch/arm/boot/dts/bcm283x.dtsi:1.4	Wed Jun 27 16:32:14 2018
+++ src/sys/external/gpl2/dts/dist/arch/arm/boot/dts/bcm283x.dtsi	Wed Aug 22 13:16:41 2018
@@ -434,12 +434,14 @@
 			compatible = "brcm,bcm2835-pixelvalve0";
 			reg = <0x7e206000 0x100>;
 			interrupts = <2 13>; /* pwa0 */
+			status = "disabled";
 		};
 
 		pixelvalve@7e207000 {
 			compatible = "brcm,bcm2835-pixelvalve1";
 			reg = <0x7e207000 0x100>;
 			interrupts = <2 14>; /* pwa1 */
+			status = "disabled";
 		};
 
 		dpi: dpi@7e208000 {
@@ -537,6 +539,7 @@
 			compatible = "brcm,bcm2835-hvs";
 			reg = <0x7e40 0x6000>;
 			interrupts = <2 1>;
+			status = "disabled";
 		};
 
 		dsi1: dsi@7e70 {
@@ -591,6 +594,7 @@
 			compatible = "brcm,bcm2835-pixelvalve2";
 			reg = <0x7e807000 0x100>;
 			interrupts = <2 10>; /* pixelvalve */
+			status = "disabled";
 		};
 
 		hdmi: hdmi@7e902000 {
@@ -623,6 +627,7 @@
 			compatible = "brcm,bcm2835-v3d";
 			reg = <0x7ec0 0x1000>;
 			interrupts = <1 10>;
+			status = "disabled";
 		};
 
 		vc4: gpu {



CVS commit: src/sys

2018-08-22 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed Aug 22 12:42:06 UTC 2018

Modified Files:
src/sys/kern: kern_malloc.c
src/sys/sys: asan.h

Log Message:
Add back the KASAN ifdefs in kern_malloc until we sort out the type issue,
and fix sys/asan.h. Tested on i386, amd64 and amd64-kasan.


To generate a diff of this commit:
cvs rdiff -u -r1.151 -r1.152 src/sys/kern/kern_malloc.c
cvs rdiff -u -r1.5 -r1.6 src/sys/sys/asan.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/kern/kern_malloc.c
diff -u src/sys/kern/kern_malloc.c:1.151 src/sys/kern/kern_malloc.c:1.152
--- src/sys/kern/kern_malloc.c:1.151	Wed Aug 22 09:38:21 2018
+++ src/sys/kern/kern_malloc.c	Wed Aug 22 12:42:06 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_malloc.c,v 1.151 2018/08/22 09:38:21 maxv Exp $	*/
+/*	$NetBSD: kern_malloc.c,v 1.152 2018/08/22 12:42:06 maxv Exp $	*/
 
 /*
  * Copyright (c) 1987, 1991, 1993
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_malloc.c,v 1.151 2018/08/22 09:38:21 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_malloc.c,v 1.152 2018/08/22 12:42:06 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_kasan.h"
@@ -108,12 +108,16 @@ void *
 kern_malloc(unsigned long size, int flags)
 {
 	const int kmflags = (flags & M_NOWAIT) ? KM_NOSLEEP : KM_SLEEP;
+#ifdef KASAN
 	const size_t origsize = size;
+#endif
 	size_t allocsize, hdroffset;
 	struct malloc_header *mh;
 	void *p;
 
+#ifdef KASAN
 	kasan_add_redzone();
+#endif
 
 	if (size >= PAGE_SIZE) {
 		if (size > (ULONG_MAX-PAGE_SIZE))
@@ -140,7 +144,9 @@ kern_malloc(unsigned long size, int flag
 #endif
 	mh++;
 
+#ifdef KASAN
 	kasan_alloc(mh, origsize, size);
+#endif
 
 	return mh;
 }
@@ -153,7 +159,9 @@ kern_free(void *addr)
 	mh = addr;
 	mh--;
 
+#ifdef KASAN
 	kasan_free(addr, mh->mh_size);
+#endif
 
 	if (mh->mh_size >= PAGE_SIZE + sizeof(struct malloc_header))
 		kmem_intr_free((char *)addr - PAGE_SIZE,

Index: src/sys/sys/asan.h
diff -u src/sys/sys/asan.h:1.5 src/sys/sys/asan.h:1.6
--- src/sys/sys/asan.h:1.5	Wed Aug 22 12:14:29 2018
+++ src/sys/sys/asan.h	Wed Aug 22 12:42:06 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: asan.h,v 1.5 2018/08/22 12:14:29 kre Exp $	*/
+/*	$NetBSD: asan.h,v 1.6 2018/08/22 12:42:06 maxv Exp $	*/
 
 /*
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -39,31 +39,24 @@ void kasan_add_redzone(size_t *);
 void kasan_alloc(const void *, size_t, size_t);
 void kasan_free(const void *, size_t);
 #else
-#if 0
-/* there are type issues - kmem_alloc() takes a u_long size not size_t */
-static void __inline __unused
+__inline static void __unused
 kasan_add_redzone(size_t *size __unused)
 {
 	/* nothing */
 }
 
-static void __inline __unused
+__inline static void __unused
 kasan_alloc(const void *addr __unused, size_t size __unused,
 size_t sz_with_redz __unused)
 {
 	/* nothing */
 }
 
-static void __inline __unused
+__inline static void __unused
 kasan_free(const void *addr __unused, size_t sz_with_redz __unused)
 {
 	/* nothing */
 }
-#else
-#define	kasan_add_redzone(SP)	__nothing
-#define	kasan_alloc(P, S1, S2)	__nothing
-#define	kasan_free(P, S)	__nothing
-#endif
 #endif
 
 #endif /* !_SYS_ASAN_H_ */



CVS commit: src/sys/sys

2018-08-22 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Wed Aug 22 12:14:29 UTC 2018

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

Log Message:
Temporarily disable the dummy inline funcs, and replace them with
__nothing until maxv sorts out the type issues - kern_malloc()
(for historical reasons) takes an unsigned long parameter, not a
size_t - on 64 bit arch's this makes no difference (size_t is unsigned
long) but that's not true on 32 bit archs (or not all of them anyway).

This should unbreak the i386 build (others?) - hopefully without
damaging anything too badly.Note the type issues need fixing,
just making this change permanent is not the solution.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/sys/asan.h

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

Modified files:

Index: src/sys/sys/asan.h
diff -u src/sys/sys/asan.h:1.4 src/sys/sys/asan.h:1.5
--- src/sys/sys/asan.h:1.4	Wed Aug 22 11:55:28 2018
+++ src/sys/sys/asan.h	Wed Aug 22 12:14:29 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: asan.h,v 1.4 2018/08/22 11:55:28 martin Exp $	*/
+/*	$NetBSD: asan.h,v 1.5 2018/08/22 12:14:29 kre Exp $	*/
 
 /*
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -39,6 +39,8 @@ void kasan_add_redzone(size_t *);
 void kasan_alloc(const void *, size_t, size_t);
 void kasan_free(const void *, size_t);
 #else
+#if 0
+/* there are type issues - kmem_alloc() takes a u_long size not size_t */
 static void __inline __unused
 kasan_add_redzone(size_t *size __unused)
 {
@@ -57,6 +59,11 @@ kasan_free(const void *addr __unused, si
 {
 	/* nothing */
 }
+#else
+#define	kasan_add_redzone(SP)	__nothing
+#define	kasan_alloc(P, S1, S2)	__nothing
+#define	kasan_free(P, S)	__nothing
+#endif
 #endif
 
 #endif /* !_SYS_ASAN_H_ */



CVS commit: src/sys

2018-08-22 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed Aug 22 12:07:43 UTC 2018

Modified Files:
src/sys/arch/amd64/amd64: asan.c machdep.c
src/sys/arch/amd64/conf: Makefile.amd64
src/sys/arch/amd64/include: param.h
src/sys/arch/x86/x86: cpu_rng.c pmap.c
src/sys/sys: cdefs.h
src/sys/uvm: uvm_glue.c

Log Message:
Add support for monitoring the stack with kASan. This allows us to detect
illegal memory accesses occuring there.

The compiler inlines a piece of code in each function that adds redzones
around the local variables and poisons them. The illegal accesses are then
detected using the usual kASan machinery.

The stack size is doubled, from 4 pages to 8 pages.

Several boot functions are marked with the __noasan flag, to prevent the
compiler from adding redzones in them (because we haven't yet initialized
kASan). The kasan_early_init function is called early at boot time to
quickly create the shadow for the current stack; after this is done, we
don't need __noasan anymore in the boot path.

We pass -fasan-shadow-offset=0xDFFF9000, because the compiler
wants to do
shad = shadow-offset + (addr >> 3)
and we do, in kasan_addr_to_shad
shad = KASAN_SHADOW_START + ((addr - CANONICAL_BASE) >> 3)
hence
shad = KASAN_SHADOW_START + (addr >> 3) - (CANONICAL_BASE >> 3)
 = [KASAN_SHADOW_START - (CANONICAL_BASE >> 3)] + (addr >> 3)
implies
shadow-offset = KASAN_SHADOW_START - (CANONICAL_BASE >> 3)
  = 0x8000 - (0x8000 >> 3)
  = 0xDFFF9000

In UVM, we add a kasan_free (that is not preceded by a kasan_alloc). We
don't add poisoned redzones ourselves, but all the functions we execute
do, so we need to manually clear the poison before freeing the stack.

With the help of Kamil for the makefile stuff.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/amd64/amd64/asan.c
cvs rdiff -u -r1.315 -r1.316 src/sys/arch/amd64/amd64/machdep.c
cvs rdiff -u -r1.72 -r1.73 src/sys/arch/amd64/conf/Makefile.amd64
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/amd64/include/param.h
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/x86/x86/cpu_rng.c
cvs rdiff -u -r1.304 -r1.305 src/sys/arch/x86/x86/pmap.c
cvs rdiff -u -r1.136 -r1.137 src/sys/sys/cdefs.h
cvs rdiff -u -r1.163 -r1.164 src/sys/uvm/uvm_glue.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/asan.c
diff -u src/sys/arch/amd64/amd64/asan.c:1.2 src/sys/arch/amd64/amd64/asan.c:1.3
--- src/sys/arch/amd64/amd64/asan.c:1.2	Wed Aug 22 09:11:47 2018
+++ src/sys/arch/amd64/amd64/asan.c	Wed Aug 22 12:07:42 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: asan.c,v 1.2 2018/08/22 09:11:47 maxv Exp $	*/
+/*	$NetBSD: asan.c,v 1.3 2018/08/22 12:07:42 maxv Exp $	*/
 
 /*
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: asan.c,v 1.2 2018/08/22 09:11:47 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: asan.c,v 1.3 2018/08/22 12:07:42 maxv Exp $");
 
 #include 
 #include 
@@ -60,6 +60,7 @@ __KERNEL_RCSID(0, "$NetBSD: asan.c,v 1.2
 #define __RET_ADDR	(unsigned long)__builtin_return_address(0)
 
 void kasan_shadow_map(void *, size_t);
+void kasan_early_init(void);
 void kasan_init(void);
 
 static bool kasan_enabled __read_mostly = false;
@@ -78,25 +79,59 @@ kasan_unsupported(vaddr_t addr)
 	addr < ((vaddr_t)PTE_BASE + NBPD_L4));
 }
 
+/* -- */
+
+static bool kasan_early __read_mostly = true;
+static uint8_t earlypages[8 * PAGE_SIZE] __aligned(PAGE_SIZE);
+static size_t earlytaken = 0;
+
+static paddr_t
+kasan_early_palloc(void)
+{
+	paddr_t ret;
+
+	KASSERT(earlytaken < 8);
+
+	ret = (paddr_t)([0] + earlytaken * PAGE_SIZE);
+	earlytaken++;
+
+	ret -= KERNBASE;
+
+	return ret;
+}
+
+static paddr_t
+kasan_palloc(void)
+{
+	paddr_t pa;
+
+	if (__predict_false(kasan_early))
+		pa = kasan_early_palloc();
+	else
+		pa = pmap_get_physpage();
+
+	return pa;
+}
+
 static void
 kasan_shadow_map_page(vaddr_t va)
 {
 	paddr_t pa;
 
 	if (!pmap_valid_entry(L4_BASE[pl4_i(va)])) {
-		pa = pmap_get_physpage();
+		pa = kasan_palloc();
 		L4_BASE[pl4_i(va)] = pa | PG_KW | pmap_pg_nx | PG_V;
 	}
 	if (!pmap_valid_entry(L3_BASE[pl3_i(va)])) {
-		pa = pmap_get_physpage();
+		pa = kasan_palloc();
 		L3_BASE[pl3_i(va)] = pa | PG_KW | pmap_pg_nx | PG_V;
 	}
 	if (!pmap_valid_entry(L2_BASE[pl2_i(va)])) {
-		pa = pmap_get_physpage();
+		pa = kasan_palloc();
 		L2_BASE[pl2_i(va)] = pa | PG_KW | pmap_pg_nx | PG_V;
 	}
 	if (!pmap_valid_entry(L1_BASE[pl1_i(va)])) {
-		pa = pmap_get_physpage();
+		pa = kasan_palloc();
 		L1_BASE[pl1_i(va)] = pa | PG_KW | pmap_pg_g | pmap_pg_nx | PG_V;
 	}
 }
@@ -161,6 +196,18 @@ kasan_ctors(void)
 }
 
 /*
+ * Map only the current stack. We will map the rest in kasan_init.
+ */
+void

CVS commit: src/sys/sys

2018-08-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Aug 22 11:55:28 UTC 2018

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

Log Message:
Change __always_inline to simple __inline to unbreak the build.


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

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

Modified files:

Index: src/sys/sys/asan.h
diff -u src/sys/sys/asan.h:1.3 src/sys/sys/asan.h:1.4
--- src/sys/sys/asan.h:1.3	Wed Aug 22 10:09:21 2018
+++ src/sys/sys/asan.h	Wed Aug 22 11:55:28 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: asan.h,v 1.3 2018/08/22 10:09:21 maxv Exp $	*/
+/*	$NetBSD: asan.h,v 1.4 2018/08/22 11:55:28 martin Exp $	*/
 
 /*
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -39,20 +39,20 @@ void kasan_add_redzone(size_t *);
 void kasan_alloc(const void *, size_t, size_t);
 void kasan_free(const void *, size_t);
 #else
-static void __always_inline __unused
+static void __inline __unused
 kasan_add_redzone(size_t *size __unused)
 {
 	/* nothing */
 }
 
-static void __always_inline __unused
+static void __inline __unused
 kasan_alloc(const void *addr __unused, size_t size __unused,
 size_t sz_with_redz __unused)
 {
 	/* nothing */
 }
 
-static void __always_inline __unused
+static void __inline __unused
 kasan_free(const void *addr __unused, size_t sz_with_redz __unused)
 {
 	/* nothing */



CVS commit: src/sys/sys

2018-08-22 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed Aug 22 10:09:22 UTC 2018

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

Log Message:
Actually add __unused on the functions themselves in case a .c file does
not use one function.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/sys/asan.h

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

Modified files:

Index: src/sys/sys/asan.h
diff -u src/sys/sys/asan.h:1.2 src/sys/sys/asan.h:1.3
--- src/sys/sys/asan.h:1.2	Wed Aug 22 09:38:21 2018
+++ src/sys/sys/asan.h	Wed Aug 22 10:09:21 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: asan.h,v 1.2 2018/08/22 09:38:21 maxv Exp $	*/
+/*	$NetBSD: asan.h,v 1.3 2018/08/22 10:09:21 maxv Exp $	*/
 
 /*
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -39,20 +39,20 @@ void kasan_add_redzone(size_t *);
 void kasan_alloc(const void *, size_t, size_t);
 void kasan_free(const void *, size_t);
 #else
-static void __always_inline
+static void __always_inline __unused
 kasan_add_redzone(size_t *size __unused)
 {
 	/* nothing */
 }
 
-static void __always_inline
+static void __always_inline __unused
 kasan_alloc(const void *addr __unused, size_t size __unused,
 size_t sz_with_redz __unused)
 {
 	/* nothing */
 }
 
-static void __always_inline
+static void __always_inline __unused
 kasan_free(const void *addr __unused, size_t sz_with_redz __unused)
 {
 	/* nothing */



CVS commit: src/sys

2018-08-22 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed Aug 22 09:38:21 UTC 2018

Modified Files:
src/sys/kern: kern_malloc.c subr_kmem.c
src/sys/sys: asan.h

Log Message:
Reduce the number of KASAN ifdefs, suggested by Christos/Taylor.


To generate a diff of this commit:
cvs rdiff -u -r1.150 -r1.151 src/sys/kern/kern_malloc.c
cvs rdiff -u -r1.69 -r1.70 src/sys/kern/subr_kmem.c
cvs rdiff -u -r1.1 -r1.2 src/sys/sys/asan.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/kern/kern_malloc.c
diff -u src/sys/kern/kern_malloc.c:1.150 src/sys/kern/kern_malloc.c:1.151
--- src/sys/kern/kern_malloc.c:1.150	Tue Aug 21 07:56:53 2018
+++ src/sys/kern/kern_malloc.c	Wed Aug 22 09:38:21 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_malloc.c,v 1.150 2018/08/21 07:56:53 maxv Exp $	*/
+/*	$NetBSD: kern_malloc.c,v 1.151 2018/08/22 09:38:21 maxv Exp $	*/
 
 /*
  * Copyright (c) 1987, 1991, 1993
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_malloc.c,v 1.150 2018/08/21 07:56:53 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_malloc.c,v 1.151 2018/08/22 09:38:21 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_kasan.h"
@@ -79,10 +79,7 @@ __KERNEL_RCSID(0, "$NetBSD: kern_malloc.
 #include 
 #include 
 #include 
-
-#ifdef KASAN
 #include 
-#endif
 
 /*
  * Built-in malloc types.  Note: ought to be removed.
@@ -111,16 +108,12 @@ void *
 kern_malloc(unsigned long size, int flags)
 {
 	const int kmflags = (flags & M_NOWAIT) ? KM_NOSLEEP : KM_SLEEP;
-#ifdef KASAN
-	size_t origsize = size;
-#endif
+	const size_t origsize = size;
 	size_t allocsize, hdroffset;
 	struct malloc_header *mh;
 	void *p;
 
-#ifdef KASAN
 	kasan_add_redzone();
-#endif
 
 	if (size >= PAGE_SIZE) {
 		if (size > (ULONG_MAX-PAGE_SIZE))
@@ -147,9 +140,7 @@ kern_malloc(unsigned long size, int flag
 #endif
 	mh++;
 
-#ifdef KASAN
 	kasan_alloc(mh, origsize, size);
-#endif
 
 	return mh;
 }
@@ -162,9 +153,7 @@ kern_free(void *addr)
 	mh = addr;
 	mh--;
 
-#ifdef KASAN
 	kasan_free(addr, mh->mh_size);
-#endif
 
 	if (mh->mh_size >= PAGE_SIZE + sizeof(struct malloc_header))
 		kmem_intr_free((char *)addr - PAGE_SIZE,

Index: src/sys/kern/subr_kmem.c
diff -u src/sys/kern/subr_kmem.c:1.69 src/sys/kern/subr_kmem.c:1.70
--- src/sys/kern/subr_kmem.c:1.69	Mon Aug 20 15:04:52 2018
+++ src/sys/kern/subr_kmem.c	Wed Aug 22 09:38:21 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_kmem.c,v 1.69 2018/08/20 15:04:52 maxv Exp $	*/
+/*	$NetBSD: subr_kmem.c,v 1.70 2018/08/22 09:38:21 maxv Exp $	*/
 
 /*-
  * Copyright (c) 2009-2015 The NetBSD Foundation, Inc.
@@ -92,7 +92,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_kmem.c,v 1.69 2018/08/20 15:04:52 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_kmem.c,v 1.70 2018/08/22 09:38:21 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_kmem.h"
@@ -106,10 +106,7 @@ __KERNEL_RCSID(0, "$NetBSD: subr_kmem.c,
 #include 
 #include 
 #include 
-
-#ifdef KASAN
 #include 
-#endif
 
 #include 
 #include 
@@ -227,9 +224,7 @@ CTASSERT(KM_NOSLEEP == PR_NOWAIT);
 void *
 kmem_intr_alloc(size_t requested_size, km_flag_t kmflags)
 {
-#ifdef KASAN
-	size_t origsize = requested_size;
-#endif
+	const size_t origsize = requested_size;
 	size_t allocsz, index;
 	size_t size;
 	pool_cache_t pc;
@@ -247,10 +242,7 @@ kmem_intr_alloc(size_t requested_size, k
 	}
 #endif
 
-#ifdef KASAN
 	kasan_add_redzone(_size);
-#endif
-
 	size = kmem_roundup_size(requested_size);
 	allocsz = size + SIZE_SIZE;
 
@@ -278,9 +270,7 @@ kmem_intr_alloc(size_t requested_size, k
 		FREECHECK_OUT(_freecheck, p);
 		kmem_size_set(p, requested_size);
 		p += SIZE_SIZE;
-#ifdef KASAN
 		kasan_alloc(p, origsize, size);
-#endif
 		return p;
 	}
 	return p;
@@ -323,17 +313,10 @@ kmem_intr_free(void *p, size_t requested
 	}
 #endif
 
-#ifdef KASAN
 	kasan_add_redzone(_size);
-#endif
-
 	size = kmem_roundup_size(requested_size);
 	allocsz = size + SIZE_SIZE;
 
-#ifdef KASAN
-	kasan_free(p, size);
-#endif
-
 	if ((index = ((allocsz -1) >> KMEM_SHIFT))
 	< kmem_cache_maxidx) {
 		pc = kmem_cache[index];
@@ -347,6 +330,8 @@ kmem_intr_free(void *p, size_t requested
 		return;
 	}
 
+	kasan_free(p, size);
+
 	p = (uint8_t *)p - SIZE_SIZE;
 	kmem_size_check(p, requested_size);
 	FREECHECK_IN(_freecheck, p);

Index: src/sys/sys/asan.h
diff -u src/sys/sys/asan.h:1.1 src/sys/sys/asan.h:1.2
--- src/sys/sys/asan.h:1.1	Mon Aug 20 15:04:52 2018
+++ src/sys/sys/asan.h	Wed Aug 22 09:38:21 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: asan.h,v 1.1 2018/08/20 15:04:52 maxv Exp $	*/
+/*	$NetBSD: asan.h,v 1.2 2018/08/22 09:38:21 maxv Exp $	*/
 
 /*
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -34,8 +34,29 @@
 
 #include 
 
+#ifdef KASAN
 void kasan_add_redzone(size_t *);
 void kasan_alloc(const void *, size_t, size_t);
 void kasan_free(const void *, size_t);
+#else
+static void __always_inline
+kasan_add_redzone(size_t *size __unused)
+{
+	/* nothing */
+}
+
+static void 

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

2018-08-22 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed Aug 22 09:11:47 UTC 2018

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

Log Message:
Fix the computation in kasan_shadow_map, we may need one more page because
of the rounddown.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/amd64/amd64/asan.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/asan.c
diff -u src/sys/arch/amd64/amd64/asan.c:1.1 src/sys/arch/amd64/amd64/asan.c:1.2
--- src/sys/arch/amd64/amd64/asan.c:1.1	Mon Aug 20 15:04:51 2018
+++ src/sys/arch/amd64/amd64/asan.c	Wed Aug 22 09:11:47 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: asan.c,v 1.1 2018/08/20 15:04:51 maxv Exp $	*/
+/*	$NetBSD: asan.c,v 1.2 2018/08/22 09:11:47 maxv Exp $	*/
 
 /*
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: asan.c,v 1.1 2018/08/20 15:04:51 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: asan.c,v 1.2 2018/08/22 09:11:47 maxv Exp $");
 
 #include 
 #include 
@@ -109,17 +109,24 @@ void
 kasan_shadow_map(void *addr, size_t size)
 {
 	size_t sz, npages, i;
-	vaddr_t va;
+	vaddr_t sva, eva;
+
+	KASSERT((vaddr_t)addr % KASAN_SHADOW_SCALE_SIZE == 0);
 
-	va = (vaddr_t)kasan_addr_to_shad(addr);
 	sz = roundup(size, KASAN_SHADOW_SCALE_SIZE) / KASAN_SHADOW_SCALE_SIZE;
-	va = rounddown(va, PAGE_SIZE);
-	npages = roundup(sz, PAGE_SIZE) / PAGE_SIZE;
 
-	KASSERT(va >= KASAN_SHADOW_START && va < KASAN_SHADOW_END);
+	sva = (vaddr_t)kasan_addr_to_shad(addr);
+	eva = (vaddr_t)kasan_addr_to_shad(addr) + sz;
+
+	sva = rounddown(sva, PAGE_SIZE);
+	eva = roundup(eva, PAGE_SIZE);
+
+	npages = (eva - sva) / PAGE_SIZE;
+
+	KASSERT(sva >= KASAN_SHADOW_START && eva < KASAN_SHADOW_END);
 
 	for (i = 0; i < npages; i++) {
-		kasan_shadow_map_page(va + i * PAGE_SIZE);
+		kasan_shadow_map_page(sva + i * PAGE_SIZE);
 	}
 }
 



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

2018-08-22 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Aug 22 07:47:33 UTC 2018

Modified Files:
src/sys/arch/arm/arm32: arm32_machdep.c

Log Message:
Use banner


To generate a diff of this commit:
cvs rdiff -u -r1.119 -r1.120 src/sys/arch/arm/arm32/arm32_machdep.c

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

Modified files:

Index: src/sys/arch/arm/arm32/arm32_machdep.c
diff -u src/sys/arch/arm/arm32/arm32_machdep.c:1.119 src/sys/arch/arm/arm32/arm32_machdep.c:1.120
--- src/sys/arch/arm/arm32/arm32_machdep.c:1.119	Wed Aug 15 06:59:29 2018
+++ src/sys/arch/arm/arm32/arm32_machdep.c	Wed Aug 22 07:47:33 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: arm32_machdep.c,v 1.119 2018/08/15 06:59:29 skrll Exp $	*/
+/*	$NetBSD: arm32_machdep.c,v 1.120 2018/08/22 07:47:33 skrll Exp $	*/
 
 /*
  * Copyright (c) 1994-1998 Mark Brinicombe.
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: arm32_machdep.c,v 1.119 2018/08/15 06:59:29 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: arm32_machdep.c,v 1.120 2018/08/22 07:47:33 skrll Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_fdt.h"
@@ -270,7 +270,6 @@ cpu_startup(void)
 {
 	vaddr_t minaddr;
 	vaddr_t maxaddr;
-	char pbuf[9];
 
 	/* Set the CPU control register */
 	cpu_setup(boot_args);
@@ -302,24 +301,13 @@ cpu_startup(void)
 	initmsgbuf(msgbufaddr, round_page(MSGBUFSIZE));
 
 	/*
-	 * Identify ourselves for the msgbuf (everything printed earlier will
-	 * not be buffered).
-	 */
-	printf("%s%s", copyright, version);
-
-	format_bytes(pbuf, sizeof(pbuf), arm_ptob(physmem));
-	printf("total memory = %s\n", pbuf);
-
-	minaddr = 0;
-
-	/*
 	 * Allocate a submap for physio
 	 */
+	minaddr = 0;
 	phys_map = uvm_km_suballoc(kernel_map, , ,
    VM_PHYS_SIZE, 0, false, NULL);
 
-	format_bytes(pbuf, sizeof(pbuf), ptoa(uvmexp.free));
-	printf("avail memory = %s\n", pbuf);
+	banner();
 
 	/*
 	 * This is actually done by initarm_common, but not all ports use it



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

2018-08-22 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Aug 22 07:43:03 UTC 2018

Modified Files:
src/sys/arch/arm/samsung: exynos_platform.c

Log Message:
Traiing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/arm/samsung/exynos_platform.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/arm/samsung/exynos_platform.c
diff -u src/sys/arch/arm/samsung/exynos_platform.c:1.13 src/sys/arch/arm/samsung/exynos_platform.c:1.14
--- src/sys/arch/arm/samsung/exynos_platform.c:1.13	Sun Aug 19 07:27:33 2018
+++ src/sys/arch/arm/samsung/exynos_platform.c	Wed Aug 22 07:43:02 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: exynos_platform.c,v 1.13 2018/08/19 07:27:33 skrll Exp $ */
+/* $NetBSD: exynos_platform.c,v 1.14 2018/08/22 07:43:02 skrll Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared D. McNeill 
@@ -34,7 +34,7 @@
 #include "ukbd.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: exynos_platform.c,v 1.13 2018/08/19 07:27:33 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: exynos_platform.c,v 1.14 2018/08/22 07:43:02 skrll Exp $");
 
 #include 
 #include 
@@ -94,7 +94,7 @@ exynos_platform_early_putchar(char c)
 	volatile uint32_t *uartaddr = cpu_earlydevice_va_p() ?
 	(volatile uint32_t *)CONSADDR_VA :
 	(volatile uint32_t *)CONSADDR;
-	
+
 	while ((uartaddr[SSCOM_UFSTAT / 4] & UFSTAT_TXFULL) != 0)
 		;
 



CVS commit: src/tests/lib/libc/sys

2018-08-22 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Aug 22 06:31:37 UTC 2018

Modified Files:
src/tests/lib/libc/sys: t_sendrecv.c

Log Message:
Den't set SA_RESTART in the signal handler allowing the process to get
interrupted durning recv and exit (pointed out by kre@)


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/sys/t_sendrecv.c

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

Modified files:

Index: src/tests/lib/libc/sys/t_sendrecv.c
diff -u src/tests/lib/libc/sys/t_sendrecv.c:1.3 src/tests/lib/libc/sys/t_sendrecv.c:1.4
--- src/tests/lib/libc/sys/t_sendrecv.c:1.3	Tue Aug 21 07:04:49 2018
+++ src/tests/lib/libc/sys/t_sendrecv.c	Wed Aug 22 02:31:37 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_sendrecv.c,v 1.3 2018/08/21 11:04:49 christos Exp $	*/
+/*	$NetBSD: t_sendrecv.c,v 1.4 2018/08/22 06:31:37 christos Exp $	*/
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__RCSID("$NetBSD: t_sendrecv.c,v 1.3 2018/08/21 11:04:49 christos Exp $");
+__RCSID("$NetBSD: t_sendrecv.c,v 1.4 2018/08/22 06:31:37 christos Exp $");
 
 #include 
 #include 
@@ -115,14 +115,14 @@ ATF_TC_BODY(sendrecv_basic, tc)
 	int fd[2], error;
 	struct sigaction sa;
 
-	atf_tc_fail("does not terminate");
+//	atf_tc_fail("does not terminate");
 
 	error = socketpair(AF_UNIX, SOCK_DGRAM, 0, fd);
 //	error = pipe(fd);
 	ATF_REQUIRE_MSG(error != -1, "socketpair failed (%s)", strerror(errno));
 
 	memset(, 0, sizeof(sa));
-	sa.sa_flags = SA_RESTART;
+	sa.sa_flags = 0;
 	sa.sa_handler = _sigchld;
 	sigemptyset(_mask);
 	error = sigaction(SIGCHLD, , 0);