Use a computed mask to mask out the fetch address and not a hard coded one.
authorGabe Black <gblack@eecs.umich.edu>
Wed, 11 Apr 2007 14:16:54 +0000 (14:16 +0000)
committerGabe Black <gblack@eecs.umich.edu>
Wed, 11 Apr 2007 14:16:54 +0000 (14:16 +0000)
--HG--
extra : convert_revision : c22907bed4b83f0dff51d2283dafe4f76fa9e94a

src/cpu/simple/base.cc

index c9d4f4c8f87d42f881d2d4c853df36e136754196..3d07961f14320df72c044c24fcb7a33845405594 100644 (file)
@@ -335,7 +335,11 @@ BaseSimpleCPU::setupFetchRequest(Request *req)
             thread->readNextPC());
 #endif
 
-    req->setVirt(0, thread->readPC() & ~3, sizeof(MachInst), 0,
+    // This will generate a mask which aligns the pc on MachInst size
+    // boundaries. It won't work for non-power-of-two sized MachInsts, but
+    // it will work better than a hard coded mask.
+    const Addr PCMask = ~(sizeof(MachInst) - 1);
+    req->setVirt(0, thread->readPC() & PCMask, sizeof(MachInst), 0,
             thread->readPC());
 
     Fault fault = thread->translateInstReq(req);