summaryrefslogtreecommitdiff
path: root/src/mem/cache/tags
diff options
context:
space:
mode:
authorGiacomo Gabrielli <Giacomo.Gabrielli@arm.com>2014-01-24 15:29:30 -0600
committerGiacomo Gabrielli <Giacomo.Gabrielli@arm.com>2014-01-24 15:29:30 -0600
commitaefe9cc624902fe26535028f86ba3a45f555bcf0 (patch)
tree4d775f34b34eeafc0c596b95aa071cc52fb94283 /src/mem/cache/tags
parent7f835a59f1c342eb1c170973ad53c493cc38e978 (diff)
downloadgem5-aefe9cc624902fe26535028f86ba3a45f555bcf0.tar.xz
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.
Diffstat (limited to 'src/mem/cache/tags')
-rw-r--r--src/mem/cache/tags/cacheset.hh14
-rw-r--r--src/mem/cache/tags/fa_lru.cc5
-rw-r--r--src/mem/cache/tags/fa_lru.hh7
-rw-r--r--src/mem/cache/tags/lru.cc15
-rw-r--r--src/mem/cache/tags/lru.hh7
5 files changed, 30 insertions, 18 deletions
diff --git a/src/mem/cache/tags/cacheset.hh b/src/mem/cache/tags/cacheset.hh
index 31eb28bf0..88e661cad 100644
--- a/src/mem/cache/tags/cacheset.hh
+++ b/src/mem/cache/tags/cacheset.hh
@@ -69,10 +69,11 @@ class CacheSet
* Find a block matching the tag in this set.
* @param way_id The id of the way that matches the tag.
* @param tag The Tag to find.
+ * @param is_secure True if the target memory space is secure.
* @return Pointer to the block if found. Set way_id to assoc if none found
*/
- Blktype* findBlk(Addr tag, int& way_id) const ;
- Blktype* findBlk(Addr tag) const ;
+ Blktype* findBlk(Addr tag, bool is_secure, int& way_id) const ;
+ Blktype* findBlk(Addr tag, bool is_secure) const ;
/**
* Move the given block to the head of the list.
@@ -90,7 +91,7 @@ class CacheSet
template <class Blktype>
Blktype*
-CacheSet<Blktype>::findBlk(Addr tag, int& way_id) const
+CacheSet<Blktype>::findBlk(Addr tag, bool is_secure, int& way_id) const
{
/**
* Way_id returns the id of the way that matches the block
@@ -98,7 +99,8 @@ CacheSet<Blktype>::findBlk(Addr tag, int& way_id) const
*/
way_id = assoc;
for (int i = 0; i < assoc; ++i) {
- if (blks[i]->tag == tag && blks[i]->isValid()) {
+ if (blks[i]->tag == tag && blks[i]->isValid() &&
+ blks[i]->isSecure() == is_secure) {
way_id = i;
return blks[i];
}
@@ -108,10 +110,10 @@ CacheSet<Blktype>::findBlk(Addr tag, int& way_id) const
template <class Blktype>
Blktype*
-CacheSet<Blktype>::findBlk(Addr tag) const
+CacheSet<Blktype>::findBlk(Addr tag, bool is_secure) const
{
int ignored_way_id;
- return findBlk(tag, ignored_way_id);
+ return findBlk(tag, is_secure, ignored_way_id);
}
template <class Blktype>
diff --git a/src/mem/cache/tags/fa_lru.cc b/src/mem/cache/tags/fa_lru.cc
index ddaa093d8..c3e2b66e4 100644
--- a/src/mem/cache/tags/fa_lru.cc
+++ b/src/mem/cache/tags/fa_lru.cc
@@ -171,7 +171,8 @@ FALRU::invalidate(FALRU::BlkType *blk)
}
FALRUBlk*
-FALRU::accessBlock(Addr addr, Cycles &lat, int context_src, int *inCache)
+FALRU::accessBlock(Addr addr, bool is_secure, Cycles &lat, int context_src,
+ int *inCache)
{
accesses++;
int tmp_in_cache = 0;
@@ -209,7 +210,7 @@ FALRU::accessBlock(Addr addr, Cycles &lat, int context_src, int *inCache)
FALRUBlk*
-FALRU::findBlock(Addr addr) const
+FALRU::findBlock(Addr addr, bool is_secure) const
{
Addr blkAddr = blkAlign(addr);
FALRUBlk* blk = hashLookup(blkAddr);
diff --git a/src/mem/cache/tags/fa_lru.hh b/src/mem/cache/tags/fa_lru.hh
index 3fbb8f0f4..1465bd861 100644
--- a/src/mem/cache/tags/fa_lru.hh
+++ b/src/mem/cache/tags/fa_lru.hh
@@ -182,20 +182,23 @@ public:
* access and should only be used as such.
* Returns the access latency and inCache flags as a side effect.
* @param addr The address to look for.
+ * @param is_secure True if the target memory space is secure.
* @param asid The address space ID.
* @param lat The latency of the access.
* @param inCache The FALRUBlk::inCache flags.
* @return Pointer to the cache block.
*/
- FALRUBlk* accessBlock(Addr addr, Cycles &lat, int context_src, int *inCache = 0);
+ FALRUBlk* accessBlock(Addr addr, bool is_secure, Cycles &lat,
+ int context_src, int *inCache = 0);
/**
* Find the block in the cache, do not update the replacement data.
* @param addr The address to look for.
+ * @param is_secure True if the target memory space is secure.
* @param asid The address space ID.
* @return Pointer to the cache block.
*/
- FALRUBlk* findBlock(Addr addr) const;
+ FALRUBlk* findBlock(Addr addr, bool is_secure) const;
/**
* Find a replacement block for the address provided.
diff --git a/src/mem/cache/tags/lru.cc b/src/mem/cache/tags/lru.cc
index 58f3f0977..ff0596987 100644
--- a/src/mem/cache/tags/lru.cc
+++ b/src/mem/cache/tags/lru.cc
@@ -127,11 +127,11 @@ LRU::~LRU()
}
LRU::BlkType*
-LRU::accessBlock(Addr addr, Cycles &lat, int master_id)
+LRU::accessBlock(Addr addr, bool is_secure, Cycles &lat, int master_id)
{
Addr tag = extractTag(addr);
unsigned set = extractSet(addr);
- BlkType *blk = sets[set].findBlk(tag);
+ BlkType *blk = sets[set].findBlk(tag, is_secure);
lat = hitLatency;
// Access all tags in parallel, hence one in each way. The data side
@@ -149,8 +149,8 @@ LRU::accessBlock(Addr addr, Cycles &lat, int master_id)
if (blk != NULL) {
// move this block to head of the MRU list
sets[set].moveToHead(blk);
- DPRINTF(CacheRepl, "set %x: moving blk %x to MRU\n",
- set, regenerateBlkAddr(tag, set));
+ DPRINTF(CacheRepl, "set %x: moving blk %x (%s) to MRU\n",
+ set, regenerateBlkAddr(tag, set), is_secure ? "s" : "ns");
if (blk->whenReady > curTick()
&& cache->ticksToCycles(blk->whenReady - curTick()) > hitLatency) {
lat = cache->ticksToCycles(blk->whenReady - curTick());
@@ -163,11 +163,11 @@ LRU::accessBlock(Addr addr, Cycles &lat, int master_id)
LRU::BlkType*
-LRU::findBlock(Addr addr) const
+LRU::findBlock(Addr addr, bool is_secure) const
{
Addr tag = extractTag(addr);
unsigned set = extractSet(addr);
- BlkType *blk = sets[set].findBlk(tag);
+ BlkType *blk = sets[set].findBlk(tag, is_secure);
return blk;
}
@@ -191,6 +191,7 @@ LRU::insertBlock(PacketPtr pkt, BlkType *blk)
Addr addr = pkt->getAddr();
MasterID master_id = pkt->req->masterId();
uint32_t task_id = pkt->req->taskId();
+ bool is_secure = pkt->isSecure();
if (!blk->isTouched) {
tagsInUse++;
blk->isTouched = true;
@@ -220,6 +221,8 @@ LRU::insertBlock(PacketPtr pkt, BlkType *blk)
blk->isTouched = true;
// Set tag for new block. Caller is responsible for setting status.
blk->tag = extractTag(addr);
+ if (is_secure)
+ blk->status |= BlkSecure;
// deal with what we are bringing in
assert(master_id < cache->system->maxMasters());
diff --git a/src/mem/cache/tags/lru.hh b/src/mem/cache/tags/lru.hh
index b9f8fc25c..9d438497a 100644
--- a/src/mem/cache/tags/lru.hh
+++ b/src/mem/cache/tags/lru.hh
@@ -148,20 +148,23 @@ public:
* NULL pointer is returned. This has all the implications of a cache
* access and should only be used as such. Returns the access latency as a side effect.
* @param addr The address to find.
+ * @param is_secure True if the target memory space is secure.
* @param asid The address space ID.
* @param lat The access latency.
* @return Pointer to the cache block if found.
*/
- BlkType* accessBlock(Addr addr, Cycles &lat, int context_src);
+ BlkType* accessBlock(Addr addr, bool is_secure, Cycles &lat,
+ int context_src);
/**
* Finds the given address in the cache, do not update replacement data.
* i.e. This is a no-side-effect find of a block.
* @param addr The address to find.
+ * @param is_secure True if the target memory space is secure.
* @param asid The address space ID.
* @return Pointer to the cache block if found.
*/
- BlkType* findBlock(Addr addr) const;
+ BlkType* findBlock(Addr addr, bool is_secure) const;
/**
* Find a block to evict for the address provided.