1212c1212,1213
< CacheBlk *blk = tags->findVictim(addr);
---
> std::vector<CacheBlk*> evict_blks;
> CacheBlk *victim = tags->findVictim(addr, evict_blks);
1215c1216
< if (!blk)
---
> if (!victim)
1218,1233c1219,1229
< if (blk->isValid()) {
< Addr repl_addr = regenerateBlkAddr(blk);
< MSHR *repl_mshr = mshrQueue.findMatch(repl_addr, blk->isSecure());
< if (repl_mshr) {
< // must be an outstanding upgrade or clean request
< // on a block we're about to replace...
< assert((!blk->isWritable() && repl_mshr->needsWritable()) ||
< repl_mshr->isCleaning());
< // too hard to replace block with transient state
< // allocation failed, block not inserted
< return nullptr;
< } else {
< DPRINTF(Cache, "replacement: replacing %#llx (%s) with %#llx "
< "(%s): %s\n", repl_addr, blk->isSecure() ? "s" : "ns",
< addr, is_secure ? "s" : "ns",
< blk->isDirty() ? "writeback" : "clean");
---
> // Check for transient state allocations. If any of the entries listed
> // for eviction has a transient state, the allocation fails
> for (const auto& blk : evict_blks) {
> if (blk->isValid()) {
> Addr repl_addr = regenerateBlkAddr(blk);
> MSHR *repl_mshr = mshrQueue.findMatch(repl_addr, blk->isSecure());
> if (repl_mshr) {
> // must be an outstanding upgrade or clean request
> // on a block we're about to replace...
> assert((!blk->isWritable() && repl_mshr->needsWritable()) ||
> repl_mshr->isCleaning());
1234a1231,1252
> // too hard to replace block with transient state
> // allocation failed, block not inserted
> return nullptr;
> }
> }
> }
>
> // The victim will be replaced by a new entry, so increase the replacement
> // counter if a valid block is being replaced
> if (victim->isValid()) {
> DPRINTF(Cache, "replacement: replacing %#llx (%s) with %#llx "
> "(%s): %s\n", regenerateBlkAddr(victim),
> victim->isSecure() ? "s" : "ns",
> addr, is_secure ? "s" : "ns",
> victim->isDirty() ? "writeback" : "clean");
>
> replacements++;
> }
>
> // Evict valid blocks associated to this victim block
> for (const auto& blk : evict_blks) {
> if (blk->isValid()) {
1237a1256
>
1239d1257
< replacements++;
1243c1261
< return blk;
---
> return victim;