mem-cache: Fix panic in Indirect Memory prefetcher
authorJavier Bueno <javier.bueno@metempsy.com>
Tue, 2 Apr 2019 21:39:06 +0000 (23:39 +0200)
committerJavier Bueno Hedo <javier.bueno@metempsy.com>
Wed, 3 Apr 2019 09:14:04 +0000 (09:14 +0000)
Memory requests with a size non-power-of-two and less than 8 values were causing
a panic, but there these should be allowed and ignored by the prefetcher.

Change-Id: I86baa60058cc8a7f232d6ba5748d4c24a463c840
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/17733
Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br>
Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
Maintainer: Nikos Nikoleris <nikos.nikoleris@arm.com>

src/mem/cache/prefetch/indirect_memory.cc

index 393958c5750f8174d79ec4e5a7694affb037ef3f..d49652fa883f0d7090482a0dab278d64ed58fb7a 100644 (file)
@@ -108,6 +108,7 @@ IndirectMemoryPrefetcher::calculatePrefetch(const PrefetchInfo &pfi,
 
                 if (!miss && !pfi.isWrite() && pfi.getSize() <= 8) {
                     int64_t index = 0;
+                    bool read_index = true;
                     switch(pfi.getSize()) {
                         case sizeof(uint8_t):
                             index = pfi.get<uint8_t>(byteOrder);
@@ -122,14 +123,15 @@ IndirectMemoryPrefetcher::calculatePrefetch(const PrefetchInfo &pfi,
                             index = pfi.get<uint64_t>(byteOrder);
                             break;
                         default:
-                            panic("Invalid access size\n");
+                            // Ignore non-power-of-two sizes
+                            read_index = false;
                     }
-                    if (!pt_entry->enabled) {
+                    if (read_index && !pt_entry->enabled) {
                         // Not enabled (no pattern detected in this stream),
                         // add or update an entry in the pattern detector and
                         // start tracking misses
                         allocateOrUpdateIPDEntry(pt_entry, index);
-                    } else {
+                    } else if (read_index) {
                         // Enabled entry, update the index
                         pt_entry->index = index;
                         if (!pt_entry->increasedIndirectCounter) {