CVS commit: [phil-wifi] src/sys

2018-08-03 Thread Phil Nelson
Module Name:src
Committed By:   phil
Date:   Fri Aug  3 19:47:25 UTC 2018

Modified Files:
src/sys/arch/amd64/conf [phil-wifi]: TESTWIFI
src/sys/dev/usb [phil-wifi]: if_urtwn.c
src/sys/net80211 [phil-wifi]: ieee80211_ioctl.c ieee80211_netbsd.c
ieee80211_netbsd.h ieee80211_node.c ieee80211_proto.c
ieee80211_ratectl.h ieee80211_scan_sta.c ieee80211_scan_sw.c
ieee80211_sta.c

Log Message:
State Save:
   Scanning works, can see the broadcasts and stations.
   Association appears to work.  (open networks only, no encryption yet.)
   IP traffic doesn't flow yet, not sure where the error is.
   Added back more NetBSD ioctls not in the FreeBSD code.  Still have
  more to go.
   Updated my TESTWIFI kernel config.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 src/sys/arch/amd64/conf/TESTWIFI
cvs rdiff -u -r1.59.2.4 -r1.59.2.5 src/sys/dev/usb/if_urtwn.c
cvs rdiff -u -r1.60.18.5 -r1.60.18.6 src/sys/net80211/ieee80211_ioctl.c
cvs rdiff -u -r1.31.2.5 -r1.31.2.6 src/sys/net80211/ieee80211_netbsd.c
cvs rdiff -u -r1.21.2.6 -r1.21.2.7 src/sys/net80211/ieee80211_netbsd.h
cvs rdiff -u -r1.75.4.3 -r1.75.4.4 src/sys/net80211/ieee80211_node.c
cvs rdiff -u -r1.34.14.5 -r1.34.14.6 src/sys/net80211/ieee80211_proto.c
cvs rdiff -u -r1.1.2.4 -r1.1.2.5 src/sys/net80211/ieee80211_ratectl.h
cvs rdiff -u -r1.1.56.5 -r1.1.56.6 src/sys/net80211/ieee80211_scan_sta.c
cvs rdiff -u -r1.1.2.3 -r1.1.2.4 src/sys/net80211/ieee80211_scan_sw.c \
src/sys/net80211/ieee80211_sta.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/conf/TESTWIFI
diff -u src/sys/arch/amd64/conf/TESTWIFI:1.1.2.1 src/sys/arch/amd64/conf/TESTWIFI:1.1.2.2
--- src/sys/arch/amd64/conf/TESTWIFI:1.1.2.1	Thu Jul 12 16:35:33 2018
+++ src/sys/arch/amd64/conf/TESTWIFI	Fri Aug  3 19:47:25 2018
@@ -1,4 +1,4 @@
-# $NetBSD: TESTWIFI,v 1.1.2.1 2018/07/12 16:35:33 phil Exp $
+# $NetBSD: TESTWIFI,v 1.1.2.2 2018/08/03 19:47:25 phil Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@ include 	"arch/amd64/conf/std.amd64"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident		"GENERIC-$Revision: 1.1.2.1 $"
+#ident		"GENERIC-$Revision: 1.1.2.2 $"
 
 maxusers	64		# estimated number of users
 
@@ -100,6 +100,8 @@ options 	DIAGNOSTIC	# inexpensive kernel
 # XXX to be commented out on release branch
 options 	DEBUG		# expensive debugging checks/support
 options 	LOCKDEBUG	# expensive locking checks/support
+options		URTWN_DEBUG # debug the urtwn driver
+options		IEEE80211_DEBUG # debug 802.11 code
 
 #
 # Because gcc omits the frame pointer for any -O level, the line below
@@ -108,9 +110,9 @@ options 	LOCKDEBUG	# expensive locking c
 makeoptions	COPTS="-O2 -fno-omit-frame-pointer"
 options 	DDB		# in-kernel debugger
 #options 	DDB_COMMANDONENTER="bt"	# execute command when ddb is entered
-#options 	DDB_ONPANIC=1	# see also sysctl(7): `ddb.onpanic'
+options 	DDB_ONPANIC=1	# see also sysctl(7): `ddb.onpanic'
 options 	DDB_HISTORY_SIZE=512	# enable history editing in DDB
-#options 	KGDB		# remote debugger
+options 	KGDB		# remote debugger
 #options 	KGDB_DEVNAME="\"com\"",KGDB_DEVADDR=0x3f8,KGDB_DEVRATE=9600
 makeoptions	DEBUG="-g"	# compile full symbol table for CTF
 #options 	SYSCALL_STATS	# per syscall counts

Index: src/sys/dev/usb/if_urtwn.c
diff -u src/sys/dev/usb/if_urtwn.c:1.59.2.4 src/sys/dev/usb/if_urtwn.c:1.59.2.5
--- src/sys/dev/usb/if_urtwn.c:1.59.2.4	Sat Jul 28 00:49:43 2018
+++ src/sys/dev/usb/if_urtwn.c	Fri Aug  3 19:47:25 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_urtwn.c,v 1.59.2.4 2018/07/28 00:49:43 phil Exp $	*/
+/*	$NetBSD: if_urtwn.c,v 1.59.2.5 2018/08/03 19:47:25 phil Exp $	*/
 /*	$OpenBSD: if_urtwn.c,v 1.42 2015/02/10 23:25:46 mpi Exp $	*/
 
 /*-
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.59.2.4 2018/07/28 00:49:43 phil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.59.2.5 2018/08/03 19:47:25 phil Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -111,7 +111,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v
 #define	DBG_REG		__BIT(6)
 #define	DBG_ALL		0xU
 /* NNN Reset urtwn_debug to 0 when done debugging. */
-u_int urtwn_debug = DBG_ALL & ~DBG_REG;
+u_int urtwn_debug = DBG_FN;
 #define DPRINTFN(n, s)	\
 	do { if (urtwn_debug & (n)) printf s; } while (/*CONSTCOND*/0)
 #else
@@ -284,7 +284,7 @@ static void	urtwn_calib_to_cb(struct urt
 static void	urtwn_next_scan(void *);
 static int	urtwn_newstate(struct ieee80211vap *, enum ieee80211_state,
 		int);
-// static void	urtwn_newstate_cb(struct urtwn_softc *, void *);
+//static void	urtwn_newstate_cb(struct urtwn_softc *, void *);
 static int	urtwn_wme_update(struct ieee80211com *);
 static void	urtwn_wme_update_cb(struct urtwn_softc *, void *);
 static void	urtwn_update_avgrssi(struct urtwn_softc *, int, int8_t);
@@ -346,6 +346,

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

2018-08-03 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Fri Aug  3 17:04:30 UTC 2018

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

Log Message:
don't set lwp->l_private if no _UC_TLSBASE flag.
atf lib/libc/sys/t_swapcontext Passed.


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

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

Modified files:

Index: src/sys/arch/aarch64/aarch64/cpu_machdep.c
diff -u src/sys/arch/aarch64/aarch64/cpu_machdep.c:1.5 src/sys/arch/aarch64/aarch64/cpu_machdep.c:1.6
--- src/sys/arch/aarch64/aarch64/cpu_machdep.c:1.5	Tue Jul 17 00:30:11 2018
+++ src/sys/arch/aarch64/aarch64/cpu_machdep.c	Fri Aug  3 17:04:30 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu_machdep.c,v 1.5 2018/07/17 00:30:11 christos Exp $ */
+/* $NetBSD: cpu_machdep.c,v 1.6 2018/08/03 17:04:30 ryo Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: cpu_machdep.c,v 1.5 2018/07/17 00:30:11 christos Exp $");
+__KERNEL_RCSID(1, "$NetBSD: cpu_machdep.c,v 1.6 2018/08/03 17:04:30 ryo Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -204,9 +204,11 @@ cpu_setmcontext(struct lwp *l, const mco
 			return error;
 
 		memcpy(&tf->tf_regs, mcp->__gregs, sizeof(tf->tf_regs));
-		l->l_private = (void *)mcp->__gregs[_REG_TPIDR];
 	}
 
+	if (flags & _UC_TLSBASE)
+		l->l_private = (void *)mcp->__gregs[_REG_TPIDR];
+
 	if (flags & _UC_FPU) {
 		struct pcb * const pcb = lwp_getpcb(l);
 		fpu_discard(l, true);



CVS commit: src/sys/arch/aarch64

2018-08-03 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Fri Aug  3 16:32:55 UTC 2018

Modified Files:
src/sys/arch/aarch64/aarch64: genassym.cf locore.S
src/sys/arch/aarch64/conf: kern.ldscript

Log Message:
set kernel text/rodata readonly when not defined DDB.
set readonly segment on 2Mbytes aligned. (kernel image is mapped with 2Mbytes 
L2 block)


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/aarch64/aarch64/genassym.cf
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/aarch64/aarch64/locore.S
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/aarch64/conf/kern.ldscript

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

Modified files:

Index: src/sys/arch/aarch64/aarch64/genassym.cf
diff -u src/sys/arch/aarch64/aarch64/genassym.cf:1.5 src/sys/arch/aarch64/aarch64/genassym.cf:1.6
--- src/sys/arch/aarch64/aarch64/genassym.cf:1.5	Tue Jul 17 10:01:59 2018
+++ src/sys/arch/aarch64/aarch64/genassym.cf	Fri Aug  3 16:32:55 2018
@@ -1,4 +1,4 @@
-# $NetBSD: genassym.cf,v 1.5 2018/07/17 10:01:59 ryo Exp $
+# $NetBSD: genassym.cf,v 1.6 2018/08/03 16:32:55 ryo Exp $
 #-
 # Copyright (c) 2014 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -120,6 +120,8 @@ define	L2_SIZE			L2_SIZE
 define	LX_BLKPAG_UXN		LX_BLKPAG_UXN
 define	LX_BLKPAG_PXN		LX_BLKPAG_PXN
 define	LX_BLKPAG_AF		LX_BLKPAG_AF
+define	LX_BLKPAG_AP		LX_BLKPAG_AP
+define	LX_BLKPAG_AP_RO		LX_BLKPAG_AP_RO
 define	LX_BLKPAG_AP_RW		LX_BLKPAG_AP_RW
 define	LX_BLKPAG_SH_IS		LX_BLKPAG_SH_IS
 define	LX_BLKPAG_ATTR_INDX_0	LX_BLKPAG_ATTR_INDX_0

Index: src/sys/arch/aarch64/aarch64/locore.S
diff -u src/sys/arch/aarch64/aarch64/locore.S:1.13 src/sys/arch/aarch64/aarch64/locore.S:1.14
--- src/sys/arch/aarch64/aarch64/locore.S:1.13	Tue Jul 17 18:08:36 2018
+++ src/sys/arch/aarch64/aarch64/locore.S	Fri Aug  3 16:32:55 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.13 2018/07/17 18:08:36 christos Exp $	*/
+/*	$NetBSD: locore.S,v 1.14 2018/08/03 16:32:55 ryo Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -35,7 +35,7 @@
 #include 
 #include "assym.h"
 
-RCSID("$NetBSD: locore.S,v 1.13 2018/07/17 18:08:36 christos Exp $")
+RCSID("$NetBSD: locore.S,v 1.14 2018/08/03 16:32:55 ryo Exp $")
 
 /* #define DEBUG_LOCORE */
 /* #define DEBUG_MMU */
@@ -650,9 +650,44 @@ arm_boot_l0pt_init:
 	lsr	x4, x4, #L2_SHIFT
 	bl	l2_setblocks
 
+#ifndef DDB
+	/* map READONLY from VM_MIN_KERNEL_ADDRESS to __data_start */
+	VERBOSE("Set kernel text/rodata READONLY\r\n")
+	ldr	x3, =__data_start
+	ands	x0, x3, #(L2_SIZE - 1)
+	beq	1f
+	ldr	x1, =_erodata
+	and	x1, x1, #L2_ADDR_BITS	/* _erodata & L2_ADDR_BIT */
+	and	x0, x3, #L2_ADDR_BITS	/* __data_start & L2_ADDR_BIT */
+	cmp	x0, x1
+	bne	1f
+	/* __data_start and _erodata are in same L2 block */
+	PRINT("Warning: data section not aligned on size of L2 block\r\n")
+1:
+	/* x3 = l2pde_index(__data_start) */
+	and	x3, x3, #L2_ADDR_BITS
+	lsr	x3, x3, #L2_SHIFT
+
+	/* x2 = l2pde_inex(VM_MIN_KERNEL_ADDRESS) */
+	mov	x2, #VM_MIN_KERNEL_ADDRESS
+	and	x2, x2, #L2_ADDR_BITS
+	lsr	x2, x2, #L2_SHIFT
+
+	ADDR	x1, ttbr1_l2table_kva
+	b	9f
+1:
+	ldr	x0, [x1, x2, lsl #3]	/* x0 = l2table[x2] */
+	and	x0, x0, #~LX_BLKPAG_AP
+	orr	x0, x0, #LX_BLKPAG_AP_RO
+	str	x0, [x1, x2, lsl #3]	/* l2table[x2] = x0 */
+	add	x2, x2, #1
+9:
+	cmp	x2, x3
+	blo	1b
+#endif
+
 	VERBOSE("Creating devmap tables\r\n")
 	/* devmap=PA table for L1 */
-nop
 	ADDR	x0, ttbr1_l1table_kva
 	ldr	x1, .L_devmap_addr
 	ADDR	x2, ttbr1_l2table_devmap

Index: src/sys/arch/aarch64/conf/kern.ldscript
diff -u src/sys/arch/aarch64/conf/kern.ldscript:1.5 src/sys/arch/aarch64/conf/kern.ldscript:1.6
--- src/sys/arch/aarch64/conf/kern.ldscript:1.5	Sun Apr  1 04:35:03 2018
+++ src/sys/arch/aarch64/conf/kern.ldscript	Fri Aug  3 16:32:55 2018
@@ -1,3 +1,5 @@
+#include "assym.h"
+
 /* Default linker script, for normal executables */
 OUTPUT_FORMAT("elf64-littleaarch64", "elf64-bigaarch64",
 	  "elf64-littleaarch64")
@@ -30,9 +32,11 @@ SECTIONS
   PROVIDE (__etext = .);
   PROVIDE (_etext = .);
   PROVIDE (etext = .);
-  /* Adjust the address for the data segment.  We want to adjust up to
- the same address within the page on the next page up.  */
-  . = ALIGN (CONSTANT (MAXPAGESIZE)) - ((CONSTANT (MAXPAGESIZE) - .) & (CONSTANT (MAXPAGESIZE) - 1)); . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));
+  /* Adjust the address for the data segment. Move .data to the next L2 block,
+ and .text and .rodata will be set readonly if needed. */
+  PROVIDE (_erodata = .);
+  . = ALIGN (L2_SIZE);
+  . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));
   /* Exception handling  */
   .eh_frame   : ONLY_IF_RW { KEEP (*(.eh_frame)) }
   .gcc_except_table   : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }



CVS commit: src/common/lib/libc/misc

2018-08-03 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Fri Aug  3 16:31:04 UTC 2018

Modified Files:
src/common/lib/libc/misc: ubsan.c

Log Message:
Try to fix the evbppc-powerpc64 build

Avoid "comparison between signed and unsigned integer expressions" on
Big-Endian hosts.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/common/lib/libc/misc/ubsan.c

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

Modified files:

Index: src/common/lib/libc/misc/ubsan.c
diff -u src/common/lib/libc/misc/ubsan.c:1.2 src/common/lib/libc/misc/ubsan.c:1.3
--- src/common/lib/libc/misc/ubsan.c:1.2	Fri Aug  3 03:12:32 2018
+++ src/common/lib/libc/misc/ubsan.c	Fri Aug  3 16:31:04 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ubsan.c,v 1.2 2018/08/03 03:12:32 kamil Exp $	*/
+/*	$NetBSD: ubsan.c,v 1.3 2018/08/03 16:31:04 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -38,9 +38,9 @@
 
 #include 
 #if defined(_KERNEL)
-__KERNEL_RCSID(0, "$NetBSD: ubsan.c,v 1.2 2018/08/03 03:12:32 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ubsan.c,v 1.3 2018/08/03 16:31:04 kamil Exp $");
 #else
-__RCSID("$NetBSD: ubsan.c,v 1.2 2018/08/03 03:12:32 kamil Exp $");
+__RCSID("$NetBSD: ubsan.c,v 1.3 2018/08/03 16:31:04 kamil Exp $");
 #endif
 
 #if defined(_KERNEL)
@@ -1269,7 +1269,7 @@ DeserializeUINT128(char *pBuffer, size_t
 #if BYTE_ORDER == LITTLE_ENDIAN
 	for (zI = sizeof(ulongest) - 1; zI >= 0; zI--) {
 #else
-	for (zI = 0; zI < sizeof(ulongest); zI++) {
+	for (zI = 0; zI < (ssize_t)sizeof(ulongest); zI++) {
 #endif
 		snprintf(szBuf, sizeof(szBuf), "%02" PRIx8, rgNumber[zI]);
 		strlcat(pBuffer, szBuf, zBUfferLength);



CVS commit: src/sys/arch

2018-08-03 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Aug  3 15:46:41 UTC 2018

Modified Files:
src/sys/arch/arm/arm32: arm32_kvminit.c
src/sys/arch/arm/broadcom: bcm283x_platform.c
src/sys/arch/arm/include/arm32: machdep.h
src/sys/arch/evbarm/rpi: rpi2_start.S rpi_start.S

Log Message:
Provide and use kern_vtopdiff in KERN_{VTOPHYS,PHYSTOV}.  A step towards
generic arm.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/arch/arm/arm32/arm32_kvminit.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/broadcom/bcm283x_platform.c
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/arm/include/arm32/machdep.h
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/evbarm/rpi/rpi2_start.S
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/evbarm/rpi/rpi_start.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/arm/arm32/arm32_kvminit.c
diff -u src/sys/arch/arm/arm32/arm32_kvminit.c:1.43 src/sys/arch/arm/arm32/arm32_kvminit.c:1.44
--- src/sys/arch/arm/arm32/arm32_kvminit.c:1.43	Tue Jul 31 10:31:02 2018
+++ src/sys/arch/arm/arm32/arm32_kvminit.c	Fri Aug  3 15:46:41 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: arm32_kvminit.c,v 1.43 2018/07/31 10:31:02 martin Exp $	*/
+/*	$NetBSD: arm32_kvminit.c,v 1.44 2018/08/03 15:46:41 skrll Exp $	*/
 
 /*
  * Copyright (c) 2002, 2003, 2005  Genetec Corporation.  All rights reserved.
@@ -126,7 +126,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: arm32_kvminit.c,v 1.43 2018/07/31 10:31:02 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: arm32_kvminit.c,v 1.44 2018/08/03 15:46:41 skrll Exp $");
 
 #include 
 #include 
@@ -175,21 +175,7 @@ extern char _end[];
 /* Page tables for mapping kernel VM */
 #define KERNEL_L2PT_VMDATA_NUM	8	/* start with 32MB of KVM */
 
-/*
- * Macros to translate between physical and virtual for a subset of the
- * kernel address space.  *Not* for general use.
- */
-#if defined(KERNEL_BASE_VOFFSET)
-#define KERN_VTOPHYS(bmi, va) \
-	((paddr_t)((vaddr_t)(va) - KERNEL_BASE_VOFFSET))
-#define KERN_PHYSTOV(bmi, pa) \
-	((vaddr_t)((paddr_t)(pa) + KERNEL_BASE_VOFFSET))
-#else
-#define KERN_VTOPHYS(bmi, va) \
-	((paddr_t)((vaddr_t)(va) - KERNEL_BASE + (bmi)->bmi_start))
-#define KERN_PHYSTOV(bmi, pa) \
-	((vaddr_t)((paddr_t)(pa) - (bmi)->bmi_start + KERNEL_BASE))
-#endif
+u_long kern_vtopdiff __attribute__((__section__(".data")));
 
 void
 arm32_bootmem_init(paddr_t memstart, psize_t memsize, vsize_t kernelstart)
@@ -197,6 +183,16 @@ arm32_bootmem_init(paddr_t memstart, psi
 	struct bootmem_info * const bmi = &bootmem_info;
 	pv_addr_t *pv = bmi->bmi_freeblocks;
 
+	/*
+	 * FDT/generic boot fills in kern_vtopdiff early
+	 */
+#if defined(KERNEL_BASE_VOFFSET)
+	kern_vtopdiff = KERNEL_BASE_VOFFSET;
+#else
+	KASSERT(memstart == kernelstart);
+	kern_vtopdiff = KERNEL_BASE + memstart;
+#endif
+
 	VPRINTF("%s: memstart=%#lx, memsize=%#lx, kernelstart=%#lx\n",
 	__func__, memstart, memsize, kernelstart);
 
@@ -217,7 +213,7 @@ arm32_bootmem_init(paddr_t memstart, psi
 	 * Let's record where the kernel lives.
 	 */
 	bmi->bmi_kernelstart = kernelstart;
-	bmi->bmi_kernelend = KERN_VTOPHYS(bmi, round_page((vaddr_t)_end));
+	bmi->bmi_kernelend = KERN_VTOPHYS(round_page((vaddr_t)_end));
 
 #if defined(FDT)
 	fdt_add_reserved_memory_range(bmi->bmi_kernelstart,
@@ -230,7 +226,7 @@ arm32_bootmem_init(paddr_t memstart, psi
 	 * Now the rest of the free memory must be after the kernel.
 	 */
 	pv->pv_pa = bmi->bmi_kernelend;
-	pv->pv_va = KERN_PHYSTOV(bmi, pv->pv_pa);
+	pv->pv_va = KERN_PHYSTOV(pv->pv_pa);
 	pv->pv_size = bmi->bmi_end - bmi->bmi_kernelend;
 	bmi->bmi_freepages += pv->pv_size / PAGE_SIZE;
 	VPRINTF("%s: adding %lu free pages: [%#lx..%#lx] (VA %#lx)\n",
@@ -244,7 +240,7 @@ arm32_bootmem_init(paddr_t memstart, psi
 	 */
 	if (bmi->bmi_start < bmi->bmi_kernelstart) {
 		pv->pv_pa = bmi->bmi_start;
-		pv->pv_va = KERN_PHYSTOV(bmi, pv->pv_pa);
+		pv->pv_va = KERN_PHYSTOV(pv->pv_pa);
 		pv->pv_size = bmi->bmi_kernelstart - pv->pv_pa;
 		bmi->bmi_freepages += pv->pv_size / PAGE_SIZE;
 		VPRINTF("%s: adding %lu free pages: [%#lx..%#lx] (VA %#lx)\n",
@@ -627,7 +623,7 @@ arm32_kernel_vm_init(vaddr_t kernel_vm_b
 	}
 
 	const vaddr_t kernel_base =
-	KERN_PHYSTOV(bmi, bmi->bmi_kernelstart & -L2_S_SEGSIZE);
+	KERN_PHYSTOV(bmi->bmi_kernelstart & -L2_S_SEGSIZE);
 	for (size_t idx = 0; idx < KERNEL_L2PT_KERNEL_NUM; idx++) {
 		pmap_link_l2pt(l1pt_va, kernel_base + idx * L2_S_SEGSIZE,
 		&kernel_l2pt[idx]);
@@ -656,16 +652,16 @@ arm32_kernel_vm_init(vaddr_t kernel_vm_b
 
 	VPRINTF("Mapping kernel\n");
 
-	extern char etext[], _end[];
+	extern char etext[];
 	size_t totalsize = bmi->bmi_kernelend - bmi->bmi_kernelstart;
-	size_t textsize = KERN_VTOPHYS(bmi, (uintptr_t)etext) - bmi->bmi_kernelstart;
+	size_t textsize = KERN_VTOPHYS((uintptr_t)etext) - bmi->bmi_kernelstart;
 
 	textsize = (textsize + PGOFSET) & ~PGOFSET;
 
 	/* start at

CVS commit: src/sys/arch/evbarm/rpi

2018-08-03 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Aug  3 15:38:16 UTC 2018

Modified Files:
src/sys/arch/evbarm/rpi: rpi_start.S

Log Message:
Subtract KERNEL_BASE_VOFFSET from all VAs to get PA.  How did this work
before?


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/evbarm/rpi/rpi_start.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/evbarm/rpi/rpi_start.S
diff -u src/sys/arch/evbarm/rpi/rpi_start.S:1.18 src/sys/arch/evbarm/rpi/rpi_start.S:1.19
--- src/sys/arch/evbarm/rpi/rpi_start.S:1.18	Wed Jun 27 11:12:15 2018
+++ src/sys/arch/evbarm/rpi/rpi_start.S	Fri Aug  3 15:38:16 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: rpi_start.S,v 1.18 2018/06/27 11:12:15 ryo Exp $	*/
+/*	$NetBSD: rpi_start.S,v 1.19 2018/08/03 15:38:16 skrll Exp $	*/
 
 /*
  * Copyright (c) 2002, 2003  Genetec Corporation.  All rights reserved.
@@ -96,7 +96,7 @@
 #include 
 #include "assym.h"
 
-RCSID("$NetBSD: rpi_start.S,v 1.18 2018/06/27 11:12:15 ryo Exp $")
+RCSID("$NetBSD: rpi_start.S,v 1.19 2018/08/03 15:38:16 skrll Exp $")
 
 
 #if defined(VERBOSE_INIT_ARM)
@@ -141,16 +141,16 @@ _C_LABEL(rpi_start):
 #if defined(VERBOSE_INIT_ARM)
 	/* stack for calling bcm2835_platform_early_putchar() */
 	ldr	sp, Lbootstk
-#if !defined(KERNEL_BASES_EQUAL)
 	sub	sp, sp, #KERNEL_BASE_VOFFSET
-#endif
 #endif /* VERBOSE_INIT_ARM */
 
 	ldr	r8, Luboot_args
+	sub	r8, r8, #KERNEL_BASE_VOFFSET
 	stmia	r8!, {r0-r3}
 
 #ifdef FDT
 	ldr	r8, Lfdt_addr_r
+	sub	r8, r8, #KERNEL_BASE_VOFFSET
 	str	r2, [r8]
 #endif
 	mrs	r0, cpsr



CVS commit: src/lib/libc

2018-08-03 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Fri Aug  3 14:01:21 UTC 2018

Modified Files:
src/lib/libc: Makefile

Log Message:
Restrict -fno-sanitize=function to Clang/LLVM only

The base GCC version 6,x does not support this option.


To generate a diff of this commit:
cvs rdiff -u -r1.171 -r1.172 src/lib/libc/Makefile

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

Modified files:

Index: src/lib/libc/Makefile
diff -u src/lib/libc/Makefile:1.171 src/lib/libc/Makefile:1.172
--- src/lib/libc/Makefile:1.171	Fri Aug  3 02:29:35 2018
+++ src/lib/libc/Makefile	Fri Aug  3 14:01:21 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.171 2018/08/03 02:29:35 kamil Exp $
+#	$NetBSD: Makefile,v 1.172 2018/08/03 14:01:21 kamil Exp $
 #	@(#)Makefile	8.2 (Berkeley) 2/3/94
 #
 # All library objects contain sccsid strings by default; they may be
@@ -17,7 +17,9 @@
 # The Hesiod functions are always in libc. To choose that getpwent() and friends
 # actually call the Hesiod functions, put -DHESIOD on the CPPFLAGS line below.
 
-LIBCSANITIZERFLAGS+=	-fno-sanitize=function	# generated code depends on RTTI
+
+# generated code depends on RTTI
+LIBCSANITIZERFLAGS+=	${${ACTIVE_CC} == "clang":? -fno-sanitize=function :}
 
 .include "Makefile.inc"
 



CVS commit: src/sys/arch

2018-08-03 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Aug  3 13:48:24 UTC 2018

Modified Files:
src/sys/arch/arm/broadcom: bcm283x_platform.c
src/sys/arch/evbarm/fdt: fdt_machdep.c
Added Files:
src/sys/arch/evbarm/fdt: machdep.h

Log Message:
Provide and use a evbarm/fdt/machdep.h


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/broadcom/bcm283x_platform.c
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/evbarm/fdt/fdt_machdep.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/evbarm/fdt/machdep.h

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

Modified files:

Index: src/sys/arch/arm/broadcom/bcm283x_platform.c
diff -u src/sys/arch/arm/broadcom/bcm283x_platform.c:1.8 src/sys/arch/arm/broadcom/bcm283x_platform.c:1.9
--- src/sys/arch/arm/broadcom/bcm283x_platform.c:1.8	Mon Jul 16 23:11:47 2018
+++ src/sys/arch/arm/broadcom/bcm283x_platform.c	Fri Aug  3 13:48:24 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: bcm283x_platform.c,v 1.8 2018/07/16 23:11:47 christos Exp $	*/
+/*	$NetBSD: bcm283x_platform.c,v 1.9 2018/08/03 13:48:24 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2017 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bcm283x_platform.c,v 1.8 2018/07/16 23:11:47 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm283x_platform.c,v 1.9 2018/08/03 13:48:24 skrll Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_bcm283x.h"
@@ -64,9 +64,7 @@ __KERNEL_RCSID(0, "$NetBSD: bcm283x_plat
 #include 
 
 #include 
-#ifdef __aarch64__
-#include 
-#endif
+
 #include 
 #include 
 
@@ -81,6 +79,7 @@ __KERNEL_RCSID(0, "$NetBSD: bcm283x_plat
 
 #include 
 #include 
+#include 
 
 #include 
 #include 

Index: src/sys/arch/evbarm/fdt/fdt_machdep.c
diff -u src/sys/arch/evbarm/fdt/fdt_machdep.c:1.29 src/sys/arch/evbarm/fdt/fdt_machdep.c:1.30
--- src/sys/arch/evbarm/fdt/fdt_machdep.c:1.29	Fri Aug  3 12:48:33 2018
+++ src/sys/arch/evbarm/fdt/fdt_machdep.c	Fri Aug  3 13:48:24 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: fdt_machdep.c,v 1.29 2018/08/03 12:48:33 skrll Exp $ */
+/* $NetBSD: fdt_machdep.c,v 1.30 2018/08/03 13:48:24 skrll Exp $ */
 
 /*-
  * Copyright (c) 2015-2017 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fdt_machdep.c,v 1.29 2018/08/03 12:48:33 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdt_machdep.c,v 1.30 2018/08/03 13:48:24 skrll Exp $");
 
 #include "opt_machdep.h"
 #include "opt_bootconfig.h"
@@ -68,14 +68,9 @@ __KERNEL_RCSID(0, "$NetBSD: fdt_machdep.
 #include 
 
 #include 
-#ifdef __aarch64__
-#include 
-#else
-#include 
-#endif
-
 
 #include 
+#include 
 #include 
 
 #include 

Added files:

Index: src/sys/arch/evbarm/fdt/machdep.h
diff -u /dev/null src/sys/arch/evbarm/fdt/machdep.h:1.1
--- /dev/null	Fri Aug  3 13:48:24 2018
+++ src/sys/arch/evbarm/fdt/machdep.h	Fri Aug  3 13:48:24 2018
@@ -0,0 +1,43 @@
+/* $NetBSD: machdep.h,v 1.1 2018/08/03 13:48:24 skrll Exp $ */
+
+/*-
+ * Copyright (c) 2018 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Nick Hudson
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _EVBARM_FDT_MACHDEP_H
+#define _EVBARM_FDT_MACHDEP_H
+
+#ifdef __aarch64__
+#include 
+#endif
+
+#ifdef __arm__
+#include 
+#endif
+
+#endif /* _EVBARM_FDT_MACHDEP_H */



CVS commit: src/sys/dev/usb

2018-08-03 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Aug  3 13:19:33 UTC 2018

Modified Files:
src/sys/dev/usb: umcs.c

Log Message:
Fix build


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/dev/usb/umcs.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/umcs.c
diff -u src/sys/dev/usb/umcs.c:1.11 src/sys/dev/usb/umcs.c:1.12
--- src/sys/dev/usb/umcs.c:1.11	Sun Jul 29 02:07:56 2018
+++ src/sys/dev/usb/umcs.c	Fri Aug  3 13:19:33 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: umcs.c,v 1.11 2018/07/29 02:07:56 riastradh Exp $ */
+/* $NetBSD: umcs.c,v 1.12 2018/08/03 13:19:33 skrll Exp $ */
 /* $FreeBSD: head/sys/dev/usb/serial/umcs.c 260559 2014-01-12 11:44:28Z hselasky $ */
 
 /*-
@@ -41,7 +41,7 @@
  *
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: umcs.c,v 1.11 2018/07/29 02:07:56 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: umcs.c,v 1.12 2018/08/03 13:19:33 skrll Exp $");
 
 #include 
 #include 
@@ -517,7 +517,8 @@ umcs7840_detach(device_t self, int flags
 		kmem_free(sc->sc_intr_buf, sc->sc_intr_buflen);
 		sc->sc_intr_pipe = NULL;
 	}
-	usb_rem_task_wait(sc->sc_udev, &sc->sc_change_task, USB_TASKQ_DRIVER);
+	usb_rem_task_wait(sc->sc_udev, &sc->sc_change_task, USB_TASKQ_DRIVER,
+	NULL);
 
 	/* detach children */
 	for (i = 0; i < sc->sc_numports; i++) {



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

2018-08-03 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Fri Aug  3 12:49:41 UTC 2018

Modified Files:
src/crypto/external/bsd/openssh/dist: sshkey.c

Log Message:
Add a "gcc is stupid" comment to the previous change, as even
the most cursory analysis shows that the var ("eg") is not (cannot
be) used unitialialised, just gcc is too dumb to work it out.

In this case, the code could be rewritten easily enough to
appease even gcc, but that would cause unnecessary code churn,
and some minor duplication, so just put up with the nonsense init...


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/crypto/external/bsd/openssh/dist/sshkey.c

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

Modified files:

Index: src/crypto/external/bsd/openssh/dist/sshkey.c
diff -u src/crypto/external/bsd/openssh/dist/sshkey.c:1.15 src/crypto/external/bsd/openssh/dist/sshkey.c:1.16
--- src/crypto/external/bsd/openssh/dist/sshkey.c:1.15	Fri Aug  3 04:32:12 2018
+++ src/crypto/external/bsd/openssh/dist/sshkey.c	Fri Aug  3 12:49:41 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: sshkey.c,v 1.15 2018/08/03 04:32:12 kamil Exp $	*/
+/*	$NetBSD: sshkey.c,v 1.16 2018/08/03 12:49:41 kre Exp $	*/
 /* $OpenBSD: sshkey.c,v 1.64 2018/03/22 07:05:48 markus Exp $ */
 /*
  * Copyright (c) 2000, 2001 Markus Friedl.  All rights reserved.
@@ -26,7 +26,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "includes.h"
-__RCSID("$NetBSD: sshkey.c,v 1.15 2018/08/03 04:32:12 kamil Exp $");
+__RCSID("$NetBSD: sshkey.c,v 1.16 2018/08/03 12:49:41 kre Exp $");
 
 #include 
 #include 
@@ -1641,7 +1641,7 @@ dsa_generate_private_key(u_int bits, DSA
 int
 sshkey_ecdsa_key_to_nid(EC_KEY *k)
 {
-	EC_GROUP *eg = NULL;
+	EC_GROUP *eg = NULL;		/* XXXGCC: unneeded init */
 	int nids[] = {
 		NID_X9_62_prime256v1,
 		NID_secp384r1,



CVS commit: src/sys/arch/evbarm/fdt

2018-08-03 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Aug  3 12:48:33 UTC 2018

Modified Files:
src/sys/arch/evbarm/fdt: fdt_machdep.c

Log Message:
s/DPRINTF/VPRINTF/ for consistency


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/evbarm/fdt/fdt_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/evbarm/fdt/fdt_machdep.c
diff -u src/sys/arch/evbarm/fdt/fdt_machdep.c:1.28 src/sys/arch/evbarm/fdt/fdt_machdep.c:1.29
--- src/sys/arch/evbarm/fdt/fdt_machdep.c:1.28	Fri Aug  3 07:44:31 2018
+++ src/sys/arch/evbarm/fdt/fdt_machdep.c	Fri Aug  3 12:48:33 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: fdt_machdep.c,v 1.28 2018/08/03 07:44:31 skrll Exp $ */
+/* $NetBSD: fdt_machdep.c,v 1.29 2018/08/03 12:48:33 skrll Exp $ */
 
 /*-
  * Copyright (c) 2015-2017 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fdt_machdep.c,v 1.28 2018/08/03 07:44:31 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdt_machdep.c,v 1.29 2018/08/03 12:48:33 skrll Exp $");
 
 #include "opt_machdep.h"
 #include "opt_bootconfig.h"
@@ -156,9 +156,9 @@ earlyconsgetc(dev_t dev)
 }
 
 #ifdef VERBOSE_INIT_ARM
-#define DPRINTF(...)	printf(__VA_ARGS__)
+#define VPRINTF(...)	printf(__VA_ARGS__)
 #else
-#define DPRINTF(...)
+#define VPRINTF(...)
 #endif
 
 /*
@@ -179,13 +179,13 @@ fdt_get_memory(uint64_t *pstart, uint64_
 	*pstart = cur_addr;
 	*pend = cur_addr + cur_size;
 
-	DPRINTF("FDT /memory [%d] @ 0x%" PRIx64 " size 0x%" PRIx64 "\n",
+	VPRINTF("FDT /memory [%d] @ 0x%" PRIx64 " size 0x%" PRIx64 "\n",
 	0, *pstart, *pend - *pstart);
 
 	for (index = 1;
 	 fdtbus_get_reg64(memory, index, &cur_addr, &cur_size) == 0;
 	 index++) {
-		DPRINTF("FDT /memory [%d] @ 0x%" PRIx64 " size 0x%" PRIx64 "\n",
+		VPRINTF("FDT /memory [%d] @ 0x%" PRIx64 " size 0x%" PRIx64 "\n",
 		index, cur_addr, cur_size);
 
 #ifdef __aarch64__
@@ -211,7 +211,7 @@ fdt_add_reserved_memory_range(uint64_t a
 		printf("MEM ERROR: res %" PRIx64 "-%" PRIx64 " failed: %d\n",
 		start, end, error);
 	else
-		DPRINTF("MEM: res %" PRIx64 "-%" PRIx64 "\n", start, end);
+		VPRINTF("MEM: res %" PRIx64 "-%" PRIx64 "\n", start, end);
 }
 
 /*
@@ -265,7 +265,7 @@ fdt_build_bootconfig(uint64_t mem_start,
 		if (error != 0)
 			printf("MEM ERROR: add %" PRIx64 "-%" PRIx64 " failed: %d\n",
 			addr, addr + size, error);
-		DPRINTF("MEM: add %" PRIx64 "-%" PRIx64 "\n", addr, addr + size);
+		VPRINTF("MEM: add %" PRIx64 "-%" PRIx64 "\n", addr, addr + size);
 	}
 
 	fdt_add_reserved_memory(mem_end);
@@ -274,10 +274,10 @@ fdt_build_bootconfig(uint64_t mem_start,
 	if (initrd_size > 0)
 		fdt_add_reserved_memory_range(initrd_start, initrd_size);
 
-	DPRINTF("Usable memory:\n");
+	VPRINTF("Usable memory:\n");
 	bc->dramblocks = 0;
 	LIST_FOREACH(er, &fdt_memory_ext->ex_regions, er_link) {
-		DPRINTF("  %lx - %lx\n", er->er_start, er->er_end);
+		VPRINTF("  %lx - %lx\n", er->er_start, er->er_end);
 		bc->dram[bc->dramblocks].address = er->er_start;
 		bc->dram[bc->dramblocks].pages =
 		(er->er_end - er->er_start) / PAGE_SIZE;
@@ -378,25 +378,25 @@ initarm(void *arg)
 		panic("Kernel does not support this device");
 
 	/* Early console may be available, announce ourselves. */
-	DPRINTF("FDT<%p>\n", fdt_addr_r);
+	VPRINTF("FDT<%p>\n", fdt_addr_r);
 
 	const int chosen = OF_finddevice("/chosen");
 	if (chosen >= 0)
 		OF_getprop(chosen, "bootargs", bootargs, sizeof(bootargs));
 	boot_args = bootargs;
 
-	DPRINTF("devmap\n");
+	VPRINTF("devmap\n");
 	pmap_devmap_register(plat->devmap());
 #ifdef __aarch64__
 	pmap_devmap_bootstrap(plat->devmap());
 #endif
 
 	/* Heads up ... Setup the CPU / MMU / TLB functions. */
-	DPRINTF("cpufunc\n");
+	VPRINTF("cpufunc\n");
 	if (set_cpufuncs())
 		panic("cpu not recognized!");
 
-	DPRINTF("bootstrap\n");
+	VPRINTF("bootstrap\n");
 	plat->bootstrap();
 
 	/*
@@ -405,11 +405,11 @@ initarm(void *arg)
 	 */
 	fdt_update_stdout_path();
 
-	DPRINTF("consinit ");
+	VPRINTF("consinit ");
 	consinit();
-	DPRINTF("ok\n");
+	VPRINTF("ok\n");
 
-	DPRINTF("uboot: args %#lx, %#lx, %#lx, %#lx\n",
+	VPRINTF("uboot: args %#lx, %#lx, %#lx, %#lx\n",
 	uboot_args[0], uboot_args[1], uboot_args[2], uboot_args[3]);
 
 	cpu_reset_address = fdt_reset;
@@ -417,7 +417,7 @@ initarm(void *arg)
 	evbarm_device_register = fdt_device_register;
 
 	/* Talk to the user */
-	DPRINTF("\nNetBSD/evbarm (fdt) booting ...\n");
+	VPRINTF("\nNetBSD/evbarm (fdt) booting ...\n");
 
 #ifdef BOOT_ARGS
 	char mi_bootargs[] = BOOT_ARGS;
@@ -425,7 +425,7 @@ initarm(void *arg)
 #endif
 
 #ifndef __aarch64__
-	DPRINTF("KERNEL_BASE=0x%x, "
+	VPRINTF("KERNEL_BASE=0x%x, "
 		"KERNEL_VM_BASE=0x%x, "
 		"KERNEL_VM_BASE - KERNEL_BASE=0x%x, "
 		"KERNEL_BASE_VOFFSET=0x%x\n",
@@ -450,7 +450,7 @@ initarm(void *arg)
 	const bool mapallmem_p = true;
 #ifndef PMAP_NEED_ALLOC_POOLPAGE
 	if (memory_size > KERNEL_VM_BASE - KERNEL_BASE) {

CVS commit: src/sys/net

2018-08-03 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Aug  3 11:24:19 UTC 2018

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

Log Message:
Use a different psz for a different lock. Patch from riastradh, reviewed
by ozaki-r.


To generate a diff of this commit:
cvs rdiff -u -r1.130 -r1.131 src/sys/net/if_vlan.c

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

Modified files:

Index: src/sys/net/if_vlan.c
diff -u src/sys/net/if_vlan.c:1.130 src/sys/net/if_vlan.c:1.131
--- src/sys/net/if_vlan.c:1.130	Tue Jun 26 06:48:02 2018
+++ src/sys/net/if_vlan.c	Fri Aug  3 11:24:19 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vlan.c,v 1.130 2018/06/26 06:48:02 msaitoh Exp $	*/
+/*	$NetBSD: if_vlan.c,v 1.131 2018/08/03 11:24:19 jmcneill Exp $	*/
 
 /*
  * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
@@ -78,7 +78,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v 1.130 2018/06/26 06:48:02 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v 1.131 2018/08/03 11:24:19 jmcneill Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -161,6 +161,7 @@ struct ifvlan {
 	 * instead of direct dereference
 	 */
 	kmutex_t ifv_lock;		/* writer lock for ifv_mib */
+	pserialize_t ifv_psz;
 
 	LIST_HEAD(__vlan_mchead, vlan_mc_entry) ifv_mc_listhead;
 	LIST_ENTRY(ifvlan) ifv_list;
@@ -355,6 +356,7 @@ vlan_clone_create(struct if_clone *ifc, 
 	psref_target_init(&mib->ifvm_psref, ifvm_psref_class);
 
 	mutex_init(&ifv->ifv_lock, MUTEX_DEFAULT, IPL_NONE);
+	ifv->ifv_psz = pserialize_create();
 	ifv->ifv_mib = mib;
 
 	mutex_enter(&ifv_list.lock);
@@ -792,7 +794,7 @@ vlan_linkmib_update(struct ifvlan *ifv, 
 	membar_producer();
 	ifv->ifv_mib = nmib;
 
-	pserialize_perform(vlan_psz);
+	pserialize_perform(ifv->ifv_psz);
 	psref_target_destroy(&omib->ifvm_psref, ifvm_psref_class);
 }
 



CVS commit: src/sys/arch/usermode

2018-08-03 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Fri Aug  3 11:18:22 UTC 2018

Modified Files:
src/sys/arch/usermode/include: vmparam.h
src/sys/arch/usermode/usermode: db_memrw.c pmap.c

Log Message:
Allow for setting kernel breakpoints in our remote kgdb


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/usermode/include/vmparam.h
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/usermode/usermode/db_memrw.c
cvs rdiff -u -r1.111 -r1.112 src/sys/arch/usermode/usermode/pmap.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/usermode/include/vmparam.h
diff -u src/sys/arch/usermode/include/vmparam.h:1.19 src/sys/arch/usermode/include/vmparam.h:1.20
--- src/sys/arch/usermode/include/vmparam.h:1.19	Wed Aug  1 12:09:02 2018
+++ src/sys/arch/usermode/include/vmparam.h	Fri Aug  3 11:18:22 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: vmparam.h,v 1.19 2018/08/01 12:09:02 reinoud Exp $ */
+/* $NetBSD: vmparam.h,v 1.20 2018/08/03 11:18:22 reinoud Exp $ */
 
 /*-
  * Copyright (c) 2007 Jared D. McNeill 
@@ -43,7 +43,7 @@ extern paddr_t kmem_user_start, kmem_use
 #define VM_MAX_ADDRESS		kmem_user_end
 #define VM_MAXUSER_ADDRESS	kmem_user_end
 #define VM_MIN_KERNEL_ADDRESS	kmem_kvm_start
-#define VM_MAX_KERNEL_ADDRESS 	kmem_kvm_end
+#define VM_MAX_KERNEL_ADDRESS 	kmem_k_end
 
 #define VM_PHYSSEG_STRAT	VM_PSTRAT_BIGFIRST
 #define VM_PHYSSEG_MAX		1

Index: src/sys/arch/usermode/usermode/db_memrw.c
diff -u src/sys/arch/usermode/usermode/db_memrw.c:1.2 src/sys/arch/usermode/usermode/db_memrw.c:1.3
--- src/sys/arch/usermode/usermode/db_memrw.c:1.2	Wed Aug  1 10:27:28 2018
+++ src/sys/arch/usermode/usermode/db_memrw.c	Fri Aug  3 11:18:22 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_memrw.c,v 1.2 2018/08/01 10:27:28 reinoud Exp $	*/
+/*	$NetBSD: db_memrw.c,v 1.3 2018/08/03 11:18:22 reinoud Exp $	*/
 
 /*-
  * Copyright (c) 1996, 2000 The NetBSD Foundation, Inc.
@@ -53,11 +53,12 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_memrw.c,v 1.2 2018/08/01 10:27:28 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_memrw.c,v 1.3 2018/08/03 11:18:22 reinoud Exp $");
 
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -211,29 +212,30 @@ db_write_text(vaddr_t addr, size_t size,
 void
 db_write_bytes(vaddr_t addr, size_t size, const char *data)
 {
-//	extern struct bootspace bootspace;
 	char *dst;
-//	size_t i;
+	int ret;
 
 	dst = (char *)addr;
 	thunk_printf_debug("\n%s : %p + %d\n", __func__, dst, (int) size);
-#if 0
-	// TODO: check if we in kernel range and if so, do the mmap dance
-	// ourselves?
 
-	/* If any part is in kernel text or rodata, use db_write_text() */
-	for (i = 0; i < BTSPACE_NSEGS; i++) {
-		if (bootspace.segs[i].type != BTSEG_TEXT &&
-		bootspace.segs[i].type != BTSEG_RODATA) {
-			continue;
-		}
-		if (addr >= bootspace.segs[i].va &&
-		addr < (bootspace.segs[i].va + bootspace.segs[i].sz)) {
-			db_write_text(addr, size, data);
-			return;
-		}
+	if (db_validate_address((vaddr_t)addr)) {
+		printf("address %p is invalid\n", (void *) addr);
+		return;
+	}
+
+	/*
+	 * if we are in the kernel range, just allow writing by using
+	 * mprotect(); Note that this needs an unprotected binary, set with
+	 * `paxctl -agm netbsd`
+	 */
+	if (addr > kmem_k_start) {
+		ret = thunk_mprotect((void *) trunc_page(addr), PAGE_SIZE,
+			PROT_READ | PROT_WRITE | PROT_EXEC);
+		if (ret != 0)
+			panic("please unprotect kernel binary with "
+			  "`paxctl -agm netbsd`");
+		assert(ret == 0);
 	}
-#endif
 
 	dst = (char *)addr;
 

Index: src/sys/arch/usermode/usermode/pmap.c
diff -u src/sys/arch/usermode/usermode/pmap.c:1.111 src/sys/arch/usermode/usermode/pmap.c:1.112
--- src/sys/arch/usermode/usermode/pmap.c:1.111	Fri Aug  3 06:52:50 2018
+++ src/sys/arch/usermode/usermode/pmap.c	Fri Aug  3 11:18:22 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.111 2018/08/03 06:52:50 reinoud Exp $ */
+/* $NetBSD: pmap.c,v 1.112 2018/08/03 11:18:22 reinoud Exp $ */
 
 /*-
  * Copyright (c) 2011 Reinoud Zandijk 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.111 2018/08/03 06:52:50 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.112 2018/08/03 11:18:22 reinoud Exp $");
 
 #include "opt_memsize.h"
 #include "opt_kmempages.h"
@@ -139,7 +139,7 @@ pmap_bootstrap(void)
 	struct pmap *pmap;
 	paddr_t DRAM_cfg;
 	paddr_t fpos, file_len;
-	paddr_t pv_fpos, tlb_fpos, pm_l1_fpos, pm_fpos;
+	paddr_t kernel_fpos, pv_fpos, tlb_fpos, pm_l1_fpos, pm_fpos;
 	paddr_t wlen;
 	paddr_t barrier_len;
 	paddr_t pv_table_size;
@@ -281,9 +281,11 @@ pmap_bootstrap(void)
 	assert(err == 0);
 
 	/* map the kernel at the start of the 'memory' file */
-	written = thunk_pwrite(mem_fh, (void *) kmem_k_start, kmem_k_length, 0);
+	kernel_fpos = 0;
+	written = thunk_pwrite(mem_fh, (void *) kmem_k_start, kmem_k_length,
+			kernel_fpos);
 	assert(written == kmem_k_length);
-	fpos = kmem_k_length;

CVS commit: src/sys/net

2018-08-03 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Fri Aug  3 09:54:40 UTC 2018

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

Log Message:
tun: fix locking against myself

filt_tunread is called with tun_lock held from tun_output (via tun_output =>
selnotify => knote), so we must not take tun_lock in filt_tunread.  The bug
is triggered only if a tun is used through kqueue.

Found by k-goda@IIJ


To generate a diff of this commit:
cvs rdiff -u -r1.144 -r1.145 src/sys/net/if_tun.c

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

Modified files:

Index: src/sys/net/if_tun.c
diff -u src/sys/net/if_tun.c:1.144 src/sys/net/if_tun.c:1.145
--- src/sys/net/if_tun.c:1.144	Tue Jun 26 06:48:02 2018
+++ src/sys/net/if_tun.c	Fri Aug  3 09:54:40 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_tun.c,v 1.144 2018/06/26 06:48:02 msaitoh Exp $	*/
+/*	$NetBSD: if_tun.c,v 1.145 2018/08/03 09:54:40 ozaki-r Exp $	*/
 
 /*
  * Copyright (c) 1988, Julian Onions 
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_tun.c,v 1.144 2018/06/26 06:48:02 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_tun.c,v 1.145 2018/08/03 09:54:40 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1058,18 +1058,15 @@ filt_tunread(struct knote *kn, long hint
 	struct ifnet *ifp = &tp->tun_if;
 	struct mbuf *m;
 
-	mutex_enter(&tp->tun_lock);
+	KASSERT(mutex_owned(&tp->tun_lock));
+
 	IF_POLL(&ifp->if_snd, m);
-	if (m == NULL) {
-		mutex_exit(&tp->tun_lock);
+	if (m == NULL)
 		return 0;
-	}
 
 	for (kn->kn_data = 0; m != NULL; m = m->m_next)
 		kn->kn_data += m->m_len;
 
-	mutex_exit(&tp->tun_lock);
-
 	return 1;
 }
 



CVS commit: src/sys/arch/evbarm/fdt

2018-08-03 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Aug  3 07:44:31 UTC 2018

Modified Files:
src/sys/arch/evbarm/fdt: fdt_machdep.c

Log Message:
Mark fdt_addr_r __attribute__((__section__(".data")))


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/evbarm/fdt/fdt_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/evbarm/fdt/fdt_machdep.c
diff -u src/sys/arch/evbarm/fdt/fdt_machdep.c:1.27 src/sys/arch/evbarm/fdt/fdt_machdep.c:1.28
--- src/sys/arch/evbarm/fdt/fdt_machdep.c:1.27	Tue Jul 17 19:12:55 2018
+++ src/sys/arch/evbarm/fdt/fdt_machdep.c	Fri Aug  3 07:44:31 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: fdt_machdep.c,v 1.27 2018/07/17 19:12:55 christos Exp $ */
+/* $NetBSD: fdt_machdep.c,v 1.28 2018/08/03 07:44:31 skrll Exp $ */
 
 /*-
  * Copyright (c) 2015-2017 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fdt_machdep.c,v 1.27 2018/07/17 19:12:55 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdt_machdep.c,v 1.28 2018/08/03 07:44:31 skrll Exp $");
 
 #include "opt_machdep.h"
 #include "opt_bootconfig.h"
@@ -98,8 +98,7 @@ char *boot_args = NULL;
 
 /* filled in before cleaning bss. keep in .data */
 u_long uboot_args[4] __attribute__((__section__(".data")));
-
-const uint8_t *fdt_addr_r = (const uint8_t *)0xdeadc0de;
+const uint8_t *fdt_addr_r __attribute__((__section__(".data")));
 
 static char fdt_memory_ext_storage[EXTENT_FIXED_STORAGE_SIZE(DRAM_BLOCKS)];
 static struct extent *fdt_memory_ext;