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

powerpc/mm: Convert pte_user() to static inline

In a subsequent patch we want to add a second definition of pte_user().
Before we do that, make the signature clear, ie. it takes a pte_t and
returns bool.

We move it up inside the existing #ifndef __ASSEMBLY__ block, but
otherwise it's a straight conversion.

Convert the call in settlbcam(), which passes an unsigned long, to pass
a pte_t.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

+11 -8
+10 -7
arch/powerpc/include/asm/pte-common.h
··· 76 76 */ 77 77 #ifndef __ASSEMBLY__ 78 78 extern unsigned long bad_call_to_PMD_PAGE_SIZE(void); 79 + 80 + /* 81 + * Don't just check for any non zero bits in __PAGE_USER, since for book3e 82 + * and PTE_64BIT, PAGE_KERNEL_X contains _PAGE_BAP_SR which is also in 83 + * _PAGE_USER. Need to explicitly match _PAGE_BAP_UR bit in that case too. 84 + */ 85 + static inline bool pte_user(pte_t pte) 86 + { 87 + return (pte_val(pte) & _PAGE_USER) == _PAGE_USER; 88 + } 79 89 #endif /* __ASSEMBLY__ */ 80 90 81 91 /* Location of the PFN in the PTE. Most 32-bit platforms use the same ··· 193 183 194 184 /* Make modules code happy. We don't set RO yet */ 195 185 #define PAGE_KERNEL_EXEC PAGE_KERNEL_X 196 - 197 - /* 198 - * Don't just check for any non zero bits in __PAGE_USER, since for book3e 199 - * and PTE_64BIT, PAGE_KERNEL_X contains _PAGE_BAP_SR which is also in 200 - * _PAGE_USER. Need to explicitly match _PAGE_BAP_UR bit in that case too. 201 - */ 202 - #define pte_user(val) ((val & _PAGE_USER) == _PAGE_USER) 203 186 204 187 /* Advertise special mapping type for AGP */ 205 188 #define PAGE_AGP (PAGE_KERNEL_NC)
+1 -1
arch/powerpc/mm/fsl_booke_mmu.c
··· 135 135 TLBCAM[index].MAS7 = (u64)phys >> 32; 136 136 137 137 /* Below is unlikely -- only for large user pages or similar */ 138 - if (pte_user(flags)) { 138 + if (pte_user(__pte(flags))) { 139 139 TLBCAM[index].MAS3 |= MAS3_UX | MAS3_UR; 140 140 TLBCAM[index].MAS3 |= ((flags & _PAGE_RW) ? MAS3_UW : 0); 141 141 }