All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [Qemu-devel] Minor MMU fixes for PowerPC 40x emulation
@ 2010-10-02 16:54 John Clark
  0 siblings, 0 replies; 10+ messages in thread
From: John Clark @ 2010-10-02 16:54 UTC (permalink / raw)
  To: qemu-devel

>>             /* Check from TLB entry */
>> -            /* XXX: there is a problem here or in the TLB fill code... */
>> +            /* There is no longer a need to force PAGE_EXEC permission here */
>> +            /* because of the tlb->attr fix in helper_4xx_tlbwe_lo() */
> 
> I guess that comment is superfluous, as readers several years from now don't care what was broken back in the day :).

Yes, I suppose so :)

>> @@ -3939,7 +3939,7 @@ target_ulong helper_4xx_tlbre_lo (target_ulong entry)
>>     tlb = &env->tlb[entry].tlbe;
>>     ret = tlb->EPN;
>>     if (tlb->prot & PAGE_VALID)
>> -        ret |= 0x400;
>> +        ret |= 0x40;    /* V bit is 0x40, not 0x400 */
> 
> Ouch. Mind to make it a define?

Sure, I was surprised that there wasn't a define for that when I found it.

>>     size = booke_page_size_to_tlb(tlb->size);
>>     if (size < 0 || size > 0x7)
>>         size = 1;
>> @@ -3948,7 +3948,7 @@ target_ulong helper_4xx_tlbre_lo (target_ulong entry)
>>     return ret;
>> }
>>
>> -target_ulong helper_4xx_tlbre_hi (target_ulong entry)
>> +target_ulong helper_4xx_tlbre_lo (target_ulong entry)
> 
> Huh?

To summarize, 'tlbre' has two forms: one to retrieve the high bits of
a TLB entry (TLBHI), and one to retrieve the low bits (TLBLO) of a TLB
entry.  This code had the TLBLO form returning the bits corresponding
to TLBHI and vice versa, hence the name change.  You can verify this
if you like with this IBM PowerPC 405 core user manual on page 362:

https://www-01.ibm.com/chips/techlib/techlib.nsf/techdocs/D060DB54BD4DC4F2872569D2004A30D6/$file/ppc405fx_um.pdf

Thanks.

- John

^ permalink raw reply	[flat|nested] 10+ messages in thread
* [Qemu-devel] Minor MMU fixes for PowerPC 40x emulation
@ 2010-10-02  5:38 John Clark
  2010-10-02  9:35 ` Alexander Graf
  0 siblings, 1 reply; 10+ messages in thread
From: John Clark @ 2010-10-02  5:38 UTC (permalink / raw)
  To: qemu-devel

Hello,

I found I had to make a few minor changes to the MMU code for the
PowerPC 40x emulation to get NetBSD to run on a virtual PowerPC 405
core with qemu-system-ppcemb. The 'tlbre' instruction was not working,
and permission checking for a TLB entry was not as strict as it should
be. Diffs are included below.

Thank you.

- John Clark

diff --git a/target-ppc/helper.c b/target-ppc/helper.c
index 3bc8a34..a8c1802 100644
--- a/target-ppc/helper.c
+++ b/target-ppc/helper.c
@@ -1172,9 +1172,9 @@ static int mmu40x_get_physical_address (CPUState *env, mmu_ctx_t *ctx,
         case 0x1:
         check_perms:
             /* Check from TLB entry */
-            /* XXX: there is a problem here or in the TLB fill code... */
+            /* There is no longer a need to force PAGE_EXEC permission here */
+            /* because of the tlb->attr fix in helper_4xx_tlbwe_lo() */
             ctx->prot = tlb->prot;
-            ctx->prot |= PAGE_EXEC;
             ret = check_prot(ctx->prot, rw, access_type);
             if (ret == -2)
                 env->spr[SPR_40x_ESR] = 0;
diff --git a/target-ppc/op_helper.c b/target-ppc/op_helper.c
index 3e6db85..54356e8 100644
--- a/target-ppc/op_helper.c
+++ b/target-ppc/op_helper.c
@@ -3929,7 +3929,7 @@ static inline int booke_page_size_to_tlb(target_ulong page_size)
 }
 
 /* Helpers for 4xx TLB management */
-target_ulong helper_4xx_tlbre_lo (target_ulong entry)
+target_ulong helper_4xx_tlbre_hi (target_ulong entry)
 {
     ppcemb_tlb_t *tlb;
     target_ulong ret;
@@ -3939,7 +3939,7 @@ target_ulong helper_4xx_tlbre_lo (target_ulong entry)
     tlb = &env->tlb[entry].tlbe;
     ret = tlb->EPN;
     if (tlb->prot & PAGE_VALID)
-        ret |= 0x400;
+        ret |= 0x40;    /* V bit is 0x40, not 0x400 */
     size = booke_page_size_to_tlb(tlb->size);
     if (size < 0 || size > 0x7)
         size = 1;
@@ -3948,7 +3948,7 @@ target_ulong helper_4xx_tlbre_lo (target_ulong entry)
     return ret;
 }
 
-target_ulong helper_4xx_tlbre_hi (target_ulong entry)
+target_ulong helper_4xx_tlbre_lo (target_ulong entry)
 {
     ppcemb_tlb_t *tlb;
     target_ulong ret;

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2010-10-05 17:00 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-02 16:54 [Qemu-devel] Minor MMU fixes for PowerPC 40x emulation John Clark
  -- strict thread matches above, loose matches on Subject: below --
2010-10-02  5:38 John Clark
2010-10-02  9:35 ` Alexander Graf
     [not found]   ` <4CA762B1.7060505@runbox.com>
2010-10-02 16:55     ` Alexander Graf
2010-10-02 17:04       ` John Clark
2010-10-02 17:06       ` Edgar E. Iglesias
2010-10-02 17:10         ` Alexander Graf
2010-10-02 18:17         ` John Clark
2010-10-05 16:42           ` Alexander Graf
2010-10-05 17:00             ` Edgar E. Iglesias

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.