Clean up page size handling for ppc 64-bit hash MMUs with TCG
cover Clean up page size handling for ppc 64-bit hash MMUs with TCG
Encoding of page sizes on 64-bit hash MMUs for Power is rather arcane, involving control bits in both the SLB and HPTE. At present we support a few of the options, but far fewer than real hardware.
We're able to get away with that in practice, because guests use a device tree property to determine which page sizes are available and we are setting that to match. However, the fact that the actual code doesn't necessarily what we put into the table of available page sizes is another ugliness.
This series makes a number of cleanups to the page size handling. The upshot is that afterwards the softmmu code operates off the same page size encoding table that is advertised to the guests, ensuring that they will be in sync.
Finally, we extend the table of allowed sizes for POWER7 and POWER8 to include the options allowed in hardware (including MPSS). We can fix other hash MMU based CPUs in future if anyone cares enough.
Once reviewed, I plan to include this in my ppc-for-2.6 tree.
David Gibson (9):
target-ppc: Remove unused kvmppc_read_segment_page_sizes() stub
target-ppc: Convert mmu-hash{32,64}.[ch] from CPUPPCState to
PowerPCCPU
target-ppc: Rework SLB page size lookup
target-ppc: Use actual page size encodings from HPTE
target-ppc: Remove unused mmu models from ppc_tlb_invalidate_one
target-ppc: Split 44x tlbiva from ppc_tlb_invalidate_one()
target-ppc: Add new TLB invalidate by HPTE call for hash64 MMUs
target-ppc: Helper to determine page size information from hpte alone
target-ppc: Allow more page sizes for POWER7 & POWER8 in TCG
hw/ppc/spapr_hcall.c | 102 ++++------------ target-ppc/helper.h | 1 + target-ppc/kvm.c | 2 +- target-ppc/kvm_ppc.h | 5 - target-ppc/mmu-hash32.c | 68 ++++++----- target-ppc/mmu-hash32.h | 30 ++--- target-ppc/mmu-hash64.c | 280 +++++++++++++++++++++++++++++++++----------- target-ppc/mmu-hash64.h | 29 +++-- target-ppc/mmu_helper.c | 47 +++----- target-ppc/translate.c | 2 +- target-ppc/translate_init.c | 32 +++++ 11 files changed, 364 insertions(+), 234 deletions(-)
Signature · 1 line
2.5.0
RFC 1/9 target-ppc: Remove unused kvmppc_read_segment_page_sizes() stub
This stub function is in the !KVM ifdef in target-ppc/kvm_ppc.h. However no such function exists on the KVM side, or is ever used.
I think this originally referenced a function which read host page size information from /proc, for we we now use the KVM GET_SMMU_INFO extension instead.
In any case, it has no function now, so remove it.
--- target-ppc/kvm_ppc.h | 5 ----- 1 file changed, 5 deletions(-)
target-ppc/kvm_ppc.h +0 -5
@@ -98,11 +98,6 @@ static inline int kvmppc_get_hypercall(CPUPPCState *env, uint8_t *buf, int buf_lreturn -1 ; } -static inline int kvmppc_read_segment_page_sizes (uint32_t *prop,int maxcells) -{ -return -1 ; -} -static inline int kvmppc_set_interrupt (PowerPCCPU *cpu,int irq,int level) {return -1 ;
Signature · 1 line
2.5.0
RFC 2/9 target-ppc: Convert mmu-hash{32, 64}.[ch] from CPUPPCState to PowerPCCPU
In reply to David GibsonLike a lot of places these files include a mixture of functions taking both the older CPUPPCState *env and newer PowerPCCPU *cpu. Move a step closer to cleaning this up by standardizing on PowerPCCPU, except for the helper_* functions which are called with the CPUPPCState * from tcg.
Callers and some related functions are updated as well, the boundaries of what's changed here are a bit arbitrary.
--- hw/ppc/spapr_hcall.c | 31 ++++++++++--------- target-ppc/kvm.c | 2 +- target-ppc/mmu-hash32.c | 68 +++++++++++++++++++++++------------------ target-ppc/mmu-hash32.h | 30 ++++++++++--------- target-ppc/mmu-hash64.c | 80 +++++++++++++++++++++++++++++-------------------- target-ppc/mmu-hash64.h | 21 ++++++------- target-ppc/mmu_helper.c | 13 ++++---- 7 files changed, 136 insertions(+), 109 deletions(-)
hw/ppc/spapr_hcall.c +15 -16
@@ -145,7 +145,7 @@ static target_ulong h_enter(PowerPCCPU *cpu, sPAPRMachineState *spapr, pte_index &= ~7ULL ; token =ppc_hash64_start_access (cpu, pte_index);for (; index <8 ; index++) { -if ((ppc_hash64_load_hpte0 (env, token, index) &HPTE64_V_VALID ) ==0 ) { +if (!(ppc_hash64_load_hpte0 (cpu, token, index) &HPTE64_V_VALID )) {break ; } }
@@ -155,14 +155,14 @@ static target_ulong h_enter(PowerPCCPU *cpu, sPAPRMachineState *spapr, } }else { token =ppc_hash64_start_access (cpu, pte_index); -if (ppc_hash64_load_hpte0 (env, token,0 ) &HPTE64_V_VALID ) { +if (ppc_hash64_load_hpte0 (cpu, token,0 ) &HPTE64_V_VALID ) {ppc_hash64_stop_access (token);return H_PTEG_FULL ; }ppc_hash64_stop_access (token); } -ppc_hash64_store_hpte (env, pte_index + index, +ppc_hash64_store_hpte (cpu, pte_index + index, pteh |HPTE64_V_HPTE_DIRTY , ptel); args[0 ] = pte_index + index;
@@ -176,11 +176,12 @@ typedef enum {REMOVE_HW =3 , } RemoveResult; -static RemoveResult remove_hpte (CPUPPCState *env,target_ulong ptex, +static RemoveResult remove_hpte (PowerPCCPU *cpu,target_ulong ptex,target_ulong avpn,target_ulong flags,target_ulong *vp,target_ulong *rp) { +CPUPPCState *env = &cpu->env;uint64_t token;target_ulong v, r, rb;
@@ -188,9 +189,9 @@ static RemoveResult remove_hpte(CPUPPCState *env, target_ulong ptex,return REMOVE_PARM ; } - token =ppc_hash64_start_access (ppc_env_get_cpu (env), ptex); - v =ppc_hash64_load_hpte0 (env, token,0 ); - r =ppc_hash64_load_hpte1 (env, token,0 ); + token =ppc_hash64_start_access (cpu, ptex); + v =ppc_hash64_load_hpte0 (cpu, token,0 ); + r =ppc_hash64_load_hpte1 (cpu, token,0 );ppc_hash64_stop_access (token); if ((v & HPTE64_V_VALID) == 0 ||
@@ -200,7 +201,7 @@ static RemoveResult remove_hpte(CPUPPCState *env, target_ulong ptex, } *vp = v; *rp = r; -ppc_hash64_store_hpte (env, ptex,HPTE64_V_HPTE_DIRTY ,0 ); +ppc_hash64_store_hpte (cpu, ptex,HPTE64_V_HPTE_DIRTY ,0 ); rb =compute_tlbie_rb (v, r, ptex);ppc_tlb_invalidate_one (env, rb);return REMOVE_SUCCESS ;
@@ -209,13 +210,12 @@ static RemoveResult remove_hpte(CPUPPCState *env, target_ulong ptex,static target_ulong h_remove (PowerPCCPU *cpu,sPAPRMachineState *spapr,target_ulong opcode,target_ulong *args) { -CPUPPCState *env = &cpu->env;target_ulong flags = args[0 ];target_ulong pte_index = args[1 ];target_ulong avpn = args[2 ];RemoveResult ret; - ret =remove_hpte (env, pte_index, avpn, flags, + ret =remove_hpte (cpu, pte_index, avpn, flags, &args[0 ], &args[1 ]);switch (ret) {
@@ -256,7 +256,6 @@ static target_ulong h_remove(PowerPCCPU *cpu, sPAPRMachineState *spapr,static target_ulong h_bulk_remove (PowerPCCPU *cpu,sPAPRMachineState *spapr,target_ulong opcode,target_ulong *args) { -CPUPPCState *env = &cpu->env;int i;for (i =0 ; i <H_BULK_REMOVE_MAX_BATCH ; i++) {
@@ -278,7 +277,7 @@ static target_ulong h_bulk_remove(PowerPCCPU *cpu, sPAPRMachineState *spapr,return H_PARAMETER ; } - ret =remove_hpte (env, *tsh &H_BULK_REMOVE_PTEX , tsl, + ret =remove_hpte (cpu, *tsh &H_BULK_REMOVE_PTEX , tsl, (*tsh &H_BULK_REMOVE_FLAGS ) >>26 , &v, &r);
@@ -315,8 +314,8 @@ static target_ulong h_protect(PowerPCCPU *cpu, sPAPRMachineState *spapr, } token =ppc_hash64_start_access (cpu, pte_index); - v =ppc_hash64_load_hpte0 (env, token,0 ); - r =ppc_hash64_load_hpte1 (env, token,0 ); + v =ppc_hash64_load_hpte0 (cpu, token,0 ); + r =ppc_hash64_load_hpte1 (cpu, token,0 );ppc_hash64_stop_access (token); if ((v & HPTE64_V_VALID) == 0 ||
@@ -330,11 +329,11 @@ static target_ulong h_protect(PowerPCCPU *cpu, sPAPRMachineState *spapr, r |= (flags <<48 ) &HPTE64_R_KEY_HI ; r |= flags & (HPTE64_R_PP |HPTE64_R_N |HPTE64_R_KEY_LO ); rb =compute_tlbie_rb (v, r, pte_index); -ppc_hash64_store_hpte (env, pte_index, +ppc_hash64_store_hpte (cpu, pte_index, (v & ~HPTE64_V_VALID ) |HPTE64_V_HPTE_DIRTY ,0 );ppc_tlb_invalidate_one (env, rb);/* Don't need a memory barrier, due to qemu's global lock */ -ppc_hash64_store_hpte (env, pte_index, v |HPTE64_V_HPTE_DIRTY , r); +ppc_hash64_store_hpte (cpu, pte_index, v |HPTE64_V_HPTE_DIRTY , r);return H_SUCCESS ; }
target-ppc/kvm.c +1 -1
@@ -1193,7 +1193,7 @@ int kvm_arch_get_registers(CPUState *cs)* Only restore valid entries */ if (rb &SLB_ESID_V ) { -ppc_store_slb (env, rb, rs); +ppc_store_slb (cpu, rb, rs); } }#endif
target-ppc/mmu-hash32.c +39 -29
221 lines not on this page · raw message
target-ppc/mmu-hash32.h +16 -14
@@ -3,8 +3,8 @@#ifndef CONFIG_USER_ONLY -hwaddr get_pteg_offset32 (CPUPPCState *env,hwaddr hash); -hwaddr ppc_hash32_get_phys_page_debug (CPUPPCState *env,target_ulong addr); +hwaddr get_pteg_offset32 (PowerPCCPU *cpu,hwaddr hash); +hwaddr ppc_hash32_get_phys_page_debug (PowerPCCPU *cpu,target_ulong addr);int ppc_hash32_handle_mmu_fault (PowerPCCPU *cpu,target_ulong address,int rw,int mmu_idx);
@@ -65,40 +65,42 @@ int ppc_hash32_handle_mmu_fault(PowerPCCPU *cpu, target_ulong address, int rw,#define HPTE32_R_WIMG 0x00000078#define HPTE32_R_PP 0x00000003 -static inline target_ulong ppc_hash32_load_hpte0 (CPUPPCState *env, +static inline target_ulong ppc_hash32_load_hpte0 (PowerPCCPU *cpu,hwaddr pte_offset) { -CPUState *cs =CPU (ppc_env_get_cpu (env)); +CPUPPCState *env = &cpu->env;assert (!env->external_htab);/* Not supported on 32-bit for now */ -return ldl_phys (cs->as, env->htab_base + pte_offset); +return ldl_phys (CPU (cpu)->as, env->htab_base + pte_offset); } -static inline target_ulong ppc_hash32_load_hpte1 (CPUPPCState *env, +static inline target_ulong ppc_hash32_load_hpte1 (PowerPCCPU *cpu,hwaddr pte_offset) { -CPUState *cs =CPU (ppc_env_get_cpu (env)); +CPUPPCState *env = &cpu->env;assert (!env->external_htab);/* Not supported on 32-bit for now */ -return ldl_phys (cs->as, env->htab_base + pte_offset +HASH_PTE_SIZE_32 /2 ); +return ldl_phys (CPU (cpu)->as, + env->htab_base + pte_offset +HASH_PTE_SIZE_32 /2 ); } -static inline void ppc_hash32_store_hpte0 (CPUPPCState *env, +static inline void ppc_hash32_store_hpte0 (PowerPCCPU *cpu,hwaddr pte_offset,target_ulong pte0) { -CPUState *cs =CPU (ppc_env_get_cpu (env)); +CPUPPCState *env = &cpu->env;assert (!env->external_htab);/* Not supported on 32-bit for now */ -stl_phys (cs->as, env->htab_base + pte_offset, pte0); +stl_phys (CPU (cpu)->as, env->htab_base + pte_offset, pte0); } -static inline void ppc_hash32_store_hpte1 (CPUPPCState *env, +static inline void ppc_hash32_store_hpte1 (PowerPCCPU *cpu,hwaddr pte_offset,target_ulong pte1) { -CPUState *cs =CPU (ppc_env_get_cpu (env)); +CPUPPCState *env = &cpu->env;assert (!env->external_htab);/* Not supported on 32-bit for now */ -stl_phys (cs->as, env->htab_base + pte_offset +HASH_PTE_SIZE_32 /2 , pte1); +stl_phys (CPU (cpu)->as, + env->htab_base + pte_offset +HASH_PTE_SIZE_32 /2 , pte1); } typedef struct {
target-ppc/mmu-hash64.c +47 -33
262 lines not on this page · raw message
target-ppc/mmu-hash64.h +11 -10
@@ -4,12 +4,13 @@#ifndef CONFIG_USER_ONLY #ifdef TARGET_PPC64 -void dump_slb (FILE *f,fprintf_function cpu_fprintf,CPUPPCState *env); -int ppc_store_slb (CPUPPCState *env,target_ulong rb,target_ulong rs); -hwaddr ppc_hash64_get_phys_page_debug (CPUPPCState *env,target_ulong addr); +void ppc_hash64_check_page_sizes (PowerPCCPU *cpu,Error **errp); +void dump_slb (FILE *f,fprintf_function cpu_fprintf,PowerPCCPU *cpu); +int ppc_store_slb (PowerPCCPU *cpu,target_ulong rb,target_ulong rs); +hwaddr ppc_hash64_get_phys_page_debug (PowerPCCPU *cpu,target_ulong addr);int ppc_hash64_handle_mmu_fault (PowerPCCPU *cpu,target_ulong address,int rw,int mmu_idx); -void ppc_hash64_store_hpte (CPUPPCState *env,target_ulong index, +void ppc_hash64_store_hpte (PowerPCCPU *cpu,target_ulong index,target_ulong pte0,target_ulong pte1);#endif
@@ -85,31 +86,31 @@ extern bool kvmppc_kern_htab;uint64_t ppc_hash64_start_access (PowerPCCPU *cpu,target_ulong pte_index);void ppc_hash64_stop_access (uint64_t token); -static inline target_ulong ppc_hash64_load_hpte0 (CPUPPCState *env, +static inline target_ulong ppc_hash64_load_hpte0 (PowerPCCPU *cpu,uint64_t token,int index) { -CPUState *cs =CPU (ppc_env_get_cpu (env)); +CPUPPCState *env = &cpu->env;uint64_t addr; addr = token + (index *HASH_PTE_SIZE_64 );if (env->external_htab) {return ldq_p ((const void *)(uintptr_t )addr); }else { -return ldq_phys (cs->as, addr); +return ldq_phys (CPU (cpu)->as, addr); } } -static inline target_ulong ppc_hash64_load_hpte1 (CPUPPCState *env, +static inline target_ulong ppc_hash64_load_hpte1 (PowerPCCPU *cpu,uint64_t token,int index) { -CPUState *cs =CPU (ppc_env_get_cpu (env)); +CPUPPCState *env = &cpu->env;uint64_t addr; addr = token + (index *HASH_PTE_SIZE_64 ) +HASH_PTE_SIZE_64 /2 ;if (env->external_htab) {return ldq_p ((const void *)(uintptr_t )addr); }else { -return ldq_phys (cs->as, addr); +return ldq_phys (CPU (cpu)->as, addr); } }
target-ppc/mmu_helper.c +7 -6
@@ -1297,7 +1297,7 @@ void dump_mmu(FILE *f, fprintf_function cpu_fprintf, CPUPPCState *env)case POWERPC_MMU_2_06a:case POWERPC_MMU_2_07 :case POWERPC_MMU_2_07a: -dump_slb (f, cpu_fprintf, env); +dump_slb (f, cpu_fprintf,ppc_env_get_cpu (env));break ;#endif default :
@@ -1439,12 +1439,12 @@ hwaddr ppc_cpu_get_phys_page_debug(CPUState *cs, vaddr addr)case POWERPC_MMU_2_06a:case POWERPC_MMU_2_07 :case POWERPC_MMU_2_07a: -return ppc_hash64_get_phys_page_debug (env, addr); +return ppc_hash64_get_phys_page_debug (cpu, addr);#endif case POWERPC_MMU_32B :case POWERPC_MMU_601 : -return ppc_hash32_get_phys_page_debug (env, addr); +return ppc_hash32_get_phys_page_debug (cpu, addr);default : ;
@@ -1510,6 +1510,7 @@ static int cpu_ppc_handle_mmu_fault(CPUPPCState *env, target_ulong address, int rw, int mmu_idx) {CPUState *cs =CPU (ppc_env_get_cpu (env)); +PowerPCCPU *cpu =POWERPC_CPU (cs);mmu_ctx_t ctx;int access_type;int ret =0 ;
@@ -1611,9 +1612,9 @@ static int cpu_ppc_handle_mmu_fault(CPUPPCState *env, target_ulong address, tlb_miss: env->error_code |= ctx.key <<19 ; env->spr[SPR_HASH1 ] = env->htab_base + -get_pteg_offset32 (env, ctx.hash[0 ]); +get_pteg_offset32 (cpu, ctx.hash[0 ]); env->spr[SPR_HASH2 ] = env->htab_base + -get_pteg_offset32 (env, ctx.hash[1 ]); +get_pteg_offset32 (cpu, ctx.hash[1 ]);break ;case POWERPC_MMU_SOFT_74xx:if (rw ==1 ) {
@@ -2101,7 +2102,7 @@ void helper_store_sr(CPUPPCState *env, target_ulong srnum, target_ulong value)/* flags = flags */ rs |= ((value >>27 ) &0xf ) <<8 ; -ppc_store_slb (env, rb, rs); +ppc_store_slb (cpu, rb, rs); } else#endif if (env->sr[srnum] != value) {
Signature · 1 line
2.5.0
RFC 3/9 target-ppc: Rework SLB page size lookup
In reply to David GibsonCurrently, the ppc_hash64_page_shift() function looks up a page size based on information in an SLB entry. It open codes the bit translation for existing CPUs, however different CPU models can have different SLB encodings. We already store those in the 'sps' table in CPUPPCState, but we don't currently enforce that that actually matches the logic in ppc_hash64_page_shift.
This patch reworks lookup of page size from SLB in several ways:
* ppc_hash64_page_shift() is replaced by slb_page_size() which
- Uses the the sps table, so it is correct for whatever encodings are stored there
- Returns a pointer to a table entry, rather than the raw shift, which we'll want later on
* We adjust ppc_store_slb() to verify that the stored SLBE has a valid
page size encoding (otherwise it fails, which will trigger an illegal instruction exception)
* ppc_hash64_htab_lookup() is extended to return the SLB's page size in addition to other information.
* Adjust ppc_hash64_pte_raddr() to take a page shift directly instead of an SLB entry. Both callers have just called ppc_hash64_htab_lookup() which has already done the SLB -> page size lookup.
--- target-ppc/mmu-hash64.c | 88 ++++++++++++++++++++++++++++--------------------- 1 file changed, 51 insertions(+), 37 deletions(-)
target-ppc/mmu-hash64.c +51 -37
@@ -90,6 +90,28 @@ void dump_slb(FILE *f, fprintf_function cpu_fprintf, PowerPCCPU *cpu) } } +static const struct ppc_one_seg_page_size *slb_page_size (PowerPCCPU *cpu, +uint64_t slbv) +{ +CPUPPCState *env = &cpu->env; +int i; + +for (i =0 ; i <PPC_PAGE_SIZES_MAX_SZ ; i++) { +const struct ppc_one_seg_page_size *sps = &env->sps.sps[i]; + +if (!sps->page_shift) { +break ; + } + +if ((slbv &SLB_VSID_LLP_MASK ) == sps->slb_enc) { +return sps; + } + } + +/* Bad page size encoding */ +return NULL ; +} +void helper_slbia (CPUPPCState *env) {PowerPCCPU *cpu =ppc_env_get_cpu (env);
@@ -150,6 +172,9 @@ int ppc_store_slb(PowerPCCPU *cpu, target_ulong rb, target_ulong rs)if ((rs &SLB_VSID_B ) && !(env->mmu_model &POWERPC_MMU_1TSEG )) {return -1 ;/* 1T segment on MMU that doesn't support it */ } +if (!slb_page_size (cpu, rs)) { +return -1 ;/* Bad page size encoding for this CPU */ + }/* Mask out the slot number as we store the entry */ slb->esid = rb & (SLB_ESID_ESID |SLB_ESID_V );
@@ -392,46 +417,37 @@ static hwaddr ppc_hash64_pteg_search(PowerPCCPU *cpu, hwaddr hash,return -1 ; } -static uint64_t ppc_hash64_page_shift (ppc_slb_t *slb) -{ -uint64_t epnshift; - -/* Page size according to the SLB, which we use to generate the -* EPN for hash table lookup.. When we implement more recent MMU -* extensions this might be different from the actual page size -* encoded in the PTE */ -if ((slb->vsid &SLB_VSID_LLP_MASK ) ==SLB_VSID_4K ) { - epnshift =TARGET_PAGE_BITS ; - }else if ((slb->vsid &SLB_VSID_LLP_MASK ) ==SLB_VSID_64K ) { - epnshift =TARGET_PAGE_BITS_64K ; - }else { - epnshift =TARGET_PAGE_BITS_16M ; - } -return epnshift; -} -static hwaddr ppc_hash64_htab_lookup (PowerPCCPU *cpu,ppc_slb_t *slb,target_ulong eaddr, -ppc_hash_pte64_t *pte) +ppc_hash_pte64_t *pte, +const struct ppc_one_seg_page_size **psps) {CPUPPCState *env = &cpu->env;hwaddr pte_offset;hwaddr hash; -uint64_t vsid, epnshift, epnmask, epn, ptem; +const struct ppc_one_seg_page_size *sps; +uint64_t vsid, epnmask, epn, ptem; + + sps =slb_page_size (cpu, slb->vsid); +/* The SLB store path should prevent any bad page size encodings +* getting in there, so: */ +assert (sps); +if (psps) { + *psps = sps; + } - epnshift =ppc_hash64_page_shift (slb); - epnmask = ~((1ULL << epnshift) -1 ); + epnmask = ~((1ULL << sps->page_shift) -1 );if (slb->vsid &SLB_VSID_B ) {/* 1TB segment */ vsid = (slb->vsid &SLB_VSID_VSID ) >>SLB_VSID_SHIFT_1T ; epn = (eaddr & ~SEGMENT_MASK_1T ) & epnmask; - hash = vsid ^ (vsid <<25 ) ^ (epn >> epnshift); + hash = vsid ^ (vsid <<25 ) ^ (epn >> sps->page_shift); }else {/* 256M segment */ vsid = (slb->vsid &SLB_VSID_VSID ) >>SLB_VSID_SHIFT ; epn = (eaddr & ~SEGMENT_MASK_256M ) & epnmask; - hash = vsid ^ (epn >> epnshift); + hash = vsid ^ (epn >> sps->page_shift); } ptem = (slb->vsid &SLB_VSID_PTEM ) | ((epn >>16 ) &HPTE64_V_AVPN );
@@ -463,17 +479,12 @@ static hwaddr ppc_hash64_htab_lookup(PowerPCCPU *cpu,return pte_offset; } -static hwaddr ppc_hash64_pte_raddr (ppc_slb_t *slb,ppc_hash_pte64_t pte, -target_ulong eaddr) +static hwaddr ppc_hash64_pte_raddr (PowerPCCPU *cpu,unsigned page_shift, +ppc_hash_pte64_t pte,target_ulong eaddr) { -hwaddr mask; -int target_page_bits; +hwaddr mask = (1ULL << page_shift) -1 ;hwaddr rpn = pte.pte1 &HPTE64_R_RPN ; -/* -* We support 4K, 64K and 16M now -*/ - target_page_bits =ppc_hash64_page_shift (slb); - mask = (1ULL << target_page_bits) -1 ; +return (rpn & ~mask) | (eaddr & mask); }
@@ -483,6 +494,7 @@ int ppc_hash64_handle_mmu_fault(PowerPCCPU *cpu, target_ulong eaddr,CPUState *cs =CPU (cpu);CPUPPCState *env = &cpu->env;ppc_slb_t *slb; +const struct ppc_one_seg_page_size *sps;hwaddr pte_offset;ppc_hash_pte64_t pte;int pp_prot, amr_prot, prot;
@@ -526,7 +538,7 @@ int ppc_hash64_handle_mmu_fault(PowerPCCPU *cpu, target_ulong eaddr, }/* 4. Locate the PTE in the hash table */ - pte_offset =ppc_hash64_htab_lookup (cpu, slb, eaddr, &pte); + pte_offset =ppc_hash64_htab_lookup (cpu, slb, eaddr, &pte, &sps);if (pte_offset ==-1 ) {if (rwx ==2 ) { cs->exception_index =POWERPC_EXCP_ISI ;
@@ -598,7 +610,7 @@ int ppc_hash64_handle_mmu_fault(PowerPCCPU *cpu, target_ulong eaddr,/* 7. Determine the real address from the PTE */ - raddr =ppc_hash64_pte_raddr (slb, pte, eaddr); + raddr =ppc_hash64_pte_raddr (cpu, sps->page_shift, pte, eaddr);tlb_set_page (cs, eaddr &TARGET_PAGE_MASK , raddr &TARGET_PAGE_MASK , prot, mmu_idx,TARGET_PAGE_SIZE );
@@ -610,6 +622,7 @@ hwaddr ppc_hash64_get_phys_page_debug(PowerPCCPU *cpu, target_ulong addr) {CPUPPCState *env = &cpu->env;ppc_slb_t *slb; +const struct ppc_one_seg_page_size *sps;hwaddr pte_offset;ppc_hash_pte64_t pte;
@@ -623,12 +636,13 @@ hwaddr ppc_hash64_get_phys_page_debug(PowerPCCPU *cpu, target_ulong addr)return -1 ; } - pte_offset =ppc_hash64_htab_lookup (cpu, slb, addr, &pte); + pte_offset =ppc_hash64_htab_lookup (cpu, slb, addr, &pte, &sps);if (pte_offset ==-1 ) {return -1 ; } -return ppc_hash64_pte_raddr (slb, pte, addr) &TARGET_PAGE_MASK ; +return ppc_hash64_pte_raddr (cpu, sps->page_shift, pte, addr) + &TARGET_PAGE_MASK ; } void ppc_hash64_store_hpte(PowerPCCPU *cpu,
Signature · 1 line
2.5.0
RFC 4/9 target-ppc: Use actual page size encodings from HPTE
In reply to David GibsonAt present the 64-bit hash MMU code uses information from the SLB to determine the page size of a translation. We do need that information to correctly look up the hash table. However the MMU also allows a possibly larger page size to be encoded into the HPTE itself, which is used to populate the TLB. At present qemu doesn't check that, and so doesn't support the MPSS "Multiple Page Size per Segment" feature.
This makes a start on allowing this, by adding an hpte_page_shift() function which looks up the page size of an HPTE. We use this to validate page sizes encodings on faults, and populate the qemu TLB with larger page sizes when appropriate.
--- target-ppc/mmu-hash64.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 71 insertions(+), 4 deletions(-)
target-ppc/mmu-hash64.c +71 -4
@@ -20,6 +20,7 @@#include "cpu.h" #include "exec/helper-proto.h" #include "sysemu/kvm.h" +#include "qemu/error-report.h" #include "kvm_ppc.h" #include "mmu-hash64.h"
@@ -479,6 +480,43 @@ static hwaddr ppc_hash64_htab_lookup(PowerPCCPU *cpu,return pte_offset; } +static unsigned hpte_page_shift (const struct ppc_one_seg_page_size *sps, +uint64_t pte0,uint64_t pte1) +{ +int i; + +if (!(pte0 &HPTE64_V_LARGE )) { +if (sps->page_shift !=12 ) { +/* 4kiB page in a non 4kiB segment */ +return 0 ; + } +/* Normal 4kiB page */ +return 12 ; + } + +for (i =0 ; i <PPC_PAGE_SIZES_MAX_SZ ; i++) { +const struct ppc_one_page_size *ps = &sps->enc[i]; +uint64_t mask; + +if (!ps->page_shift) { +break ; + } + +if (ps->page_shift ==12 ) { +/* L bit is set so this can't be a 4kiB page */ +continue ; + } + + mask = ((1ULL << ps->page_shift) -1 ) &HPTE64_R_RPN ; + +if ((pte1 & mask) == ps->pte_enc) { +return ps->page_shift; + } + } + +return 0 ;/* Bad page size encoding */ +} +static hwaddr ppc_hash64_pte_raddr (PowerPCCPU *cpu,unsigned page_shift,ppc_hash_pte64_t pte,target_ulong eaddr) {
@@ -495,6 +533,7 @@ int ppc_hash64_handle_mmu_fault(PowerPCCPU *cpu, target_ulong eaddr,CPUPPCState *env = &cpu->env;ppc_slb_t *slb;const struct ppc_one_seg_page_size *sps; +unsigned apshift;hwaddr pte_offset;ppc_hash_pte64_t pte;int pp_prot, amr_prot, prot;
@@ -539,6 +578,7 @@ int ppc_hash64_handle_mmu_fault(PowerPCCPU *cpu, target_ulong eaddr,/* 4. Locate the PTE in the hash table */ pte_offset =ppc_hash64_htab_lookup (cpu, slb, eaddr, &pte, &sps); +if (pte_offset ==-1 ) {if (rwx ==2 ) { cs->exception_index =POWERPC_EXCP_ISI ;
@@ -558,6 +598,28 @@ int ppc_hash64_handle_mmu_fault(PowerPCCPU *cpu, target_ulong eaddr,qemu_log_mask (CPU_LOG_MMU ,"found PTE at offset %08" HWADDR_PRIx"\n" , pte_offset); +/* Validate page size encoding */ + apshift =hpte_page_shift (sps, pte.pte0, pte.pte1); +if (!apshift) { +error_report ("Bad page size encoding in HPTE 0x%" PRIx64" - 0x%" PRIx64 +" @ 0x%" HWADDR_PRIx, pte.pte0, pte.pte1, pte_offset); +/* Treat it like a hash miss for the guest */ +if (rwx ==2 ) { + cs->exception_index =POWERPC_EXCP_ISI ; + env->error_code =0x40000000 ; + }else { + cs->exception_index =POWERPC_EXCP_DSI ; + env->error_code =0 ; + env->spr[SPR_DAR ] = eaddr; +if (rwx ==1 ) { + env->spr[SPR_DSISR ] =0x42000000 ; + }else { + env->spr[SPR_DSISR ] =0x40000000 ; + } + } +return 1 ; + } +/* 5. Check access permissions */ pp_prot =ppc_hash64_pte_prot (cpu, slb, pte);
@@ -610,10 +672,9 @@ int ppc_hash64_handle_mmu_fault(PowerPCCPU *cpu, target_ulong eaddr,/* 7. Determine the real address from the PTE */ - raddr =ppc_hash64_pte_raddr (cpu, sps->page_shift, pte, eaddr); - + raddr =ppc_hash64_pte_raddr (cpu, apshift, pte, eaddr);tlb_set_page (cs, eaddr &TARGET_PAGE_MASK , raddr &TARGET_PAGE_MASK , - prot, mmu_idx,TARGET_PAGE_SIZE ); + prot, mmu_idx,1ULL << apshift);return 0 ; }
@@ -625,6 +686,7 @@ hwaddr ppc_hash64_get_phys_page_debug(PowerPCCPU *cpu, target_ulong addr)const struct ppc_one_seg_page_size *sps;hwaddr pte_offset;ppc_hash_pte64_t pte; +unsigned apshift;if (msr_dr ==0 ) {/* In real mode the top 4 effective address bits are ignored */
@@ -641,7 +703,12 @@ hwaddr ppc_hash64_get_phys_page_debug(PowerPCCPU *cpu, target_ulong addr)return -1 ; } -return ppc_hash64_pte_raddr (cpu, sps->page_shift, pte, addr) + apshift =hpte_page_shift (sps, pte.pte0, pte.pte1); +if (!apshift) { +return -1 ; + } + +return ppc_hash64_pte_raddr (cpu, apshift, pte, addr) &TARGET_PAGE_MASK ; }
Signature · 1 line
2.5.0
RFC 5/9 target-ppc: Remove unused mmu models from ppc_tlb_invalidate_one
In reply to David Gibsonppc_tlb_invalidate_one() has a big switch handling many different MMU types. However, most of those branches can never be reached:
It is called from 3 places: from remove_hpte() and h_protect() in spapr_hcall.c (which always has a 64-bit hash MMU type), and from helper_tlbie() in mmu_helper.c.
Calls to helper_tlbie() are generated from gen_tlbiel, gen_tlbiel and gen_tlbiva. The first two are only used with the PPC_MEM_TLBIE flag, set only with 32-bit or 64-bit hash MMU models, and gen_tlbiva() is used only on 440 and 460 models with the BookE mmu model.
These means the exhaustive list of MMU types which may call ppc_tlb_invalidate_one() is: POWERPC_MMU_SOFT_6xx, POWERPC_MMU_601, POWERPC_MMU_32B, POWERPC_MMU_SOFT_74xx, POWERPC_MMU_64B, POWERPC_MMU_2_03, POWERPC_MMU_2_06, POWERPC_MMU_2_07 and POWERPC_MMU_BOOKE.
Clean up by removing logic for all other MMU types from ppc_tlb_invalidate_one().
--- target-ppc/mmu_helper.c | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-)
target-ppc/mmu_helper.c +2 -18
@@ -1971,25 +1971,10 @@ void ppc_tlb_invalidate_one(CPUPPCState *env, target_ulong addr)ppc6xx_tlb_invalidate_virt (env, addr,1 ); }break ; -case POWERPC_MMU_SOFT_4xx: -case POWERPC_MMU_SOFT_4xx_Z: -ppc4xx_tlb_invalidate_virt (env, addr, env->spr[SPR_40x_PID]); -break ; -case POWERPC_MMU_REAL : -cpu_abort (CPU (cpu),"No TLB for PowerPC 4xx in real mode\n" ); -break ; -case POWERPC_MMU_MPC8xx: -/* XXX: TODO */ -cpu_abort (CPU (cpu),"MPC8xx MMU model is not implemented\n" ); -break ;case POWERPC_MMU_BOOKE :/* XXX: TODO */ cpu_abort (CPU (cpu),"BookE MMU model is not implemented\n" );break ; -case POWERPC_MMU_BOOKE206 : -/* XXX: TODO */ -cpu_abort (CPU (cpu),"BookE 2.06 MMU model is not implemented\n" ); -break ;case POWERPC_MMU_32B :case POWERPC_MMU_601 :/* tlbie invalidate TLBs for all segments */
@@ -2031,9 +2016,8 @@ void ppc_tlb_invalidate_one(CPUPPCState *env, target_ulong addr)break ;#endif /* defined(TARGET_PPC64) */ default : -/* XXX: TODO */ -cpu_abort (CPU (cpu),"Unknown MMU model\n" ); -break ; +/* Should never reach here with other MMU models */ +assert (0 ); }#else ppc_tlb_invalidate_all (env);
Signature · 1 line
2.5.0
RFC 6/9 target-ppc: Split 44x tlbiva from ppc_tlb_invalidate_one()
In reply to David GibsonCurrently both the tlbiva instruction (used on 44x chips) and the tlbie instruction (used on hash MMU chips) are both handled via ppc_tlb_invalidate_one(). This is silly, because they're invoked from different places, and do different things.
Clean this up by separating out the tlbiva instruction into its own handling. In fact the implementation is only a stub anyway.
--- target-ppc/helper.h | 1 + target-ppc/mmu_helper.c | 14 ++++++++++---- target-ppc/translate.c | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-)
target-ppc/helper.h +1 -0
@@ -544,6 +544,7 @@ DEF_HELPER_2(74xx_tlbd, void, env, tl) DEF_HELPER_2(74xx_tlbi, void, env, tl) DEF_HELPER_FLAGS_1(tlbia, TCG_CALL_NO_RWG, void, env) DEF_HELPER_FLAGS_2(tlbie, TCG_CALL_NO_RWG, void, env, tl) +DEF_HELPER_FLAGS_2(tlbiva, TCG_CALL_NO_RWG, void, env, tl)#if defined(TARGET_PPC64 ) DEF_HELPER_FLAGS_3(store_slb, TCG_CALL_NO_RWG, void, env, tl, tl)DEF_HELPER_2 (load_slb_esid, tl, env, tl)
target-ppc/mmu_helper.c +10 -4
@@ -1971,10 +1971,6 @@ void ppc_tlb_invalidate_one(CPUPPCState *env, target_ulong addr)ppc6xx_tlb_invalidate_virt (env, addr,1 ); }break ; -case POWERPC_MMU_BOOKE : -/* XXX: TODO */ -cpu_abort (CPU (cpu),"BookE MMU model is not implemented\n" ); -break ;case POWERPC_MMU_32B :case POWERPC_MMU_601 :/* tlbie invalidate TLBs for all segments */
@@ -2120,6 +2116,16 @@ void helper_tlbie(CPUPPCState *env, target_ulong addr)ppc_tlb_invalidate_one (env, addr); } +void helper_tlbiva (CPUPPCState *env,target_ulong addr) +{ +PowerPCCPU *cpu =ppc_env_get_cpu (env); + +/* tlbiva instruciton only exists on BookE */ +assert (env->mmu_model ==POWERPC_MMU_BOOKE ); +/* XXX: TODO */ +cpu_abort (CPU (cpu),"BookE MMU model is not implemented\n" ); +} +/* Software driven TLBs management */ /* PowerPC 602/603 software TLB load instructions helpers */ static void do_6xx_tlb (CPUPPCState *env,target_ulong new_EPN,int is_code)
target-ppc/translate.c +1 -1
@@ -5904,7 +5904,7 @@ static void gen_tlbiva(DisasContext *ctx) } t0 =tcg_temp_new ();gen_addr_reg_index (ctx, t0); -gen_helper_tlbie (cpu_env, cpu_gpr[rB (ctx->opcode)]); +gen_helper_tlbiva (cpu_env, cpu_gpr[rB (ctx->opcode)]);tcg_temp_free (t0);#endif }
Signature · 1 line
2.5.0
RFC 7/9 target-ppc: Add new TLB invalidate by HPTE call for hash64 MMUs
In reply to David GibsonWhen HPTEs are removed or modified by hypercalls on spapr, we need to invalidate the relevant pages in the qemu TLB.
Currently we do that by doing some complicated calculations to work out the right encoding for the tlbie instruction, then passing that to ppc_tlb_invalidate_one()... which totally ignores the argument and flushes the whole tlb.
Avoid that by adding a new flush-by-hpte helper in mmu-hash64.c.
--- hw/ppc/spapr_hcall.c | 46 ++++------------------------------------------ target-ppc/mmu-hash64.c | 12 ++++++++++++ target-ppc/mmu-hash64.h | 3 +++ 3 files changed, 19 insertions(+), 42 deletions(-)
hw/ppc/spapr_hcall.c +4 -42
@@ -37,42 +37,6 @@ static void set_spr(CPUState *cs, int spr, target_ulong value,run_on_cpu (cs, do_spr_sync, &s); } -static target_ulong compute_tlbie_rb (target_ulong v,target_ulong r, -target_ulong pte_index) -{ -target_ulong rb, va_low; - - rb = (v & ~0x7fULL ) <<16 ;/* AVA field */ - va_low = pte_index >>3 ; -if (v &HPTE64_V_SECONDARY ) { - va_low = ~va_low; - } -/* xor vsid from AVA */ -if (!(v &HPTE64_V_1TB_SEG )) { - va_low ^= v >>12 ; - }else { - va_low ^= v >>24 ; - } - va_low &=0x7ff ; -if (v &HPTE64_V_LARGE ) { - rb |=1 ;/* L field */ -#if 0 /* Disable that P7 specific bit for now */ -if (r &0xff000 ) { -/* non-16MB large page, must be 64k */ -/* (masks depend on page size) */ - rb |=0x1000 ;/* page encoding in LP field */ - rb |= (va_low &0x7f ) <<16 ;/* 7b of VA in AVA/LP field */ - rb |= (va_low &0xfe );/* AVAL field */ - } -#endif - }else { -/* 4kB page */ - rb |= (va_low &0x7ff ) <<12 ;/* remaining 11b of AVA */ - } - rb |= (v >>54 ) &0x300 ;/* B field */ -return rb; -} -static inline bool valid_pte_index (CPUPPCState *env,target_ulong pte_index) {/*
@@ -183,7 +147,7 @@ static RemoveResult remove_hpte(PowerPCCPU *cpu, target_ulong ptex, {CPUPPCState *env = &cpu->env;uint64_t token; -target_ulong v, r, rb; +target_ulong v, r;if (!valid_pte_index (env, ptex)) {return REMOVE_PARM ;
@@ -202,8 +166,7 @@ static RemoveResult remove_hpte(PowerPCCPU *cpu, target_ulong ptex, *vp = v; *rp = r;ppc_hash64_store_hpte (cpu, ptex,HPTE64_V_HPTE_DIRTY ,0 ); - rb =compute_tlbie_rb (v, r, ptex); -ppc_tlb_invalidate_one (env, rb); +ppc_hash64_tlb_flush_hpte (cpu, ptex, v, r);return REMOVE_SUCCESS ; }
@@ -307,7 +270,7 @@ static target_ulong h_protect(PowerPCCPU *cpu, sPAPRMachineState *spapr,target_ulong pte_index = args[1 ];target_ulong avpn = args[2 ];uint64_t token; -target_ulong v, r, rb; +target_ulong v, r;if (!valid_pte_index (env, pte_index)) {return H_PARAMETER ;
@@ -328,10 +291,9 @@ static target_ulong h_protect(PowerPCCPU *cpu, sPAPRMachineState *spapr, r |= (flags <<55 ) &HPTE64_R_PP0 ; r |= (flags <<48 ) &HPTE64_R_KEY_HI ; r |= flags & (HPTE64_R_PP |HPTE64_R_N |HPTE64_R_KEY_LO ); - rb =compute_tlbie_rb (v, r, pte_index);ppc_hash64_store_hpte (cpu, pte_index, (v & ~HPTE64_V_VALID ) |HPTE64_V_HPTE_DIRTY ,0 ); -ppc_tlb_invalidate_one (env, rb); +ppc_hash64_tlb_flush_hpte (cpu, pte_index, v, r);/* Don't need a memory barrier, due to qemu's global lock */ ppc_hash64_store_hpte (cpu, pte_index, v |HPTE64_V_HPTE_DIRTY , r);return H_SUCCESS ;
target-ppc/mmu-hash64.c +12 -0
@@ -733,3 +733,15 @@ void ppc_hash64_store_hpte(PowerPCCPU *cpu, env->htab_base + pte_index + HASH_PTE_SIZE_64 / 2, pte1); } } + +void ppc_hash64_tlb_flush_hpte (PowerPCCPU *cpu, +target_ulong pte_index, +target_ulong pte0,target_ulong pte1) +{ +/* +* XXX: given the fact that there are too many segments to +* invalidate, and we still don't have a tlb_flush_mask(env, n, +* mask) in QEMU, we just invalidate all TLBs +*/ +tlb_flush (CPU (cpu),1 ); +}
target-ppc/mmu-hash64.h +3 -0
@@ -12,6 +12,9 @@ int ppc_hash64_handle_mmu_fault(PowerPCCPU *cpu, target_ulong address, int rw, int mmu_idx);void ppc_hash64_store_hpte (PowerPCCPU *cpu,target_ulong index,target_ulong pte0,target_ulong pte1); +void ppc_hash64_tlb_flush_hpte (PowerPCCPU *cpu, +target_ulong pte_index, +target_ulong pte0,target_ulong pte1);#endif /*
Signature · 1 line
2.5.0
RFC 8/9 target-ppc: Helper to determine page size information from hpte alone
In reply to David Gibsonh_enter() in the spapr code needs to know the page size of the HPTE it's about to insert. Unlike other paths that do this, it doesn't have access to the SLB, so at the moment it determines this with some open-coded tests which assume POWER7 or POWER8 page size encodings.
To make this more flexible add ppc_hash64_hpte_page_shift_noslb() to determine both the "base" page size per segment, and the individual effective page size from an HPTE alone.
This means that the spapr code should now be able to handle any page size listed in the env->sps table.
--- hw/ppc/spapr_hcall.c | 25 ++++++------------------- target-ppc/mmu-hash64.c | 37 ++++++++++++++++++++++++++++++++++++- target-ppc/mmu-hash64.h | 3 +++ 3 files changed, 45 insertions(+), 20 deletions(-)
hw/ppc/spapr_hcall.c +6 -19
@@ -57,31 +57,18 @@ static target_ulong h_enter(PowerPCCPU *cpu, sPAPRMachineState *spapr,target_ulong pte_index = args[1 ];target_ulong pteh = args[2 ];target_ulong ptel = args[3 ]; -target_ulong page_shift =12 ; +unsigned apshift, spshift;target_ulong raddr;target_ulong index;uint64_t token; -/* only handle 4k and 16M pages for now */ -if (pteh &HPTE64_V_LARGE ) { -#if 0 /* We don't support 64k pages yet */ -if ((ptel &0xf000 ) ==0x1000 ) { -/* 64k page */ - } else -#endif -if ((ptel &0xff000 ) ==0 ) { -/* 16M page */ - page_shift =24 ; -/* lowest AVA bit must be 0 for 16M pages */ -if (pteh &0x80 ) { -return H_PARAMETER ; - } - }else { -return H_PARAMETER ; - } + apshift =ppc_hash64_hpte_page_shift_noslb (cpu, pteh, ptel, &spshift); +if (!apshift) { +/* Bad page size encoding */ +return H_PARAMETER ; } - raddr = (ptel &HPTE64_R_RPN ) & ~((1ULL << page_shift) -1 ); + raddr = (ptel &HPTE64_R_RPN ) & ~((1ULL << apshift) -1 );if (raddr < machine->ram_size) {/* Regular RAM - should have WIMG=0010 */
target-ppc/mmu-hash64.c +36 -1
@@ -509,7 +509,7 @@ static unsigned hpte_page_shift(const struct ppc_one_seg_page_size *sps, mask = ((1ULL << ps->page_shift) -1 ) &HPTE64_R_RPN ; -if ((pte1 & mask) == ps->pte_enc) { +if ((pte1 & mask) == (ps->pte_enc <<HPTE64_R_RPN_SHIFT )) {return ps->page_shift; } }
@@ -517,6 +517,41 @@ static unsigned hpte_page_shift(const struct ppc_one_seg_page_size *sps,return 0 ;/* Bad page size encoding */ } +unsigned ppc_hash64_hpte_page_shift_noslb (PowerPCCPU *cpu, +uint64_t pte0,uint64_t pte1, +unsigned *seg_page_shift) +{ +CPUPPCState *env = &cpu->env; +int i; + +if (!(pte0 &HPTE64_V_LARGE )) { + *seg_page_shift =12 ; +return 12 ; + } + +/* +* The encodings in env->sps need to be carefully chosen so that +* this gives an unambiguous result. +*/ +for (i =0 ; i <PPC_PAGE_SIZES_MAX_SZ ; i++) { +const struct ppc_one_seg_page_size *sps = &env->sps.sps[i]; +unsigned shift; + +if (!sps->page_shift) { +break ; + } + + shift =hpte_page_shift (sps, pte0, pte1); +if (shift) { + *seg_page_shift = sps->page_shift; +return shift; + } + } + + *seg_page_shift =0 ; +return 0 ; +} +static hwaddr ppc_hash64_pte_raddr (PowerPCCPU *cpu,unsigned page_shift,ppc_hash_pte64_t pte,target_ulong eaddr) {
target-ppc/mmu-hash64.h +3 -0
@@ -15,6 +15,9 @@ void ppc_hash64_store_hpte(PowerPCCPU *cpu, target_ulong index,void ppc_hash64_tlb_flush_hpte (PowerPCCPU *cpu,target_ulong pte_index,target_ulong pte0,target_ulong pte1); +unsigned ppc_hash64_hpte_page_shift_noslb (PowerPCCPU *cpu, +uint64_t pte0,uint64_t pte1, +unsigned *seg_page_shift);#endif /*
Signature · 1 line
2.5.0
RFC 9/9 target-ppc: Allow more page sizes for POWER7 & POWER8 in TCG
In reply to David GibsonNow that the TCG and spapr code has been extended to allow (semi-) arbitrary page encodings in the CPU's 'sps' table, we can add the many page sizes supported by real POWER7 and POWER8 hardware that we previously didn't support in TCG.
--- target-ppc/mmu-hash64.h | 2 ++ target-ppc/translate_init.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+)
target-ppc/mmu-hash64.h +2 -0
@@ -47,6 +47,8 @@ unsigned ppc_hash64_hpte_page_shift_noslb(PowerPCCPU *cpu,#define SLB_VSID_LLP_MASK (SLB_VSID_L | SLB_VSID_LP)#define SLB_VSID_4K 0x0000000000000000ULL#define SLB_VSID_64K 0x0000000000000110ULL +#define SLB_VSID_16M 0x0000000000000100ULL +#define SLB_VSID_16G 0x0000000000000120ULL/* * Hash page table definitions
target-ppc/translate_init.c +32 -0
@@ -8104,6 +8104,36 @@ static Property powerpc_servercpu_properties[] = { DEFINE_PROP_END_OF_LIST(), }; +#ifdef CONFIG_SOFTMMU +static const struct ppc_segment_page_sizes POWER7_POWER8_sps = { + .sps = { + { + .page_shift =12 ,/* 4K */ + .slb_enc =0 , + .enc = { { .page_shift =12 , .pte_enc =0 }, + { .page_shift =16 , .pte_enc =0x7 }, + { .page_shift =24 , .pte_enc =0x38 }, }, + }, + { + .page_shift =16 ,/* 64K */ + .slb_enc =SLB_VSID_64K , + .enc = { { .page_shift =16 , .pte_enc =0x1 }, + { .page_shift =24 , .pte_enc =0x8 }, }, + }, + { + .page_shift =24 ,/* 16M */ + .slb_enc =SLB_VSID_16M , + .enc = { { .page_shift =24 , .pte_enc =0 }, }, + }, + { + .page_shift =34 ,/* 16G */ + .slb_enc =SLB_VSID_16G , + .enc = { { .page_shift =34 , .pte_enc =0x3 }, }, + }, + } +}; +#endif /* CONFIG_SOFTMMU */ +static void init_proc_POWER7 (CPUPPCState *env) {init_proc_book3s_64 (env,BOOK3S_CPU_POWER7 );
@@ -8167,6 +8197,7 @@ POWERPC_FAMILY(POWER7)(ObjectClass *oc, void *data) pcc->mmu_model =POWERPC_MMU_2_06 ;#if defined(CONFIG_SOFTMMU ) pcc->handle_mmu_fault = ppc_hash64_handle_mmu_fault; + pcc->sps = &POWER7_POWER8_sps;#endif pcc->excp_model =POWERPC_EXCP_POWER7 ; pcc->bus_model =PPC_FLAGS_INPUT_POWER7 ;
@@ -8247,6 +8278,7 @@ POWERPC_FAMILY(POWER8)(ObjectClass *oc, void *data) pcc->mmu_model =POWERPC_MMU_2_07 ;#if defined(CONFIG_SOFTMMU ) pcc->handle_mmu_fault = ppc_hash64_handle_mmu_fault; + pcc->sps = &POWER7_POWER8_sps;#endif pcc->excp_model =POWERPC_EXCP_POWER7 ; pcc->bus_model =PPC_FLAGS_INPUT_POWER7 ;
Signature · 1 line
2.5.0