CVS commit: src/sys/dev/videomode

2018-07-09 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue Jul 10 01:44:30 UTC 2018

Modified Files:
src/sys/dev/videomode: edid.c

Log Message:
add quirk to find the native resolution on certain Iiyama monitors
tested by MOCHIDA Shuji


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/dev/videomode/edid.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/videomode/edid.c
diff -u src/sys/dev/videomode/edid.c:1.13 src/sys/dev/videomode/edid.c:1.14
--- src/sys/dev/videomode/edid.c:1.13	Mon Nov 17 00:46:04 2014
+++ src/sys/dev/videomode/edid.c	Tue Jul 10 01:44:30 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: edid.c,v 1.13 2014/11/17 00:46:04 jmcneill Exp $ */
+/* $NetBSD: edid.c,v 1.14 2018/07/10 01:44:30 macallan Exp $ */
 
 /*-
  * Copyright (c) 2006 Itronix Inc.
@@ -32,7 +32,7 @@
  */ 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: edid.c,v 1.13 2014/11/17 00:46:04 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: edid.c,v 1.14 2018/07/10 01:44:30 macallan Exp $");
 
 #include 
 #include 
@@ -420,6 +420,22 @@ edid_det_timing(uint8_t *data, struct vi
 	return 1;
 }
 
+static void bump_preferred_mode(struct edid_info *edid, struct videomode *m)
+{
+	/*
+	 * XXX
+	 * Iiyama 4800 series monitors may have their native resolution in the
+	 * 2nd detailed timing descriptor instead of the 1st. Try to detect
+	 * that here and pick the native mode anyway.
+	 */
+	if (edid->edid_preferred_mode == NULL) {
+		edid->edid_preferred_mode = m;
+	} else if ((strncmp(edid->edid_vendor, "IVM", 3) == 0) &&
+	   (edid->edid_product == 0x4800) &&
+	   (edid->edid_preferred_mode->dot_clock < m->dot_clock))
+		edid->edid_preferred_mode = m;
+}
+
 static void
 edid_block(struct edid_info *edid, uint8_t *data)
 {
@@ -433,13 +449,11 @@ edid_block(struct edid_info *edid, uint8
 		exist_mode = edid_search_mode(edid, );
 		if (exist_mode != NULL) {
 			*exist_mode = mode;
-			if (edid->edid_preferred_mode == NULL)
-edid->edid_preferred_mode = exist_mode;
+			bump_preferred_mode(edid, exist_mode);
 		} else {
 			edid->edid_modes[edid->edid_nmodes] = mode;
-			if (edid->edid_preferred_mode == NULL)
-edid->edid_preferred_mode =
->edid_modes[edid->edid_nmodes];
+			bump_preferred_mode(edid,
+			>edid_modes[edid->edid_nmodes]);
 			edid->edid_nmodes++;	
 		}
 		return;



CVS commit: src/sys/net

2018-07-09 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Tue Jul 10 01:23:13 UTC 2018

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

Log Message:
Don't overwrite an existing llentry on RTM_ADD to avoid race conditions

Reported and tested by christos@


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/net/if_llatbl.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_llatbl.c
diff -u src/sys/net/if_llatbl.c:1.27 src/sys/net/if_llatbl.c:1.28
--- src/sys/net/if_llatbl.c:1.27	Tue Jun  5 01:25:59 2018
+++ src/sys/net/if_llatbl.c	Tue Jul 10 01:23:13 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_llatbl.c,v 1.27 2018/06/05 01:25:59 nonaka Exp $	*/
+/*	$NetBSD: if_llatbl.c,v 1.28 2018/07/10 01:23:13 ozaki-r Exp $	*/
 /*
  * Copyright (c) 2004 Luigi Rizzo, Alessandro Cerri. All rights reserved.
  * Copyright (c) 2004-2008 Qing Li. All rights reserved.
@@ -672,7 +672,7 @@ lla_rt_output(const u_char rtm_type, con
 
 		/* Add static LLE */
 		IF_AFDATA_WLOCK(ifp);
-		lle = lla_lookup(llt, 0, dst);
+		lle = lla_lookup(llt, LLE_EXCLUSIVE, dst);
 
 		/* Cannot overwrite an existing static entry */
 		if (lle != NULL &&
@@ -684,8 +684,18 @@ lla_rt_output(const u_char rtm_type, con
 			error = EEXIST;
 			goto out;
 		}
-		if (lle != NULL)
-			LLE_RUNLOCK(lle);
+
+		/*
+		 * We can't overwrite an existing entry to avoid race
+		 * conditions so remove it first.
+		 */
+		if (lle != NULL) {
+			size_t pkts_dropped = llentry_free(lle);
+			if (dst->sa_family == AF_INET) {
+arp_stat_add(ARP_STAT_DFRDROPPED,
+(uint64_t)pkts_dropped);
+			}
+		}
 
 		lle = lla_create(llt, 0, dst, rt);
 		if (lle == NULL) {



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

2018-07-09 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Mon Jul  9 18:52:04 UTC 2018

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

Log Message:
Don't push/pop %rdx, we don't care about preserving its value.


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

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

Modified files:

Index: src/sys/arch/amd64/amd64/locore.S
diff -u src/sys/arch/amd64/amd64/locore.S:1.168 src/sys/arch/amd64/amd64/locore.S:1.169
--- src/sys/arch/amd64/amd64/locore.S:1.168	Mon Jul  9 18:43:05 2018
+++ src/sys/arch/amd64/amd64/locore.S	Mon Jul  9 18:52:04 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.168 2018/07/09 18:43:05 maxv Exp $	*/
+/*	$NetBSD: locore.S,v 1.169 2018/07/09 18:52:04 maxv Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -1105,21 +1105,17 @@ ENTRY(cpu_switchto)
 	jnz	.Lswitch_return
 
 #ifdef SVS
-	pushq	%rdx
 	movb	_C_LABEL(svs_enabled),%dl
 	testb	%dl,%dl
 	jz	.Lskip_svs
 	callq	_C_LABEL(svs_lwp_switch)
 .Lskip_svs:
-	popq	%rdx
 #endif
 
 #ifndef XEN
-	pushq	%rdx
 	movq	%r13,%rdi
 	movq	%r12,%rsi
 	callq	_C_LABEL(speculation_barrier)
-	popq	%rdx
 #endif
 
 	/* Switch ring0 stack */
@@ -1147,7 +1143,6 @@ ENTRY(cpu_switchto)
 .Lring0_switched:
 
 #ifndef XEN
-	pushq	%rdx
 	movb	_C_LABEL(x86_fpu_eager),%dl
 	testb	%dl,%dl
 	jz	.Lno_eagerfpu
@@ -1155,7 +1150,6 @@ ENTRY(cpu_switchto)
 	movq	%r12,%rsi
 	callq	_C_LABEL(fpu_eagerswitch)
 .Lno_eagerfpu:
-	popq	%rdx
 #endif
 
 	/* Don't bother with the rest if switching to a system process. */



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

2018-07-09 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Mon Jul  9 18:43:05 UTC 2018

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

Log Message:
Small optimization: don't execute the Meltdown/SpectreV2 cswitch code if
we're leaving a softint. We were executing the softint with the LWP's
context, so no need to switch the SVS/IBRS contexts, we already are in
the desired contexts.


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

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

Modified files:

Index: src/sys/arch/amd64/amd64/locore.S
diff -u src/sys/arch/amd64/amd64/locore.S:1.167 src/sys/arch/amd64/amd64/locore.S:1.168
--- src/sys/arch/amd64/amd64/locore.S:1.167	Fri Jun 29 19:21:43 2018
+++ src/sys/arch/amd64/amd64/locore.S	Mon Jul  9 18:43:05 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.167 2018/06/29 19:21:43 maxv Exp $	*/
+/*	$NetBSD: locore.S,v 1.168 2018/07/09 18:43:05 maxv Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -1088,26 +1088,6 @@ ENTRY(cpu_switchto)
 	movq	%rbp,PCB_RBP(%rax)
 .Lskip_save:
 
-#ifdef SVS
-	pushq	%rdx
-	movb	_C_LABEL(svs_enabled),%dl
-	testb	%dl,%dl
-	jz	.Lskip_svs
-	callq	_C_LABEL(svs_lwp_switch)
-.Lskip_svs:
-	popq	%rdx
-
-	/* RDI/RSI got clobbered. */
-	movq	%r13,%rdi
-	movq	%r12,%rsi
-#endif
-
-#ifndef XEN
-	pushq	%rdx
-	callq	_C_LABEL(speculation_barrier)
-	popq	%rdx
-#endif
-
 	/* Switch to newlwp's stack. */
 	movq	L_PCB(%r12),%r14
 	movq	PCB_RSP(%r14),%rsp
@@ -1124,6 +1104,24 @@ ENTRY(cpu_switchto)
 	testb	%dl,%dl		/* returning = true ? */
 	jnz	.Lswitch_return
 
+#ifdef SVS
+	pushq	%rdx
+	movb	_C_LABEL(svs_enabled),%dl
+	testb	%dl,%dl
+	jz	.Lskip_svs
+	callq	_C_LABEL(svs_lwp_switch)
+.Lskip_svs:
+	popq	%rdx
+#endif
+
+#ifndef XEN
+	pushq	%rdx
+	movq	%r13,%rdi
+	movq	%r12,%rsi
+	callq	_C_LABEL(speculation_barrier)
+	popq	%rdx
+#endif
+
 	/* Switch ring0 stack */
 #ifdef SVS
 	movb	_C_LABEL(svs_enabled),%al



CVS commit: src/sys/net

2018-07-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Jul  9 14:54:01 UTC 2018

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

Log Message:
Calling rtinit(sa_family = AF_LINK, RTM_DELETE, 0) is guaranteed not to
work. Remove bogus call leaving a KASSERT behind.


To generate a diff of this commit:
cvs rdiff -u -r1.429 -r1.430 src/sys/net/if.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.c
diff -u src/sys/net/if.c:1.429 src/sys/net/if.c:1.430
--- src/sys/net/if.c:1.429	Mon Jul  2 23:37:03 2018
+++ src/sys/net/if.c	Mon Jul  9 10:54:01 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.c,v 1.429 2018/07/03 03:37:03 ozaki-r Exp $	*/
+/*	$NetBSD: if.c,v 1.430 2018/07/09 14:54:01 christos Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.429 2018/07/03 03:37:03 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.430 2018/07/09 14:54:01 christos Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -595,7 +595,7 @@ if_free_sadl(struct ifnet *ifp, int fact
 	KASSERT(ifp->if_sadl != NULL);
 
 	s = splsoftnet();
-	rtinit(ifa, RTM_DELETE, 0);
+	KASSERT(ifa->ifa_addr->sa_family == AF_LINK);
 	ifa_remove(ifp, ifa);
 	if_deactivate_sadl(ifp);
 	splx(s);



CVS commit: src/sys

2018-07-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Jul  9 14:07:37 UTC 2018

Modified Files:
src/sys/arch/evbarm/stand/boot2440: dev_sdmmc.c
src/sys/arch/mips/sibyte/dev: sbjcnvar.h
src/sys/dev/sbus: magmareg.h spifreg.h

Log Message:
Remove duplicate copies of the SET/CLR/ISSET macros.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/evbarm/stand/boot2440/dev_sdmmc.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/mips/sibyte/dev/sbjcnvar.h
cvs rdiff -u -r1.19 -r1.20 src/sys/dev/sbus/magmareg.h
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/sbus/spifreg.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/evbarm/stand/boot2440/dev_sdmmc.c
diff -u src/sys/arch/evbarm/stand/boot2440/dev_sdmmc.c:1.4 src/sys/arch/evbarm/stand/boot2440/dev_sdmmc.c:1.5
--- src/sys/arch/evbarm/stand/boot2440/dev_sdmmc.c:1.4	Mon Jul  9 04:51:19 2018
+++ src/sys/arch/evbarm/stand/boot2440/dev_sdmmc.c	Mon Jul  9 10:07:37 2018
@@ -90,17 +90,6 @@
 #include "dev_sdmmc.h"
 #include "s3csdi.h"
 
-#ifndef SET
-#define SET(t, f)   ((t) |= (f))
-#endif
-#ifndef ISSET
-#define ISSET(t, f) ((t) & (f))
-#endif
-#ifndef CLR
-#define CLR(t, f)   ((t) &= ~(f))
-#endif
-
-
 //#define SDMMC_DEBUG
 #ifdef SDMMC_DEBUG
 #define DPRINTF(s) do {printf s; } while (/*CONSTCOND*/0)

Index: src/sys/arch/mips/sibyte/dev/sbjcnvar.h
diff -u src/sys/arch/mips/sibyte/dev/sbjcnvar.h:1.7 src/sys/arch/mips/sibyte/dev/sbjcnvar.h:1.8
--- src/sys/arch/mips/sibyte/dev/sbjcnvar.h:1.7	Mon Jul  9 04:51:19 2018
+++ src/sys/arch/mips/sibyte/dev/sbjcnvar.h	Mon Jul  9 10:07:37 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: sbjcnvar.h,v 1.7 2018/07/09 08:51:19 kre Exp $ */
+/* $NetBSD: sbjcnvar.h,v 1.8 2018/07/09 14:07:37 christos Exp $ */
 
 /*
  * Copyright 2000, 2001
@@ -169,14 +169,3 @@ struct sbjcn_softc {
 
 	struct sbjcn_channel sc_channels[1];
 };
-
-/* Macros to clear/set/test flags. */
-#ifndef SET
-#define	SET(t, f)	((t) |= (f))
-#endif
-#ifndef CLR
-#define	CLR(t, f)	((t) &= ~(f))
-#endif
-#ifndef ISSET
-#define	ISSET(t, f)	((t) & (f))
-#endif

Index: src/sys/dev/sbus/magmareg.h
diff -u src/sys/dev/sbus/magmareg.h:1.19 src/sys/dev/sbus/magmareg.h:1.20
--- src/sys/dev/sbus/magmareg.h:1.19	Mon Jul  9 04:51:19 2018
+++ src/sys/dev/sbus/magmareg.h	Mon Jul  9 10:07:37 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: magmareg.h,v 1.19 2018/07/09 08:51:19 kre Exp $	*/
+/*	$NetBSD: magmareg.h,v 1.20 2018/07/09 14:07:37 christos Exp $	*/
 
 /*-
  *  Copyright (c) 1998 Iain Hibbert
@@ -186,19 +186,6 @@ struct mbpp_softc {
 	struct mbpp_port ms_port[MAGMA_MAX_BPP];
 };
 
-/*
- * useful macros
- */
-#ifndef SET
-#define SET(t, f)	((t) |= (f))
-#endif
-#ifndef CLR
-#define CLR(t, f)	((t) &= ~(f))
-#endif
-#ifndef ISSET
-#define ISSET(t, f)	((t) & (f))
-#endif
-
 /* internal function prototypes */
 
 int cd1400_compute_baud(speed_t, int, int *, int *);

Index: src/sys/dev/sbus/spifreg.h
diff -u src/sys/dev/sbus/spifreg.h:1.6 src/sys/dev/sbus/spifreg.h:1.7
--- src/sys/dev/sbus/spifreg.h:1.6	Mon Jul  9 04:51:19 2018
+++ src/sys/dev/sbus/spifreg.h	Mon Jul  9 10:07:37 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: spifreg.h,v 1.6 2018/07/09 08:51:19 kre Exp $	*/
+/*	$NetBSD: spifreg.h,v 1.7 2018/07/09 14:07:37 christos Exp $	*/
 /*	$OpenBSD: spifreg.h,v 1.5 2003/06/02 18:32:41 jason Exp $	*/
 
 /*
@@ -381,19 +381,6 @@
 #define	STTY_RBUF_SIZE		(2 * 512)
 
 /*
- * useful macros
- */
-#ifndef SET
-#define	SET(t, f)	((t) |= (f))
-#endif
-#ifndef CLR
-#define	CLR(t, f)	((t) &= ~(f))
-#endif
-#ifndef ISSET
-#define	ISSET(t, f)	((t) & (f))
-#endif
-
-/*
  * internal function prototypes
  */
 int	spif_match(device_t, cfdata_t, void *);



CVS commit: src/external/gpl3/binutils.old/dist/bfd

2018-07-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Jul  9 12:15:31 UTC 2018

Modified Files:
src/external/gpl3/binutils.old/dist/bfd: peXXigen.c

Log Message:
FIx reproducible builds for EFI boot blocks (from HEAD)


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/external/gpl3/binutils.old/dist/bfd/peXXigen.c

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

Modified files:

Index: src/external/gpl3/binutils.old/dist/bfd/peXXigen.c
diff -u src/external/gpl3/binutils.old/dist/bfd/peXXigen.c:1.5 src/external/gpl3/binutils.old/dist/bfd/peXXigen.c:1.6
--- src/external/gpl3/binutils.old/dist/bfd/peXXigen.c:1.5	Sat Apr 14 11:49:39 2018
+++ src/external/gpl3/binutils.old/dist/bfd/peXXigen.c	Mon Jul  9 08:15:31 2018
@@ -879,6 +879,8 @@ _bfd_XXi_only_swap_filehdr_out (bfd * ab
   /* Only use a real timestamp if the option was chosen.  */
   if ((pe_data (abfd)->insert_timestamp))
 H_PUT_32 (abfd, time (0), filehdr_out->f_timdat);
+  else
+H_PUT_32 (abfd, 0, filehdr_out->f_timdat);
 
   PUT_FILEHDR_SYMPTR (abfd, filehdr_in->f_symptr,
 		  filehdr_out->f_symptr);



CVS commit: src/external/gpl3/binutils.old

2018-07-09 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Mon Jul  9 11:55:45 UTC 2018

Modified Files:
src/external/gpl3/binutils.old/dist/bfd: config.bfd
src/external/gpl3/binutils.old/lib/libbfd/arch/i386: defs.mk

Log Message:
Apply the change made to binutils:

  Committed By:   christos
  Date:   Sun Jul  8 16:53:56 UTC 2018

  Modified Files:
src/external/gpl3/binutils/dist/bfd: config.bfd
src/external/gpl3/binutils/lib/libbfd/arch/i386: defs.mk

  Log Message:
  enable coff/pe executable vectors for i386 for the efi bootblocks.
  XXX: pullup-8

to binutils.old (which is what i386 is using).  Should unbreak the build.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/external/gpl3/binutils.old/dist/bfd/config.bfd
cvs rdiff -u -r1.5 -r1.6 \
src/external/gpl3/binutils.old/lib/libbfd/arch/i386/defs.mk

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

Modified files:

Index: src/external/gpl3/binutils.old/dist/bfd/config.bfd
diff -u src/external/gpl3/binutils.old/dist/bfd/config.bfd:1.5 src/external/gpl3/binutils.old/dist/bfd/config.bfd:1.6
--- src/external/gpl3/binutils.old/dist/bfd/config.bfd:1.5	Sat Apr 14 15:49:38 2018
+++ src/external/gpl3/binutils.old/dist/bfd/config.bfd	Mon Jul  9 11:55:45 2018
@@ -642,8 +642,8 @@ case "${targ}" in
 ;;
   i[3-7]86-*-netbsdelf* | i[3-7]86-*-netbsd*-gnu* | i[3-7]86-*-knetbsd*-gnu)
 targ_defvec=i386_elf32_vec
-targ_selvecs="i386_aout_nbsd_vec iamcu_elf32_vec"
-targ64_selvecs="x86_64_elf64_vec l1om_elf64_vec k1om_elf64_vec"
+targ_selvecs="i386_aout_nbsd_vec iamcu_elf32_vec i386_coff_vec i386_pei_vec"
+targ64_selvecs="x86_64_elf64_vec l1om_elf64_vec k1om_elf64_vec x86_64_pei_vec"
 ;;
   i[3-7]86-*-netbsdpe*)
 targ_defvec=i386_pe_vec

Index: src/external/gpl3/binutils.old/lib/libbfd/arch/i386/defs.mk
diff -u src/external/gpl3/binutils.old/lib/libbfd/arch/i386/defs.mk:1.5 src/external/gpl3/binutils.old/lib/libbfd/arch/i386/defs.mk:1.6
--- src/external/gpl3/binutils.old/lib/libbfd/arch/i386/defs.mk:1.5	Sat Apr 14 17:53:01 2018
+++ src/external/gpl3/binutils.old/lib/libbfd/arch/i386/defs.mk	Mon Jul  9 11:55:45 2018
@@ -2,8 +2,8 @@
 # Generated from: NetBSD: mknative-binutils,v 1.9 2013/10/01 15:41:17 skrll Exp 
 # Generated from: NetBSD: mknative.common,v 1.11 2014/02/17 21:39:43 christos Exp 
 #
-G_libbfd_la_DEPENDENCIES=elf32-i386.lo elf-ifunc.lo elf-nacl.lo elf-vxworks.lo elf32.lo elf.lo elflink.lo elf-attrs.lo elf-strtab.lo elf-eh-frame.lo dwarf1.lo dwarf2.lo i386netbsd.lo aout32.lo elf32-gen.lo plugin.lo cpu-i386.lo cpu-iamcu.lo cpu-plugin.lo netbsd-core.lo ofiles
+G_libbfd_la_DEPENDENCIES=elf32-i386.lo elf-ifunc.lo elf-nacl.lo elf-vxworks.lo elf32.lo elf.lo elflink.lo elf-attrs.lo elf-strtab.lo elf-eh-frame.lo dwarf1.lo dwarf2.lo i386netbsd.lo aout32.lo coff-i386.lo cofflink.lo coffgen.lo pei-i386.lo peigen.lo elf32-gen.lo plugin.lo cpu-i386.lo cpu-iamcu.lo cpu-plugin.lo netbsd-core.lo ofiles
 G_libbfd_la_OBJECTS=archive.lo archures.lo bfd.lo bfdio.lo bfdwin.lo  cache.lo coff-bfd.lo compress.lo corefile.lo format.lo hash.lo  init.lo libbfd.lo linker.lo merge.lo opncls.lo reloc.lo  section.lo simple.lo stab-syms.lo stabs.lo syms.lo targets.lo  binary.lo ihex.lo srec.lo tekhex.lo verilog.lo
 G_DEFS=-DHAVE_CONFIG_H
-G_INCLUDES=-DNETBSD_CORE-I. -I${GNUHOSTDIST}/bfd -I${GNUHOSTDIST}/bfd/../include   -DHAVE_i386_elf32_vec -DHAVE_i386_aout_nbsd_vec -DHAVE_iamcu_elf32_vec -DHAVE_elf32_le_vec -DHAVE_elf32_be_vec -DHAVE_plugin_vec -I./../intl
-G_TDEFAULTS=-DDEFAULT_VECTOR=i386_elf32_vec -DSELECT_VECS='_elf32_vec,_aout_nbsd_vec,_elf32_vec,_le_vec,_be_vec,_vec' -DSELECT_ARCHITECTURES='_i386_arch,_iamcu_arch,_plugin_arch'
+G_INCLUDES=-DNETBSD_CORE-I. -I${GNUHOSTDIST}/bfd -I${GNUHOSTDIST}/bfd/../include   -DHAVE_i386_elf32_vec -DHAVE_i386_aout_nbsd_vec -DHAVE_iamcu_elf32_vec -DHAVE_i386_coff_vec -DHAVE_i386_pei_vec -DHAVE_elf32_le_vec -DHAVE_elf32_be_vec -DHAVE_plugin_vec -I./../intl
+G_TDEFAULTS=-DDEFAULT_VECTOR=i386_elf32_vec -DSELECT_VECS='_elf32_vec,_aout_nbsd_vec,_elf32_vec,_le_vec,_coff_vec,_pei_vec,_be_vec,_vec' -DSELECT_ARCHITECTURES='_i386_arch,_iamcu_arch,_plugin_arch'



CVS commit: src/sys/dev/ic

2018-07-09 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Mon Jul  9 10:44:44 UTC 2018

Modified Files:
src/sys/dev/ic: ahcisata_core.c

Log Message:
Avoid undefined behavior of signedness bit shift in ahcisata_core.c

sys/dev/ic/ahcisata_core.c:365:31, left shift of 1 by 31 places cannot be 
represented in type 'int'
sys/dev/ic/ahcisata_core.c:558:16, left shift of 1 by 31 places cannot be 
represented in type 'int'

Detected with Kernel Undefined Behavior Sanitizer.

This code could be refactored in future and switched to ISSET(9) API,
instead of reinventing the common functionality.


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/sys/dev/ic/ahcisata_core.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/ic/ahcisata_core.c
diff -u src/sys/dev/ic/ahcisata_core.c:1.61 src/sys/dev/ic/ahcisata_core.c:1.62
--- src/sys/dev/ic/ahcisata_core.c:1.61	Sun Jul  8 17:58:26 2018
+++ src/sys/dev/ic/ahcisata_core.c	Mon Jul  9 10:44:44 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ahcisata_core.c,v 1.61 2018/07/08 17:58:26 jdolecek Exp $	*/
+/*	$NetBSD: ahcisata_core.c,v 1.62 2018/07/09 10:44:44 kamil Exp $	*/
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.61 2018/07/08 17:58:26 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.62 2018/07/09 10:44:44 kamil Exp $");
 
 #include 
 #include 
@@ -175,7 +175,7 @@ ahci_setup_ports(struct ahci_softc *sc)
 	int i, port;
 	
 	for (i = 0, port = 0; i < AHCI_MAX_PORTS; i++) {
-		if ((sc->sc_ahci_ports & (1 << i)) == 0)
+		if ((sc->sc_ahci_ports & (1U << i)) == 0)
 			continue;
 		if (port >= sc->sc_atac.atac_nchannels) {
 			aprint_error("%s: more ports than announced\n",
@@ -194,7 +194,7 @@ ahci_reprobe_drives(struct ahci_softc *s
 	struct ata_channel *chp;
 
 	for (i = 0, port = 0; i < AHCI_MAX_PORTS; i++) {
-		if ((sc->sc_ahci_ports & (1 << i)) == 0)
+		if ((sc->sc_ahci_ports & (1U << i)) == 0)
 			continue;
 		if (port >= sc->sc_atac.atac_nchannels) {
 			aprint_error("%s: more ports than announced\n",
@@ -362,7 +362,7 @@ ahci_attach(struct ahci_softc *sc)
 		DEBUG_PROBE);
 	}
 	for (i = 0, port = 0; i < AHCI_MAX_PORTS; i++) {
-		if ((sc->sc_ahci_ports & (1 << i)) == 0)
+		if ((sc->sc_ahci_ports & (1U << i)) == 0)
 			continue;
 		if (port >= sc->sc_atac.atac_nchannels) {
 			aprint_error("%s: more ports than announced\n",
@@ -493,7 +493,7 @@ ahci_detach(struct ahci_softc *sc, int f
 		achp = >sc_channels[i];
 		chp = >ata_channel;
 
-		if ((sc->sc_ahci_ports & (1 << i)) == 0)
+		if ((sc->sc_ahci_ports & (1U << i)) == 0)
 			continue;
 		if (i >= sc->sc_atac.atac_nchannels) {
 			aprint_error("%s: more ports than announced\n",
@@ -555,7 +555,7 @@ ahci_intr(void *v)
 		r = 1;
 		AHCI_WRITE(sc, AHCI_IS, is);
 		for (i = 0; i < AHCI_MAX_PORTS; i++)
-			if (is & (1 << i))
+			if (is & (1U << i))
 ahci_intr_port(sc, >sc_channels[i]);
 	}
 	return r;
@@ -723,9 +723,9 @@ ahci_exec_fis(struct ata_channel *chp, i
 	AHCI_CMDH_SYNC(sc, achp, slot,
 	BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
 	/* start command */
-	AHCI_WRITE(sc, AHCI_P_CI(chp->ch_channel), 1 << slot);
+	AHCI_WRITE(sc, AHCI_P_CI(chp->ch_channel), 1U << slot);
 	for (i = 0; i < timeout; i++) {
-		if ((AHCI_READ(sc, AHCI_P_CI(chp->ch_channel)) & (1 << slot)) ==
+		if ((AHCI_READ(sc, AHCI_P_CI(chp->ch_channel)) & (1U << slot)) ==
 		0)
 			return 0;
 		is = AHCI_READ(sc, AHCI_P_IS(chp->ch_channel));
@@ -1069,7 +1069,7 @@ ahci_cmd_start(struct ata_channel *chp, 
 	DEBUG_XFERS);
 
 	ata_channel_lock_owned(chp);
-	KASSERT((achp->ahcic_cmds_active & (1 << slot)) == 0);
+	KASSERT((achp->ahcic_cmds_active & (1U << slot)) == 0);
 
 	cmd_tbl = achp->ahcic_cmd_tbl[slot];
 	AHCIDEBUG_PRINT(("%s port %d tbl %p\n", AHCINAME(sc), chp->ch_channel,
@@ -1102,9 +1102,9 @@ ahci_cmd_start(struct ata_channel *chp, 
 		AHCI_READ(sc, AHCI_GHC) & ~AHCI_GHC_IE);
 	}
 	/* start command */
-	AHCI_WRITE(sc, AHCI_P_CI(chp->ch_channel), 1 << slot);
+	AHCI_WRITE(sc, AHCI_P_CI(chp->ch_channel), 1U << slot);
 	/* and says we started this command */
-	achp->ahcic_cmds_active |= 1 << slot;
+	achp->ahcic_cmds_active |= 1U << slot;
 
 	if ((ata_c->flags & AT_POLL) == 0) {
 		callout_reset(>c_timo_callout, mstohz(ata_c->timeout),
@@ -1188,8 +1188,8 @@ ahci_cmd_kill_xfer(struct ata_channel *c
 	}
 
 	if (deactivate) {
-		KASSERT((achp->ahcic_cmds_active & (1 << xfer->c_slot)) != 0);
-		achp->ahcic_cmds_active &= ~(1 << xfer->c_slot);
+		KASSERT((achp->ahcic_cmds_active & (1U << xfer->c_slot)) != 0);
+		achp->ahcic_cmds_active &= ~(1U << xfer->c_slot);
 		ata_deactivate_xfer(chp, xfer);
 	}
 
@@ -1211,8 +1211,8 @@ ahci_cmd_complete(struct ata_channel *ch
 	if (ata_waitdrain_xfer_check(chp, xfer))
 		return 0;
 
-	KASSERT((achp->ahcic_cmds_active & (1 << xfer->c_slot)) != 0);
-	achp->ahcic_cmds_active &= ~(1 << xfer->c_slot);

CVS commit: src/share/man/man9

2018-07-09 Thread Radoslaw Kujawa
Module Name:src
Committed By:   rkujawa
Date:   Mon Jul  9 10:36:30 UTC 2018

Modified Files:
src/share/man/man9: radio.9

Log Message:
Try to bring this man page up to NetBSD standards.

This page is bad and we should feel bad about it. But perhaps now it is
considerably less bad.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/share/man/man9/radio.9

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

Modified files:

Index: src/share/man/man9/radio.9
diff -u src/share/man/man9/radio.9:1.4 src/share/man/man9/radio.9:1.5
--- src/share/man/man9/radio.9:1.4	Tue Dec 20 19:53:15 2005
+++ src/share/man/man9/radio.9	Mon Jul  9 10:36:30 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: radio.9,v 1.4 2005/12/20 19:53:15 rpaulo Exp $
+.\"	$NetBSD: radio.9,v 1.5 2018/07/09 10:36:30 rkujawa Exp $
 .\"	$OpenBSD: radio.9,v 1.2 2001/10/08 08:52:50 mpech Exp $
 .\"
 .\" Copyright (c) Maxim Tsyplakov 
@@ -24,77 +24,102 @@
 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd December 20, 2005
+.Dd July 9, 2018
 .Dt RADIO 9
 .Os
 .Sh NAME
 .Nm radio
-.Nd interface between low and high level radio drivers
+.Nd interface between low and high level FM radio drivers
+.Sh SYNOPSIS
+.In dev/radio_if.h
+.Ft device_t
+.Fo radio_attach_mi
+.Fa "const struct radio_hw_if *rhwp"
+.Fa "void *hdlp"
+.Fa "device_t dev"
+.Fc
 .Sh DESCRIPTION
-The radio device driver is divided into a high level,
-hardware independent layer, and a low level hardware
-dependent layer.
-The interface between these is the
-.Va radio_hw_if
-structure.
-.Bd -literal
-struct radio_hw_if {
-	int	(*open)(void *, int, int, struct lwp *);
-	int	(*close)(void *, int, int, struct lwp *);
-	int (*get_info)(void *, struct radio_info *);
-	int (*set_info)(void *, struct radio_info *);
-	int (*search)(void *, int);
-};
-.Ed
+The
+.Nm
+layer provides support for digitally programmable FM radio tuners.
+.Pp
+It is divided into a machine independent, high level part responsible for
+managing device file, and low level hardware drivers.
 .Pp
 The high level radio driver attaches to the low level driver
 when the latter calls
-.Va radio_attach_mi .
-This call should be
-.Bd -literal
-void
-radio_attach_mi(rhwp, hdlp, dev)
-	struct radio_hw_if *rhwp;
-	void *hdlp;
-	struct device *dev;
-.Ed
+.Fn radio_attach_mi .
 .Pp
 The
-.Va radio_hw_if
-struct is as shown above.
+.Fa radio_hw_if
+struct is contains pointers to functions provided by the low level driver.
 The
-.Va hdlp
-argument is a handle to some low level data structure.
+.Fa hdlp
+argument is a handle to a low level driver's softc structure.
 It is sent as the first argument to all the functions in
-.Va radio_hw_if
+.Fa radio_hw_if
 when the high level driver calls them.
-.Va dev
+.Fa dev
 is the device struct for the hardware device.
 .Pp
 The fields of
-.Va radio_hw_if
+.Fa radio_hw_if
 are described in some more detail below.
 .Bd -literal
-int open (void *, int flags, int fmt, struct lwp *p);
-  Optional.
-  Is called when the radio device is opened.
-  Returns 0 on success, otherwise an error code.
-
-int close (void *, int flags, int fmt, struct lwp *p);
-  Optional.
-  Is called when the radio device is closed.
-  Returns 0 on success, otherwise an error code.
-
-int get_info (void *, struct radio_info *);
-  Fill the radio_info struct.
-  Returns 0 on success, otherwise an error code.
-
-int set_info (void *, struct radio_info *);
-  Set values from the radio_info struct.
-  Returns 0 on success, otherwise an error code.
-
-int search (void *, int);
-  Returns 0 on success, otherwise an error code.
+struct radio_hw_if {
+	int	(*open)(void *, int, int, struct lwp *);
+	int	(*close)(void *, int, int, struct lwp *);
+	int (*get_info)(void *, struct radio_info *);
+	int (*set_info)(void *, struct radio_info *);
+	int (*search)(void *, int);
+};
 .Ed
+.Pp
+.Bl -tag -width 
+.It Fn (*open) "sc" "flags" "fmt" "lwp"
+Called when the radio device is opened.
+Optional, if there is no need to call a driver's function when device file is
+opened, NULL should be passed in this field.
+Returns 0 on success, otherwise an error code.
+.It Fn (*close) "sc" "flags" "fmt" "lwp"
+Called when the radio device is closed.
+Optional, if there is no need to call a driver's function when device file is
+closed, NULL should be passed in thie field.
+Returns 0 on success, otherwise an error code.
+.It Fn (*get_info) "sc" "ri"
+Fills the radio_info struct.
+This function is used to obtain the current state of a hardware device.
+It is executed as a result of calling
+.Dv RIOCGINFO
+on a device file managed by the high level driver.
+Returns 0 on success, otherwise an error code.
+.It Fn (*set_info) "sc" "ri"
+Set values from the radio_info struct.
+This function is used to modify the current state of a hardware device

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

2018-07-09 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Jul  9 10:24:44 UTC 2018

Modified Files:
src/sys/arch/arm/sunxi: sunxi_rsb.c

Log Message:
Put RSB controller into known state at the start of every transfer.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/sunxi/sunxi_rsb.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/sunxi/sunxi_rsb.c
diff -u src/sys/arch/arm/sunxi/sunxi_rsb.c:1.3 src/sys/arch/arm/sunxi/sunxi_rsb.c:1.4
--- src/sys/arch/arm/sunxi/sunxi_rsb.c:1.3	Sun Jul  1 21:15:02 2018
+++ src/sys/arch/arm/sunxi/sunxi_rsb.c	Mon Jul  9 10:24:44 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_rsb.c,v 1.3 2018/07/01 21:15:02 jmcneill Exp $ */
+/* $NetBSD: sunxi_rsb.c,v 1.4 2018/07/09 10:24:44 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014-2017 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_rsb.c,v 1.3 2018/07/01 21:15:02 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_rsb.c,v 1.4 2018/07/09 10:24:44 jmcneill Exp $");
 
 #include 
 #include 
@@ -191,14 +191,6 @@ sunxi_rsb_attach(device_t parent, device
 	}
 	aprint_normal_dev(self, "interrupting on %s\n", intrstr);
 
-	/* Enable interrupts */
-	RSB_WRITE(sc, RSB_INTE_REG,
-	RSB_INTE_LOAD_BSY_ENB |
-	RSB_INTE_TRANS_ERR_ENB |
-	RSB_INTE_TRANS_OVER_ENB);
-	RSB_WRITE(sc, RSB_CTRL_REG,
-	RSB_CTRL_GLOBAL_INT_ENB);
-
 	sc->sc_ic.ic_cookie = sc;
 	sc->sc_ic.ic_acquire_bus = sunxi_rsb_acquire_bus;
 	sc->sc_ic.ic_release_bus = sunxi_rsb_release_bus;
@@ -230,6 +222,23 @@ sunxi_rsb_intr(void *priv)
 }
 
 static int
+sunxi_rsb_soft_reset(struct sunxi_rsb_softc *sc)
+{
+	int retry = 1000;
+
+	RSB_WRITE(sc, RSB_CTRL_REG, RSB_CTRL_SOFT_RESET);
+	while (--retry > 0) {
+		if ((RSB_READ(sc, RSB_CTRL_REG) & RSB_CTRL_SOFT_RESET) == 0)
+			break;
+		delay(10);
+	}
+	if (retry == 0)
+		return EIO;
+
+	return 0;
+}
+
+static int
 sunxi_rsb_wait(struct sunxi_rsb_softc *sc, int flags)
 {
 	int error = 0, retry;
@@ -317,12 +326,7 @@ sunxi_rsb_acquire_bus(void *priv, int fl
 {
 	struct sunxi_rsb_softc *sc = priv;
 
-	if (flags & I2C_F_POLL) {
-		if (!mutex_tryenter(>sc_lock))
-			return EBUSY;
-	} else {
-		mutex_enter(>sc_lock);
-	}
+	mutex_enter(>sc_lock);
 
 	return 0;
 }
@@ -349,6 +353,22 @@ sunxi_rsb_exec(void *priv, i2c_op_t op, 
 	if (cmdlen != 1 || (len != 1 && len != 2 && len != 4))
 		return EINVAL;
 
+	error = sunxi_rsb_soft_reset(sc);
+	if (error != 0) {
+		device_printf(sc->sc_dev, "soft reset timed out\n");
+		return error;
+	}
+
+	if ((flags & I2C_F_POLL) == 0) {
+		/* Enable interrupts */
+		RSB_WRITE(sc, RSB_INTE_REG,
+		RSB_INTE_LOAD_BSY_ENB |
+		RSB_INTE_TRANS_ERR_ENB |
+		RSB_INTE_TRANS_OVER_ENB);
+		RSB_WRITE(sc, RSB_CTRL_REG,
+		RSB_CTRL_GLOBAL_INT_ENB);
+	}
+
 	if (sc->sc_type == SUNXI_RSB && sc->sc_rsb_last_da != addr) {
 		/* Lookup run-time address for given device address */
 		for (rta = 0, i = 0; rsb_rtamap[i].rta != 0; i++)
@@ -367,7 +387,7 @@ sunxi_rsb_exec(void *priv, i2c_op_t op, 
 			"SRTA failed, flags = %x, error = %d\n",
 			flags, error);
 			sc->sc_rsb_last_da = 0;
-			return error;
+			goto done;
 		}
 
 		sc->sc_rsb_last_da = addr;
@@ -392,7 +412,8 @@ sunxi_rsb_exec(void *priv, i2c_op_t op, 
 			(pbuf[2] << 16) | (pbuf[3] << 24);
 			break;
 		default:
-			return EINVAL;
+			error = EINVAL;
+			goto done;
 		}
 		RSB_WRITE(sc, RSB_DATA0_REG, data);
 	}
@@ -404,14 +425,14 @@ sunxi_rsb_exec(void *priv, i2c_op_t op, 
 			case 1:	cmd = RSB_CMD_IDX_WR8; break;
 			case 2: cmd = RSB_CMD_IDX_WR16; break;
 			case 4: cmd = RSB_CMD_IDX_WR32; break;
-			default: return EINVAL;
+			default: error = EINVAL; goto done;
 			}
 		} else {
 			switch (len) {
 			case 1:	cmd = RSB_CMD_IDX_RD8; break;
 			case 2: cmd = RSB_CMD_IDX_RD16; break;
 			case 4: cmd = RSB_CMD_IDX_RD32; break;
-			default: return EINVAL;
+			default: error = EINVAL; goto done;
 			}
 		}
 		RSB_WRITE(sc, RSB_CMD_REG, cmd);
@@ -428,7 +449,8 @@ sunxi_rsb_exec(void *priv, i2c_op_t op, 
 	ctrl = RSB_READ(sc, RSB_CTRL_REG);
 	if (ctrl & RSB_CTRL_START_TRANS) {
 		device_printf(sc->sc_dev, "device is busy\n");
-		return EBUSY;
+		error = EBUSY;
+		goto done;
 	}
 
 	/* Start the transfer */
@@ -436,9 +458,8 @@ sunxi_rsb_exec(void *priv, i2c_op_t op, 
 	ctrl | RSB_CTRL_START_TRANS);
 
 	error = sunxi_rsb_wait(sc, flags);
-	if (error) {
-		return error;
-	}
+	if (error)
+		goto done;
 
 	if (I2C_OP_READ_P(op)) {
 		uint32_t data = RSB_READ(sc, RSB_DATA0_REG);
@@ -453,9 +474,15 @@ sunxi_rsb_exec(void *priv, i2c_op_t op, 
 			*(uint8_t *)buf = data & 0xff;
 			break;
 		default:
-			return EINVAL;
+			error = EINVAL;
+			goto done;
 		}
 	}
 
-	return 0;
+	error = 0;
+
+done:
+	RSB_WRITE(sc, RSB_CTRL_REG, 0);
+
+	return error;
 }



CVS commit: src/doc

2018-07-09 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Mon Jul  9 10:08:35 UTC 2018

Modified Files:
src/doc: CHANGES

Log Message:
SMP support for aarch64


To generate a diff of this commit:
cvs rdiff -u -r1.2405 -r1.2406 src/doc/CHANGES

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

Modified files:

Index: src/doc/CHANGES
diff -u src/doc/CHANGES:1.2405 src/doc/CHANGES:1.2406
--- src/doc/CHANGES:1.2405	Tue Jun 26 21:09:48 2018
+++ src/doc/CHANGES	Mon Jul  9 10:08:35 2018
@@ -1,4 +1,4 @@
-# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2405 $>
+# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2406 $>
 #
 #
 # [Note: This file does not mention every change made to the NetBSD source tree.
@@ -168,3 +168,4 @@ Changes from NetBSD 8.0 to NetBSD 9.0:
 	bpf(4): Add the BPF direction filter (BIOC[GS]DIRECTION).
 		[msaitoh 20180626]
 	gcc: add lsan the Leak Sanitizer [christos 20180626]
+	aarch64: Add support for SMP. [ryo 20180709]



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

2018-07-09 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Jul  9 10:07:42 UTC 2018

Modified Files:
src/sys/arch/arm/dts: sun50i-a64-pinebook.dts

Log Message:
Make brightness-levels available in increments of 10% from 0 to 100, and set 
the default brightness level to match the one used by U-Boot (30%)


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/dts/sun50i-a64-pinebook.dts

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/dts/sun50i-a64-pinebook.dts
diff -u src/sys/arch/arm/dts/sun50i-a64-pinebook.dts:1.11 src/sys/arch/arm/dts/sun50i-a64-pinebook.dts:1.12
--- src/sys/arch/arm/dts/sun50i-a64-pinebook.dts:1.11	Fri May 11 00:00:17 2018
+++ src/sys/arch/arm/dts/sun50i-a64-pinebook.dts	Mon Jul  9 10:07:42 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: sun50i-a64-pinebook.dts,v 1.11 2018/05/11 00:00:17 jmcneill Exp $ */
+/* $NetBSD: sun50i-a64-pinebook.dts,v 1.12 2018/07/09 10:07:42 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -67,8 +67,8 @@
 	backlight: backlight {
 		compatible = "pwm-backlight";
 		pwms = < 0 5 0>;
-		brightness-levels = <0 30 40 50 60 70 80 90 100>;
-		default-brightness-level = <6>;
+		brightness-levels = <0 10 20 30 40 50 60 70 80 90 100>;
+		default-brightness-level = <3>;
 		enable-gpios = < 3 23 GPIO_ACTIVE_HIGH>;	/* PD23 */
 	};
 



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

2018-07-09 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Mon Jul  9 09:58:15 UTC 2018

Modified Files:
src/sys/arch/aarch64/aarch64: TODO

Log Message:
check off SMP


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/aarch64/aarch64/TODO

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/TODO
diff -u src/sys/arch/aarch64/aarch64/TODO:1.1 src/sys/arch/aarch64/aarch64/TODO:1.2
--- src/sys/arch/aarch64/aarch64/TODO:1.1	Sun Apr  1 04:35:03 2018
+++ src/sys/arch/aarch64/aarch64/TODO	Mon Jul  9 09:58:15 2018
@@ -1,4 +1,4 @@
-$NetBSD: TODO,v 1.1 2018/04/01 04:35:03 ryo Exp $
+$NetBSD: TODO,v 1.2 2018/07/09 09:58:15 ryo Exp $
 
 TODO list for NetBSD/aarch64
 
@@ -7,7 +7,6 @@ TODO list for NetBSD/aarch64
   - C++ stack unwinding (libunwind?)
 
 - not yet
-  - SMP
   - kernel text/rodata segments are mapped writable. it should be mapped as RX.
   - ucas(9), and ucas_ras_check() is not implemented yet
   - crash(8), savecore(8) and libkvm (cpu_kcore_hdr_t)



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

2018-07-09 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Mon Jul  9 09:55:59 UTC 2018

Modified Files:
src/sys/arch/evbarm/conf: RPI64

Log Message:
enable options MULTIPROCESSOR


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/evbarm/conf/RPI64

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/conf/RPI64
diff -u src/sys/arch/evbarm/conf/RPI64:1.5 src/sys/arch/evbarm/conf/RPI64:1.6
--- src/sys/arch/evbarm/conf/RPI64:1.5	Sun Jul  1 15:33:29 2018
+++ src/sys/arch/evbarm/conf/RPI64	Mon Jul  9 09:55:58 2018
@@ -1,5 +1,5 @@
 #
-#	$NetBSD: RPI64,v 1.5 2018/07/01 15:33:29 skrll Exp $
+#	$NetBSD: RPI64,v 1.6 2018/07/09 09:55:58 ryo Exp $
 #
 #	RPI64 - Raspberry Pi 3 and Pi 2 v1.2 in AARCH64 mode
 #
@@ -19,6 +19,7 @@ makeoptions	DTS="
 # CPU options
 options 	CPU_CORTEXA53
 options 	SOC_BCM2836
+options 	MULTIPROCESSOR
 
 # verbose bootstraping messages
 options 	EARLYCONS=bcm2837



CVS commit: src/share/mk

2018-07-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jul  9 09:22:55 UTC 2018

Modified Files:
src/share/mk: sys.mk

Log Message:
Debug hack: print out full random-seed for C++ compile/link.


To generate a diff of this commit:
cvs rdiff -u -r1.133 -r1.134 src/share/mk/sys.mk

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

Modified files:

Index: src/share/mk/sys.mk
diff -u src/share/mk/sys.mk:1.133 src/share/mk/sys.mk:1.134
--- src/share/mk/sys.mk:1.133	Fri Jun 22 11:25:03 2018
+++ src/share/mk/sys.mk	Mon Jul  9 09:22:55 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: sys.mk,v 1.133 2018/06/22 11:25:03 maya Exp $
+#	$NetBSD: sys.mk,v 1.134 2018/07/09 09:22:55 martin Exp $
 #	@(#)sys.mk	8.2 (Berkeley) 3/21/94
 #
 # This file contains the basic rules for make(1) and is read first
@@ -61,8 +61,8 @@ __ALLSRC4=	${empty(X11SRCDIR):?${__ALLSR
 __BUILDSEED=	${BUILDSEED}/${__ALLSRC4:O}/${.TARGET}
 _CXXSEED?=	${BUILDSEED:D-frandom-seed=${__BUILDSEED:hash}}
 
-COMPILE.cc?=	${CXX} ${_CXXSEED} ${CXXFLAGS} ${DTRACE_OPTS} ${CPPFLAGS} -c
-LINK.cc?=	${CXX} ${CXXFLAGS} ${CPPFLAGS} ${LDFLAGS}
+COMPILE.cc?=	echo "random-seed is ${__BUILDSEED}"; ${CXX} ${_CXXSEED} ${CXXFLAGS} ${DTRACE_OPTS} ${CPPFLAGS} -c
+LINK.cc?=	echo "random-seed is ${__BUILDSEED}"; ${CXX} ${CXXFLAGS} ${CPPFLAGS} ${LDFLAGS}
 
 OBJC?=		${CC}
 OBJCFLAGS?=	${CFLAGS}



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

2018-07-09 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Jul  9 09:13:50 UTC 2018

Modified Files:
src/sys/arch/evbarm/conf: GENERIC64

Log Message:
Enable options MULTIPROCESSOR


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/evbarm/conf/GENERIC64

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/conf/GENERIC64
diff -u src/sys/arch/evbarm/conf/GENERIC64:1.25 src/sys/arch/evbarm/conf/GENERIC64:1.26
--- src/sys/arch/evbarm/conf/GENERIC64:1.25	Sun Jul  1 18:18:18 2018
+++ src/sys/arch/evbarm/conf/GENERIC64	Mon Jul  9 09:13:50 2018
@@ -1,5 +1,5 @@
 #
-#	$NetBSD: GENERIC64,v 1.25 2018/07/01 18:18:18 jmcneill Exp $
+#	$NetBSD: GENERIC64,v 1.26 2018/07/09 09:13:50 jmcneill Exp $
 #
 #	GENERIC ARM (aarch64) kernel
 #
@@ -57,7 +57,7 @@ options 	SOC_SUN50I_A64
 options 	SOC_SUN50I_H5
 options 	SOC_SUN50I_H6
 options 	SOC_VIRT
-#options 	MULTIPROCESSOR
+options 	MULTIPROCESSOR
 
 pseudo-device 	openfirm	# /dev/openfirm
 



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

2018-07-09 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Jul  9 09:13:20 UTC 2018

Modified Files:
src/sys/arch/arm/fdt: psci_fdt.c

Log Message:
Fix arm32 build


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/fdt/psci_fdt.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/fdt/psci_fdt.c
diff -u src/sys/arch/arm/fdt/psci_fdt.c:1.7 src/sys/arch/arm/fdt/psci_fdt.c:1.8
--- src/sys/arch/arm/fdt/psci_fdt.c:1.7	Mon Jul  9 09:10:28 2018
+++ src/sys/arch/arm/fdt/psci_fdt.c	Mon Jul  9 09:13:20 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: psci_fdt.c,v 1.7 2018/07/09 09:10:28 jmcneill Exp $ */
+/* $NetBSD: psci_fdt.c,v 1.8 2018/07/09 09:13:20 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -29,7 +29,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: psci_fdt.c,v 1.7 2018/07/09 09:10:28 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: psci_fdt.c,v 1.8 2018/07/09 09:13:20 jmcneill Exp $");
 
 #include 
 #include 
@@ -169,6 +169,7 @@ psci_fdt_mpstart_pa(void)
 	extern void aarch64_mpstart(void);
 	return (register_t)aarch64_kern_vtophys(aarch64_mpstart);
 #else
+	extern void cortex_mpstart(void);
 	return (register_t)cortex_mpstart;
 #endif
 }



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

2018-07-09 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Jul  9 09:11:21 UTC 2018

Modified Files:
src/sys/arch/arm/sunxi: sunxi_platform.c

Log Message:
Use PSCI to spinup secondary CPUs on sun50i family SoCs.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/arm/sunxi/sunxi_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/sunxi/sunxi_platform.c
diff -u src/sys/arch/arm/sunxi/sunxi_platform.c:1.23 src/sys/arch/arm/sunxi/sunxi_platform.c:1.24
--- src/sys/arch/arm/sunxi/sunxi_platform.c:1.23	Sat Apr  7 18:06:27 2018
+++ src/sys/arch/arm/sunxi/sunxi_platform.c	Mon Jul  9 09:11:21 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_platform.c,v 1.23 2018/04/07 18:06:27 bouyer Exp $ */
+/* $NetBSD: sunxi_platform.c,v 1.24 2018/07/09 09:11:21 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -31,7 +31,7 @@
 #include "opt_fdt_arm.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_platform.c,v 1.23 2018/04/07 18:06:27 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_platform.c,v 1.24 2018/07/09 09:11:21 jmcneill Exp $");
 
 #include 
 #include 
@@ -372,7 +372,7 @@ ARM_PLATFORM(sun9i_a80, "allwinner,sun9i
 
 static const struct arm_platform sun50i_platform = {
 	.devmap = sunxi_platform_devmap,
-	.bootstrap = sunxi_platform_bootstrap,
+	.bootstrap = sunxi_platform_psci_bootstrap,
 	.init_attach_args = sunxi_platform_init_attach_args,
 	.early_putchar = sunxi_platform_early_putchar,
 	.device_register = sunxi_platform_device_register,
@@ -386,7 +386,7 @@ ARM_PLATFORM(sun50i_h5, "allwinner,sun50
 
 static const struct arm_platform sun50i_h6_platform = {
 	.devmap = sunxi_platform_devmap,
-	.bootstrap = sunxi_platform_bootstrap,
+	.bootstrap = sunxi_platform_psci_bootstrap,
 	.init_attach_args = sunxi_platform_init_attach_args,
 	.early_putchar = sunxi_platform_early_putchar,
 	.device_register = sunxi_platform_device_register,



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

2018-07-09 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Jul  9 09:10:29 UTC 2018

Modified Files:
src/sys/arch/arm/fdt: psci_fdt.c

Log Message:
Add aarch64 support.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/fdt/psci_fdt.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/fdt/psci_fdt.c
diff -u src/sys/arch/arm/fdt/psci_fdt.c:1.6 src/sys/arch/arm/fdt/psci_fdt.c:1.7
--- src/sys/arch/arm/fdt/psci_fdt.c:1.6	Sat Jul  7 15:11:07 2018
+++ src/sys/arch/arm/fdt/psci_fdt.c	Mon Jul  9 09:10:28 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: psci_fdt.c,v 1.6 2018/07/07 15:11:07 jmcneill Exp $ */
+/* $NetBSD: psci_fdt.c,v 1.7 2018/07/09 09:10:28 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -29,13 +29,14 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: psci_fdt.c,v 1.6 2018/07/07 15:11:07 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: psci_fdt.c,v 1.7 2018/07/09 09:10:28 jmcneill Exp $");
 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -152,13 +153,32 @@ psci_fdt_preinit(void)
 	return psci_fdt_init(phandle);
 }
 
+static bus_addr_t psci_fdt_read_mpidr_aff(void)
+{
+#ifdef __aarch64__
+	return reg_mpidr_el1_read() & (MPIDR_AFF3|MPIDR_AFF2|MPIDR_AFF1|MPIDR_AFF0);
+#else
+	return armreg_mpidr_read() & (MPIDR_AFF2|MPIDR_AFF1|MPIDR_AFF0);
+#endif
+}
+
+static register_t
+psci_fdt_mpstart_pa(void)
+{
+#ifdef __aarch64__
+	extern void aarch64_mpstart(void);
+	return (register_t)aarch64_kern_vtophys(aarch64_mpstart);
+#else
+	return (register_t)cortex_mpstart;
+#endif
+}
+
 void
 psci_fdt_bootstrap(void)
 {
 #ifdef MULTIPROCESSOR
 	extern void cortex_mpstart(void);
-	bus_addr_t mpidr;
-	uint32_t bp_mpidr;
+	bus_addr_t mpidr, bp_mpidr;
 	int child;
 
 	const int cpus = OF_finddevice("/cpus");
@@ -178,7 +198,7 @@ psci_fdt_bootstrap(void)
 		return;
 
 	/* MPIDR affinity levels of boot processor. */
-	bp_mpidr = armreg_mpidr_read() & (MPIDR_AFF2|MPIDR_AFF1|MPIDR_AFF0);
+	bp_mpidr = psci_fdt_read_mpidr_aff();
 
 	/* Boot APs */
 	uint32_t started = 0;
@@ -191,20 +211,18 @@ psci_fdt_bootstrap(void)
 			continue; 	/* BP already started */
 
 		/* XXX NetBSD requires all CPUs to be in the same cluster */
-		const u_int bp_clid = __SHIFTOUT(bp_mpidr, CORTEXA9_MPIDR_CLID);
-		const u_int clid = __SHIFTOUT(mpidr, CORTEXA9_MPIDR_CLID);
-		if (bp_clid != clid)
+		if ((mpidr & ~MPIDR_AFF0) != (bp_mpidr & ~MPIDR_AFF0))
 			continue;
 
-		const u_int cpuid = __SHIFTOUT(mpidr, CORTEXA9_MPIDR_CPUID);
-		int ret = psci_cpu_on(cpuid, (register_t)cortex_mpstart, 0);
+		const u_int cpuid = __SHIFTOUT(mpidr, MPIDR_AFF0);
+		int ret = psci_cpu_on(cpuid, psci_fdt_mpstart_pa(), 0);
 		if (ret == PSCI_SUCCESS)
 			started |= __BIT(cpuid);
 	}
 
 	/* Wait for APs to start */
 	for (u_int i = 0x1000; i > 0; i--) {
-		arm_dmb();
+		membar_consumer();
 		if (arm_cpu_hatched == started)
 			break;
 	}



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

2018-07-09 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Jul  9 09:09:47 UTC 2018

Modified Files:
src/sys/arch/aarch64/include: locore.h

Log Message:
Include aarch64/machdep.h for arm32 compat.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/aarch64/include/locore.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/aarch64/include/locore.h
diff -u src/sys/arch/aarch64/include/locore.h:1.4 src/sys/arch/aarch64/include/locore.h:1.5
--- src/sys/arch/aarch64/include/locore.h:1.4	Mon Jul  9 06:19:53 2018
+++ src/sys/arch/aarch64/include/locore.h	Mon Jul  9 09:09:47 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: locore.h,v 1.4 2018/07/09 06:19:53 ryo Exp $ */
+/* $NetBSD: locore.h,v 1.5 2018/07/09 09:09:47 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -50,6 +50,7 @@
 #include 
 
 #include 
+#include 	/* arm32 compat */
 
 /* for compatibility arch/arm */
 #define I32_bit			DAIF_I



CVS commit: src/sys

2018-07-09 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Mon Jul  9 08:51:19 UTC 2018

Modified Files:
src/sys/arch/evbarm/stand/boot2440: dev_sdmmc.c
src/sys/arch/mips/sibyte/dev: sbjcnvar.h
src/sys/dev/sbus: magmareg.h spifreg.h

Log Message:
Avoid redefining SET/CLR/ISSET (which in the kernel are normally
defined in ).   These redefinitions (when they are,
that is, when types.h is included) were sneaking through because
they were defined identically ... until CLR in  was
changed...Avoid that issue arising again.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/evbarm/stand/boot2440/dev_sdmmc.c
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/mips/sibyte/dev/sbjcnvar.h
cvs rdiff -u -r1.18 -r1.19 src/sys/dev/sbus/magmareg.h
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/sbus/spifreg.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/evbarm/stand/boot2440/dev_sdmmc.c
diff -u src/sys/arch/evbarm/stand/boot2440/dev_sdmmc.c:1.3 src/sys/arch/evbarm/stand/boot2440/dev_sdmmc.c:1.4
--- src/sys/arch/evbarm/stand/boot2440/dev_sdmmc.c:1.3	Fri Jan  2 19:42:05 2015
+++ src/sys/arch/evbarm/stand/boot2440/dev_sdmmc.c	Mon Jul  9 08:51:19 2018
@@ -90,9 +90,16 @@
 #include "dev_sdmmc.h"
 #include "s3csdi.h"
 
+#ifndef SET
 #define SET(t, f)   ((t) |= (f))
+#endif
+#ifndef ISSET
 #define ISSET(t, f) ((t) & (f))
+#endif
+#ifndef CLR
 #define CLR(t, f)   ((t) &= ~(f))
+#endif
+
 
 //#define SDMMC_DEBUG
 #ifdef SDMMC_DEBUG

Index: src/sys/arch/mips/sibyte/dev/sbjcnvar.h
diff -u src/sys/arch/mips/sibyte/dev/sbjcnvar.h:1.6 src/sys/arch/mips/sibyte/dev/sbjcnvar.h:1.7
--- src/sys/arch/mips/sibyte/dev/sbjcnvar.h:1.6	Mon Apr 13 21:18:42 2015
+++ src/sys/arch/mips/sibyte/dev/sbjcnvar.h	Mon Jul  9 08:51:19 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: sbjcnvar.h,v 1.6 2015/04/13 21:18:42 riastradh Exp $ */
+/* $NetBSD: sbjcnvar.h,v 1.7 2018/07/09 08:51:19 kre Exp $ */
 
 /*
  * Copyright 2000, 2001
@@ -171,6 +171,12 @@ struct sbjcn_softc {
 };
 
 /* Macros to clear/set/test flags. */
-#define	SET(t, f)	(t) |= (f)
-#define	CLR(t, f)	(t) &= ~(f)
+#ifndef SET
+#define	SET(t, f)	((t) |= (f))
+#endif
+#ifndef CLR
+#define	CLR(t, f)	((t) &= ~(f))
+#endif
+#ifndef ISSET
 #define	ISSET(t, f)	((t) & (f))
+#endif

Index: src/sys/dev/sbus/magmareg.h
diff -u src/sys/dev/sbus/magmareg.h:1.18 src/sys/dev/sbus/magmareg.h:1.19
--- src/sys/dev/sbus/magmareg.h:1.18	Sat Nov 15 19:18:19 2014
+++ src/sys/dev/sbus/magmareg.h	Mon Jul  9 08:51:19 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: magmareg.h,v 1.18 2014/11/15 19:18:19 christos Exp $	*/
+/*	$NetBSD: magmareg.h,v 1.19 2018/07/09 08:51:19 kre Exp $	*/
 
 /*-
  *  Copyright (c) 1998 Iain Hibbert
@@ -189,9 +189,15 @@ struct mbpp_softc {
 /*
  * useful macros
  */
+#ifndef SET
 #define SET(t, f)	((t) |= (f))
+#endif
+#ifndef CLR
 #define CLR(t, f)	((t) &= ~(f))
+#endif
+#ifndef ISSET
 #define ISSET(t, f)	((t) & (f))
+#endif
 
 /* internal function prototypes */
 

Index: src/sys/dev/sbus/spifreg.h
diff -u src/sys/dev/sbus/spifreg.h:1.5 src/sys/dev/sbus/spifreg.h:1.6
--- src/sys/dev/sbus/spifreg.h:1.5	Sat Nov 15 19:18:19 2014
+++ src/sys/dev/sbus/spifreg.h	Mon Jul  9 08:51:19 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: spifreg.h,v 1.5 2014/11/15 19:18:19 christos Exp $	*/
+/*	$NetBSD: spifreg.h,v 1.6 2018/07/09 08:51:19 kre Exp $	*/
 /*	$OpenBSD: spifreg.h,v 1.5 2003/06/02 18:32:41 jason Exp $	*/
 
 /*
@@ -383,9 +383,15 @@
 /*
  * useful macros
  */
+#ifndef SET
 #define	SET(t, f)	((t) |= (f))
+#endif
+#ifndef CLR
 #define	CLR(t, f)	((t) &= ~(f))
+#endif
+#ifndef ISSET
 #define	ISSET(t, f)	((t) & (f))
+#endif
 
 /*
  * internal function prototypes



CVS commit: [pgoyette-compat] src/sys/kern

2018-07-09 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Mon Jul  9 08:45:42 UTC 2018

Modified Files:
src/sys/kern [pgoyette-compat]: kern_module.c

Log Message:
Put the checks back in the original order, and remove extra ')'

Thanks to soda for finding the real error.


To generate a diff of this commit:
cvs rdiff -u -r1.130.2.12 -r1.130.2.13 src/sys/kern/kern_module.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_module.c
diff -u src/sys/kern/kern_module.c:1.130.2.12 src/sys/kern/kern_module.c:1.130.2.13
--- src/sys/kern/kern_module.c:1.130.2.12	Mon Jul  9 08:26:29 2018
+++ src/sys/kern/kern_module.c	Mon Jul  9 08:45:41 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_module.c,v 1.130.2.12 2018/07/09 08:26:29 pgoyette Exp $	*/
+/*	$NetBSD: kern_module.c,v 1.130.2.13 2018/07/09 08:45:41 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.130.2.12 2018/07/09 08:26:29 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.130.2.13 2018/07/09 08:45:41 pgoyette Exp $");
 
 #define _MODULE_INTERNAL
 
@@ -1039,8 +1039,8 @@ module_do_load(const char *name, bool is
 		}
 	}
 	if (mod) {
-		if (!ISSET(flags, MODCTL_LOAD_FORCE) &&
-		ISSET(mod->mod_flags, MODFLG_MUST_FORCE)) {
+		if (ISSET(mod->mod_flags, MODFLG_MUST_FORCE) &&
+		!ISSET(flags, MODCTL_LOAD_FORCE)) {
 			if (!autoload) {
 module_error("use -f to reinstate "
 "builtin module `%s'", name);



CVS commit: [pgoyette-compat] src/sys/kern

2018-07-09 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Mon Jul  9 08:26:29 UTC 2018

Modified Files:
src/sys/kern [pgoyette-compat]: kern_module.c

Log Message:
Reverse order of flags checking to appease compiler.  It seems
that gcc doesn't like

if (expr && !ISSET(t, f)) ...


To generate a diff of this commit:
cvs rdiff -u -r1.130.2.11 -r1.130.2.12 src/sys/kern/kern_module.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_module.c
diff -u src/sys/kern/kern_module.c:1.130.2.11 src/sys/kern/kern_module.c:1.130.2.12
--- src/sys/kern/kern_module.c:1.130.2.11	Sun Jul  8 07:33:14 2018
+++ src/sys/kern/kern_module.c	Mon Jul  9 08:26:29 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_module.c,v 1.130.2.11 2018/07/08 07:33:14 pgoyette Exp $	*/
+/*	$NetBSD: kern_module.c,v 1.130.2.12 2018/07/09 08:26:29 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.130.2.11 2018/07/08 07:33:14 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.130.2.12 2018/07/09 08:26:29 pgoyette Exp $");
 
 #define _MODULE_INTERNAL
 
@@ -1039,8 +1039,8 @@ module_do_load(const char *name, bool is
 		}
 	}
 	if (mod) {
-		if (ISSET(mod->mod_flags, MODFLG_MUST_FORCE)) &&
-		!ISSET(flags, MODCTL_LOAD_FORCE)) {
+		if (!ISSET(flags, MODCTL_LOAD_FORCE) &&
+		ISSET(mod->mod_flags, MODFLG_MUST_FORCE)) {
 			if (!autoload) {
 module_error("use -f to reinstate "
 "builtin module `%s'", name);



CVS commit: src/etc

2018-07-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jul  9 08:24:33 UTC 2018

Modified Files:
src/etc: Makefile.params

Log Message:
Remove debug hack (revert previous)


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/etc/Makefile.params

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

Modified files:

Index: src/etc/Makefile.params
diff -u src/etc/Makefile.params:1.18 src/etc/Makefile.params:1.19
--- src/etc/Makefile.params:1.18	Thu Jul  5 15:52:27 2018
+++ src/etc/Makefile.params	Mon Jul  9 08:24:33 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.params,v 1.18 2018/07/05 15:52:27 martin Exp $
+#	$NetBSD: Makefile.params,v 1.19 2018/07/09 08:24:33 martin Exp $
 #
 # Makefile fragment for printing build parameters.
 #
@@ -52,9 +52,6 @@ RELEASEVARS+= 	BSDOBJDIR BSDSRCDIR BUILD
 		DESTDIR KERNARCHDIR KERNCONFDIR KERNOBJDIR KERNSRCDIR MAKE \
 		MAKEFLAGS NBUILDJOBS NETBSDSRCDIR OBJMACHINE OBJMACHINE_ARCH \
 		RELEASEDIR RELEASEMACHINEDIR TOOLDIR USR_OBJMACHINE X11SRCDIR
-.else
-		# temporary debugging for MKREPRO builds
-RELEASEVARS+=	BUILDSEED _CXXSEED __BUILDSEED
 .endif
 
 RELEASEVARS+= ${_MKVARS.yes} ${_MKVARS.no}



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

2018-07-09 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Mon Jul  9 06:33:08 UTC 2018

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

Log Message:
fix compile error


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/aarch64/aarch64/db_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/db_machdep.c
diff -u src/sys/arch/aarch64/aarch64/db_machdep.c:1.3 src/sys/arch/aarch64/aarch64/db_machdep.c:1.4
--- src/sys/arch/aarch64/aarch64/db_machdep.c:1.3	Mon Jul  9 06:19:53 2018
+++ src/sys/arch/aarch64/aarch64/db_machdep.c	Mon Jul  9 06:33:08 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: db_machdep.c,v 1.3 2018/07/09 06:19:53 ryo Exp $ */
+/* $NetBSD: db_machdep.c,v 1.4 2018/07/09 06:33:08 ryo Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -30,13 +30,15 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.3 2018/07/09 06:19:53 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.4 2018/07/09 06:33:08 ryo Exp $");
 
 #include "opt_kernhist.h"
 #include "opt_uvmhist.h"
 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 



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

2018-07-09 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Mon Jul  9 06:21:46 UTC 2018

Modified Files:
src/sys/arch/arm/broadcom: bcm283x_platform.c

Log Message:
hatch secondary processors (aarch64)


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/broadcom/bcm283x_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/broadcom/bcm283x_platform.c
diff -u src/sys/arch/arm/broadcom/bcm283x_platform.c:1.6 src/sys/arch/arm/broadcom/bcm283x_platform.c:1.7
--- src/sys/arch/arm/broadcom/bcm283x_platform.c:1.6	Wed Jun 27 11:12:14 2018
+++ src/sys/arch/arm/broadcom/bcm283x_platform.c	Mon Jul  9 06:21:46 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: bcm283x_platform.c,v 1.6 2018/06/27 11:12:14 ryo Exp $	*/
+/*	$NetBSD: bcm283x_platform.c,v 1.7 2018/07/09 06:21:46 ryo Exp $	*/
 
 /*-
  * Copyright (c) 2017 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bcm283x_platform.c,v 1.6 2018/06/27 11:12:14 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm283x_platform.c,v 1.7 2018/07/09 06:21:46 ryo Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_bcm283x.h"
@@ -774,18 +774,51 @@ bcm2836_bootstrap(void)
 {
 #define RPI_CPU_MAX	4
 
-#ifdef MULTIPROCESSOR
-	extern int cortex_mmuinfo;
+#ifdef VERBOSE_INIT_ARM
+#define DPRINTF(...)	printf(__VA_ARGS__)
+#else
+#define DPRINTF(...)
+#endif
 
+#ifdef MULTIPROCESSOR
 	arm_cpu_max = RPI_CPU_MAX;
+	DPRINTF("%s: %d cpus present\n", __func__, arm_cpu_max);
+#ifdef __arm__
+	extern int cortex_mmuinfo;
 	cortex_mmuinfo = armreg_ttbr_read();
-#ifdef VERBOSE_INIT_ARM
-	printf("%s: %d cpus present\n", __func__, arm_cpu_max);
-	printf("%s: cortex_mmuinfo %x\n", __func__, cortex_mmuinfo);
+	DPRINTF("%s: cortex_mmuinfo %x\n", __func__, cortex_mmuinfo);
 #endif
+#endif /* MULTIPROCESSOR */
+
+#ifdef __aarch64__
+	/*
+	 * XXX: use psci_fdt_bootstrap()
+	 */
+	extern void aarch64_mpstart(void);
+	for (int i = 1; i < RPI_CPU_MAX; i++) {
+		/*
+		 * Reference:
+		 *   armstubs/armstub8.S
+		 *   in https://github.com/raspberrypi/tools
+		 */
+		volatile uint64_t *cpu_release_addr;
+#define RPI3_ARMSTUB8_SPINADDR_BASE	0x00d8
+		cpu_release_addr =
+		AARCH64_PA_TO_KVA(RPI3_ARMSTUB8_SPINADDR_BASE + i * 8);
+		*cpu_release_addr = aarch64_kern_vtophys(aarch64_mpstart);
+
+		/* need flush cache. secondary processors are cache disabled */
+		cpu_dcache_wb_range(cpu_release_addr, sizeof(cpu_release_addr));
+		__asm __volatile("sev" ::: "memory");
+
+#if defined(VERBOSE_INIT_ARM) && defined(EARLYCONS)
+		/* wait secondary processor's debug output */
+		gtmr_delay(10);
 #endif
+	}
+#endif /* __aarch64__ */
 
-#ifndef __aarch64__
+#ifdef __arm__
 	/*
 	 * Even if no options MULTIPROCESSOR,
 	 * It is need to initialize the secondary CPU,
@@ -803,6 +836,7 @@ bcm2836_bootstrap(void)
 		(uint32_t)cortex_mpstart);
 	}
 #endif
+
 #ifdef MULTIPROCESSOR
 	/* Wake up AP in case firmware has placed it in WFE state */
 	__asm __volatile("sev" ::: "memory");



CVS commit: src/sys/arch/aarch64

2018-07-09 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Mon Jul  9 06:19:53 UTC 2018

Modified Files:
src/sys/arch/aarch64/aarch64: cpu.c cpu_machdep.c db_machdep.c
genassym.cf locore.S
src/sys/arch/aarch64/include: cpu.h locore.h machdep.h

Log Message:
add MULTIPROCESSOR support


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/aarch64/aarch64/cpu.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/aarch64/aarch64/cpu_machdep.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/aarch64/aarch64/db_machdep.c \
src/sys/arch/aarch64/aarch64/genassym.cf
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/aarch64/aarch64/locore.S
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/aarch64/include/cpu.h
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/aarch64/include/locore.h
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/aarch64/include/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/aarch64/aarch64/cpu.c
diff -u src/sys/arch/aarch64/aarch64/cpu.c:1.1 src/sys/arch/aarch64/aarch64/cpu.c:1.2
--- src/sys/arch/aarch64/aarch64/cpu.c:1.1	Sun Apr  1 04:35:03 2018
+++ src/sys/arch/aarch64/aarch64/cpu.c	Mon Jul  9 06:19:53 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.1 2018/04/01 04:35:03 ryo Exp $ */
+/* $NetBSD: cpu.c,v 1.2 2018/07/09 06:19:53 ryo Exp $ */
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,13 +27,16 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.1 2018/04/01 04:35:03 ryo Exp $");
+__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.2 2018/07/09 06:19:53 ryo Exp $");
 
 #include "locators.h"
+#include "opt_arm_debug.h"
+#include "opt_fdt.h"
 #include "opt_multiprocessor.h"
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -43,71 +46,106 @@ __KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.1 
 #include 
 #include 
 
+#ifdef FDT
+#include 
+#endif
+
 void cpu_attach(device_t, cpuid_t);
-static void cpu_identify(device_t self, struct cpu_info *);
+static void identify_aarch64_model(uint32_t, char *, size_t);
+static void cpu_identify(device_t self, struct cpu_info *, uint32_t, uint64_t);
+static void cpu_identify1(device_t self, struct cpu_info *);
 static void cpu_identify2(device_t self, struct cpu_info *);
 
+#ifdef MULTIPROCESSOR
+volatile u_int arm_cpu_hatched __cacheline_aligned = 0;
+volatile uint32_t arm_cpu_mbox __cacheline_aligned = 0;
+u_int arm_cpu_max = 1;
+
+/* stored by secondary processors (available when arm_cpu_hatched) */
+uint32_t cpus_midr[MAXCPUS];
+uint64_t cpus_mpidr[MAXCPUS];
+
+static kmutex_t cpu_hatch_lock;
+#endif /* MULTIPROCESSOR */
+
+/* Our exported CPU info; we can have only one. */
+struct cpu_info cpu_info_store __cacheline_aligned = {
+	.ci_cpl = IPL_HIGH,
+	.ci_curlwp = 
+};
+
+#ifdef MULTIPROCESSOR
+#define NCPUINFO	MAXCPUS
+#else
+#define NCPUINFO	1
+#endif /* MULTIPROCESSOR */
+
+struct cpu_info *cpu_info[NCPUINFO] = {
+	[0] = _info_store
+};
+
 void
 cpu_attach(device_t dv, cpuid_t id)
 {
 	struct cpu_info *ci;
+	uint64_t mpidr;
+	uint32_t midr;
 
 	if (id == 0) {
 		ci = curcpu();
-
+		midr = reg_midr_el1_read();
+		mpidr = reg_mpidr_el1_read();
 	} else {
 #ifdef MULTIPROCESSOR
-		//XXXAARCH64: notyet?
-
-		uint64_t mpidr = reg_mpidr_el1_read();
-
 		KASSERT(cpu_info[id] == NULL);
 		ci = kmem_zalloc(sizeof(*ci), KM_SLEEP);
 		ci->ci_cpl = IPL_HIGH;
 		ci->ci_cpuid = id;
-		if (mpidr & MPIDR_MT) {
-			ci->ci_data.cpu_smt_id = mpidr & MPIDR_AFF0;
-			ci->ci_data.cpu_core_id = mpidr & MPIDR_AFF1;
-			ci->ci_data.cpu_package_id = mpidr & MPIDR_AFF2;
-		} else {
-			ci->ci_data.cpu_core_id = mpidr & MPIDR_AFF0;
-			ci->ci_data.cpu_package_id = mpidr & MPIDR_AFF1;
-		}
-		ci->ci_data.cpu_cc_freq = cpu_info_store.ci_data.cpu_cc_freq;
+
+		ci->ci_data.cpu_cc_freq = cpu_info[0]->ci_data.cpu_cc_freq;
 		cpu_info[ci->ci_cpuid] = ci;
 		if ((arm_cpu_hatched & (1 << id)) == 0) {
 			ci->ci_dev = dv;
 			dv->dv_private = ci;
 
 			aprint_naive(": disabled\n");
-			aprint_normal(": disabled (uniprocessor kernel)\n");
+			aprint_normal(": disabled (unresponsive)\n");
 			return;
 		}
-#else
+
+		/* cpus_{midr,mpidr}[id] is stored by secondary processor */
+		midr = cpus_midr[id];
+		mpidr = cpus_mpidr[id];
+#else /* MULTIPROCESSOR */
 		aprint_naive(": disabled\n");
 		aprint_normal(": disabled (uniprocessor kernel)\n");
 		return;
-#endif
+#endif /* MULTIPROCESSOR */
+	}
+
+	if (mpidr & MPIDR_MT) {
+		ci->ci_data.cpu_smt_id = mpidr & MPIDR_AFF0;
+		ci->ci_data.cpu_core_id = mpidr & MPIDR_AFF1;
+		ci->ci_data.cpu_package_id = mpidr & MPIDR_AFF2;
+	} else {
+		ci->ci_data.cpu_core_id = mpidr & MPIDR_AFF0;
+		ci->ci_data.cpu_package_id = mpidr & MPIDR_AFF1;
 	}
 
 	ci->ci_dev = dv;
 	dv->dv_private = ci;
 
+	cpu_identify(ci->ci_dev, ci, midr, mpidr);
 #ifdef MULTIPROCESSOR
-	if (caa->caa_cpucore != 0) {
-		aprint_naive("\n");
-		aprint_normal(": %s\n", cpu_getmodel());
+	if (id != 0) {
 		mi_cpu_attach(ci);
-
-		// XXXAARCH64
-		//pmap_tlb_info_attach();
-		panic("notyet");
+		

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

2018-07-09 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Mon Jul  9 06:14:38 UTC 2018

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

Log Message:
need locks in pmap_kremove() and pmap_fault_fixup()


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/aarch64/aarch64/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/aarch64/aarch64/pmap.c
diff -u src/sys/arch/aarch64/aarch64/pmap.c:1.7 src/sys/arch/aarch64/aarch64/pmap.c:1.8
--- src/sys/arch/aarch64/aarch64/pmap.c:1.7	Sun May 20 06:45:00 2018
+++ src/sys/arch/aarch64/aarch64/pmap.c	Mon Jul  9 06:14:38 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.7 2018/05/20 06:45:00 ryo Exp $	*/
+/*	$NetBSD: pmap.c,v 1.8 2018/07/09 06:14:38 ryo Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.7 2018/05/20 06:45:00 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.8 2018/07/09 06:14:38 ryo Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_ddb.h"
@@ -1514,11 +1514,13 @@ _pmap_remove(struct pmap *pm, vaddr_t va
 	UVMHIST_LOG(pmaphist, "pm=%p, va=%016lx, kremovemode=%d",
 	pm, va, kremove, 0);
 
+	PM_LOCK(pm);
+
 	ptep = _pmap_pte_lookup(pm, va);
 	if (ptep != NULL) {
 		pte = *ptep;
 		if (!l3pte_valid(pte))
-			return;
+			goto done;
 
 		pa = l3pte_pa(pte);
 
@@ -1541,6 +1543,8 @@ _pmap_remove(struct pmap *pm, vaddr_t va
 			pm->pm_stats.wired_count--;
 		pm->pm_stats.resident_count--;
 	}
+ done:
+	PM_UNLOCK(pm);
 }
 
 void
@@ -1550,14 +1554,10 @@ pmap_remove(struct pmap *pm, vaddr_t sva
 
 	PM_ADDR_CHECK(pm, sva);
 
-	PM_LOCK(pm);
-
 	KASSERT(!IN_KSEG_ADDR(sva));
 
 	for (va = sva; va < eva; va += PAGE_SIZE)
 		_pmap_remove(pm, va, false);
-
-	PM_UNLOCK(pm);
 }
 
 void
@@ -1651,6 +1651,7 @@ pmap_fault_fixup(struct pmap *pm, vaddr_
 	pt_entry_t *ptep, pte;
 	vm_prot_t pmap_prot;
 	paddr_t pa;
+	bool fixed = false;
 
 	UVMHIST_FUNC(__func__);
 	UVMHIST_CALLED(pmaphist);
@@ -1674,25 +1675,27 @@ pmap_fault_fixup(struct pmap *pm, vaddr_
 	}
 #endif
 
+	PM_LOCK(pm);
+
 	ptep = _pmap_pte_lookup(pm, va);
 	if (ptep == NULL) {
 		UVMHIST_LOG(pmaphist, "pte_lookup failure: va=%016lx",
 		va, 0, 0, 0);
-		return false;
+		goto done;
 	}
 
 	pte = *ptep;
 	if (!l3pte_valid(pte)) {
 		UVMHIST_LOG(pmaphist, "invalid pte: %016llx: va=%016lx",
 		pte, va, 0, 0);
-		return false;
+		goto done;
 	}
 
 	pa = l3pte_pa(*ptep);
 	pg = PHYS_TO_VM_PAGE(pa);
 	if (pg == NULL) {
 		UVMHIST_LOG(pmaphist, "pg not found: va=%016lx", va, 0, 0, 0);
-		return false;
+		goto done;
 	}
 	md = VM_PAGE_TO_MD(pg);
 
@@ -1722,7 +1725,7 @@ pmap_fault_fixup(struct pmap *pm, vaddr_
 	/* no permission to read/write/execute for this page */
 	if ((pmap_prot & accessprot) != accessprot) {
 		UVMHIST_LOG(pmaphist, "no permission to access", 0, 0, 0, 0);
-		return false;
+		goto done;
 	}
 
 	if ((pte & LX_BLKPAG_AF) && ((pte & LX_BLKPAG_AP) == LX_BLKPAG_AP_RW)) {
@@ -1737,7 +1740,7 @@ pmap_fault_fixup(struct pmap *pm, vaddr_
 			__func__, va, pte, curlwp->l_md.md_onfault);
 		}
 #endif
-		return false;
+		goto done;
 	}
 	KASSERT(((pte & LX_BLKPAG_AF) == 0) ||
 	((pte & LX_BLKPAG_AP) == LX_BLKPAG_AP_RO));
@@ -1776,8 +1779,11 @@ pmap_fault_fixup(struct pmap *pm, vaddr_
 #else
 	aarch64_tlbi_by_va(va);
 #endif
+	fixed = true;
 
-	return true;
+ done:
+	PM_UNLOCK(pm);
+	return fixed;
 }
 
 bool
@@ -1924,7 +1930,7 @@ static void
 pmap_db_pte_print(pt_entry_t pte, int level, void (*pr)(const char *, ...))
 {
 	if (pte == 0) {
-		pr("UNUSED\n");
+		pr(" UNUSED\n");
 
 	} else if (level == 0) {
 		/* L0 pde */
@@ -2089,7 +2095,9 @@ pmap_db_pteinfo(vaddr_t va, void (*pr)(c
 
 	pa = l3pte_pa(pte);
 	pg = PHYS_TO_VM_PAGE(pa);
-	if (pg != NULL) {
+	if (pg == NULL) {
+		pr("No VM_PAGE\n");
+	} else {
 		pg_dump(pg, pr);
 		md = VM_PAGE_TO_MD(pg);
 		pv_dump(md, pr);



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

2018-07-09 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Mon Jul  9 06:11:12 UTC 2018

Modified Files:
src/sys/arch/aarch64/aarch64: cpuswitch.S

Log Message:
remove unused code


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/aarch64/aarch64/cpuswitch.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/aarch64/aarch64/cpuswitch.S
diff -u src/sys/arch/aarch64/aarch64/cpuswitch.S:1.1 src/sys/arch/aarch64/aarch64/cpuswitch.S:1.2
--- src/sys/arch/aarch64/aarch64/cpuswitch.S:1.1	Sun Apr  1 04:35:03 2018
+++ src/sys/arch/aarch64/aarch64/cpuswitch.S	Mon Jul  9 06:11:12 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: cpuswitch.S,v 1.1 2018/04/01 04:35:03 ryo Exp $ */
+/* $NetBSD: cpuswitch.S,v 1.2 2018/07/09 06:11:12 ryo Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 
 #include "opt_ddb.h"
 
-RCSID("$NetBSD: cpuswitch.S,v 1.1 2018/04/01 04:35:03 ryo Exp $")
+RCSID("$NetBSD: cpuswitch.S,v 1.2 2018/07/09 06:11:12 ryo Exp $")
 
 /*
  * At IPL_SCHED:
@@ -200,13 +200,6 @@ END(softint_cleanup)
  *	x28 = arg
  */
 ENTRY_NP(lwp_trampoline)
-#if defined(MULTIPROCESSOR)
-	mov	x19, x0
-	mov	x20, x1
-	bl	_C_LABEL(proc_trampoline_mp)
-	mov	x1, x20
-	mov	x0, x19
-#endif
 	bl	_C_LABEL(lwp_startup)
 
 	/*
@@ -345,24 +338,6 @@ ENTRY_NP(cpu_Debugger)
 END(cpu_Debugger)
 #endif /* DDB */
 
-#ifdef MULTIPROCESSOR
-/*
- * void
- * cpu_spinup_trampoline(int cpu_index)
- * {
- *  ci := tp == cpu_info[cpu_index]
- *  ci->ci_curlwp = ci->ci_data.ci_idlelwp;
- *  sp := ci->ci_curlwp->l_addr + USPACE - sizeof(struct trapframe)
- *  cpu_hatch(ci);
- *  jump to idle_loop() to join the cpu pool.
- * }
- */
-ENTRY_NP(cpu_spinup_trampoline)
-	bl	_C_LABEL(cpu_hatch)
-	b	_C_LABEL(cpu_idle)
-END(cpu_spinup_trampoline)
-#endif
-
 /*
  * int cpu_set_onfault(struct faultbuf *fb)
  */



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

2018-07-09 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Mon Jul  9 06:10:21 UTC 2018

Modified Files:
src/sys/arch/aarch64/aarch64: locore_el2.S

Log Message:
keep stack pointer when changing from EL2 to EL1.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/aarch64/aarch64/locore_el2.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/aarch64/aarch64/locore_el2.S
diff -u src/sys/arch/aarch64/aarch64/locore_el2.S:1.1 src/sys/arch/aarch64/aarch64/locore_el2.S:1.2
--- src/sys/arch/aarch64/aarch64/locore_el2.S:1.1	Sun Apr  1 04:35:03 2018
+++ src/sys/arch/aarch64/aarch64/locore_el2.S	Mon Jul  9 06:10:21 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore_el2.S,v 1.1 2018/04/01 04:35:03 ryo Exp $	*/
+/*	$NetBSD: locore_el2.S,v 1.2 2018/07/09 06:10:21 ryo Exp $	*/
 
 /*-
  * Copyright (c) 2012-2014 Andrew Turner
@@ -32,17 +32,15 @@
 #include 
 #include "assym.h"
 
-RCSID("$NetBSD: locore_el2.S,v 1.1 2018/04/01 04:35:03 ryo Exp $")
+RCSID("$NetBSD: locore_el2.S,v 1.2 2018/07/09 06:10:21 ryo Exp $")
 
 
 /* for use in #include "locore_el2.S" */
 	.text
 drop_to_el1_inline:
-	mov	x27, sp
-	mov	x28, lr
+	mov	x8, lr
 	bl	drop_to_el1
-	mov	lr, x28
-	mov	sp, x27
+	mov	lr, x8
 	b	drop_to_el1_inline_done
 
 	.text
@@ -117,6 +115,10 @@ drop_to_el1:
 	msr	icc_sre_el2, x2
 2:
 
+	/* keep stack pointer */
+	mov	x0, sp
+	msr	sp_el1, x0
+
 	/* Set the address to return to our return address */
 	msr	elr_el2, x30
 	isb



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

2018-07-09 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Mon Jul  9 06:08:42 UTC 2018

Modified Files:
src/sys/arch/arm/pic: pic.c

Log Message:
fix false positive KASSERT.
the case that secondary processors failed to hatch, and not attached.

when "cpu1 at cpus0: disabled (unresponsive)"


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sys/arch/arm/pic/pic.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/pic/pic.c
diff -u src/sys/arch/arm/pic/pic.c:1.42 src/sys/arch/arm/pic/pic.c:1.43
--- src/sys/arch/arm/pic/pic.c:1.42	Sun Apr  1 04:35:04 2018
+++ src/sys/arch/arm/pic/pic.c	Mon Jul  9 06:08:42 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.42 2018/04/01 04:35:04 ryo Exp $	*/
+/*	$NetBSD: pic.c,v 1.43 2018/07/09 06:08:42 ryo Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -33,7 +33,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.42 2018/04/01 04:35:04 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.43 2018/07/09 06:08:42 ryo Exp $");
 
 #include 
 #include 
@@ -201,7 +201,7 @@ intr_ipi_send(const kcpuset_t *kcp, u_lo
 			sent_p = true;
 		}
 	}
-	KASSERT(cold || sent_p || arm_cpu_max == 1);
+	KASSERT(cold || sent_p || ncpu <= 1);
 }
 #endif /* MULTIPROCESSOR */
 



CVS commit: src/common/lib/libc/arch/aarch64/string

2018-07-09 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Mon Jul  9 06:07:06 UTC 2018

Modified Files:
src/common/lib/libc/arch/aarch64/string: memcmp.S

Log Message:
avoid reading from out of range that may cause access fault.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/common/lib/libc/arch/aarch64/string/memcmp.S

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/arch/aarch64/string/memcmp.S
diff -u src/common/lib/libc/arch/aarch64/string/memcmp.S:1.2 src/common/lib/libc/arch/aarch64/string/memcmp.S:1.3
--- src/common/lib/libc/arch/aarch64/string/memcmp.S:1.2	Sun Feb  4 21:52:16 2018
+++ src/common/lib/libc/arch/aarch64/string/memcmp.S	Mon Jul  9 06:07:06 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: memcmp.S,v 1.2 2018/02/04 21:52:16 skrll Exp $ */
+/* $NetBSD: memcmp.S,v 1.3 2018/07/09 06:07:06 ryo Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 
 
-RCSID("$NetBSD: memcmp.S,v 1.2 2018/02/04 21:52:16 skrll Exp $")
+RCSID("$NetBSD: memcmp.S,v 1.3 2018/07/09 06:07:06 ryo Exp $")
 
 ENTRY(memcmp)
 	mov	x9, x0
@@ -55,17 +55,19 @@ ENTRY(memcmp)
 	sub	x2, x2, #8		/* now subtract a dword */
 
 	sub	x9, x9, x3		/* dword align src1 */
-	sub	x10, x10, x3		/* adjust src2 */
 
+	ldr	x6, [x10], #8		/* load dword from src2 */
+	sub	x10, x10, x3		/* src2 -= x3 */
 	lsl	x3, x3, #3		/* convert bytes to bits */
 	ldr	x4, [x9], #8		/* load dword from src1 */
-	ldr	x6, [x10], #8		/* load dword from src2 */
 #ifdef __AARCH64EB__
 	lsl	x4, x4, x3		/* discard leading bytes from data1 */
-	lsl	x6, x6, x3		/* discard leading bytes from data2 */
+	lsr	x6, x6, x3		/* discard leading bytes from data2 */
+	lsl	x6, x6, x3		/* get back bit position */
 #else
 	lsr	x4, x4, x3		/* discard leading bytes from data1 */
-	lsr	x6, x6, x3		/* discard leading bytes from data2 */
+	lsl	x6, x6, x3		/* discard leading bytes from data2 */
+	lsr	x6, x6, x3		/* get back bit position */
 #endif
 	subs	x0, x4, x6		/* compare data */
 	b.ne	.Lmemcmp_last_compare	/* difference.  find it */