aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/include
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@ozlabs.org>2016-11-11 00:55:03 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-01-19 14:18:06 -0500
commite5f33ef0a60141e8eb560962750d6942a830048f (patch)
tree6515c631e93cde365f9f6b1807afd5a2562e4382 /arch/powerpc/include
parentf607fd883654003e76db567ebb4c4dd9054892bf (diff)
powerpc/64: Simplify adaptation to new ISA v3.00 HPTE format
commit 6b243fcfb5f1e16bcf732e6f86a63f8af5b59a9f upstream. This changes the way that we support the new ISA v3.00 HPTE format. Instead of adapting everything that uses HPTE values to handle either the old format or the new format, depending on which CPU we are on, we now convert explicitly between old and new formats if necessary in the low-level routines that actually access HPTEs in memory. This limits the amount of code that needs to know about the new format and makes the conversions explicit. This is OK because the old format contains all the information that is in the new format. This also fixes operation under a hypervisor, because the H_ENTER hypercall (and other hypercalls that deal with HPTEs) will continue to require the HPTE value to be supplied in the old format. At present the kernel will not boot in HPT mode on POWER9 under a hypervisor. This fixes and partially reverts commit 50de596de8be ("powerpc/mm/hash: Add support for Power9 Hash", 2016-04-29). Fixes: 50de596de8be ("powerpc/mm/hash: Add support for Power9 Hash") Signed-off-by: Paul Mackerras <paulus@ozlabs.org> Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'arch/powerpc/include')
-rw-r--r--arch/powerpc/include/asm/book3s/64/mmu-hash.h47
1 files changed, 39 insertions, 8 deletions
diff --git a/arch/powerpc/include/asm/book3s/64/mmu-hash.h b/arch/powerpc/include/asm/book3s/64/mmu-hash.h
index e407af2b7333..2e6a823fa502 100644
--- a/arch/powerpc/include/asm/book3s/64/mmu-hash.h
+++ b/arch/powerpc/include/asm/book3s/64/mmu-hash.h
@@ -70,7 +70,9 @@
70 70
71#define HPTE_V_SSIZE_SHIFT 62 71#define HPTE_V_SSIZE_SHIFT 62
72#define HPTE_V_AVPN_SHIFT 7 72#define HPTE_V_AVPN_SHIFT 7
73#define HPTE_V_COMMON_BITS ASM_CONST(0x000fffffffffffff)
73#define HPTE_V_AVPN ASM_CONST(0x3fffffffffffff80) 74#define HPTE_V_AVPN ASM_CONST(0x3fffffffffffff80)
75#define HPTE_V_AVPN_3_0 ASM_CONST(0x000fffffffffff80)
74#define HPTE_V_AVPN_VAL(x) (((x) & HPTE_V_AVPN) >> HPTE_V_AVPN_SHIFT) 76#define HPTE_V_AVPN_VAL(x) (((x) & HPTE_V_AVPN) >> HPTE_V_AVPN_SHIFT)
75#define HPTE_V_COMPARE(x,y) (!(((x) ^ (y)) & 0xffffffffffffff80UL)) 77#define HPTE_V_COMPARE(x,y) (!(((x) ^ (y)) & 0xffffffffffffff80UL))
76#define HPTE_V_BOLTED ASM_CONST(0x0000000000000010) 78#define HPTE_V_BOLTED ASM_CONST(0x0000000000000010)
@@ -80,14 +82,16 @@
80#define HPTE_V_VALID ASM_CONST(0x0000000000000001) 82#define HPTE_V_VALID ASM_CONST(0x0000000000000001)
81 83
82/* 84/*
83 * ISA 3.0 have a different HPTE format. 85 * ISA 3.0 has a different HPTE format.
84 */ 86 */
85#define HPTE_R_3_0_SSIZE_SHIFT 58 87#define HPTE_R_3_0_SSIZE_SHIFT 58
88#define HPTE_R_3_0_SSIZE_MASK (3ull << HPTE_R_3_0_SSIZE_SHIFT)
86#define HPTE_R_PP0 ASM_CONST(0x8000000000000000) 89#define HPTE_R_PP0 ASM_CONST(0x8000000000000000)
87#define HPTE_R_TS ASM_CONST(0x4000000000000000) 90#define HPTE_R_TS ASM_CONST(0x4000000000000000)
88#define HPTE_R_KEY_HI ASM_CONST(0x3000000000000000) 91#define HPTE_R_KEY_HI ASM_CONST(0x3000000000000000)
89#define HPTE_R_RPN_SHIFT 12 92#define HPTE_R_RPN_SHIFT 12
90#define HPTE_R_RPN ASM_CONST(0x0ffffffffffff000) 93#define HPTE_R_RPN ASM_CONST(0x0ffffffffffff000)
94#define HPTE_R_RPN_3_0 ASM_CONST(0x01fffffffffff000)
91#define HPTE_R_PP ASM_CONST(0x0000000000000003) 95#define HPTE_R_PP ASM_CONST(0x0000000000000003)
92#define HPTE_R_PPP ASM_CONST(0x8000000000000003) 96#define HPTE_R_PPP ASM_CONST(0x8000000000000003)
93#define HPTE_R_N ASM_CONST(0x0000000000000004) 97#define HPTE_R_N ASM_CONST(0x0000000000000004)
@@ -316,12 +320,43 @@ static inline unsigned long hpte_encode_avpn(unsigned long vpn, int psize,
316 */ 320 */
317 v = (vpn >> (23 - VPN_SHIFT)) & ~(mmu_psize_defs[psize].avpnm); 321 v = (vpn >> (23 - VPN_SHIFT)) & ~(mmu_psize_defs[psize].avpnm);
318 v <<= HPTE_V_AVPN_SHIFT; 322 v <<= HPTE_V_AVPN_SHIFT;
319 if (!cpu_has_feature(CPU_FTR_ARCH_300)) 323 v |= ((unsigned long) ssize) << HPTE_V_SSIZE_SHIFT;
320 v |= ((unsigned long) ssize) << HPTE_V_SSIZE_SHIFT;
321 return v; 324 return v;
322} 325}
323 326
324/* 327/*
328 * ISA v3.0 defines a new HPTE format, which differs from the old
329 * format in having smaller AVPN and ARPN fields, and the B field
330 * in the second dword instead of the first.
331 */
332static inline unsigned long hpte_old_to_new_v(unsigned long v)
333{
334 /* trim AVPN, drop B */
335 return v & HPTE_V_COMMON_BITS;
336}
337
338static inline unsigned long hpte_old_to_new_r(unsigned long v, unsigned long r)
339{
340 /* move B field from 1st to 2nd dword, trim ARPN */
341 return (r & ~HPTE_R_3_0_SSIZE_MASK) |
342 (((v) >> HPTE_V_SSIZE_SHIFT) << HPTE_R_3_0_SSIZE_SHIFT);
343}
344
345static inline unsigned long hpte_new_to_old_v(unsigned long v, unsigned long r)
346{
347 /* insert B field */
348 return (v & HPTE_V_COMMON_BITS) |
349 ((r & HPTE_R_3_0_SSIZE_MASK) <<
350 (HPTE_V_SSIZE_SHIFT - HPTE_R_3_0_SSIZE_SHIFT));
351}
352
353static inline unsigned long hpte_new_to_old_r(unsigned long r)
354{
355 /* clear out B field */
356 return r & ~HPTE_R_3_0_SSIZE_MASK;
357}
358
359/*
325 * This function sets the AVPN and L fields of the HPTE appropriately 360 * This function sets the AVPN and L fields of the HPTE appropriately
326 * using the base page size and actual page size. 361 * using the base page size and actual page size.
327 */ 362 */
@@ -341,12 +376,8 @@ static inline unsigned long hpte_encode_v(unsigned long vpn, int base_psize,
341 * aligned for the requested page size 376 * aligned for the requested page size
342 */ 377 */
343static inline unsigned long hpte_encode_r(unsigned long pa, int base_psize, 378static inline unsigned long hpte_encode_r(unsigned long pa, int base_psize,
344 int actual_psize, int ssize) 379 int actual_psize)
345{ 380{
346
347 if (cpu_has_feature(CPU_FTR_ARCH_300))
348 pa |= ((unsigned long) ssize) << HPTE_R_3_0_SSIZE_SHIFT;
349
350 /* A 4K page needs no special encoding */ 381 /* A 4K page needs no special encoding */
351 if (actual_psize == MMU_PAGE_4K) 382 if (actual_psize == MMU_PAGE_4K)
352 return pa & HPTE_R_RPN; 383 return pa & HPTE_R_RPN;