Sparc64: handle MMU global bit and nucleus context
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
This commit is contained in:
		
							parent
							
								
									dd5121bd8a
								
							
						
					
					
						commit
						2a90358f8a
					
				| @ -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) | ||||
|  | ||||
| @ -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"); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Blue Swirl
						Blue Swirl