memblock tests: zero-extend simulated memory addresses

Converting a 32-bit pointer directly to the 64-bit phys_addr_t can
sign-extend it when BUILD=32 is used. A dummy allocation above 2 GiB
then gets registered at an address different from its unsigned pointer
value. The low-address tests compare that value against the registered
range and fail once the earlier maximum-address free test is fixed.

Convert through uintptr_t when registering and reporting dummy memory.
This preserves the pointer bits and agrees with the simulator __pa()
conversion and the allocation tests.

Assisted-by: LLM
Signed-off-by: Tianyi Chen <hi@tychen.cc>
Link: https://patch.msgid.link/20260923023126.1910311-3-hi@tychen.cc
Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
This commit is contained in:
Tianyi Chen 2026-09-23 11:31:24 +09:00 committed by Mike Rapoport (Microsoft)
parent 9357596afa
commit 6957416ae4

View File

@ -67,7 +67,7 @@ static inline void fill_memblock(void)
void setup_memblock(void)
{
reset_memblock_regions();
memblock_add((phys_addr_t)memory_block.base, MEM_SIZE);
memblock_add((phys_addr_t)(uintptr_t)memory_block.base, MEM_SIZE);
fill_memblock();
}
@ -88,7 +88,7 @@ void setup_numa_memblock(const unsigned int node_fracs[])
int flags;
reset_memblock_regions();
base = (phys_addr_t)memory_block.base;
base = (phys_addr_t)(uintptr_t)memory_block.base;
flags = (movable_node_is_enabled()) ? MEMBLOCK_NONE : MEMBLOCK_HOTPLUG;
for (int i = 0; i < NUMA_NODES; i++) {
@ -115,7 +115,7 @@ void dummy_physical_memory_cleanup(void)
phys_addr_t dummy_physical_memory_base(void)
{
return (phys_addr_t)memory_block.base;
return (phys_addr_t)(uintptr_t)memory_block.base;
}
phys_addr_t dummy_physical_memory_low_limit(void)