aboutsummaryrefslogtreecommitdiff
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
parentdd5121bd8a40fc8900ae3e741aea8eb2e3736839 (diff)
downloadqemu-2a90358f8ae950a22efbfcc69e6142e86a38064e.zip
qemu-2a90358f8ae950a22efbfcc69e6142e86a38064e.tar.gz
qemu-2a90358f8ae950a22efbfcc69e6142e86a38064e.tar.bz2
Sparc64: handle MMU global bit and nucleus context
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
-rw-r--r--target-sparc/cpu.h2
-rw-r--r--target-sparc/helper.c30
2 files changed, 21 insertions, 11 deletions
diff --git a/target-sparc/cpu.h b/target-sparc/cpu.h
index 63aead9..1fe4d0f 100644
--- a/target-sparc/cpu.h
+++ b/target-sparc/cpu.h
@@ -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)
diff --git a/target-sparc/helper.c b/target-sparc/helper.c
index 1203105..a06923a 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");
}
}
}