diff --git a/sys/arch/aarch64/conf/files.aarch64 b/sys/arch/aarch64/conf/files.aarch64 index 720f249c7d05..c3b6455461b2 100644 --- a/sys/arch/aarch64/conf/files.aarch64 +++ b/sys/arch/aarch64/conf/files.aarch64 @@ -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 diff --git a/sys/arch/arm/conf/files.arm b/sys/arch/arm/conf/files.arm index d65d60dc3d42..13c5769abf93 100644 --- a/sys/arch/arm/conf/files.arm +++ b/sys/arch/arm/conf/files.arm @@ -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 diff --git a/sys/arch/x86/conf/files.x86 b/sys/arch/x86/conf/files.x86 index 31c1bf9607b8..1dfe30d34f52 100644 --- a/sys/arch/x86/conf/files.x86 +++ b/sys/arch/x86/conf/files.x86 @@ -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 diff --git a/sys/conf/files b/sys/conf/files index 2e811840b95d..90b975a1460e 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -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 diff --git a/sys/uvm/pmap/pmap.c b/sys/uvm/pmap/pmap.c index 569c6b57c664..abeb14effcc2 100644 --- a/sys/uvm/pmap/pmap.c +++ b/sys/uvm/pmap/pmap.c @@ -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 -__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.71 2022/10/27 06:20:41 skrll Exp $"); */ #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, "kernel mapping changed"); 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, paddr_t pa, vm_prot_t prot, u_int flags) { 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, paddr_t pa, vm_prot_t prot, u_int flags) 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, paddr_t pa, vm_prot_t prot, u_int flags) 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();