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

powerpc/mm/hash: Add helper for finding SLBE LLP encoding

Replace opencoding of the same at multiple places with the helper.
No functional change with this patch.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

authored by

Aneesh Kumar K.V and committed by
Michael Ellerman
138ee7ee 8cb8140c

+12 -6
+9
arch/powerpc/include/asm/book3s/64/mmu-hash.h
··· 191 191 BUG(); 192 192 } 193 193 194 + static inline unsigned long get_sllp_encoding(int psize) 195 + { 196 + unsigned long sllp; 197 + 198 + sllp = ((mmu_psize_defs[psize].sllp & SLB_VSID_L) >> 6) | 199 + ((mmu_psize_defs[psize].sllp & SLB_VSID_LP) >> 4); 200 + return sllp; 201 + } 202 + 194 203 #endif /* __ASSEMBLY__ */ 195 204 196 205 /*
+1 -2
arch/powerpc/include/asm/kvm_book3s_64.h
··· 181 181 182 182 switch (b_psize) { 183 183 case MMU_PAGE_4K: 184 - sllp = ((mmu_psize_defs[a_psize].sllp & SLB_VSID_L) >> 6) | 185 - ((mmu_psize_defs[a_psize].sllp & SLB_VSID_LP) >> 4); 184 + sllp = get_sllp_encoding(a_psize); 186 185 rb |= sllp << 5; /* AP field */ 187 186 rb |= (va_low & 0x7ff) << 12; /* remaining 11 bits of AVA */ 188 187 break;
+2 -4
arch/powerpc/mm/hash_native_64.c
··· 72 72 /* clear out bits after (52) [0....52.....63] */ 73 73 va &= ~((1ul << (64 - 52)) - 1); 74 74 va |= ssize << 8; 75 - sllp = ((mmu_psize_defs[apsize].sllp & SLB_VSID_L) >> 6) | 76 - ((mmu_psize_defs[apsize].sllp & SLB_VSID_LP) >> 4); 75 + sllp = get_sllp_encoding(apsize); 77 76 va |= sllp << 5; 78 77 asm volatile(ASM_FTR_IFCLR("tlbie %0,0", PPC_TLBIE(%1,%0), %2) 79 78 : : "r" (va), "r"(0), "i" (CPU_FTR_ARCH_206) ··· 121 122 /* clear out bits after(52) [0....52.....63] */ 122 123 va &= ~((1ul << (64 - 52)) - 1); 123 124 va |= ssize << 8; 124 - sllp = ((mmu_psize_defs[apsize].sllp & SLB_VSID_L) >> 6) | 125 - ((mmu_psize_defs[apsize].sllp & SLB_VSID_LP) >> 4); 125 + sllp = get_sllp_encoding(apsize); 126 126 va |= sllp << 5; 127 127 asm volatile(".long 0x7c000224 | (%0 << 11) | (0 << 21)" 128 128 : : "r"(va) : "memory");