changeset 65ae342b627b in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=65ae342b627b
description:
        mem: Add support for secure packets in the snoop filter

        Secure and non-secure data can coexist in the cache and therefore the
        snoop filter should treat differently packets with secure and non
        secure accesses. This patch uses the lower bits of the line address to
        keep track of whether the packet is addressing secure memory or not.

        Change-Id: I54a5e614dad566a5083582bede86c86896f2c2c1
        Reviewed-by: Andreas Sandberg <[email protected]>
        Reviewed-by: Stephan Diestelhorst <[email protected]>
        Reviewed-by: Tony Gutierrez <[email protected]>

diffstat:

 src/mem/coherent_xbar.cc |   6 +++---
 src/mem/snoop_filter.cc  |  23 +++++++++++++++++++++--
 src/mem/snoop_filter.hh  |  12 ++++++++++--
 3 files changed, 34 insertions(+), 7 deletions(-)

diffs (134 lines):

diff -r b254396b7759 -r 65ae342b627b src/mem/coherent_xbar.cc
--- a/src/mem/coherent_xbar.cc  Fri Aug 12 14:11:45 2016 +0100
+++ b/src/mem/coherent_xbar.cc  Fri Aug 12 14:11:45 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2015 ARM Limited
+ * Copyright (c) 2011-2016 ARM Limited
  * All rights reserved
  *
  * The license below extends only to copyright in the software and shall
@@ -266,7 +266,7 @@
 
     if (snoopFilter && !system->bypassCaches()) {
         // Let the snoop filter know about the success of the send operation
-        snoopFilter->finishRequest(!success, addr);
+        snoopFilter->finishRequest(!success, addr, pkt->isSecure());
     }
 
     // check if we were successful in sending the packet onwards
@@ -666,7 +666,7 @@
             // operation, and do it even before sending it onwards to
             // avoid situations where atomic upward snoops sneak in
             // between and change the filter state
-            snoopFilter->finishRequest(false, pkt->getAddr());
+            snoopFilter->finishRequest(false, pkt->getAddr(), pkt->isSecure());
 
             snoop_result = forwardAtomic(pkt, slave_port_id, InvalidPortID,
                                          sf_res.first);
diff -r b254396b7759 -r 65ae342b627b src/mem/snoop_filter.cc
--- a/src/mem/snoop_filter.cc   Fri Aug 12 14:11:45 2016 +0100
+++ b/src/mem/snoop_filter.cc   Fri Aug 12 14:11:45 2016 +0100
@@ -69,6 +69,9 @@
     bool allocate = !cpkt->req->isUncacheable() && slave_port.isSnooping() &&
         cpkt->fromCache();
     Addr line_addr = cpkt->getBlockAddr(linesize);
+    if (cpkt->isSecure()) {
+        line_addr |= LineSecure;
+    }
     SnoopMask req_port = portToMask(slave_port);
     reqLookupResult = cachedLocations.find(line_addr);
     bool is_hit = (reqLookupResult != cachedLocations.end());
@@ -146,12 +149,16 @@
 }
 
 void
-SnoopFilter::finishRequest(bool will_retry, const Addr addr)
+SnoopFilter::finishRequest(bool will_retry, Addr addr, bool is_secure)
 {
     if (reqLookupResult != cachedLocations.end()) {
         // since we rely on the caller, do a basic check to ensure
         // that finishRequest is being called following lookupRequest
-        assert(reqLookupResult->first == (addr & ~(Addr(linesize - 1))));
+        Addr line_addr = (addr & ~(Addr(linesize - 1)));
+        if (is_secure) {
+            line_addr |= LineSecure;
+        }
+        assert(reqLookupResult->first == line_addr);
         if (will_retry) {
             // Undo any changes made in lookupRequest to the snoop filter
             // entry if the request will come again. retryItem holds
@@ -175,6 +182,9 @@
     assert(cpkt->isRequest());
 
     Addr line_addr = cpkt->getBlockAddr(linesize);
+    if (cpkt->isSecure()) {
+        line_addr |= LineSecure;
+    }
     auto sf_it = cachedLocations.find(line_addr);
     bool is_hit = (sf_it != cachedLocations.end());
 
@@ -243,6 +253,9 @@
     }
 
     Addr line_addr = cpkt->getBlockAddr(linesize);
+    if (cpkt->isSecure()) {
+        line_addr |= LineSecure;
+    }
     SnoopMask rsp_mask = portToMask(rsp_port);
     SnoopMask req_mask = portToMask(req_port);
     SnoopItem& sf_item = cachedLocations[line_addr];
@@ -289,6 +302,9 @@
     assert(cpkt->cacheResponding());
 
     Addr line_addr = cpkt->getBlockAddr(linesize);
+    if (cpkt->isSecure()) {
+        line_addr |= LineSecure;
+    }
     auto sf_it = cachedLocations.find(line_addr);
     bool is_hit = sf_it != cachedLocations.end();
 
@@ -328,6 +344,9 @@
 
     // next check if we actually allocated an entry
     Addr line_addr = cpkt->getBlockAddr(linesize);
+    if (cpkt->isSecure()) {
+        line_addr |= LineSecure;
+    }
     auto sf_it = cachedLocations.find(line_addr);
     if (sf_it == cachedLocations.end())
         return;
diff -r b254396b7759 -r 65ae342b627b src/mem/snoop_filter.hh
--- a/src/mem/snoop_filter.hh   Fri Aug 12 14:11:45 2016 +0100
+++ b/src/mem/snoop_filter.hh   Fri Aug 12 14:11:45 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013-2015 ARM Limited
+ * Copyright (c) 2013-2016 ARM Limited
  * All rights reserved
  *
  * The license below extends only to copyright in the software and shall
@@ -143,7 +143,7 @@
      * @param will_retry    This request will retry on this bus / snoop filter
      * @param addr          Packet address, merely for sanity checking
      */
-    void finishRequest(bool will_retry, const Addr addr);
+    void finishRequest(bool will_retry, Addr addr, bool is_secure);
 
     /**
      * Handle an incoming snoop from below (the master port). These
@@ -282,6 +282,14 @@
     /** Max capacity in terms of cache blocks tracked, for sanity checking */
     const unsigned maxEntryCount;
 
+    /**
+     * Use the lower bits of the address to keep track of the line status
+     */
+    enum LineStatus {
+        /** block holds data from the secure memory space */
+        LineSecure = 0x01,
+    };
+
     /** Statistics */
     Stats::Scalar totRequests;
     Stats::Scalar hitSingleRequests;
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to