Skip to content

Commit 27f36bd

Browse files
dcpleungcfriedt
authored andcommitted
boards: qemu_x86_tiny: enabled for general demand paging testing
This enables qemu_x86_tiny to be used for more general demand paging testing where non-pinned code and data is not available in physical memory at boot. This adds a custom linker script to qemu_x86_tiny for pinning code and data. In the process, a new kconfig CONFIG_BOARD_QEMU_X86_TINY has to be introduced to distinguish from other qemu_x86* boards. This linker script is based on the generic x86-32 one in include/arch/x86/ia32/linker.ld, with additions to put symbols into boot and pinned sections. Signed-off-by: Daniel Leung <[email protected]>
1 parent c3abd7a commit 27f36bd

File tree

7 files changed

+846
-5
lines changed

7 files changed

+846
-5
lines changed

boards/x86/qemu_x86/Kconfig.board

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,9 @@ config BOARD_QEMU_X86_LAKEMONT
2020
select QEMU_TARGET
2121
select CPU_HAS_FPU
2222
select HAS_COVERAGE_SUPPORT
23+
24+
config BOARD_QEMU_X86_TINY
25+
bool "QEMU x86 (tiny memory)"
26+
depends on SOC_IA32
27+
select QEMU_TARGET
28+
select CPU_HAS_FPU

boards/x86/qemu_x86/Kconfig.defconfig

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,38 @@ config X86_PC_COMPATIBLE
5656
default y
5757

5858
endif # BOARD_QEMU_X86_LAKEMONT
59+
60+
if BOARD_QEMU_X86_TINY
61+
62+
config BUILD_OUTPUT_BIN
63+
default n
64+
65+
config BOARD
66+
default "qemu_x86_tiny"
67+
68+
config KERNEL_VM_SIZE
69+
default 0x400000
70+
71+
config MULTIBOOT
72+
# This is needed for QEMU to load the ELF image
73+
default y
74+
75+
config X86_PC_COMPATIBLE
76+
# QEMU presents a PC-compatible machine
77+
default y
78+
79+
config HAVE_CUSTOM_LINKER_SCRIPT
80+
default y
81+
82+
config CUSTOM_LINKER_SCRIPT
83+
default "${ZEPHYR_BASE}/boards/x86/qemu_x86/qemu_x86_tiny.ld"
84+
85+
config X86_EXTRA_PAGE_TABLE_PAGES
86+
# This is needed for gen_mmu.py to map the flash into memory
87+
default 2 if DEMAND_PAGING && !LINKER_GENERIC_SECTIONS_PRESENT_AT_BOOT
88+
89+
config DEMAND_PAGING_PAGE_FRAMES_RESERVE
90+
# Need to accommodate the heap for newlib in libc-hook.c
91+
default 6 if NEWLIB_LIBC
92+
93+
endif # BOARD_QEMU_X86_TINY

boards/x86/qemu_x86/board.cmake

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ endif()
2222
if(CONFIG_XIP)
2323
# Extra 4MB to emulate flash area
2424
math(EXPR QEMU_MEMORY_SIZE_MB "${CONFIG_SRAM_SIZE} / 1024 + 4")
25+
elseif(CONFIG_BOARD_QEMU_X86_TINY AND CONFIG_DEMAND_PAGING
26+
AND NOT CONFIG_LINKER_GENERIC_SECTIONS_PRESENT_AT_BOOT)
27+
# Flash is at 4MB-8MB, so need this to be large enough
28+
math(EXPR QEMU_MEMORY_SIZE_MB "8")
2529
else()
2630
math(EXPR QEMU_MEMORY_SIZE_MB "${CONFIG_SRAM_SIZE} / 1024")
2731
endif()
@@ -69,3 +73,11 @@ endif()
6973
# board_set_debugger_ifnset(qemu)
7074
# debugserver: QEMU_EXTRA_FLAGS += -s -S
7175
# debugserver: qemu
76+
77+
if(CONFIG_BOARD_QEMU_X86_TINY AND CONFIG_DEMAND_PAGING
78+
AND NOT CONFIG_LINKER_GENERIC_SECTIONS_PRESENT_AT_BOOT)
79+
# This is to map the flash so it is accessible.
80+
math(EXPR QEMU_FLASH_SIZE_KB "${CONFIG_FLASH_SIZE} * 1024")
81+
set(X86_EXTRA_GEN_MMU_ARGUMENTS
82+
--map ${CONFIG_FLASH_BASE_ADDRESS},${QEMU_FLASH_SIZE_KB},W)
83+
endif()

0 commit comments

Comments
 (0)