aboutsummaryrefslogtreecommitdiff
path: root/target-sparc/helper.c
diff options
context:
space:
mode:
authorBlue Swirl <blauwirbel@gmail.com>2009-12-05 11:14:55 +0000
committerBlue Swirl <blauwirbel@gmail.com>2009-12-05 11:14:55 +0000
commit2a90358f8ae950a22efbfcc69e6142e86a38064e (patch)
tree909be74b0ee523728034b0e011563b84f2437b6d /target-sparc/helper.c
parentdd5121bd8a40fc8900ae3e741aea8eb2e3736839 (diff)
Sparc64: handle MMU global bit and nucleus context
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Diffstat (limited to 'target-sparc/helper.c')
-rw-r--r--target-sparc/helper.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/target-sparc/helper.c b/target-sparc/helper.c
index 1203105f47..a06923a8c1 100644
--- a/target-sparc/helper.c
+++ b/target-sparc/helper.c
@@ -388,7 +388,8 @@ static inline int compare_masked(uint64_t x, uint64_t y, uint64_t mask)
// requires virtual address mask value calculated from TTE entry size
static inline int ultrasparc_tag_match(SparcTLBEntry *tlb,
uint64_t address, uint64_t context,
- target_phys_addr_t *physical)
+ target_phys_addr_t *physical,
+ int is_nucleus)
{
uint64_t mask;
@@ -410,8 +411,9 @@ 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) &&
- compare_masked(address, tlb->tag, mask))
+ ((is_nucleus && compare_masked(0, tlb->tag, 0x1fff))
+ || TTE_IS_GLOBAL(tlb->tte) || compare_masked(context, tlb->tag, 0x1fff))
+ && compare_masked(address, tlb->tag, mask))
{
// decode physical address
*physical = ((tlb->tte & mask) | (address & ~mask)) & 0x1ffffffe000ULL;
@@ -427,6 +429,7 @@ static int get_physical_address_data(CPUState *env,
{
unsigned int i;
uint64_t context;
+ int is_nucleus;
if ((env->lsu & DMMU_E) == 0) { /* DMMU disabled */
*physical = ultrasparc_truncate_physical(address);
@@ -435,12 +438,13 @@ static int get_physical_address_data(CPUState *env,
}
context = env->dmmu.mmu_primary_context & 0x1fff;
+ is_nucleus = env->tl > 0;
for (i = 0; i < 64; i++) {
// ctx match, vaddr match, valid?
if (ultrasparc_tag_match(&env->dtlb[i],
- address, context, physical)
- ) {
+ address, context, physical,
+ is_nucleus)) {
// access ok?
if (((env->dtlb[i].tte & 0x4) && is_user) ||
(!(env->dtlb[i].tte & 0x2) && (rw == 1))) {
@@ -486,6 +490,7 @@ static int get_physical_address_code(CPUState *env,
{
unsigned int i;
uint64_t context;
+ int is_nucleus;
if ((env->lsu & IMMU_E) == 0 || (env->pstate & PS_RED) != 0) {
/* IMMU disabled */
@@ -495,12 +500,13 @@ static int get_physical_address_code(CPUState *env,
}
context = env->dmmu.mmu_primary_context & 0x1fff;
+ is_nucleus = env->tl > 0;
for (i = 0; i < 64; i++) {
// ctx match, vaddr match, valid?
if (ultrasparc_tag_match(&env->itlb[i],
- address, context, physical)
- ) {
+ address, context, physical,
+ is_nucleus)) {
// access ok?
if ((env->itlb[i].tte & 0x4) && is_user) {
if (env->immu.sfsr) /* Fault status register */
@@ -596,7 +602,7 @@ void dump_mmu(CPUState *env)
}
if ((env->dtlb[i].tte & 0x8000000000000000ULL) != 0) {
printf("[%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_t)~0x1fffULL,
env->dtlb[i].tte & (uint64_t)0x1ffffffe000ULL,
@@ -604,7 +610,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_t)0x1fffULL);
+ env->dtlb[i].tag & (uint64_t)0x1fffULL,
+ TTE_IS_GLOBAL(env->dtlb[i].tag)? "global" : "local");
}
}
}
@@ -630,14 +637,15 @@ void dump_mmu(CPUState *env)
}
if ((env->itlb[i].tte & 0x8000000000000000ULL) != 0) {
printf("[%02u] VA: %" PRIx64 ", PA: %" PRIx64
- ", %s, %s, %s, ctx %" PRId64 "\n",
+ ", %s, %s, %s, ctx %" PRId64 " %s\n",
i,
env->itlb[i].tag & (uint64_t)~0x1fffULL,
env->itlb[i].tte & (uint64_t)0x1ffffffe000ULL,
mask,
env->itlb[i].tte & 0x4? "priv": "user",
env->itlb[i].tte & 0x40? "locked": "unlocked",
- env->itlb[i].tag & (uint64_t)0x1fffULL);
+ env->itlb[i].tag & (uint64_t)0x1fffULL,
+ TTE_IS_GLOBAL(env->itlb[i].tag)? "global" : "local");
}
}
}