diff --git a/arch/Kconfig b/arch/Kconfig index dc3845b21a2..34b45f4951a 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -62,7 +62,6 @@ config X86 select ARCH_HAS_TIMING_FUNCTIONS select ARCH_HAS_THREAD_LOCAL_STORAGE select ARCH_HAS_DEMAND_PAGING - select ARCH_MAPS_ALL_RAM help x86 architecture diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index c58d05f016b..068361e58de 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -95,6 +95,7 @@ endchoice config ACPI bool "ACPI (Advanced Configuration and Power Interface) support" + select ARCH_MAPS_ALL_RAM help Allow retrieval of platform configuration at runtime. diff --git a/arch/x86/gen_mmu.py b/arch/x86/gen_mmu.py index 1d7a4c65047..22e7e738be8 100755 --- a/arch/x86/gen_mmu.py +++ b/arch/x86/gen_mmu.py @@ -457,10 +457,15 @@ def main(): debug("building %s" % pclass.__name__) vm_base = syms["CONFIG_KERNEL_VM_BASE"] - vm_size = syms["CONFIG_KERNEL_VM_SIZE"] + # Work around #31562 + vm_size = syms["CONFIG_KERNEL_VM_SIZE"] & 0xFFFFFFFF - image_base = syms["z_mapped_start"] - image_size = syms["z_mapped_size"] + if isdef("CONFIG_ARCH_MAPS_ALL_RAM"): + image_base = syms["CONFIG_SRAM_BASE_ADDRESS"] + image_size = syms["CONFIG_SRAM_SIZE"] * 1024 + else: + image_base = syms["z_mapped_start"] + image_size = syms["z_mapped_size"] ptables_phys = syms["z_x86_pagetables_start"] debug("Address space: 0x%x - 0x%x size %x" % @@ -471,6 +476,9 @@ def main(): is_perm_regions = isdef("CONFIG_SRAM_REGION_PERMISSIONS") + if image_size >= vm_size: + error("VM size is too small (have 0x%x need more than 0x%x)" % (vm_size, image_size)) + if is_perm_regions: # Don't allow execution by default for any pages. We'll adjust this # in later calls to pt.set_region_perms() diff --git a/tests/arch/x86/pagetables/src/main.c b/tests/arch/x86/pagetables/src/main.c index 7305be4e7a1..a2ae3323b75 100644 --- a/tests/arch/x86/pagetables/src/main.c +++ b/tests/arch/x86/pagetables/src/main.c @@ -159,6 +159,22 @@ void test_ram_perms(void) PRI_ENTRY, flags, pos, expected); } #endif /* CONFIG_X86_64 */ + +#ifdef CONFIG_ARCH_MAPS_ALL_RAM + /* All RAM page frame entries aside from 0x0 must have a mapping. + * We currently identity-map on x86, no conversion necessary other than a cast + */ + for (pos = (uint8_t *)Z_PHYS_RAM_START; pos < (uint8_t *)Z_PHYS_RAM_END; + pos += CONFIG_MMU_PAGE_SIZE) { + if (pos == NULL) { + continue; + } + + entry = get_entry(&flags, pos); + zassert_true((flags & MMU_P) != 0, + "address %p isn't mapped", pos); + } +#endif } /**