Skip to content

Commit

Permalink
Merge pull request #58 from comparch-security/goodie-from-spike
Browse files Browse the repository at this point in the history
add good stuff form recent commits of the spike branch
  • Loading branch information
wsong83 authored Feb 1, 2024
2 parents 721b028 + 2f4d8d5 commit 3fbbfb2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@ endif

UTIL_HEADERS = $(wildcard util/*.hpp)
CACHE_HEADERS = $(wildcard cache/*.hpp)
DSL_HEADERS = $(wildcard dsl/*.hpp)

CRYPTO_LIB = cryptopp/libcryptopp.a
CACHE_OBJS = cache/metadata.o
UTIL_OBJS = util/random.o util/query.o util/monitor.o

all: libflexicas.a

.PONY: all

$(CRYPTO_LIB):
CXXFLAGS="-g0" $(MAKE) -C cryptopp -j$(NCORE)

Expand Down Expand Up @@ -65,6 +68,9 @@ regression: $(REGRESSION_TESTS_RST)
clean-regression:
-rm $(REGRESSION_TESTS_LOG) $(REGRESSION_TESTS_EXE) $(REGRESSION_TESTS_RST)

libflexicas.a: $(CACHE_OBJS) $(UTIL_OBJS) $(CRYPTO_LIB)
ar rvs $@ $(CACHE_OBJS) $(UTIL_OBJS) $(CRYPTO_LIB)

.PHONY: regression

clean:
Expand Down
3 changes: 3 additions & 0 deletions cache/cache.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ class CacheBase : public CacheMonitorSupport
virtual CMMetadataBase *meta_copy_buffer() = 0; // allocate a copy buffer, needed by exclusive cache with extended meta
virtual void meta_return_buffer(CMMetadataBase *buf) = 0; // return a copy buffer, used to detect conflicts in copy buffer

virtual std::tuple<int, int, int> size() const = 0; // return the size parameters of the cache
uint32_t get_id() const { return id; }
const std::string& get_name() const { return name;}

Expand Down Expand Up @@ -191,6 +192,8 @@ class CacheSkewed : public CacheBase
for(auto &buf: meta_buffer_state) delete buf.first;
}

virtual std::tuple<int, int, int> size() const { return std::make_tuple(P, 1ul<<IW, NW); }

virtual bool hit(uint64_t addr, uint32_t *ai, uint32_t *s, uint32_t *w ) {
for(*ai=0; *ai<P; (*ai)++) {
*s = indexer.index(addr, *ai);
Expand Down
12 changes: 12 additions & 0 deletions cache/coherence.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,18 @@ class CoreInterface : public InnerCohPortUncached {
assert(nullptr == "Error: L1.writeback_invalidate() is not implemented yet!");
}

// flush the whole cache
virtual void flush_cache(uint64_t *delay) {
auto [npar, nset, nway] = cache->size();
for(int ipar=0; ipar<npar; ipar++)
for(int iset=0; iset < nset; iset++)
for(int iway=0; iway < nway; iway++) {
auto [meta, data] = cache->access_line(ipar, iset, iway);
if(meta->is_valid())
flush_line(meta->addr(iset), policy->cmd_for_flush(), delay);
}
}

virtual void query_loc(uint64_t addr, std::list<LocInfo> *locs){
addr = normalize(addr);
outer->query_loc_req(addr, locs);
Expand Down

0 comments on commit 3fbbfb2

Please sign in to comment.