From dc2162dbff22cac3b497308d7b87bf154c5a5186 Mon Sep 17 00:00:00 2001 From: Erin Le Date: Mon, 22 Jul 2024 18:54:02 +0000 Subject: [PATCH] mem: Fix "Need is_secure arg" prefetcher crash This commit fixes the "Need is_secure arg" crash that occurs when using the IndirectMemoryPrefetcher, SignaturePathPrefetcher, SignaturePathPrefetcherV2, STeMSPrefetcher, and PIFPrefetcher. This was done by changing some variables to be AssociativeSet<...> instead of AssociativeCache<...> and changing the affected function calls. Change-Id: I61808c877514efeb73ad041de273ae386711acae --- src/mem/cache/prefetch/associative_set.hh | 2 +- src/mem/cache/prefetch/indirect_memory.cc | 4 ++-- src/mem/cache/prefetch/indirect_memory.hh | 2 +- src/mem/cache/prefetch/pif.cc | 8 +++++--- src/mem/cache/prefetch/pif.hh | 2 +- src/mem/cache/prefetch/signature_path.cc | 7 ++++--- src/mem/cache/prefetch/signature_path.hh | 2 +- src/mem/cache/prefetch/signature_path_v2.cc | 2 +- src/mem/cache/prefetch/signature_path_v2.hh | 2 +- .../cache/prefetch/spatio_temporal_memory_streaming.cc | 8 +++++--- .../cache/prefetch/spatio_temporal_memory_streaming.hh | 2 +- 11 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/mem/cache/prefetch/associative_set.hh b/src/mem/cache/prefetch/associative_set.hh index b73939fd5d..f7217a1e6b 100644 --- a/src/mem/cache/prefetch/associative_set.hh +++ b/src/mem/cache/prefetch/associative_set.hh @@ -90,7 +90,7 @@ class AssociativeSet : public AssociativeCache using AssociativeCache::accessEntryByAddr; using AssociativeCache::findEntry; using AssociativeCache::insertEntry; - using AssociativeCache::getPossibleEntries; + // using AssociativeCache::getPossibleEntries; using AssociativeCache::replPolicy; using AssociativeCache::indexingPolicy; diff --git a/src/mem/cache/prefetch/indirect_memory.cc b/src/mem/cache/prefetch/indirect_memory.cc index f689bff38c..169356277a 100644 --- a/src/mem/cache/prefetch/indirect_memory.cc +++ b/src/mem/cache/prefetch/indirect_memory.cc @@ -85,7 +85,7 @@ IndirectMemory::calculatePrefetch(const PrefetchInfo &pfi, } } else { // if misses are not being tracked, attempt to detect stream accesses - PrefetchTableEntry *pt_entry = prefetchTable.findEntry(pc); + PrefetchTableEntry *pt_entry = prefetchTable.findEntry(pc, is_secure); if (pt_entry != nullptr) { prefetchTable.accessEntry(pt_entry); @@ -159,7 +159,7 @@ IndirectMemory::calculatePrefetch(const PrefetchInfo &pfi, } else { pt_entry = prefetchTable.findVictim(pc); assert(pt_entry != nullptr); - prefetchTable.insertEntry(pc, pt_entry); + prefetchTable.insertEntry(pc, pt_entry-> secure, pt_entry); pt_entry->address = addr; pt_entry->secure = is_secure; } diff --git a/src/mem/cache/prefetch/indirect_memory.hh b/src/mem/cache/prefetch/indirect_memory.hh index 1062545301..00c89fd036 100644 --- a/src/mem/cache/prefetch/indirect_memory.hh +++ b/src/mem/cache/prefetch/indirect_memory.hh @@ -121,7 +121,7 @@ class IndirectMemory : public Queued } }; /** Prefetch table */ - AssociativeCache prefetchTable; + AssociativeSet prefetchTable; /** Indirect Pattern Detector entrt */ struct IndirectPatternDetectorEntry : public TaggedEntry diff --git a/src/mem/cache/prefetch/pif.cc b/src/mem/cache/prefetch/pif.cc index 138c89f08e..bfe53d0fc9 100644 --- a/src/mem/cache/prefetch/pif.cc +++ b/src/mem/cache/prefetch/pif.cc @@ -177,13 +177,15 @@ PIF::notifyRetiredInst(const Addr pc) // the 'iterator' table to point to the new entry historyBuffer.push_back(spatialCompactor); - auto idx_entry = index.findEntry(spatialCompactor.trigger); + auto idx_entry = index.findEntry(spatialCompactor.trigger, + false); if (idx_entry != nullptr) { index.accessEntry(idx_entry); } else { idx_entry = index.findVictim(spatialCompactor.trigger); assert(idx_entry != nullptr); - index.insertEntry(spatialCompactor.trigger, idx_entry); + index.insertEntry(spatialCompactor.trigger, false, + idx_entry); } idx_entry->historyIt = historyBuffer.getIterator(historyBuffer.tail()); @@ -219,7 +221,7 @@ PIF::calculatePrefetch(const PrefetchInfo &pfi, // Check if a valid entry in the 'index' table is found and allocate a new // active prediction stream - IndexEntry *idx_entry = index.findEntry(pc); + IndexEntry *idx_entry = index.findEntry(pc, false); if (idx_entry != nullptr) { index.accessEntry(idx_entry); diff --git a/src/mem/cache/prefetch/pif.hh b/src/mem/cache/prefetch/pif.hh index 3592397804..9422419db5 100644 --- a/src/mem/cache/prefetch/pif.hh +++ b/src/mem/cache/prefetch/pif.hh @@ -143,7 +143,7 @@ class PIF : public Queued * The index table is a small cache-like structure that facilitates * fast search of the history buffer. */ - AssociativeCache index; + AssociativeSet index; /** * A Stream Address Buffer (SAB) tracks a window of consecutive diff --git a/src/mem/cache/prefetch/signature_path.cc b/src/mem/cache/prefetch/signature_path.cc index 122c498be7..74eccbde77 100644 --- a/src/mem/cache/prefetch/signature_path.cc +++ b/src/mem/cache/prefetch/signature_path.cc @@ -192,7 +192,8 @@ SignaturePath::getSignatureEntry(Addr ppn, bool is_secure, SignaturePath::PatternEntry & SignaturePath::getPatternEntry(Addr signature) { - PatternEntry* pattern_entry = patternTable.findEntry(signature); + bool is_secure = false; + PatternEntry* pattern_entry = patternTable.findEntry(signature, is_secure); if (pattern_entry != nullptr) { // Signature found patternTable.accessEntry(pattern_entry); @@ -201,7 +202,7 @@ SignaturePath::getPatternEntry(Addr signature) pattern_entry = patternTable.findVictim(signature); assert(pattern_entry != nullptr); - patternTable.insertEntry(signature, pattern_entry); + patternTable.insertEntry(signature, is_secure, pattern_entry); } return *pattern_entry; } @@ -277,7 +278,7 @@ SignaturePath::calculatePrefetch(const PrefetchInfo &pfi, // confidence, these are prefetch candidates // - select the entry with the highest counter as the "lookahead" PatternEntry *current_pattern_entry = - patternTable.findEntry(current_signature); + patternTable.findEntry(current_signature, false); //, PatternStrideEntry const *lookahead = nullptr; if (current_pattern_entry != nullptr) { unsigned long max_counter = 0; diff --git a/src/mem/cache/prefetch/signature_path.hh b/src/mem/cache/prefetch/signature_path.hh index d5e1ea18ab..c4a640ae78 100644 --- a/src/mem/cache/prefetch/signature_path.hh +++ b/src/mem/cache/prefetch/signature_path.hh @@ -148,7 +148,7 @@ class SignaturePath : public Queued }; /** Pattern table */ - AssociativeCache patternTable; + AssociativeSet patternTable; /** * Generates a new signature from an existing one and a new stride diff --git a/src/mem/cache/prefetch/signature_path_v2.cc b/src/mem/cache/prefetch/signature_path_v2.cc index 518fc3e0e7..202a6ee7c8 100644 --- a/src/mem/cache/prefetch/signature_path_v2.cc +++ b/src/mem/cache/prefetch/signature_path_v2.cc @@ -125,7 +125,7 @@ SignaturePathV2::handlePageCrossingLookahead(signature_t signature, GlobalHistoryEntry *gh_entry = globalHistoryRegister.findVictim(0); assert(gh_entry != nullptr); // Any address value works, as it is never used - globalHistoryRegister.insertEntry(0, gh_entry); + globalHistoryRegister.insertEntry(0, false, gh_entry); // false, gh_entry->signature = signature; gh_entry->lastBlock = last_offset; diff --git a/src/mem/cache/prefetch/signature_path_v2.hh b/src/mem/cache/prefetch/signature_path_v2.hh index ee9e2cdc3c..417b7ec540 100644 --- a/src/mem/cache/prefetch/signature_path_v2.hh +++ b/src/mem/cache/prefetch/signature_path_v2.hh @@ -66,7 +66,7 @@ class SignaturePathV2 : public SignaturePath delta(0) {} }; /** Global History Register */ - AssociativeCache globalHistoryRegister; + AssociativeSet globalHistoryRegister; double calculateLookaheadConfidence(PatternEntry const &sig, PatternStrideEntry const &lookahead) const override; diff --git a/src/mem/cache/prefetch/spatio_temporal_memory_streaming.cc b/src/mem/cache/prefetch/spatio_temporal_memory_streaming.cc index c2f936b176..fe264ab5f7 100644 --- a/src/mem/cache/prefetch/spatio_temporal_memory_streaming.cc +++ b/src/mem/cache/prefetch/spatio_temporal_memory_streaming.cc @@ -92,12 +92,14 @@ STeMS::checkForActiveGenerationsEnd(const CacheAccessor &cache) } if (generation_ended) { // PST is indexed using the PC (secure bit is unused) - auto pst_entry = patternSequenceTable.findEntry(pst_addr); + auto pst_entry = patternSequenceTable.findEntry(pst_addr, + false); if (pst_entry == nullptr) { // Tipically an entry will not exist pst_entry = patternSequenceTable.findVictim(pst_addr); assert(pst_entry != nullptr); - patternSequenceTable.insertEntry(pst_addr, pst_entry); + patternSequenceTable.insertEntry(pst_addr, false, + pst_entry); } else { patternSequenceTable.accessEntry(pst_entry); } @@ -221,7 +223,7 @@ STeMS::reconstructSequence( idx = 0; for (auto it = rmob_it; it != rmob.end() && (idx < reconstructionEntries); it++) { - auto pst_entry = patternSequenceTable.findEntry(it->pstAddress); + auto pst_entry = patternSequenceTable.findEntry(it->pstAddress, false); if (pst_entry != nullptr) { patternSequenceTable.accessEntry(pst_entry); for (auto &seq_entry : pst_entry->sequence) { diff --git a/src/mem/cache/prefetch/spatio_temporal_memory_streaming.hh b/src/mem/cache/prefetch/spatio_temporal_memory_streaming.hh index 753c6a79b4..c6cd2f72d1 100644 --- a/src/mem/cache/prefetch/spatio_temporal_memory_streaming.hh +++ b/src/mem/cache/prefetch/spatio_temporal_memory_streaming.hh @@ -155,7 +155,7 @@ class STeMS : public Queued /** Active Generation Table (AGT) */ AssociativeSet activeGenerationTable; /** Pattern Sequence Table (PST) */ - AssociativeCache patternSequenceTable; + AssociativeSet patternSequenceTable; /** Data type of the Region Miss Order Buffer entry */ struct RegionMissOrderBufferEntry