sparc64: implement global translation table entries
PATCH 1/1 sparc64: implement global translation table entries
From: Igor V. Kovalenko <[email protected]>
- match global tte against any context
- show global tte in MMU dump
Signed-off-by Igor V. Kovalenko <[email protected]>
--- target-sparc/cpu.h | 18 ++++++++++++++++ target-sparc/helper.c | 18 +++++++--------- target-sparc/op_helper.c | 53 ++++++++++++++++++++++++++++++++++++++-------- 3 files changed, 70 insertions(+), 19 deletions(-)
target-sparc/cpu.h +18 -0
@@ -277,10 +277,12 @@ enum {#define TTE_VALID_BIT (1ULL << 63)#define TTE_USED_BIT (1ULL << 41)#define TTE_LOCKED_BIT (1ULL << 6) +#define TTE_GLOBAL_BIT (1ULL << 0)#define TTE_IS_VALID (tte) ((tte) & TTE_VALID_BIT)#define TTE_IS_USED (tte) ((tte) & TTE_USED_BIT)#define TTE_IS_LOCKED (tte) ((tte) & TTE_LOCKED_BIT) +#define TTE_IS_GLOBAL (tte) ((tte) & TTE_GLOBAL_BIT)#define TTE_SET_USED (tte) ((tte) |= TTE_USED_BIT)#define TTE_SET_UNUSED (tte) ((tte) &= ~TTE_USED_BIT)
@@ -489,6 +491,22 @@ static inline void cpu_set_cwp(CPUSPARCState *env1, int new_cwp)/* sun4m.c, sun4u.c */ void cpu_check_irqs (CPUSPARCState *env); +#if defined (TARGET_SPARC64 ) + +static inline int compare_masked (uint64_t x,uint64_t y,uint64_t mask) +{ +return (x & mask) == (y & mask); +} + +#define MMU_CONTEXT_BITS 13 +#define MMU_CONTEXT_MASK ((1 << MMU_CONTEXT_BITS) - 1) + +static inline int tlb_compare_context (const SparcTLBEntry *tlb,uint64_t context) +{ +return compare_masked (context, tlb->tag,MMU_CONTEXT_MASK ); +} +#endif +static inline void PUT_PSR (CPUSPARCState *env1,target_ulong val) { env1->psr = val &PSR_ICC ;
target-sparc/helper.c +8 -10
@@ -379,11 +379,6 @@ static inline target_phys_addr_t ultrasparc_truncate_physical(uint64_t x)* UltraSparc IIi I/DMMUs */ -static inline int compare_masked (uint64_t x,uint64_t y,uint64_t mask) -{ -return (x & mask) == (y & mask); -} -// Returns true if TTE tag is valid and matches virtual address value in context // requires virtual address mask value calculated from TTE entry size static inline int ultrasparc_tag_match(SparcTLBEntry *tlb,
@@ -410,7 +405,8 @@ static inline int ultrasparc_tag_match(SparcTLBEntry *tlb,// valid, context match, virtual address match? if (TTE_IS_VALID (tlb->tte) && -compare_masked (context, tlb->tag,0x1fff ) && + (TTE_IS_GLOBAL (tlb->tte) || +tlb_compare_context (tlb, context)) &&compare_masked (address, tlb->tag, mask)) {// decode physical address
@@ -596,7 +592,7 @@ void dump_mmu(CPUState *env) }if ((env->dtlb[i].tte &0x8000000000000000ULL ) !=0 ) { fprintf(logfile, "[%02u] VA: %" PRIx64 ", PA: %" PRIx64 - ", %s, %s, %s, %s, ctx %" PRId64 "\n", + ", %s, %s, %s, %s, ctx %" PRId64 "%s\n", i, env->dtlb[i].tag & ~(__UINT64_C(0x1fff)), env->dtlb[i].tte & (__UINT64_C(0x1ffffffe000)),
@@ -604,7 +600,8 @@ void dump_mmu(CPUState *env) env->dtlb[i].tte &0x4 ?"priv" :"user" , env->dtlb[i].tte &0x2 ?"RW" :"RO" , env->dtlb[i].tte &0x40 ?"locked" :"unlocked" , - env->dtlb[i].tag & (__UINT64_C(0x1fff))); + env->dtlb[i].tag & (__UINT64_C (0x1fff )), + TTE_IS_GLOBAL(env->dtlb[i].tte) ? " (global)" : ""); } }
@@ -630,14 +627,15 @@ void dump_mmu(CPUState *env) }if ((env->itlb[i].tte &0x8000000000000000ULL ) !=0 ) {fprintf (logfile,"[%02u] VA: %" PRIx64", PA: %" PRIx64 -", %s, %s, %s, ctx %" PRId64"\n" , +", %s, %s, %s, ctx %" PRId64"%s\n" , i, env->itlb[i].tag & ~(__UINT64_C (0x1fff )), env->itlb[i].tte & (__UINT64_C (0x1ffffffe000 )), mask, env->itlb[i].tte &0x4 ?"priv" :"user" , env->itlb[i].tte &0x40 ?"locked" :"unlocked" , - env->itlb[i].tag & (__UINT64_C (0x1fff ))); + env->itlb[i].tag & (__UINT64_C (0x1fff )), +TTE_IS_GLOBAL (env->itlb[i].tte) ?" (global)" :"" ); } }
target-sparc/op_helper.c +44 -9
68 lines not on this page · raw message