From a10f3a08d248fcb3006f587faf42437837fd12c6 Mon Sep 17 00:00:00 2001 From: Tianyi Chen Date: Wed, 23 Sep 2026 11:31:25 +0900 Subject: [PATCH] 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 Link: https://lore.kernel.org/r/179007180279.508753.4595268983388589280.b4-review@b4 Assisted-by: LLM Signed-off-by: Tianyi Chen Link: https://patch.msgid.link/20260923023126.1910311-4-hi@tychen.cc Signed-off-by: Mike Rapoport (Microsoft) --- tools/include/linux/mm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/include/linux/mm.h b/tools/include/linux/mm.h index 84b5954f66c3..480526de8d65 100644 --- a/tools/include/linux/mm.h +++ b/tools/include/linux/mm.h @@ -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)