tools: use __pa() in virt_to_phys()

With 32-bit pointers and a 64-bit phys_addr_t, GCC warns about the
pointer-to-integer cast in virt_to_phys(). It can also sign-extend
pointers whose top bit is set, turning 0x80000000 into 0xffffffff80000000.

Use __pa() to convert through unsigned long before widening the result.
This preserves the unsigned pointer value and matches the other address
conversion helpers.

Reported-by: Mike Rapoport <rppt@kernel.org>
Link: https://lore.kernel.org/r/179007180279.508753.4595268983388589280.b4-review@b4
Assisted-by: LLM
Signed-off-by: Tianyi Chen <hi@tychen.cc>
Link: https://patch.msgid.link/20260923023126.1910311-4-hi@tychen.cc
Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
This commit is contained in:
Tianyi Chen 2026-09-23 11:31:25 +09:00 committed by Mike Rapoport (Microsoft)
parent 6957416ae4
commit a10f3a08d2

View File

@ -30,7 +30,7 @@ static inline void *phys_to_virt(unsigned long address)
#define virt_to_phys virt_to_phys
static inline phys_addr_t virt_to_phys(volatile void *address)
{
return (phys_addr_t)address;
return __pa(address);
}
static inline void totalram_pages_inc(void)