Module Name:    src
Committed By:   skrll
Date:           Fri Oct 28 07:16:34 UTC 2022

Modified Files:
        src/sys/arch/aarch64/conf: files.aarch64
        src/sys/arch/arm/conf: files.arm
        src/sys/arch/x86/conf: files.x86
        src/sys/conf: files
        src/sys/uvm/pmap: pmap.c

Log Message:
MI PMAP EFI_RUNTIME support


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/sys/arch/aarch64/conf/files.aarch64
cvs rdiff -u -r1.166 -r1.167 src/sys/arch/arm/conf/files.arm
cvs rdiff -u -r1.124 -r1.125 src/sys/arch/x86/conf/files.x86
cvs rdiff -u -r1.1301 -r1.1302 src/sys/conf/files
cvs rdiff -u -r1.71 -r1.72 src/sys/uvm/pmap/pmap.c

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

Modified files:

Index: src/sys/arch/aarch64/conf/files.aarch64
diff -u src/sys/arch/aarch64/conf/files.aarch64:1.39 src/sys/arch/aarch64/conf/files.aarch64:1.40
--- src/sys/arch/aarch64/conf/files.aarch64:1.39	Sat Oct 15 11:07:38 2022
+++ src/sys/arch/aarch64/conf/files.aarch64	Fri Oct 28 07:16:34 2022
@@ -1,4 +1,4 @@
-#	$NetBSD: files.aarch64,v 1.39 2022/10/15 11:07:38 jmcneill Exp $
+#	$NetBSD: files.aarch64,v 1.40 2022/10/28 07:16:34 skrll Exp $
 
 defflag opt_cpuoptions.h	AARCH64_ALIGNMENT_CHECK
 defflag opt_cpuoptions.h	AARCH64_EL0_STACK_ALIGNMENT_CHECK
@@ -47,7 +47,6 @@ file	arch/arm/arm/psci.c			psci
 file	arch/arm/arm/psci_arm.S			psci
 
 # EFI support
-defflag	opt_efi.h		EFI_RUNTIME
 file	arch/arm/arm/efi_runtime.c		efi_runtime
 
 # PMAP options

Index: src/sys/arch/arm/conf/files.arm
diff -u src/sys/arch/arm/conf/files.arm:1.166 src/sys/arch/arm/conf/files.arm:1.167
--- src/sys/arch/arm/conf/files.arm:1.166	Sat Apr  2 11:16:07 2022
+++ src/sys/arch/arm/conf/files.arm	Fri Oct 28 07:16:34 2022
@@ -1,4 +1,4 @@
-#	$NetBSD: files.arm,v 1.166 2022/04/02 11:16:07 skrll Exp $
+#	$NetBSD: files.arm,v 1.167 2022/10/28 07:16:34 skrll Exp $
 
 # temporary define to allow easy moving to ../arch/arm/arm32
 defflag				ARM32
@@ -109,7 +109,6 @@ file	arch/arm/arm/psci.c			psci
 file	arch/arm/arm/psci_arm.S			psci
 
 # EFI support
-defflag	opt_efi.h		EFI_RUNTIME
 file	arch/arm/arm/efi_runtime.c		efi_runtime
 
 # New PMAP options

Index: src/sys/arch/x86/conf/files.x86
diff -u src/sys/arch/x86/conf/files.x86:1.124 src/sys/arch/x86/conf/files.x86:1.125
--- src/sys/arch/x86/conf/files.x86:1.124	Sat Sep 24 11:05:18 2022
+++ src/sys/arch/x86/conf/files.x86	Fri Oct 28 07:16:34 2022
@@ -1,4 +1,4 @@
-#	$NetBSD: files.x86,v 1.124 2022/09/24 11:05:18 riastradh Exp $
+#	$NetBSD: files.x86,v 1.125 2022/10/28 07:16:34 skrll Exp $
 
 # options for MP configuration through the MP spec
 defflag opt_mpbios.h MPBIOS MPDEBUG MPBIOS_SCANPCI
@@ -21,8 +21,6 @@ defflag	opt_xen.h		DO_NOT_DEFINE
 # Option to have a static kernel memory layout
 defflag opt_kaslr.h	NO_X86_ASLR
 
-defflag opt_efi.h	EFI_RUNTIME
-
 defflag	SVS
 
 defflag	PCPU_IDT

Index: src/sys/conf/files
diff -u src/sys/conf/files:1.1301 src/sys/conf/files:1.1302
--- src/sys/conf/files:1.1301	Sun Jul 24 18:04:48 2022
+++ src/sys/conf/files	Fri Oct 28 07:16:34 2022
@@ -1,4 +1,4 @@
-#	$NetBSD: files,v 1.1301 2022/07/24 18:04:48 mrg Exp $
+#	$NetBSD: files,v 1.1302 2022/10/28 07:16:34 skrll Exp $
 #	@(#)files.newconf	7.5 (Berkeley) 5/10/93
 
 version 	20171118
@@ -144,6 +144,8 @@ defflag opt_todr.h		TODR_DEBUG
 
 defparam opt_maxlwp.h		MAXLWP
 
+defflag opt_efi.h		EFI_RUNTIME
+
 # compatibility options
 #
 defflag opt_compat_netbsd.h	COMPAT_NETBSD

Index: src/sys/uvm/pmap/pmap.c
diff -u src/sys/uvm/pmap/pmap.c:1.71 src/sys/uvm/pmap/pmap.c:1.72
--- src/sys/uvm/pmap/pmap.c:1.71	Thu Oct 27 06:20:41 2022
+++ src/sys/uvm/pmap/pmap.c	Fri Oct 28 07:16:34 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.71 2022/10/27 06:20:41 skrll Exp $	*/
+/*	$NetBSD: pmap.c,v 1.72 2022/10/28 07:16:34 skrll Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.71 2022/10/27 06:20:41 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.72 2022/10/28 07:16:34 skrll Exp $");
 
 /*
  *	Manages physical address maps.
@@ -96,6 +96,7 @@ __KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.7
  */
 
 #include "opt_ddb.h"
+#include "opt_efi.h"
 #include "opt_modular.h"
 #include "opt_multiprocessor.h"
 #include "opt_sysv.h"
@@ -157,6 +158,7 @@ PMAP_COUNTER(kernel_mappings_changed, "k
 PMAP_COUNTER(uncached_mappings, "uncached pages mapped");
 PMAP_COUNTER(unmanaged_mappings, "unmanaged pages mapped");
 PMAP_COUNTER(pvtracked_mappings, "pv-tracked unmanaged pages mapped");
+PMAP_COUNTER(efirt_mappings, "EFI RT pages mapped");
 PMAP_COUNTER(managed_mappings, "managed pages mapped");
 PMAP_COUNTER(mappings, "pages mapped");
 PMAP_COUNTER(remappings, "pages remapped");
@@ -237,6 +239,22 @@ struct pmap_kernel kernel_pmap_store = {
 
 struct pmap * const kernel_pmap_ptr = &kernel_pmap_store.kernel_pmap;
 
+#if defined(EFI_RUNTIME)
+static struct pmap efirt_pmap;
+
+pmap_t
+pmap_efirt(void)
+{
+	return &efirt_pmap;
+}
+#else
+static inline pt_entry_t
+pte_make_enter_efirt(paddr_t pa, vm_prot_t prot, u_int flags)
+{
+	panic("not supported");
+}
+#endif
+
 /* The current top of kernel VM - gets updated by pmap_growkernel */
 vaddr_t pmap_curmaxkvaddr;
 
@@ -1354,6 +1372,11 @@ pmap_enter(pmap_t pmap, vaddr_t va, padd
 {
 	const bool wired = (flags & PMAP_WIRED) != 0;
 	const bool is_kernel_pmap_p = (pmap == pmap_kernel());
+#if defined(EFI_RUNTIME)
+	const bool is_efirt_pmap_p = (pmap == pmap_efirt());
+#else
+	const bool is_efirt_pmap_p = false;
+#endif
 	u_int update_flags = (flags & VM_PROT_ALL) != 0 ? PMAP_TLB_INSERT : 0;
 #ifdef UVMHIST
 	struct kern_history * const histp =
@@ -1411,6 +1434,8 @@ pmap_enter(pmap_t pmap, vaddr_t va, padd
 
 		PMAP_COUNT(pvtracked_mappings);
 #endif
+	} else if (is_efirt_pmap_p) {
+		PMAP_COUNT(efirt_mappings);
 	} else {
 		/*
 		 * Assumption: if it is not part of our managed memory
@@ -1421,11 +1446,14 @@ pmap_enter(pmap_t pmap, vaddr_t va, padd
 		PMAP_COUNT(unmanaged_mappings);
 	}
 
-	KASSERTMSG(mdpg == NULL || mdpp == NULL, "mdpg %p mdpp %p", mdpg, mdpp);
+	KASSERTMSG(mdpg == NULL || mdpp == NULL || is_efirt_pmap_p,
+	    "mdpg %p mdpp %p efirt %s", mdpg, mdpp,
+	    is_efirt_pmap_p ? "true" : "false");
 
 	struct vm_page_md *md = (mdpg != NULL) ? mdpg : mdpp;
-	pt_entry_t npte = pte_make_enter(pa, md, prot, flags,
-	    is_kernel_pmap_p);
+	pt_entry_t npte = is_efirt_pmap_p ?
+	    pte_make_enter_efirt(pa, prot, flags) :
+	    pte_make_enter(pa, md, prot, flags, is_kernel_pmap_p);
 
 	kpreempt_disable();
 

Reply via email to