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

2021-05-31 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon May 31 17:22:45 UTC 2021

Modified Files:
src/sys/arch/alpha/include: pmap.h

Log Message:
Additional comment about the range (0-1025) that's needed for the PT page
reference count, and thus now many bits we need to scare up.


To generate a diff of this commit:
cvs rdiff -u -r1.97 -r1.98 src/sys/arch/alpha/include/pmap.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/alpha/include/pmap.h
diff -u src/sys/arch/alpha/include/pmap.h:1.97 src/sys/arch/alpha/include/pmap.h:1.98
--- src/sys/arch/alpha/include/pmap.h:1.97	Mon May 31 17:16:05 2021
+++ src/sys/arch/alpha/include/pmap.h	Mon May 31 17:22:44 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.h,v 1.97 2021/05/31 17:16:05 thorpej Exp $ */
+/* $NetBSD: pmap.h,v 1.98 2021/05/31 17:22:44 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001, 2007 The NetBSD Foundation, Inc.
@@ -360,6 +360,10 @@ struct vm_page_md {
 	 * XXX These fields are only needed for pages that are used
 	 * as PT pages.  It would be nice to find safely-unused fields
 	 * in the vm_page structure that could be used instead.
+	 *
+	 * (Only 11 bits are needed ... we need to be able to count from
+	 * 0-1025 ... 1025 because sometimes we need to take an extra
+	 * reference temporarily in pmap_enter().)
 	 */
 	unsigned int pvh_physpgrefs;	/* # refs as a PT page */
 	unsigned int pvh_spare0;	/* XXX spare field */



CVS commit: src/sys/arch/alpha

2021-05-31 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon May 31 17:16:05 UTC 2021

Modified Files:
src/sys/arch/alpha/alpha: pmap.c
src/sys/arch/alpha/include: pmap.h

Log Message:
After a comment by joerg@, go back to using a dedicated field for the
PT page reference count, but add an XXX comment stating the desire to
find a safely-unused field in the vm_page structure when pages are in-
use as PT pages, so that we can save the 8 bytes per page needed for
this.


To generate a diff of this commit:
cvs rdiff -u -r1.292 -r1.293 src/sys/arch/alpha/alpha/pmap.c
cvs rdiff -u -r1.96 -r1.97 src/sys/arch/alpha/include/pmap.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/alpha/alpha/pmap.c
diff -u src/sys/arch/alpha/alpha/pmap.c:1.292 src/sys/arch/alpha/alpha/pmap.c:1.293
--- src/sys/arch/alpha/alpha/pmap.c:1.292	Sun May 30 19:50:23 2021
+++ src/sys/arch/alpha/alpha/pmap.c	Mon May 31 17:16:04 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.292 2021/05/30 19:50:23 thorpej Exp $ */
+/* $NetBSD: pmap.c,v 1.293 2021/05/31 17:16:04 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001, 2007, 2008, 2020
@@ -135,7 +135,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.292 2021/05/30 19:50:23 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.293 2021/05/31 17:16:04 thorpej Exp $");
 
 #include 
 #include 
@@ -507,8 +507,8 @@ pmap_pagelist_free(struct pmap_pagelist 
 
 	while ((pg = LIST_FIRST(list)) != NULL) {
 		LIST_REMOVE(pg, pageq.list);
-		/* Zap any fields we used internally. */
-		atomic_store_relaxed(>loan_count, 0);
+		/* Fix up ref count; it's not always 0 when we get here. */
+		PHYSPAGE_REFCNT_SET(pg, 0);
 		uvm_pagefree(pg);
 	}
 }
@@ -1893,7 +1893,7 @@ pmap_remove_all(pmap_t pmap)
 
 	/* Fix up the reference count on the lev1map page. */
 	pg = PHYS_TO_VM_PAGE(ALPHA_K0SEG_TO_PHYS((vaddr_t)lev1map));
-	atomic_store_relaxed(>loan_count, 0);
+	PHYSPAGE_REFCNT_SET(pg, 0);
 
 	/* Step 3 */
 	while ((pv = LIST_FIRST(>pm_pvents)) != NULL) {
@@ -3470,15 +3470,6 @@ pmap_pv_page_free(struct pool *pp, void 
 / misc. functions /
 
 /*
- * Pages that are in-use as page table pages should never be part
- * of a UVM loan, so we'll use that field for our PT page reference
- * count.
- */
-#define	PHYSPAGE_REFCNT(pg)	atomic_load_relaxed(&(pg)->loan_count)
-#define	PHYSPAGE_REFCNT_INC(pg)	atomic_inc_uint_nv(&(pg)->loan_count)
-#define	PHYSPAGE_REFCNT_DEC(pg)	atomic_dec_uint_nv(&(pg)->loan_count)
-
-/*
  * pmap_physpage_alloc:
  *
  *	Allocate a single page from the VM system and return the

Index: src/sys/arch/alpha/include/pmap.h
diff -u src/sys/arch/alpha/include/pmap.h:1.96 src/sys/arch/alpha/include/pmap.h:1.97
--- src/sys/arch/alpha/include/pmap.h:1.96	Sun May 30 19:41:59 2021
+++ src/sys/arch/alpha/include/pmap.h	Mon May 31 17:16:05 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.h,v 1.96 2021/05/30 19:41:59 thorpej Exp $ */
+/* $NetBSD: pmap.h,v 1.97 2021/05/31 17:16:05 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001, 2007 The NetBSD Foundation, Inc.
@@ -355,9 +355,26 @@ do {	\
  */
 #define	__HAVE_VM_PAGE_MD
 struct vm_page_md {
-	uintptr_t pvh_listx;			/* pv_entry list + attrs */
+	uintptr_t pvh_listx;		/* pv_entry list + attrs */
+	/*
+	 * XXX These fields are only needed for pages that are used
+	 * as PT pages.  It would be nice to find safely-unused fields
+	 * in the vm_page structure that could be used instead.
+	 */
+	unsigned int pvh_physpgrefs;	/* # refs as a PT page */
+	unsigned int pvh_spare0;	/* XXX spare field */
 };
 
+/* Reference counting for page table pages. */
+#define	PHYSPAGE_REFCNT(pg)		\
+	atomic_load_relaxed(&(pg)->mdpage.pvh_physpgrefs)
+#define	PHYSPAGE_REFCNT_SET(pg, v)	\
+	atomic_store_relaxed(&(pg)->mdpage.pvh_physpgrefs, (v))
+#define	PHYSPAGE_REFCNT_INC(pg)		\
+	atomic_inc_uint_nv(&(pg)->mdpage.pvh_physpgrefs)
+#define	PHYSPAGE_REFCNT_DEC(pg)		\
+	atomic_dec_uint_nv(&(pg)->mdpage.pvh_physpgrefs)
+
 #define	VM_MDPAGE_PVS(pg)		\
 	((struct pv_entry *)((pg)->mdpage.pvh_listx & ~3UL))
 



CVS commit: src/sys/arch

2021-05-31 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Mon May 31 14:38:57 UTC 2021

Modified Files:
src/sys/arch/aarch64/include: param.h
src/sys/arch/alpha/include: param.h
src/sys/arch/cats/include: param.h
src/sys/arch/hppa/include: param.h
src/sys/arch/i386/include: param.h
src/sys/arch/ia64/include: param.h
src/sys/arch/m68k/include: param.h
src/sys/arch/macppc/include: param.h
src/sys/arch/mips/include: mips_param.h
src/sys/arch/powerpc/include: param.h
src/sys/arch/powerpc/include/ibm4xx: cpu.h
src/sys/arch/riscv/include: param.h
src/sys/arch/sgimips/include: param.h
src/sys/arch/sh3/include: param.h
src/sys/arch/sparc64/include: param.h
src/sys/arch/sun2/include: param.h
src/sys/arch/sun3/include: param.h
src/sys/arch/vax/include: param.h
src/sys/arch/x68k/include: param.h

Log Message:
Include "opt_param.h" (ifdef _KERNEL_OPT) everywhere that MSGBUFSIZE is
referenced since some sources include .


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/aarch64/include/param.h
cvs rdiff -u -r1.47 -r1.48 src/sys/arch/alpha/include/param.h
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/cats/include/param.h
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/hppa/include/param.h
cvs rdiff -u -r1.87 -r1.88 src/sys/arch/i386/include/param.h
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/ia64/include/param.h
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/m68k/include/param.h
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/macppc/include/param.h
cvs rdiff -u -r1.50 -r1.51 src/sys/arch/mips/include/mips_param.h
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/powerpc/include/param.h
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/powerpc/include/ibm4xx/cpu.h
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/riscv/include/param.h
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/sgimips/include/param.h
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/sh3/include/param.h
cvs rdiff -u -r1.61 -r1.62 src/sys/arch/sparc64/include/param.h
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/sun2/include/param.h
cvs rdiff -u -r1.61 -r1.62 src/sys/arch/sun3/include/param.h
cvs rdiff -u -r1.63 -r1.64 src/sys/arch/vax/include/param.h
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/x68k/include/param.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/param.h
diff -u src/sys/arch/aarch64/include/param.h:1.15 src/sys/arch/aarch64/include/param.h:1.16
--- src/sys/arch/aarch64/include/param.h:1.15	Sun Jan 24 12:51:32 2021
+++ src/sys/arch/aarch64/include/param.h	Mon May 31 14:38:57 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: param.h,v 1.15 2021/01/24 12:51:32 jmcneill Exp $ */
+/* $NetBSD: param.h,v 1.16 2021/05/31 14:38:57 simonb Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -36,6 +36,7 @@
 
 #ifdef _KERNEL_OPT
 #include "opt_cputypes.h"
+#include "opt_param.h"
 #endif
 
 /*

Index: src/sys/arch/alpha/include/param.h
diff -u src/sys/arch/alpha/include/param.h:1.47 src/sys/arch/alpha/include/param.h:1.48
--- src/sys/arch/alpha/include/param.h:1.47	Sat Oct 10 21:59:03 2020
+++ src/sys/arch/alpha/include/param.h	Mon May 31 14:38:55 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: param.h,v 1.47 2020/10/10 21:59:03 thorpej Exp $ */
+/* $NetBSD: param.h,v 1.48 2021/05/31 14:38:55 simonb Exp $ */
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -38,6 +38,10 @@
  *	@(#)param.h	8.1 (Berkeley) 6/10/93
  */
 
+#ifdef _KERNEL_OPT
+#include "opt_param.h"
+#endif
+
 /*
  * Machine dependent constants for the Alpha.
  */

Index: src/sys/arch/cats/include/param.h
diff -u src/sys/arch/cats/include/param.h:1.8 src/sys/arch/cats/include/param.h:1.9
--- src/sys/arch/cats/include/param.h:1.8	Wed Dec  1 06:47:16 2010
+++ src/sys/arch/cats/include/param.h	Mon May 31 14:38:55 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.8 2010/12/01 06:47:16 skrll Exp $	*/
+/*	$NetBSD: param.h,v 1.9 2021/05/31 14:38:55 simonb Exp $	*/
 
 /*
  * Copyright (c) 1994,1995 Mark Brinicombe.
@@ -35,6 +35,10 @@
 #ifndef	_CATS_PARAM_H_
 #define	_CATS_PARAM_H_
 
+#ifdef _KERNEL_OPT
+#include "opt_param.h"
+#endif
+
 /*
  * Machine dependent constants for ARM6+ processors
  */

Index: src/sys/arch/hppa/include/param.h
diff -u src/sys/arch/hppa/include/param.h:1.28 src/sys/arch/hppa/include/param.h:1.29
--- src/sys/arch/hppa/include/param.h:1.28	Sat May  8 13:10:29 2021
+++ src/sys/arch/hppa/include/param.h	Mon May 31 14:38:55 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.28 2021/05/08 13:10:29 skrll Exp $	*/
+/*	$NetBSD: param.h,v 1.29 2021/05/31 14:38:55 simonb Exp $	*/
 
 /*	$OpenBSD: param.h,v 1.12 2001/07/06 02:07:41 provos Exp $	*/
 
@@ -27,6 +27,9 @@
 
 #ifdef _KERNEL
 #include 
+#ifdef _KERNEL_OPT
+#include "opt_param.h"
+#endif
 #endif
 
 /*

Index: src/sys/arch/i386/include/param.h
diff -u src/sys/arch/i386/include/param.h:1.87 src/sys/arch/i386/include/param.h:1.88
--- 

CVS commit: src/sys/arch/alpha/alpha

2021-05-30 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun May 30 19:50:23 UTC 2021

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

Log Message:
Fix DEBUG build.


To generate a diff of this commit:
cvs rdiff -u -r1.291 -r1.292 src/sys/arch/alpha/alpha/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/alpha/alpha/pmap.c
diff -u src/sys/arch/alpha/alpha/pmap.c:1.291 src/sys/arch/alpha/alpha/pmap.c:1.292
--- src/sys/arch/alpha/alpha/pmap.c:1.291	Sun May 30 19:46:21 2021
+++ src/sys/arch/alpha/alpha/pmap.c	Sun May 30 19:50:23 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.291 2021/05/30 19:46:21 thorpej Exp $ */
+/* $NetBSD: pmap.c,v 1.292 2021/05/30 19:50:23 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001, 2007, 2008, 2020
@@ -135,7 +135,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.291 2021/05/30 19:46:21 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.292 2021/05/30 19:50:23 thorpej Exp $");
 
 #include 
 #include 
@@ -1933,9 +1933,6 @@ pmap_page_protect(struct vm_page *pg, vm
 	struct pmap_tlb_context tlbctx;
 
 #ifdef DEBUG
-	paddr_t pa = VM_PAGE_TO_PHYS(pg);
-
-
 	if ((pmapdebug & (PDB_FOLLOW|PDB_PROTECT)) ||
 	(prot == VM_PROT_NONE && (pmapdebug & PDB_REMOVE)))
 		printf("pmap_page_protect(%p, %x)\n", pg, prot);
@@ -2576,7 +2573,7 @@ pmap_extract(pmap_t pmap, vaddr_t va, pa
 		if (__predict_true(vtophys_internal(va, pap))) {
 #ifdef DEBUG
 			if (pmapdebug & PDB_FOLLOW)
-printf("0x%lx (kernel vtophys)\n", pa);
+printf("0x%lx (kernel vtophys)\n", *pap);
 #endif
 			return true;
 		}
@@ -3278,7 +3275,7 @@ pmap_pv_dump(paddr_t pa)
 	lock = pmap_pvh_lock(pg);
 	mutex_enter(lock);
 
-	printf("pa 0x%lx (attrs = 0x%x):\n", pa, md->pvh_listx & PGA_ATTRS);
+	printf("pa 0x%lx (attrs = 0x%lx):\n", pa, md->pvh_listx & PGA_ATTRS);
 	for (pv = VM_MDPAGE_PVS(pg); pv != NULL; pv = pv->pv_next)
 		printf(" pmap %p, va 0x%lx\n",
 		pv->pv_pmap, pv->pv_va);
@@ -4004,7 +4001,7 @@ pmap_asn_alloc(pmap_t const pmap, struct
 #ifdef DEBUG
 		if (pmapdebug & PDB_ASN)
 			printf("pmap_asn_alloc: generation bumped to %lu\n",
-			ci->ci_asn_ge);
+			ci->ci_asn_gen);
 #endif
 	}
 



CVS commit: src/sys/arch/alpha/alpha

2021-05-30 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun May 30 19:46:21 UTC 2021

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

Log Message:
Fix unused variable warning when DIAGNOSTIC is disabled.  Pointed out
by jklos.


To generate a diff of this commit:
cvs rdiff -u -r1.290 -r1.291 src/sys/arch/alpha/alpha/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/alpha/alpha/pmap.c
diff -u src/sys/arch/alpha/alpha/pmap.c:1.290 src/sys/arch/alpha/alpha/pmap.c:1.291
--- src/sys/arch/alpha/alpha/pmap.c:1.290	Sun May 30 19:41:59 2021
+++ src/sys/arch/alpha/alpha/pmap.c	Sun May 30 19:46:21 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.290 2021/05/30 19:41:59 thorpej Exp $ */
+/* $NetBSD: pmap.c,v 1.291 2021/05/30 19:46:21 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001, 2007, 2008, 2020
@@ -135,7 +135,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.290 2021/05/30 19:41:59 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.291 2021/05/30 19:46:21 thorpej Exp $");
 
 #include 
 #include 
@@ -1657,7 +1657,6 @@ pmap_destroy(pmap_t pmap)
 		return;
 
 	pt_entry_t *lev1map = pmap_lev1map(pmap);
-	int i;
 
 	rw_enter(_growkernel_lock, RW_READER);
 
@@ -1670,6 +1669,7 @@ pmap_destroy(pmap_t pmap)
 
 	pool_cache_put(_l1pt_cache, lev1map);
 #ifdef DIAGNOSTIC
+	int i;
 	for (i = 0; i < pmap_ncpuids; i++) {
 		pmap->pm_percpu[i].pmc_lev1map = (pt_entry_t *)0xdeadbeefUL;
 	}



CVS commit: src/sys/arch/alpha

2021-05-30 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun May 30 19:41:59 UTC 2021

Modified Files:
src/sys/arch/alpha/alpha: pmap.c
src/sys/arch/alpha/include: pmap.h

Log Message:
Implement pmap_remove_all().


To generate a diff of this commit:
cvs rdiff -u -r1.289 -r1.290 src/sys/arch/alpha/alpha/pmap.c
cvs rdiff -u -r1.95 -r1.96 src/sys/arch/alpha/include/pmap.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/alpha/alpha/pmap.c
diff -u src/sys/arch/alpha/alpha/pmap.c:1.289 src/sys/arch/alpha/alpha/pmap.c:1.290
--- src/sys/arch/alpha/alpha/pmap.c:1.289	Sun May 30 14:06:37 2021
+++ src/sys/arch/alpha/alpha/pmap.c	Sun May 30 19:41:59 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.289 2021/05/30 14:06:37 thorpej Exp $ */
+/* $NetBSD: pmap.c,v 1.290 2021/05/30 19:41:59 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001, 2007, 2008, 2020
@@ -135,7 +135,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.289 2021/05/30 14:06:37 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.290 2021/05/30 19:41:59 thorpej Exp $");
 
 #include 
 #include 
@@ -507,6 +507,8 @@ pmap_pagelist_free(struct pmap_pagelist 
 
 	while ((pg = LIST_FIRST(list)) != NULL) {
 		LIST_REMOVE(pg, pageq.list);
+		/* Zap any fields we used internally. */
+		atomic_store_relaxed(>loan_count, 0);
 		uvm_pagefree(pg);
 	}
 }
@@ -663,6 +665,7 @@ TLB_COUNT_DECL(shootnow_remote);
 
 TLB_COUNT_DECL(reason_remove_kernel);
 TLB_COUNT_DECL(reason_remove_user);
+TLB_COUNT_DECL(reason_remove_all_user);
 TLB_COUNT_DECL(reason_page_protect_read);
 TLB_COUNT_DECL(reason_page_protect_none);
 TLB_COUNT_DECL(reason_protect);
@@ -729,6 +732,7 @@ pmap_tlb_init(void)
 
 	TLB_COUNT_ATTACH(reason_remove_kernel);
 	TLB_COUNT_ATTACH(reason_remove_user);
+	TLB_COUNT_ATTACH(reason_remove_all_user);
 	TLB_COUNT_ATTACH(reason_page_protect_read);
 	TLB_COUNT_ATTACH(reason_page_protect_none);
 	TLB_COUNT_ATTACH(reason_protect);
@@ -1844,6 +1848,77 @@ pmap_remove(pmap_t pmap, vaddr_t sva, va
 }
 
 /*
+ * pmap_remove_all:		[ INTERFACE ]
+ *
+ *	Remove all mappings from a pmap in bulk.  This is only called
+ *	when it's known that the address space is no longer visible to
+ *	any user process (e.g. during exit or exec).
+ */
+bool
+pmap_remove_all(pmap_t pmap)
+{
+	struct pmap_tlb_context tlbctx;
+	struct vm_page *pg;
+	pv_entry_t pv;
+
+	KASSERT(pmap != pmap_kernel());
+
+	/*
+	 * This process is pretty simple:
+	 *
+	 * ==> (1) Zero out the user-space portion of the lev1map.
+	 *
+	 * ==> (2) Copy the PT page list to the tlbctx and re-init.
+	 *
+	 * ==> (3) Walk the PV entry list and remove each entry.
+	 *
+	 * ==> (4) Zero the wired and resident count.
+	 *
+	 * Once we've done that, we just need to free everything
+	 * back to the system.
+	 */
+
+	pmap_tlb_context_init(, 0);
+
+	PMAP_MAP_TO_HEAD_LOCK();
+	PMAP_LOCK(pmap);
+
+	/* Step 1 */
+	pt_entry_t * const lev1map = pmap_lev1map(pmap);
+	memset(lev1map, 0,
+	   l1pte_index(VM_MAXUSER_ADDRESS) * sizeof(pt_entry_t));
+
+	/* Step 2 */
+	LIST_MOVE(>pm_ptpages, _freeptq, pageq.list);
+
+	/* Fix up the reference count on the lev1map page. */
+	pg = PHYS_TO_VM_PAGE(ALPHA_K0SEG_TO_PHYS((vaddr_t)lev1map));
+	atomic_store_relaxed(>loan_count, 0);
+
+	/* Step 3 */
+	while ((pv = LIST_FIRST(>pm_pvents)) != NULL) {
+		KASSERT(pv->pv_pmap == pmap);
+		pmap_pv_remove(pmap, PHYS_TO_VM_PAGE(pmap_pte_pa(pv->pv_pte)),
+		pv->pv_va, true, NULL, );
+	}
+
+	/* Step 4 */
+	atomic_store_relaxed(>pm_stats.wired_count, 0);
+	atomic_store_relaxed(>pm_stats.resident_count, 0);
+
+	pmap_tlb_shootdown_all_user(pmap, PG_EXEC, );
+
+	PMAP_UNLOCK(pmap);
+	PMAP_MAP_TO_HEAD_UNLOCK();
+
+	pmap_tlb_shootnow();
+	pmap_tlb_context_drain();
+	TLB_COUNT(reason_remove_all_user);
+
+	return true;
+}
+
+/*
  * pmap_page_protect:		[ INTERFACE ]
  *
  *	Lower the permission for all mappings to a given page to

Index: src/sys/arch/alpha/include/pmap.h
diff -u src/sys/arch/alpha/include/pmap.h:1.95 src/sys/arch/alpha/include/pmap.h:1.96
--- src/sys/arch/alpha/include/pmap.h:1.95	Sun May 30 14:06:37 2021
+++ src/sys/arch/alpha/include/pmap.h	Sun May 30 19:41:59 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.h,v 1.95 2021/05/30 14:06:37 thorpej Exp $ */
+/* $NetBSD: pmap.h,v 1.96 2021/05/30 19:41:59 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001, 2007 The NetBSD Foundation, Inc.
@@ -209,13 +209,6 @@ void	pmap_tlb_shootdown_ipi(struct cpu_i
 #define	pmap_copy(dp, sp, da, l, sa)	/* nothing */
 #define	pmap_update(pmap)		/* nothing (yet) */
 
-static __inline bool
-pmap_remove_all(struct pmap *pmap)
-{
-	/* Nothing. */
-	return false;
-}
-
 #define	pmap_is_referenced(pg)		\
 	(((pg)->mdpage.pvh_listx & PGA_REFERENCED) != 0)
 #define	pmap_is_modified(pg)		\



CVS commit: src/sys/arch/alpha

2021-05-30 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun May 30 14:06:37 UTC 2021

Modified Files:
src/sys/arch/alpha/alpha: pmap.c
src/sys/arch/alpha/include: pmap.h

Log Message:
When removing mappings, hang PV entries to be freed off of the
pmap_tlb_context structure, and free them back in bulk after we
release all of our locks (as we do with PT pages that are freed).


To generate a diff of this commit:
cvs rdiff -u -r1.288 -r1.289 src/sys/arch/alpha/alpha/pmap.c
cvs rdiff -u -r1.94 -r1.95 src/sys/arch/alpha/include/pmap.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/alpha/alpha/pmap.c
diff -u src/sys/arch/alpha/alpha/pmap.c:1.288 src/sys/arch/alpha/alpha/pmap.c:1.289
--- src/sys/arch/alpha/alpha/pmap.c:1.288	Sun May 30 13:34:21 2021
+++ src/sys/arch/alpha/alpha/pmap.c	Sun May 30 14:06:37 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.288 2021/05/30 13:34:21 thorpej Exp $ */
+/* $NetBSD: pmap.c,v 1.289 2021/05/30 14:06:37 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001, 2007, 2008, 2020
@@ -135,7 +135,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.288 2021/05/30 13:34:21 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.289 2021/05/30 14:06:37 thorpej Exp $");
 
 #include 
 #include 
@@ -432,6 +432,71 @@ pmap_activation_lock(pmap_t const pmap)
 #endif /* MULTIPROCESSOR */
 
 /*
+ * TLB context structure; see description in "TLB management" section
+ * below.
+ */
+#define	TLB_CTX_MAXVA		8
+#define	TLB_CTX_ALLVA		PAGE_MASK
+struct pmap_tlb_context {
+	uintptr_t		t_addrdata[TLB_CTX_MAXVA];
+	pmap_t			t_pmap;
+	struct pmap_pagelist	t_freeptq;
+	struct pmap_pvlist	t_freepvq;
+};
+
+/*
+ * Internal routines
+ */
+static void	alpha_protection_init(void);
+static pt_entry_t pmap_remove_mapping(pmap_t, vaddr_t, pt_entry_t *, bool,
+  pv_entry_t *,
+  struct pmap_tlb_context *);
+static void	pmap_changebit(struct vm_page *, pt_entry_t, pt_entry_t,
+			   struct pmap_tlb_context *);
+
+/*
+ * PT page management functions.
+ */
+static int	pmap_ptpage_alloc(pmap_t, pt_entry_t *, int);
+static void	pmap_ptpage_free(pmap_t, pt_entry_t *,
+ struct pmap_tlb_context *);
+static void	pmap_l3pt_delref(pmap_t, vaddr_t, pt_entry_t *,
+		 struct pmap_tlb_context *);
+static void	pmap_l2pt_delref(pmap_t, pt_entry_t *, pt_entry_t *,
+		 struct pmap_tlb_context *);
+static void	pmap_l1pt_delref(pmap_t, pt_entry_t *);
+
+static void	*pmap_l1pt_alloc(struct pool *, int);
+static void	pmap_l1pt_free(struct pool *, void *);
+
+static struct pool_allocator pmap_l1pt_allocator = {
+	pmap_l1pt_alloc, pmap_l1pt_free, 0,
+};
+
+static int	pmap_l1pt_ctor(void *, void *, int);
+
+/*
+ * PV table management functions.
+ */
+static int	pmap_pv_enter(pmap_t, struct vm_page *, vaddr_t, pt_entry_t *,
+			  bool, pv_entry_t);
+static void	pmap_pv_remove(pmap_t, struct vm_page *, vaddr_t, bool,
+			   pv_entry_t *, struct pmap_tlb_context *);
+static void	*pmap_pv_page_alloc(struct pool *, int);
+static void	pmap_pv_page_free(struct pool *, void *);
+
+static struct pool_allocator pmap_pv_page_allocator = {
+	pmap_pv_page_alloc, pmap_pv_page_free, 0,
+};
+
+#ifdef DEBUG
+void	pmap_pv_dump(paddr_t);
+#endif
+
+#define	pmap_pv_alloc()		pool_cache_get(_pv_cache, PR_NOWAIT)
+#define	pmap_pv_free(pv)	pool_cache_put(_pv_cache, (pv))
+
+/*
  * Generic routine for freeing pages on a pmap_pagelist back to
  * the system.
  */
@@ -447,6 +512,21 @@ pmap_pagelist_free(struct pmap_pagelist 
 }
 
 /*
+ * Generic routine for freeing a list of PV entries back to the
+ * system.
+ */
+static void
+pmap_pvlist_free(struct pmap_pvlist * const list)
+{
+	pv_entry_t pv;
+
+	while ((pv = LIST_FIRST(list)) != NULL) {
+		LIST_REMOVE(pv, pv_link);
+		pmap_pv_free(pv);
+	}
+}
+
+/*
  * TLB management.
  *
  * TLB invalidations need to be performed on local and remote CPUs
@@ -518,9 +598,6 @@ pmap_pagelist_free(struct pmap_pagelist 
  * window size (defined as 64KB on alpha in ).
  */
 
-#define	TLB_CTX_MAXVA		8
-#define	TLB_CTX_ALLVA		PAGE_MASK
-
 #define	TLB_CTX_F_ASM		__BIT(0)
 #define	TLB_CTX_F_IMB		__BIT(1)
 #define	TLB_CTX_F_KIMB		__BIT(2)
@@ -538,12 +615,6 @@ pmap_pagelist_free(struct pmap_pagelist 
 #define	TLB_CTX_SETVA(ctx, i, va)	\
 	(ctx)->t_addrdata[(i)] = (va) | ((ctx)->t_addrdata[(i)] & PAGE_MASK)
 
-struct pmap_tlb_context {
-	uintptr_t	t_addrdata[TLB_CTX_MAXVA];
-	pmap_t		t_pmap;
-	struct pmap_pagelist t_freeptq;
-};
-
 static struct {
 	kmutex_t	lock;
 	struct evcnt	events;
@@ -689,6 +760,7 @@ pmap_tlb_context_init(struct pmap_tlb_co
 	tlbctx->t_addrdata[1] = flags;
 	tlbctx->t_pmap = NULL;
 	LIST_INIT(>t_freeptq);
+	LIST_INIT(>t_freepvq);
 }
 
 static void
@@ -1081,65 +1153,18 @@ pmap_tlb_shootdown_ipi(struct cpu_info *
 }
 #endif /* MULTIPROCESSOR */
 
-static __inline void
-pmap_tlb_ptpage_drain(struct 

CVS commit: src/sys/arch/alpha

2021-05-30 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun May 30 13:34:21 UTC 2021

Modified Files:
src/sys/arch/alpha/alpha: pmap.c
src/sys/arch/alpha/include: pmap.h

Log Message:
Keep track of a pmap's PV entries with a list hanging off the pmap.


To generate a diff of this commit:
cvs rdiff -u -r1.287 -r1.288 src/sys/arch/alpha/alpha/pmap.c
cvs rdiff -u -r1.93 -r1.94 src/sys/arch/alpha/include/pmap.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/alpha/alpha/pmap.c
diff -u src/sys/arch/alpha/alpha/pmap.c:1.287 src/sys/arch/alpha/alpha/pmap.c:1.288
--- src/sys/arch/alpha/alpha/pmap.c:1.287	Sun May 30 06:41:19 2021
+++ src/sys/arch/alpha/alpha/pmap.c	Sun May 30 13:34:21 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.287 2021/05/30 06:41:19 thorpej Exp $ */
+/* $NetBSD: pmap.c,v 1.288 2021/05/30 13:34:21 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001, 2007, 2008, 2020
@@ -135,7 +135,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.287 2021/05/30 06:41:19 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.288 2021/05/30 13:34:21 thorpej Exp $");
 
 #include 
 #include 
@@ -1384,6 +1384,7 @@ pmap_bootstrap(paddr_t ptaddr, u_int max
 	 */
 	memset(pmap_kernel(), 0, sizeof(struct pmap));
 	LIST_INIT(_kernel()->pm_ptpages);
+	LIST_INIT(_kernel()->pm_pvents);
 	atomic_store_relaxed(_kernel()->pm_count, 1);
 	/* Kernel pmap does not have per-CPU info. */
 	TAILQ_INSERT_TAIL(_all_pmaps, pmap_kernel(), pm_list);
@@ -1568,6 +1569,7 @@ pmap_create(void)
 	pmap = pool_cache_get(_pmap_cache, PR_WAITOK);
 	memset(pmap, 0, sizeof(*pmap));
 	LIST_INIT(>pm_ptpages);
+	LIST_INIT(>pm_pvents);
 
 	atomic_store_relaxed(>pm_count, 1);
 
@@ -3278,6 +3280,7 @@ pmap_pv_enter(pmap_t pmap, struct vm_pag
 	uintptr_t const attrs = md->pvh_listx & PGA_ATTRS;
 	newpv->pv_next = (struct pv_entry *)(md->pvh_listx & ~PGA_ATTRS);
 	md->pvh_listx = (uintptr_t)newpv | attrs;
+	LIST_INSERT_HEAD(>pm_pvents, newpv, pv_link);
 
 	if (dolock) {
 		mutex_exit(lock);
@@ -3316,8 +3319,15 @@ pmap_pv_remove(pmap_t pmap, struct vm_pa
 
 	KASSERT(pv != NULL);
 
+	/*
+	 * The page attributes are in the lower 2 bits of the first
+	 * PV entry pointer.  Rather than comparing the pointer address
+	 * and branching, we just always preserve what might be there
+	 * (either attribute bits or zero bits).
+	 */
 	*pvp = (pv_entry_t)((uintptr_t)pv->pv_next |
 			(((uintptr_t)*pvp) & PGA_ATTRS));
+	LIST_REMOVE(pv, pv_link);
 
 	if (dolock) {
 		mutex_exit(lock);

Index: src/sys/arch/alpha/include/pmap.h
diff -u src/sys/arch/alpha/include/pmap.h:1.93 src/sys/arch/alpha/include/pmap.h:1.94
--- src/sys/arch/alpha/include/pmap.h:1.93	Sun May 30 06:41:19 2021
+++ src/sys/arch/alpha/include/pmap.h	Sun May 30 13:34:21 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.h,v 1.93 2021/05/30 06:41:19 thorpej Exp $ */
+/* $NetBSD: pmap.h,v 1.94 2021/05/30 13:34:21 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001, 2007 The NetBSD Foundation, Inc.
@@ -151,7 +151,7 @@ struct pmap {	/* pmaps are aligned to CO
 	unsigned int		pm_count;	/* [24] reference count */
 	unsigned int		__pm_spare0;	/* [28] spare field */
 	struct pmap_pagelist	pm_ptpages;	/* [32] list of PT pages */
-	unsigned long		__pm_spare1;	/* [40] spare field */
+	LIST_HEAD(, pv_entry)	pm_pvents;	/* [40] list of PV entries */
 	TAILQ_ENTRY(pmap)	pm_list;	/* [48] list of all pmaps */
 	/* -- COHERENCY_UNIT boundary -- */
 	struct pmap_percpu	pm_percpu[];	/* [64] per-CPU data */
@@ -171,7 +171,8 @@ struct pmap {	/* pmaps are aligned to CO
  * mappings of that page.  An entry is a pv_entry_t, the list is pv_table.
  */
 typedef struct pv_entry {
-	struct pv_entry	*pv_next;	/* next pv_entry on list */
+	struct pv_entry	*pv_next;	/* next pv_entry on page list */
+	LIST_ENTRY(pv_entry) pv_link;	/* link on owning pmap's list */
 	struct pmap	*pv_pmap;	/* pmap where mapping lies */
 	vaddr_t		pv_va;		/* virtual address for mapping */
 	pt_entry_t	*pv_pte;	/* PTE that maps the VA */



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

2021-05-30 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sun May 30 07:20:00 UTC 2021

Modified Files:
src/sys/arch/arm/include/arm32: param.h

Log Message:
Include opt_param.h for MSGBUFSIZE ifdef _KERNEL_OPT.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/arm/include/arm32/param.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/include/arm32/param.h
diff -u src/sys/arch/arm/include/arm32/param.h:1.33 src/sys/arch/arm/include/arm32/param.h:1.34
--- src/sys/arch/arm/include/arm32/param.h:1.33	Fri Jul 10 12:25:09 2020
+++ src/sys/arch/arm/include/arm32/param.h	Sun May 30 07:20:00 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.33 2020/07/10 12:25:09 skrll Exp $	*/
+/*	$NetBSD: param.h,v 1.34 2021/05/30 07:20:00 rin Exp $	*/
 
 /*
  * Copyright (c) 1994,1995 Mark Brinicombe.
@@ -38,6 +38,7 @@
 #ifdef _KERNEL_OPT
 #include "opt_arm32_pmap.h"
 #include "opt_kasan.h"
+#include "opt_param.h"
 #endif
 
 /*



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

2021-05-30 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sun May 30 06:53:15 UTC 2021

Modified Files:
src/sys/arch/arm/arm32: cpuswitch.S

Log Message:
typo in comment


To generate a diff of this commit:
cvs rdiff -u -r1.104 -r1.105 src/sys/arch/arm/arm32/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/arm/arm32/cpuswitch.S
diff -u src/sys/arch/arm/arm32/cpuswitch.S:1.104 src/sys/arch/arm/arm32/cpuswitch.S:1.105
--- src/sys/arch/arm/arm32/cpuswitch.S:1.104	Sat Nov 21 19:44:52 2020
+++ src/sys/arch/arm/arm32/cpuswitch.S	Sun May 30 06:53:15 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpuswitch.S,v 1.104 2020/11/21 19:44:52 skrll Exp $	*/
+/*	$NetBSD: cpuswitch.S,v 1.105 2021/05/30 06:53:15 dholland Exp $	*/
 
 /*
  * Copyright 2003 Wasabi Systems, Inc.
@@ -87,7 +87,7 @@
 #include 
 #include 
 
-	RCSID("$NetBSD: cpuswitch.S,v 1.104 2020/11/21 19:44:52 skrll Exp $")
+	RCSID("$NetBSD: cpuswitch.S,v 1.105 2021/05/30 06:53:15 dholland Exp $")
 
 /* LINTSTUB: include  */
 
@@ -136,7 +136,7 @@ ENTRY(cpu_switchto)
 	mov	ip, sp
 	push	{r4-r7, ip, lr}
 
-	/* move lwps into caller saved registers */
+	/* move lwps into callee saved registers */
 	mov	r6, r1
 	mov	r4, r0
 



CVS commit: src/sys/arch/alpha

2021-05-30 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun May 30 06:41:19 UTC 2021

Modified Files:
src/sys/arch/alpha/alpha: pmap.c
src/sys/arch/alpha/include: pmap.h

Log Message:
Store the modified / referenced attribute bits in the lower 2 bits of
the PV entry list pointer in struct vm_page_md.  This reduces the size
of that structure from 16 bytes to 8, and will go a fair way to making
up for increasing the size of struct pv_entry in a future commit.


To generate a diff of this commit:
cvs rdiff -u -r1.286 -r1.287 src/sys/arch/alpha/alpha/pmap.c
cvs rdiff -u -r1.92 -r1.93 src/sys/arch/alpha/include/pmap.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/alpha/alpha/pmap.c
diff -u src/sys/arch/alpha/alpha/pmap.c:1.286 src/sys/arch/alpha/alpha/pmap.c:1.287
--- src/sys/arch/alpha/alpha/pmap.c:1.286	Sun May 30 05:26:09 2021
+++ src/sys/arch/alpha/alpha/pmap.c	Sun May 30 06:41:19 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.286 2021/05/30 05:26:09 thorpej Exp $ */
+/* $NetBSD: pmap.c,v 1.287 2021/05/30 06:41:19 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001, 2007, 2008, 2020
@@ -135,7 +135,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.286 2021/05/30 05:26:09 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.287 2021/05/30 06:41:19 thorpej Exp $");
 
 #include 
 #include 
@@ -2233,17 +2233,18 @@ pmap_enter(pmap_t pmap, vaddr_t va, padd
 	npte = ((pa >> PGSHIFT) << PG_SHIFT) | pte_prot(pmap, prot) | PG_V;
 	if (pg != NULL) {
 		struct vm_page_md * const md = VM_PAGE_TO_MD(pg);
-		int attrs;
+		uintptr_t attrs = 0;
 
 		KASSERT(((flags & VM_PROT_ALL) & ~prot) == 0);
 
-		lock = pmap_pvh_lock(pg);
-		mutex_enter(lock);
 		if (flags & VM_PROT_WRITE)
-			md->pvh_attrs |= (PGA_REFERENCED|PGA_MODIFIED);
+			attrs |= (PGA_REFERENCED|PGA_MODIFIED);
 		else if (flags & VM_PROT_ALL)
-			md->pvh_attrs |= PGA_REFERENCED;
-		attrs = md->pvh_attrs;
+			attrs |= PGA_REFERENCED;
+
+		lock = pmap_pvh_lock(pg);
+		mutex_enter(lock);
+		md->pvh_listx |= attrs;
 		mutex_exit(lock);
 
 		/* Set up referenced/modified emulation for new mapping. */
@@ -2779,10 +2780,10 @@ pmap_clear_modify(struct vm_page *pg)
 	lock = pmap_pvh_lock(pg);
 	mutex_enter(lock);
 
-	if (md->pvh_attrs & PGA_MODIFIED) {
+	if (md->pvh_listx & PGA_MODIFIED) {
 		rv = true;
 		pmap_changebit(pg, PG_FOW, ~0UL, );
-		md->pvh_attrs &= ~PGA_MODIFIED;
+		md->pvh_listx &= ~PGA_MODIFIED;
 	}
 
 	mutex_exit(lock);
@@ -2818,10 +2819,10 @@ pmap_clear_reference(struct vm_page *pg)
 	lock = pmap_pvh_lock(pg);
 	mutex_enter(lock);
 
-	if (md->pvh_attrs & PGA_REFERENCED) {
+	if (md->pvh_listx & PGA_REFERENCED) {
 		rv = true;
 		pmap_changebit(pg, PG_FOR | PG_FOW | PG_FOE, ~0UL, );
-		md->pvh_attrs &= ~PGA_REFERENCED;
+		md->pvh_listx &= ~PGA_REFERENCED;
 	}
 
 	mutex_exit(lock);
@@ -3133,10 +3134,10 @@ pmap_emulate_reference(struct lwp *l, va
 	mutex_enter(lock);
 
 	if (type == ALPHA_MMCSR_FOW) {
-		md->pvh_attrs |= (PGA_REFERENCED|PGA_MODIFIED);
+		md->pvh_listx |= (PGA_REFERENCED|PGA_MODIFIED);
 		faultoff = PG_FOR | PG_FOW;
 	} else {
-		md->pvh_attrs |= PGA_REFERENCED;
+		md->pvh_listx |= PGA_REFERENCED;
 		faultoff = PG_FOR;
 		if (exec) {
 			faultoff |= PG_FOE;
@@ -3173,7 +3174,7 @@ pmap_pv_dump(paddr_t pa)
 	lock = pmap_pvh_lock(pg);
 	mutex_enter(lock);
 
-	printf("pa 0x%lx (attrs = 0x%x):\n", pa, md->pvh_attrs);
+	printf("pa 0x%lx (attrs = 0x%x):\n", pa, md->pvh_listx & PGA_ATTRS);
 	for (pv = VM_MDPAGE_PVS(pg); pv != NULL; pv = pv->pv_next)
 		printf(" pmap %p, va 0x%lx\n",
 		pv->pv_pmap, pv->pv_va);
@@ -3274,8 +3275,9 @@ pmap_pv_enter(pmap_t pmap, struct vm_pag
 	/*
 	 * ...and put it in the list.
 	 */
-	newpv->pv_next = md->pvh_list;
-	md->pvh_list = newpv;
+	uintptr_t const attrs = md->pvh_listx & PGA_ATTRS;
+	newpv->pv_next = (struct pv_entry *)(md->pvh_listx & ~PGA_ATTRS);
+	md->pvh_listx = (uintptr_t)newpv | attrs;
 
 	if (dolock) {
 		mutex_exit(lock);
@@ -3307,14 +3309,15 @@ pmap_pv_remove(pmap_t pmap, struct vm_pa
 	/*
 	 * Find the entry to remove.
 	 */
-	for (pvp = >pvh_list, pv = *pvp;
+	for (pvp = (struct pv_entry **)>pvh_listx, pv = VM_MDPAGE_PVS(pg);
 	 pv != NULL; pvp = >pv_next, pv = *pvp)
 		if (pmap == pv->pv_pmap && va == pv->pv_va)
 			break;
 
 	KASSERT(pv != NULL);
 
-	*pvp = pv->pv_next;
+	*pvp = (pv_entry_t)((uintptr_t)pv->pv_next |
+			(((uintptr_t)*pvp) & PGA_ATTRS));
 
 	if (dolock) {
 		mutex_exit(lock);

Index: src/sys/arch/alpha/include/pmap.h
diff -u src/sys/arch/alpha/include/pmap.h:1.92 src/sys/arch/alpha/include/pmap.h:1.93
--- src/sys/arch/alpha/include/pmap.h:1.92	Sun May 30 05:26:09 2021
+++ src/sys/arch/alpha/include/pmap.h	Sun May 30 06:41:19 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.h,v 1.92 2021/05/30 05:26:09 thorpej Exp $ */
+/* $NetBSD: pmap.h,v 1.93 2021/05/30 06:41:19 thorpej Exp $ */
 
 /*-
  * 

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

2021-05-29 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sun May 30 05:40:57 UTC 2021

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

Log Message:
Fix conversion between aarch64 and aarch32 fpreg's; in aarch32 mode,
d0-d31 are packed into v0-v15 (== q0-q15).

This fixes crashes in VFP-optimized codes running on COMPAT_NETBSD32.

OK ryo


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/aarch64/aarch64/netbsd32_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/netbsd32_machdep.c
diff -u src/sys/arch/aarch64/aarch64/netbsd32_machdep.c:1.17 src/sys/arch/aarch64/aarch64/netbsd32_machdep.c:1.18
--- src/sys/arch/aarch64/aarch64/netbsd32_machdep.c:1.17	Fri Dec 11 18:03:33 2020
+++ src/sys/arch/aarch64/aarch64/netbsd32_machdep.c	Sun May 30 05:40:56 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_machdep.c,v 1.17 2020/12/11 18:03:33 skrll Exp $	*/
+/*	$NetBSD: netbsd32_machdep.c,v 1.18 2021/05/30 05:40:56 rin Exp $	*/
 
 /*
  * Copyright (c) 2018 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.17 2020/12/11 18:03:33 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.18 2021/05/30 05:40:56 rin Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -158,7 +158,7 @@ netbsd32_process_read_fpregs(struct lwp 
 {
 	struct proc * const p = l->l_proc;
 	struct pcb * const pcb = lwp_getpcb(l);
-	int i;
+	int i, j;
 
 	if ((p->p_flag & PK_32) == 0)
 		return EINVAL;
@@ -180,11 +180,17 @@ netbsd32_process_read_fpregs(struct lwp 
 	fpregs->fpr_vfp.vfp_fpinst = 0;
 	fpregs->fpr_vfp.vfp_fpinst2 = 0;
 
-	for (i = 0; i < 32; i++) {
+	for (i = j = 0; i < 16; i++) {
 #ifdef __AARCH64EB__
-		fpregs->fpr_vfp.vfp_regs[i] = pcb->pcb_fpregs.fp_reg[i].u64[1];
+		fpregs->fpr_vfp.vfp_regs[j++] =
+		pcb->pcb_fpregs.fp_reg[i].u64[1];
+		fpregs->fpr_vfp.vfp_regs[j++] =
+		pcb->pcb_fpregs.fp_reg[i].u64[0];
 #else
-		fpregs->fpr_vfp.vfp_regs[i] = pcb->pcb_fpregs.fp_reg[i].u64[0];
+		fpregs->fpr_vfp.vfp_regs[j++] =
+		pcb->pcb_fpregs.fp_reg[i].u64[0];
+		fpregs->fpr_vfp.vfp_regs[j++] =
+		pcb->pcb_fpregs.fp_reg[i].u64[1];
 #endif
 	}
 
@@ -226,7 +232,7 @@ netbsd32_process_write_fpregs(struct lwp
 {
 	struct proc * const p = l->l_proc;
 	struct pcb * const pcb = lwp_getpcb(l);
-	int i;
+	int i, j;
 
 	if ((p->p_flag & PK_32) == 0)
 		return EINVAL;
@@ -237,17 +243,18 @@ netbsd32_process_write_fpregs(struct lwp
 	pcb->pcb_fpregs.fpsr = fpregs->fpr_vfp.vfp_fpscr & FPSR_BITS;
 	pcb->pcb_fpregs.fpcr = fpregs->fpr_vfp.vfp_fpscr & FPCR_BITS;
 
-	CTASSERT(__arraycount(fpregs->fpr_vfp.vfp_regs) ==
-	__arraycount(pcb->pcb_fpregs.fp_reg) + 1);
-	for (i = 0; i < __arraycount(pcb->pcb_fpregs.fp_reg); i++) {
+	for (i = j = 0; i < 16; i++) {
 #ifdef __AARCH64EB__
-		pcb->pcb_fpregs.fp_reg[i].u64[0] = 0;
 		pcb->pcb_fpregs.fp_reg[i].u64[1] =
+		fpregs->fpr_vfp.vfp_regs[j++];
+		pcb->pcb_fpregs.fp_reg[i].u64[0] =
+		fpregs->fpr_vfp.vfp_regs[j++];
 #else
-		pcb->pcb_fpregs.fp_reg[i].u64[1] = 0;
 		pcb->pcb_fpregs.fp_reg[i].u64[0] =
+		fpregs->fpr_vfp.vfp_regs[j++];
+		pcb->pcb_fpregs.fp_reg[i].u64[1] =
+		fpregs->fpr_vfp.vfp_regs[j++];
 #endif
-		fpregs->fpr_vfp.vfp_regs[i];
 	}
 
 	return 0;
@@ -458,18 +465,21 @@ cpu_getmcontext32(struct lwp *l, mcontex
 	/* fpu context */
 	if (fpu_used_p(l)) {
 		const struct pcb * const pcb = lwp_getpcb(l);
-		int i;
+		int i, j;
 
 		fpu_save(l);
 
-		CTASSERT(__arraycount(mcp->__vfpregs.__vfp_fstmx) ==
-		__arraycount(pcb->pcb_fpregs.fp_reg));
-		for (i = 0; i < __arraycount(pcb->pcb_fpregs.fp_reg); i++) {
-			mcp->__vfpregs.__vfp_fstmx[i] =
+		for (i = j = 0; i < 16; i++) {
 #ifdef __AARCH64EB__
+			mcp->__vfpregs.__vfp_fstmx[j++] =
 			pcb->pcb_fpregs.fp_reg[i].u64[1];
+			mcp->__vfpregs.__vfp_fstmx[j++] =
+			pcb->pcb_fpregs.fp_reg[i].u64[0];
 #else
+			mcp->__vfpregs.__vfp_fstmx[j++] =
 			pcb->pcb_fpregs.fp_reg[i].u64[0];
+			mcp->__vfpregs.__vfp_fstmx[j++] =
+			pcb->pcb_fpregs.fp_reg[i].u64[1];
 #endif
 		}
 
@@ -491,7 +501,7 @@ cpu_setmcontext32(struct lwp *l, const m
 	struct trapframe * const tf = l->l_md.md_utf;
 	const __greg32_t * const gr = mcp->__gregs;
 	struct proc * const p = l->l_proc;
-	int error, i;
+	int error, i, j;
 
 	if (flags & _UC_CPU) {
 		error = cpu_mcontext32_validate(l, mcp);
@@ -521,17 +531,18 @@ cpu_setmcontext32(struct lwp *l, const m
 		struct pcb * const pcb = lwp_getpcb(l);
 		fpu_discard(l, true);
 
-		CTASSERT(__arraycount(mcp->__vfpregs.__vfp_fstmx) ==
-		__arraycount(pcb->pcb_fpregs.fp_reg));
-		for (i = 0; i < __arraycount(pcb->pcb_fpregs.fp_reg); i++) {
+		for (i = j = 0; i < 16; i++) {
 #ifdef __AARCH64EB__
-			pcb->pcb_fpregs.fp_reg[i].u64[0] = 0;
 			pcb->pcb_fpregs.fp_reg[i].u64[1] =
+			mcp->__vfpregs.__vfp_fstmx[j++];
+			pcb->pcb_fpregs.fp_reg[i].u64[0] 

CVS commit: src/sys/arch/alpha

2021-05-29 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun May 30 05:26:09 UTC 2021

Modified Files:
src/sys/arch/alpha/alpha: pmap.c
src/sys/arch/alpha/include: pmap.h

Log Message:
Define a macro, VM_MDPAGE_PVS(), for fetching the first pv entry
for a page.


To generate a diff of this commit:
cvs rdiff -u -r1.285 -r1.286 src/sys/arch/alpha/alpha/pmap.c
cvs rdiff -u -r1.91 -r1.92 src/sys/arch/alpha/include/pmap.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/alpha/alpha/pmap.c
diff -u src/sys/arch/alpha/alpha/pmap.c:1.285 src/sys/arch/alpha/alpha/pmap.c:1.286
--- src/sys/arch/alpha/alpha/pmap.c:1.285	Sun May 30 04:04:26 2021
+++ src/sys/arch/alpha/alpha/pmap.c	Sun May 30 05:26:09 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.285 2021/05/30 04:04:26 thorpej Exp $ */
+/* $NetBSD: pmap.c,v 1.286 2021/05/30 05:26:09 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001, 2007, 2008, 2020
@@ -135,7 +135,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.285 2021/05/30 04:04:26 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.286 2021/05/30 05:26:09 thorpej Exp $");
 
 #include 
 #include 
@@ -1823,7 +1823,6 @@ pmap_remove(pmap_t pmap, vaddr_t sva, va
 void
 pmap_page_protect(struct vm_page *pg, vm_prot_t prot)
 {
-	struct vm_page_md * const md = VM_PAGE_TO_MD(pg);
 	pv_entry_t pv, nextpv;
 	pt_entry_t opte;
 	kmutex_t *lock;
@@ -1851,7 +1850,7 @@ pmap_page_protect(struct vm_page *pg, vm
 		PMAP_HEAD_TO_MAP_LOCK();
 		lock = pmap_pvh_lock(pg);
 		mutex_enter(lock);
-		for (pv = md->pvh_list; pv != NULL; pv = pv->pv_next) {
+		for (pv = VM_MDPAGE_PVS(pg); pv != NULL; pv = pv->pv_next) {
 			PMAP_LOCK(pv->pv_pmap);
 			opte = atomic_load_relaxed(pv->pv_pte);
 			if (opte & (PG_KWE | PG_UWE)) {
@@ -1876,7 +1875,7 @@ pmap_page_protect(struct vm_page *pg, vm
 	PMAP_HEAD_TO_MAP_LOCK();
 	lock = pmap_pvh_lock(pg);
 	mutex_enter(lock);
-	for (pv = md->pvh_list; pv != NULL; pv = nextpv) {
+	for (pv = VM_MDPAGE_PVS(pg); pv != NULL; pv = nextpv) {
 		pt_entry_t pte_bits;
 		pmap_t pmap;
 		vaddr_t va;
@@ -3007,7 +3006,6 @@ static void
 pmap_changebit(struct vm_page *pg, pt_entry_t set, pt_entry_t mask,
 struct pmap_tlb_context * const tlbctx)
 {
-	struct vm_page_md * const md = VM_PAGE_TO_MD(pg);
 	pv_entry_t pv;
 	pt_entry_t *pte, npte, opte;
 
@@ -3020,7 +3018,7 @@ pmap_changebit(struct vm_page *pg, pt_en
 	/*
 	 * Loop over all current mappings setting/clearing as apropos.
 	 */
-	for (pv = md->pvh_list; pv != NULL; pv = pv->pv_next) {
+	for (pv = VM_MDPAGE_PVS(pg); pv != NULL; pv = pv->pv_next) {
 		PMAP_LOCK(pv->pv_pmap);
 
 		pte = pv->pv_pte;
@@ -3176,7 +3174,7 @@ pmap_pv_dump(paddr_t pa)
 	mutex_enter(lock);
 
 	printf("pa 0x%lx (attrs = 0x%x):\n", pa, md->pvh_attrs);
-	for (pv = md->pvh_list; pv != NULL; pv = pv->pv_next)
+	for (pv = VM_MDPAGE_PVS(pg); pv != NULL; pv = pv->pv_next)
 		printf(" pmap %p, va 0x%lx\n",
 		pv->pv_pmap, pv->pv_va);
 	printf("\n");
@@ -3264,7 +3262,7 @@ pmap_pv_enter(pmap_t pmap, struct vm_pag
 	/*
 	 * Make sure the entry doesn't already exist.
 	 */
-	for (pv = md->pvh_list; pv != NULL; pv = pv->pv_next) {
+	for (pv = VM_MDPAGE_PVS(pg); pv != NULL; pv = pv->pv_next) {
 		if (pmap == pv->pv_pmap && va == pv->pv_va) {
 			printf("pmap = %p, va = 0x%lx\n", pmap, va);
 			panic("pmap_pv_enter: already in pv table");

Index: src/sys/arch/alpha/include/pmap.h
diff -u src/sys/arch/alpha/include/pmap.h:1.91 src/sys/arch/alpha/include/pmap.h:1.92
--- src/sys/arch/alpha/include/pmap.h:1.91	Sun May 30 04:04:26 2021
+++ src/sys/arch/alpha/include/pmap.h	Sun May 30 05:26:09 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.h,v 1.91 2021/05/30 04:04:26 thorpej Exp $ */
+/* $NetBSD: pmap.h,v 1.92 2021/05/30 05:26:09 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001, 2007 The NetBSD Foundation, Inc.
@@ -363,6 +363,9 @@ struct vm_page_md {
 	int pvh_attrs;/* page attributes */
 };
 
+#define	VM_MDPAGE_PVS(pg)		\
+	((pg)->mdpage.pvh_list)
+
 #define	VM_MDPAGE_INIT(pg)		\
 do {	\
 	(pg)->mdpage.pvh_list = NULL;	\



CVS commit: src/sys/arch/alpha

2021-05-29 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun May 30 04:04:27 UTC 2021

Modified Files:
src/sys/arch/alpha/alpha: pmap.c
src/sys/arch/alpha/include: pmap.h

Log Message:
Pages that are in-use as page table pages should never be part of a
UVM loan transaction, so use the vm_page::loan_count field as the PT
page reference count.


To generate a diff of this commit:
cvs rdiff -u -r1.284 -r1.285 src/sys/arch/alpha/alpha/pmap.c
cvs rdiff -u -r1.90 -r1.91 src/sys/arch/alpha/include/pmap.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/alpha/alpha/pmap.c
diff -u src/sys/arch/alpha/alpha/pmap.c:1.284 src/sys/arch/alpha/alpha/pmap.c:1.285
--- src/sys/arch/alpha/alpha/pmap.c:1.284	Sun May 30 01:41:45 2021
+++ src/sys/arch/alpha/alpha/pmap.c	Sun May 30 04:04:26 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.284 2021/05/30 01:41:45 thorpej Exp $ */
+/* $NetBSD: pmap.c,v 1.285 2021/05/30 04:04:26 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001, 2007, 2008, 2020
@@ -135,7 +135,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.284 2021/05/30 01:41:45 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.285 2021/05/30 04:04:26 thorpej Exp $");
 
 #include 
 #include 
@@ -3358,6 +3358,15 @@ pmap_pv_page_free(struct pool *pp, void 
 / misc. functions /
 
 /*
+ * Pages that are in-use as page table pages should never be part
+ * of a UVM loan, so we'll use that field for our PT page reference
+ * count.
+ */
+#define	PHYSPAGE_REFCNT(pg)	atomic_load_relaxed(&(pg)->loan_count)
+#define	PHYSPAGE_REFCNT_INC(pg)	atomic_inc_uint_nv(&(pg)->loan_count)
+#define	PHYSPAGE_REFCNT_DEC(pg)	atomic_dec_uint_nv(&(pg)->loan_count)
+
+/*
  * pmap_physpage_alloc:
  *
  *	Allocate a single page from the VM system and return the
@@ -3376,14 +3385,7 @@ pmap_physpage_alloc(int usage)
 	pg = uvm_pagealloc(NULL, 0, NULL, usage == PGU_L1PT ?
 	UVM_PGA_USERESERVE : UVM_PGA_USERESERVE|UVM_PGA_ZERO);
 	if (pg != NULL) {
-#ifdef DEBUG
-		struct vm_page_md * const md = VM_PAGE_TO_MD(pg);
-		if (md->pvh_refcnt != 0) {
-			printf("pmap_physpage_alloc: page 0x%lx has "
-			"%d references\n", pa, md->pvh_refcnt);
-			panic("pmap_physpage_alloc");
-		}
-#endif
+		KASSERT(PHYSPAGE_REFCNT(pg) == 0);
 	}
 	return pg;
 }
@@ -3401,11 +3403,7 @@ pmap_physpage_free(paddr_t pa)
 	if ((pg = PHYS_TO_VM_PAGE(pa)) == NULL)
 		panic("pmap_physpage_free: bogus physical page address");
 
-#ifdef DEBUG
-	struct vm_page_md * const md = VM_PAGE_TO_MD(pg);
-	if (md->pvh_refcnt != 0)
-		panic("pmap_physpage_free: page still has references");
-#endif
+	KASSERT(PHYSPAGE_REFCNT(pg) == 0);
 
 	uvm_pagefree(pg);
 }
@@ -3419,16 +3417,14 @@ static int
 pmap_physpage_addref(void *kva)
 {
 	struct vm_page *pg;
-	struct vm_page_md *md;
 	paddr_t pa;
 
 	pa = ALPHA_K0SEG_TO_PHYS(trunc_page((vaddr_t)kva));
 	pg = PHYS_TO_VM_PAGE(pa);
-	md = VM_PAGE_TO_MD(pg);
 
-	KASSERT((int)md->pvh_refcnt >= 0);
+	KASSERT(PHYSPAGE_REFCNT(pg) < UINT32_MAX);
 
-	return atomic_inc_uint_nv(>pvh_refcnt);
+	return PHYSPAGE_REFCNT_INC(pg);
 }
 
 /*
@@ -3440,16 +3436,14 @@ static int
 pmap_physpage_delref(void *kva)
 {
 	struct vm_page *pg;
-	struct vm_page_md *md;
 	paddr_t pa;
 
 	pa = ALPHA_K0SEG_TO_PHYS(trunc_page((vaddr_t)kva));
 	pg = PHYS_TO_VM_PAGE(pa);
-	md = VM_PAGE_TO_MD(pg);
 
-	KASSERT((int)md->pvh_refcnt > 0);
+	KASSERT(PHYSPAGE_REFCNT(pg) != 0);
 
-	return atomic_dec_uint_nv(>pvh_refcnt);
+	return PHYSPAGE_REFCNT_DEC(pg);
 }
 
 / page table page management /
@@ -3685,10 +3679,8 @@ pmap_ptpage_free(pmap_t pmap, pt_entry_t
 	struct vm_page * const pg = PHYS_TO_VM_PAGE(ptpa);
 	KASSERT(pg != NULL);
 
+	KASSERT(PHYSPAGE_REFCNT(pg) == 0);
 #ifdef DEBUG
-	struct vm_page_md * const md = VM_PAGE_TO_MD(pg);
-	KDASSERT(md->pvh_refcnt == 0);
-
 	pmap_zero_page(ptpa);
 #endif
 

Index: src/sys/arch/alpha/include/pmap.h
diff -u src/sys/arch/alpha/include/pmap.h:1.90 src/sys/arch/alpha/include/pmap.h:1.91
--- src/sys/arch/alpha/include/pmap.h:1.90	Sun May 30 01:41:45 2021
+++ src/sys/arch/alpha/include/pmap.h	Sun May 30 04:04:26 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.h,v 1.90 2021/05/30 01:41:45 thorpej Exp $ */
+/* $NetBSD: pmap.h,v 1.91 2021/05/30 04:04:26 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001, 2007 The NetBSD Foundation, Inc.
@@ -361,13 +361,12 @@ do {	\
 struct vm_page_md {
 	struct pv_entry *pvh_list;		/* pv_entry list */
 	int pvh_attrs;/* page attributes */
-	unsigned pvh_refcnt;
 };
 
 #define	VM_MDPAGE_INIT(pg)		\
 do {	\
 	(pg)->mdpage.pvh_list = NULL;	\
-	(pg)->mdpage.pvh_refcnt = 0;	\
+	(pg)->mdpage.pvh_attrs = 0;	\
 } while (/*CONSTCOND*/0)
 
 #endif /* _KERNEL */



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

2021-05-29 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Sun May 30 02:28:59 UTC 2021

Modified Files:
src/sys/arch/arm/include: lock.h

Log Message:
Don't use V8 atomic instruction for AA32 mode.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/arch/arm/include/lock.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/include/lock.h
diff -u src/sys/arch/arm/include/lock.h:1.38 src/sys/arch/arm/include/lock.h:1.39
--- src/sys/arch/arm/include/lock.h:1.38	Tue Apr 27 06:03:09 2021
+++ src/sys/arch/arm/include/lock.h	Sun May 30 02:28:59 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: lock.h,v 1.38 2021/04/27 06:03:09 skrll Exp $	*/
+/*	$NetBSD: lock.h,v 1.39 2021/05/30 02:28:59 joerg Exp $	*/
 
 /*-
  * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
@@ -204,7 +204,7 @@ static __inline void __unused
 __cpu_simple_unlock(__cpu_simple_lock_t *__alp)
 {
 
-#if defined(_ARM_ARCH_8)
+#if defined(_ARM_ARCH_8) && defined(__LP64__)
 	if (sizeof(*__alp) == 1) {
 		__asm __volatile("stlrb\t%w0, [%1]"
 		:: "r"(__SIMPLELOCK_UNLOCKED), "r"(__alp) : "memory");



CVS commit: src/sys/arch/alpha

2021-05-29 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun May 30 01:41:45 UTC 2021

Modified Files:
src/sys/arch/alpha/alpha: pmap.c
src/sys/arch/alpha/include: pmap.h

Log Message:
Track the PT pages allocated to a pmap in the pmap itself.


To generate a diff of this commit:
cvs rdiff -u -r1.283 -r1.284 src/sys/arch/alpha/alpha/pmap.c
cvs rdiff -u -r1.89 -r1.90 src/sys/arch/alpha/include/pmap.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/alpha/alpha/pmap.c
diff -u src/sys/arch/alpha/alpha/pmap.c:1.283 src/sys/arch/alpha/alpha/pmap.c:1.284
--- src/sys/arch/alpha/alpha/pmap.c:1.283	Sun May 30 01:24:19 2021
+++ src/sys/arch/alpha/alpha/pmap.c	Sun May 30 01:41:45 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.283 2021/05/30 01:24:19 thorpej Exp $ */
+/* $NetBSD: pmap.c,v 1.284 2021/05/30 01:41:45 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001, 2007, 2008, 2020
@@ -135,7 +135,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.283 2021/05/30 01:24:19 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.284 2021/05/30 01:41:45 thorpej Exp $");
 
 #include 
 #include 
@@ -1081,22 +1081,6 @@ pmap_tlb_shootdown_ipi(struct cpu_info *
 }
 #endif /* MULTIPROCESSOR */
 
-static void
-pmap_tlb_physpage_free(paddr_t const ptpa,
-struct pmap_tlb_context * const tlbctx)
-{
-	struct vm_page * const pg = PHYS_TO_VM_PAGE(ptpa);
-
-	KASSERT(pg != NULL);
-
-#ifdef DEBUG
-	struct vm_page_md * const md = VM_PAGE_TO_MD(pg);
-	KDASSERT(md->pvh_refcnt == 0);
-#endif
-
-	LIST_INSERT_HEAD(>t_freeptq, pg, pageq.list);
-}
-
 static __inline void
 pmap_tlb_ptpage_drain(struct pmap_tlb_context * const tlbctx)
 {
@@ -1116,8 +1100,9 @@ static void	pmap_changebit(struct vm_pag
 /*
  * PT page management functions.
  */
-static int	pmap_ptpage_alloc(pt_entry_t *, int);
-static void	pmap_ptpage_free(pt_entry_t *, struct pmap_tlb_context *);
+static int	pmap_ptpage_alloc(pmap_t, pt_entry_t *, int);
+static void	pmap_ptpage_free(pmap_t, pt_entry_t *,
+ struct pmap_tlb_context *);
 static void	pmap_l3pt_delref(pmap_t, vaddr_t, pt_entry_t *,
 		 struct pmap_tlb_context *);
 static void	pmap_l2pt_delref(pmap_t, pt_entry_t *, pt_entry_t *,
@@ -1398,6 +1383,7 @@ pmap_bootstrap(paddr_t ptaddr, u_int max
 	 * generation.
 	 */
 	memset(pmap_kernel(), 0, sizeof(struct pmap));
+	LIST_INIT(_kernel()->pm_ptpages);
 	atomic_store_relaxed(_kernel()->pm_count, 1);
 	/* Kernel pmap does not have per-CPU info. */
 	TAILQ_INSERT_TAIL(_all_pmaps, pmap_kernel(), pm_list);
@@ -1581,6 +1567,7 @@ pmap_create(void)
 
 	pmap = pool_cache_get(_pmap_cache, PR_WAITOK);
 	memset(pmap, 0, sizeof(*pmap));
+	LIST_INIT(>pm_ptpages);
 
 	atomic_store_relaxed(>pm_count, 1);
 
@@ -2105,7 +2092,7 @@ pmap_enter(pmap_t pmap, vaddr_t va, padd
 		l1pte = pmap_l1pte(lev1map, va);
 		if (pmap_pte_v(l1pte) == 0) {
 			pmap_physpage_addref(l1pte);
-			error = pmap_ptpage_alloc(l1pte, PGU_L2PT);
+			error = pmap_ptpage_alloc(pmap, l1pte, PGU_L2PT);
 			if (error) {
 pmap_l1pt_delref(pmap, l1pte);
 if (flags & PMAP_CANFAIL)
@@ -2129,7 +2116,7 @@ pmap_enter(pmap_t pmap, vaddr_t va, padd
 		l2pte = pmap_l2pte(lev1map, va, l1pte);
 		if (pmap_pte_v(l2pte) == 0) {
 			pmap_physpage_addref(l2pte);
-			error = pmap_ptpage_alloc(l2pte, PGU_L3PT);
+			error = pmap_ptpage_alloc(pmap, l2pte, PGU_L3PT);
 			if (error) {
 /* unlocks pmap */
 pmap_enter_l2pt_delref(pmap, l1pte, l2pte);
@@ -3652,7 +3639,7 @@ pmap_l1pt_free(struct pool *pp, void *v)
  *	Note: the pmap must already be locked.
  */
 static int
-pmap_ptpage_alloc(pt_entry_t * const pte, int const usage)
+pmap_ptpage_alloc(pmap_t pmap, pt_entry_t * const pte, int const usage)
 {
 	/*
 	 * Allocate the page table page.
@@ -3662,6 +3649,8 @@ pmap_ptpage_alloc(pt_entry_t * const pte
 		return ENOMEM;
 	}
 
+	LIST_INSERT_HEAD(>pm_ptpages, pg, pageq.list);
+
 	/*
 	 * Initialize the referencing PTE.
 	 */
@@ -3682,7 +3671,8 @@ pmap_ptpage_alloc(pt_entry_t * const pte
  *	Note: the pmap must already be locked.
  */
 static void
-pmap_ptpage_free(pt_entry_t * const pte, struct pmap_tlb_context * const tlbctx)
+pmap_ptpage_free(pmap_t pmap, pt_entry_t * const pte,
+struct pmap_tlb_context * const tlbctx)
 {
 
 	/*
@@ -3692,10 +3682,18 @@ pmap_ptpage_free(pt_entry_t * const pte,
 	const paddr_t ptpa = pmap_pte_pa(pte);
 	atomic_store_relaxed(pte, PG_NV);
 
+	struct vm_page * const pg = PHYS_TO_VM_PAGE(ptpa);
+	KASSERT(pg != NULL);
+
 #ifdef DEBUG
+	struct vm_page_md * const md = VM_PAGE_TO_MD(pg);
+	KDASSERT(md->pvh_refcnt == 0);
+
 	pmap_zero_page(ptpa);
 #endif
-	pmap_tlb_physpage_free(ptpa, tlbctx);
+
+	LIST_REMOVE(pg, pageq.list);
+	LIST_INSERT_HEAD(>t_freeptq, pg, pageq.list);
 }
 
 /*
@@ -3735,7 +3733,7 @@ pmap_l3pt_delref(pmap_t pmap, vaddr_t va
 		 * be dropped.
 		 */
 		KASSERT(tlbctx != NULL);
-		

CVS commit: src/sys/arch/alpha/alpha

2021-05-29 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun May 30 01:24:19 UTC 2021

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

Log Message:
Change pmap_physpage_alloc() to return the vm_page * so that the
callers have access to it.


To generate a diff of this commit:
cvs rdiff -u -r1.282 -r1.283 src/sys/arch/alpha/alpha/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/alpha/alpha/pmap.c
diff -u src/sys/arch/alpha/alpha/pmap.c:1.282 src/sys/arch/alpha/alpha/pmap.c:1.283
--- src/sys/arch/alpha/alpha/pmap.c:1.282	Sun May 30 00:34:27 2021
+++ src/sys/arch/alpha/alpha/pmap.c	Sun May 30 01:24:19 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.282 2021/05/30 00:34:27 thorpej Exp $ */
+/* $NetBSD: pmap.c,v 1.283 2021/05/30 01:24:19 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001, 2007, 2008, 2020
@@ -135,7 +135,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.282 2021/05/30 00:34:27 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.283 2021/05/30 01:24:19 thorpej Exp $");
 
 #include 
 #include 
@@ -1162,7 +1162,7 @@ static u_int	pmap_asn_alloc(pmap_t, stru
 /*
  * Misc. functions.
  */
-static bool	pmap_physpage_alloc(int, paddr_t *);
+static struct vm_page *pmap_physpage_alloc(int);
 static void	pmap_physpage_free(paddr_t);
 static int	pmap_physpage_addref(void *);
 static int	pmap_physpage_delref(void *);
@@ -3349,11 +3349,11 @@ pmap_pv_remove(pmap_t pmap, struct vm_pa
 static void *
 pmap_pv_page_alloc(struct pool *pp, int flags)
 {
-	paddr_t pg;
-
-	if (pmap_physpage_alloc(PGU_PVENT, ))
-		return ((void *)ALPHA_PHYS_TO_K0SEG(pg));
-	return (NULL);
+	struct vm_page * const pg = pmap_physpage_alloc(PGU_PVENT);
+	if (__predict_false(pg == NULL)) {
+		return NULL;
+	}
+	return (void *)ALPHA_PHYS_TO_K0SEG(VM_PAGE_TO_PHYS(pg));
 }
 
 /*
@@ -3376,11 +3376,10 @@ pmap_pv_page_free(struct pool *pp, void 
  *	Allocate a single page from the VM system and return the
  *	physical address for that page.
  */
-static bool
-pmap_physpage_alloc(int usage, paddr_t *pap)
+static struct vm_page *
+pmap_physpage_alloc(int usage)
 {
 	struct vm_page *pg;
-	paddr_t pa;
 
 	/*
 	 * Don't ask for a zero'd page in the L1PT case -- we will
@@ -3390,7 +3389,6 @@ pmap_physpage_alloc(int usage, paddr_t *
 	pg = uvm_pagealloc(NULL, 0, NULL, usage == PGU_L1PT ?
 	UVM_PGA_USERESERVE : UVM_PGA_USERESERVE|UVM_PGA_ZERO);
 	if (pg != NULL) {
-		pa = VM_PAGE_TO_PHYS(pg);
 #ifdef DEBUG
 		struct vm_page_md * const md = VM_PAGE_TO_MD(pg);
 		if (md->pvh_refcnt != 0) {
@@ -3399,10 +3397,8 @@ pmap_physpage_alloc(int usage, paddr_t *
 			panic("pmap_physpage_alloc");
 		}
 #endif
-		*pap = pa;
-		return (true);
 	}
-	return (false);
+	return pg;
 }
 
 /*
@@ -3485,7 +3481,12 @@ pmap_kptpage_alloc(paddr_t *pap)
 		return true;
 	}
 
-	return pmap_physpage_alloc(PGU_NORMAL, pap);
+	struct vm_page * const pg = pmap_physpage_alloc(PGU_NORMAL);
+	if (__predict_true(pg != NULL)) {
+		*pap = VM_PAGE_TO_PHYS(pg);
+		return true;
+	}
+	return false;
 }
 
 /*
@@ -3620,15 +3621,14 @@ pmap_l1pt_ctor(void *arg, void *object, 
 static void *
 pmap_l1pt_alloc(struct pool *pp, int flags)
 {
-	paddr_t ptpa;
-
 	/*
 	 * Attempt to allocate a free page.
 	 */
-	if (pmap_physpage_alloc(PGU_L1PT, ) == false)
-		return (NULL);
-
-	return ((void *) ALPHA_PHYS_TO_K0SEG(ptpa));
+	struct vm_page * const pg = pmap_physpage_alloc(PGU_L1PT);
+	if (__predict_false(pg == NULL)) {
+		return NULL;
+	}
+	return (void *)ALPHA_PHYS_TO_K0SEG(VM_PAGE_TO_PHYS(pg));
 }
 
 /*
@@ -3654,18 +3654,18 @@ pmap_l1pt_free(struct pool *pp, void *v)
 static int
 pmap_ptpage_alloc(pt_entry_t * const pte, int const usage)
 {
-	paddr_t ptpa;
-
 	/*
 	 * Allocate the page table page.
 	 */
-	if (pmap_physpage_alloc(usage, ) == false)
-		return (ENOMEM);
+	struct vm_page * const pg = pmap_physpage_alloc(usage);
+	if (__predict_false(pg == NULL)) {
+		return ENOMEM;
+	}
 
 	/*
 	 * Initialize the referencing PTE.
 	 */
-	const pt_entry_t npte = ((ptpa >> PGSHIFT) << PG_SHIFT) |
+	const pt_entry_t npte = ((VM_PAGE_TO_PHYS(pg) >> PGSHIFT) << PG_SHIFT) |
 	PG_V | PG_KRE | PG_KWE | PG_WIRED;
 
 	atomic_store_relaxed(pte, npte);



CVS commit: src/sys/arch/alpha

2021-05-29 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun May 30 00:34:27 UTC 2021

Modified Files:
src/sys/arch/alpha/alpha: pmap.c
src/sys/arch/alpha/include: pmap.h

Log Message:
Define a pmap_pagelist LIST_HEAD and use it where we used ad hoc LIST_HEADs
of vm_page structures.  Define and use a generic routine to free such a list
back to UVM.

In pmap_remove_internal(), KASSERT that no PT pages are queued up to be
freed when removing mappings from the kernel pmap.


To generate a diff of this commit:
cvs rdiff -u -r1.281 -r1.282 src/sys/arch/alpha/alpha/pmap.c
cvs rdiff -u -r1.88 -r1.89 src/sys/arch/alpha/include/pmap.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/alpha/alpha/pmap.c
diff -u src/sys/arch/alpha/alpha/pmap.c:1.281 src/sys/arch/alpha/alpha/pmap.c:1.282
--- src/sys/arch/alpha/alpha/pmap.c:1.281	Sat May 29 23:27:22 2021
+++ src/sys/arch/alpha/alpha/pmap.c	Sun May 30 00:34:27 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.281 2021/05/29 23:27:22 thorpej Exp $ */
+/* $NetBSD: pmap.c,v 1.282 2021/05/30 00:34:27 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001, 2007, 2008, 2020
@@ -135,7 +135,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.281 2021/05/29 23:27:22 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.282 2021/05/30 00:34:27 thorpej Exp $");
 
 #include 
 #include 
@@ -432,6 +432,21 @@ pmap_activation_lock(pmap_t const pmap)
 #endif /* MULTIPROCESSOR */
 
 /*
+ * Generic routine for freeing pages on a pmap_pagelist back to
+ * the system.
+ */
+static void
+pmap_pagelist_free(struct pmap_pagelist * const list)
+{
+	struct vm_page *pg;
+
+	while ((pg = LIST_FIRST(list)) != NULL) {
+		LIST_REMOVE(pg, pageq.list);
+		uvm_pagefree(pg);
+	}
+}
+
+/*
  * TLB management.
  *
  * TLB invalidations need to be performed on local and remote CPUs
@@ -526,7 +541,7 @@ pmap_activation_lock(pmap_t const pmap)
 struct pmap_tlb_context {
 	uintptr_t	t_addrdata[TLB_CTX_MAXVA];
 	pmap_t		t_pmap;
-	LIST_HEAD(, vm_page) t_freeptq;
+	struct pmap_pagelist t_freeptq;
 };
 
 static struct {
@@ -1082,15 +1097,10 @@ pmap_tlb_physpage_free(paddr_t const ptp
 	LIST_INSERT_HEAD(>t_freeptq, pg, pageq.list);
 }
 
-static void
+static __inline void
 pmap_tlb_ptpage_drain(struct pmap_tlb_context * const tlbctx)
 {
-	struct vm_page *pg;
-
-	while ((pg = LIST_FIRST(>t_freeptq)) != NULL) {
-		LIST_REMOVE(pg, pageq.list);
-		uvm_pagefree(pg);
-	}
+	pmap_pagelist_free(>t_freeptq);
 }
 
 /*
@@ -1720,7 +1730,8 @@ pmap_remove_internal(pmap_t pmap, vaddr_
 		PMAP_MAP_TO_HEAD_UNLOCK();
 		PMAP_UNLOCK(pmap);
 		pmap_tlb_shootnow(tlbctx);
-		pmap_tlb_ptpage_drain(tlbctx);
+		/* kernel PT pages are never freed. */
+		KASSERT(LIST_EMPTY(>t_freeptq));
 		TLB_COUNT(reason_remove_kernel);
 
 		return;

Index: src/sys/arch/alpha/include/pmap.h
diff -u src/sys/arch/alpha/include/pmap.h:1.88 src/sys/arch/alpha/include/pmap.h:1.89
--- src/sys/arch/alpha/include/pmap.h:1.88	Sat May 29 23:27:22 2021
+++ src/sys/arch/alpha/include/pmap.h	Sun May 30 00:34:27 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.h,v 1.88 2021/05/29 23:27:22 thorpej Exp $ */
+/* $NetBSD: pmap.h,v 1.89 2021/05/30 00:34:27 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001, 2007 The NetBSD Foundation, Inc.
@@ -131,6 +131,9 @@
  * allocate any ASN info for the kernel pmap at all.
  * arrays which hold enough for ALPHA_MAXPROCS.
  */
+
+LIST_HEAD(pmap_pagelist, vm_page);
+
 struct pmap_percpu {
 	unsigned int		pmc_asn;	/* address space number */
 	unsigned int		pmc_pad0;



CVS commit: src/sys/arch/alpha

2021-05-29 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat May 29 23:27:22 UTC 2021

Modified Files:
src/sys/arch/alpha/alpha: pmap.c vm_machdep.c
src/sys/arch/alpha/include: pmap.h

Log Message:
Move the pointer to the pmap's lev1map out of the shared pmap structure
and into each CPU's pmap_percpu area.  This pointer is constant for the
life of the pmap, and moving it gives us an additional 8 bytes in the
shared pmap structure.

Because the kernel pmap does not have per-CPU data, all places where we
need the kernel pmap's lev1map now just reference kernel_lev1map directly.


To generate a diff of this commit:
cvs rdiff -u -r1.280 -r1.281 src/sys/arch/alpha/alpha/pmap.c
cvs rdiff -u -r1.117 -r1.118 src/sys/arch/alpha/alpha/vm_machdep.c
cvs rdiff -u -r1.87 -r1.88 src/sys/arch/alpha/include/pmap.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/alpha/alpha/pmap.c
diff -u src/sys/arch/alpha/alpha/pmap.c:1.280 src/sys/arch/alpha/alpha/pmap.c:1.281
--- src/sys/arch/alpha/alpha/pmap.c:1.280	Sat May 29 22:14:09 2021
+++ src/sys/arch/alpha/alpha/pmap.c	Sat May 29 23:27:22 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.280 2021/05/29 22:14:09 thorpej Exp $ */
+/* $NetBSD: pmap.c,v 1.281 2021/05/29 23:27:22 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001, 2007, 2008, 2020
@@ -135,7 +135,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.280 2021/05/29 22:14:09 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.281 2021/05/29 23:27:22 thorpej Exp $");
 
 #include 
 #include 
@@ -1173,19 +1173,19 @@ static bool	vtophys_internal(vaddr_t, pa
 ({	\
 	pt_entry_t *l1pte_, *l2pte_;	\
 	\
-	l1pte_ = pmap_l1pte(pmap_kernel(), va);\
+	l1pte_ = pmap_l1pte(kernel_lev1map, va);			\
 	if (pmap_pte_v(l1pte_) == 0) {	\
 		printf("kernel level 1 PTE not valid, va 0x%lx "	\
 		"(line %d)\n", (va), __LINE__);			\
 		panic("PMAP_KERNEL_PTE");\
 	}\
-	l2pte_ = pmap_l2pte(pmap_kernel(), va, l1pte_);			\
+	l2pte_ = pmap_l2pte(kernel_lev1map, va, l1pte_);		\
 	if (pmap_pte_v(l2pte_) == 0) {	\
 		printf("kernel level 2 PTE not valid, va 0x%lx "	\
 		"(line %d)\n", (va), __LINE__);			\
 		panic("PMAP_KERNEL_PTE");\
 	}\
-	pmap_l3pte(pmap_kernel(), va, l2pte_);\
+	pmap_l3pte(kernel_lev1map, va, l2pte_);\
 })
 #else
 #define	PMAP_KERNEL_PTE(va)	([VPT_INDEX((va))])
@@ -1388,9 +1388,8 @@ pmap_bootstrap(paddr_t ptaddr, u_int max
 	 * generation.
 	 */
 	memset(pmap_kernel(), 0, sizeof(struct pmap));
-	pmap_kernel()->pm_lev1map = kernel_lev1map;
 	atomic_store_relaxed(_kernel()->pm_count, 1);
-	/* Kernel pmap does not have ASN info. */
+	/* Kernel pmap does not have per-CPU info. */
 	TAILQ_INSERT_TAIL(_all_pmaps, pmap_kernel(), pm_list);
 
 	/*
@@ -1562,6 +1561,7 @@ pmap_t
 pmap_create(void)
 {
 	pmap_t pmap;
+	pt_entry_t *lev1map;
 	int i;
 
 #ifdef DEBUG
@@ -1574,24 +1574,29 @@ pmap_create(void)
 
 	atomic_store_relaxed(>pm_count, 1);
 
+ try_again:
+	rw_enter(_growkernel_lock, RW_READER);
+
+	lev1map = pool_cache_get(_l1pt_cache, PR_NOWAIT);
+	if (__predict_false(lev1map == NULL)) {
+		rw_exit(_growkernel_lock);
+		(void) kpause("pmap_create", false, hz >> 2, NULL);
+		goto try_again;
+	}
+
 	/*
 	 * There are only kernel mappings at this point; give the pmap
 	 * the kernel ASN.  This will be initialized to correct values
 	 * when the pmap is activated.
+	 *
+	 * We stash a pointer to the pmap's lev1map in each CPU's
+	 * private data.  It remains constant for the life of the
+	 * pmap, and gives us more room in the shared pmap structure.
 	 */
 	for (i = 0; i < pmap_ncpuids; i++) {
 		pmap->pm_percpu[i].pmc_asn = PMAP_ASN_KERNEL;
 		pmap->pm_percpu[i].pmc_asngen = PMAP_ASNGEN_INVALID;
-	}
-
- try_again:
-	rw_enter(_growkernel_lock, RW_READER);
-
-	pmap->pm_lev1map = pool_cache_get(_l1pt_cache, PR_NOWAIT);
-	if (__predict_false(pmap->pm_lev1map == NULL)) {
-		rw_exit(_growkernel_lock);
-		(void) kpause("pmap_create", false, hz >> 2, NULL);
-		goto try_again;
+		pmap->pm_percpu[i].pmc_lev1map = lev1map;
 	}
 
 	mutex_enter(_all_pmaps_lock);
@@ -1623,6 +1628,9 @@ pmap_destroy(pmap_t pmap)
 	if (atomic_dec_uint_nv(>pm_count) > 0)
 		return;
 
+	pt_entry_t *lev1map = pmap_lev1map(pmap);
+	int i;
+
 	rw_enter(_growkernel_lock, RW_READER);
 
 	/*
@@ -1632,8 +1640,12 @@ pmap_destroy(pmap_t pmap)
 	TAILQ_REMOVE(_all_pmaps, pmap, pm_list);
 	mutex_exit(_all_pmaps_lock);
 
-	pool_cache_put(_l1pt_cache, pmap->pm_lev1map);
-	pmap->pm_lev1map = (pt_entry_t *)0xdeadbeefUL;
+	pool_cache_put(_l1pt_cache, lev1map);
+#ifdef DIAGNOSTIC
+	for (i = 0; i < pmap_ncpuids; i++) {
+		pmap->pm_percpu[i].pmc_lev1map = (pt_entry_t *)0xdeadbeefUL;
+	}
+#endif /* DIAGNOSTIC */
 
 	rw_exit(_growkernel_lock);
 
@@ -1714,19 +1726,21 @@ pmap_remove_internal(pmap_t pmap, vaddr_
 		return;
 	}
 
+	pt_entry_t * const 

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

2021-05-29 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat May 29 22:52:35 UTC 2021

Modified Files:
src/sys/arch/hp300/conf: INSTALL

Log Message:
Reduce diffs from GENERIC for maintainability.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 src/sys/arch/hp300/conf/INSTALL

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

Modified files:

Index: src/sys/arch/hp300/conf/INSTALL
diff -u src/sys/arch/hp300/conf/INSTALL:1.68 src/sys/arch/hp300/conf/INSTALL:1.69
--- src/sys/arch/hp300/conf/INSTALL:1.68	Sat May 29 21:08:44 2021
+++ src/sys/arch/hp300/conf/INSTALL	Sat May 29 22:52:35 2021
@@ -1,4 +1,4 @@
-# $NetBSD: INSTALL,v 1.68 2021/05/29 21:08:44 tsutsui Exp $
+# $NetBSD: INSTALL,v 1.69 2021/05/29 22:52:35 tsutsui Exp $
 #
 # INSTALL machine description file
 #
@@ -9,17 +9,18 @@ include 	"arch/hp300/conf/std.hp300"
 
 #options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-# optimise for smaller kernels
-makeoptions 	COPTS="-Os -fno-unwind-tables"
+# Optimize for space.
+makeoptions	COPTS="-Os -fno-unwind-tables"
+
+maxusers	8		# estimated number of users
+
+# Special options for smaller kernels
 #options 	NVNODE=50
 #options 	NBUF=16
 #options 	BUFPAGES=16
 options 	BUFCACHE=5
 options 	NFS_V2_ONLY
 options 	NFS_DEFAULT_NIOTHREADS=1
-options 	USERCONF		# userconf(4) support
-options 	PIPE_SOCKETPAIR		# smaller, but slower pipe(2)
-#options 	SYSCTL_INCLUDE_DESCR	# Include sysctl descriptions in kernel
 
 # Support for various CPU types
 options 	HP320
@@ -38,42 +39,77 @@ options 	HP400
 options 	HP425
 options 	HP433
 options 	FPSP		# floating point interface for 68040
-
-# Need to set locally
-maxusers	8
+#options 	FPU_EMULATE	# software fpu emulation for MC68030
 
 # Standard system options
+#options 	KTRACE		# system call tracing support
+#options 	INSECURE	# disable kernel security level
+options 	USERCONF	# userconf(4) support
+options 	PIPE_SOCKETPAIR	# smaller, but slower pipe(2)
+#options 	SYSCTL_INCLUDE_DESCR	# Include sysctl descriptions in kernel
+#options 	RTC_OFFSET=0	# hardware clock is this many mins. west of GMT
+#options 	NTP		# NTP phase/frequency locked loop
+#options 	SYSVMSG		# System V-style message queues
+#options 	SYSVSEM		# System V-style semaphores
+#options 	SYSVSHM		# System V-style shared memory
+
+#options 	MODULAR		# new style module(7) framework
+#options 	MODULAR_DEFAULT_AUTOLOAD
+
+# Alternate buffer queue strategies for better responsiveness under high
+# disk I/O load.
+#options 	BUFQ_READPRIO
+#options 	BUFQ_PRIOCSCAN
+
+# Debugging options
+#options 	DIAGNOSTIC	# Extra kernel sanity checks
+#options 	DEBUG		# Enable misc. kernel debugging code
+#options 	DDB		# Kernel Dynamic Debugger
+#options 	DDB_HISTORY_SIZE=512	# Enable history editing in DDB
+#options 	KGDB		# remote debugger
+#makeoptions	DEBUG="-g"	# netbsd.gdb with full debugging symbols
+
+# Compatibility options
 #include 	"conf/compat_netbsd09.config"
 options 	COMPAT_BSDPTY	# /dev/[pt]ty?? ptys.
-#options 	SYSVSHM		# System V-style shared memory
-#options 	SYSVSEM		# System V-style semaphores
-#options 	SEMMNI=10	# number of semaphore identifiers
-#options 	SEMMNS=60	# number of semaphores in system
-#options 	SEMUME=10	# max number of undo entries per process
-#options 	SEMMNU=30	# number of undo structures in system
-#options 	SYSVMSG		# System V-style message queues
-#options 	KTRACE		# system call tracing support
-#options 	SCSIVERBOSE	# Verbose SCSI errors
+
+# Binary compatibility.
+#options 	COMPAT_AOUT_M68K	# NetBSD/m68k a.out binary compatibility
+#options 	COMPAT_M68K4K	# NetBSD/m68k4k binary compatibility
+#options 	COMPAT_SUNOS	# SunOS4 m68k binary compatibility
+#options 	COMPAT_LINUX	# Linux/m68k binary compatibility
+#options 	COMPAT_OSSAUDIO	# Linux/m68k binary compatibility
 
 # Filesystems
-file-system	FFS		# fast filesystem
 file-system	CD9660		# CD-ROM ISO-9660 filesystem
-file-system	NFS		# Network filesystem client
-#file-system	UNION		# Union filesystem (req. for FDESC)
-#file-system	KERNFS		# kernel data-structure filesystem
+#file-system	EXT2FS		# second extended file system (linux)
 #file-system	FDESC		# user file descriptor filesystem
-#file-system	PROCFS		# /proc filesystem
+file-system	FFS		# fast filesystem
+#file-system	KERNFS		# kernel data-structure filesystem
+#file-system	LFS		# log-structured file system
 file-system	MFS		# Memory-based filesystem
+file-system	NFS		# Network filesystem client
+#file-system	NULLFS		# loopback file system
+#file-system	OVERLAY		# overlay file system
+#file-system	PUFFS		# Userspace file systems (e.g. ntfs-3g & sshfs)
+#file-system	PROCFS		# /proc filesystem
+#file-system	UMAPFS		# NULLFS + uid and gid remapping
+#file-system	UNION		# Union filesystem (req. for FDESC)
+#file-system	CODA		# Coda File System; also needs vcoda (below)
 #file-system	PTYFS		# /dev/pts/N support
+#file-system	TMPFS		# Efficient 

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

2021-05-29 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat May 29 22:50:18 UTC 2021

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

Log Message:
Reorder entries and reorganize comments for maintainability.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.207 -r1.208 src/sys/arch/hp300/conf/GENERIC

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

Modified files:

Index: src/sys/arch/hp300/conf/GENERIC
diff -u src/sys/arch/hp300/conf/GENERIC:1.207 src/sys/arch/hp300/conf/GENERIC:1.208
--- src/sys/arch/hp300/conf/GENERIC:1.207	Thu Jan 21 06:51:54 2021
+++ src/sys/arch/hp300/conf/GENERIC	Sat May 29 22:50:18 2021
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.207 2021/01/21 06:51:54 nia Exp $
+# $NetBSD: GENERIC,v 1.208 2021/05/29 22:50:18 tsutsui Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@ include 	"arch/hp300/conf/std.hp300"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident 		"GENERIC-$Revision: 1.207 $"
+#ident 		"GENERIC-$Revision: 1.208 $"
 
 makeoptions	COPTS="-O2 -fno-reorder-blocks -fno-omit-frame-pointer"
 	# See share/mk/sys.mk. -fno-omit-frame-pointer is necessary for
@@ -57,9 +57,9 @@ options 	USERCONF	# userconf(4) support
 options 	SYSCTL_INCLUDE_DESCR	# Include sysctl descriptions in kernel
 #options 	RTC_OFFSET=0	# hardware clock is this many mins. west of GMT
 options 	NTP		# NTP phase/frequency locked loop
-options 	SYSVSHM		# System V-style shared memory
 options 	SYSVMSG		# System V-style message queues
 options 	SYSVSEM		# System V-style semaphores
+options 	SYSVSHM		# System V-style shared memory
 
 options 	MODULAR		# new style module(7) framework
 options 	MODULAR_DEFAULT_AUTOLOAD
@@ -159,7 +159,8 @@ options 	USELEDS		# make the lights twin
 options 	DIOVERBOSE	# recognize "unknown" DIO devices
 
 # workstation console options
-options 	WSEMUL_VT100# VT100 / VT220 emulation
+options 	WSEMUL_VT100			# VT100 / VT220 emulation
+#options 	WSDISPLAY_DEFAULTSCREENS=1
 options 	WSDISPLAY_COMPAT_USL		# wsconscfg VT handling
 options 	WSDISPLAY_COMPAT_RAWKBD
 options 	WS_KERNEL_FG=WSCOL_GREEN
@@ -180,6 +181,12 @@ intio0		at mainbus0		# internal i/o spac
 dio0		at mainbus0		# DIO/DIO-II bus
 sgc0		at mainbus0		# SGC bus
 
+# Real-time clock (not optional)
+rtc*		at intio?
+
+# DMA controller
+dma* 		at intio?
+
 # Human Interface Loop devices
 hil0		at intio?		# HIL controller
 hilkbd* 	at hil?			# keyboards
@@ -188,10 +195,8 @@ hilms*		at hil?			# mice, buttons and ta
 wsmouse*	at hilms? mux 0
 hilid*		at hil?			# ID module
 
-rtc*		at intio?		# real-time clock (not optional)
-dma* 		at intio?		# DMA controller
-frodo*		at intio?		# Frodo utility chip found on 382, 4xx
-nhpib*		at intio?		# slow internal HP-IB
+# Frodo utility chip found on 382, 4xx's
+frodo*		at intio?
 
 # 8250-like serial ports found on Frodo ASIC
 dnkbd0		at frodo? offset 0x0	# Domain keyboard flavor
@@ -202,32 +207,40 @@ com*		at frodo? offset ?	# tty flavor
 # mc146818-like real time clock found on 425e
 mcclock0	at frodo? offset 0x80
 
-dvbox*		at intio?		# Davinci framebuffer
+# Davinci framebuffer
+dvbox*		at intio?
 dvbox*		at dio? scode ?
 wsdisplay*	at dvbox?
 
-gbox*		at intio?		# Gatorbox framebuffer
+# Gatorbox framebuffer
+gbox*		at intio?
 gbox*		at dio? scode ?
 wsdisplay*	at gbox?
 
-hyper*		at dio? scode ?		# Hyperion framebuffer
+# Hyperion framebuffer
+hyper*		at dio? scode ?
 wsdisplay*	at hyper?
 
-rbox*		at intio?		# Renaissance framebuffer
+# Renaissance framebuffer
+rbox*		at intio?
 rbox*		at dio? scode ?
 wsdisplay*	at rbox?
 
-topcat*		at intio?		# Topcat/catseye framebuffers
+# Topcat/catseye framebuffers
+topcat*		at intio?
 topcat*		at dio? scode ?
 wsdisplay*	at topcat?
 
-tvrx*		at dio? scode ?		# TurboVRX framebuffer
+# TurboVRX framebuffer
+tvrx*		at dio? scode ?
 wsdisplay*	at tvrx?
 
-gendiofb*	at dio? scode ?		# dumb framebuffer support for 362/382
+# dumb framebuffer support for 362/382
+gendiofb*	at dio? scode ?
 wsdisplay*	at gendiofb?
 
-sti*		at sgc?	slot ?		# SGC EVRX framebuffers
+# STI framebuffers
+sti*		at sgc?	slot ?
 wsdisplay*	at sti?
 
 com0		at dio0 scode 9		# DCA serial interfaces
@@ -237,10 +250,12 @@ dcm*		at dio? scode ?	flags 0xe # DCM 4-
 
 le*		at dio? scode ?		# LANCE ethernet interfaces
 
-nhpib0		at dio? scode 7		# slow internal HP-IB
+# HP-IB devices
+nhpib*		at intio?		# internal HP-IB
+nhpib0		at dio? scode 7		# 98624A HP-IB
 nhpib*		at dio? scode ?
 
-fhpib*		at dio? scode ?		# `fast' HP-IB
+fhpib*		at dio? scode ?		# 98625A/98625B HP-IB
 
 hpibbus0	at nhpib0
 hpibbus*	at nhpib?
@@ -251,6 +266,7 @@ ct*		at hpibbus? slave ? punit ?	# HP-IB
 mt*		at hpibbus? slave ? punit ?	# HP-IB 9-track tape
 ppi0		at hpibbus0 slave 5 punit 0	# HP-IB plotter
 
+# SCSI devices
 spc*		at dio? scode ?			# HP 98265A SCSI
 scsibus*	at spc?
 
@@ -296,10 +312,10 @@ pseudo-device	agr			# IEEE 802.3ad link 
 

CVS commit: src/sys/arch/alpha

2021-05-29 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat May 29 22:14:09 UTC 2021

Modified Files:
src/sys/arch/alpha/alpha: pmap.c
src/sys/arch/alpha/include: pmap.h

Log Message:
Rather than tracking "needs I-sync on return to userspace" in a bitmap,
track it with a separate field in the pmap_percpu.  Not only does this
reduce cache line contention ever so slightly, it also frees up a field
in the shared portion of the pmap structure.


To generate a diff of this commit:
cvs rdiff -u -r1.279 -r1.280 src/sys/arch/alpha/alpha/pmap.c
cvs rdiff -u -r1.86 -r1.87 src/sys/arch/alpha/include/pmap.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/alpha/alpha/pmap.c
diff -u src/sys/arch/alpha/alpha/pmap.c:1.279 src/sys/arch/alpha/alpha/pmap.c:1.280
--- src/sys/arch/alpha/alpha/pmap.c:1.279	Sat May 29 21:54:50 2021
+++ src/sys/arch/alpha/alpha/pmap.c	Sat May 29 22:14:09 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.279 2021/05/29 21:54:50 thorpej Exp $ */
+/* $NetBSD: pmap.c,v 1.280 2021/05/29 22:14:09 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001, 2007, 2008, 2020
@@ -135,7 +135,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.279 2021/05/29 21:54:50 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.280 2021/05/29 22:14:09 thorpej Exp $");
 
 #include 
 #include 
@@ -862,8 +862,6 @@ pmap_tlb_invalidate(const struct pmap_tl
 	pmap_t const pmap = tlbctx->t_pmap;
 	KASSERT(pmap != NULL);
 
-	const u_long cpu_mask = 1UL << ci->ci_cpuid;
-
 	if (__predict_false(pmap != ci->ci_pmap)) {
 		TLB_COUNT(invalidate_user_not_current);
 
@@ -875,6 +873,8 @@ pmap_tlb_invalidate(const struct pmap_tl
 			return;
 		}
 
+		const u_long cpu_mask = 1UL << ci->ci_cpuid;
+
 		/*
 		 * We cannot directly invalidate the TLB in this case,
 		 * so force allocation of a new ASN when the pmap becomes
@@ -890,14 +890,14 @@ pmap_tlb_invalidate(const struct pmap_tl
 		 * of accounting for internal consistency.
 		 */
 		if (TLB_CTX_FLAGS(tlbctx) & TLB_CTX_F_IMB) {
-			atomic_or_ulong(>pm_needisync, cpu_mask);
+			pmap->pm_percpu[ci->ci_cpuid].pmc_needisync = 1;
 		}
 		return;
 	}
 
 	if (TLB_CTX_FLAGS(tlbctx) & TLB_CTX_F_IMB) {
 		TLB_COUNT(invalidate_user_lazy_imb);
-		atomic_or_ulong(>pm_needisync, cpu_mask);
+		pmap->pm_percpu[ci->ci_cpuid].pmc_needisync = 1;
 	}
 
 	if (count == TLB_CTX_ALLVA) {
@@ -3882,7 +3882,7 @@ pmap_asn_alloc(pmap_t const pmap, struct
 	 * We have a new ASN, so we can skip any pending I-stream sync
 	 * on the way back out to user space.
 	 */
-	atomic_and_ulong(>pm_needisync, ~(1UL << ci->ci_cpuid));
+	pmc->pmc_needisync = 0;
 
 #ifdef DEBUG
 	if (pmapdebug & PDB_ASN)

Index: src/sys/arch/alpha/include/pmap.h
diff -u src/sys/arch/alpha/include/pmap.h:1.86 src/sys/arch/alpha/include/pmap.h:1.87
--- src/sys/arch/alpha/include/pmap.h:1.86	Sat May 29 21:54:51 2021
+++ src/sys/arch/alpha/include/pmap.h	Sat May 29 22:14:09 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.h,v 1.86 2021/05/29 21:54:51 thorpej Exp $ */
+/* $NetBSD: pmap.h,v 1.87 2021/05/29 22:14:09 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001, 2007 The NetBSD Foundation, Inc.
@@ -135,17 +135,19 @@ struct pmap_percpu {
 	unsigned int		pmc_asn;	/* address space number */
 	unsigned int		pmc_pad0;
 	unsigned long		pmc_asngen;	/* ASN generation number */
-	unsigned long		pmc_padN[(COHERENCY_UNIT / 8) - 2];
+	unsigned int		pmc_needisync;	/* CPU needes isync */
+	unsigned int		pmc_pad1;
+	unsigned long		pmc_padN[(COHERENCY_UNIT / 8) - 3];
 };
 
 struct pmap {	/* pmaps are aligned to COHERENCY_UNIT boundaries */
 		/* pmaps are locked by hashed mutexes */
 	pt_entry_t		*pm_lev1map;	/* [ 0] level 1 map */
 	unsigned long		pm_cpus;	/* [ 8] CPUs using pmap */
-	unsigned long		pm_needisync;	/* [16] CPUs needing isync */
+	unsigned long		__pm_spare0;	/* [16] spare field */
 	struct pmap_statistics	pm_stats;	/* [32] statistics */
 	unsigned int		pm_count;	/* [40] reference count */
-	unsigned int		__pm_spare;	/* [44] spare field */
+	unsigned int		__pm_spare1;	/* [44] spare field */
 	TAILQ_ENTRY(pmap)	pm_list;	/* [48] list of all pmaps */
 	/* -- COHERENCY_UNIT boundary -- */
 	struct pmap_percpu	pm_percpu[];	/* [64] per-CPU data */
@@ -326,10 +328,10 @@ pmap_l3pte(pmap_t pmap, vaddr_t v, pt_en
  */
 #define	PMAP_USERRET(pmap)		\
 do {	\
-	u_long cpu_mask = (1UL << cpu_number());			\
+	const unsigned long cpu_id = cpu_number();			\
 	\
-	if ((pmap)->pm_needisync & cpu_mask) {\
-		atomic_and_ulong(&(pmap)->pm_needisync,	~cpu_mask);	\
+	if ((pmap)->pm_percpu[cpu_id].pmc_needisync) {			\
+		(pmap)->pm_percpu[cpu_id].pmc_needisync = 0;		\
 		alpha_pal_imb();	\
 	}\
 } while (0)



CVS commit: src/sys/arch/alpha

2021-05-29 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat May 29 21:54:51 UTC 2021

Modified Files:
src/sys/arch/alpha/alpha: pmap.c
src/sys/arch/alpha/include: pmap.h

Log Message:
Rename pmap_asn_info to pmap_percpu, and pmap::pm_asni to pmap::pm_percpu.
No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.278 -r1.279 src/sys/arch/alpha/alpha/pmap.c
cvs rdiff -u -r1.85 -r1.86 src/sys/arch/alpha/include/pmap.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/alpha/alpha/pmap.c
diff -u src/sys/arch/alpha/alpha/pmap.c:1.278 src/sys/arch/alpha/alpha/pmap.c:1.279
--- src/sys/arch/alpha/alpha/pmap.c:1.278	Mon May 24 03:43:24 2021
+++ src/sys/arch/alpha/alpha/pmap.c	Sat May 29 21:54:50 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.278 2021/05/24 03:43:24 thorpej Exp $ */
+/* $NetBSD: pmap.c,v 1.279 2021/05/29 21:54:50 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001, 2007, 2008, 2020
@@ -135,7 +135,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.278 2021/05/24 03:43:24 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.279 2021/05/29 21:54:50 thorpej Exp $");
 
 #include 
 #include 
@@ -265,9 +265,9 @@ static struct pool_cache pmap_pmap_cache
 static struct pool_cache pmap_l1pt_cache __read_mostly;
 static struct pool_cache pmap_pv_cache __read_mostly;
 
-CTASSERT(offsetof(struct pmap, pm_asni[0]) == COHERENCY_UNIT);
+CTASSERT(offsetof(struct pmap, pm_percpu[0]) == COHERENCY_UNIT);
 CTASSERT(PMAP_SIZEOF(ALPHA_MAXPROCS) < ALPHA_PGBYTES);
-CTASSERT(sizeof(struct pmap_asn_info) == COHERENCY_UNIT);
+CTASSERT(sizeof(struct pmap_percpu) == COHERENCY_UNIT);
 
 /*
  * Address Space Numbers.
@@ -880,7 +880,7 @@ pmap_tlb_invalidate(const struct pmap_tl
 		 * so force allocation of a new ASN when the pmap becomes
 		 * active again.
 		 */
-		pmap->pm_asni[ci->ci_cpuid].pma_asngen = PMAP_ASNGEN_INVALID;
+		pmap->pm_percpu[ci->ci_cpuid].pmc_asngen = PMAP_ASNGEN_INVALID;
 		atomic_and_ulong(>pm_cpus, ~cpu_mask);
 
 		/*
@@ -1580,8 +1580,8 @@ pmap_create(void)
 	 * when the pmap is activated.
 	 */
 	for (i = 0; i < pmap_ncpuids; i++) {
-		pmap->pm_asni[i].pma_asn = PMAP_ASN_KERNEL;
-		pmap->pm_asni[i].pma_asngen = PMAP_ASNGEN_INVALID;
+		pmap->pm_percpu[i].pmc_asn = PMAP_ASN_KERNEL;
+		pmap->pm_percpu[i].pmc_asngen = PMAP_ASNGEN_INVALID;
 	}
 
  try_again:
@@ -3814,7 +3814,7 @@ pmap_asn_alloc(pmap_t const pmap, struct
 	if (pmap_max_asn == 0)
 		return 0;
 
-	struct pmap_asn_info * const pma = >pm_asni[ci->ci_cpuid];
+	struct pmap_percpu * const pmc = >pm_percpu[ci->ci_cpuid];
 
 	/*
 	 * Hopefully, we can continue using the one we have...
@@ -3824,14 +3824,14 @@ pmap_asn_alloc(pmap_t const pmap, struct
 	 * the generation counter at 1, but initialize pmaps with
 	 * 0; this forces the first ASN allocation to occur.
 	 */
-	if (pma->pma_asngen == ci->ci_asn_gen) {
+	if (pmc->pmc_asngen == ci->ci_asn_gen) {
 #ifdef DEBUG
 		if (pmapdebug & PDB_ASN)
 			printf("pmap_asn_alloc: same generation, keeping %u\n",
-			pma->pma_asn);
+			pmc->pmc_asn);
 #endif
 		TLB_COUNT(asn_reuse);
-		return pma->pma_asn;
+		return pmc->pmc_asn;
 	}
 
 	/*
@@ -3874,8 +3874,8 @@ pmap_asn_alloc(pmap_t const pmap, struct
 	/*
 	 * Assign the new ASN and validate the generation number.
 	 */
-	pma->pma_asn = ci->ci_next_asn++;
-	pma->pma_asngen = ci->ci_asn_gen;
+	pmc->pmc_asn = ci->ci_next_asn++;
+	pmc->pmc_asngen = ci->ci_asn_gen;
 	TLB_COUNT(asn_assign);
 
 	/*
@@ -3887,7 +3887,7 @@ pmap_asn_alloc(pmap_t const pmap, struct
 #ifdef DEBUG
 	if (pmapdebug & PDB_ASN)
 		printf("pmap_asn_alloc: assigning %u to pmap %p\n",
-		pma->pma_asn, pmap);
+		pmc->pmc_asn, pmap);
 #endif
-	return pma->pma_asn;
+	return pmc->pmc_asn;
 }

Index: src/sys/arch/alpha/include/pmap.h
diff -u src/sys/arch/alpha/include/pmap.h:1.85 src/sys/arch/alpha/include/pmap.h:1.86
--- src/sys/arch/alpha/include/pmap.h:1.85	Mon May 24 03:43:24 2021
+++ src/sys/arch/alpha/include/pmap.h	Sat May 29 21:54:51 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.h,v 1.85 2021/05/24 03:43:24 thorpej Exp $ */
+/* $NetBSD: pmap.h,v 1.86 2021/05/29 21:54:51 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001, 2007 The NetBSD Foundation, Inc.
@@ -131,11 +131,11 @@
  * allocate any ASN info for the kernel pmap at all.
  * arrays which hold enough for ALPHA_MAXPROCS.
  */
-struct pmap_asn_info {
-	unsigned int		pma_asn;	/* address space number */
-	unsigned int		pma_pad0;
-	unsigned long		pma_asngen;	/* ASN generation number */
-	unsigned long		pma_padN[(COHERENCY_UNIT / 8) - 2];
+struct pmap_percpu {
+	unsigned int		pmc_asn;	/* address space number */
+	unsigned int		pmc_pad0;
+	unsigned long		pmc_asngen;	/* ASN generation number */
+	unsigned long		pmc_padN[(COHERENCY_UNIT / 8) - 2];
 };
 
 struct pmap {	/* pmaps are aligned to COHERENCY_UNIT boundaries */
@@ 

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

2021-05-29 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat May 29 21:08:44 UTC 2021

Modified Files:
src/sys/arch/hp300/conf: INSTALL

Log Message:
Reduce maxusers to 8 as GENERIC.

Should be pulled up to netbsd-9 and netbsd-8.


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 src/sys/arch/hp300/conf/INSTALL

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

Modified files:

Index: src/sys/arch/hp300/conf/INSTALL
diff -u src/sys/arch/hp300/conf/INSTALL:1.67 src/sys/arch/hp300/conf/INSTALL:1.68
--- src/sys/arch/hp300/conf/INSTALL:1.67	Sat May 29 21:06:20 2021
+++ src/sys/arch/hp300/conf/INSTALL	Sat May 29 21:08:44 2021
@@ -1,4 +1,4 @@
-# $NetBSD: INSTALL,v 1.67 2021/05/29 21:06:20 tsutsui Exp $
+# $NetBSD: INSTALL,v 1.68 2021/05/29 21:08:44 tsutsui Exp $
 #
 # INSTALL machine description file
 #
@@ -40,7 +40,7 @@ options 	HP433
 options 	FPSP		# floating point interface for 68040
 
 # Need to set locally
-maxusers	32
+maxusers	8
 
 # Standard system options
 #include 	"conf/compat_netbsd09.config"



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

2021-05-29 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat May 29 21:06:20 UTC 2021

Modified Files:
src/sys/arch/hp300/conf: INSTALL

Log Message:
Add missed 'nhpib at intio' for internal HP-IB.  Found on testing HPDisk.

Also fix comments for HP-IB devices.
Should be pulled up to netbsd-8 and netbsd-9.


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/sys/arch/hp300/conf/INSTALL

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

Modified files:

Index: src/sys/arch/hp300/conf/INSTALL
diff -u src/sys/arch/hp300/conf/INSTALL:1.66 src/sys/arch/hp300/conf/INSTALL:1.67
--- src/sys/arch/hp300/conf/INSTALL:1.66	Sat Dec 12 05:48:55 2020
+++ src/sys/arch/hp300/conf/INSTALL	Sat May 29 21:06:20 2021
@@ -1,4 +1,4 @@
-# $NetBSD: INSTALL,v 1.66 2020/12/12 05:48:55 tsutsui Exp $
+# $NetBSD: INSTALL,v 1.67 2021/05/29 21:06:20 tsutsui Exp $
 #
 # INSTALL machine description file
 #
@@ -183,10 +183,11 @@ dcm*		at dio? scode ?	flags 0xe # DCM 4-
 
 le*		at dio? scode ?		# LANCE ethernet interfaces
 
-nhpib0		at dio? scode 7		# slow internal HP-IB
+nhpib*		at intio?		# internal HP-IB
+nhpib0		at dio? scode 7		# 98624A HP-IB
 nhpib*		at dio? scode ?
 
-fhpib*		at dio? scode ?		# `fast' HP-IB
+fhpib*		at dio? scode ?		# 98625A/98625B HP-IB
 
 hpibbus0	at nhpib0
 hpibbus*	at nhpib?



CVS commit: src/sys/arch/mips

2021-05-29 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Sat May 29 12:35:27 UTC 2021

Modified Files:
src/sys/arch/mips/include: cpuregs.h
src/sys/arch/mips/mips: fp.S locore.S mips_emul.c mips_fpu.c
mips_fputrap.c

Log Message:
Update the FPU register names and bit definitions to something somewhat
modern (MIPS32/MIPS64) and convert to __BIT/__BITS.


To generate a diff of this commit:
cvs rdiff -u -r1.110 -r1.111 src/sys/arch/mips/include/cpuregs.h
cvs rdiff -u -r1.57 -r1.58 src/sys/arch/mips/mips/fp.S
cvs rdiff -u -r1.227 -r1.228 src/sys/arch/mips/mips/locore.S
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/mips/mips/mips_emul.c
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/mips/mips/mips_fpu.c
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/mips/mips/mips_fputrap.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/mips/include/cpuregs.h
diff -u src/sys/arch/mips/include/cpuregs.h:1.110 src/sys/arch/mips/include/cpuregs.h:1.111
--- src/sys/arch/mips/include/cpuregs.h:1.110	Wed Mar 17 11:05:37 2021
+++ src/sys/arch/mips/include/cpuregs.h	Sat May 29 12:35:27 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpuregs.h,v 1.110 2021/03/17 11:05:37 simonb Exp $	*/
+/*	$NetBSD: cpuregs.h,v 1.111 2021/05/29 12:35:27 simonb Exp $	*/
 
 /*
  * Copyright (c) 2009 Miodrag Vallat.
@@ -704,40 +704,41 @@
 /*
  * The floating point version and status registers.
  */
-#define	MIPS_FPU_ID	$0
-#define	MIPS_FPU_CSR	$31
+#define	MIPS_FIR	$0	/* FP Implementation and Revision Register */
+#define	MIPS_FCSR	$31	/* FP Control/Status Register */
 
 /*
  * The floating point coprocessor status register bits.
  */
-#define	MIPS_FPU_ROUNDING_BITS		0x0003
-#define	MIPS_FPU_ROUND_RN		0x
-#define	MIPS_FPU_ROUND_RZ		0x0001
-#define	MIPS_FPU_ROUND_RP		0x0002
-#define	MIPS_FPU_ROUND_RM		0x0003
-#define	MIPS_FPU_STICKY_BITS		0x007c
-#define	MIPS_FPU_STICKY_INEXACT		0x0004
-#define	MIPS_FPU_STICKY_UNDERFLOW	0x0008
-#define	MIPS_FPU_STICKY_OVERFLOW	0x0010
-#define	MIPS_FPU_STICKY_DIV0		0x0020
-#define	MIPS_FPU_STICKY_INVALID		0x0040
-#define	MIPS_FPU_ENABLE_BITS		0x0f80
-#define	MIPS_FPU_ENABLE_INEXACT		0x0080
-#define	MIPS_FPU_ENABLE_UNDERFLOW	0x0100
-#define	MIPS_FPU_ENABLE_OVERFLOW	0x0200
-#define	MIPS_FPU_ENABLE_DIV0		0x0400
-#define	MIPS_FPU_ENABLE_INVALID		0x0800
-#define	MIPS_FPU_EXCEPTION_BITS		0x0003f000
-#define	MIPS_FPU_EXCEPTION_INEXACT	0x1000
-#define	MIPS_FPU_EXCEPTION_UNDERFLOW	0x2000
-#define	MIPS_FPU_EXCEPTION_OVERFLOW	0x4000
-#define	MIPS_FPU_EXCEPTION_DIV0		0x8000
-#define	MIPS_FPU_EXCEPTION_INVALID	0x0001
-#define	MIPS_FPU_EXCEPTION_UNIMPL	0x0002
-#define	MIPS_FPU_COND_BIT		0x0080
-#define	MIPS_FPU_FLUSH_BIT		0x0100	/* r4k,	 MBZ on r3k */
-#define	MIPS1_FPC_MBZ_BITS		0xff7c
-#define	MIPS3_FPC_MBZ_BITS		0xfe7c
+#define	MIPS_FCSR_RM		__BITS(1,0)
+#define	  MIPS_FCSR_RM_RN	  0	/* round to nearest */
+#define	  MIPS_FCSR_RM_RZ	  1	/* round toward zerO */
+#define	  MIPS_FCSR_RM_RP	  2	/* round towards +infinity */
+#define	  MIPS_FCSR_RM_RM	  3	/* round towards -infinity */
+#define	MIPS_FCSR_FLAGS		__BITS(6,2)
+#define	  MIPS_FCSR_FLAGS_I	  __BIT(2)	/* inexact */
+#define	  MIPS_FCSR_FLAGS_U	  __BIT(3)	/* underflow */
+#define	  MIPS_FCSR_FLAGS_O	  __BIT(4)	/* overflow */
+#define	  MIPS_FCSR_FLAGS_Z	  __BIT(5)	/* divide by zero */
+#define	  MIPS_FCSR_FLAGS_V	  __BIT(6)	/* invalid operation */
+#define	MIPS_FCSR_ENABLES	__BITS(11,7)
+#define	  MIPS_FCSR_ENABLES_I	  __BIT(7)	/* inexact */
+#define	  MIPS_FCSR_ENABLES_U	  __BIT(8)	/* underflow */
+#define	  MIPS_FCSR_ENABLES_O	  __BIT(9)	/* overflow */
+#define	  MIPS_FCSR_ENABLES_Z	  __BIT(10)	/* divide by zero */
+#define	  MIPS_FCSR_ENABLES_V	  __BIT(11)	/* invalid operation */
+#define	MIPS_FCSR_CAUSE		__BITS(17,12)
+#define	  MIPS_FCSR_CAUSE_I	  __BIT(12)	/* inexact */
+#define	  MIPS_FCSR_CAUSE_U	  __BIT(13)	/* underflow */
+#define	  MIPS_FCSR_CAUSE_O	  __BIT(14)	/* overflow */
+#define	  MIPS_FCSR_CAUSE_Z	  __BIT(15)	/* divide by zero */
+#define	  MIPS_FCSR_CAUSE_V	  __BIT(16)	/* invalid operation */
+#define	  MIPS_FCSR_CAUSE_E	  __BIT(17)	/* unimplemented operation */
+#define	MIPS_FCSR_NAN_2008	__BIT(18)
+#define	MIPS_FCSR_ABS_2008	__BIT(19)
+#define	MIPS_FCSR_FCC0		__BIT(23)
+#define	MIPS_FCSR_FCC		(MIPS_FPU_COND_BIT | __BITS(31,25))
+#define	MIPS_FCSR_FS		__BIT(24)	/* r4k+ */
 
 
 /*

Index: src/sys/arch/mips/mips/fp.S
diff -u src/sys/arch/mips/mips/fp.S:1.57 src/sys/arch/mips/mips/fp.S:1.58
--- src/sys/arch/mips/mips/fp.S:1.57	Mon May 24 07:27:39 2021
+++ src/sys/arch/mips/mips/fp.S	Sat May 29 12:35:27 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: fp.S,v 1.57 2021/05/24 07:27:39 simonb Exp $	*/
+/*	$NetBSD: fp.S,v 1.58 2021/05/29 12:35:27 simonb Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -143,10 +143,10 @@ NESTED(mips_emul_fp, CALLFRAME_SIZ, ra)
 	PTR_L	a3, 

CVS commit: src/sys/arch/atari/stand/keymaps

2021-05-29 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat May 29 09:50:04 UTC 2021

Modified Files:
src/sys/arch/atari/stand/keymaps: Makefile.inc
src/sys/arch/atari/stand/keymaps/de: de-kbdmap.c
src/sys/arch/atari/stand/keymaps/fr: fr-kbdmap.c
src/sys/arch/atari/stand/keymaps/uk: uk-kbdmap.c
src/sys/arch/atari/stand/keymaps/us: us-kbdmap.c

Log Message:
Appease compiler warnings derived from ancient HOST files.  PR/56187

Also fix misc styles and formats per KNF.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/atari/stand/keymaps/Makefile.inc
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/atari/stand/keymaps/de/de-kbdmap.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/atari/stand/keymaps/fr/fr-kbdmap.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/atari/stand/keymaps/uk/uk-kbdmap.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/atari/stand/keymaps/us/us-kbdmap.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/atari/stand/keymaps/Makefile.inc
diff -u src/sys/arch/atari/stand/keymaps/Makefile.inc:1.7 src/sys/arch/atari/stand/keymaps/Makefile.inc:1.8
--- src/sys/arch/atari/stand/keymaps/Makefile.inc:1.7	Sat May  4 21:56:50 2002
+++ src/sys/arch/atari/stand/keymaps/Makefile.inc	Sat May 29 09:50:04 2021
@@ -1,4 +1,8 @@
-# $NetBSD: Makefile.inc,v 1.7 2002/05/04 21:56:50 bjh21 Exp $
+# $NetBSD: Makefile.inc,v 1.8 2021/05/29 09:50:04 tsutsui Exp $
+
+.include 
+
+#HOST_CFLAGS+=	-Wall -Werror
 
 realall: ${MAP}
 

Index: src/sys/arch/atari/stand/keymaps/de/de-kbdmap.c
diff -u src/sys/arch/atari/stand/keymaps/de/de-kbdmap.c:1.3 src/sys/arch/atari/stand/keymaps/de/de-kbdmap.c:1.4
--- src/sys/arch/atari/stand/keymaps/de/de-kbdmap.c:1.3	Wed Mar 18 10:22:25 2009
+++ src/sys/arch/atari/stand/keymaps/de/de-kbdmap.c	Sat May 29 09:50:04 2021
@@ -1,172 +1,179 @@
-/*	$NetBSD: de-kbdmap.c,v 1.3 2009/03/18 10:22:25 cegger Exp $	*/
+/*	$NetBSD: de-kbdmap.c,v 1.4 2021/05/29 09:50:04 tsutsui Exp $	*/
 
 /*
  * Contributed by Thomas Gerner
  */
 
+#if !defined(_KERNEL)
+#include 
+#include 
+#endif
+
 #include "../../../dev/kbdmap.h"
 
 /* mode shortcuts: */
 #define	S KBD_MODE_STRING
-#define C KBD_MODE_CAPS
-#define K KBD_MODE_KPAD
+#define	C KBD_MODE_CAPS
+#define	K KBD_MODE_KPAD
 
 struct kbdmap kbdmap;
 struct kbdmap ascii_kbdmap = {
 	/* normal map */
 	{
-/* 0x00 */	0, 0,		0, ESC,		0, '1',		0, '2',
-/* 0x04 */	0, '3',		0, '4',		0, '5',		0, '6',
-/* 0x08 */	0, '7',		0, '8',		0, '9',		0, '0',
-/* 0x0c */	C, 0xDF,	0, '\'',	0, '\b',	0, '\t',
-/* 0x10	*/	C, 'q',		C, 'w',		C, 'e',		C, 'r',
-/* 0x14 */	C, 't',		C, 'z',		C, 'u',		C, 'i',
-/* 0x18 */	C, 'o',		C, 'p',		C, 0xFC,	0, '+',
-/* 0x1c */	0, '\r',	0, 0,		C, 'a',		C, 's',
-/* 0x20 */	C, 'd',		C, 'f',		C, 'g',		C, 'h',
-/* 0x24 */	C, 'j',		C, 'k',		C, 'l',		C, 0xF6,
-/* 0x28 */	C, 0xE4,	0, '#',		0, 0,		0, '~',
-/* 0x2c */	C, 'y',		C, 'x',		C, 'c',		C, 'v',
-/* 0x30 */	C, 'b',		C, 'n',		C, 'm',		0, ',',
-/* 0x34 */	0, '.',		0, '-',		0, 0,		0, 0,
-/* 0x38 */	0, 0,		0, ' ',		0, 0,		S, 0x10,
-/* 0x3c */	S, 0x15,	S, 0x1A,	S, 0x1F,	S, 0x24,
-/* 0x40 */	S, 0x29,	S, 0x2E,	S, 0x33,	S, 0x38,
-/* 0x44 */	S, 0x3D,	0, 0,		0, 0,		0, 0,
-/* 0x48 */	S, 0x00,	0, 0,		0, '-',		S, 0x0C,
-/* 0x4c */	0, 0,		S, 0x08,	0, '+',		0, 0,
-/* 0x50 */	S, 0x04,	0, 0,		0, 0,		0, DEL,
-/* 0x54 */	0, 0,		0, 0,		0, 0,		0, 0,
-/* 0x58 */	0, 0,		0, 0,		0, 0,		0, 0,
-/* 0x5c */	0, 0,		0, 0,		0, 0,		0, 0,
+/* 0x00 */	{ 0, 0 },	{ 0, ESC },	{ 0, '1' },	{ 0, '2' },
+/* 0x04 */	{ 0, '3' },	{ 0, '4' },	{ 0, '5' },	{ 0, '6' },
+/* 0x08 */	{ 0, '7' },	{ 0, '8' },	{ 0, '9' },	{ 0, '0' },
+/* 0x0C */	{ C, 0xDF },	{ 0, '\'' },	{ 0, '\b' },	{ 0, '\t' },
+/* 0x10 */	{ C, 'q' },	{ C, 'w' },	{ C, 'e' },	{ C, 'r' },
+/* 0x14 */	{ C, 't' },	{ C, 'z' },	{ C, 'u' },	{ C, 'i' },
+/* 0x18 */	{ C, 'o' },	{ C, 'p' },	{ C, 0xFC },	{ 0, '+' },
+/* 0x1C */	{ 0, '\r' },	{ 0, 0 },	{ C, 'a' },	{ C, 's' },
+/* 0x20 */	{ C, 'd' },	{ C, 'f' },	{ C, 'g' },	{ C, 'h' },
+/* 0x24 */	{ C, 'j' },	{ C, 'k' },	{ C, 'l' },	{ C, 0xF6 },
+/* 0x28 */	{ C, 0xE4 },	{ 0, '#' },	{ 0, 0 },	{ 0, '~' },
+/* 0x2C */	{ C, 'y' },	{ C, 'x' },	{ C, 'c' },	{ C, 'v' },
+/* 0x30 */	{ C, 'b' },	{ C, 'n' },	{ C, 'm' },	{ 0, ',' },
+/* 0x34 */	{ 0, '.' },	{ 0, '-' },	{ 0, 0 },	{ 0, 0 },
+/* 0x38 */	{ 0, 0 },	{ 0, ' ' },	{ 0, 0 },	{ S, 0x10 },
+/* 0x3C */	{ S, 0x15 },	{ S, 0x1A },	{ S, 0x1F },	{ S, 0x24 },
+/* 0x40 */	{ S, 0x29 },	{ S, 0x2E },	{ S, 0x33 },	{ S, 0x38 },
+/* 0x44 */	{ S, 0x3D },	{ 0, 0 },	{ 0, 0 },	{ 0, 0 },
+/* 0x48 */	{ S, 0x00 },	{ 0, 0 },	{ 0, '-' },	{ S, 0x0C },
+/* 0x4C */	{ 0, 0 },	{ S, 0x08 },	{ 0, '+' },	{ 0, 0 },
+/* 0x50 */	{ S, 0x04 },	{ 0, 0 },	{ 0, 0 },	{ 0, DEL },
+/* 0x54 */	{ 0, 0 },	{ 0, 0 },	{ 0, 0 },	{ 0, 0 },
+/* 0x58 */	{ 0, 0 },	{ 0, 0 },	{ 0, 0 },	{ 0, 0 },
+/* 0x5C */	{ 0, 0 },	{ 0, 0 },	{ 0, 0 },	{ 0, 0 },
 /* 0x60 */
-/* 0x60 */	0, '<',		0, 0,		0, 0,		0, '(',
-/* 0x64 */	0, ')',		0, '/',		0, '*',	

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

2021-05-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat May 29 09:47:28 UTC 2021

Modified Files:
src/sys/arch/x86/pci: dwiic_pci.c

Log Message:
dwiic(4): Attribute output correctly and relegate to debug-level.

Tidy up a little while here.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/x86/pci/dwiic_pci.c

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

Modified files:

Index: src/sys/arch/x86/pci/dwiic_pci.c
diff -u src/sys/arch/x86/pci/dwiic_pci.c:1.4 src/sys/arch/x86/pci/dwiic_pci.c:1.5
--- src/sys/arch/x86/pci/dwiic_pci.c:1.4	Sat Apr 24 23:36:51 2021
+++ src/sys/arch/x86/pci/dwiic_pci.c	Sat May 29 09:47:28 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: dwiic_pci.c,v 1.4 2021/04/24 23:36:51 thorpej Exp $ */
+/* $NetBSD: dwiic_pci.c,v 1.5 2021/05/29 09:47:28 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dwiic_pci.c,v 1.4 2021/04/24 23:36:51 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dwiic_pci.c,v 1.5 2021/05/29 09:47:28 riastradh Exp $");
 
 #include 
 #include 
@@ -68,9 +68,8 @@ struct pci_dwiic_softc {
 static uint32_t
 lpss_read(struct pci_dwiic_softc *sc, int offset)
 {
-	u_int32_t b = bus_space_read_4(sc->sc_dwiic.sc_iot, sc->sc_dwiic.sc_ioh,
-	 offset);
-	return b;
+	return bus_space_read_4(sc->sc_dwiic.sc_iot, sc->sc_dwiic.sc_ioh,
+	offset);
 }
 
 static void
@@ -169,7 +168,7 @@ pci_dwiic_attach(device_t parent, device
 	pa->pa_bus, pa->pa_device, pa->pa_function);
 
 	if (sc->sc_acpinode) {
-		sc->sc_dwiic.sc_iba.iba_child_devices = 
+		sc->sc_dwiic.sc_iba.iba_child_devices =
 		acpi_enter_i2c_devs(NULL, sc->sc_acpinode);
 	} else {
 		aprint_verbose_dev(self, "no matching ACPI node\n");
@@ -188,13 +187,18 @@ out:
 static bool
 dwiic_pci_power(struct dwiic_softc *dwsc, bool power)
 {
-	struct pci_dwiic_softc *sc = (void *)dwsc;
-	pcireg_t pmreg;
-
-	printf("status 0x%x\n", pci_conf_read(sc->sc_pc, sc->sc_ptag, PCI_COMMAND_STATUS_REG));
-	printf("reset 0x%x\n", lpss_read(sc, LPSS_RESET));
-	printf("rlo 0x%x\n", lpss_read(sc, LPSS_REMAP_LO));
-	printf("rho 0x%x\n", lpss_read(sc, LPSS_REMAP_HI));
+	struct pci_dwiic_softc *sc = container_of(dwsc, struct pci_dwiic_softc,
+	sc_dwiic);
+	pcireg_t pmreg, csr;
+	uint32_t reset, rlo, rhi;
+
+	csr = pci_conf_read(sc->sc_pc, sc->sc_ptag, PCI_COMMAND_STATUS_REG);
+	reset = lpss_read(sc, LPSS_RESET);
+	rlo = lpss_read(sc, LPSS_REMAP_LO);
+	rhi = lpss_read(sc, LPSS_REMAP_HI);
+	aprint_debug_dev(dwsc->sc_dev,
+	"status 0x%x reset 0x%x rlo 0x%x rhi 0x%x\n",
+	csr, reset, rlo, rhi);
 
 	if (!power)
 		lpss_write(sc, LPSS_CLKGATE, LPSS_CLKGATE_CTRL_OFF);
@@ -205,7 +209,7 @@ dwiic_pci_power(struct dwiic_softc *dwsc
 		pci_conf_write(sc->sc_pc, sc->sc_ptag, pmreg + PCI_PMCSR,
 		power ? PCI_PMCSR_STATE_D0 : PCI_PMCSR_STATE_D3);
 		DELAY(1); /* 10 milliseconds */
-		DPRINTF((" -> 0x%x\n", 
+		DPRINTF((" -> 0x%x\n",
 		pci_conf_read(sc->sc_pc, sc->sc_ptag, pmreg + PCI_PMCSR)));
 	}
 	if (power) {



CVS commit: src/sys/arch/aarch64

2021-05-29 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat May 29 06:54:20 UTC 2021

Modified Files:
src/sys/arch/aarch64/aarch64: pmap.c
src/sys/arch/aarch64/include: cpu.h

Log Message:
Deal with the pmap limitation of maxproc in a more complete way and
recognise CPUs with only 8bit ASIDs.


To generate a diff of this commit:
cvs rdiff -u -r1.107 -r1.108 src/sys/arch/aarch64/aarch64/pmap.c
cvs rdiff -u -r1.35 -r1.36 src/sys/arch/aarch64/include/cpu.h

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

Modified files:

Index: src/sys/arch/aarch64/aarch64/pmap.c
diff -u src/sys/arch/aarch64/aarch64/pmap.c:1.107 src/sys/arch/aarch64/aarch64/pmap.c:1.108
--- src/sys/arch/aarch64/aarch64/pmap.c:1.107	Fri Apr 30 20:07:22 2021
+++ src/sys/arch/aarch64/aarch64/pmap.c	Sat May 29 06:54:20 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.107 2021/04/30 20:07:22 skrll Exp $	*/
+/*	$NetBSD: pmap.c,v 1.108 2021/05/29 06:54:20 skrll Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.107 2021/04/30 20:07:22 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.108 2021/05/29 06:54:20 skrll Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_ddb.h"
@@ -554,6 +554,10 @@ pmap_init(void)
 	pool_cache_bootstrap(&_pmap_pv_pool, sizeof(struct pv_entry),
 	32, 0, PR_LARGECACHE, "pvpl", NULL, IPL_NONE, _pmap_pv_ctor,
 	NULL, NULL);
+
+	int nmaxproc = cpu_maxproc();
+	if (maxproc > nmaxproc)
+		maxproc = nmaxproc;
 }
 
 void
@@ -1420,12 +1424,6 @@ pmap_protect(struct pmap *pm, vaddr_t sv
 	pm_unlock(pm);
 }
 
-/* XXX: due to the current implementation of pmap depends on 16bit ASID */
-int
-cpu_maxproc(void)
-{
-	return 65535;
-}
 
 void
 pmap_activate(struct lwp *l)

Index: src/sys/arch/aarch64/include/cpu.h
diff -u src/sys/arch/aarch64/include/cpu.h:1.35 src/sys/arch/aarch64/include/cpu.h:1.36
--- src/sys/arch/aarch64/include/cpu.h:1.35	Sat May 29 06:37:21 2021
+++ src/sys/arch/aarch64/include/cpu.h	Sat May 29 06:54:20 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.h,v 1.35 2021/05/29 06:37:21 skrll Exp $ */
+/* $NetBSD: cpu.h,v 1.36 2021/05/29 06:54:20 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014, 2020 The NetBSD Foundation, Inc.
@@ -149,7 +149,22 @@ static __inline struct cpu_info *lwp_get
 #undef curlwp
 #define	curlwp			(aarch64_curlwp())
 
-int	cpu_maxproc(void);
+static inline int
+cpu_maxproc(void)
+{
+	/*
+	 * the pmap uses PID for ASID.
+	 */
+	switch (__SHIFTOUT(reg_id_aa64mmfr0_el1_read(), ID_AA64MMFR0_EL1_ASIDBITS)) {
+	case ID_AA64MMFR0_EL1_ASIDBITS_8BIT:
+		return (1U << 8) - 1;
+	case ID_AA64MMFR0_EL1_ASIDBITS_16BIT:
+		return (1U << 16) - 1;
+	default:
+		return 0;
+	}
+}
+
 void	cpu_signotify(struct lwp *l);
 void	cpu_need_proftick(struct lwp *l);
 



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

2021-05-29 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat May 29 06:37:22 UTC 2021

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

Log Message:
Sort includes. NFCI.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/aarch64/include/cpu.h

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

Modified files:

Index: src/sys/arch/aarch64/include/cpu.h
diff -u src/sys/arch/aarch64/include/cpu.h:1.34 src/sys/arch/aarch64/include/cpu.h:1.35
--- src/sys/arch/aarch64/include/cpu.h:1.34	Sat Mar 27 12:15:09 2021
+++ src/sys/arch/aarch64/include/cpu.h	Sat May 29 06:37:21 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.h,v 1.34 2021/03/27 12:15:09 jmcneill Exp $ */
+/* $NetBSD: cpu.h,v 1.35 2021/05/29 06:37:21 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014, 2020 The NetBSD Foundation, Inc.
@@ -45,8 +45,8 @@
 #if defined(_KERNEL) || defined(_KMEMUSER)
 #include 
 
-#include 
 #include 
+#include 
 
 struct clockframe {
 	struct trapframe cf_tf;



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

2021-05-28 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sat May 29 02:58:38 UTC 2021

Modified Files:
src/sys/arch/sparc/sparc: cpu.c

Log Message:
report to the scheduler if we have different speed cpus.


To generate a diff of this commit:
cvs rdiff -u -r1.259 -r1.260 src/sys/arch/sparc/sparc/cpu.c

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

Modified files:

Index: src/sys/arch/sparc/sparc/cpu.c
diff -u src/sys/arch/sparc/sparc/cpu.c:1.259 src/sys/arch/sparc/sparc/cpu.c:1.260
--- src/sys/arch/sparc/sparc/cpu.c:1.259	Sun Jan 24 07:36:54 2021
+++ src/sys/arch/sparc/sparc/cpu.c	Sat May 29 02:58:37 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.259 2021/01/24 07:36:54 mrg Exp $ */
+/*	$NetBSD: cpu.c,v 1.260 2021/05/29 02:58:37 mrg Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -52,7 +52,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.259 2021/01/24 07:36:54 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.260 2021/05/29 02:58:37 mrg Exp $");
 
 #include "opt_multiprocessor.h"
 #include "opt_lockdebug.h"
@@ -520,6 +520,19 @@ cpu_attach(struct cpu_softc *sc, int nod
 	 */
 	if (bootmid == 0)
 		bootmid = mid;
+
+	/*
+	 * Set speeds now we've attached all CPUs.
+	 */
+	if (sparc_ncpus > 1 && sparc_ncpus == cpu_attach_count) {
+		CPU_INFO_ITERATOR n;
+		unsigned best_hz = 0;
+
+		for (CPU_INFO_FOREACH(n, cpi))
+			best_hz = MAX(cpi->hz, best_hz);
+		for (CPU_INFO_FOREACH(n, cpi))
+			cpu_topology_setspeed(cpi, cpi->hz < best_hz);
+	}
 }
 
 /*



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

2021-05-28 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri May 28 07:33:02 UTC 2021

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

Log Message:
 Add ixg* (commented out). Tested with rin@'s AlphaServer DS10.


To generate a diff of this commit:
cvs rdiff -u -r1.410 -r1.411 src/sys/arch/alpha/conf/GENERIC

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

Modified files:

Index: src/sys/arch/alpha/conf/GENERIC
diff -u src/sys/arch/alpha/conf/GENERIC:1.410 src/sys/arch/alpha/conf/GENERIC:1.411
--- src/sys/arch/alpha/conf/GENERIC:1.410	Mon Sep 28 03:30:47 2020
+++ src/sys/arch/alpha/conf/GENERIC	Fri May 28 07:33:02 2021
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.410 2020/09/28 03:30:47 thorpej Exp $
+# $NetBSD: GENERIC,v 1.411 2021/05/28 07:33:02 msaitoh Exp $
 #
 # This machine description file is used to generate the default NetBSD
 # kernel.
@@ -19,7 +19,7 @@ include 	"arch/alpha/conf/std.alpha"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-ident		"GENERIC-$Revision: 1.410 $"
+ident		"GENERIC-$Revision: 1.411 $"
 
 maxusers 32
 
@@ -311,6 +311,7 @@ fxp*	at	pci? dev ? function ?		# Intel E
 gsip*	at	pci? dev ? function ?		# NS DP83820 Gigabit Ethernet
 iha*	at	pci? dev ? function ?		# Initio INIC-940/950 SCSI
 isp*	at	pci? dev ? function ?		# Qlogic ISP 10x0 SCSI
+#ixg*	at	pci? dev ? function ?		# Intel 8259x 10G Ethernet
 pcn*	at	pci? dev ? function ?		# PCnet-PCI Ethernet
 sf*	at	pci? dev ? function ?		# Adaptec AIC-6915 Ethernet
 siop*	at	pci? dev ? function ?		# Symbios 53c8xx SCSI



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

2021-05-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri May 28 05:42:07 UTC 2021

Modified Files:
src/sys/arch/emips/include: types.h

Log Message:
G/C


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/emips/include/types.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/emips/include/types.h
diff -u src/sys/arch/emips/include/types.h:1.3 src/sys/arch/emips/include/types.h:1.4
--- src/sys/arch/emips/include/types.h:1.3	Thu Apr  1 04:35:45 2021
+++ src/sys/arch/emips/include/types.h	Fri May 28 05:42:06 2021
@@ -1,11 +1,9 @@
-/*	$NetBSD: types.h,v 1.3 2021/04/01 04:35:45 simonb Exp $	*/
+/*	$NetBSD: types.h,v 1.4 2021/05/28 05:42:06 skrll Exp $	*/
 
 #include 
 
 #define	__HAVE_DEVICE_REGISTER
 #define	__HAVE_GENERIC_SOFT_INTERRUPTS
-/* We'll use the FreeRunning counter everywhere */
-#define	__HAVE_TIMECOUNTER
 
 /* MIPS specific options */
 #define	__HAVE_BOOTINFO_H



CVS commit: src/sys/arch/mips

2021-05-27 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Fri May 28 00:18:27 UTC 2021

Modified Files:
src/sys/arch/mips: README.models

Log Message:
Update R6000 description.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/mips/README.models

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

Modified files:

Index: src/sys/arch/mips/README.models
diff -u src/sys/arch/mips/README.models:1.6 src/sys/arch/mips/README.models:1.7
--- src/sys/arch/mips/README.models:1.6	Sat Aug 15 05:41:57 2020
+++ src/sys/arch/mips/README.models	Fri May 28 00:18:27 2021
@@ -1,4 +1,4 @@
-# $NetBSD: README.models,v 1.6 2020/08/15 05:41:57 mrg Exp $
+# $NetBSD: README.models,v 1.7 2021/05/28 00:18:27 simonb Exp $
 
 MIPS models and architecture levels
 ---
@@ -51,7 +51,7 @@ which have model numbers with fewer zero
 	R4400		MIPS-III (64-bit)	[idt96 A-197]
 	R4600		MIPS-III (64-bit)	[idt96 A-197]
 	R5000		MIPS-IV (64-bit)	[idt96 1-5]
-	R6000		MIPS-II ??
+	R6000		MIPS-II (32-bit) with 64-bit FPU regs
 	R8000		MIPS-IV (64-bit)	[idt96 1-5]
 	R1		MIPS-IV (64-bit)	[idt96 1-5]
 	R1x000		MIPS-IV (64-bit)



CVS commit: src/sys/arch/alpha

2021-05-27 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Thu May 27 22:11:31 UTC 2021

Modified Files:
src/sys/arch/alpha/include: pci_machdep.h
src/sys/arch/alpha/pci: tsc.c tsp_dma.c tsreg.h tsvar.h

Log Message:
The Tsunami / Typhoon chipsets have a static "monster window" for DMA
that allows for up to 32GB of RAM to be direct-mapped if the PCI device
can issue a 64-bit address (the monster window lives at 0x100).
Enable this window and provide this to the PCI bus as a "dmat64".


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/alpha/include/pci_machdep.h
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/alpha/pci/tsc.c
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/alpha/pci/tsp_dma.c
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/alpha/pci/tsreg.h
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/alpha/pci/tsvar.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/alpha/include/pci_machdep.h
diff -u src/sys/arch/alpha/include/pci_machdep.h:1.21 src/sys/arch/alpha/include/pci_machdep.h:1.22
--- src/sys/arch/alpha/include/pci_machdep.h:1.21	Sat Sep 26 21:07:48 2020
+++ src/sys/arch/alpha/include/pci_machdep.h	Thu May 27 22:11:31 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pci_machdep.h,v 1.21 2020/09/26 21:07:48 thorpej Exp $ */
+/* $NetBSD: pci_machdep.h,v 1.22 2021/05/27 22:11:31 thorpej Exp $ */
 
 /*
  * Copyright (c) 1996 Carnegie-Mellon University.
@@ -36,6 +36,7 @@
  * Machine-specific definitions for PCI autoconfiguration.
  */
 #define	__HAVE_PCIIDE_MACHDEP_COMPAT_INTR_ESTABLISH
+#define	_PCI_HAVE_DMA64
 
 /*
  * Types provided to machine-independent PCI code

Index: src/sys/arch/alpha/pci/tsc.c
diff -u src/sys/arch/alpha/pci/tsc.c:1.25 src/sys/arch/alpha/pci/tsc.c:1.26
--- src/sys/arch/alpha/pci/tsc.c:1.25	Sat Apr 24 23:36:23 2021
+++ src/sys/arch/alpha/pci/tsc.c	Thu May 27 22:11:31 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: tsc.c,v 1.25 2021/04/24 23:36:23 thorpej Exp $ */
+/* $NetBSD: tsc.c,v 1.26 2021/05/27 22:11:31 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1999 by Ross Harvey.  All rights reserved.
@@ -35,7 +35,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: tsc.c,v 1.25 2021/04/24 23:36:23 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tsc.c,v 1.26 2021/05/27 22:11:31 thorpej Exp $");
 
 #include 
 #include 
@@ -231,7 +231,7 @@ tspattach(device_t parent, device_t self
 	pba.pba_memt = >pc_memt;
 	pba.pba_dmat =
 	alphabus_dma_get_tag(>pc_dmat_direct, ALPHA_BUS_PCI);
-	pba.pba_dmat64 = NULL;
+	pba.pba_dmat64 = >pc_dmat64_direct;
 	pba.pba_pc = >pc_pc;
 	pba.pba_bus = 0;
 	pba.pba_bridgetag = NULL;

Index: src/sys/arch/alpha/pci/tsp_dma.c
diff -u src/sys/arch/alpha/pci/tsp_dma.c:1.16 src/sys/arch/alpha/pci/tsp_dma.c:1.17
--- src/sys/arch/alpha/pci/tsp_dma.c:1.16	Wed May  5 02:15:18 2021
+++ src/sys/arch/alpha/pci/tsp_dma.c	Thu May 27 22:11:31 2021
@@ -1,4 +1,34 @@
-/* $NetBSD: tsp_dma.c,v 1.16 2021/05/05 02:15:18 thorpej Exp $ */
+/* $NetBSD: tsp_dma.c,v 1.17 2021/05/27 22:11:31 thorpej Exp $ */
+
+/*-
+ * Copyright (c) 1997, 1998, 2021 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
+ * NASA Ames Research Center.
+ *
+ * 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.
+ */
 
 /*-
  * Copyright (c) 1999 by Ross Harvey.  All rights reserved.
@@ -28,41 +58,10 @@
  * 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.
- *
- */
-
-/*-
- * Copyright (c) 1997, 1998 The NetBSD 

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

2021-05-27 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Thu May 27 22:05:25 UTC 2021

Modified Files:
src/sys/arch/alpha/include: alpha_cpu.h

Log Message:
Define the arithmetic exception summary bits passed in a0 to entArith.


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/sys/arch/alpha/include/alpha_cpu.h

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

Modified files:

Index: src/sys/arch/alpha/include/alpha_cpu.h
diff -u src/sys/arch/alpha/include/alpha_cpu.h:1.53 src/sys/arch/alpha/include/alpha_cpu.h:1.54
--- src/sys/arch/alpha/include/alpha_cpu.h:1.53	Thu Oct 15 00:55:09 2020
+++ src/sys/arch/alpha/include/alpha_cpu.h	Thu May 27 22:05:24 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: alpha_cpu.h,v 1.53 2020/10/15 00:55:09 thorpej Exp $ */
+/* $NetBSD: alpha_cpu.h,v 1.54 2021/05/27 22:05:24 thorpej Exp $ */
 
 /*
  * Copyright (c) 1996 Carnegie-Mellon University.
@@ -44,6 +44,7 @@
  *	Virtual Memory Management
  *	Kernel Entry Vectors
  *	MMCSR Fault Type Codes
+ *	AESR Fault Code bits
  *	Translation Buffer Invalidation
  *
  * and miscellaneous PALcode operations.
@@ -265,6 +266,18 @@ typedef unsigned long alpha_pt_entry_t;
 #define	ALPHA_KENTRY_SYS	5
 
 /*
+ * Arithmetic Exception Summary Register.  [OSF/1 PALcode Specific]
+ */
+
+#define	ALPHA_AESR_SWC		__BIT(0)	/* software completion */
+#define	ALPHA_AESR_INV		__BIT(1)	/* invalid operation */
+#define	ALPHA_AESR_DZE		__BIT(2)	/* division by zero */
+#define	ALPHA_AESR_OVF		__BIT(3)	/* overflow */
+#define	ALPHA_AESR_UNF		__BIT(4)	/* underflow */
+#define	ALPHA_AESR_INE		__BIT(5)	/* inexact result */
+#define	ALPHA_AESR_IOV		__BIT(6)	/* integer overflow */
+
+/*
  * MMCSR Fault Type Codes.  [OSF/1 PALcode Specific]
  */
 



CVS commit: src/sys/arch/mips

2021-05-27 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Thu May 27 15:00:02 UTC 2021

Modified Files:
src/sys/arch/mips/include: locore.h
src/sys/arch/mips/mips: mips_emul.c

Log Message:
Rename the unhelpfully named mips_emul_lwc0() and mips_emul_swc0() to
mips_emul_ll() and mips_emul_sc(); make these static to mips_emul.c.


To generate a diff of this commit:
cvs rdiff -u -r1.118 -r1.119 src/sys/arch/mips/include/locore.h
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/mips/mips/mips_emul.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/mips/include/locore.h
diff -u src/sys/arch/mips/include/locore.h:1.118 src/sys/arch/mips/include/locore.h:1.119
--- src/sys/arch/mips/include/locore.h:1.118	Wed May 12 03:53:37 2021
+++ src/sys/arch/mips/include/locore.h	Thu May 27 15:00:02 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: locore.h,v 1.118 2021/05/12 03:53:37 simonb Exp $ */
+/* $NetBSD: locore.h,v 1.119 2021/05/27 15:00:02 simonb Exp $ */
 
 /*
  * This file should not be included by MI code!!!
@@ -347,8 +347,6 @@ void	mips_emul_inst(uint32_t, uint32_t, 
 void	mips_emul_fp(uint32_t, struct trapframe *, uint32_t);
 void	mips_emul_branchdelayslot(uint32_t, struct trapframe *, uint32_t);
 
-void	mips_emul_lwc0(uint32_t, struct trapframe *, uint32_t);
-void	mips_emul_swc0(uint32_t, struct trapframe *, uint32_t);
 void	mips_emul_special(uint32_t, struct trapframe *, uint32_t);
 void	mips_emul_special3(uint32_t, struct trapframe *, uint32_t);
 

Index: src/sys/arch/mips/mips/mips_emul.c
diff -u src/sys/arch/mips/mips/mips_emul.c:1.28 src/sys/arch/mips/mips/mips_emul.c:1.29
--- src/sys/arch/mips/mips/mips_emul.c:1.28	Thu May 27 13:32:54 2021
+++ src/sys/arch/mips/mips/mips_emul.c	Thu May 27 15:00:02 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: mips_emul.c,v 1.28 2021/05/27 13:32:54 simonb Exp $ */
+/*	$NetBSD: mips_emul.c,v 1.29 2021/05/27 15:00:02 simonb Exp $ */
 
 /*
  * Copyright (c) 1999 Shuichiro URATA.  All rights reserved.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mips_emul.c,v 1.28 2021/05/27 13:32:54 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mips_emul.c,v 1.29 2021/05/27 15:00:02 simonb Exp $");
 
 #include 
 #include 
@@ -47,6 +47,9 @@ static inline void	send_sigsegv(intptr_t
 			uint32_t);
 static inline void	update_pc(struct trapframe *, uint32_t);
 
+static void	mips_emul_ll(uint32_t, struct trapframe *, uint32_t);
+static void	mips_emul_sc(uint32_t, struct trapframe *, uint32_t);
+
 /*
  * MIPS2 LL instruction emulation state
  */
@@ -198,11 +201,11 @@ mips_emul_inst(uint32_t status, uint32_t
 		inst = mips_ufetch32((uint32_t *)opc);
 
 	switch (((InstFmt)inst).FRType.op) {
-	case OP_LWC0:
-		mips_emul_lwc0(inst, tf, cause);
+	case OP_LL:
+		mips_emul_ll(inst, tf, cause);
 		break;
-	case OP_SWC0:
-		mips_emul_swc0(inst, tf, cause);
+	case OP_SC:
+		mips_emul_sc(inst, tf, cause);
 		break;
 	case OP_SPECIAL:
 		mips_emul_special(inst, tf, cause);
@@ -289,7 +292,7 @@ update_pc(struct trapframe *tf, uint32_t
  * MIPS2 LL instruction
  */
 void
-mips_emul_lwc0(uint32_t inst, struct trapframe *tf, uint32_t cause)
+mips_emul_ll(uint32_t inst, struct trapframe *tf, uint32_t cause)
 {
 	intptr_t	vaddr;
 	int16_t		offset;
@@ -322,7 +325,7 @@ mips_emul_lwc0(uint32_t inst, struct tra
  * MIPS2 SC instruction
  */
 void
-mips_emul_swc0(uint32_t inst, struct trapframe *tf, uint32_t cause)
+mips_emul_sc(uint32_t inst, struct trapframe *tf, uint32_t cause)
 {
 	intptr_t	vaddr;
 	uint32_t	value;



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

2021-05-27 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Thu May 27 13:32:54 UTC 2021

Modified Files:
src/sys/arch/mips/mips: mips_emul.c

Log Message:
Print the CP0 status register too in the debug trap code.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/mips/mips/mips_emul.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/mips/mips/mips_emul.c
diff -u src/sys/arch/mips/mips/mips_emul.c:1.27 src/sys/arch/mips/mips/mips_emul.c:1.28
--- src/sys/arch/mips/mips/mips_emul.c:1.27	Sat Apr  6 03:06:26 2019
+++ src/sys/arch/mips/mips/mips_emul.c	Thu May 27 13:32:54 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: mips_emul.c,v 1.27 2019/04/06 03:06:26 thorpej Exp $ */
+/*	$NetBSD: mips_emul.c,v 1.28 2021/05/27 13:32:54 simonb Exp $ */
 
 /*
  * Copyright (c) 1999 Shuichiro URATA.  All rights reserved.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mips_emul.c,v 1.27 2019/04/06 03:06:26 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mips_emul.c,v 1.28 2021/05/27 13:32:54 simonb Exp $");
 
 #include 
 #include 
@@ -240,7 +240,10 @@ mips_emul_inst(uint32_t status, uint32_t
 #endif
 	default:
 #ifdef DEBUG
-		printf("pid %d (%s): trap: bad insn @ %#"PRIxVADDR" cause %#x insn %#x code %d\n", curproc->p_pid, curproc->p_comm, opc, cause, inst, code);
+		printf("pid %d (%s): trap: bad insn @ %#"PRIxVADDR
+		" cause %#x status %#"PRIxREGISTER" insn %#x code %d\n",
+		curproc->p_pid, curproc->p_comm, opc,
+		cause, tf->tf_regs[_R_SR], inst, code);
 #endif
 		tf->tf_regs[_R_CAUSE] = cause;
 		tf->tf_regs[_R_BADVADDR] = opc;



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

2021-05-27 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Thu May 27 06:19:38 UTC 2021

Modified Files:
src/sys/arch/aarch64/conf: Makefile.aarch64

Log Message:
In gcc10, -msign-return-address is no longer supported.
Instead, (LLVM-compatible) -mbranch-protection option is supported.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/aarch64/conf/Makefile.aarch64

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/conf/Makefile.aarch64
diff -u src/sys/arch/aarch64/conf/Makefile.aarch64:1.22 src/sys/arch/aarch64/conf/Makefile.aarch64:1.23
--- src/sys/arch/aarch64/conf/Makefile.aarch64:1.22	Wed Feb 10 08:25:01 2021
+++ src/sys/arch/aarch64/conf/Makefile.aarch64	Thu May 27 06:19:38 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.aarch64,v 1.22 2021/02/10 08:25:01 ryo Exp $
+#	$NetBSD: Makefile.aarch64,v 1.23 2021/05/27 06:19:38 ryo Exp $
 
 # Makefile for NetBSD
 #
@@ -44,7 +44,6 @@ CFLAGS+=	-mno-omit-leaf-frame-pointer
 CFLAGS+=	-fno-optimize-sibling-calls
 .endif
 
-.if ${HAVE_LLVM:Uno} == "yes"
 .if ${ARMV83_PAC:U0} > 0 && ${ARMV85_BTI:U0} > 0
 CFLAGS+=	-mbranch-protection=pac-ret+bti
 .else
@@ -55,16 +54,6 @@ CFLAGS+=	-mbranch-protection=pac-ret
 CFLAGS+=	-mbranch-protection=bti
 .endif
 .endif
-.endif
-
-.if ${HAVE_GCC:U0} > 0
-.if ${ARMV83_PAC:U0} > 0
-CFLAGS+=	-msign-return-address=all
-.endif
-.if ${ARMV85_BTI:U0} > 0
-# XXX: notyet for gcc
-.endif
-.endif
 
 .if ${KASAN:U0} > 0 && ${HAVE_GCC:U0} > 0
 KASANFLAGS=	-fsanitize=kernel-address \



CVS commit: src/sys/arch/aarch64

2021-05-27 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Thu May 27 06:11:20 UTC 2021

Modified Files:
src/sys/arch/aarch64/aarch64: procfs_machdep.c
src/sys/arch/aarch64/include: cpufunc.h

Log Message:
fix build error with options ARMV85_BTI


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/aarch64/aarch64/procfs_machdep.c
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/aarch64/include/cpufunc.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/procfs_machdep.c
diff -u src/sys/arch/aarch64/aarch64/procfs_machdep.c:1.4 src/sys/arch/aarch64/aarch64/procfs_machdep.c:1.5
--- src/sys/arch/aarch64/aarch64/procfs_machdep.c:1.4	Thu Oct  1 07:31:27 2020
+++ src/sys/arch/aarch64/aarch64/procfs_machdep.c	Thu May 27 06:11:20 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: procfs_machdep.c,v 1.4 2020/10/01 07:31:27 skrll Exp $ */
+/* $NetBSD: procfs_machdep.c,v 1.5 2021/05/27 06:11:20 ryo Exp $ */
 
 /*-
  * Copyright (c) 2020 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.4 2020/10/01 07:31:27 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.5 2021/05/27 06:11:20 ryo Exp $");
 
 #include 
 #include 
@@ -36,7 +36,7 @@ __KERNEL_RCSID(0, "$NetBSD: procfs_machd
 #include 
 
 #include 
-
+#include 
 
 /* use variables named 'buf', 'left', 'total' */
 #define FORWARD_BUF(_len)	\

Index: src/sys/arch/aarch64/include/cpufunc.h
diff -u src/sys/arch/aarch64/include/cpufunc.h:1.19 src/sys/arch/aarch64/include/cpufunc.h:1.20
--- src/sys/arch/aarch64/include/cpufunc.h:1.19	Fri Dec  4 08:29:11 2020
+++ src/sys/arch/aarch64/include/cpufunc.h	Thu May 27 06:11:20 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc.h,v 1.19 2020/12/04 08:29:11 skrll Exp $	*/
+/*	$NetBSD: cpufunc.h,v 1.20 2021/05/27 06:11:20 ryo Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -63,6 +63,7 @@ extern u_int aarch64_cache_vindexsize;	/
 extern u_int aarch64_cache_prefer_mask;
 extern u_int cputype;			/* compat arm */
 
+extern int aarch64_bti_enabled;
 extern int aarch64_pan_enabled;
 extern int aarch64_pac_enabled;
 



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

2021-05-26 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Thu May 27 03:23:29 UTC 2021

Modified Files:
src/sys/arch/mips/cavium/dev: if_cnmac.c

Log Message:
Move the send queue checking to a new function, and also call this
in the rx interrupt path.  Measureable improvement on a NFS "create
small files" test.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/mips/cavium/dev/if_cnmac.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/mips/cavium/dev/if_cnmac.c
diff -u src/sys/arch/mips/cavium/dev/if_cnmac.c:1.25 src/sys/arch/mips/cavium/dev/if_cnmac.c:1.26
--- src/sys/arch/mips/cavium/dev/if_cnmac.c:1.25	Thu May 27 01:43:32 2021
+++ src/sys/arch/mips/cavium/dev/if_cnmac.c	Thu May 27 03:23:29 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_cnmac.c,v 1.25 2021/05/27 01:43:32 simonb Exp $	*/
+/*	$NetBSD: if_cnmac.c,v 1.26 2021/05/27 03:23:29 simonb Exp $	*/
 
 /*
  * Copyright (c) 2007 Internet Initiative Japan, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_cnmac.c,v 1.25 2021/05/27 01:43:32 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_cnmac.c,v 1.26 2021/05/27 03:23:29 simonb Exp $");
 
 /*
  * If no free send buffer is available, free all the sent buffers and bail out.
@@ -122,6 +122,7 @@ static inline void cnmac_send_queue_flus
 static inline void cnmac_send_queue_flush_fetch(struct cnmac_softc *);
 static inline void cnmac_send_queue_flush(struct cnmac_softc *);
 static inline void cnmac_send_queue_flush_sync(struct cnmac_softc *);
+static void cnmac_send_queue_check_and_flush(struct cnmac_softc *);
 static inline int cnmac_send_queue_is_full(struct cnmac_softc *);
 static inline void cnmac_send_queue_add(struct cnmac_softc *, struct mbuf *,
 uint64_t *);
@@ -604,6 +605,23 @@ cnmac_send_queue_is_full(struct cnmac_so
 	return 0;
 }
 
+static void
+cnmac_send_queue_check_and_flush(struct cnmac_softc *sc)
+{
+	int s;
+
+	/* XXX XXX XXX */
+	s = splnet();
+	if (sc->sc_soft_req_cnt > 0) {
+		cnmac_send_queue_flush_prefetch(sc);
+		cnmac_send_queue_flush_fetch(sc);
+		cnmac_send_queue_flush(sc);
+		cnmac_send_queue_flush_sync(sc);
+	}
+	splx(s);
+	/* XXX XXX XXX */
+}
+
 /*
  * (Ab)use m_nextpkt and m_paddr to maintain mbuf chain and pointer to gather
  * buffer.  Other mbuf members may be used by m_freem(), so don't touch them!
@@ -1299,6 +1317,8 @@ cnmac_intr(void *arg)
 		}
 
 		(void)cnmac_recv(sc, work);
+
+		cnmac_send_queue_check_and_flush(sc);
 	}
 
 	_POW_WR8(sc->sc_pow, POW_WQ_INT_OFFSET, wqmask);
@@ -1326,21 +1346,11 @@ cnmac_tick_free(void *arg)
 {
 	struct cnmac_softc *sc = arg;
 	int timo;
-	int s;
 
-	s = splnet();
-	/* XXX XXX XXX */
-	if (sc->sc_soft_req_cnt > 0) {
-		cnmac_send_queue_flush_prefetch(sc);
-		cnmac_send_queue_flush_fetch(sc);
-		cnmac_send_queue_flush(sc);
-		cnmac_send_queue_flush_sync(sc);
-	}
-	/* XXX XXX XXX */
+	cnmac_send_queue_check_and_flush(sc);
 
 	timo = (sc->sc_ext_callback_cnt > 0) ? 1 : hz;
 	callout_schedule(>sc_tick_free_ch, timo);
-	splx(s);
 }
 
 /*



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

2021-05-26 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Thu May 27 01:43:32 UTC 2021

Modified Files:
src/sys/arch/mips/cavium/dev: if_cnmac.c

Log Message:
Schedule the send cleanup function for next tick in cnmac_start().  In
the send cleanup function, schedule for the next tick instead of waiting
for HZ ticks if there are still send requests outstanding.  Greatly
increases NFS throughput, perhaps other types of network traffic.

Use callout_setfunc() after callout_init() instead of callout_reset().


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/mips/cavium/dev/if_cnmac.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/mips/cavium/dev/if_cnmac.c
diff -u src/sys/arch/mips/cavium/dev/if_cnmac.c:1.24 src/sys/arch/mips/cavium/dev/if_cnmac.c:1.25
--- src/sys/arch/mips/cavium/dev/if_cnmac.c:1.24	Tue Jun 23 05:17:13 2020
+++ src/sys/arch/mips/cavium/dev/if_cnmac.c	Thu May 27 01:43:32 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_cnmac.c,v 1.24 2020/06/23 05:17:13 simonb Exp $	*/
+/*	$NetBSD: if_cnmac.c,v 1.25 2021/05/27 01:43:32 simonb Exp $	*/
 
 /*
  * Copyright (c) 2007 Internet Initiative Japan, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_cnmac.c,v 1.24 2020/06/23 05:17:13 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_cnmac.c,v 1.25 2021/05/27 01:43:32 simonb Exp $");
 
 /*
  * If no free send buffer is available, free all the sent buffers and bail out.
@@ -278,7 +278,10 @@ cnmac_attach(device_t parent, device_t s
 	octgmx_stats_init(sc->sc_gmx_port);
 
 	callout_init(>sc_tick_misc_ch, 0);
+	callout_setfunc(>sc_tick_misc_ch, cnmac_tick_misc, sc);
+
 	callout_init(>sc_tick_free_ch, 0);
+	callout_setfunc(>sc_tick_free_ch, cnmac_tick_free, sc);
 
 	const int dv_unit = device_unit(self);
 	octfau_op_init(>sc_fau_done,
@@ -998,6 +1001,7 @@ cnmac_start(struct ifnet *ifp)
 			if (wdc > 0)
 octpko_op_doorbell_write(sc->sc_port,
 sc->sc_port, wdc);
+			callout_schedule(>sc_tick_free_ch, 1);
 			return;
 		}
 		/* XXX XXX XXX */
@@ -1031,6 +1035,7 @@ cnmac_start(struct ifnet *ifp)
 
 last:
 	cnmac_send_queue_flush_fetch(sc);
+	callout_schedule(>sc_tick_free_ch, 1);
 }
 
 static void
@@ -1073,8 +1078,8 @@ cnmac_init(struct ifnet *ifp)
 
 	octgmx_set_filter(sc->sc_gmx_port);
 
-	callout_reset(>sc_tick_misc_ch, hz, cnmac_tick_misc, sc);
-	callout_reset(>sc_tick_free_ch, hz, cnmac_tick_free, sc);
+	callout_schedule(>sc_tick_misc_ch, hz);
+	callout_schedule(>sc_tick_free_ch, hz);
 
 	SET(ifp->if_flags, IFF_RUNNING);
 	CLR(ifp->if_flags, IFF_OACTIVE);
@@ -1097,7 +1102,6 @@ cnmac_stop(struct ifnet *ifp, int disabl
 	/* Mark the interface as down and cancel the watchdog timer. */
 	CLR(ifp->if_flags, IFF_RUNNING | IFF_OACTIVE);
 	ifp->if_timer = 0;
-
 }
 
 /*  misc */
@@ -1334,13 +1338,8 @@ cnmac_tick_free(void *arg)
 	}
 	/* XXX XXX XXX */
 
-	/* XXX XXX XXX */
-	/* ??? */
-	timo = hz - (100 * sc->sc_ext_callback_cnt);
-	if (timo < 10)
-		 timo = 10;
+	timo = (sc->sc_ext_callback_cnt > 0) ? 1 : hz;
 	callout_schedule(>sc_tick_free_ch, timo);
-	/* XXX XXX XXX */
 	splx(s);
 }
 



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

2021-05-25 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Tue May 25 09:19:28 UTC 2021

Modified Files:
src/sys/arch/mips/conf: files.mips

Log Message:
Alignment nit.


To generate a diff of this commit:
cvs rdiff -u -r1.83 -r1.84 src/sys/arch/mips/conf/files.mips

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

Modified files:

Index: src/sys/arch/mips/conf/files.mips
diff -u src/sys/arch/mips/conf/files.mips:1.83 src/sys/arch/mips/conf/files.mips:1.84
--- src/sys/arch/mips/conf/files.mips:1.83	Tue Mar 23 13:22:40 2021
+++ src/sys/arch/mips/conf/files.mips	Tue May 25 09:19:28 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: files.mips,v 1.83 2021/03/23 13:22:40 simonb Exp $
+#	$NetBSD: files.mips,v 1.84 2021/05/25 09:19:28 simonb Exp $
 #
 
 defflag	opt_cputype.h		NOFPU FPEMUL
@@ -75,7 +75,7 @@ file	arch/mips/mips/cache_ls2.c		mips3_l
 file	arch/mips/mips/cache_r4k.c		mips3 | mips4
 file	arch/mips/mips/cache_r5k.c		mips3 | mips4
 file	arch/mips/mips/cache_r5k_subr.S		mips3 | mips4
-file	arch/mips/mips/cache_r10k.c	(mips3|mips4) & enable_mips4_cache_r10k
+file	arch/mips/mips/cache_r10k.c		(mips3|mips4) & enable_mips4_cache_r10k
 file	arch/mips/mips/cache_octeon.c		mips64_octeon
 file	arch/mips/mips/cache_mipsNN.c		mips32|mips32r2|mips64|mips64r2
 file	arch/mips/mips/cache_r4k_pcache16.S	mips3|mips4|mips32|mips32r2|mips64|mips64r2



CVS commit: src/sys/arch/alpha

2021-05-24 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon May 24 21:00:12 UTC 2021

Modified Files:
src/sys/arch/alpha/alpha: machdep.c
src/sys/arch/alpha/include: mcontext.h

Log Message:
Add _UC_SETSTACK / _UC_CLRSTACK handling.  Fixes the t_sigaltstack test
on alpha.


To generate a diff of this commit:
cvs rdiff -u -r1.371 -r1.372 src/sys/arch/alpha/alpha/machdep.c
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/alpha/include/mcontext.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/alpha/alpha/machdep.c
diff -u src/sys/arch/alpha/alpha/machdep.c:1.371 src/sys/arch/alpha/alpha/machdep.c:1.372
--- src/sys/arch/alpha/alpha/machdep.c:1.371	Wed May  5 15:36:17 2021
+++ src/sys/arch/alpha/alpha/machdep.c	Mon May 24 21:00:12 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.371 2021/05/05 15:36:17 thorpej Exp $ */
+/* $NetBSD: machdep.c,v 1.372 2021/05/24 21:00:12 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2019, 2020 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.371 2021/05/05 15:36:17 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.372 2021/05/24 21:00:12 thorpej Exp $");
 
 #include 
 #include 
@@ -1525,6 +1525,8 @@ sendsig_siginfo(const ksiginfo_t *ksi, c
 	frame.sf_uc.uc_flags = _UC_SIGMASK;
 	frame.sf_uc.uc_sigmask = *mask;
 	frame.sf_uc.uc_link = l->l_ctxlink;
+	frame.sf_uc.uc_flags |= (l->l_sigstk.ss_flags & SS_ONSTACK)
+	? _UC_SETSTACK : _UC_CLRSTACK;
 	sendsig_reset(l, sig);
 	mutex_exit(p->p_lock);
 	cpu_getmcontext(l, _uc.uc_mcontext, _uc.uc_flags);
@@ -1885,8 +1887,10 @@ cpu_setmcontext(struct lwp *l, const mco
 		frame->tf_regs[FRAME_PC] = gr[_REG_PC];
 		frame->tf_regs[FRAME_PS] = gr[_REG_PS];
 	}
+
 	if (flags & _UC_TLSBASE)
 		lwp_setprivate(l, (void *)(uintptr_t)gr[_REG_UNIQUE]);
+
 	/* Restore floating point register context, if any. */
 	if (flags & _UC_FPU) {
 		/* If we have an FP register context, get rid of it. */
@@ -1896,6 +1900,13 @@ cpu_setmcontext(struct lwp *l, const mco
 		l->l_md.md_flags = mcp->__fpregs.__fp_fpcr & MDLWP_FP_C;
 	}
 
+	mutex_enter(l->l_proc->p_lock);
+	if (flags & _UC_SETSTACK)
+		l->l_sigstk.ss_flags |= SS_ONSTACK;
+	if (flags & _UC_CLRSTACK)
+		l->l_sigstk.ss_flags &= ~SS_ONSTACK;
+	mutex_exit(l->l_proc->p_lock);
+
 	return (0);
 }
 

Index: src/sys/arch/alpha/include/mcontext.h
diff -u src/sys/arch/alpha/include/mcontext.h:1.10 src/sys/arch/alpha/include/mcontext.h:1.11
--- src/sys/arch/alpha/include/mcontext.h:1.10	Fri Dec 27 00:32:16 2019
+++ src/sys/arch/alpha/include/mcontext.h	Mon May 24 21:00:12 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: mcontext.h,v 1.10 2019/12/27 00:32:16 kamil Exp $	*/
+/*	$NetBSD: mcontext.h,v 1.11 2021/05/24 21:00:12 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -94,6 +94,8 @@ typedef struct {
 
 /* Machine-dependent uc_flags */
 #define _UC_TLSBASE	0x20	/* valid process-unique value in _REG_UNIQUE */
+#define _UC_SETSTACK	0x0001
+#define _UC_CLRSTACK	0x0002
 
 #define _UC_MACHINE_SP(uc)	((uc)->uc_mcontext.__gregs[_REG_SP])
 #define _UC_MACHINE_FP(uc)	((uc)->uc_mcontext.__gregs[_REG_S6])



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

2021-05-24 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon May 24 11:13:44 UTC 2021

Modified Files:
src/sys/arch/macppc/stand/ofwboot: ofdev.c

Log Message:
PR 56205: make the 64bit build work


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/macppc/stand/ofwboot/ofdev.c

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

Modified files:

Index: src/sys/arch/macppc/stand/ofwboot/ofdev.c
diff -u src/sys/arch/macppc/stand/ofwboot/ofdev.c:1.28 src/sys/arch/macppc/stand/ofwboot/ofdev.c:1.29
--- src/sys/arch/macppc/stand/ofwboot/ofdev.c:1.28	Sun Feb 28 20:27:40 2021
+++ src/sys/arch/macppc/stand/ofwboot/ofdev.c	Mon May 24 11:13:44 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ofdev.c,v 1.28 2021/02/28 20:27:40 thorpej Exp $	*/
+/*	$NetBSD: ofdev.c,v 1.29 2021/05/24 11:13:44 martin Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -103,7 +103,7 @@ devclose(struct open_file *of)
 	uint32_t cells[2];
 	struct of_dev *op = of->f_devdata;
 
-	cells[0] = (uint32_t)op->dmabuf;
+	cells[0] = (uintptr_t)op->dmabuf;
 	cells[1] = MAXPHYS;
 
 	if (op->type == OFDEV_NET)
@@ -439,7 +439,7 @@ devopen(struct open_file *of, const char
 	ofdev.dmabuf = NULL;
 	cells[0] = MAXPHYS;
 	OF_call_method("dma-alloc", handle, 1, 1, (int *)cells);
-	ofdev.dmabuf = (void *)cells[1];
+	ofdev.dmabuf = (void*)(uintptr_t)cells[1];
 	if (!strcmp(buf, "block")) {
 		ofdev.type = OFDEV_DISK;
 		ofdev.bsize = DEV_BSIZE;



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

2021-05-24 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Mon May 24 07:27:39 UTC 2021

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

Log Message:
Whitespace alignment nit.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sys/arch/mips/mips/fp.S

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

Modified files:

Index: src/sys/arch/mips/mips/fp.S
diff -u src/sys/arch/mips/mips/fp.S:1.56 src/sys/arch/mips/mips/fp.S:1.57
--- src/sys/arch/mips/mips/fp.S:1.56	Thu May 13 06:15:29 2021
+++ src/sys/arch/mips/mips/fp.S	Mon May 24 07:27:39 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: fp.S,v 1.56 2021/05/13 06:15:29 simonb Exp $	*/
+/*	$NetBSD: fp.S,v 1.57 2021/05/24 07:27:39 simonb Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -773,7 +773,7 @@ branchc1:
 
 	.rdata
 branchc1_tbl:
-	PTR_WORD bcfalse		# br 0
+	PTR_WORD bcfalse	# br 0
 	PTR_WORD bctrue		# br 1
 	PTR_WORD bcfalse_l	# br 2
 	PTR_WORD bctrue_l	# br 3



CVS commit: src/sys/arch/alpha

2021-05-23 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon May 24 03:43:24 UTC 2021

Modified Files:
src/sys/arch/alpha/alpha: pmap.c
src/sys/arch/alpha/include: pmap.h

Log Message:
pmap_tlb_shootdown_all_user() can be called in the PV scenario as well
as the forward scenario, for example if a pmap_page_protect() to remove
all mappings results in the freeing of a PT page.  It therefore needs
to do the same reference counting dance as pmap_tlb_shootdown_pv().

Also fix a use-after-free error in pmap_page_protect().

Add / tweak some assertions, and shrink the pmap::pm_count field from
long to unsigned int (which gave me a spare unsigned int field for
debugging purposes).

PR port-alpha/56201.


To generate a diff of this commit:
cvs rdiff -u -r1.277 -r1.278 src/sys/arch/alpha/alpha/pmap.c
cvs rdiff -u -r1.84 -r1.85 src/sys/arch/alpha/include/pmap.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/alpha/alpha/pmap.c
diff -u src/sys/arch/alpha/alpha/pmap.c:1.277 src/sys/arch/alpha/alpha/pmap.c:1.278
--- src/sys/arch/alpha/alpha/pmap.c:1.277	Sun May 23 19:13:27 2021
+++ src/sys/arch/alpha/alpha/pmap.c	Mon May 24 03:43:24 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.277 2021/05/23 19:13:27 thorpej Exp $ */
+/* $NetBSD: pmap.c,v 1.278 2021/05/24 03:43:24 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001, 2007, 2008, 2020
@@ -135,7 +135,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.277 2021/05/23 19:13:27 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.278 2021/05/24 03:43:24 thorpej Exp $");
 
 #include 
 #include 
@@ -667,17 +667,17 @@ pmap_tlb_init(void)
 }
 
 static inline void
-pmap_tlb_context_init(struct pmap_tlb_context * const tlbctx)
+pmap_tlb_context_init(struct pmap_tlb_context * const tlbctx, uintptr_t flags)
 {
 	/* Initialize the minimum number of fields. */
 	tlbctx->t_addrdata[0] = 0;
-	tlbctx->t_addrdata[1] = 0;
+	tlbctx->t_addrdata[1] = flags;
 	tlbctx->t_pmap = NULL;
 	LIST_INIT(>t_freeptq);
 }
 
 static void
-pmap_tlb_shootdown(pmap_t const pmap, vaddr_t const va,
+pmap_tlb_shootdown_internal(pmap_t const pmap, vaddr_t const va,
 pt_entry_t const pte_bits, struct pmap_tlb_context * const tlbctx)
 {
 	KASSERT(pmap != NULL);
@@ -730,6 +730,14 @@ pmap_tlb_shootdown(pmap_t const pmap, va
 }
 
 static void
+pmap_tlb_shootdown(pmap_t const pmap, vaddr_t const va,
+pt_entry_t const pte_bits, struct pmap_tlb_context * const tlbctx)
+{
+	KASSERT((TLB_CTX_FLAGS(tlbctx) & TLB_CTX_F_PV) == 0);
+	pmap_tlb_shootdown_internal(pmap, va, pte_bits, tlbctx);
+}
+
+static void
 pmap_tlb_shootdown_all_user(pmap_t const pmap, pt_entry_t const pte_bits,
 struct pmap_tlb_context * const tlbctx)
 {
@@ -743,29 +751,42 @@ pmap_tlb_shootdown_all_user(pmap_t const
 		TLB_CTX_SET_FLAG(tlbctx, TLB_CTX_F_IMB);
 	}
 
-	KASSERT(tlbctx->t_pmap == NULL || tlbctx->t_pmap == pmap);
-	tlbctx->t_pmap = pmap;
+	if (TLB_CTX_FLAGS(tlbctx) & TLB_CTX_F_PV) {
+		if (tlbctx->t_pmap == NULL || tlbctx->t_pmap == pmap) {
+			if (tlbctx->t_pmap == NULL) {
+pmap_reference(pmap);
+tlbctx->t_pmap = pmap;
+			}
+		} else {
+			TLB_CTX_SET_FLAG(tlbctx, TLB_CTX_F_MULTI);
+		}
+	} else {
+		KASSERT(tlbctx->t_pmap == NULL || tlbctx->t_pmap == pmap);
+		tlbctx->t_pmap = pmap;
+	}
 
 	TLB_CTX_SET_ALLVA(tlbctx);
 }
 
 static void
-pmap_tlb_shootdown_pv(const pv_entry_t pv, pt_entry_t const pte_bits,
-struct pmap_tlb_context * const tlbctx)
+pmap_tlb_shootdown_pv(pmap_t const pmap, vaddr_t const va,
+pt_entry_t const pte_bits, struct pmap_tlb_context * const tlbctx)
 {
-	uintptr_t flags = TLB_CTX_F_PV;
+
+	KASSERT(TLB_CTX_FLAGS(tlbctx) & TLB_CTX_F_PV);
 
 	TLB_COUNT(shootdown_pv);
 
-	if (tlbctx->t_pmap == NULL || tlbctx->t_pmap == pv->pv_pmap) {
+	if (tlbctx->t_pmap == NULL || tlbctx->t_pmap == pmap) {
 		if (tlbctx->t_pmap == NULL) {
-			pmap_reference(pv->pv_pmap);
+			pmap_reference(pmap);
+			tlbctx->t_pmap = pmap;
 		}
-		pmap_tlb_shootdown(pv->pv_pmap, pv->pv_va, pte_bits, tlbctx);
+		pmap_tlb_shootdown_internal(pmap, va, pte_bits, tlbctx);
 	} else {
 		TLB_COUNT(shootdown_pv_multi);
-		flags |= TLB_CTX_F_MULTI;
-		if (pv->pv_pmap == pmap_kernel()) {
+		uintptr_t flags = TLB_CTX_F_MULTI;
+		if (pmap == pmap_kernel()) {
 			KASSERT(pte_bits & PG_ASM);
 			flags |= TLB_CTX_F_ASM;
 		} else {
@@ -780,8 +801,8 @@ pmap_tlb_shootdown_pv(const pv_entry_t p
 			flags |= TLB_CTX_F_IMB;
 		}
 		TLB_CTX_SET_ALLVA(tlbctx);
+		TLB_CTX_SET_FLAG(tlbctx, flags);
 	}
-	TLB_CTX_SET_FLAG(tlbctx, flags);
 }
 
 static void
@@ -1034,6 +1055,7 @@ pmap_tlb_shootnow(const struct pmap_tlb_
 #if defined(MULTIPROCESSOR)
 void
 pmap_tlb_shootdown_ipi(struct cpu_info * const ci,
+
 struct trapframe * const tf __unused)
 {
 	KASSERT(tlb_context != NULL);
@@ -1367,7 +1389,7 @@ pmap_bootstrap(paddr_t ptaddr, u_int max
 	 */
 	memset(pmap_kernel(), 0, 

CVS commit: src/sys/arch/mips

2021-05-23 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sun May 23 23:24:45 UTC 2021

Modified Files:
src/sys/arch/mips/include: mips_param.h netbsd32_machdep.h
src/sys/arch/mips/mips: cpu_exec.c netbsd32_machdep.c

Log Message:
fix "uname -p" on mips n32.

this has been returning "mipsn64eb" on my edgerouter4 with the
32 bit uname binary.

introduce o32, n32, and n64 versions of MACHINE_ARCH, and use
them appropriately in PROC_MACHINE_ARCH32().  now o32, n32 and
n64 "uname -p" all return different values.


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/sys/arch/mips/include/mips_param.h
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/mips/include/netbsd32_machdep.h
cvs rdiff -u -r1.67 -r1.68 src/sys/arch/mips/mips/cpu_exec.c
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/mips/mips/netbsd32_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/mips/include/mips_param.h
diff -u src/sys/arch/mips/include/mips_param.h:1.49 src/sys/arch/mips/include/mips_param.h:1.50
--- src/sys/arch/mips/include/mips_param.h:1.49	Sat May  8 13:09:58 2021
+++ src/sys/arch/mips/include/mips_param.h	Sun May 23 23:24:45 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: mips_param.h,v 1.49 2021/05/08 13:09:58 skrll Exp $	*/
+/*	$NetBSD: mips_param.h,v 1.50 2021/05/23 23:24:45 mrg Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -38,19 +38,28 @@
 # error neither __MIPSEL__ nor __MIPSEB__ are defined.
 #endif
 
+#define	___MACHINE32_OARCH		mips##_MACHINE_SUFFIX
+#define	__MACHINE32_OARCH		"mips" MACHINE_SUFFIX
+#define	___MACHINE32_NARCH		mips64##_MACHINE_SUFFIX
+#define	__MACHINE32_NARCH		"mips64" MACHINE_SUFFIX
+#define	___MACHINE64_NARCH		mipsn64##_MACHINE_SUFFIX
+#define	__MACHINE64_NARCH		"mipsn64" MACHINE_SUFFIX
+
 #if defined(__mips_n32) || defined(__mips_n64)
 # if defined(__mips_n32)
-#  define	_MACHINE_ARCH	mips64##_MACHINE_SUFFIX
-#  define	MACHINE_ARCH	"mips64" MACHINE_SUFFIX
+#  define	_MACHINE_ARCH		___MACHINE32_NARCH
+#  define	MACHINE_ARCH		__MACHINE32_NARCH
 # else /* __mips_n64 */
-#  define	_MACHINE_ARCH	mipsn64##_MACHINE_SUFFIX
-#  define	MACHINE_ARCH	"mipsn64" MACHINE_SUFFIX
+#  define	_MACHINE_ARCH		___MACHINE64_NARCH
+#  define	MACHINE_ARCH		__MACHINE64_NARCH
+#  define	_MACHINE32_NARCH	___MACHINE32_NARCH
+#  define	MACHINE32_NARCH		__MACHINE32_NARCH
 # endif
-# define	_MACHINE32_ARCH	mips##_MACHINE_SUFFIX
-# define	MACHINE32_ARCH	"mips" MACHINE_SUFFIX
+# define	_MACHINE32_OARCH	___MACHINE32_OARCH
+# define	MACHINE32_OARCH		__MACHINE32_OARCH
 #else /* o32 */
-# define	_MACHINE_ARCH	mips##_MACHINE_SUFFIX
-# define	MACHINE_ARCH	"mips" MACHINE_SUFFIX
+# define	_MACHINE_ARCH		___MACHINE32_OARCH
+# define	MACHINE_ARCH		__MACHINE32_OARCH
 #endif
 
 /*

Index: src/sys/arch/mips/include/netbsd32_machdep.h
diff -u src/sys/arch/mips/include/netbsd32_machdep.h:1.6 src/sys/arch/mips/include/netbsd32_machdep.h:1.7
--- src/sys/arch/mips/include/netbsd32_machdep.h:1.6	Sun Jul 26 08:08:41 2020
+++ src/sys/arch/mips/include/netbsd32_machdep.h	Sun May 23 23:24:45 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_machdep.h,v 1.6 2020/07/26 08:08:41 simonb Exp $	*/
+/*	$NetBSD: netbsd32_machdep.h,v 1.7 2021/05/23 23:24:45 mrg Exp $	*/
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -44,10 +44,17 @@ typedef struct { NETBSD32_POINTER_TYPE i
 
 typedef netbsd32_pointer_t			netbsd32_sigcontextp_t;
 
-/* Support varying ABI names for netbsd32 */
-extern const char machine_arch32[];
+/* Support varying ABI names for netbsd32/ABI */
+extern const char machine_archo32[];
+#if defined(__mips_n64)
+extern const char machine_archn32[];
 #define	PROC_MACHINE_ARCH32(P)	((P)->p_md.md_abi == _MIPS_BSD_API_O32) ? \
-	__UNCONST(machine_arch32) : machine_arch
+	__UNCONST(machine_archo32) : ((P)->p_md.md_abi == _MIPS_BSD_API_N32) ? \
+	__UNCONST(machine_archn32) : machine_arch
+#else
+#define	PROC_MACHINE_ARCH32(P)	((P)->p_md.md_abi == _MIPS_BSD_API_O32) ? \
+	__UNCONST(machine_archo32) : machine_arch
+#endif
 
 /*
  * The sigcode is ABI neutral.

Index: src/sys/arch/mips/mips/cpu_exec.c
diff -u src/sys/arch/mips/mips/cpu_exec.c:1.67 src/sys/arch/mips/mips/cpu_exec.c:1.68
--- src/sys/arch/mips/mips/cpu_exec.c:1.67	Sun Aug 19 10:33:49 2018
+++ src/sys/arch/mips/mips/cpu_exec.c	Sun May 23 23:24:45 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu_exec.c,v 1.67 2018/08/19 10:33:49 mrg Exp $	*/
+/*	$NetBSD: cpu_exec.c,v 1.68 2021/05/23 23:24:45 mrg Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu_exec.c,v 1.67 2018/08/19 10:33:49 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu_exec.c,v 1.68 2021/05/23 23:24:45 mrg Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_compat_ultrix.h"
@@ -201,7 +201,7 @@ coredump_elf32_setup(struct lwp *l, void
 		eh->e_flags |= EF_MIPS_ABI2;
 		break;
 	case _MIPS_BSD_API_O32:
-		eh->e_flags |=EF_MIPS_ABI_O32; 
+		eh->e_flags |= 

CVS commit: src/sys/arch

2021-05-23 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sun May 23 23:22:55 UTC 2021

Modified Files:
src/sys/arch/mips/mips: db_disasm.c db_interface.c
src/sys/arch/riscv/riscv: db_disasm.c db_machdep.c

Log Message:
Improve ddb disassembly for mips (and riscv, cribbed from mips).

- use db_read_bytes to get instructions
- move the address check logic previously attached only to fetching
  instructions for disassembly to db_read_bytes (and db_write_bytes)

Motivated by related x86 changes this afternoon.

Note that the address check logic is not as sophisticated as what the
x86 code does, but it's what we had before. (Except that riscv will
now also try to fetch usermode instructions instead of just failing.)


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sys/arch/mips/mips/db_disasm.c
cvs rdiff -u -r1.93 -r1.94 src/sys/arch/mips/mips/db_interface.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/riscv/riscv/db_disasm.c \
src/sys/arch/riscv/riscv/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/mips/mips/db_disasm.c
diff -u src/sys/arch/mips/mips/db_disasm.c:1.42 src/sys/arch/mips/mips/db_disasm.c:1.43
--- src/sys/arch/mips/mips/db_disasm.c:1.42	Mon Apr 12 11:35:22 2021
+++ src/sys/arch/mips/mips/db_disasm.c	Sun May 23 23:22:55 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_disasm.c,v 1.42 2021/04/12 11:35:22 simonb Exp $	*/
+/*	$NetBSD: db_disasm.c,v 1.43 2021/05/23 23:22:55 dholland Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.42 2021/04/12 11:35:22 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.43 2021/05/23 23:22:55 dholland Exp $");
 
 #include 
 #include 
@@ -47,6 +47,7 @@ __KERNEL_RCSID(0, "$NetBSD: db_disasm.c,
 
 #include 
 
+#include 
 #include 
 #include 
 #include 
@@ -218,11 +219,6 @@ static void print_addr(db_addr_t);
  * "next instruction" does NOT mean the next instruction to
  * be executed but the 'linear' next instruction.
  */
-#ifdef _LP64
-#define	DISASM_KERN_START	MIPS_XKSEG_START
-#else
-#define	DISASM_KERN_START	MIPS_KSEG0_START
-#endif
 db_addr_t
 db_disasm(db_addr_t loc, bool altfmt)
 {
@@ -232,19 +228,14 @@ db_disasm(db_addr_t loc, bool altfmt)
 	 * Take some care with addresses to not UTLB here as it
 	 * loses the current debugging context.  KSEG2 and XKSEG
 	 * are not checked.
+	 * Update: db_read_bytes is supposed to do that, and now
+	 * does, so we can use that.
+	 *
+	 * XXX db_read_bytes_can't return failure but instead zeros
+	 * the output. That's ok here, but if ever improved the
+	 * proper thing here on error is to return the original loc.
 	 */
-	if (loc < (db_addr_t)DISASM_KERN_START) {
-#ifdef _KERNEL
-		if (ufetch_32((void *)loc, ) != 0) {
-			db_printf("invalid address.\n");
-			return loc;
-		}
-#else
-		return loc;
-#endif
-	} else {
-		instr =  *(uint32_t *)loc;
-	}
+	db_read_bytes(loc, sizeof(instr), (void *));
 
 	return (db_disasm_insn(instr, loc, altfmt));
 }

Index: src/sys/arch/mips/mips/db_interface.c
diff -u src/sys/arch/mips/mips/db_interface.c:1.93 src/sys/arch/mips/mips/db_interface.c:1.94
--- src/sys/arch/mips/mips/db_interface.c:1.93	Mon Apr 12 02:23:41 2021
+++ src/sys/arch/mips/mips/db_interface.c	Sun May 23 23:22:55 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_interface.c,v 1.93 2021/04/12 02:23:41 mrg Exp $	*/
+/*	$NetBSD: db_interface.c,v 1.94 2021/05/23 23:22:55 dholland Exp $	*/
 
 /*
  * Mach Operating System
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.93 2021/04/12 02:23:41 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.94 2021/05/23 23:22:55 dholland Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_multiprocessor.h"
@@ -180,6 +180,23 @@ void
 db_read_bytes(vaddr_t addr, size_t size, char *data)
 {
 	const char *src = (char *)addr;
+	int err;
+
+	/*
+	 * If asked to fetch from userspace, do it safely.
+	 * Note that MIPS_KSEG0_START is the proper address for
+	 * both 32-bit and 64-bit kernels.
+	 */
+	if (addr < (vaddr_t)MIPS_KSEG0_START) {
+		err = copyin(src, data, size);
+		if (err) {
+#ifdef DDB
+			db_printf("address %p is invalid\n", src);
+#endif
+			memset(data, 0, size);
+		}
+		return;
+	}
 
 	if (size <= 8 && (size & (size-1)) == 0 && (addr & (size-1)) == 0
 	&& ((uintptr_t)data & (size-1)) == 0) {
@@ -205,6 +222,18 @@ db_write_bytes(vaddr_t addr, size_t size
 {
 	char *p = (char *)addr;
 	size_t n = size;
+	int err;
+
+	/* If asked to fetch from userspace, do it safely */
+	if (addr < (vaddr_t)MIPS_KSEG0_START) {
+		err = copyout(data, p, size);
+		if (err) {
+#ifdef DDB
+			db_printf("address %p is invalid\n", p);
+#endif
+		}
+		return;
+	}
 
 	if (size <= 8 && (size & (size-1)) == 0 && (addr & (size-1)) == 0
 	&& ((uintptr_t)data & (size-1)) == 0) {

Index: src/sys/arch/riscv/riscv/db_disasm.c
diff -u 

CVS commit: src/sys/arch/alpha/alpha

2021-05-23 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun May 23 19:13:27 UTC 2021

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

Log Message:
Fix a bug in pmap_tlb_shootdown_all_user(), where it was not
stashing away the pointer to the pmap in the TLB context structure
like pmap_tlb_shootdown() was doing.  This would result in the
following failure scenario:

- Page fault handler calls pmap_enter() to map a page.  Mapping
  is the first one for that L2 PT L3 PT, meaning that an L2 PT
  and an L3 PT must be allocated.
- L2 PT allocation succeeds.
- L3 PT allocation fails under memory pressure.
- pmap_enter() goes to drop the reference on the L2 PT, which, because
  it was the first of its mappings, frees the L2 PT.  Becuse PALcode
  may have already tried to service a TLB miss though that L2 PT, we
  must issue an all-user-VA shootdown, and call pmap_tlb_shootdown_all_user()
  to do so.
- pmap_tlb_shootnow() is called and an assert fires because the TLB
  context structure does not point to a pmap.

This did not fail in the pmap_remove() scenario because the TLB context
would have already had at least one call to pmap_tlb_shootdown(), which
was initializing the pmap pointer properly.

PR port-alpha/56200


To generate a diff of this commit:
cvs rdiff -u -r1.276 -r1.277 src/sys/arch/alpha/alpha/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/alpha/alpha/pmap.c
diff -u src/sys/arch/alpha/alpha/pmap.c:1.276 src/sys/arch/alpha/alpha/pmap.c:1.277
--- src/sys/arch/alpha/alpha/pmap.c:1.276	Sat Apr  3 15:29:02 2021
+++ src/sys/arch/alpha/alpha/pmap.c	Sun May 23 19:13:27 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.276 2021/04/03 15:29:02 thorpej Exp $ */
+/* $NetBSD: pmap.c,v 1.277 2021/05/23 19:13:27 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001, 2007, 2008, 2020
@@ -135,7 +135,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.276 2021/04/03 15:29:02 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.277 2021/05/23 19:13:27 thorpej Exp $");
 
 #include 
 #include 
@@ -743,6 +743,9 @@ pmap_tlb_shootdown_all_user(pmap_t const
 		TLB_CTX_SET_FLAG(tlbctx, TLB_CTX_F_IMB);
 	}
 
+	KASSERT(tlbctx->t_pmap == NULL || tlbctx->t_pmap == pmap);
+	tlbctx->t_pmap = pmap;
+
 	TLB_CTX_SET_ALLVA(tlbctx);
 }
 



CVS commit: src/sys/arch/i386/i386

2021-05-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 23 11:56:28 UTC 2021

Modified Files:
src/sys/arch/i386/i386: db_disasm.c

Log Message:
ddb/i386: Don't go out of the way to detect invalid addresses.

db_read_bytes already does this better (but didn't at the time this
check was originally added back in 1998).  Not sure if this code had
the same mistake as the amd64 code causing it to trip over its own
shoelaces, but there should be no need for it here.


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/sys/arch/i386/i386/db_disasm.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/i386/i386/db_disasm.c
diff -u src/sys/arch/i386/i386/db_disasm.c:1.48 src/sys/arch/i386/i386/db_disasm.c:1.49
--- src/sys/arch/i386/i386/db_disasm.c:1.48	Sat Mar  9 08:42:25 2019
+++ src/sys/arch/i386/i386/db_disasm.c	Sun May 23 11:56:28 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_disasm.c,v 1.48 2019/03/09 08:42:25 maxv Exp $	*/
+/*	$NetBSD: db_disasm.c,v 1.49 2021/05/23 11:56:28 riastradh Exp $	*/
 
 /* 
  * Mach Operating System
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.48 2019/03/09 08:42:25 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.49 2021/05/23 11:56:28 riastradh Exp $");
 
 #include 
 #include 
@@ -1132,26 +1132,6 @@ db_disasm(db_addr_t loc, bool altfmt)
 	int	len;
 	struct i_addr	address;
 
-#ifdef _KERNEL
-	pt_entry_t *pte, *pde;
-
-	/*
-	 * Don't try to disassemble the location if the mapping is invalid.
-	 * If we do, we'll fault, and end up debugging the debugger!
-	 * in the case of largepages, "pte" is really the pde and "pde" is
-	 * really the entry for the pdp itself.
-	 */
-	if ((vaddr_t)loc >= VM_MIN_KERNEL_ADDRESS)
-		pte = kvtopte((vaddr_t)loc);
-	else
-		pte = vtopte((vaddr_t)loc);
-	pde = vtopte((vaddr_t)pte);
-	if ((*pde & PTE_P) == 0 || (*pte & PTE_P) == 0) {
-		db_printf("invalid address\n");
-		return (loc);
-	}
-#endif
-
 	get_value_inc(inst, loc, 1, false);
 	short_addr = false;
 	size = LONG;



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

2021-05-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 23 08:59:08 UTC 2021

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

Log Message:
ddb/amd64: Don't go out of the way to detect invalid addresses.

db_disasm had logic to detect invalid addresses before trying to
disassemble them.  But when disassembling a null instruction address,
the logic to detect invalid addresses itself tried to dereference an
invalid address.

db_get_value can already handle this situation gracefully, so there is
no need for this faulty fault-avoidance logic.

Fixes double-fault in ddb on calling null function pointers.  With
any luck, this should make diagnosing such bugs easier in the future!


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/amd64/amd64/db_disasm.c

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

Modified files:

Index: src/sys/arch/amd64/amd64/db_disasm.c
diff -u src/sys/arch/amd64/amd64/db_disasm.c:1.27 src/sys/arch/amd64/amd64/db_disasm.c:1.28
--- src/sys/arch/amd64/amd64/db_disasm.c:1.27	Sat Mar  9 08:42:25 2019
+++ src/sys/arch/amd64/amd64/db_disasm.c	Sun May 23 08:59:08 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_disasm.c,v 1.27 2019/03/09 08:42:25 maxv Exp $	*/
+/*	$NetBSD: db_disasm.c,v 1.28 2021/05/23 08:59:08 riastradh Exp $	*/
 
 /* 
  * Mach Operating System
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.27 2019/03/09 08:42:25 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.28 2021/05/23 08:59:08 riastradh Exp $");
 
 #ifndef _KERNEL
 #include 
@@ -1191,33 +1191,8 @@ db_disasm(db_addr_t loc, bool altfmt)
 	uint64_t imm64;
 	int	len;
 	struct i_addr	address;
-#ifdef _KERNEL
-	pt_entry_t *pte, *pde;
-#endif
 	u_int	rex = 0;
 
-#ifdef _KERNEL
-	/*
-	 * Don't try to disassemble the location if the mapping is invalid.
-	 * If we do, we'll fault, and end up debugging the debugger!
-	 * in the case of largepages, "pte" is really the pde and "pde" is
-	 * really the entry for the pdp itself.
-	 */
-	if ((vaddr_t)loc >= VM_MIN_KERNEL_ADDRESS)
-		pte = kvtopte((vaddr_t)loc);
-	else
-		pte = vtopte((vaddr_t)loc);
-	if ((vaddr_t)pte >= VM_MIN_KERNEL_ADDRESS)
-		pde = kvtopte((vaddr_t)pte);
-	else
-		pde = vtopte((vaddr_t)pte);
-
-	if ((*pde & PTE_P) == 0 || (*pte & PTE_P) == 0) {
-		db_printf("invalid address\n");
-		return (loc);
-	}
-#endif
-
 	get_value_inc(inst, loc, 1, false);
 	short_addr = false;
 	size = LONG;



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

2021-05-22 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun May 23 01:34:18 UTC 2021

Added Files:
src/sys/arch/alpha/conf: GENERIC.QEMU

Log Message:
Add a GENERIC.QEMU kernel config.  This just includes QEMU and then
sets some options specifically to make the Qemu experience a little
batter.

Currently, this just sets COPY_SYMTAB=1 (Qemu loads the kernel directly,
and does not load the symbol table).


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/arch/alpha/conf/GENERIC.QEMU

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

Added files:

Index: src/sys/arch/alpha/conf/GENERIC.QEMU
diff -u /dev/null src/sys/arch/alpha/conf/GENERIC.QEMU:1.1
--- /dev/null	Sun May 23 01:34:18 2021
+++ src/sys/arch/alpha/conf/GENERIC.QEMU	Sun May 23 01:34:17 2021
@@ -0,0 +1,10 @@
+# $NetBSD: GENERIC.QEMU,v 1.1 2021/05/23 01:34:17 thorpej Exp $
+#
+# Generic Alpha kernel specifically configured for Qemu.
+
+include	"arch/alpha/conf/GENERIC"
+
+# reserve symbol space and copy the symbol table into it.  Needed
+# because Qemu does not load the symbol table when loading the
+# kernel.
+makeoptions	COPY_SYMTAB=1



CVS commit: src/sys/arch/alpha/alpha

2021-05-22 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun May 23 01:00:53 UTC 2021

Modified Files:
src/sys/arch/alpha/alpha: locore.s

Log Message:
Fix an error introduced in rev 1.130 where the previous pcb_onfault
handler was not restored properly in the kcopyerr case.  Also add a
comment explaining why it's save for these routines to be wrappers
around memcpy().

Fixes port-alpha/56197.


To generate a diff of this commit:
cvs rdiff -u -r1.136 -r1.137 src/sys/arch/alpha/alpha/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/alpha/alpha/locore.s
diff -u src/sys/arch/alpha/alpha/locore.s:1.136 src/sys/arch/alpha/alpha/locore.s:1.137
--- src/sys/arch/alpha/alpha/locore.s:1.136	Sat Sep 19 01:32:16 2020
+++ src/sys/arch/alpha/alpha/locore.s	Sun May 23 01:00:53 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: locore.s,v 1.136 2020/09/19 01:32:16 thorpej Exp $ */
+/* $NetBSD: locore.s,v 1.137 2021/05/23 01:00:53 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1999, 2000, 2019 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: locore.s,v 1.136 2020/09/19 01:32:16 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locore.s,v 1.137 2021/05/23 01:00:53 thorpej Exp $");
 
 #include "assym.h"
 
@@ -987,6 +987,11 @@ NESTED(copyoutstr, 4, 16, ra, IM_RA|IM_S
  * kcopy() _must_ save and restore the old fault handler since it is
  * called by uiomove(), which may be in the path of servicing a non-fatal
  * page fault.
+ *
+ * N.B. This implementation is a wrapper around memcpy(), which is
+ * implemented in src/common/lib/libc/arch/alpha/string/bcopy.S.
+ * This is safe ONLY because we know that, as implemented, it is
+ * a LEAF function (and thus does not use any callee-saved registers).
  */
 NESTED(kcopy, 3, 32, ra, IM_RA|IM_S0|IM_S1, 0)
 	LDGP(pv)
@@ -1016,10 +1021,7 @@ NESTED(kcopy, 3, 32, ra, IM_RA|IM_S0|IM_
 
 LEAF(kcopyerr, 0)
 	LDGP(pv)
-	.set noat
-	ldq	at_reg, L_PCB(s1)		/* restore the old handler.  */
-	stq	s0, PCB_ONFAULT(at_reg)
-	.set at
+	stq	s0, PCB_ONFAULT(s1)		/* s1 == pcb (from above)*/
 	ldq	ra, (32-8)(sp)			/* restore ra.		 */
 	ldq	s0, (32-16)(sp)			/* restore s0.		 */
 	ldq	s1, (32-24)(sp)			/* restore s1.		 */



CVS commit: src/sys/arch/hpcmips/vr

2021-05-22 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat May 22 16:00:42 UTC 2021

Modified Files:
src/sys/arch/hpcmips/vr: vrgiu.c

Log Message:
Be explicit about our interface attributes.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/sys/arch/hpcmips/vr/vrgiu.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/hpcmips/vr/vrgiu.c
diff -u src/sys/arch/hpcmips/vr/vrgiu.c:1.45 src/sys/arch/hpcmips/vr/vrgiu.c:1.46
--- src/sys/arch/hpcmips/vr/vrgiu.c:1.45	Sat Apr 24 23:36:38 2021
+++ src/sys/arch/hpcmips/vr/vrgiu.c	Sat May 22 16:00:42 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: vrgiu.c,v 1.45 2021/04/24 23:36:38 thorpej Exp $	*/
+/*	$NetBSD: vrgiu.c,v 1.46 2021/05/22 16:00:42 thorpej Exp $	*/
 /*-
  * Copyright (c) 1999-2001
  * Shin Takemura and PocketBSD Project. All rights reserved.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vrgiu.c,v 1.45 2021/04/24 23:36:38 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vrgiu.c,v 1.46 2021/05/22 16:00:42 thorpej Exp $");
 
 #include 
 #include 
@@ -268,7 +268,9 @@ vrgiu_attach(device_t parent, device_t s
 	haa.haa_sc = sc;
 	haa.haa_getchip = vrgiu_getchip;
 	haa.haa_iot = sc->sc_iot;
-	while (config_found(self, , vrgiu_print, CFARG_EOL)) ;
+	while (config_found(self, , vrgiu_print,
+	CFARG_IATTR, "hpcioif",
+	CFARG_EOL)) ;
 	/*
 	 * GIU-ISA bridge
 	 */
@@ -289,7 +291,9 @@ vrgiu_callback(device_t self)
 	haa.haa_sc = sc;
 	haa.haa_getchip = vrgiu_getchip;
 	haa.haa_iot = sc->sc_iot;
-	config_found(self, , vrgiu_print, CFARG_EOL);
+	config_found(self, , vrgiu_print,
+	CFARG_IATTR, "vrisabif",
+	CFARG_EOL);
 }
 
 int



CVS commit: src/sys/arch/alpha/alpha

2021-05-22 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat May 22 15:05:37 UTC 2021

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

Log Message:
Gah, fix cut-and-paste-o.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sys/arch/alpha/alpha/autoconf.c

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

Modified files:

Index: src/sys/arch/alpha/alpha/autoconf.c
diff -u src/sys/arch/alpha/alpha/autoconf.c:1.56 src/sys/arch/alpha/alpha/autoconf.c:1.57
--- src/sys/arch/alpha/alpha/autoconf.c:1.56	Sat May 22 15:04:33 2021
+++ src/sys/arch/alpha/alpha/autoconf.c	Sat May 22 15:05:36 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: autoconf.c,v 1.56 2021/05/22 15:04:33 thorpej Exp $ */
+/* $NetBSD: autoconf.c,v 1.57 2021/05/22 15:05:36 thorpej Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -42,7 +42,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.56 2021/05/22 15:04:33 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.57 2021/05/22 15:05:36 thorpej Exp $");
 
 #include "pci.h"
 
@@ -116,13 +116,6 @@ qemu_find_rootdev(void)
 		}
 	}
 
-	if (prom_qemu_getenv("rootdev", buf, sizeof(buf))) {
-		snprintf(bootinfo.booted_dev, sizeof(bootinfo.booted_dev),
-		"rootdev=%s", buf);
-		booted_device = device_find_by_xname(buf);
-		return;
-	}
-
 	const size_t devlen = strlen("/dev/");
 	const char *cp = buf;
 	char *ecp = [sizeof(buf) - 1];



CVS commit: src/sys/arch/alpha/alpha

2021-05-22 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat May 22 15:04:34 UTC 2021

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

Log Message:
qemu_find_rootdev(): Zero the buffer that we use to fetch the Qemu
"prom" root device variable; junk past the trailing NUL would cause
the way we parse the string to fail.  Also parse rootdev= and root=
the same way ("be liberal in what you accept" approach).


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/sys/arch/alpha/alpha/autoconf.c

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

Modified files:

Index: src/sys/arch/alpha/alpha/autoconf.c
diff -u src/sys/arch/alpha/alpha/autoconf.c:1.55 src/sys/arch/alpha/alpha/autoconf.c:1.56
--- src/sys/arch/alpha/alpha/autoconf.c:1.55	Sat Oct  3 17:31:46 2020
+++ src/sys/arch/alpha/alpha/autoconf.c	Sat May 22 15:04:33 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: autoconf.c,v 1.55 2020/10/03 17:31:46 thorpej Exp $ */
+/* $NetBSD: autoconf.c,v 1.56 2021/05/22 15:04:33 thorpej Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -42,7 +42,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.55 2020/10/03 17:31:46 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.56 2021/05/22 15:04:33 thorpej Exp $");
 
 #include "pci.h"
 
@@ -100,11 +100,22 @@ cpu_configure(void)
 static void
 qemu_find_rootdev(void)
 {
-	char buf[32];
+	char buf[32] = { 0 };
 
 	/*
 	 * Check for "rootdev=wd0".
 	 */
+	if (! prom_qemu_getenv("rootdev", buf, sizeof(buf))) {
+		/*
+		 * Check "root=/dev/wd0a", "root=/dev/hda1", etc.
+		 */
+		if (! prom_qemu_getenv("root", buf, sizeof(buf))) {
+			printf("WARNING: no rootdev= or root= arguments "
+			   "provided by Qemu\n");
+			return;
+		}
+	}
+
 	if (prom_qemu_getenv("rootdev", buf, sizeof(buf))) {
 		snprintf(bootinfo.booted_dev, sizeof(bootinfo.booted_dev),
 		"rootdev=%s", buf);
@@ -112,35 +123,26 @@ qemu_find_rootdev(void)
 		return;
 	}
 
-	/*
-	 * Check for "root=/dev/wd0a", "root=/dev/hda1", etc.
-	 */
-	if (prom_qemu_getenv("root", buf, sizeof(buf))) {
-		const size_t devlen = strlen("/dev/");
-		const char *cp = buf;
-		char *ecp = [sizeof(buf) - 1];
-
-		snprintf(bootinfo.booted_dev, sizeof(bootinfo.booted_dev),
-		"root=%s", buf);
-
-		/* Find the start of the device xname. */
-		if (strlen(cp) > devlen && strncmp(cp, "/dev/", devlen) == 0) {
-			cp += devlen;
-		}
+	const size_t devlen = strlen("/dev/");
+	const char *cp = buf;
+	char *ecp = [sizeof(buf) - 1];
+
+	/* Find the start of the device xname. */
+	if (strlen(cp) > devlen && strncmp(cp, "/dev/", devlen) == 0) {
+		cp += devlen;
+	}
 
-		/* Now strip any partition letter off the end. */
-		while (ecp != cp) {
-			if (*ecp >= '0' && *ecp <= '9') {
-break;
-			}
-			*ecp-- = '\0';
+	/* Now strip any partition letter off the end. */
+	while (ecp != cp) {
+		if (*ecp >= '0' && *ecp <= '9') {
+			break;
 		}
-
-		booted_device = device_find_by_xname(cp);
-		return;
+		*ecp-- = '\0';
 	}
 
-	printf("WARNING: no rootdev= or root= arguments provided by Qemu\n");
+	snprintf(bootinfo.booted_dev, sizeof(bootinfo.booted_dev),
+	"root=%s", cp);
+	booted_device = device_find_by_xname(cp);
 }
 
 void



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

2021-05-21 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri May 21 09:33:27 UTC 2021

Modified Files:
src/sys/arch/arm/rockchip: rk_fb.c

Log Message:
whitespace cleanup


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/rockchip/rk_fb.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/rockchip/rk_fb.c
diff -u src/sys/arch/arm/rockchip/rk_fb.c:1.1 src/sys/arch/arm/rockchip/rk_fb.c:1.2
--- src/sys/arch/arm/rockchip/rk_fb.c:1.1	Sat Nov  9 23:30:14 2019
+++ src/sys/arch/arm/rockchip/rk_fb.c	Fri May 21 09:33:27 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: rk_fb.c,v 1.1 2019/11/09 23:30:14 jmcneill Exp $ */
+/* $NetBSD: rk_fb.c,v 1.2 2021/05/21 09:33:27 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015-2019 Jared McNeill 
@@ -29,7 +29,7 @@
 #include "opt_wsdisplay_compat.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rk_fb.c,v 1.1 2019/11/09 23:30:14 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rk_fb.c,v 1.2 2021/05/21 09:33:27 jmcneill Exp $");
 
 #include 
 #include 
@@ -61,7 +61,6 @@ static int	rk_fb_ioctl(struct drmfb_soft
 static const struct drmfb_params rkfb_drmfb_params = {
 	.dp_mmapfb = rk_fb_mmapfb,
 	.dp_ioctl = rk_fb_ioctl,
-	
 };
 
 CFATTACH_DECL_NEW(rk_fb, sizeof(struct rk_fb_softc),



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

2021-05-19 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu May 20 01:41:55 UTC 2021

Modified Files:
src/sys/arch/arm/rockchip: rk_cru_composite.c

Log Message:
Fix wrong calculation found by kUBSan. OK'd by jmcneill.

 The output was:
UBSan: Undefined Behavior in ../../../../arch/arm/rockchip/
rk_cru_composite.c:86:21, unsigned integer overflow: 0 divrem 0 cannot be
represented in type 'unsigned int'


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/rockchip/rk_cru_composite.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/rockchip/rk_cru_composite.c
diff -u src/sys/arch/arm/rockchip/rk_cru_composite.c:1.5 src/sys/arch/arm/rockchip/rk_cru_composite.c:1.6
--- src/sys/arch/arm/rockchip/rk_cru_composite.c:1.5	Sat Nov 16 13:23:13 2019
+++ src/sys/arch/arm/rockchip/rk_cru_composite.c	Thu May 20 01:41:55 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: rk_cru_composite.c,v 1.5 2019/11/16 13:23:13 jmcneill Exp $ */
+/* $NetBSD: rk_cru_composite.c,v 1.6 2021/05/20 01:41:55 msaitoh Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rk_cru_composite.c,v 1.5 2019/11/16 13:23:13 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rk_cru_composite.c,v 1.6 2021/05/20 01:41:55 msaitoh Exp $");
 
 #include 
 #include 
@@ -83,7 +83,8 @@ rk_cru_composite_get_rate(struct rk_cru_
 		return (u_int)((uint64_t)prate * num / den);
 	} else {
 		const uint32_t val = CRU_READ(sc, composite->muxdiv_reg);
-		const u_int div = __SHIFTOUT(val, composite->div_mask) + 1;
+		const u_int div = (composite->div_mask != 0)
+		? __SHIFTOUT(val, composite->div_mask) + 1 : 1;
 
 		return prate / div;
 	}



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

2021-05-19 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu May 20 01:07:24 UTC 2021

Modified Files:
src/sys/arch/arm/rockchip: rk3399_cru.c

Log Message:
Fix signed integer overflow found by kUBSan. OK'd by jmcneill.

 The output was:
   UBSan: Undefined Behavior in ../../../../arch/arm/rockchip/rk3399_cru.c:
   284:13, signed integer overflow: 59400 - -2086967296 cannot be
   represented in type 'int'


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/arm/rockchip/rk3399_cru.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/rockchip/rk3399_cru.c
diff -u src/sys/arch/arm/rockchip/rk3399_cru.c:1.21 src/sys/arch/arm/rockchip/rk3399_cru.c:1.22
--- src/sys/arch/arm/rockchip/rk3399_cru.c:1.21	Wed Jan 27 03:10:19 2021
+++ src/sys/arch/arm/rockchip/rk3399_cru.c	Thu May 20 01:07:24 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: rk3399_cru.c,v 1.21 2021/01/27 03:10:19 thorpej Exp $ */
+/* $NetBSD: rk3399_cru.c,v 1.22 2021/05/20 01:07:24 msaitoh Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: rk3399_cru.c,v 1.21 2021/01/27 03:10:19 thorpej Exp $");
+__KERNEL_RCSID(1, "$NetBSD: rk3399_cru.c,v 1.22 2021/05/20 01:07:24 msaitoh Exp $");
 
 #include 
 #include 
@@ -281,10 +281,15 @@ rk3399_cru_pll_set_rate(struct rk_cru_so
 
 	best_diff = INT_MAX;
 	for (int i = 0; i < pll->nrates; i++) {
-		const int diff = (int)rate - (int)pll->rates[i].rate;
-		if (abs(diff) < best_diff) {
+		int diff;
+
+		if (rate > pll->rates[i].rate)
+			diff = rate - pll->rates[i].rate;
+		else
+			diff = pll->rates[i].rate - rate;
+		if (diff < best_diff) {
 			pll_rate = >rates[i];
-			best_diff = abs(diff);
+			best_diff = diff;
 		}
 	}
 



CVS commit: src/sys/arch/aarch64

2021-05-19 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed May 19 12:16:01 UTC 2021

Modified Files:
src/sys/arch/aarch64/aarch64: db_interface.c
src/sys/arch/aarch64/include: pmap.h

Log Message:
Make even more pmap agnostic


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/aarch64/aarch64/db_interface.c
cvs rdiff -u -r1.47 -r1.48 src/sys/arch/aarch64/include/pmap.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/db_interface.c
diff -u src/sys/arch/aarch64/aarch64/db_interface.c:1.15 src/sys/arch/aarch64/aarch64/db_interface.c:1.16
--- src/sys/arch/aarch64/aarch64/db_interface.c:1.15	Wed May 19 11:54:17 2021
+++ src/sys/arch/aarch64/aarch64/db_interface.c	Wed May 19 12:16:01 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: db_interface.c,v 1.15 2021/05/19 11:54:17 skrll Exp $ */
+/* $NetBSD: db_interface.c,v 1.16 2021/05/19 12:16:01 skrll Exp $ */
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.15 2021/05/19 11:54:17 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.16 2021/05/19 12:16:01 skrll Exp $");
 
 #include 
 #include 
@@ -411,14 +411,14 @@ db_pte_print(pt_entry_t pte, int level,
 			break;
 		}
 
-		if (pte & LX_BLKPAG_OS_BOOT)
-			pr(", boot");
-		if (pte & LX_BLKPAG_OS_READ)
-			pr(", pmap_read");
-		if (pte & LX_BLKPAG_OS_WRITE)
-			pr(", pmap_write");
-		if (pte & LX_BLKPAG_OS_WIRED)
-			pr(", wired");
+		if (pte & LX_BLKPAG_OS_0)
+			pr(", " PMAP_PTE_OS0);
+		if (pte & LX_BLKPAG_OS_1)
+			pr(", " PMAP_PTE_OS1);
+		if (pte & LX_BLKPAG_OS_2)
+			pr(", " PMAP_PTE_OS2);
+		if (pte & LX_BLKPAG_OS_3)
+			pr(", " PMAP_PTE_OS3);
 	} else {
 		pr(" **ILLEGAL TYPE**");
 	}
@@ -526,7 +526,6 @@ dump_ln_table(bool countmode, pd_entry_t
 vaddr_t va, void (*pr)(const char *, ...) __printflike(1, 2))
 {
 	struct vm_page *pg;
-	struct vm_page_md *md;
 	pd_entry_t pde;
 	paddr_t pa;
 	int i, n;
@@ -535,13 +534,11 @@ dump_ln_table(bool countmode, pd_entry_t
 
 	pa = AARCH64_KVA_TO_PA((vaddr_t)pdp);
 	pg = PHYS_TO_VM_PAGE(pa);
-	md = VM_PAGE_TO_MD(pg);
 
 	if (pg == NULL) {
 		pr("%sL%d: pa=%lx pg=NULL\n", spc, level, pa);
 	} else {
-		pr("%sL%d: pa=%lx pg=%p, wire_count=%d, mdpg_ptep_parent=%p\n",
-		spc, level, pa, pg, pg->wire_count, md->mdpg_ptep_parent);
+		pr("%sL%d: pa=%lx pg=%p", spc, level, pa, pg);
 	}
 
 	for (i = n = 0; i < Ln_ENTRIES; i++) {

Index: src/sys/arch/aarch64/include/pmap.h
diff -u src/sys/arch/aarch64/include/pmap.h:1.47 src/sys/arch/aarch64/include/pmap.h:1.48
--- src/sys/arch/aarch64/include/pmap.h:1.47	Fri Apr 30 20:07:23 2021
+++ src/sys/arch/aarch64/include/pmap.h	Wed May 19 12:16:01 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.h,v 1.47 2021/04/30 20:07:23 skrll Exp $ */
+/* $NetBSD: pmap.h,v 1.48 2021/05/19 12:16:01 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -130,6 +130,11 @@ struct vm_page_md {
 #define LX_BLKPAG_OS_BOOT		LX_BLKPAG_OS_3
 #define LX_BLKPAG_OS_RWMASK		(LX_BLKPAG_OS_WRITE|LX_BLKPAG_OS_READ)
 
+#define PMAP_PTE_OS0	"read"
+#define PMAP_PTE_OS1	"write"
+#define PMAP_PTE_OS2	"wired"
+#define PMAP_PTE_OS3	"boot"
+
 /* memory attributes are configured MAIR_EL1 in locore */
 #define LX_BLKPAG_ATTR_NORMAL_WB	__SHIFTIN(0, LX_BLKPAG_ATTR_INDX)
 #define LX_BLKPAG_ATTR_NORMAL_NC	__SHIFTIN(1, LX_BLKPAG_ATTR_INDX)



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

2021-05-19 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed May 19 11:54:18 UTC 2021

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

Log Message:
Reduce characters to print in db_pte_print and unwrap some short lines.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/aarch64/aarch64/db_interface.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_interface.c
diff -u src/sys/arch/aarch64/aarch64/db_interface.c:1.14 src/sys/arch/aarch64/aarch64/db_interface.c:1.15
--- src/sys/arch/aarch64/aarch64/db_interface.c:1.14	Mon May  3 19:33:09 2021
+++ src/sys/arch/aarch64/aarch64/db_interface.c	Wed May 19 11:54:17 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: db_interface.c,v 1.14 2021/05/03 19:33:09 skrll Exp $ */
+/* $NetBSD: db_interface.c,v 1.15 2021/05/19 11:54:17 skrll Exp $ */
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.14 2021/05/03 19:33:09 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.15 2021/05/19 11:54:17 skrll Exp $");
 
 #include 
 #include 
@@ -360,15 +360,13 @@ db_pte_print(pt_entry_t pte, int level,
 
 		pr(", PA=%lx", l3pte_pa(pte));
 
-		pr(", %s", (pte & LX_BLKPAG_UXN) ?
-		"UXN" : "UX ");
-		pr(", %s", (pte & LX_BLKPAG_PXN) ?
-		   "PXN" :  "PX ");
+		pr(", %s", (pte & LX_BLKPAG_UXN) ? "UXN" : "UX");
+		pr(", %s", (pte & LX_BLKPAG_PXN) ? "PXN" : "PX");
 
 		if (pte & LX_BLKPAG_CONTIG)
 			pr(", CONTIG");
 
-		pr(", %s", (pte & LX_BLKPAG_NG) ? "NG" : "global");
+		pr(", %s", (pte & LX_BLKPAG_NG) ? "nG" : "G");
 		pr(", %s", (pte & LX_BLKPAG_AF) ?
 		"accessible" :
 		"**fault** ");
@@ -403,10 +401,10 @@ db_pte_print(pt_entry_t pte, int level,
 			pr(", WT");
 			break;
 		case LX_BLKPAG_ATTR_DEVICE_MEM:
-			pr(", DEVICE");
+			pr(", DEV");
 			break;
 		case LX_BLKPAG_ATTR_DEVICE_MEM_SO:
-			pr(", DEVICE(SO)");
+			pr(", DEV(SO)");
 			break;
 		default:
 			pr(", ATTR(%lu)", __SHIFTOUT(pte, LX_BLKPAG_ATTR_INDX));



CVS commit: src/sys/arch/amiga/stand/bootblock/elf2bb

2021-05-18 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Tue May 18 20:34:20 UTC 2021

Modified Files:
src/sys/arch/amiga/stand/bootblock/elf2bb: elf2bb.c

Log Message:
Remove some unused variables, found by gcc -Wall.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/amiga/stand/bootblock/elf2bb/elf2bb.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/amiga/stand/bootblock/elf2bb/elf2bb.c
diff -u src/sys/arch/amiga/stand/bootblock/elf2bb/elf2bb.c:1.19 src/sys/arch/amiga/stand/bootblock/elf2bb/elf2bb.c:1.20
--- src/sys/arch/amiga/stand/bootblock/elf2bb/elf2bb.c:1.19	Tue May 18 20:32:18 2021
+++ src/sys/arch/amiga/stand/bootblock/elf2bb/elf2bb.c	Tue May 18 20:34:20 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: elf2bb.c,v 1.19 2021/05/18 20:32:18 dholland Exp $	*/
+/*	$NetBSD: elf2bb.c,v 1.20 2021/05/18 20:34:20 dholland Exp $	*/
 
 /*-
  * Copyright (c) 1996,2006 The NetBSD Foundation, Inc.
@@ -92,7 +92,6 @@ int
 main(int argc, char *argv[])
 {
 	int ifd, ofd;
-	u_int mid, flags, magic;
 	void *image;
 	Elf32_Ehdr *eh;
 	Elf32_Shdr *sh;
@@ -104,7 +103,7 @@ main(int argc, char *argv[])
 	int i, l, delta;
 	u_int8_t *rpo;
 	u_int32_t oldaddr, addrdiff;
-	u_int32_t tsz, dsz, bsz, trsz, drsz, entry, relver;
+	u_int32_t tsz, dsz, bsz, trsz, relver;
 	u_int32_t pcrelsz, r32sz;
 	int sumsize = 16;
 	int c;



CVS commit: src/sys/arch/amiga/stand/bootblock/elf2bb

2021-05-18 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Tue May 18 20:32:18 UTC 2021

Modified Files:
src/sys/arch/amiga/stand/bootblock/elf2bb: elf2bb.c

Log Message:
Print ptrdiff_t with %td, not %d. Appeared in passing in PR 56188.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/amiga/stand/bootblock/elf2bb/elf2bb.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/amiga/stand/bootblock/elf2bb/elf2bb.c
diff -u src/sys/arch/amiga/stand/bootblock/elf2bb/elf2bb.c:1.18 src/sys/arch/amiga/stand/bootblock/elf2bb/elf2bb.c:1.19
--- src/sys/arch/amiga/stand/bootblock/elf2bb/elf2bb.c:1.18	Thu Feb 25 03:40:27 2021
+++ src/sys/arch/amiga/stand/bootblock/elf2bb/elf2bb.c	Tue May 18 20:32:18 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: elf2bb.c,v 1.18 2021/02/25 03:40:27 rin Exp $	*/
+/*	$NetBSD: elf2bb.c,v 1.19 2021/05/18 20:32:18 dholland Exp $	*/
 
 /*-
  * Copyright (c) 1996,2006 The NetBSD Foundation, Inc.
@@ -421,7 +421,7 @@ retry:
 	*rpo = 0; rpo += delta;
 	*rpo = 0; rpo += delta;
 
-	printf("using %d bytes, %d bytes remaining.\n", delta > 0 ?
+	printf("using %td bytes, %td bytes remaining.\n", delta > 0 ?
 	rpo-buffer-tsz-dsz : buffer+bbsize-rpo, delta > 0 ?
 	buffer + bbsize - rpo : rpo - buffer - tsz - dsz);
 	/*



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

2021-05-18 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Tue May 18 15:21:41 UTC 2021

Modified Files:
src/sys/arch/hp300/dev: rdreg.h

Log Message:
Consistently use #define here.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/hp300/dev/rdreg.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/hp300/dev/rdreg.h
diff -u src/sys/arch/hp300/dev/rdreg.h:1.13 src/sys/arch/hp300/dev/rdreg.h:1.14
--- src/sys/arch/hp300/dev/rdreg.h:1.13	Tue Feb  8 20:20:13 2011
+++ src/sys/arch/hp300/dev/rdreg.h	Tue May 18 15:21:41 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: rdreg.h,v 1.13 2011/02/08 20:20:13 rmind Exp $	*/
+/*	$NetBSD: rdreg.h,v 1.14 2021/05/18 15:21:41 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -78,9 +78,9 @@ struct	rd_stat {
 		} cu_tva;
 	} c_pf;
 } __attribute__((__packed__));
-#define c_raw	c_pf.cu_raw
-#define c_blk	c_pf.cu_sva.cu_lsl	/* for now */
-#define c_tva	c_pf.cu_tva
+#define	c_raw	c_pf.cu_raw
+#define	c_blk	c_pf.cu_sva.cu_lsl	/* for now */
+#define	c_tva	c_pf.cu_tva
 
 struct	rd_ssmcmd {
 	char	c_unit;
@@ -132,18 +132,18 @@ struct rd_describe {
 #define	RD9134DID	0x221	/* also 9122S */
 #define	RD9134LID	0x222	/* also 9122D */
 #define	RD7912PID	0x209
-#define RD7914CTID	0x20A
+#define	RD7914CTID	0x20A
 #define	RD7914PID	0x20B
 #define	RD7958AID	0x22B
-#define RD7957AID	0x22A
+#define	RD7957AID	0x22A
 #define	RD7933HID	0x212
 #define	RD7936HID	0x213	/* just guessing -- as of yet unknown */
 #define	RD7937HID	0x214
-#define RD7957BID	0x22C	/* another guess based on 7958B */
-#define RD7958BID	0x22D
-#define RD7959BID	0x22E	/* another guess based on 7958B */
-#define RD2200AID	0x22F
-#define RD2203AID	0x230	/* yet another guess */
+#define	RD7957BID	0x22C	/* another guess based on 7958B */
+#define	RD7958BID	0x22D
+#define	RD7959BID	0x22E	/* another guess based on 7958B */
+#define	RD2200AID	0x22F
+#define	RD2203AID	0x230	/* yet another guess */
 
 /* SW ids -- indicies into rdidentinfo, order is arbitrary */
 #define	RD7945A		0
@@ -152,17 +152,17 @@ struct rd_describe {
 #define	RD7912P		3
 #define	RD7914P		4
 #define	RD7958A		5
-#define RD7957A		6
+#define	RD7957A		6
 #define	RD7933H		7
 #define	RD9134L		8
 #define	RD7936H		9
 #define	RD7937H		10
-#define RD7914CT	11
-#define RD7946A		12
-#define RD9122D		13
-#define RD7957B		14
-#define RD7958B		15
-#define RD7959B		16
+#define	RD7914CT	11
+#define	RD7946A		12
+#define	RD9122D		13
+#define	RD7957B		14
+#define	RD7958B		15
+#define	RD7959B		16
 
 #define	NRD7945ABPT	16
 #define	NRD7945ATRK	7
@@ -226,31 +226,31 @@ struct rd_describe {
 #define	RDCTLR		15
 
 /* convert 512 byte count into DEV_BSIZE count */
-#define RDSZ(x)		((x) >> (DEV_BSHIFT-9))
+#define	RDSZ(x)		((x) >> (DEV_BSHIFT-9))
 
 /* convert block number into sector number and back */
 #define	RDBTOS(x)	((x) << (DEV_BSHIFT-8))
-#define RDSTOB(x)	((x) >> (DEV_BSHIFT-8))
+#define	RDSTOB(x)	((x) >> (DEV_BSHIFT-8))
 
 /* extract cyl/head/sect info from three-vector address */
-#define RDCYL(tva)	((u_long)(tva).cu_cyhd >> 8)
-#define RDHEAD(tva)	((tva).cu_cyhd & 0xFF)
-#define RDSECT(tva)	((tva).cu_sect)
+#define	RDCYL(tva)	((u_long)(tva).cu_cyhd >> 8)
+#define	RDHEAD(tva)	((tva).cu_cyhd & 0xFF)
+#define	RDSECT(tva)	((tva).cu_sect)
 
 #define	REF_MASK	0x0
 #define	FEF_MASK	0x0
 #define	AEF_MASK	0x0
 #define	IEF_MASK	0xF970
 
-#define FEF_CU		0x4000	/* cross-unit */
-#define FEF_DR		0x0080	/* diagnostic result */
-#define FEF_IMR		0x0008	/* internal maintenance release */
+#define	FEF_CU		0x4000	/* cross-unit */
+#define	FEF_DR		0x0080	/* diagnostic result */
+#define	FEF_IMR		0x0008	/* internal maintenance release */
 #define	FEF_PF		0x0002	/* power fail */
 #define	FEF_REXMT	0x0001	/* retransmit */
-#define AEF_UD		0x0040	/* unrecoverable data */
-#define IEF_RRMASK	0xe000	/* request release bits */
-#define IEF_MD		0x0020	/* marginal data */
-#define IEF_RD		0x0010	/* recoverable data */
+#define	AEF_UD		0x0040	/* unrecoverable data */
+#define	IEF_RRMASK	0xe000	/* request release bits */
+#define	IEF_MD		0x0020	/* marginal data */
+#define	IEF_RD		0x0010	/* recoverable data */
 
 #define	C_READ		0x00
 #define	C_RAM		0x00	/* single vector (i.e. sector number) */
@@ -260,13 +260,13 @@ struct rd_describe {
 #define	C_SADDR		0x10
 #define	C_SLEN		0x18
 #define	C_SUNIT(x)	(0x20 | (x))
-#define C_SVOL(x)	(0x40 | (x))
+#define	C_SVOL(x)	(0x40 | (x))
 #define	C_NOP		0x34
-#define C_DESC		0x35
+#define	C_DESC		0x35
 #define	C_SREL		0x3b
 #define	C_SSM		0x3e
 #define	C_SRAM		0x48
-#define C_REL		0xc0
+#define	C_REL		0xc0
 
 #define	C_CMD		0x05
 #define	C_EXEC		0x0e



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

2021-05-18 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue May 18 06:42:12 UTC 2021

Modified Files:
src/sys/arch/riscv/include: db_machdep.h

Log Message:
Use #define in this file


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/riscv/include/db_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/riscv/include/db_machdep.h
diff -u src/sys/arch/riscv/include/db_machdep.h:1.4 src/sys/arch/riscv/include/db_machdep.h:1.5
--- src/sys/arch/riscv/include/db_machdep.h:1.4	Tue May 18 06:40:16 2021
+++ src/sys/arch/riscv/include/db_machdep.h	Tue May 18 06:42:11 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: db_machdep.h,v 1.4 2021/05/18 06:40:16 skrll Exp $ */
+/* $NetBSD: db_machdep.h,v 1.5 2021/05/18 06:42:11 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -47,19 +47,19 @@ extern const uint32_t __cpu_Debugger_ins
 
 #define	PC_REGS(tf)	((tf)->tf_pc)
 
-#define PC_ADVANCE(tf) do {		\
+#define	PC_ADVANCE(tf) do {		\
 	if (db_get_value((tf)->tf_pc, sizeof(uint32_t), false) == BKPT_INST) \
 		(tf)->tf_pc += BKPT_SIZE;			\
 } while(0)
 
 /* Similar to PC_ADVANCE(), except only advance on cpu_Debugger()'s bpt */
-#define PC_BREAK_ADVANCE(tf) do {\
+#define	PC_BREAK_ADVANCE(tf) do {\
 	if ((tf)->tf_pc == (register_t) __cpu_Debugger_insn)	\
 		(tf)->tf_pc += BKPT_SIZE;			\
 } while(0)
 
 #define	BKPT_ADDR(addr)		(addr)			/* breakpoint address */
-#define BKPT_INST		0x00100073
+#define	BKPT_INST		0x00100073
 #define	BKPT_SIZE		(sizeof(uint32_t))	/* size of bkpt inst */
 #define	BKPT_SET(inst, addr)	(BKPT_INST)
 
@@ -70,12 +70,12 @@ extern const uint32_t __cpu_Debugger_ins
  * MI ddb can't cope with having two sizes :-(
  */
 #if 0
-#define BKPT_INST_2	0x9002
-#define BKPT_SIZE_2	(sizeof(uint16_t))
+#define	BKPT_INST_2	0x9002
+#define	BKPT_SIZE_2	(sizeof(uint16_t))
 #endif
 
 #define	IS_BREAKPOINT_TRAP(type, code)	((type) == CAUSE_BREAKPOINT)
-#define IS_WATCHPOINT_TRAP(type, code)	(0)
+#define	IS_WATCHPOINT_TRAP(type, code)	(0)
 
 /*
  * Interface to disassembly
@@ -106,9 +106,9 @@ typedef	register_t	kgdb_reg_t;
 /*
  * RISCV cpus have no hardware single-step.
  */
-#define SOFTWARE_SSTEP
+#define	SOFTWARE_SSTEP
 
-#define inst_trap_return(ins)	((ins)&0)
+#define	inst_trap_return(ins)	((ins)&0)
 
 bool	inst_branch(uint32_t inst);
 bool	inst_call(uint32_t inst);
@@ -127,7 +127,7 @@ void db_resume_others(void);
 /*
  * We have machine-dependent commands.
  */
-#define DB_MACHINE_COMMANDS
+#define	DB_MACHINE_COMMANDS
 #endif
 
 #endif	/* _RISCV_DB_MACHDEP_H_ */



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

2021-05-18 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue May 18 06:40:16 UTC 2021

Modified Files:
src/sys/arch/riscv/include: db_machdep.h

Log Message:
Remove argument names from function declaration prototypes.
Misc tidyup.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/riscv/include/db_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/riscv/include/db_machdep.h
diff -u src/sys/arch/riscv/include/db_machdep.h:1.3 src/sys/arch/riscv/include/db_machdep.h:1.4
--- src/sys/arch/riscv/include/db_machdep.h:1.3	Wed Apr 14 06:32:20 2021
+++ src/sys/arch/riscv/include/db_machdep.h	Tue May 18 06:40:16 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: db_machdep.h,v 1.3 2021/04/14 06:32:20 dholland Exp $ */
+/* $NetBSD: db_machdep.h,v 1.4 2021/05/18 06:40:16 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -28,6 +28,7 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
+
 #ifndef	_RISCV_DB_MACHDEP_H_
 #define	_RISCV_DB_MACHDEP_H_
 
@@ -57,9 +58,9 @@ extern const uint32_t __cpu_Debugger_ins
 		(tf)->tf_pc += BKPT_SIZE;			\
 } while(0)
 
-#define	BKPT_ADDR(addr)	(addr)		/* breakpoint address */
-#define BKPT_INST	0x00100073
-#define	BKPT_SIZE	(sizeof(uint32_t))	/* size of breakpoint inst */
+#define	BKPT_ADDR(addr)		(addr)			/* breakpoint address */
+#define BKPT_INST		0x00100073
+#define	BKPT_SIZE		(sizeof(uint32_t))	/* size of bkpt inst */
 #define	BKPT_SET(inst, addr)	(BKPT_INST)
 
 /*
@@ -79,14 +80,14 @@ extern const uint32_t __cpu_Debugger_ins
 /*
  * Interface to disassembly
  */
-db_addr_t	db_disasm_insn(uint32_t insn, db_addr_t loc, bool altfmt);
+db_addr_t	db_disasm_insn(uint32_t, db_addr_t, bool);
 
 
 /*
  * Entrypoints to DDB for kernel, keyboard drivers, init hook
  */
 void 	kdb_kbd_trap(db_regs_t *);
-int 	kdb_trap(int type, struct trapframe *);
+int 	kdb_trap(int, struct trapframe *);
 
 static inline void
 db_set_ddb_regs(int type, struct trapframe *tf)



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

2021-05-18 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue May 18 06:38:24 UTC 2021

Modified Files:
src/sys/arch/mips/include: db_machdep.h

Log Message:
Remove argument names from function declaration prototypes.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/arch/mips/include/db_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/mips/include/db_machdep.h
diff -u src/sys/arch/mips/include/db_machdep.h:1.37 src/sys/arch/mips/include/db_machdep.h:1.38
--- src/sys/arch/mips/include/db_machdep.h:1.37	Mon Mar 29 03:09:41 2021
+++ src/sys/arch/mips/include/db_machdep.h	Tue May 18 06:38:24 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: db_machdep.h,v 1.37 2021/03/29 03:09:41 simonb Exp $ */
+/* $NetBSD: db_machdep.h,v 1.38 2021/05/18 06:38:24 skrll Exp $ */
 
 /*
  * Copyright (c) 1997 Jonathan Stone (hereinafter referred to as the author)
@@ -91,7 +91,7 @@ db_addr_t	db_disasm_insn(int insn, db_ad
  * Entrypoints to DDB for kernel, keyboard drivers, init hook
  */
 void 	kdb_kbd_trap(db_regs_t *);
-int 	kdb_trap(int type, struct reg *);
+int 	kdb_trap(int, struct reg *);
 
 static inline void
 db_set_ddb_regs(int type, struct reg *regs)
@@ -103,7 +103,7 @@ db_set_ddb_regs(int type, struct reg *re
  * Helper functions for fetching 32-bit and 64-bit kernel memory.
  */
 bool		kdbpeek(vaddr_t, unsigned *);
-mips_reg_t	kdbrpeek(vaddr_t addr, size_t n);
+mips_reg_t	kdbrpeek(vaddr_t, size_t);
 
 
 /*



CVS commit: src/sys/arch/mipsco/stand

2021-05-17 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Mon May 17 22:36:31 UTC 2021

Modified Files:
src/sys/arch/mipsco/stand: Makefile.booters

Log Message:
also strip .eh_frame.  libkern dkcksum pushed bootxx_ffs 7 bytes over a limit.

remove an old comment.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/mipsco/stand/Makefile.booters

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/mipsco/stand/Makefile.booters
diff -u src/sys/arch/mipsco/stand/Makefile.booters:1.24 src/sys/arch/mipsco/stand/Makefile.booters:1.25
--- src/sys/arch/mipsco/stand/Makefile.booters:1.24	Sat Apr  8 19:53:21 2017
+++ src/sys/arch/mipsco/stand/Makefile.booters	Mon May 17 22:36:31 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.booters,v 1.24 2017/04/08 19:53:21 christos Exp $
+#	$NetBSD: Makefile.booters,v 1.25 2021/05/17 22:36:31 mrg Exp $
 
 NOMAN=		# defined
 NOPIE=		# defined
@@ -26,8 +26,6 @@ AFLAGS+=	-D_LOCORE -D_KERNEL -DASSEMBLER
 # -I${.CURDIR}/../.. done by Makefile.inc
 CPPFLAGS+=	-nostdinc -D_STANDALONE -DNO_ABICALLS -D_NO_PROM_DEFINES
 CPPFLAGS+=	-I${.OBJDIR} -I${S}
-# compiler flags for smallest code size
-#CFLAGS=		-Os -mmemcpy -mno-abicalls -G 128
 CFLAGS=		-Os -mmemcpy -ffreestanding -mno-abicalls -msoft-float -G 128
 CFLAGS+=	-Wall -Wmissing-prototypes -Wstrict-prototypes -Wpointer-arith
 
@@ -68,7 +66,7 @@ CPPFLAGS+=	-DPRIMARY_BOOTBLOCK \
 CHECKSIZE_CMD?=	SIZE=${SIZE} ${HOST_SH} ${.CURDIR}/../common/checksize.sh
 
 STRIPSECTIONS?= -R .reginfo -R .mdebug.abi32 -R .comment -R .pdr \
-	-R .MIPS.abiflags  -R .gnu.attributes
+	-R .MIPS.abiflags  -R .gnu.attributes -R .eh_frame
 
 .elif defined(SECONDARY_PROG)
 PROG=		${SECONDARY_PROG}



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

2021-05-17 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Mon May 17 20:21:05 UTC 2021

Modified Files:
src/sys/arch/ofppc/stand/ofwboot: mbr.c rdb.c

Log Message:
include libkern.h for moved dkcksum().


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/ofppc/stand/ofwboot/mbr.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/ofppc/stand/ofwboot/rdb.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/ofppc/stand/ofwboot/mbr.c
diff -u src/sys/arch/ofppc/stand/ofwboot/mbr.c:1.5 src/sys/arch/ofppc/stand/ofwboot/mbr.c:1.6
--- src/sys/arch/ofppc/stand/ofwboot/mbr.c:1.5	Wed Mar 30 21:14:54 2016
+++ src/sys/arch/ofppc/stand/ofwboot/mbr.c	Mon May 17 20:21:05 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: mbr.c,v 1.5 2016/03/30 21:14:54 christos Exp $	*/
+/*	$NetBSD: mbr.c,v 1.6 2021/05/17 20:21:05 mrg Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -34,6 +34,7 @@
 #include 
 #include 
 
+#include 
 #include 
 #include 
 

Index: src/sys/arch/ofppc/stand/ofwboot/rdb.c
diff -u src/sys/arch/ofppc/stand/ofwboot/rdb.c:1.2 src/sys/arch/ofppc/stand/ofwboot/rdb.c:1.3
--- src/sys/arch/ofppc/stand/ofwboot/rdb.c:1.2	Sat Jun 19 08:48:33 2010
+++ src/sys/arch/ofppc/stand/ofwboot/rdb.c	Mon May 17 20:21:05 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: rdb.c,v 1.2 2010/06/19 08:48:33 kiyohara Exp $	*/
+/*	$NetBSD: rdb.c,v 1.3 2021/05/17 20:21:05 mrg Exp $	*/
 
 /*-
  * Copyright (c) 2009 Frank Wille.
@@ -31,6 +31,7 @@
 #include 
 #include 
 
+#include 
 #include 
 
 #include "rdb.h"



CVS commit: src/sys/arch

2021-05-17 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Mon May 17 19:31:39 UTC 2021

Modified Files:
src/sys/arch/atari/stand/libsa: diskio.c
src/sys/arch/landisk/stand/boot: biosdisk.c
src/sys/arch/luna68k/stand/boot: ufs_disksubr.c

Log Message:
include libkern.h to get moved dkcksum() definition.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/atari/stand/libsa/diskio.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/landisk/stand/boot/biosdisk.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/luna68k/stand/boot/ufs_disksubr.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/atari/stand/libsa/diskio.c
diff -u src/sys/arch/atari/stand/libsa/diskio.c:1.8 src/sys/arch/atari/stand/libsa/diskio.c:1.9
--- src/sys/arch/atari/stand/libsa/diskio.c:1.8	Tue Mar 17 00:18:40 2009
+++ src/sys/arch/atari/stand/libsa/diskio.c	Mon May 17 19:31:38 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: diskio.c,v 1.8 2009/03/17 00:18:40 he Exp $	*/
+/*	$NetBSD: diskio.c,v 1.9 2021/05/17 19:31:38 mrg Exp $	*/
 
 /*
  * Copyright (c) 1995 Waldi Ravens.
@@ -34,6 +34,8 @@
 #include "atari_stand.h"
 #include 
 
+#include 
+
 typedef int (*rdsec_f)(void *buffer, u_int offset, u_int count);
 typedef	struct { rdsec_f rds; u_int rst; u_int rend; } bdevd_t;
 

Index: src/sys/arch/landisk/stand/boot/biosdisk.c
diff -u src/sys/arch/landisk/stand/boot/biosdisk.c:1.3 src/sys/arch/landisk/stand/boot/biosdisk.c:1.4
--- src/sys/arch/landisk/stand/boot/biosdisk.c:1.3	Sun Jul 17 20:54:43 2011
+++ src/sys/arch/landisk/stand/boot/biosdisk.c	Mon May 17 19:31:38 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: biosdisk.c,v 1.3 2011/07/17 20:54:43 joerg Exp $	*/
+/*	$NetBSD: biosdisk.c,v 1.4 2021/05/17 19:31:38 mrg Exp $	*/
 
 /*
  * Copyright (c) 1996, 1998
@@ -66,6 +66,7 @@
 #include 
 #include 
 
+#include 
 #include 
 #include 
 #include 

Index: src/sys/arch/luna68k/stand/boot/ufs_disksubr.c
diff -u src/sys/arch/luna68k/stand/boot/ufs_disksubr.c:1.5 src/sys/arch/luna68k/stand/boot/ufs_disksubr.c:1.6
--- src/sys/arch/luna68k/stand/boot/ufs_disksubr.c:1.5	Sat Feb 14 05:03:09 2015
+++ src/sys/arch/luna68k/stand/boot/ufs_disksubr.c	Mon May 17 19:31:38 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_disksubr.c,v 1.5 2015/02/14 05:03:09 tsutsui Exp $	*/
+/*	$NetBSD: ufs_disksubr.c,v 1.6 2021/05/17 19:31:38 mrg Exp $	*/
 
 /*
  * Copyright (c) 1992 OMRON Corporation.
@@ -77,6 +77,9 @@
 
 #include 
 #include 
+
+#include 
+
 #include 
 #include 
 



CVS commit: src/sys/arch/riscv/riscv

2021-05-16 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun May 16 09:02:04 UTC 2021

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

Log Message:
s/ENTRY/ENTRY_NP/ in a few places


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/riscv/riscv/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/riscv/riscv/locore.S
diff -u src/sys/arch/riscv/riscv/locore.S:1.21 src/sys/arch/riscv/riscv/locore.S:1.22
--- src/sys/arch/riscv/riscv/locore.S:1.21	Sat May  1 07:10:34 2021
+++ src/sys/arch/riscv/riscv/locore.S	Sun May 16 09:02:04 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: locore.S,v 1.21 2021/05/01 07:10:34 skrll Exp $ */
+/* $NetBSD: locore.S,v 1.22 2021/05/16 09:02:04 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -479,7 +479,7 @@ END(cpu_exception_handler)
 
 // int cpu_set_onfault(struct faultbuf *fb, register_t retval)
 //
-ENTRY(cpu_set_onfault)
+ENTRY_NP(cpu_set_onfault)
 	REG_S	ra, FB_RA(a0)
 	REG_S	s0, FB_S0(a0)
 	REG_S	s1, FB_S1(a0)
@@ -500,7 +500,7 @@ ENTRY(cpu_set_onfault)
 	ret
 END(cpu_set_onfault)
 
-ENTRY(setjmp)
+ENTRY_NP(setjmp)
 	REG_S	ra, FB_RA(a0)
 	REG_S	s0, FB_S0(a0)
 	REG_S	s1, FB_S1(a0)
@@ -519,7 +519,7 @@ ENTRY(setjmp)
 	ret
 END(setjmp)
 
-ENTRY(longjmp)
+ENTRY_NP(longjmp)
 	REG_L	ra, FB_RA(a0)
 	REG_L	s0, FB_S0(a0)
 	REG_L	s1, FB_S1(a0)



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

2021-05-15 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sat May 15 11:39:20 UTC 2021

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

Log Message:
Wrap long line. No binary changes.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/aarch64/aarch64/aarch32_syscall.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/aarch32_syscall.c
diff -u src/sys/arch/aarch64/aarch64/aarch32_syscall.c:1.4 src/sys/arch/aarch64/aarch64/aarch32_syscall.c:1.5
--- src/sys/arch/aarch64/aarch64/aarch32_syscall.c:1.4	Sat May 15 11:38:26 2021
+++ src/sys/arch/aarch64/aarch64/aarch32_syscall.c	Sat May 15 11:39:20 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: aarch32_syscall.c,v 1.4 2021/05/15 11:38:26 rin Exp $	*/
+/*	$NetBSD: aarch32_syscall.c,v 1.5 2021/05/15 11:39:20 rin Exp $	*/
 
 /*
  * Copyright (c) 2018 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: aarch32_syscall.c,v 1.4 2021/05/15 11:38:26 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: aarch32_syscall.c,v 1.5 2021/05/15 11:39:20 rin Exp $");
 
 #include 
 #include 
@@ -151,7 +151,8 @@ EMULNAME(syscall)(struct trapframe *tf)
 	do_trace = p->p_trace_enabled &&
 	((callp->sy_flags & SYCALL_INDIRECT) == 0);
 	if (__predict_false(do_trace ||
-	KDTRACE_ENTRY(callp->sy_entry) || KDTRACE_ENTRY(callp->sy_return))) {
+	KDTRACE_ENTRY(callp->sy_entry) ||
+	KDTRACE_ENTRY(callp->sy_return))) {
 		/* build 64bit args for trace_enter()/trace_exit() */
 		int nargs = callp->sy_narg;
 		for (i = 0; i < nargs; i++)



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

2021-05-15 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sat May 15 11:38:26 UTC 2021

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

Log Message:
Fix __syscall(2) for COMPAT_NETBSD32 on aarch64{,eb}.

The 1st argument for __syscall(2) is quad_t, which is stored in r0 and r1.

Now, tests/lib/libc/t_syscall:mmap___syscall passes for COMPAT_NETBSD32.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/aarch64/aarch64/aarch32_syscall.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/aarch32_syscall.c
diff -u src/sys/arch/aarch64/aarch64/aarch32_syscall.c:1.3 src/sys/arch/aarch64/aarch64/aarch32_syscall.c:1.4
--- src/sys/arch/aarch64/aarch64/aarch32_syscall.c:1.3	Fri Apr 12 09:29:26 2019
+++ src/sys/arch/aarch64/aarch64/aarch32_syscall.c	Sat May 15 11:38:26 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: aarch32_syscall.c,v 1.3 2019/04/12 09:29:26 ryo Exp $	*/
+/*	$NetBSD: aarch32_syscall.c,v 1.4 2021/05/15 11:38:26 rin Exp $	*/
 
 /*
  * Copyright (c) 2018 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: aarch32_syscall.c,v 1.3 2019/04/12 09:29:26 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: aarch32_syscall.c,v 1.4 2021/05/15 11:38:26 rin Exp $");
 
 #include 
 #include 
@@ -91,9 +91,24 @@ EMULNAME(syscall)(struct trapframe *tf)
 	code %= EMULNAMEU(SYS_NSYSENT);
 	callp = p->p_emul->e_sysent + code;
 	if (__predict_false(callp->sy_flags & SYCALL_INDIRECT)) {
-		nargs_reg -= 1;
-		regstart = 1;	/* args start from r1 */
-		code = tf->tf_reg[0] % EMULNAMEU(SYS_NSYSENT);
+		int off = 1;
+#ifdef NETBSD32_SYS_netbsd32syscall /* XXX ugly: apply only for NETBSD32 */
+		/*
+		 * For __syscall(2), 1st argument is quad_t, which is
+		 * stored in r0 and r1.
+		 */
+		if (code == NETBSD32_SYS_netbsd32syscall)
+			off = 2;
+#endif
+		nargs_reg -= off;
+		regstart = off;	/* args start from r1 or r2 */
+#ifdef __AARCH64EB__
+		if (off == 2)
+			code = tf->tf_reg[1];
+		else
+#endif
+			code = tf->tf_reg[0];
+		code %= EMULNAMEU(SYS_NSYSENT);
 		callp = p->p_emul->e_sysent + code;
 
 		/* don't allow nested syscall */



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

2021-05-15 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sat May 15 08:46:01 UTC 2021

Modified Files:
src/sys/arch/arm/rockchip: rk3328_cru.c rk_spi.c

Log Message:
add SPI support to rk3328, tested on rock64.

simply adding the SPI clocks (and pwm while here) and enabling
the config match was sufficient, though my first rock64 seems
to have a deal SPI now (does not probe in u-boot or netbsd.)


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/rockchip/rk3328_cru.c
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/rockchip/rk_spi.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/rockchip/rk3328_cru.c
diff -u src/sys/arch/arm/rockchip/rk3328_cru.c:1.7 src/sys/arch/arm/rockchip/rk3328_cru.c:1.8
--- src/sys/arch/arm/rockchip/rk3328_cru.c:1.7	Wed Jan 27 03:10:19 2021
+++ src/sys/arch/arm/rockchip/rk3328_cru.c	Sat May 15 08:46:00 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: rk3328_cru.c,v 1.7 2021/01/27 03:10:19 thorpej Exp $ */
+/* $NetBSD: rk3328_cru.c,v 1.8 2021/05/15 08:46:00 mrg Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: rk3328_cru.c,v 1.7 2021/01/27 03:10:19 thorpej Exp $");
+__KERNEL_RCSID(1, "$NetBSD: rk3328_cru.c,v 1.8 2021/05/15 08:46:00 mrg Exp $");
 
 #include 
 #include 
@@ -218,6 +218,20 @@ static struct rk_cru_clk rk3328_cru_clks
 		 CLKGATE_CON(8),	/* gate_reg */
 		 __BIT(2),		/* gate_mask */
 		 0),
+	RK_COMPOSITE(RK3328_SCLK_SPI, "clk_spi", mux_2plls_parents,
+		 CLKSEL_CON(24),	/* muxdiv_reg */
+		 __BIT(7),		/* mux_mask */
+		 __BITS(6,0),	/* div_mask */
+		 CLKGATE_CON(2),	/* gate_reg */
+		 __BIT(7),		/* gate_mask */
+		 0),
+	RK_COMPOSITE(RK3328_SCLK_PWM, "clk_pwm", mux_2plls_parents,
+		 CLKSEL_CON(24),	/* muxdiv_reg */
+		 __BIT(15),		/* mux_mask */
+		 __BITS(14,8),	/* div_mask */
+		 CLKGATE_CON(2),	/* gate_reg */
+		 __BIT(8),		/* gate_mask */
+		 0),
 	RK_COMPOSITE(RK3328_ACLK_PERI_PRE, "aclk_peri_pre", aclk_peri_pre_parents,
 		 CLKSEL_CON(28),	/* muxdiv_reg */
 		 __BITS(7,6),	/* mux_mask */
@@ -239,7 +253,7 @@ static struct rk_cru_clk rk3328_cru_clks
 		 __BIT(1),		/* gate_mask */
 		 0),
 	RK_COMPOSITE(RK3328_SCLK_SDMMC, "clk_sdmmc", mmc_parents,
-		 CLKSEL_CON(30),		/* muxdiv_reg */
+		 CLKSEL_CON(30),	/* muxdiv_reg */
 		 __BITS(9,8),	/* mux_mask */
 		 __BITS(7,0),	/* div_mask */
 		 CLKGATE_CON(4),	/* gate_reg */
@@ -360,6 +374,8 @@ static struct rk_cru_clk rk3328_cru_clks
 	RK_GATE(RK3328_PCLK_I2C1, "pclk_i2c1", "pclk_bus", CLKGATE_CON(16), 0),
 	RK_GATE(RK3328_PCLK_I2C2, "pclk_i2c2", "pclk_bus", CLKGATE_CON(16), 1),
 	RK_GATE(RK3328_PCLK_I2C3, "pclk_i2c3", "pclk_bus", CLKGATE_CON(16), 2),
+	RK_GATE(RK3328_PCLK_SPI, "pclk_spi", "pclk_bus", CLKGATE_CON(16), 5),
+	RK_GATE(RK3328_PCLK_PWM, "pclk_rk_pwm", "pclk_bus", CLKGATE_CON(16), 6),
 	RK_GATE(RK3328_PCLK_GPIO0, "pclk_gpio0", "pclk_bus", CLKGATE_CON(16), 7),
 	RK_GATE(RK3328_PCLK_GPIO1, "pclk_gpio1", "pclk_bus", CLKGATE_CON(16), 8),
 	RK_GATE(RK3328_PCLK_GPIO2, "pclk_gpio2", "pclk_bus", CLKGATE_CON(16), 9),

Index: src/sys/arch/arm/rockchip/rk_spi.c
diff -u src/sys/arch/arm/rockchip/rk_spi.c:1.6 src/sys/arch/arm/rockchip/rk_spi.c:1.7
--- src/sys/arch/arm/rockchip/rk_spi.c:1.6	Wed Jan 27 03:10:19 2021
+++ src/sys/arch/arm/rockchip/rk_spi.c	Sat May 15 08:46:00 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: rk_spi.c,v 1.6 2021/01/27 03:10:19 thorpej Exp $	*/
+/*	$NetBSD: rk_spi.c,v 1.7 2021/05/15 08:46:00 mrg Exp $	*/
 
 /*
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rk_spi.c,v 1.6 2021/01/27 03:10:19 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rk_spi.c,v 1.7 2021/05/15 08:46:00 mrg Exp $");
 
 #include 
 #include 
@@ -144,10 +144,8 @@ __KERNEL_RCSID(0, "$NetBSD: rk_spi.c,v 1
 #define SPI_FIFOLEN		32
 
 static const struct device_compatible_entry compat_data[] = {
-#if 0 /* should work on RK3328 but untested */
 	{ .compat = "rockchip,rk3066-spi" },
 	{ .compat = "rockchip,rk3328-spi" },
-#endif		
 	{ .compat = "rockchip,rk3399-spi" },
 	DEVICE_COMPAT_EOL
 };



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

2021-05-14 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Sat May 15 02:37:07 UTC 2021

Modified Files:
src/sys/arch/mips/include: types.h

Log Message:
The MIPS O64 ABI uses full 64-bit FP regs.


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/sys/arch/mips/include/types.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/mips/include/types.h
diff -u src/sys/arch/mips/include/types.h:1.75 src/sys/arch/mips/include/types.h:1.76
--- src/sys/arch/mips/include/types.h:1.75	Mon Mar 29 02:07:43 2021
+++ src/sys/arch/mips/include/types.h	Sat May 15 02:37:07 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: types.h,v 1.75 2021/03/29 02:07:43 simonb Exp $	*/
+/*	$NetBSD: types.h,v 1.76 2021/05/15 02:37:07 simonb Exp $	*/
 
 /*-
  * Copyright (c) 1992, 1993
@@ -49,13 +49,10 @@ typedef __uint64_t		__fpregister64_t;
 typedef	unsigned int		__cpu_simple_lock_nv_t;
 #if defined(__mips_o32)
 typedef __register32_t		__register_t;
+typedef __fpregister32_t	__fpregister_t;
 #else
 typedef __register64_t		__register_t;
-#endif
-#if defined(__mips_o64) || defined(__mips_o32)
-typedef	__fpregister32_t	__fpregister_t;
-#else
-typedef	__fpregister64_t	__fpregister_t;
+typedef __fpregister64_t	__fpregister_t;
 #endif
 
 /*



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

2021-05-14 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Fri May 14 13:36:28 UTC 2021

Modified Files:
src/sys/arch/mips/cavium/dev: octeon_gmx.c

Log Message:
Fix a missed bitmask to __SHIFTOUT conversion in rev 1.12.

Fixes negotiation problems on non-gige switches.  Problem discovered and
tested by riastradh@.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/mips/cavium/dev/octeon_gmx.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/mips/cavium/dev/octeon_gmx.c
diff -u src/sys/arch/mips/cavium/dev/octeon_gmx.c:1.18 src/sys/arch/mips/cavium/dev/octeon_gmx.c:1.19
--- src/sys/arch/mips/cavium/dev/octeon_gmx.c:1.18	Wed May  5 06:47:29 2021
+++ src/sys/arch/mips/cavium/dev/octeon_gmx.c	Fri May 14 13:36:28 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: octeon_gmx.c,v 1.18 2021/05/05 06:47:29 simonb Exp $	*/
+/*	$NetBSD: octeon_gmx.c,v 1.19 2021/05/14 13:36:28 simonb Exp $	*/
 
 /*
  * Copyright (c) 2007 Internet Initiative Japan, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: octeon_gmx.c,v 1.18 2021/05/05 06:47:29 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: octeon_gmx.c,v 1.19 2021/05/14 13:36:28 simonb Exp $");
 
 #include 
 #include 
@@ -834,7 +834,7 @@ octgmx_rgmii_speed_speed(struct octgmx_p
 
 	prt_cfg = _GMX_PORT_RD8(sc, GMX0_PRT0_CFG);
 
-	switch (sc->sc_link & RXN_RX_INBND_SPEED) {
+	switch (__SHIFTOUT(sc->sc_link, RXN_RX_INBND_SPEED)) {
 	case RXN_RX_INBND_SPEED_2_5:
 		/* 10Mbps */
 		/*



CVS commit: src/sys/arch/mac68k/obio

2021-05-13 Thread Hauke Fath
Module Name:src
Committed By:   hauke
Date:   Thu May 13 08:47:21 UTC 2021

Modified Files:
src/sys/arch/mac68k/obio: iwm_fd.c

Log Message:
We do not match machines whose SWIM does not support the IWM register
set used by this driver (SWIM II/III, SWIM behind IOP, AV models' DMA
based controllers).  Unfortunately, this distinction does not run
cleanly along MACH_CLASS* lines, and we have to look at MACH_MAC{model} tags.


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/sys/arch/mac68k/obio/iwm_fd.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/mac68k/obio/iwm_fd.c
diff -u src/sys/arch/mac68k/obio/iwm_fd.c:1.59 src/sys/arch/mac68k/obio/iwm_fd.c:1.60
--- src/sys/arch/mac68k/obio/iwm_fd.c:1.59	Sat Apr 24 23:36:41 2021
+++ src/sys/arch/mac68k/obio/iwm_fd.c	Thu May 13 08:47:21 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: iwm_fd.c,v 1.59 2021/04/24 23:36:41 thorpej Exp $	*/
+/*	$NetBSD: iwm_fd.c,v 1.60 2021/05/13 08:47:21 hauke Exp $	*/
 
 /*
  * Copyright (c) 1997, 1998 Hauke Fath.  All rights reserved.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: iwm_fd.c,v 1.59 2021/04/24 23:36:41 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: iwm_fd.c,v 1.60 2021/05/13 08:47:21 hauke Exp $");
 
 #include "locators.h"
 
@@ -65,11 +65,6 @@ __KERNEL_RCSID(0, "$NetBSD: iwm_fd.c,v 1
 #include 
 #include 
 
-/**
- **	Private functions
- **/
-static int map_iwm_base(vm_offset_t);
-
 /* Autoconfig */
 int	iwm_match(device_t, cfdata_t, void *);
 void	iwm_attach(device_t, device_t, void *);
@@ -78,6 +73,10 @@ int	fd_match(device_t, cfdata_t, void *)
 void	fd_attach(device_t, device_t, void *);
 int	fd_print(void *, const char *);
 
+/**
+ **	Private functions
+ **/
+
 /* Disklabel stuff */
 static void fdGetDiskLabel(fd_softc_t *, dev_t);
 static void fdPrintDiskLabel(struct disklabel *);
@@ -164,7 +163,7 @@ int iwmDebugging = 0 /* | M_TRACE_OP
  ** Module-global Variables
  **/
 
-/* The IWM base address */
+/* The controller base address */
 u_long IWMBase;
 
 /*
@@ -273,30 +272,71 @@ struct dkdriver fd_dkDriver = {
  * to match against. After all, that's what the obio concept is 
  * about: Onboard components that are present depending (only) 
  * on machine type.
+ *
+ * While here, map the machine-dependent physical IO address of IWM
+ * to VM address.
+ *
+ * We do not match, nor return an IWMBase address for machines whose
+ * SWIM does not support the IWM register set used by this driver
+ * (SWIM II/III, SWIM behind IOP, AV models' DMA based controllers).
+ * Unfortunately, this distinction does not run cleanly along
+ * MACH_CLASS* lines, and we will have to look at MACH_MAC{model} tags.
+ *
+ * See also "What chips are in what Macs?" at
+ * ,
  */
 int
 iwm_match(device_t parent, cfdata_t match, void *aux)
 {
-	int matched;
+	int matched = 0;
 	extern u_long IOBase;		/* from mac68k/machdep.c */
 	extern u_long IWMBase;
-	
-	if (0 == map_iwm_base(IOBase)) {
-		/* 
-		 * Unknown machine HW:
-		 * The SWIM II/III chips that are present in post-Q700
-		 * '040 Macs have dropped the IWM register structure.
-		 * We know next to nothing about the SWIM.
-		 */
-		matched = 0;
-		if (TRACE_CONFIG)
-			printf("IWM or SWIM not found: Unknown location (SWIM II?).\n");
-	} else {
+
+	IWMBase = 0L;
+
+	switch (current_mac_model->class) {
+	case MACH_CLASSPB:	/* Not: 5x0, 190x */
+		if (current_mac_model->machineid == MACH_MACPB500 ||
+		current_mac_model->machineid == MACH_MACPB190 ||
+		current_mac_model->machineid == MACH_MACPB190CS)
+			break;
+		/* FALLTHROUGH */
+	case MACH_CLASSLC:	/* Only: LC II, Classic II */
+		if (current_mac_model->machineid != MACH_MACLCII &&
+		current_mac_model->machineid != MACH_MACCLASSICII)
+			break;
+		/* FALLTHROUGH */
+	case MACH_CLASSII:	/* All */
+	case MACH_CLASSIIci:	/* All */
+	case MACH_CLASSIIsi:	/* All */
+	case MACH_CLASSIIvx:	/* All */
+	case MACH_CLASSDUO:	/* All */
+		IWMBase = IOBase + 0x16000;
 		matched = 1;
-		if (TRACE_CONFIG) {
-			printf("iwm: IWMBase mapped to 0x%lx in VM.\n", 
-			IWMBase);
+		break;
+	case MACH_CLASSQ:	/* Only: 700 */
+		if (current_mac_model->machineid == MACH_MACQ700) {
+			IWMBase = IOBase + 0x1E000;
+			matched = 1;
+			break;
 		}
+		/* FALLTHROUGH */
+	case MACH_CLASSQ2:	/* None */
+	case MACH_CLASSP580:	/* None */
+	case MACH_CLASSIIfx:	/* None */
+	case MACH_CLASSAV:	/* None */
+	default:
+		IWMBase = 0L;
+		matched = 0;
+		break;
+	}
+
+	if (TRACE_CONFIG) {
+		if (matched == 0)
+			printf("IWM or original SWIM not found.\n");
+		else
+			printf("IWMBase mapped to VM addr 0x%lx.\n",
+			IWMBase);
 	}
 	return matched;
 }
@@ -337,7 +377,7 @@ iwm_attach(device_t parent, device_t sel
 		if (TRACE_CONFIG)
 			printf("iwm: Initialization completed.\n");
 	} else {
-		printf("iwm: Chip revision not supported (%d)\n", 

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

2021-05-13 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu May 13 06:15:41 UTC 2021

Modified Files:
src/sys/arch/arm/rockchip: rk3399_iomux.c

Log Message:
 Use unsigned to avoid undefined behavior in GRF_GPIO_P_{CTL,WRITE_EN}.
Found by kUBSan.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/rockchip/rk3399_iomux.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/rockchip/rk3399_iomux.c
diff -u src/sys/arch/arm/rockchip/rk3399_iomux.c:1.11 src/sys/arch/arm/rockchip/rk3399_iomux.c:1.12
--- src/sys/arch/arm/rockchip/rk3399_iomux.c:1.11	Sat Apr 24 23:36:28 2021
+++ src/sys/arch/arm/rockchip/rk3399_iomux.c	Thu May 13 06:15:41 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: rk3399_iomux.c,v 1.11 2021/04/24 23:36:28 thorpej Exp $ */
+/* $NetBSD: rk3399_iomux.c,v 1.12 2021/05/13 06:15:41 msaitoh Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -29,7 +29,7 @@
 //#define RK3399_IOMUX_DEBUG
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rk3399_iomux.c,v 1.11 2021/04/24 23:36:28 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rk3399_iomux.c,v 1.12 2021/05/13 06:15:41 msaitoh Exp $");
 
 #include 
 #include 
@@ -45,8 +45,8 @@ __KERNEL_RCSID(0, "$NetBSD: rk3399_iomux
 #include 
 
 /* PU/PD control */
-#define	 GRF_GPIO_P_CTL(_idx)		(0x3 << (((_idx) & 7) * 2))
-#define	 GRF_GPIO_P_WRITE_EN(_idx)	(0x3 << (((_idx) & 7) * 2 + 16))
+#define	 GRF_GPIO_P_CTL(_idx)		(0x3U << (((_idx) & 7) * 2))
+#define	 GRF_GPIO_P_WRITE_EN(_idx)	(0x3U << (((_idx) & 7) * 2 + 16))
 /* Different bias value mapping based on pull type of pin */
 #define	  IO_DEF_GPIO_P_CTL_Z		0
 #define	  IO_DEF_GPIO_P_CTL_PULLUP	1



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

2021-05-13 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Thu May 13 06:15:29 UTC 2021

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

Log Message:
Update ISA for some "L" variant instructions after checking the R4400 UM.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/sys/arch/mips/mips/fp.S

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

Modified files:

Index: src/sys/arch/mips/mips/fp.S
diff -u src/sys/arch/mips/mips/fp.S:1.55 src/sys/arch/mips/mips/fp.S:1.56
--- src/sys/arch/mips/mips/fp.S:1.55	Thu May 13 04:55:12 2021
+++ src/sys/arch/mips/mips/fp.S	Thu May 13 06:15:29 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: fp.S,v 1.55 2021/05/13 04:55:12 simonb Exp $	*/
+/*	$NetBSD: fp.S,v 1.56 2021/05/13 06:15:29 simonb Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -350,7 +350,7 @@ func_single_tbl:
 	PTR_WORD ill		# func 34 42
 	PTR_WORD ill		# func 35 43
 	PTR_WORD cvt_w_s	# func 36 44	CVT.W.S
-	PTR_WORD cvt_l_s	# func 37 45	CVT.L.S		MIPS64r2
+	PTR_WORD cvt_l_s	# func 37 45	CVT.L.S		MIPS3/MIPS64
 	PTR_WORD cvt_ps_s	# func 38 46	CVT.PS.S	MIPS32r2
 	PTR_WORD ill		# func 39 47
 	PTR_WORD ill		# func 40 50
@@ -387,10 +387,10 @@ func_double_tbl:
 	PTR_WORD abs_d		# func  5 05	ABS.D
 	PTR_WORD mov_d		# func  6 06	MOV.D
 	PTR_WORD neg_d		# func  7 07	NEG.D 
-	PTR_WORD round_l_d	# func  8 10	ROUND.L.D	MIPS64r2
-	PTR_WORD trunc_l_d	# func  9 11	TRUNC.L.D	MIPS64r2
-	PTR_WORD ceil_l_d	# func 10 12	CEIL.L.D	MIPS64r2
-	PTR_WORD floor_l_d	# func 11 13	FLOOR.L.D	MIPS64r2
+	PTR_WORD round_l_d	# func  8 10	ROUND.L.D	MIPS3/MIPS64
+	PTR_WORD trunc_l_d	# func  9 11	TRUNC.L.D	MIPS3/MIPS64
+	PTR_WORD ceil_l_d	# func 10 12	CEIL.L.D	MIPS3/MIPS64
+	PTR_WORD floor_l_d	# func 11 13	FLOOR.L.D	MIPS3/MIPS64
 	PTR_WORD round_w_d	# func 12 14	ROUND.W.D
 	PTR_WORD trunc_w_d	# func 13 15	TRUNC.W.D
 	PTR_WORD ceil_w_d	# func 14 16	CEIL.W.D
@@ -416,7 +416,7 @@ func_double_tbl:
 	PTR_WORD ill		# func 34 42
 	PTR_WORD ill		# func 35 43
 	PTR_WORD cvt_w_d	# func 36 44	CVT.W.D
-	PTR_WORD cvt_l_d	# func 37 45	CVT.L.D		MIPS64r2
+	PTR_WORD cvt_l_d	# func 37 45	CVT.L.D		MIPS3/MIPS64
 	PTR_WORD ill		# func 38 46
 	PTR_WORD ill		# func 39 47
 	PTR_WORD ill		# func 40 50
@@ -543,8 +543,8 @@ func_long_fixed_tbl:
 	PTR_WORD ill		# func 29 35
 	PTR_WORD ill		# func 30 36
 	PTR_WORD ill		# func 31 37
-	PTR_WORD cvt_s_l	# func 32 40	CVT.S.L		MIPS32r2
-	PTR_WORD cvt_d_l	# func 33 41	CVT.D.L		MIPS32r2
+	PTR_WORD cvt_s_l	# func 32 40	CVT.S.L		MIPS3/MIPS64
+	PTR_WORD cvt_d_l	# func 33 41	CVT.D.L		MIPS3/MIPS64
 	PTR_WORD ill		# func 34 42
 	PTR_WORD ill		# func 35 43
 	PTR_WORD ill		# func 36 44



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

2021-05-12 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Thu May 13 04:55:12 UTC 2021

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

Log Message:
Note which ISA the unimplemented instructions belong to.


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/sys/arch/mips/mips/fp.S

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

Modified files:

Index: src/sys/arch/mips/mips/fp.S
diff -u src/sys/arch/mips/mips/fp.S:1.54 src/sys/arch/mips/mips/fp.S:1.55
--- src/sys/arch/mips/mips/fp.S:1.54	Thu Apr 29 08:45:29 2021
+++ src/sys/arch/mips/mips/fp.S	Thu May 13 04:55:12 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: fp.S,v 1.54 2021/04/29 08:45:29 simonb Exp $	*/
+/*	$NetBSD: fp.S,v 1.55 2021/05/13 04:55:12 simonb Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -282,14 +282,14 @@ fmt_tbl:
 	PTR_WORD mfromc1	# sub 0		mfc1
 	PTR_WORD dmfromc1	# sub 1		dmfc1
 	PTR_WORD cfromc1	# sub 2		cfc1
-	PTR_WORD ill		# sub 3		mfhc1
+	PTR_WORD ill		# sub 3		mfhc1		MIPS32r2
 	PTR_WORD mtoc1		# sub 4		mtc1
 	PTR_WORD dmtoc1		# sub 5		dmtc1
 	PTR_WORD ctoc1		# sub 6		ctc1
-	PTR_WORD ill		# sub 7		mthc1
+	PTR_WORD ill		# sub 7		mthc1		MIPS32r2
 	PTR_WORD branchc1	# sub 8		bc1
-	PTR_WORD branchc1any2	# sub 9		bc1any2
-	PTR_WORD branchc1any4	# sub 10	bc1any4
+	PTR_WORD branchc1any2	# sub 9		bc1any2		MIPS-3D ASE
+	PTR_WORD branchc1any4	# sub 10	bc1any4		MIPS-3D ASE
 	PTR_WORD ill		# sub 11
 	PTR_WORD ill		# sub 12
 	PTR_WORD ill		# sub 13
@@ -321,37 +321,37 @@ func_single_tbl:
 	PTR_WORD abs_s		# func  5 05	ABS.S
 	PTR_WORD mov_s		# func  6 06	MOV.S
 	PTR_WORD neg_s		# func  7 07	NEG.S 
-	PTR_WORD round_l_s	# func  8 10	ROUND.L.S
-	PTR_WORD trunc_l_s	# func  9 11	TRUNC.L.S
-	PTR_WORD ceil_l_s	# func 10 12	CEIL.L.S
-	PTR_WORD floor_l_s	# func 11 13	FLOOR.L.S
+	PTR_WORD round_l_s	# func  8 10	ROUND.L.S	MIPS3/MIPS64
+	PTR_WORD trunc_l_s	# func  9 11	TRUNC.L.S	MIPS3/MIPS64
+	PTR_WORD ceil_l_s	# func 10 12	CEIL.L.S	MIPS3/MIPS64
+	PTR_WORD floor_l_s	# func 11 13	FLOOR.L.S	MIPS3/MIPS64
 	PTR_WORD round_w_s	# func 12 14	ROUND.W.S
 	PTR_WORD trunc_w_s	# func 13 15	TRUNC.W.S
 	PTR_WORD ceil_w_s	# func 14 16	CEIL.W.S
 	PTR_WORD floor_w_s	# func 15 17	FLOOR.W.S
 	PTR_WORD ill		# func 16 20
-	PTR_WORD movcf_s	# func 17 21	MOVCF.S
-	PTR_WORD movz_s		# func 18 22	MOVZ.S
-	PTR_WORD movn_s		# func 19 23	MOVN.S
+	PTR_WORD movcf_s	# func 17 21	MOVCF.S		MIPS32
+	PTR_WORD movz_s		# func 18 22	MOVZ.S		MIPS32
+	PTR_WORD movn_s		# func 19 23	MOVN.S		MIPS32
 	PTR_WORD ill		# func 20 24
-	PTR_WORD recip_s	# func 21 25	RECIP.S
-	PTR_WORD rsqrt_s	# func 22 26	RSQRT.S
+	PTR_WORD recip_s	# func 21 25	RECIP.S		MIPS32r2
+	PTR_WORD rsqrt_s	# func 22 26	RSQRT.S		MIPS32r2
 	PTR_WORD ill		# func 23 27
 	PTR_WORD ill		# func 24 30
 	PTR_WORD ill		# func 25 31
 	PTR_WORD ill		# func 26 32
 	PTR_WORD ill		# func 27 33
-	PTR_WORD recip2_s	# func 28 34	RECIP2.S
-	PTR_WORD recip1_s	# func 29 35	RECIP1.S
-	PTR_WORD rsqrt1_s	# func 30 36	RSQRT1.S
-	PTR_WORD rsqrt2_s	# func 31 37	RSQRT2.S
+	PTR_WORD recip2_s	# func 28 34	RECIP2.S	MIPS-3D ASE
+	PTR_WORD recip1_s	# func 29 35	RECIP1.S	MIPS-3D ASE
+	PTR_WORD rsqrt1_s	# func 30 36	RSQRT1.S	MIPS-3D ASE
+	PTR_WORD rsqrt2_s	# func 31 37	RSQRT2.S	MIPS-3D ASE
 	PTR_WORD ill		# func 32 40
 	PTR_WORD cvt_d_s	# func 33 41	CVT.D.S
 	PTR_WORD ill		# func 34 42
 	PTR_WORD ill		# func 35 43
 	PTR_WORD cvt_w_s	# func 36 44	CVT.W.S
-	PTR_WORD cvt_l_s	# func 37 45	CVT.L.S
-	PTR_WORD cvt_ps_s	# func 38 46	CVT.PS.S
+	PTR_WORD cvt_l_s	# func 37 45	CVT.L.S		MIPS64r2
+	PTR_WORD cvt_ps_s	# func 38 46	CVT.PS.S	MIPS32r2
 	PTR_WORD ill		# func 39 47
 	PTR_WORD ill		# func 40 50
 	PTR_WORD ill		# func 41 51
@@ -387,36 +387,36 @@ func_double_tbl:
 	PTR_WORD abs_d		# func  5 05	ABS.D
 	PTR_WORD mov_d		# func  6 06	MOV.D
 	PTR_WORD neg_d		# func  7 07	NEG.D 
-	PTR_WORD round_l_d	# func  8 10	ROUND.L.D
-	PTR_WORD trunc_l_d	# func  9 11	TRUNC.L.D
-	PTR_WORD ceil_l_d	# func 10 12	CEIL.L.D
-	PTR_WORD floor_l_d	# func 11 13	FLOOR.L.D
+	PTR_WORD round_l_d	# func  8 10	ROUND.L.D	MIPS64r2
+	PTR_WORD trunc_l_d	# func  9 11	TRUNC.L.D	MIPS64r2
+	PTR_WORD ceil_l_d	# func 10 12	CEIL.L.D	MIPS64r2
+	PTR_WORD floor_l_d	# func 11 13	FLOOR.L.D	MIPS64r2
 	PTR_WORD round_w_d	# func 12 14	ROUND.W.D
 	PTR_WORD trunc_w_d	# func 13 15	TRUNC.W.D
 	PTR_WORD ceil_w_d	# func 14 16	CEIL.W.D
 	PTR_WORD floor_w_d	# func 15 17	FLOOR.W.D
 	PTR_WORD ill		# func 16 20
-	PTR_WORD movcf_d	# func 17 21	MOVCF.D
-	PTR_WORD movz_d		# func 18 22	MOVZ.D
-	PTR_WORD movn_d		# func 19 23	MOVN.D
+	PTR_WORD movcf_d	# func 17 21	MOVCF.D		MIPS32
+	PTR_WORD movz_d		# func 18 22	MOVZ.D		MIPS32
+	PTR_WORD movn_d		# func 19 23	MOVN.D		MIPS32
 	PTR_WORD ill		# func 20 24
-	PTR_WORD recip_d	# func 21 25	RECIP.D
-	PTR_WORD rsqrt_d	# func 22 26	RSQRT.D
+	PTR_WORD recip_d	# func 21 25	RECIP.D		MIPS32r2
+	PTR_WORD rsqrt_d	# func 22 26	RSQRT.D		MIPS32r2
 	PTR_WORD ill		# func 23 27
 	PTR_WORD ill		# func 24 30
 	PTR_WORD ill		# func 25 31
 	

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

2021-05-12 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Thu May 13 03:41:46 UTC 2021

Modified Files:
src/sys/arch/mips/mips: mips_fputrap.c

Log Message:
If we're going to print a number in hex, at least put a 0x in front of it.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/mips/mips/mips_fputrap.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/mips/mips/mips_fputrap.c
diff -u src/sys/arch/mips/mips/mips_fputrap.c:1.10 src/sys/arch/mips/mips/mips_fputrap.c:1.11
--- src/sys/arch/mips/mips/mips_fputrap.c:1.10	Sat Feb 26 15:41:32 2011
+++ src/sys/arch/mips/mips/mips_fputrap.c	Thu May 13 03:41:46 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: mips_fputrap.c,v 1.10 2011/02/26 15:41:32 tsutsui Exp $ */
+/* $NetBSD: mips_fputrap.c,v 1.11 2021/05/13 03:41:46 simonb Exp $ */
 
 /*
  * Copyright (c) 2004
@@ -47,7 +47,7 @@ mips_fpuexcept(struct lwp *l, uint32_t f
 	ksiginfo_t ksi;
 
 #ifdef FPEMUL_DEBUG
-	printf("%s(%x,%#"PRIxREGISTER")\n",
+	printf("%s(%#x,%#"PRIxREGISTER")\n",
 	   __func__, fpustat, l->l_md.md_utf->tf_regs[_R_PC]);
 #endif
 
@@ -64,7 +64,7 @@ mips_fpuillinst(struct lwp *l, uint32_t 
 	ksiginfo_t ksi;
 
 #ifdef FPEMUL_DEBUG
-	printf("%s(%x,%#"PRIxREGISTER")\n",
+	printf("%s(%#x,%#"PRIxREGISTER")\n",
 	   __func__, opcode, l->l_md.md_utf->tf_regs[_R_PC]);
 #endif
 



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

2021-05-12 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed May 12 23:48:41 UTC 2021

Modified Files:
src/sys/arch/shark/conf: files.shark

Log Message:
Add OFW PCI subroutines if PCI support is included in the kernel.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/shark/conf/files.shark

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/shark/conf/files.shark
diff -u src/sys/arch/shark/conf/files.shark:1.24 src/sys/arch/shark/conf/files.shark:1.25
--- src/sys/arch/shark/conf/files.shark:1.24	Fri Apr 30 02:24:05 2021
+++ src/sys/arch/shark/conf/files.shark	Wed May 12 23:48:41 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: files.shark,v 1.24 2021/04/30 02:24:05 thorpej Exp $
+#	$NetBSD: files.shark,v 1.25 2021/05/12 23:48:41 thorpej Exp $
 #
 # First try for arm-specific configuration info
 #
@@ -136,6 +136,7 @@ file	arch/shark/ofw/chipsfb_ofbus.c		chi
 device	vlpci: pcibus
 file	arch/shark/ofw/vlpci.c			vlpci needs-flag
 attach	vlpci at ofbus
+file	dev/ofw/ofw_pci_subr.c			pci
 
 # Smart Card Reader
 device	scr: tty



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

2021-05-12 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed May 12 22:17:40 UTC 2021

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

Log Message:
In mpacpi_pci_attach_hook(), set the device handle of the PCI bus instance
to the associated ACPI handle if a device handle is not already set.

XXX This is a mess. Sure would be nice if it looked / worked more like
XXX the ARM code.


To generate a diff of this commit:
cvs rdiff -u -r1.105 -r1.106 src/sys/arch/x86/x86/mpacpi.c

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

Modified files:

Index: src/sys/arch/x86/x86/mpacpi.c
diff -u src/sys/arch/x86/x86/mpacpi.c:1.105 src/sys/arch/x86/x86/mpacpi.c:1.106
--- src/sys/arch/x86/x86/mpacpi.c:1.105	Sat Apr 24 23:36:51 2021
+++ src/sys/arch/x86/x86/mpacpi.c	Wed May 12 22:17:40 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: mpacpi.c,v 1.105 2021/04/24 23:36:51 thorpej Exp $	*/
+/*	$NetBSD: mpacpi.c,v 1.106 2021/05/12 22:17:40 thorpej Exp $	*/
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mpacpi.c,v 1.105 2021/04/24 23:36:51 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mpacpi.c,v 1.106 2021/05/12 22:17:40 thorpej Exp $");
 
 #include "acpica.h"
 #include "opt_acpi.h"
@@ -90,7 +90,7 @@ ACPI_MODULE_NAME   ("mpacpi")
 #if NPCI > 0
 struct mpacpi_pcibus {
 	TAILQ_ENTRY(mpacpi_pcibus) mpr_list;
-	ACPI_HANDLE mpr_handle;		/* Same thing really, but.. */
+	devhandle_t mpr_devhandle;
 	ACPI_BUFFER mpr_buf;		/* preserve _PRT */
 	int mpr_seg;			/* PCI segment number */
 	int mpr_bus;			/* PCI bus number */
@@ -509,7 +509,7 @@ mpacpi_pci_foundbus(struct acpi_devnode 
 	}
 
 	mpr = kmem_zalloc(sizeof(struct mpacpi_pcibus), KM_SLEEP);
-	mpr->mpr_handle = ad->ad_handle;
+	mpr->mpr_devhandle = devhandle_from_acpi(ad->ad_handle);
 	mpr->mpr_buf = buf;
 	mpr->mpr_seg = ad->ad_pciinfo->ap_segment;
 	mpr->mpr_bus = ad->ad_pciinfo->ap_downbus;
@@ -953,6 +953,29 @@ mpacpi_find_interrupts(void *self)
 
 #if NPCI > 0
 
+static void
+mpacpi_set_devhandle(device_t self, struct pcibus_attach_args *pba)
+{
+	devhandle_t devhandle = device_handle(self);
+	struct mpacpi_pcibus *mpr;
+
+	/* If we already have a valid handle, eject now. */
+	if (devhandle_type(devhandle) != DEVHANDLE_TYPE_INVALID) {
+		return;
+	}
+
+	TAILQ_FOREACH(mpr, _pcibusses, mpr_list) {
+		/* XXX Assuming always segment 0 on x86. */
+		if (mpr->mpr_seg != 0) {
+			continue;
+		}
+		if (mpr->mpr_bus == pba->pba_bus) {
+			device_set_handle(self, mpr->mpr_devhandle);
+			return;
+		}
+	}
+}
+
 int
 mpacpi_pci_attach_hook(device_t parent, device_t self,
 		   struct pcibus_attach_args *pba)
@@ -984,13 +1007,16 @@ mpacpi_pci_attach_hook(device_t parent, 
 	if (mpb->mb_name != NULL) {
 		if (strcmp(mpb->mb_name, "pci"))
 			return EINVAL;
-	} else
+	} else {
 		/*
 		 * As we cannot find all PCI-to-PCI bridge in
 		 * mpacpi_find_pcibusses, some of the MP_busses may remain
 		 * uninitialized.
 		 */
 		mpb->mb_name = "pci";
+	}
+
+	mpacpi_set_devhandle(self, pba);
 
 	mpb->mb_dev = self;
 	mpb->mb_pci_bridge_tag = pba->pba_bridgetag;



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

2021-05-12 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed May 12 21:56:13 UTC 2021

Modified Files:
src/sys/arch/arm/acpi: acpipchb.c

Log Message:
Pass along our devhandle to the PCI bus instance we attach.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/arm/acpi/acpipchb.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/acpi/acpipchb.c
diff -u src/sys/arch/arm/acpi/acpipchb.c:1.24 src/sys/arch/arm/acpi/acpipchb.c:1.25
--- src/sys/arch/arm/acpi/acpipchb.c:1.24	Sat Apr 24 23:36:25 2021
+++ src/sys/arch/arm/acpi/acpipchb.c	Wed May 12 21:56:13 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: acpipchb.c,v 1.24 2021/04/24 23:36:25 thorpej Exp $ */
+/* $NetBSD: acpipchb.c,v 1.25 2021/05/12 21:56:13 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpipchb.c,v 1.24 2021/04/24 23:36:25 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpipchb.c,v 1.25 2021/05/12 21:56:13 thorpej Exp $");
 
 #include 
 #include 
@@ -174,7 +174,9 @@ acpipchb_attach(device_t parent, device_
 	acpipchb_setup_ranges(sc, );
 	acpipchb_setup_quirks(sc, );
 
-	config_found(self, , pcibusprint, CFARG_EOL);
+	config_found(self, , pcibusprint,
+	CFARG_DEVHANDLE, device_handle(self),
+	CFARG_EOL);
 }
 
 struct acpipchb_setup_ranges_args {



CVS commit: src/sys/arch

2021-05-11 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed May 12 04:07:34 UTC 2021

Modified Files:
src/sys/arch/arm/broadcom: bcm2838_pcie.c
src/sys/arch/arm/fdt: pcihost_fdt.c
src/sys/arch/arm/nvidia: tegra_pcie.c
src/sys/arch/arm/nxp: imxpcie.c
src/sys/arch/ofppc/pci: ofwpci.c

Log Message:
Pass along our device handle to the PCI bus instance we attach.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/broadcom/bcm2838_pcie.c
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/arm/fdt/pcihost_fdt.c
cvs rdiff -u -r1.37 -r1.38 src/sys/arch/arm/nvidia/tegra_pcie.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/nxp/imxpcie.c
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/ofppc/pci/ofwpci.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/bcm2838_pcie.c
diff -u src/sys/arch/arm/broadcom/bcm2838_pcie.c:1.3 src/sys/arch/arm/broadcom/bcm2838_pcie.c:1.4
--- src/sys/arch/arm/broadcom/bcm2838_pcie.c:1.3	Mon May  3 18:56:38 2021
+++ src/sys/arch/arm/broadcom/bcm2838_pcie.c	Wed May 12 04:07:34 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: bcm2838_pcie.c,v 1.3 2021/05/03 18:56:38 tnn Exp $ */
+/*	$NetBSD: bcm2838_pcie.c,v 1.4 2021/05/12 04:07:34 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bcm2838_pcie.c,v 1.3 2021/05/03 18:56:38 tnn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2838_pcie.c,v 1.4 2021/05/12 04:07:34 thorpej Exp $");
 
 #include 
 #include 
@@ -281,7 +281,9 @@ bcmstb_attach(device_t self, struct bcms
 	pba.pba_pc = pc;
 	pba.pba_bus = sc->sc_bus_min;
 
-	config_found(self, , pcibusprint, CFARG_EOL);
+	config_found(self, , pcibusprint,
+	CFARG_DEVHANDLE, device_handle(self),
+	CFARG_EOL);
 }
 
 static void

Index: src/sys/arch/arm/fdt/pcihost_fdt.c
diff -u src/sys/arch/arm/fdt/pcihost_fdt.c:1.24 src/sys/arch/arm/fdt/pcihost_fdt.c:1.25
--- src/sys/arch/arm/fdt/pcihost_fdt.c:1.24	Sat Apr 24 23:36:26 2021
+++ src/sys/arch/arm/fdt/pcihost_fdt.c	Wed May 12 04:07:34 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pcihost_fdt.c,v 1.24 2021/04/24 23:36:26 thorpej Exp $ */
+/* $NetBSD: pcihost_fdt.c,v 1.25 2021/05/12 04:07:34 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pcihost_fdt.c,v 1.24 2021/04/24 23:36:26 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcihost_fdt.c,v 1.25 2021/05/12 04:07:34 thorpej Exp $");
 
 #include 
 
@@ -194,7 +194,9 @@ pcihost_init2(struct pcihost_softc *sc)
 	pba.pba_pc = >sc_pc;
 	pba.pba_bus = sc->sc_bus_min;
 
-	config_found(sc->sc_dev, , pcibusprint, CFARG_EOL);
+	config_found(sc->sc_dev, , pcibusprint,
+	CFARG_DEVHANDLE, device_handle(sc->sc_dev),
+	CFARG_EOL);
 }
 
 void

Index: src/sys/arch/arm/nvidia/tegra_pcie.c
diff -u src/sys/arch/arm/nvidia/tegra_pcie.c:1.37 src/sys/arch/arm/nvidia/tegra_pcie.c:1.38
--- src/sys/arch/arm/nvidia/tegra_pcie.c:1.37	Sat Apr 24 23:36:27 2021
+++ src/sys/arch/arm/nvidia/tegra_pcie.c	Wed May 12 04:07:34 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_pcie.c,v 1.37 2021/04/24 23:36:27 thorpej Exp $ */
+/* $NetBSD: tegra_pcie.c,v 1.38 2021/05/12 04:07:34 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tegra_pcie.c,v 1.37 2021/04/24 23:36:27 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tegra_pcie.c,v 1.38 2021/05/12 04:07:34 thorpej Exp $");
 
 #include 
 
@@ -275,7 +275,9 @@ tegra_pcie_attach(device_t parent, devic
 	pba.pba_pc = >sc_pc;
 	pba.pba_bus = 0;
 
-	config_found(self, , pcibusprint, CFARG_EOL);
+	config_found(self, , pcibusprint,
+	CFARG_DEVHANDLE, device_handle(self),
+	CFARG_EOL);
 }
 
 static int

Index: src/sys/arch/arm/nxp/imxpcie.c
diff -u src/sys/arch/arm/nxp/imxpcie.c:1.2 src/sys/arch/arm/nxp/imxpcie.c:1.3
--- src/sys/arch/arm/nxp/imxpcie.c:1.2	Sat Apr 24 23:36:28 2021
+++ src/sys/arch/arm/nxp/imxpcie.c	Wed May 12 04:07:34 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: imxpcie.c,v 1.2 2021/04/24 23:36:28 thorpej Exp $	*/
+/*	$NetBSD: imxpcie.c,v 1.3 2021/05/12 04:07:34 thorpej Exp $	*/
 
 /*
  * Copyright (c) 2019  Genetec Corporation.  All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: imxpcie.c,v 1.2 2021/04/24 23:36:28 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: imxpcie.c,v 1.3 2021/05/12 04:07:34 thorpej Exp $");
 
 #include "opt_pci.h"
 #include "opt_fdt.h"
@@ -509,7 +509,9 @@ imxpcie_attach_common(struct imxpcie_sof
 	pba.pba_pc = >sc_pc;
 	pba.pba_bus = 0;
 
-	config_found(sc->sc_dev, , pcibusprint, CFARG_EOL);
+	config_found(sc->sc_dev, , pcibusprint,
+	CFARG_DEVHANDLE, device_handle(sc->sc_dev),
+	CFARG_EOL);
 }
 
 int

Index: src/sys/arch/ofppc/pci/ofwpci.c
diff -u src/sys/arch/ofppc/pci/ofwpci.c:1.19 src/sys/arch/ofppc/pci/ofwpci.c:1.20
--- src/sys/arch/ofppc/pci/ofwpci.c:1.19	Sat 

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

2021-05-11 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Wed May 12 03:53:37 UTC 2021

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

Log Message:
Whitespace nit.


To generate a diff of this commit:
cvs rdiff -u -r1.117 -r1.118 src/sys/arch/mips/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/mips/include/locore.h
diff -u src/sys/arch/mips/include/locore.h:1.117 src/sys/arch/mips/include/locore.h:1.118
--- src/sys/arch/mips/include/locore.h:1.117	Tue Mar  2 08:16:52 2021
+++ src/sys/arch/mips/include/locore.h	Wed May 12 03:53:37 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: locore.h,v 1.117 2021/03/02 08:16:52 skrll Exp $ */
+/* $NetBSD: locore.h,v 1.118 2021/05/12 03:53:37 simonb Exp $ */
 
 /*
  * This file should not be included by MI code!!!
@@ -306,7 +306,7 @@ struct mips_options {
 #endif
 #define	MIPS_HAS_LLADDR		((mips_options.mips_cpu_flags & CPU_MIPS_NO_LLADDR) == 0)
 #define	MIPS_HAS_DSP		(mips_options.mips_cpu_flags & CPU_MIPS_HAVE_DSP)
-# define MIPS_HAS_USERLOCAL	(mips_options.mips_cpu_flags & CPU_MIPS_HAVE_USERLOCAL)
+#define MIPS_HAS_USERLOCAL	(mips_options.mips_cpu_flags & CPU_MIPS_HAVE_USERLOCAL)
 
 /* This test is ... rather bogus */
 #define	CPUISMIPS3	((mips_options.mips_cpu_arch & \



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

2021-05-11 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Tue May 11 14:41:08 UTC 2021

Modified Files:
src/sys/arch/mips/mips: mips_fpu.c

Log Message:
Use "static" in the function intro if the function is static.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/mips/mips/mips_fpu.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/mips/mips/mips_fpu.c
diff -u src/sys/arch/mips/mips/mips_fpu.c:1.15 src/sys/arch/mips/mips/mips_fpu.c:1.16
--- src/sys/arch/mips/mips/mips_fpu.c:1.15	Sun May  7 05:45:07 2017
+++ src/sys/arch/mips/mips/mips_fpu.c	Tue May 11 14:41:08 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: mips_fpu.c,v 1.15 2017/05/07 05:45:07 skrll Exp $	*/
+/*	$NetBSD: mips_fpu.c,v 1.16 2021/05/11 14:41:08 simonb Exp $	*/
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mips_fpu.c,v 1.15 2017/05/07 05:45:07 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mips_fpu.c,v 1.16 2021/05/11 14:41:08 simonb Exp $");
 
 #include 
 #include 
@@ -79,7 +79,7 @@ fpu_used_p(const lwp_t *l)
 	return pcu_valid_p(_fpu_ops, l);
 }
 
-void
+static void
 mips_fpu_state_save(lwp_t *l)
 {
 	struct trapframe * const tf = l->l_md.md_utf;
@@ -206,7 +206,7 @@ mips_fpu_state_save(lwp_t *l)
 	__asm volatile ("mtc0 %0, $%1" :: "r"(status), "n"(MIPS_COP_0_STATUS));
 }
 
-void
+static void
 mips_fpu_state_load(lwp_t *l, u_int flags)
 {
 	struct trapframe * const tf = l->l_md.md_utf;
@@ -350,7 +350,7 @@ mips_fpu_state_load(lwp_t *l, u_int flag
 		"n"(MIPS_COP_0_STATUS));
 }
 
-void
+static void
 mips_fpu_state_release(lwp_t *l)
 {
 	l->l_md.md_utf->tf_regs[_R_SR] &= ~MIPS_SR_COP_1_BIT;



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

2021-05-11 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Tue May 11 09:21:25 UTC 2021

Modified Files:
src/sys/arch/mips/conf: std.octeon

Log Message:
Revert rev 1.5 - put the NOFPU option back.  Older cnMIPS cores don't
have an FPU.


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

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

Modified files:

Index: src/sys/arch/mips/conf/std.octeon
diff -u src/sys/arch/mips/conf/std.octeon:1.5 src/sys/arch/mips/conf/std.octeon:1.6
--- src/sys/arch/mips/conf/std.octeon:1.5	Sun Apr 18 12:05:29 2021
+++ src/sys/arch/mips/conf/std.octeon	Tue May 11 09:21:24 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: std.octeon,v 1.5 2021/04/18 12:05:29 simonb Exp $
+#	$NetBSD: std.octeon,v 1.6 2021/05/11 09:21:24 simonb Exp $
 
 machine evbmips mips
 include 	"conf/std"	# MI standard options
@@ -10,6 +10,7 @@ options 	MIPS3_ENABLE_CLOCK_INTR
 makeoptions	LP64="yes"
 
 options 	MIPS64R2
+options 	NOFPU		# No FPU
 options 	EXEC_ELF32	# exec ELF32 binaries
 options 	EXEC_ELF64	# exec ELF64 binaries
 options 	COMPAT_NETBSD32



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

2021-05-10 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Tue May 11 03:43:30 UTC 2021

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

Log Message:
All of the OFW-enumerated busses now associate the OFW node with the
device at config_found() time, so we can remove all of the stuff from
device_register() that does it, leaving only the @pci case to fix that
up (similar situation with ACPI on ARM and x86).

Adapt the boot device matching code to use the devhandle from the
device_t rather than the previous mechanism, and add some comments
explaining what's going on and some assertions to validate the
comments.

Collapse the sun4v vdsk boot device detection into the normal "sd"
case because it's almost identical to the normal "sd" case anyhow.


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

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

Modified files:

Index: src/sys/arch/sparc64/sparc64/autoconf.c
diff -u src/sys/arch/sparc64/sparc64/autoconf.c:1.229 src/sys/arch/sparc64/sparc64/autoconf.c:1.230
--- src/sys/arch/sparc64/sparc64/autoconf.c:1.229	Mon May 10 23:53:44 2021
+++ src/sys/arch/sparc64/sparc64/autoconf.c	Tue May 11 03:43:30 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.229 2021/05/10 23:53:44 thorpej Exp $ */
+/*	$NetBSD: autoconf.c,v 1.230 2021/05/11 03:43:30 thorpej Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.229 2021/05/10 23:53:44 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.230 2021/05/11 03:43:30 thorpej Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -144,7 +144,6 @@ int kgdb_break_at_attach;
 #endif
 
 #define	OFPATHLEN	128
-#define	OFNODEKEY	"OFpnode"
 
 char	machine_banner[100];
 char	machine_model[100];
@@ -997,62 +996,25 @@ dev_bi_unit_drive_match(device_t dev, in
 }
 
 /*
- * Get the firmware package handle from a device_t.
- * Assuming we have previously stored it in the device properties
- * dictionary.
- */
-static int
-device_ofnode(device_t dev)
-{
-	prop_dictionary_t props;
-	prop_object_t obj;
-
-	if (dev == NULL)
-		return 0;
-	props = device_properties(dev);
-	if (props == NULL)
-		return 0;
-	obj = prop_dictionary_get(props, OFNODEKEY);
-	if (obj == NULL)
-		return 0;
-
-	return prop_number_signed_value(obj);
-}
-
-/*
- * Save the firmware package handle inside the properties dictionary
- * of a device_t.
- */
-static void
-device_setofnode(device_t dev, int node)
-{
-	prop_dictionary_t props;
-	prop_object_t obj;
-
-	if (dev == NULL)
-		return;
-	props = device_properties(dev);
-	if (props == NULL)
-		return;
-	obj = prop_number_create_signed(node);
-	if (obj == NULL)
-		return;
-	prop_dictionary_set(props, OFNODEKEY, obj);
-	prop_object_release(obj);
-	DPRINTF(ACDB_BOOTDEV, (" [device %s has node %x] ",
-	device_xname(dev), node));
-}
-
-/*
  * Called back during autoconfiguration for each device found
  */
 void
 device_register(device_t dev, void *aux)
 {
 	device_t busdev = device_parent(dev);
+	devhandle_t devhandle;
 	int ofnode = 0;
 
 	/*
+	 * If the device has a valid OpenFirmware node association,
+	 * grab it now.
+	 */
+	devhandle = device_handle(dev);
+	if (devhandle_type(devhandle) == DEVHANDLE_TYPE_OF) {
+		ofnode = devhandle_to_of(devhandle);
+	}
+
+	/*
 	 * We don't know the type of 'aux' - it depends on the
 	 * bus this device attaches to. We are only interested in
 	 * certain bus types, this only is used to find the boot
@@ -1063,23 +1025,18 @@ device_register(device_t dev, void *aux)
 		 * Ignore mainbus0 itself, it certainly is not a boot
 		 * device.
 		 */
-	} else if (device_is_a(busdev, "mainbus")) {
-		struct mainbus_attach_args *ma = aux;
-
-		ofnode = ma->ma_node;
 	} else if (device_is_a(busdev, "pci")) {
 		struct pci_attach_args *pa = aux;
 
-		ofnode = PCITAG_NODE(pa->pa_tag);
-	} else if (device_is_a(busdev, "sbus") || device_is_a(busdev, "dma")
-	|| device_is_a(busdev, "ledma")) {
-		struct sbus_attach_args *sa = aux;
-
-		ofnode = sa->sa_node;
-	} else if (device_is_a(busdev, "ebus")) {
-		struct ebus_attach_args *ea = aux;
-
-		ofnode = ea->ea_node;
+		/*
+		 * XXX PCI devices don't currently get their devhandles
+		 * set when the PCI layer attaches them, so we need to
+		 * do it here.  (It's not just us; ACPI has the same
+		 * problem...)
+		 */
+		ofnode = (int)PCITAG_NODE(pa->pa_tag);
+		devhandle = devhandle_from_of(ofnode);
+		device_set_handle(dev, devhandle);
 	} else if (device_is_a(busdev, "iic")) {
 		struct i2c_attach_args *ia = aux;
 
@@ -1098,6 +1055,7 @@ device_register(device_t dev, void *aux)
 add_gpio_props_e250(dev, aux);
 			}
 		} 
+		return;
 	} else if (device_is_a(dev, "sd") || device_is_a(dev, "cd")) {
 		struct scsipibus_attach_args *sa = aux;
 		struct scsipi_periph *periph = sa->sa_periph;
@@ -1121,9 +1079,37 @@ device_register(device_t dev, void *aux)
 

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

2021-05-10 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon May 10 23:58:52 UTC 2021

Modified Files:
src/sys/arch/mips/cavium: mainbus.c

Log Message:
Specify the "fdt" interface attribute when configuring via FDT, since
mainbus also carries the "mainbus" interface attribute.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/mips/cavium/mainbus.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/mips/cavium/mainbus.c
diff -u src/sys/arch/mips/cavium/mainbus.c:1.7 src/sys/arch/mips/cavium/mainbus.c:1.8
--- src/sys/arch/mips/cavium/mainbus.c:1.7	Sat Apr 24 23:36:42 2021
+++ src/sys/arch/mips/cavium/mainbus.c	Mon May 10 23:58:52 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: mainbus.c,v 1.7 2021/04/24 23:36:42 thorpej Exp $	*/
+/*	$NetBSD: mainbus.c,v 1.8 2021/05/10 23:58:52 thorpej Exp $	*/
 
 /*
  * Copyright (c) 2007
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.7 2021/04/24 23:36:42 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.8 2021/05/10 23:58:52 thorpej Exp $");
 
 #define	_MIPS_BUS_DMA_PRIVATE
 
@@ -149,7 +149,9 @@ mainbus_attach_devicetree(device_t self)
 	}
 
 	faa.faa_phandle = OF_peer(0);
-	config_found(self, , NULL, CFARG_EOL);
+	config_found(self, , NULL,
+	CFARG_IATTR, "fdt",
+	CFARG_EOL);
 }
 
 static int



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

2021-05-08 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat May  8 13:10:29 UTC 2021

Modified Files:
src/sys/arch/hppa/include: param.h

Log Message:
KNF


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/hppa/include/param.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/hppa/include/param.h
diff -u src/sys/arch/hppa/include/param.h:1.27 src/sys/arch/hppa/include/param.h:1.28
--- src/sys/arch/hppa/include/param.h:1.27	Fri May  1 08:21:27 2020
+++ src/sys/arch/hppa/include/param.h	Sat May  8 13:10:29 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.27 2020/05/01 08:21:27 isaki Exp $	*/
+/*	$NetBSD: param.h,v 1.28 2021/05/08 13:10:29 skrll Exp $	*/
 
 /*	$OpenBSD: param.h,v 1.12 2001/07/06 02:07:41 provos Exp $	*/
 
@@ -41,11 +41,11 @@
 
 #define	PGSHIFT		12		/* LOG2(NBPG) */
 #define	NBPG		(1 << PGSHIFT)	/* bytes/page */
-#define	PGOFSET		(NBPG-1)	/* byte offset into page */
+#define	PGOFSET		(NBPG - 1)	/* byte offset into page */
 
 #define	SEGSHIFT	(PGSHIFT + (PGSHIFT-PTESHIFT))	/* LOG2(NBSEG) */
 #define NBSEG		(1 << SEGSHIFT)	/* bytes/segment (quadrant) */
-#define	SEGOFSET	(NBSEG-1)	/* byte offset into segment */
+#define	SEGOFSET	(NBSEG - 1)	/* byte offset into segment */
 
 #define	KERNBASE	0x	/* start of kernel virtual */
 #define	BTOPKERNBASE	((u_long)KERNBASE >> PGSHIFT)
@@ -61,7 +61,7 @@
 #define	USPACE		(UPAGES * NBPG)	/* pages for user struct and kstack */
 
 #ifndef	MSGBUFSIZE
-#define	MSGBUFSIZE	(2*NBPG)	/* default message buffer size */
+#define	MSGBUFSIZE	(2 * NBPG)	/* default message buffer size */
 #endif
 
 /*



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

2021-05-08 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat May  8 13:09:58 UTC 2021

Modified Files:
src/sys/arch/mips/include: mips_param.h

Log Message:
KNG


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/sys/arch/mips/include/mips_param.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/mips/include/mips_param.h
diff -u src/sys/arch/mips/include/mips_param.h:1.48 src/sys/arch/mips/include/mips_param.h:1.49
--- src/sys/arch/mips/include/mips_param.h:1.48	Mon Apr 26 13:29:51 2021
+++ src/sys/arch/mips/include/mips_param.h	Sat May  8 13:09:58 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: mips_param.h,v 1.48 2021/04/26 13:29:51 christos Exp $	*/
+/*	$NetBSD: mips_param.h,v 1.49 2021/05/08 13:09:58 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -104,7 +104,7 @@
 
 #define	SEGSHIFT	(PGSHIFT + PTPLENGTH)	/* LOG2(NBSEG) */
 #define	NBSEG		(1 << SEGSHIFT)	/* bytes/segment */
-#define	SEGOFSET	(NBSEG-1)	/* byte offset into segment */
+#define	SEGOFSET	(NBSEG - 1)	/* byte offset into segment */
 
 #ifdef _LP64
 #define	SEGLENGTH	(PGSHIFT - 3)



CVS commit: src/sys/arch/vax/vsa

2021-05-08 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sat May  8 09:03:30 UTC 2021

Modified Files:
src/sys/arch/vax/vsa: tc_vsbus.c

Log Message:
Catch up with this commit:

http://www.nerv.org/netbsd/?q=id:20210507T165558Z.d4aba9e0e053181f2a98ee4ee43012b50949921b

by which per slot tcs_used flag was obsoleted.

No need to initialize __BIT(0) of sc_slots_used here; it is zero anyway
before calling tcattach().


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/vax/vsa/tc_vsbus.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/vax/vsa/tc_vsbus.c
diff -u src/sys/arch/vax/vsa/tc_vsbus.c:1.9 src/sys/arch/vax/vsa/tc_vsbus.c:1.10
--- src/sys/arch/vax/vsa/tc_vsbus.c:1.9	Fri Jun  9 18:02:40 2017
+++ src/sys/arch/vax/vsa/tc_vsbus.c	Sat May  8 09:03:30 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: tc_vsbus.c,v 1.9 2017/06/09 18:02:40 flxd Exp $	*/
+/*	$NetBSD: tc_vsbus.c,v 1.10 2021/05/08 09:03:30 rin Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tc_vsbus.c,v 1.9 2017/06/09 18:02:40 flxd Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tc_vsbus.c,v 1.10 2021/05/08 09:03:30 rin Exp $");
 
 #include 
 #include 
@@ -252,7 +252,6 @@ tc_vsbus_attach(device_t parent, device_
 	/* Pass pre-mapped space for TC drivers not bus_space'ified yet. */
 	sc->sc_slots[0].tcs_addr = (tc_addr_t)bus_space_vaddr(bst, bsh_slot);
 	sc->sc_slots[0].tcs_cookie = sc;
-	sc->sc_slots[0].tcs_used = 0;
 
 	tba.tba_busname = "tc";
 	/* Tag with custom methods for pre-mapped bus_space. */



CVS commit: src/sys/arch/alpha/pci

2021-05-07 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat May  8 00:08:43 UTC 2021

Modified Files:
src/sys/arch/alpha/pci: sio_pic.c ttwoga.c ttwoga_dma.c ttwogavar.h

Log Message:
More symbol sanitizing.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/sys/arch/alpha/pci/sio_pic.c
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/alpha/pci/ttwoga.c
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/alpha/pci/ttwoga_dma.c
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/alpha/pci/ttwogavar.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/alpha/pci/sio_pic.c
diff -u src/sys/arch/alpha/pci/sio_pic.c:1.47 src/sys/arch/alpha/pci/sio_pic.c:1.48
--- src/sys/arch/alpha/pci/sio_pic.c:1.47	Fri May  7 16:58:34 2021
+++ src/sys/arch/alpha/pci/sio_pic.c	Sat May  8 00:08:43 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: sio_pic.c,v 1.47 2021/05/07 16:58:34 thorpej Exp $ */
+/* $NetBSD: sio_pic.c,v 1.48 2021/05/08 00:08:43 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000, 2020 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: sio_pic.c,v 1.47 2021/05/07 16:58:34 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sio_pic.c,v 1.48 2021/05/08 00:08:43 thorpej Exp $");
 
 #include 
 #include 
@@ -102,9 +102,9 @@ __KERNEL_RCSID(0, "$NetBSD: sio_pic.c,v 
  * Private functions and variables.
  */
 
-bus_space_tag_t sio_iot;
-pci_chipset_tag_t sio_pc;
-bus_space_handle_t sio_ioh_icu1, sio_ioh_icu2;
+static bus_space_tag_t sio_iot;
+static pci_chipset_tag_t sio_pc;
+static bus_space_handle_t sio_ioh_icu1, sio_ioh_icu2;
 
 #define	ICU_LEN		16		/* number of ISA IRQs */
 
@@ -262,7 +262,7 @@ cy82c693_write_elcr(int elcr, uint8_t va
  * they should panic.
  */
 
-int (*const sio_elcr_setup_funcs[])(void) = {
+static int (*const sio_elcr_setup_funcs[])(void) = {
 	cy82c693_setup_elcr,
 	i82378_setup_elcr,
 	NULL,

Index: src/sys/arch/alpha/pci/ttwoga.c
diff -u src/sys/arch/alpha/pci/ttwoga.c:1.16 src/sys/arch/alpha/pci/ttwoga.c:1.17
--- src/sys/arch/alpha/pci/ttwoga.c:1.16	Sat Apr 24 23:36:23 2021
+++ src/sys/arch/alpha/pci/ttwoga.c	Sat May  8 00:08:43 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: ttwoga.c,v 1.16 2021/04/24 23:36:23 thorpej Exp $ */
+/* $NetBSD: ttwoga.c,v 1.17 2021/05/08 00:08:43 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: ttwoga.c,v 1.16 2021/04/24 23:36:23 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ttwoga.c,v 1.17 2021/05/08 00:08:43 thorpej Exp $");
 
 #include 
 #include 
@@ -62,27 +62,27 @@ __KERNEL_RCSID(0, "$NetBSD: ttwoga.c,v 1
 
 #include "locators.h"
 
-int	ttwogamatch(device_t, cfdata_t, void *);
-void	ttwogaattach(device_t, device_t, void *);
+static int	ttwogamatch(device_t, cfdata_t, void *);
+static void	ttwogaattach(device_t, device_t, void *);
 
 CFATTACH_DECL_NEW(ttwoga, 0,
 ttwogamatch, ttwogaattach, NULL, NULL);
 
-int	ttwogaprint(void *, const char *);
+static int	ttwogaprint(void *, const char *);
 
-int	ttwopcimatch(device_t, cfdata_t, void *);
-void	ttwopciattach(device_t, device_t, void *);
+static int	ttwopcimatch(device_t, cfdata_t, void *);
+static void	ttwopciattach(device_t, device_t, void *);
 
 CFATTACH_DECL_NEW(ttwopci, 0,
 ttwopcimatch, ttwopciattach, NULL, NULL);
 
-int	ttwosableioprint(void *, const char *);
+static int	ttwosableioprint(void *, const char *);
 
 /*
  * There can be only one, but it might have 2 primary PCI busses.
  */
-int ttwogafound;
-struct ttwoga_config ttwoga_configuration[2];
+static int ttwogafound;
+static struct ttwoga_config ttwoga_configuration[2];
 
 /* CBUS address bias for Gamma systems. */
 bus_addr_t ttwoga_gamma_cbus_bias;
@@ -90,7 +90,7 @@ bus_addr_t ttwoga_gamma_cbus_bias;
 #define	GIGABYTE	(1024UL * 1024UL * 1024UL)
 #define	MEGABYTE	(1024UL * 1024UL)
 
-const struct ttwoga_sysmap ttwoga_sysmap[2] = {
+static const struct ttwoga_sysmap ttwoga_sysmap[2] = {
 /*	  Base			System size	Bus size	*/
 	{ T2_PCI0_SIO_BASE,	256UL * MEGABYTE, 8UL * MEGABYTE,
 	  T2_PCI0_SMEM_BASE,	4UL * GIGABYTE,	128UL * MEGABYTE,
@@ -107,7 +107,7 @@ const struct ttwoga_sysmap ttwoga_sysmap
 #undef GIGABYTE
 #undef MEGABYTE
 
-int
+static int
 ttwogamatch(device_t parent, cfdata_t match, void *aux)
 {
 	struct mainbus_attach_args *ma = aux;
@@ -122,7 +122,7 @@ ttwogamatch(device_t parent, cfdata_t ma
 	return (1);
 }
 
-void
+static void
 ttwogaattach(device_t parent, device_t self, void *aux)
 {
 	struct pcibus_attach_args pba;
@@ -149,7 +149,7 @@ ttwogaattach(device_t parent, device_t s
 	}
 }
 
-int
+static int
 ttwogaprint(void *aux, const char *pnp)
 {
 	struct pcibus_attach_args *pba = aux;
@@ -204,7 +204,7 @@ ttwoga_init(int hose, int mallocsafe)
 	return (tcp);
 }
 
-int
+static int
 ttwopcimatch(device_t parent, cfdata_t match, void *aux)
 {
 	struct 

CVS commit: src/sys/arch/alpha

2021-05-07 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri May  7 22:46:11 UTC 2021

Modified Files:
src/sys/arch/alpha/tc: tcasic.c
src/sys/arch/alpha/tlsb: gbus.c mcclock_tlsb.c

Log Message:
Static'ify more symbols.


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/sys/arch/alpha/tc/tcasic.c
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/alpha/tlsb/gbus.c
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/alpha/tlsb/mcclock_tlsb.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/alpha/tc/tcasic.c
diff -u src/sys/arch/alpha/tc/tcasic.c:1.50 src/sys/arch/alpha/tc/tcasic.c:1.51
--- src/sys/arch/alpha/tc/tcasic.c:1.50	Sat Apr 24 23:36:24 2021
+++ src/sys/arch/alpha/tc/tcasic.c	Fri May  7 22:46:10 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: tcasic.c,v 1.50 2021/04/24 23:36:24 thorpej Exp $ */
+/* $NetBSD: tcasic.c,v 1.51 2021/05/07 22:46:10 thorpej Exp $ */
 
 /*
  * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
@@ -32,7 +32,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: tcasic.c,v 1.50 2021/04/24 23:36:24 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcasic.c,v 1.51 2021/05/07 22:46:10 thorpej Exp $");
 
 #include 
 #include 
@@ -47,20 +47,20 @@ __KERNEL_RCSID(0, "$NetBSD: tcasic.c,v 1
 #include 
 
 /* Definition of the driver for autoconfig. */
-int	tcasicmatch(device_t, cfdata_t, void *);
-void	tcasicattach(device_t, device_t, void *);
+static int	tcasicmatch(device_t, cfdata_t, void *);
+static void	tcasicattach(device_t, device_t, void *);
 
 CFATTACH_DECL_NEW(tcasic, 0,
 tcasicmatch, tcasicattach, NULL, NULL);
 
 extern struct cfdriver tcasic_cd;
 
-int	tcasicprint(void *, const char *);
+static int	tcasicprint(void *, const char *);
 
 /* There can be only one. */
-int	tcasicfound;
+static int	tcasicfound;
 
-int
+static int
 tcasicmatch(device_t parent, cfdata_t cf, void *aux)
 {
 	struct mainbus_attach_args *ma = aux;
@@ -79,7 +79,7 @@ tcasicmatch(device_t parent, cfdata_t cf
 	return (1);
 }
 
-void
+static void
 tcasicattach(device_t parent, device_t self, void *aux)
 {
 	struct tcbus_attach_args tba;
@@ -153,7 +153,7 @@ tcasicattach(device_t parent, device_t s
 	config_found(self, , tcasicprint, CFARG_EOL);
 }
 
-int
+static int
 tcasicprint(void *aux, const char *pnp)
 {
 

Index: src/sys/arch/alpha/tlsb/gbus.c
diff -u src/sys/arch/alpha/tlsb/gbus.c:1.23 src/sys/arch/alpha/tlsb/gbus.c:1.24
--- src/sys/arch/alpha/tlsb/gbus.c:1.23	Sat Apr 24 23:36:24 2021
+++ src/sys/arch/alpha/tlsb/gbus.c	Fri May  7 22:46:10 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: gbus.c,v 1.23 2021/04/24 23:36:24 thorpej Exp $ */
+/* $NetBSD: gbus.c,v 1.24 2021/05/07 22:46:10 thorpej Exp $ */
 
 /*
  * Copyright (c) 1997 by Matthew Jacob
@@ -37,7 +37,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: gbus.c,v 1.23 2021/04/24 23:36:24 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gbus.c,v 1.24 2021/05/07 22:46:10 thorpej Exp $");
 
 #include 
 #include 
@@ -69,7 +69,7 @@ CFATTACH_DECL_NEW(gbus, sizeof(struct gb
 
 static int	gbusprint(void *, const char *);
 
-const struct gbus_attach_args gbus_children[] = {
+static const struct gbus_attach_args gbus_children[] = {
 	{ "zsc",	GBUS_DUART0_OFFSET },
 	{ "zsc",	GBUS_DUART1_OFFSET },
 	{ "mcclock",	GBUS_CLOCK_OFFSET },

Index: src/sys/arch/alpha/tlsb/mcclock_tlsb.c
diff -u src/sys/arch/alpha/tlsb/mcclock_tlsb.c:1.17 src/sys/arch/alpha/tlsb/mcclock_tlsb.c:1.18
--- src/sys/arch/alpha/tlsb/mcclock_tlsb.c:1.17	Fri Jul  1 19:19:51 2011
+++ src/sys/arch/alpha/tlsb/mcclock_tlsb.c	Fri May  7 22:46:11 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: mcclock_tlsb.c,v 1.17 2011/07/01 19:19:51 dyoung Exp $ */
+/* $NetBSD: mcclock_tlsb.c,v 1.18 2021/05/07 22:46:11 thorpej Exp $ */
 
 /*
  * Copyright (c) 1997 by Matthew Jacob
@@ -32,7 +32,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: mcclock_tlsb.c,v 1.17 2011/07/01 19:19:51 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mcclock_tlsb.c,v 1.18 2021/05/07 22:46:11 thorpej Exp $");
 
 #include 
 #include 
@@ -65,8 +65,8 @@ struct mcclock_tlsb_softc {
 	unsigned long regbase;
 };
 
-int	mcclock_tlsb_match(device_t, cfdata_t, void *);
-void	mcclock_tlsb_attach(device_t, device_t, void *);
+static int	mcclock_tlsb_match(device_t, cfdata_t, void *);
+static void	mcclock_tlsb_attach(device_t, device_t, void *);
 
 CFATTACH_DECL_NEW(mcclock_tlsb, sizeof(struct mcclock_tlsb_softc),
 mcclock_tlsb_match, mcclock_tlsb_attach, NULL, NULL);
@@ -75,7 +75,7 @@ static void	mcclock_tlsb_write(struct mc
 static u_int	mcclock_tlsb_read(struct mc146818_softc *, u_int);
 
 
-int
+static int
 mcclock_tlsb_match(device_t parent, cfdata_t cf, void *aux)
 {
 	struct gbus_attach_args *ga = aux;
@@ -85,7 +85,7 @@ mcclock_tlsb_match(device_t parent, cfda
 	return (1);
 }
 
-void
+static void
 mcclock_tlsb_attach(device_t parent, device_t self, void 

CVS commit: src/sys/arch/alpha

2021-05-07 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri May  7 16:58:34 UTC 2021

Modified Files:
src/sys/arch/alpha/common: bus_dma.c shared_intr.c
src/sys/arch/alpha/isa: isa_machdep.c isadma_bounce.c mcclock_isa.c
src/sys/arch/alpha/jensenio: com_jensenio.c jensenio.c jensenio_dma.c
jensenio_intr.c lpt_jensenio.c mcclock_jensenio.c pckbc_jensenio.c
src/sys/arch/alpha/pci: apecs_pci.c cia_pci.c dwlpx_pci.c
irongate_pci.c lca_pci.c mcpcia_pci.c sio.c sio_pic.c tsp_pci.c
ttwoga_pci.c
src/sys/arch/alpha/sableio: com_sableio.c fdc_sableio.c lpt_sableio.c
pckbc_sableio.c sableio.c
src/sys/arch/alpha/tc: ioasic.c mcclock_ioasic.c tc_3000_300.c
tc_3000_500.c tc_conf.h

Log Message:
Liberally sprinkle static around to get more symbols out of the
global namespace.  A small bit of const poisoning in the TC code.


To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.72 src/sys/arch/alpha/common/bus_dma.c
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/alpha/common/shared_intr.c
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/alpha/isa/isa_machdep.c
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/alpha/isa/isadma_bounce.c
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/alpha/isa/mcclock_isa.c
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/alpha/jensenio/com_jensenio.c
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/alpha/jensenio/jensenio.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/alpha/jensenio/jensenio_dma.c
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/alpha/jensenio/jensenio_intr.c \
src/sys/arch/alpha/jensenio/lpt_jensenio.c
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/alpha/jensenio/mcclock_jensenio.c
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/alpha/jensenio/pckbc_jensenio.c
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/alpha/pci/apecs_pci.c
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/alpha/pci/cia_pci.c
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/alpha/pci/dwlpx_pci.c
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/alpha/pci/irongate_pci.c \
src/sys/arch/alpha/pci/tsp_pci.c
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/alpha/pci/lca_pci.c
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/alpha/pci/mcpcia_pci.c
cvs rdiff -u -r1.55 -r1.56 src/sys/arch/alpha/pci/sio.c
cvs rdiff -u -r1.46 -r1.47 src/sys/arch/alpha/pci/sio_pic.c
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/alpha/pci/ttwoga_pci.c
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/alpha/sableio/com_sableio.c
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/alpha/sableio/fdc_sableio.c
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/alpha/sableio/lpt_sableio.c
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/alpha/sableio/pckbc_sableio.c \
src/sys/arch/alpha/sableio/sableio.c
cvs rdiff -u -r1.48 -r1.49 src/sys/arch/alpha/tc/ioasic.c
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/alpha/tc/mcclock_ioasic.c
cvs rdiff -u -r1.38 -r1.39 src/sys/arch/alpha/tc/tc_3000_300.c
cvs rdiff -u -r1.37 -r1.38 src/sys/arch/alpha/tc/tc_3000_500.c
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/alpha/tc/tc_conf.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/alpha/common/bus_dma.c
diff -u src/sys/arch/alpha/common/bus_dma.c:1.71 src/sys/arch/alpha/common/bus_dma.c:1.72
--- src/sys/arch/alpha/common/bus_dma.c:1.71	Wed Nov 18 02:04:29 2020
+++ src/sys/arch/alpha/common/bus_dma.c	Fri May  7 16:58:33 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: bus_dma.c,v 1.71 2020/11/18 02:04:29 thorpej Exp $ */
+/* $NetBSD: bus_dma.c,v 1.72 2021/05/07 16:58:33 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.71 2020/11/18 02:04:29 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.72 2021/05/07 16:58:33 thorpej Exp $");
 
 #include 
 #include 
@@ -50,9 +50,9 @@ __KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 
 
 #include 
 
-int	_bus_dmamap_load_buffer_direct(bus_dma_tag_t,
-	bus_dmamap_t, void *, bus_size_t, struct vmspace *, int,
-	paddr_t *, int *, int);
+static int	_bus_dmamap_load_buffer_direct(bus_dma_tag_t,
+		bus_dmamap_t, void *, bus_size_t, struct vmspace *, int,
+		paddr_t *, int *, int);
 
 extern paddr_t avail_start, avail_end;	/* from pmap.c */
 
@@ -129,7 +129,7 @@ _bus_dmamap_destroy(bus_dma_tag_t t, bus
  * the starting segment on entrance, and the ending segment on exit.
  * first indicates if this is the first invocation of this function.
  */
-int
+static int
 _bus_dmamap_load_buffer_direct(bus_dma_tag_t t, bus_dmamap_t map,
 void *buf, size_t buflen, struct vmspace *vm, int flags, paddr_t *lastaddrp,
 int *segp, int first)

Index: src/sys/arch/alpha/common/shared_intr.c
diff -u src/sys/arch/alpha/common/shared_intr.c:1.26 src/sys/arch/alpha/common/shared_intr.c:1.27
--- src/sys/arch/alpha/common/shared_intr.c:1.26	Sat Sep 26 02:35:31 2020
+++ src/sys/arch/alpha/common/shared_intr.c	Fri May  7 16:58:33 2021
@@ -1,4 +1,4 @@
-/* 

CVS commit: src/sys/arch/amiga/stand/bootblock

2021-05-06 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu May  6 13:07:00 UTC 2021

Modified Files:
src/sys/arch/amiga/stand/bootblock: Makefile

Log Message:
Unhook elf2bb and txlt as they are built as tools.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/amiga/stand/bootblock/Makefile

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

Modified files:

Index: src/sys/arch/amiga/stand/bootblock/Makefile
diff -u src/sys/arch/amiga/stand/bootblock/Makefile:1.5 src/sys/arch/amiga/stand/bootblock/Makefile:1.6
--- src/sys/arch/amiga/stand/bootblock/Makefile:1.5	Thu Feb 25 03:42:14 2021
+++ src/sys/arch/amiga/stand/bootblock/Makefile	Thu May  6 13:07:00 2021
@@ -1,15 +1,7 @@
-#	$NetBSD: Makefile,v 1.5 2021/02/25 03:42:14 rin Exp $
+#	$NetBSD: Makefile,v 1.6 2021/05/06 13:07:00 rin Exp $
 
 .include 
 
-# Don't install these, but make them first:
-.ifnmake install
-SUBDIR=txlt
-SUBDIR+=elf2bb
-.endif
-
-# but these:
 SUBDIR+=boot bootxx_ffs bootxx_ffsv2
 
-
 .include 



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

2021-05-05 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed May  5 20:58:03 UTC 2021

Modified Files:
src/sys/arch/arm/sunxi: sunxi_codec.c sunxi_codec.h

Log Message:
Fix GENERIC64 build


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/arm/sunxi/sunxi_codec.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/sunxi/sunxi_codec.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/sunxi/sunxi_codec.c
diff -u src/sys/arch/arm/sunxi/sunxi_codec.c:1.13 src/sys/arch/arm/sunxi/sunxi_codec.c:1.14
--- src/sys/arch/arm/sunxi/sunxi_codec.c:1.13	Wed May  5 10:24:04 2021
+++ src/sys/arch/arm/sunxi/sunxi_codec.c	Wed May  5 20:58:03 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_codec.c,v 1.13 2021/05/05 10:24:04 jmcneill Exp $ */
+/* $NetBSD: sunxi_codec.c,v 1.14 2021/05/05 20:58:03 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014-2017 Jared McNeill 
@@ -29,7 +29,7 @@
 #include "opt_ddb.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_codec.c,v 1.13 2021/05/05 10:24:04 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_codec.c,v 1.14 2021/05/05 20:58:03 jmcneill Exp $");
 
 #include 
 #include 
@@ -89,10 +89,10 @@ __KERNEL_RCSID(0, "$NetBSD: sunxi_codec.
 #define	AC_ADC_CNT(_sc)		((_sc)->sc_cfg->ADC_CNT)
 
 static const struct device_compatible_entry compat_data[] = {
-	A10_CODEC_COMPATDATA,
-	A31_CODEC_COMPATDATA,
-	H3_CODEC_COMPATDATA,
-	V3S_CODEC_COMPATDATA,
+	A10_CODEC_COMPATDATA
+	A31_CODEC_COMPATDATA
+	H3_CODEC_COMPATDATA
+	V3S_CODEC_COMPATDATA
 
 	DEVICE_COMPAT_EOL
 };

Index: src/sys/arch/arm/sunxi/sunxi_codec.h
diff -u src/sys/arch/arm/sunxi/sunxi_codec.h:1.7 src/sys/arch/arm/sunxi/sunxi_codec.h:1.8
--- src/sys/arch/arm/sunxi/sunxi_codec.h:1.7	Wed May  5 10:24:04 2021
+++ src/sys/arch/arm/sunxi/sunxi_codec.h	Wed May  5 20:58:03 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_codec.h,v 1.7 2021/05/05 10:24:04 jmcneill Exp $ */
+/* $NetBSD: sunxi_codec.h,v 1.8 2021/05/05 20:58:03 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014-2017 Jared McNeill 
@@ -121,7 +121,7 @@ struct sunxi_codec_softc {
 extern const struct sunxi_codec_conf sun8i_h3_codecconf;
 #define	H3_CODEC_COMPATDATA		\
 	{ .compat = "allwinner,sun8i-h3-codec",\
-	  .data = _h3_codecconf }
+	  .data = _h3_codecconf },
 #else
 #define	H3_CODEC_COMPATDATA
 #endif
@@ -130,7 +130,7 @@ extern const struct sunxi_codec_conf sun
 extern const struct sunxi_codec_conf sun8i_v3s_codecconf;
 #define V3S_CODEC_COMPATDATA		\
 	{ .compat = "allwinner,sun8i-v3s-codec",			\
-	  .data = _v3s_codecconf }
+	  .data = _v3s_codecconf },
 #else
 #define V3S_CODEC_COMPATDATA
 #endif
@@ -140,11 +140,11 @@ extern const struct sunxi_codec_conf sun
 	{ .compat = "allwinner,sun4i-a10-codec",			\
 	  .data = _a10_codecconf }, \
 	{ .compat = "allwinner,sun7i-a20-codec",			\
-	  .data = _a10_codecconf }
+	  .data = _a10_codecconf },
 
 extern const struct sunxi_codec_conf sun6i_a31_codecconf;
 #define	A31_CODEC_COMPATDATA		\
 	{ .compat = "allwinner,sun6i-a31-codec",			\
-	  .data = _a31_codecconf }
+	  .data = _a31_codecconf },
 
 #endif /* !_ARM_SUNXI_CODEC_H */



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

2021-05-05 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed May  5 15:39:39 UTC 2021

Modified Files:
src/sys/arch/alpha/conf: Makefile.alpha

Log Message:
Remove unneeded Makefile dependency for things which have long since
used opt_*.h headers.


To generate a diff of this commit:
cvs rdiff -u -r1.86 -r1.87 src/sys/arch/alpha/conf/Makefile.alpha

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/alpha/conf/Makefile.alpha
diff -u src/sys/arch/alpha/conf/Makefile.alpha:1.86 src/sys/arch/alpha/conf/Makefile.alpha:1.87
--- src/sys/arch/alpha/conf/Makefile.alpha:1.86	Wed May  5 01:35:35 2021
+++ src/sys/arch/alpha/conf/Makefile.alpha	Wed May  5 15:39:39 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.alpha,v 1.86 2021/05/05 01:35:35 thorpej Exp $
+#	$NetBSD: Makefile.alpha,v 1.87 2021/05/05 15:39:39 thorpej Exp $
 
 # Makefile for NetBSD
 #
@@ -71,9 +71,6 @@ STRIPFLAGS=	-g -X
 ## (6) port specific target dependencies
 ##
 
-# depend on CPU configuration
-clock.o apecs.o cia.o lca.o ioasic.o icasic.o: Makefile
-
 ##
 ## (7) misc settings
 ##



<    1   2   3   4   5   6   7   8   9   10   >