From aefe9cc624902fe26535028f86ba3a45f555bcf0 Mon Sep 17 00:00:00 2001 From: Giacomo Gabrielli Date: Fri, 24 Jan 2014 15:29:30 -0600 Subject: mem: Add support for a security bit in the memory system This patch adds the basic building blocks required to support e.g. ARM TrustZone by discerning secure and non-secure memory accesses. --- src/mem/cache/prefetch/base.cc | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) (limited to 'src/mem/cache/prefetch/base.cc') diff --git a/src/mem/cache/prefetch/base.cc b/src/mem/cache/prefetch/base.cc index ed7b63f82..c440978e6 100644 --- a/src/mem/cache/prefetch/base.cc +++ b/src/mem/cache/prefetch/base.cc @@ -122,9 +122,9 @@ BasePrefetcher::regStats() } inline bool -BasePrefetcher::inCache(Addr addr) +BasePrefetcher::inCache(Addr addr, bool is_secure) { - if (cache->inCache(addr)) { + if (cache->inCache(addr, is_secure)) { pfCacheHit++; return true; } @@ -132,9 +132,9 @@ BasePrefetcher::inCache(Addr addr) } inline bool -BasePrefetcher::inMissQueue(Addr addr) +BasePrefetcher::inMissQueue(Addr addr, bool is_secure) { - if (cache->inMissQueue(addr)) { + if (cache->inMissQueue(addr, is_secure)) { pfMSHRHit++; return true; } @@ -157,12 +157,14 @@ BasePrefetcher::getPacket() pf.pop_front(); Addr blk_addr = pkt->getAddr() & ~(Addr)(blkSize-1); + bool is_secure = pkt->isSecure(); - if (!inCache(blk_addr) && !inMissQueue(blk_addr)) + if (!inCache(blk_addr, is_secure) && !inMissQueue(blk_addr, is_secure)) // we found a prefetch, return it break; - DPRINTF(HWPrefetch, "addr 0x%x in cache, skipping\n", pkt->getAddr()); + DPRINTF(HWPrefetch, "addr 0x%x (%s) in cache, skipping\n", + pkt->getAddr(), is_secure ? "s" : "ns"); delete pkt->req; delete pkt; @@ -174,7 +176,8 @@ BasePrefetcher::getPacket() pfIssued++; assert(pkt != NULL); - DPRINTF(HWPrefetch, "returning 0x%x\n", pkt->getAddr()); + DPRINTF(HWPrefetch, "returning 0x%x (%s)\n", pkt->getAddr(), + pkt->isSecure() ? "s" : "ns"); return pkt; } @@ -185,12 +188,15 @@ BasePrefetcher::notify(PacketPtr &pkt, Tick tick) if (!pkt->req->isUncacheable() && !(pkt->req->isInstFetch() && onlyData)) { // Calculate the blk address Addr blk_addr = pkt->getAddr() & ~(Addr)(blkSize-1); + bool is_secure = pkt->isSecure(); // Check if miss is in pfq, if so remove it - std::list::iterator iter = inPrefetch(blk_addr); + std::list::iterator iter = inPrefetch(blk_addr, + is_secure); if (iter != pf.end()) { DPRINTF(HWPrefetch, "Saw a miss to a queued prefetch addr: " - "0x%x, removing it\n", blk_addr); + "0x%x (%s), removing it\n", blk_addr, + is_secure ? "s" : "ns"); pfRemovedMSHR++; delete iter->pkt->req; delete iter->pkt; @@ -239,7 +245,7 @@ BasePrefetcher::notify(PacketPtr &pkt, Tick tick) addr, *delayIter, time); // Check if it is already in the pf buffer - if (inPrefetch(addr) != pf.end()) { + if (inPrefetch(addr, is_secure) != pf.end()) { pfBufferHit++; DPRINTF(HWPrefetch, "Prefetch addr already in pf buffer\n"); continue; @@ -247,6 +253,8 @@ BasePrefetcher::notify(PacketPtr &pkt, Tick tick) // create a prefetch memreq Request *prefetchReq = new Request(*addrIter, blkSize, 0, masterId); + if (is_secure) + prefetchReq->setFlags(Request::SECURE); prefetchReq->taskId(ContextSwitchTaskId::Prefetcher); PacketPtr prefetch = new Packet(prefetchReq, MemCmd::HardPFReq); @@ -274,12 +282,13 @@ BasePrefetcher::notify(PacketPtr &pkt, Tick tick) } std::list::iterator -BasePrefetcher::inPrefetch(Addr address) +BasePrefetcher::inPrefetch(Addr address, bool is_secure) { // Guaranteed to only be one match, we always check before inserting std::list::iterator iter; for (iter = pf.begin(); iter != pf.end(); iter++) { - if ((iter->pkt->getAddr() & ~(Addr)(blkSize-1)) == address) { + if (((*iter).pkt->getAddr() & ~(Addr)(blkSize-1)) == address && + (*iter).pkt->isSecure() == is_secure) { return iter; } } -- cgit v1.2.3