changeset 9db8a438608c in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=9db8a438608c
description:
        kvm: Use the address finalization code in the TLB

        Reuse the address finalization code in the TLB instead of replicating
        it when handling MMIO. This patch also adds support for injecting
        memory mapped IPR requests into the memory system.

diffstat:

 src/cpu/kvm/base.cc |  23 ++++++++++++++++++++++-
 src/mem/request.hh  |  10 +++++-----
 2 files changed, 27 insertions(+), 6 deletions(-)

diffs (69 lines):

diff -r 8f1f1bdedf8c -r 9db8a438608c src/cpu/kvm/base.cc
--- a/src/cpu/kvm/base.cc       Tue Jun 18 16:10:22 2013 +0200
+++ b/src/cpu/kvm/base.cc       Tue Jun 18 16:10:22 2013 +0200
@@ -46,6 +46,7 @@
 #include <csignal>
 #include <ostream>
 
+#include "arch/mmapped_ipr.hh"
 #include "arch/utility.hh"
 #include "cpu/kvm/base.hh"
 #include "debug/Checkpoint.hh"
@@ -949,12 +950,32 @@
 Tick
 BaseKvmCPU::doMMIOAccess(Addr paddr, void *data, int size, bool write)
 {
+    ThreadContext *tc(thread->getTC());
+    syncThreadContext();
+
     mmio_req.setPhys(paddr, size, Request::UNCACHEABLE, dataMasterId());
+    // Some architectures do need to massage physical addresses a bit
+    // before they are inserted into the memory system. This enables
+    // APIC accesses on x86 and m5ops where supported through a MMIO
+    // interface.
+    BaseTLB::Mode tlb_mode(write ? BaseTLB::Write : BaseTLB::Read);
+    Fault fault(tc->getDTBPtr()->finalizePhysical(&mmio_req, tc, tlb_mode));
+    if (fault != NoFault)
+        warn("Finalization of MMIO address failed: %s\n", fault->name());
+
 
     const MemCmd cmd(write ? MemCmd::WriteReq : MemCmd::ReadReq);
     Packet pkt(&mmio_req, cmd);
     pkt.dataStatic(data);
-    return dataPort.sendAtomic(&pkt);
+
+    if (mmio_req.isMmappedIpr()) {
+        if (write)
+            return TheISA::handleIprWrite(tc, &pkt);
+        else
+            return TheISA::handleIprRead(tc, &pkt);
+    } else {
+        return dataPort.sendAtomic(&pkt);
+    }
 }
 
 void
diff -r 8f1f1bdedf8c -r 9db8a438608c src/mem/request.hh
--- a/src/mem/request.hh        Tue Jun 18 16:10:22 2013 +0200
+++ b/src/mem/request.hh        Tue Jun 18 16:10:22 2013 +0200
@@ -321,15 +321,15 @@
     }
 
     /**
-     * Set just the physical address.  This should only be used to
-     * record the result of a translation, and thus the vaddr must be
-     * valid before this method is called.  Otherwise, use setPhys()
-     * to guarantee that the size and flags are also set.
+     * Set just the physical address.  This usually used to record the
+     * result of a translation. However, when using virtualized CPUs
+     * setPhys() is sometimes called to finalize a physical address
+     * without a virtual address, so we can't check if the virtual
+     * address is valid.
      */
     void
     setPaddr(Addr paddr)
     {
-        assert(privateFlags.isSet(VALID_VADDR));
         _paddr = paddr;
         privateFlags.set(VALID_PADDR);
     }
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to