Skip to content

Commit 7786103

Browse files
Andrew Boienashif
authored andcommitted
x86: map all RAM if ACPI
ACPI tables can lurk anywhere. Map all memory so they can be read. Signed-off-by: Andrew Boie <[email protected]>
1 parent c56b41f commit 7786103

File tree

4 files changed

+28
-4
lines changed

4 files changed

+28
-4
lines changed

arch/Kconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ config X86
6262
select ARCH_HAS_TIMING_FUNCTIONS
6363
select ARCH_HAS_THREAD_LOCAL_STORAGE
6464
select ARCH_HAS_DEMAND_PAGING
65-
select ARCH_MAPS_ALL_RAM
6665
help
6766
x86 architecture
6867

arch/x86/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ endchoice
9595

9696
config ACPI
9797
bool "ACPI (Advanced Configuration and Power Interface) support"
98+
select ARCH_MAPS_ALL_RAM
9899
help
99100
Allow retrieval of platform configuration at runtime.
100101

arch/x86/gen_mmu.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -457,10 +457,15 @@ def main():
457457
debug("building %s" % pclass.__name__)
458458

459459
vm_base = syms["CONFIG_KERNEL_VM_BASE"]
460-
vm_size = syms["CONFIG_KERNEL_VM_SIZE"]
460+
# Work around #31562
461+
vm_size = syms["CONFIG_KERNEL_VM_SIZE"] & 0xFFFFFFFF
461462

462-
image_base = syms["z_mapped_start"]
463-
image_size = syms["z_mapped_size"]
463+
if isdef("CONFIG_ARCH_MAPS_ALL_RAM"):
464+
image_base = syms["CONFIG_SRAM_BASE_ADDRESS"]
465+
image_size = syms["CONFIG_SRAM_SIZE"] * 1024
466+
else:
467+
image_base = syms["z_mapped_start"]
468+
image_size = syms["z_mapped_size"]
464469
ptables_phys = syms["z_x86_pagetables_start"]
465470

466471
debug("Address space: 0x%x - 0x%x size %x" %
@@ -471,6 +476,9 @@ def main():
471476

472477
is_perm_regions = isdef("CONFIG_SRAM_REGION_PERMISSIONS")
473478

479+
if image_size >= vm_size:
480+
error("VM size is too small (have 0x%x need more than 0x%x)" % (vm_size, image_size))
481+
474482
if is_perm_regions:
475483
# Don't allow execution by default for any pages. We'll adjust this
476484
# in later calls to pt.set_region_perms()

tests/arch/x86/pagetables/src/main.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,22 @@ void test_ram_perms(void)
159159
PRI_ENTRY, flags, pos, expected);
160160
}
161161
#endif /* CONFIG_X86_64 */
162+
163+
#ifdef CONFIG_ARCH_MAPS_ALL_RAM
164+
/* All RAM page frame entries aside from 0x0 must have a mapping.
165+
* We currently identity-map on x86, no conversion necessary other than a cast
166+
*/
167+
for (pos = (uint8_t *)Z_PHYS_RAM_START; pos < (uint8_t *)Z_PHYS_RAM_END;
168+
pos += CONFIG_MMU_PAGE_SIZE) {
169+
if (pos == NULL) {
170+
continue;
171+
}
172+
173+
entry = get_entry(&flags, pos);
174+
zassert_true((flags & MMU_P) != 0,
175+
"address %p isn't mapped", pos);
176+
}
177+
#endif
162178
}
163179

164180
/**

0 commit comments

Comments
 (0)