Skip to content

Commit 2d7872f

Browse files
Anshuman Khandualctmarinas
authored andcommitted
arm64/mm: Convert __pte_to_phys() and __phys_to_pte_val() as functions
When CONFIG_ARM64_PA_BITS_52 is enabled, page table helpers __pte_to_phys() and __phys_to_pte_val() are functions which return phys_addr_t and pteval_t respectively as expected. But otherwise without this config being enabled, they are defined as macros and their return types are implicit. Until now this has worked out correctly as both pte_t and phys_addr_t data types have been 64 bits. But with the introduction of 128 bit page tables, pte_t becomes 128 bits. Hence this ends up with incorrect widths after the conversions, which leads to compiler warnings. Fix these warnings by converting __pte_to_phys() and __phys_to_pte_val() as functions instead where the return types are handled explicitly. Cc: Will Deacon <will@kernel.org> Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com> Reviewed-by: Ryan Roberts <ryan.roberts@arm.com> Link: https://lore.kernel.org/r/20250227022412.2015835-1-anshuman.khandual@arm.com Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
1 parent 0ad2507 commit 2d7872f

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

arch/arm64/include/asm/pgtable.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,6 @@ extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
6868
#define pte_ERROR(e) \
6969
pr_err("%s:%d: bad pte %016llx.\n", __FILE__, __LINE__, pte_val(e))
7070

71-
/*
72-
* Macros to convert between a physical address and its placement in a
73-
* page table entry, taking care of 52-bit addresses.
74-
*/
7571
#ifdef CONFIG_ARM64_PA_BITS_52
7672
static inline phys_addr_t __pte_to_phys(pte_t pte)
7773
{
@@ -84,8 +80,15 @@ static inline pteval_t __phys_to_pte_val(phys_addr_t phys)
8480
return (phys | (phys >> PTE_ADDR_HIGH_SHIFT)) & PHYS_TO_PTE_ADDR_MASK;
8581
}
8682
#else
87-
#define __pte_to_phys(pte) (pte_val(pte) & PTE_ADDR_LOW)
88-
#define __phys_to_pte_val(phys) (phys)
83+
static inline phys_addr_t __pte_to_phys(pte_t pte)
84+
{
85+
return pte_val(pte) & PTE_ADDR_LOW;
86+
}
87+
88+
static inline pteval_t __phys_to_pte_val(phys_addr_t phys)
89+
{
90+
return phys;
91+
}
8992
#endif
9093

9194
#define pte_pfn(pte) (__pte_to_phys(pte) >> PAGE_SHIFT)

0 commit comments

Comments
 (0)