Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ARM: 7077/1: LPAE: Use a mask for physical addresses in page table entries

With LPAE, the physical address mask is 40-bit while the page table
entry is 64-bit. This patch introduces PHYS_MASK for the 2-level page
table format, defined as ~0UL.

Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

authored by

Catalin Marinas and committed by
Russell King
d7c5d0dc 442e70c0

+5 -3
+2
arch/arm/include/asm/pgtable-2level-hwdef.h
··· 88 88 #define PTE_SMALL_AP_URO_SRW (_AT(pteval_t, 0xaa) << 4) 89 89 #define PTE_SMALL_AP_URW_SRW (_AT(pteval_t, 0xff) << 4) 90 90 91 + #define PHYS_MASK (~0UL) 92 + 91 93 #endif
+3 -3
arch/arm/include/asm/pgtable.h
··· 196 196 197 197 static inline pte_t *pmd_page_vaddr(pmd_t pmd) 198 198 { 199 - return __va(pmd_val(pmd) & PAGE_MASK); 199 + return __va(pmd_val(pmd) & PHYS_MASK & (s32)PAGE_MASK); 200 200 } 201 201 202 - #define pmd_page(pmd) pfn_to_page(__phys_to_pfn(pmd_val(pmd))) 202 + #define pmd_page(pmd) pfn_to_page(__phys_to_pfn(pmd_val(pmd) & PHYS_MASK)) 203 203 204 204 /* we don't need complex calculations here as the pmd is folded into the pgd */ 205 205 #define pmd_addr_end(addr,end) (end) ··· 220 220 #define pte_offset_map(pmd,addr) (__pte_map(pmd) + pte_index(addr)) 221 221 #define pte_unmap(pte) __pte_unmap(pte) 222 222 223 - #define pte_pfn(pte) (pte_val(pte) >> PAGE_SHIFT) 223 + #define pte_pfn(pte) ((pte_val(pte) & PHYS_MASK) >> PAGE_SHIFT) 224 224 #define pfn_pte(pfn,prot) __pte(__pfn_to_phys(pfn) | pgprot_val(prot)) 225 225 226 226 #define pte_page(pte) pfn_to_page(pte_pfn(pte))