CVS commit: src/distrib/notes/common

2023-12-15 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Fri Dec 15 22:09:16 UTC 2023

Modified Files:
src/distrib/notes/common: main

Log Message:
main: minor style fix


To generate a diff of this commit:
cvs rdiff -u -r1.571 -r1.572 src/distrib/notes/common/main

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

Modified files:

Index: src/distrib/notes/common/main
diff -u src/distrib/notes/common/main:1.571 src/distrib/notes/common/main:1.572
--- src/distrib/notes/common/main:1.571	Thu Dec 14 20:46:45 2023
+++ src/distrib/notes/common/main	Fri Dec 15 22:09:16 2023
@@ -1,4 +1,4 @@
-.\"	$NetBSD: main,v 1.571 2023/12/14 20:46:45 abs Exp $
+.\"	$NetBSD: main,v 1.572 2023/12/15 22:09:16 gutteridge Exp $
 .\"
 .\" Copyright (c) 1999-2012 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -815,7 +815,7 @@ In
 .Nx 9
 and earlier, filesystems listed in
 .Pa /etc/fstab
-would be mounted before non legacy
+would be mounted before non-legacy
 .Ic zfs
 filesystems. Starting from
 .Nx 10



CVS commit: src/distrib/notes/common

2023-12-15 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Fri Dec 15 22:09:16 UTC 2023

Modified Files:
src/distrib/notes/common: main

Log Message:
main: minor style fix


To generate a diff of this commit:
cvs rdiff -u -r1.571 -r1.572 src/distrib/notes/common/main

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



CVS commit: src/sys/arch/powerpc

2023-12-15 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Dec 15 09:44:00 UTC 2023

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

Log Message:
powerpc: Make sure direct-mapped buffer fits within correct range

For OEA and OEA64_BRIDGE, only first 3GiB memory is direct-mapped.

Part of PR kern/57621


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sys/arch/powerpc/include/pmap.h
cvs rdiff -u -r1.55 -r1.56 src/sys/arch/powerpc/powerpc/bus_dma.c
cvs rdiff -u -r1.105 -r1.106 src/sys/arch/powerpc/powerpc/vm_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/powerpc/include/pmap.h
diff -u src/sys/arch/powerpc/include/pmap.h:1.42 src/sys/arch/powerpc/include/pmap.h:1.43
--- src/sys/arch/powerpc/include/pmap.h:1.42	Sat May  7 07:10:46 2022
+++ src/sys/arch/powerpc/include/pmap.h	Fri Dec 15 09:43:59 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.h,v 1.42 2022/05/07 07:10:46 rin Exp $	*/
+/*	$NetBSD: pmap.h,v 1.43 2023/12/15 09:43:59 rin Exp $	*/
 
 #ifndef _POWERPC_PMAP_H_
 #define _POWERPC_PMAP_H_
@@ -20,6 +20,10 @@
 #error unknown PPC variant
 #endif
 
+#ifndef PMAP_DIRECT_MAPPED_LEN
+#define	PMAP_DIRECT_MAPPED_LEN	(~0UL)
+#endif
+
 #endif /* !_MODULE */
 
 #if !defined(_LOCORE) && (defined(MODULAR) || defined(_MODULE))

Index: src/sys/arch/powerpc/powerpc/bus_dma.c
diff -u src/sys/arch/powerpc/powerpc/bus_dma.c:1.55 src/sys/arch/powerpc/powerpc/bus_dma.c:1.56
--- src/sys/arch/powerpc/powerpc/bus_dma.c:1.55	Tue Jul 26 20:08:56 2022
+++ src/sys/arch/powerpc/powerpc/bus_dma.c	Fri Dec 15 09:43:59 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: bus_dma.c,v 1.55 2022/07/26 20:08:56 andvar Exp $	*/
+/*	$NetBSD: bus_dma.c,v 1.56 2023/12/15 09:43:59 rin Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
 #define _POWERPC_BUS_DMA_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.55 2022/07/26 20:08:56 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.56 2023/12/15 09:43:59 rin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ppcarch.h"
@@ -707,8 +707,10 @@ _bus_dmamem_map(bus_dma_tag_t t, bus_dma
 	if (nsegs == 1 && (flags & BUS_DMA_DONTCACHE) == 0) {
 		KASSERT(size == segs->ds_len);
 		addr = BUS_MEM_TO_PHYS(t, segs->ds_addr);
-		*kvap = (void *)PMAP_MAP_POOLPAGE(addr);
-		return 0;
+		if (__predict_true(addr + size < PMAP_DIRECT_MAPPED_LEN)) {
+			*kvap = (void *)PMAP_MAP_POOLPAGE(addr);
+			return 0;
+		}
 	}
 #endif
 

Index: src/sys/arch/powerpc/powerpc/vm_machdep.c
diff -u src/sys/arch/powerpc/powerpc/vm_machdep.c:1.105 src/sys/arch/powerpc/powerpc/vm_machdep.c:1.106
--- src/sys/arch/powerpc/powerpc/vm_machdep.c:1.105	Mon Dec  5 16:01:03 2022
+++ src/sys/arch/powerpc/powerpc/vm_machdep.c	Fri Dec 15 09:43:59 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: vm_machdep.c,v 1.105 2022/12/05 16:01:03 martin Exp $	*/
+/*	$NetBSD: vm_machdep.c,v 1.106 2023/12/15 09:43:59 rin Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.105 2022/12/05 16:01:03 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.106 2023/12/15 09:43:59 rin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_altivec.h"
@@ -322,7 +322,8 @@ cpu_uarea_alloc(bool system)
 	 * Allocate a new physically contiguous uarea which can be
 	 * direct-mapped.
 	 */
-	error = uvm_pglistalloc(USPACE, 0, ~0UL, 0, 0, , 1, 1);
+	error = uvm_pglistalloc(USPACE, 0, PMAP_DIRECT_MAPPED_LEN, 0, 0,
+	, 1, 1);
 	if (error) {
 		return NULL;
 	}



CVS commit: src/sys/arch/powerpc

2023-12-15 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Dec 15 09:44:00 UTC 2023

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

Log Message:
powerpc: Make sure direct-mapped buffer fits within correct range

For OEA and OEA64_BRIDGE, only first 3GiB memory is direct-mapped.

Part of PR kern/57621


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sys/arch/powerpc/include/pmap.h
cvs rdiff -u -r1.55 -r1.56 src/sys/arch/powerpc/powerpc/bus_dma.c
cvs rdiff -u -r1.105 -r1.106 src/sys/arch/powerpc/powerpc/vm_machdep.c

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



CVS commit: src/sys/arch/powerpc

2023-12-15 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Dec 15 09:42:33 UTC 2023

Modified Files:
src/sys/arch/powerpc/include: vmparam.h
src/sys/arch/powerpc/include/oea: pmap.h
src/sys/arch/powerpc/oea: pmap.c pmap_kernel.c

Log Message:
powerpc: oea: For OEA64_BRIDGE, 1:1 map up to 3GiB memory

As done for OEA. Note that kva over 3GiB is reserved.

Provide PMAP_MAP_POOLPAGE for OEA64_BRIDGE at the same time, by
which direct-mapped memory is utilized in order to work around
starvation of 512MiB kernel virtual space.

PR kern/57621


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/powerpc/include/vmparam.h
cvs rdiff -u -r1.38 -r1.39 src/sys/arch/powerpc/include/oea/pmap.h
cvs rdiff -u -r1.120 -r1.121 src/sys/arch/powerpc/oea/pmap.c
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/powerpc/oea/pmap_kernel.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/powerpc/include/vmparam.h
diff -u src/sys/arch/powerpc/include/vmparam.h:1.26 src/sys/arch/powerpc/include/vmparam.h:1.27
--- src/sys/arch/powerpc/include/vmparam.h:1.26	Wed May 11 13:58:43 2022
+++ src/sys/arch/powerpc/include/vmparam.h	Fri Dec 15 09:42:33 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: vmparam.h,v 1.26 2022/05/11 13:58:43 andvar Exp $	*/
+/*	$NetBSD: vmparam.h,v 1.27 2023/12/15 09:42:33 rin Exp $	*/
 
 #ifndef _POWERPC_VMPARAM_H_
 #define _POWERPC_VMPARAM_H_
@@ -12,7 +12,7 @@
  * These are common for BOOKE, IBM4XX, and OEA
  */
 #define	VM_FREELIST_DEFAULT	0
-#define	VM_FREELIST_FIRST256	1
+#define	VM_FREELIST_DIRECT_MAPPED	1
 #define	VM_FREELIST_FIRST16	2
 #define	VM_NFREELIST		3
 

Index: src/sys/arch/powerpc/include/oea/pmap.h
diff -u src/sys/arch/powerpc/include/oea/pmap.h:1.38 src/sys/arch/powerpc/include/oea/pmap.h:1.39
--- src/sys/arch/powerpc/include/oea/pmap.h:1.38	Thu Sep 28 06:19:19 2023
+++ src/sys/arch/powerpc/include/oea/pmap.h	Fri Dec 15 09:42:33 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.h,v 1.38 2023/09/28 06:19:19 skrll Exp $	*/
+/*	$NetBSD: pmap.h,v 1.39 2023/12/15 09:42:33 rin Exp $	*/
 
 /*-
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -121,6 +121,16 @@ __BEGIN_DECLS
 #include 
 #include 
 
+/*
+ * For OEA and OEA64_BRIDGE, we guarantee that pa below USER_ADDR
+ * (== 3GB < VM_MIN_KERNEL_ADDRESS) is direct-mapped.
+ */
+#if defined(PPC_OEA) || defined(PPC_OEA64_BRIDGE)
+#define	PMAP_DIRECT_MAPPED_SR	(USER_SR - 1)
+#define	PMAP_DIRECT_MAPPED_LEN \
+((vaddr_t)SEGMENT_LENGTH * (PMAP_DIRECT_MAPPED_SR + 1))
+#endif
+
 #if defined (PPC_OEA) || defined (PPC_OEA64_BRIDGE)
 extern register_t iosrtable[];
 #endif
@@ -186,10 +196,13 @@ static __inline paddr_t vtophys (vaddr_t
  * VA==PA all at once.  But pmap_copy_page() and pmap_zero_page() will have
  * this problem, too.
  */
-#if !defined(PPC_OEA64) && !defined (PPC_OEA64_BRIDGE)
+#if !defined(PPC_OEA64)
 #define	PMAP_MAP_POOLPAGE(pa)	(pa)
 #define	PMAP_UNMAP_POOLPAGE(pa)	(pa)
 #define POOL_VTOPHYS(va)	vtophys((vaddr_t) va)
+
+#define	PMAP_ALLOC_POOLPAGE(flags)	pmap_alloc_poolpage(flags)
+struct vm_page *pmap_alloc_poolpage(int);
 #endif
 
 static __inline paddr_t

Index: src/sys/arch/powerpc/oea/pmap.c
diff -u src/sys/arch/powerpc/oea/pmap.c:1.120 src/sys/arch/powerpc/oea/pmap.c:1.121
--- src/sys/arch/powerpc/oea/pmap.c:1.120	Fri Dec 15 09:36:35 2023
+++ src/sys/arch/powerpc/oea/pmap.c	Fri Dec 15 09:42:33 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.120 2023/12/15 09:36:35 rin Exp $	*/
+/*	$NetBSD: pmap.c,v 1.121 2023/12/15 09:42:33 rin Exp $	*/
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -63,7 +63,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.120 2023/12/15 09:36:35 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.121 2023/12/15 09:42:33 rin Exp $");
 
 #define	PMAP_NOOPNAMES
 
@@ -342,18 +342,6 @@ struct pvo_tqhead *pmap_pvo_table;	/* pv
 struct pool pmap_pool;		/* pool for pmap structures */
 struct pool pmap_pvo_pool;	/* pool for pvo entries */
 
-/*
- * We keep a cache of unmanaged pages to be used for pvo entries for
- * unmanaged pages.
- */
-struct pvo_page {
-	SIMPLEQ_ENTRY(pvo_page) pvop_link;
-};
-SIMPLEQ_HEAD(pvop_head, pvo_page);
-static struct pvop_head pmap_pvop_head = SIMPLEQ_HEAD_INITIALIZER(pmap_pvop_head);
-static u_long pmap_pvop_free;
-static u_long pmap_pvop_maxfree;
-
 static void *pmap_pool_alloc(struct pool *, int);
 static void pmap_pool_free(struct pool *, void *);
 
@@ -1137,7 +1125,7 @@ pmap_create(void)
 	pmap_t pm;
 
 	pm = pool_get(_pool, PR_WAITOK | PR_ZERO);
-	KASSERT((vaddr_t)pm < VM_MIN_KERNEL_ADDRESS);
+	KASSERT((vaddr_t)pm < PMAP_DIRECT_MAPPED_LEN);
 	pmap_pinit(pm);
 	
 	DPRINTFN(CREATE, "pmap_create: pm %p:\n"
@@ -1381,7 +1369,7 @@ pmap_pvo_find_va(pmap_t pm, vaddr_t va, 
 
 	TAILQ_FOREACH(pvo, _pvo_table[ptegidx], pvo_olink) {
 #if defined(DIAGNOSTIC) || defined(DEBUG) || defined(PMAPCHECK)
-		if ((uintptr_t) pvo >= SEGMENT_LENGTH)
+		

CVS commit: src/sys/arch/powerpc

2023-12-15 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Dec 15 09:42:33 UTC 2023

Modified Files:
src/sys/arch/powerpc/include: vmparam.h
src/sys/arch/powerpc/include/oea: pmap.h
src/sys/arch/powerpc/oea: pmap.c pmap_kernel.c

Log Message:
powerpc: oea: For OEA64_BRIDGE, 1:1 map up to 3GiB memory

As done for OEA. Note that kva over 3GiB is reserved.

Provide PMAP_MAP_POOLPAGE for OEA64_BRIDGE at the same time, by
which direct-mapped memory is utilized in order to work around
starvation of 512MiB kernel virtual space.

PR kern/57621


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/powerpc/include/vmparam.h
cvs rdiff -u -r1.38 -r1.39 src/sys/arch/powerpc/include/oea/pmap.h
cvs rdiff -u -r1.120 -r1.121 src/sys/arch/powerpc/oea/pmap.c
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/powerpc/oea/pmap_kernel.c

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



CVS commit: src/sys/arch/powerpc/oea

2023-12-15 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Dec 15 09:36:36 UTC 2023

Modified Files:
src/sys/arch/powerpc/oea: pmap.c

Log Message:
powerpc/oea: pmap_create: Use PR_ZERO and drop memset(9), NFC

Part of PR kern/57621


To generate a diff of this commit:
cvs rdiff -u -r1.119 -r1.120 src/sys/arch/powerpc/oea/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/powerpc/oea/pmap.c
diff -u src/sys/arch/powerpc/oea/pmap.c:1.119 src/sys/arch/powerpc/oea/pmap.c:1.120
--- src/sys/arch/powerpc/oea/pmap.c:1.119	Fri Dec 15 09:35:29 2023
+++ src/sys/arch/powerpc/oea/pmap.c	Fri Dec 15 09:36:35 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.119 2023/12/15 09:35:29 rin Exp $	*/
+/*	$NetBSD: pmap.c,v 1.120 2023/12/15 09:36:35 rin Exp $	*/
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -63,7 +63,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.119 2023/12/15 09:35:29 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.120 2023/12/15 09:36:35 rin Exp $");
 
 #define	PMAP_NOOPNAMES
 
@@ -1136,9 +1136,8 @@ pmap_create(void)
 {
 	pmap_t pm;
 
-	pm = pool_get(_pool, PR_WAITOK);
+	pm = pool_get(_pool, PR_WAITOK | PR_ZERO);
 	KASSERT((vaddr_t)pm < VM_MIN_KERNEL_ADDRESS);
-	memset((void *)pm, 0, sizeof *pm);
 	pmap_pinit(pm);
 	
 	DPRINTFN(CREATE, "pmap_create: pm %p:\n"



CVS commit: src/sys/arch/powerpc/oea

2023-12-15 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Dec 15 09:36:36 UTC 2023

Modified Files:
src/sys/arch/powerpc/oea: pmap.c

Log Message:
powerpc/oea: pmap_create: Use PR_ZERO and drop memset(9), NFC

Part of PR kern/57621


To generate a diff of this commit:
cvs rdiff -u -r1.119 -r1.120 src/sys/arch/powerpc/oea/pmap.c

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



CVS commit: src/sys/arch/powerpc/oea

2023-12-15 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Dec 15 09:35:29 UTC 2023

Modified Files:
src/sys/arch/powerpc/oea: pmap.c

Log Message:
powerpc/oea: pmap: Fix mostly-pointless overhead of pmap_pvo_pool

(1) Drop __aligned(32) from struct pvo_entry; otherwise,
sizeof(struct pvo_entry) is round-up'ed to a multiple of 32.

(2) Do not set sizeof(struct pvo_entry) to `align` argument for
pool_init(9); it must be power of 2.

(3) Align pvo_entry to 32-byte boundary only if reasonably possible,
i.e., OEA without DIAGNOSTIC (--> POOL_REDZONE) for now.

Part of PR kern/57621


To generate a diff of this commit:
cvs rdiff -u -r1.118 -r1.119 src/sys/arch/powerpc/oea/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/powerpc/oea/pmap.c
diff -u src/sys/arch/powerpc/oea/pmap.c:1.118 src/sys/arch/powerpc/oea/pmap.c:1.119
--- src/sys/arch/powerpc/oea/pmap.c:1.118	Fri Dec 15 09:33:29 2023
+++ src/sys/arch/powerpc/oea/pmap.c	Fri Dec 15 09:35:29 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.118 2023/12/15 09:33:29 rin Exp $	*/
+/*	$NetBSD: pmap.c,v 1.119 2023/12/15 09:35:29 rin Exp $	*/
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -63,7 +63,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.118 2023/12/15 09:33:29 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.119 2023/12/15 09:35:29 rin Exp $");
 
 #define	PMAP_NOOPNAMES
 
@@ -292,7 +292,7 @@ const struct pmap_ops PMAPNAME(ops) = {
 #endif /* !PMAPNAME */
 
 /*
- * The following structure is aligned to 32 bytes 
+ * The following structure is aligned to 32 bytes, if reasonably possible.
  */
 struct pvo_entry {
 	LIST_ENTRY(pvo_entry) pvo_vlink;	/* Link to common virt page */
@@ -317,7 +317,14 @@ struct pvo_entry {
 #define	PVO_REMOVE		6		/* PVO has been removed */
 #define	PVO_WHERE_MASK		15
 #define	PVO_WHERE_SHFT		8
-} __attribute__ ((aligned (32)));
+};
+
+#if defined(PMAP_OEA) && !defined(DIAGNOSTIC)
+#define	PMAP_PVO_ENTRY_ALIGN	32
+#else
+#define	PMAP_PVO_ENTRY_ALIGN	__alignof(struct pvo_entry)
+#endif
+
 #define	PVO_VADDR(pvo)		((pvo)->pvo_vaddr & ~ADDR_POFF)
 #define	PVO_PTEGIDX_GET(pvo)	((pvo)->pvo_vaddr & PVO_PTEGIDX_MASK)
 #define	PVO_PTEGIDX_ISSET(pvo)	((pvo)->pvo_vaddr & PVO_PTEGIDX_VALID)
@@ -3440,7 +3447,7 @@ pmap_bootstrap1(paddr_t kernelstart, pad
 #endif
 
 	pool_init(_pvo_pool, sizeof(struct pvo_entry),
-	sizeof(struct pvo_entry), 0, 0, "pmap_pvopl",
+	PMAP_PVO_ENTRY_ALIGN, 0, 0, "pmap_pvopl",
 	_pool_allocator, IPL_VM);
 
 	pool_setlowat(_pvo_pool, 1008);



CVS commit: src/sys/arch/powerpc/oea

2023-12-15 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Dec 15 09:35:29 UTC 2023

Modified Files:
src/sys/arch/powerpc/oea: pmap.c

Log Message:
powerpc/oea: pmap: Fix mostly-pointless overhead of pmap_pvo_pool

(1) Drop __aligned(32) from struct pvo_entry; otherwise,
sizeof(struct pvo_entry) is round-up'ed to a multiple of 32.

(2) Do not set sizeof(struct pvo_entry) to `align` argument for
pool_init(9); it must be power of 2.

(3) Align pvo_entry to 32-byte boundary only if reasonably possible,
i.e., OEA without DIAGNOSTIC (--> POOL_REDZONE) for now.

Part of PR kern/57621


To generate a diff of this commit:
cvs rdiff -u -r1.118 -r1.119 src/sys/arch/powerpc/oea/pmap.c

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



CVS commit: src/sys/arch/powerpc/oea

2023-12-15 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Dec 15 09:33:30 UTC 2023

Modified Files:
src/sys/arch/powerpc/oea: pmap.c

Log Message:
powerpc/oea: pmap: Rework pmap_pte_spill()

It was broken in many ways... Now, it gets working stable both for
OEA and OEA64_BRIDGE, as far as I can see.

Part of PR kern/57621


To generate a diff of this commit:
cvs rdiff -u -r1.117 -r1.118 src/sys/arch/powerpc/oea/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/powerpc/oea/pmap.c
diff -u src/sys/arch/powerpc/oea/pmap.c:1.117 src/sys/arch/powerpc/oea/pmap.c:1.118
--- src/sys/arch/powerpc/oea/pmap.c:1.117	Fri Dec 15 09:32:05 2023
+++ src/sys/arch/powerpc/oea/pmap.c	Fri Dec 15 09:33:29 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.117 2023/12/15 09:32:05 rin Exp $	*/
+/*	$NetBSD: pmap.c,v 1.118 2023/12/15 09:33:29 rin Exp $	*/
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -63,7 +63,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.117 2023/12/15 09:32:05 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.118 2023/12/15 09:33:29 rin Exp $");
 
 #define	PMAP_NOOPNAMES
 
@@ -879,48 +879,35 @@ pmap_pte_insert(int ptegidx, struct pte 
  * Tries to spill a page table entry from the overflow area.
  * This runs in either real mode (if dealing with a exception spill)
  * or virtual mode when dealing with manually spilling one of the
- * kernel's pte entries.  In either case, interrupts are already
- * disabled.
+ * kernel's pte entries.
  */
 
 int
-pmap_pte_spill(struct pmap *pm, vaddr_t addr, bool exec)
+pmap_pte_spill(struct pmap *pm, vaddr_t addr, bool isi_p)
 {
-	struct pvo_entry *source_pvo, *victim_pvo, *next_pvo;
-	struct pvo_entry *pvo;
-	/* XXX: gcc -- vpvoh is always set at either *1* or *2* */
-	struct pvo_tqhead *pvoh, *vpvoh = NULL;
-	int ptegidx, i, j;
+	struct pvo_tqhead *spvoh, *vpvoh;
+	struct pvo_entry *pvo, *source_pvo, *victim_pvo;
 	volatile struct pteg *pteg;
 	volatile struct pte *pt;
+	register_t msr, vsid, hash;
+	int ptegidx, hid, i, j;
+	int done = 0;
 
 	PMAP_LOCK();
+	msr = pmap_interrupts_off();
+
+	/* XXXRO paranoid? */
+	if (pm->pm_evictions == 0)
+		goto out;
 
 	ptegidx = va_to_pteg(pm, addr);
 
 	/*
-	 * Have to substitute some entry. Use the primary hash for this.
-	 * Use low bits of timebase as random generator.  Make sure we are
-	 * not picking a kernel pte for replacement.
+	 * Find source pvo.
 	 */
-	pteg = _pteg_table[ptegidx];
-	i = MFTB() & 7;
-	for (j = 0; j < 8; j++) {
-		pt = >pt[i];
-		if ((pt->pte_hi & PTE_VALID) == 0)
-			break;
-		if (VSID_TO_HASH((pt->pte_hi & PTE_VSID) >> PTE_VSID_SHFT)
-< PHYSMAP_VSIDBITS)
-			break;
-		i = (i + 1) & 7;
-	}
-	KASSERT(j < 8);
-
+	spvoh = _pvo_table[ptegidx];
 	source_pvo = NULL;
-	victim_pvo = NULL;
-	pvoh = _pvo_table[ptegidx];
-	TAILQ_FOREACH(pvo, pvoh, pvo_olink) {
-
+	TAILQ_FOREACH(pvo, spvoh, pvo_olink) {
 		/*
 		 * We need to find pvo entry for this address...
 		 */
@@ -931,101 +918,105 @@ pmap_pte_spill(struct pmap *pm, vaddr_t 
 		 * a valid PTE, then we know we can't find it because all
 		 * evicted PVOs always are first in the list.
 		 */
-		if (source_pvo == NULL && (pvo->pvo_pte.pte_hi & PTE_VALID))
+		if ((pvo->pvo_pte.pte_hi & PTE_VALID) != 0)
 			break;
-		if (source_pvo == NULL && pm == pvo->pvo_pmap &&
-		addr == PVO_VADDR(pvo)) {
 
-			/*
-			 * Now we have found the entry to be spilled into the
-			 * pteg.  Attempt to insert it into the page table.
-			 */
-			j = pmap_pte_insert(ptegidx, >pvo_pte);
-			if (j >= 0) {
-PVO_PTEGIDX_SET(pvo, j);
-PMAP_PVO_CHECK(pvo);	/* sanity check */
-PVO_WHERE(pvo, SPILL_INSERT);
-pvo->pvo_pmap->pm_evictions--;
-PMAPCOUNT(ptes_spilled);
-PMAPCOUNT2(((pvo->pvo_pte.pte_hi & PTE_HID)
-? pmap_evcnt_ptes_secondary
-: pmap_evcnt_ptes_primary)[j]);
-
-/*
- * Since we keep the evicted entries at the
- * from of the PVO list, we need move this
- * (now resident) PVO after the evicted
- * entries.
- */
-next_pvo = TAILQ_NEXT(pvo, pvo_olink);
-
-/*
- * If we don't have to move (either we were the
- * last entry or the next entry was valid),
- * don't change our position.  Otherwise 
- * move ourselves to the tail of the queue.
- */
-if (next_pvo != NULL &&
-!(next_pvo->pvo_pte.pte_hi & PTE_VALID)) {
-	TAILQ_REMOVE(pvoh, pvo, pvo_olink);
-	TAILQ_INSERT_TAIL(pvoh, pvo, pvo_olink);
-}
-PMAP_UNLOCK();
-return 1;
+		if (pm == pvo->pvo_pmap && addr == PVO_VADDR(pvo)) {
+			if (isi_p) {
+if (!PVO_EXECUTABLE_P(pvo))
+	goto out;
+#if defined(PMAP_OEA) || defined(PMAP_OEA64_BRIDGE)
+int sr __diagused =
+PVO_VADDR(pvo) >> ADDR_SR_SHFT;
+KASSERT((pm->pm_sr[sr] & SR_NOEXEC) == 0);
+#endif
 			}
+			KASSERT(!PVO_PTEGIDX_ISSET(pvo));
+			/* XXXRO where check */
 			source_pvo = 

CVS commit: src/sys/arch/powerpc/oea

2023-12-15 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Dec 15 09:33:30 UTC 2023

Modified Files:
src/sys/arch/powerpc/oea: pmap.c

Log Message:
powerpc/oea: pmap: Rework pmap_pte_spill()

It was broken in many ways... Now, it gets working stable both for
OEA and OEA64_BRIDGE, as far as I can see.

Part of PR kern/57621


To generate a diff of this commit:
cvs rdiff -u -r1.117 -r1.118 src/sys/arch/powerpc/oea/pmap.c

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



CVS commit: src/sys/arch/powerpc/oea

2023-12-15 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Dec 15 09:32:05 UTC 2023

Modified Files:
src/sys/arch/powerpc/oea: pmap.c

Log Message:
powerpc/oea: pmap: Drop unused argument for pmap_pvo_reclaim(), NFC

Part of PR kern/57621


To generate a diff of this commit:
cvs rdiff -u -r1.116 -r1.117 src/sys/arch/powerpc/oea/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/powerpc/oea/pmap.c
diff -u src/sys/arch/powerpc/oea/pmap.c:1.116 src/sys/arch/powerpc/oea/pmap.c:1.117
--- src/sys/arch/powerpc/oea/pmap.c:1.116	Fri Dec  8 21:46:02 2023
+++ src/sys/arch/powerpc/oea/pmap.c	Fri Dec 15 09:32:05 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.116 2023/12/08 21:46:02 andvar Exp $	*/
+/*	$NetBSD: pmap.c,v 1.117 2023/12/15 09:32:05 rin Exp $	*/
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -63,7 +63,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.116 2023/12/08 21:46:02 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.117 2023/12/15 09:32:05 rin Exp $");
 
 #define	PMAP_NOOPNAMES
 
@@ -388,7 +388,7 @@ static void pmap_pvo_free(struct pvo_ent
 static void pmap_pvo_free_list(struct pvo_head *);
 static struct pvo_entry *pmap_pvo_find_va(pmap_t, vaddr_t, int *); 
 static volatile struct pte *pmap_pvo_to_pte(const struct pvo_entry *, int);
-static struct pvo_entry *pmap_pvo_reclaim(struct pmap *);
+static struct pvo_entry *pmap_pvo_reclaim(void);
 static void pvo_set_exec(struct pvo_entry *);
 static void pvo_clear_exec(struct pvo_entry *);
 
@@ -1507,7 +1507,7 @@ pmap_pvo_check(const struct pvo_entry *p
  */
 
 struct pvo_entry *
-pmap_pvo_reclaim(struct pmap *pm)
+pmap_pvo_reclaim(void)
 {
 	struct pvo_tqhead *pvoh;
 	struct pvo_entry *pvo;
@@ -1615,7 +1615,7 @@ pmap_pvo_enter(pmap_t pm, struct pool *p
 	++pmap_pvo_enter_depth;
 #endif
 	if (pvo == NULL) {
-		pvo = pmap_pvo_reclaim(pm);
+		pvo = pmap_pvo_reclaim();
 		if (pvo == NULL) {
 			if ((flags & PMAP_CANFAIL) == 0)
 panic("pmap_pvo_enter: failed");



CVS commit: src/sys/arch/powerpc/oea

2023-12-15 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Dec 15 09:32:05 UTC 2023

Modified Files:
src/sys/arch/powerpc/oea: pmap.c

Log Message:
powerpc/oea: pmap: Drop unused argument for pmap_pvo_reclaim(), NFC

Part of PR kern/57621


To generate a diff of this commit:
cvs rdiff -u -r1.116 -r1.117 src/sys/arch/powerpc/oea/pmap.c

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



CVS commit: src/sys/arch/powerpc/powerpc

2023-12-15 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Dec 15 09:31:03 UTC 2023

Modified Files:
src/sys/arch/powerpc/powerpc: trap.c

Log Message:
powerpc/oea: trap: pmap_{pte,ste}_spill() even in the interrupt context

Page table for oea is something like L2 TLB on memory; kernel and
processes share its entries, and process entries can be spilled out.

As done for MMU based on software-managed TLB, we need to restore
such entries even in the interrupt context.

Note that pmap_pte_spill() require no resouce to restore entries.
Still-not-implemented pmap_ste_spill() for OEA64 should also.

Part of PR kern/57621


To generate a diff of this commit:
cvs rdiff -u -r1.164 -r1.165 src/sys/arch/powerpc/powerpc/trap.c

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

Modified files:

Index: src/sys/arch/powerpc/powerpc/trap.c
diff -u src/sys/arch/powerpc/powerpc/trap.c:1.164 src/sys/arch/powerpc/powerpc/trap.c:1.165
--- src/sys/arch/powerpc/powerpc/trap.c:1.164	Thu Oct  5 19:41:05 2023
+++ src/sys/arch/powerpc/powerpc/trap.c	Fri Dec 15 09:31:02 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.164 2023/10/05 19:41:05 ad Exp $	*/
+/*	$NetBSD: trap.c,v 1.165 2023/12/15 09:31:02 rin Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -35,7 +35,7 @@
 #define	__UCAS_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.164 2023/10/05 19:41:05 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.165 2023/12/15 09:31:02 rin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_altivec.h"
@@ -136,42 +136,40 @@ trap(struct trapframe *tf)
 
 		ci->ci_ev_kdsi.ev_count++;
 
-		/*
-		 * Only query UVM if no interrupts are active.
-		 */
-		if (ci->ci_idepth < 0) {
-			if ((va >> ADDR_SR_SHFT) == pcb->pcb_kmapsr) {
-va &= ADDR_PIDX | ADDR_POFF;
-va |= pcb->pcb_umapsr << ADDR_SR_SHFT;
-map = >p_vmspace->vm_map;
-#ifdef PPC_OEA64
-if ((tf->tf_dsisr & DSISR_NOTFOUND) &&
-vm_map_pmap(map)->pm_ste_evictions > 0 &&
-pmap_ste_spill(vm_map_pmap(map),
-	trunc_page(va), false)) {
-	return;
-}
+		if ((va >> ADDR_SR_SHFT) == pcb->pcb_kmapsr) {
+			va &= ADDR_PIDX | ADDR_POFF;
+			va |= pcb->pcb_umapsr << ADDR_SR_SHFT;
+			map = >p_vmspace->vm_map;
+		}
+#if defined(DIAGNOSTIC) && !defined(PPC_OEA64)
+		else if (__predict_false((va >> ADDR_SR_SHFT) == USER_SR)) {
+			printf("trap: kernel %s DSI trap @ %#lx by %#lx"
+			" (DSISR %#x): USER_SR unset\n",
+			(tf->tf_dsisr & DSISR_STORE)
+? "write" : "read",
+			va, tf->tf_srr0, tf->tf_dsisr);
+			goto brain_damage2;
+		}
 #endif
+		else {
+			map = kernel_map;
+		}
 
-if ((tf->tf_dsisr & DSISR_NOTFOUND) &&
-vm_map_pmap(map)->pm_evictions > 0 &&
-pmap_pte_spill(vm_map_pmap(map),
-	trunc_page(va), false)) {
-	return;
-}
-#if defined(DIAGNOSTIC) && !defined(PPC_OEA64)
-			} else if ((va >> ADDR_SR_SHFT) == USER_SR) {
-printf("trap: kernel %s DSI trap @ %#lx by %#lx"
-" (DSISR %#x): USER_SR unset\n",
-(tf->tf_dsisr & DSISR_STORE)
-	? "write" : "read",
-va, tf->tf_srr0, tf->tf_dsisr);
-goto brain_damage2;
+#ifdef PPC_OEA64
+		if ((tf->tf_dsisr & DSISR_NOTFOUND) &&
+		vm_map_pmap(map)->pm_ste_evictions > 0 &&
+		pmap_ste_spill(vm_map_pmap(map), trunc_page(va), false))
+			return;
 #endif
-			} else {
-map = kernel_map;
-			}
+		if ((tf->tf_dsisr & DSISR_NOTFOUND) &&
+		vm_map_pmap(map)->pm_evictions > 0 &&
+		pmap_pte_spill(vm_map_pmap(map), trunc_page(va), false))
+			return;
 
+		/*
+		 * Only query UVM if no interrupts are active.
+		 */
+		if (ci->ci_idepth < 0) {
 			if (tf->tf_dsisr & DSISR_STORE)
 ftype = VM_PROT_WRITE;
 			else



CVS commit: src/sys/arch/powerpc/powerpc

2023-12-15 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Dec 15 09:31:03 UTC 2023

Modified Files:
src/sys/arch/powerpc/powerpc: trap.c

Log Message:
powerpc/oea: trap: pmap_{pte,ste}_spill() even in the interrupt context

Page table for oea is something like L2 TLB on memory; kernel and
processes share its entries, and process entries can be spilled out.

As done for MMU based on software-managed TLB, we need to restore
such entries even in the interrupt context.

Note that pmap_pte_spill() require no resouce to restore entries.
Still-not-implemented pmap_ste_spill() for OEA64 should also.

Part of PR kern/57621


To generate a diff of this commit:
cvs rdiff -u -r1.164 -r1.165 src/sys/arch/powerpc/powerpc/trap.c

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