mem: Use address range to find the right physical address
authorNikos Nikoleris <nikos.nikoleris@arm.com>
Mon, 4 Jun 2018 15:30:50 +0000 (16:30 +0100)
committerNikos Nikoleris <nikos.nikoleris@arm.com>
Tue, 19 Jun 2018 14:24:25 +0000 (14:24 +0000)
Previously, we used the start address to determine the right physical
memory while servicing memory requests. This change uses the full
address range to correctly determine the right physical memory and
expose bugs where requests might not fully map to a single physical
memory.

Change-Id: I183d7552918106000f917a62ceb877511ff0ff71
Reviewed-on: https://gem5-review.googlesource.com/11118
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Maintainer: Nikos Nikoleris <nikos.nikoleris@arm.com>

src/mem/physical.cc

index fdc88a8c098cdc2f43d7fcade413300dbd5b2f88..2806204305ca023f2bac234ea72e37f1ee242a7b 100644 (file)
@@ -278,8 +278,8 @@ void
 PhysicalMemory::access(PacketPtr pkt)
 {
     assert(pkt->isRequest());
-    Addr addr = pkt->getAddr();
-    const auto& m = addrMap.contains(addr);
+    AddrRange addr_range = RangeSize(pkt->getAddr(), pkt->getSize());
+    const auto& m = addrMap.contains(addr_range);
     assert(m != addrMap.end());
     m->second->access(pkt);
 }
@@ -288,8 +288,8 @@ void
 PhysicalMemory::functionalAccess(PacketPtr pkt)
 {
     assert(pkt->isRequest());
-    Addr addr = pkt->getAddr();
-    const auto& m = addrMap.contains(addr);
+    AddrRange addr_range = RangeSize(pkt->getAddr(), pkt->getSize());
+    const auto& m = addrMap.contains(addr_range);
     assert(m != addrMap.end());
     m->second->functionalAccess(pkt);
 }