qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Andrew May <acmay@acmay.homeip.net>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] 4xx TLB fixes
Date: Mon, 8 Dec 2008 00:17:35 -0800	[thread overview]
Message-ID: <20081208001735.0244e189@acmay.homeip.net> (raw)

[-- Attachment #1: Type: text/plain, Size: 578 bytes --]

I don't all the details of the 4xx MMU stuff, but I think these 2 fixes
for the tlb handling are correct.

One is to ignore the Little endian bit if the page isn't valid. The
linux code reuses the registers when it invalidates a mapping. So any
invalidate of mappings 32-63, would trigger the abort.

The 2nd fix is to handle a change of a mapping from read-only to
read-write. I think the invalid is needed after this, but I am not sure.

With these my kernel boots, and starts to run userspace. But there it
doesn't finish running init. But my userspace FS may not be correct.

[-- Attachment #2: 4xx_tlb.patch --]
[-- Type: text/x-patch, Size: 1213 bytes --]

diff --git a/trunk/target-ppc/op_helper.c b/trunk/target-ppc/op_helper.c
--- a/trunk/target-ppc/op_helper.c
+++ b/trunk/target-ppc/op_helper.c
@@ -2806,7 +2806,7 @@ void do_4xx_tlbwe_hi (void)
         tlb->prot |= PAGE_VALID;
     else
         tlb->prot &= ~PAGE_VALID;
-    if (T1 & 0x20) {
+    if (T1 & 0x40 && T1 & 0x20) {
         /* XXX: TO BE FIXED */
         cpu_abort(env, "Little-endian TLB entries are not supported by now\n");
     }
@@ -2849,11 +2849,20 @@ void do_4xx_tlbwe_lo (void)
     T0 &= 0x3F;
     tlb = &env->tlb[T0].tlbe;
     tlb->RPN = T1 & 0xFFFFFC00;
-    tlb->prot = PAGE_READ;
+    tlb->prot &= ~(PAGE_EXEC | PAGE_WRITE);
+    tlb->prot |= PAGE_READ;
     if (T1 & 0x200)
         tlb->prot |= PAGE_EXEC;
     if (T1 & 0x100)
         tlb->prot |= PAGE_WRITE;
+
+    /* If the page is valid flush it for the prot change */
+    if (tlb->prot & PAGE_VALID) {
+            target_ulong page, end;
+        end = tlb->EPN + tlb->size;
+        for (page = tlb->EPN; page < end; page += TARGET_PAGE_SIZE)
+            tlb_flush_page(env, page);
+    }
 #if defined (DEBUG_SOFTWARE_TLB)
     if (loglevel != 0) {
         fprintf(logfile, "%s: set up TLB %d RPN " PADDRX " EPN " ADDRX

             reply	other threads:[~2008-12-08  8:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-08  8:17 Andrew May [this message]
2008-12-08 16:37 ` [Qemu-devel] 4xx TLB fixes Andreas Färber
2008-12-09 16:19 ` [Qemu-devel] " Andrew May

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20081208001735.0244e189@acmay.homeip.net \
    --to=acmay@acmay.homeip.net \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).