This is an automated email from the ASF dual-hosted git repository. acassis pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit a8ed107fa06e016e8d36489f7d308c9666426f27 Author: Marco Casaroli <[email protected]> AuthorDate: Sun Jul 26 17:24:57 2026 +0200 arch/x86_64: give the page allocator the physical page pool base. mm_pginitialize() documents heap_start as "the physical address of the start of memory region", and every x86_64 consumer of mm_pgalloc() agrees: create_spgtables(), x86_64_get_pgtable() and up_addrenv_create() all put the result through x86_64_pgvaddr() before touching it. x86_64_pgvaddr() in turn range-checks against CONFIG_ARCH_PGPOOL_PBASE (arch/x86_64/src/common/ pgalloc.h:67). arm64's equivalent passes CONFIG_ARCH_PGPOOL_PBASE. up_allocate_pgheap() passed CONFIG_ARCH_PGPOOL_VBASE instead, and in the other branch X86_64_PGPOOL_BASE + X86_64_LOAD_OFFSET, which is the same mistake spelled out. Every page handed out was therefore a virtual address that fell outside the pool's physical window, x86_64_pgvaddr() returned 0, and the first x86_64_pgwipe() memset NULL. It presents as a page fault in memset() under create_spgtables() the first time a process address environment is created, which is loading the init program. qemu-intel64:knsh_romfs sets PGPOOL_PBASE=0x00c000000 and PGPOOL_VBASE=0x10c000000, so the value passed was off by the 4GB load offset. Impact: runtime, CONFIG_ARCH_ADDRENV builds only (CONFIG_MM_PGALLOC). Assisted-by: Claude:claude-opus-5 Signed-off-by: Marco Casaroli <[email protected]> --- arch/x86_64/src/intel64/intel64_pgalloc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/x86_64/src/intel64/intel64_pgalloc.c b/arch/x86_64/src/intel64/intel64_pgalloc.c index 86031baa25e..98e0ead34c6 100644 --- a/arch/x86_64/src/intel64/intel64_pgalloc.c +++ b/arch/x86_64/src/intel64/intel64_pgalloc.c @@ -61,15 +61,17 @@ void up_allocate_pgheap(void **heap_start, size_t *heap_size) { DEBUGASSERT(heap_start && heap_size); + /* The page allocator uses physical addresses. */ + #ifndef CONFIG_ARCH_PGPOOL_MAPPING /* pgheap at the end of RAM */ - *heap_start = (void *)(X86_64_PGPOOL_BASE + X86_64_LOAD_OFFSET); + *heap_start = (void *)X86_64_PGPOOL_BASE; *heap_size = (size_t)X86_64_PGPOOL_SIZE; #else /* pgheap defined with Kconfig options */ - *heap_start = (void *)CONFIG_ARCH_PGPOOL_VBASE; + *heap_start = (void *)CONFIG_ARCH_PGPOOL_PBASE; *heap_size = (size_t)CONFIG_ARCH_PGPOOL_SIZE; #endif }
