mem: When loading an image directly in memory, use the right CL size.
authorGabe Black <gabeblack@google.com>
Fri, 25 Sep 2020 07:56:24 +0000 (00:56 -0700)
committerGabe Black <gabeblack@google.com>
Sat, 26 Sep 2020 01:16:40 +0000 (01:16 +0000)
Some code was added fairly recently which would load a memory image
into a memory directly in order to make it easier to set up ROMs.
Unfortunately, that code accidentally used the image size instead of
the cache line size when setting up the port proxy which would actually
write the data. This happens to work when the image size is a power of
two since that's all the proxy checks for, but there's no guarantee
that every image will be sized that way.

This change instead looks into the system object, retrieves the cache
line size from it, and uses that to set up the port proxy.

Change-Id: I227ac475b855d9516e1feb881769e12ec4e7d598
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/35155
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Maintainer: Jason Lowe-Power <power.jg@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
src/mem/abstract_mem.cc

index a5730c78de73c656e020eccb8fad229e480f5c28..2de77e9ec53766d6114b2ba2a1766e76ab6f98db 100644 (file)
@@ -93,7 +93,8 @@ AbstractMemory::initState()
     panic_if(!image_range.isSubset(range), "%s: memory image %s doesn't fit.",
              name(), file);
 
-    PortProxy proxy([this](PacketPtr pkt) { functionalAccess(pkt); }, size());
+    PortProxy proxy([this](PacketPtr pkt) { functionalAccess(pkt); },
+                    system()->cacheLineSize());
 
     panic_if(!image.write(proxy), "%s: Unable to write image.");
 }