Commit 1a8ac300 authored by Maeva Ramarjiaona's avatar Maeva Ramarjiaona

some changes based around the new nature of ACSSecurity. Still might not be...

some changes based around the new nature of ACSSecurity. Still might not be the best way to represent what we want, but at least it compiles and somewhat works
parent aaa78d1a
#ifndef LRUSECURITY_ACSS_MANAGER_H_
#define LRUSECURITY_ACSS_MANAGER_H_
#include <otawa/icat3/features.h>
#include <otawa/cfg/features.h>
#include <lrumc/features.h>
namespace lrusecurity
{
class CacheState;
class ACSSManager
{
public:
ACSSManager(otawa::WorkSpace* ws);
~ACSSManager(void);
void start(otawa::Block* b);
void update(const otawa::icache::Access& acc);
int existHitAge(const otawa::icat3::LBlock* b);
otawa::Address prev(const otawa::icat3::LBlock *b);
void print(const otawa::icat3::LBlock* b, otawa::io::Output& out);
private:
CacheState& use(int set);
lrumc::ACSSManager _underlyingManager;
const otawa::icat3::LBlockCollection& _coll;
elm::Vector<int> _used;
otawa::Block* _b;
CacheState** _states;
bool _hasPrev;
};
} // namespace lrusecurity
#endif // LRUSECURITY_ACSS_MANAGER_H_
#ifndef LRUSECURITY_ACSSECURITY_H_H_
#define LRUSECURITY_ACSSECURITY_H_H_
#include <otawa/icache/features.h>
#include <otawa/icat3/features.h>
#include <otawa/base.h>
namespace lrusecurity
{
class ACSSecurity : public AllocArray<otawa::Address>
class ACSSecurity : public elm::AllocArray<otawa::Address>
{
public:
ACSSecurity();
ACSSecurity(int n, otawa::Adress ad = otawa::Address()){
for (int i = 0 ; i<n ; i++)
this.[i] = otawa::Address();
}
}
}
ACSSecurity() = default;
ACSSecurity(int n) : elm::AllocArray<otawa::Address>(n){
for (int i = 0; i < n; i++)
(*this)[i] = otawa::Address();
};
void print(int set, const otawa::icat3::LBlockCollection& coll, elm::io::Output& out= elm::cout) const;
};
}// namespace lrusecurity
#endif //LRUSECURITY_ACSSECURITY_H_H_
......@@ -19,8 +19,8 @@ enum class SecurityCategory{
SAFE,
UNSAFE
};
class ACSSManager
class CacheState;
class ACSSManager
{
public:
ACSSManager(otawa::WorkSpace *ws);
......@@ -37,9 +37,10 @@ private:
otawa::Block *_b;
CacheState **_states;
};
//Specifying which calls are making the program unsafe
extern otawa::p::feature SECURITY_CATEGORY_FEATURE;
extern otawa::p::id<SecurityCategory> SECURITY_CATEGORY;
extern otawa::p::id<SecurityCategory> SECURITY_CATEGORY;
} // namespace lrusecurity
......
......@@ -3,26 +3,19 @@
#include <otawa/icache/features.h>
#include <otawa/icat3/features.h>
#include <otawa/util/Bag.h>
#include <otawa/base.h>
namespace lrusecurity
{
class ACSSecurity
class ACSSecurity : public AllocArray<otawa::Address>
{
public:
ACSSecurity(){
_acs = otawa::icat3::ACS();
ACSSecurity();
ACSSecurity(int n){
for (int i = 0; i < n; i++)
(*this)[i] = otawa::Address();
};
inline ACSSecurity(otawa::icat3::ACS acs) {
this->_acs = acs;
this->_prev = otawa::Bag<otawa::icache::Access>();
}
void copy(ACSSecurity b){
_acs.copy(b._acs);
_prev = otawa::Bag<otawa::icache::Access>(b._prev);
};
otawa::icat3::ACS _acs;
otawa::Bag<otawa::icache::Access> _prev;
void print(int set, const otawa::icat3::LBlockCollection& coll, io::Output& out=cout) const;
};
}
#endif //LRUSECURITY_ACSSECURITY_H_H
#endif //LRUSECURITY_ACSSECURITY_H_H_
......@@ -31,7 +31,7 @@ public:
void update(otawa::Block *v, t& d);
private:
lrupreanalysis::ACSManager _mustManager;
lrumc::ACSManager _ehManager;
domain_t _domain;
graph_t _graph;
store_t _store;
......
......@@ -56,7 +56,7 @@ extern otawa::p::feature EXIST_HIT_PREV_ANALYSIS_FEATURE;
*
* @ingroup lrusecurity
*/
extern otawa::p::id<otawa::icat3::Container<lrusecurity::ACSSecurity> > EXIST_HIT_PREV_IN;
extern otawa::p::id<otawa::icat3::Container<ACSSecurity> > EXIST_HIT_PREV_IN;
/**
......@@ -70,7 +70,7 @@ extern otawa::p::feature EXIST_HIT_PREV_ANALYSIS_FEATURE;
*
* @ingroup lrusecurity
*/
extern otawa::p::id<otawa::icat3::Container<lrusecurity::ACSSecurity> > EXIST_HIT_PREV_INIT;
extern otawa::p::id<otawa::icat3::Container<ACSSecurity> > EXIST_HIT_PREV_INIT;
}; // namespace lrusecurity
......
......@@ -4,7 +4,8 @@
#include <otawa/icat3/features.h>
#include <otawa/icache/features.h>
#include <elm/io/Output.h>
#include <lrumc/features.h>
#include <lrumc/ACSManager.h>
#include <lrupreanalysis/features.h>
#include <lrusecurity/ACSSecurity.h>
namespace lrusecurity
......@@ -18,14 +19,14 @@ public:
inline const t& bot(void) const { return _bot; }
inline const t& top(void) const { return _top; }
inline const t& init(void) const { return _init; }
inline void print(const t& a, otawa::io::Output& out) const { a._acs.print(_set, _coll, out); }
inline void print(const t& a, otawa::io::Output& out) const { a.print(_set, _coll, out); }
inline elm::io::Printable<t, ExistHitPrevDomain> print(const t& a) const { return elm::io::p(a, *this); }
inline bool contains(const t& a, int i) { return(a._acs[i] != otawa::icat3::BOT_AGE); }
inline bool contains(const t& a, int i) { return(a[i] != otawa::Address()); }
inline void copy(t& d, const t& s) { d.copy(s); }
bool equals(const t& a, const t& b) const;
void join(t& d, const t& s);
void fetch(t& a, const otawa::icache::Access ac, lrupreanalysis::ACSManager& mustManager);
void update(const otawa::icache::Access& access, t& a, lrupreanalysis::ACSManager& mustManager);
void fetch(t& a, const otawa::icache::Access& ac, lrumc::ACSManager& ehManager);
void update(const otawa::icache::Access& access, t& a, lrumc::ACSManager& ehManager);
private:
int _n;
......
......@@ -11,7 +11,7 @@ ExistHitPrevAdapter::ExistHitPrevAdapter(
const icat3::LBlockCollection& coll,
const CFGCollection& cfgs,
otawa::WorkSpace* ws) :
_mustManager(ws),
_ehManager(ws),
_domain(coll, set, init),
_graph(cfgs),
_store(_domain, _graph)
......@@ -21,8 +21,8 @@ ExistHitPrevAdapter::ExistHitPrevAdapter(
void ExistHitPrevAdapter::update(const Bag<icache::Access>& accs, t& d)
{
for(int i = 0; i < accs.count(); i++) {
_domain.update(accs[i], d, _mustManager);
_mustManager.update(accs[i]);
_domain.update(accs[i], d, _ehManager);
_ehManager.update(accs[i]);
}
}
......@@ -36,7 +36,7 @@ void ExistHitPrevAdapter::update(Block *v, t& d)
Block *w = e->source();
_domain.copy(s, _store.get(w));
_mustManager.start(w);
_ehManager.start(w);
// apply block
{
......
......@@ -79,7 +79,7 @@ void ExistHitPrevAnalysis::processSet(int set, WorkSpace* ws)
// store the results
for(CFGCollection::BlockIter b(_cfgs); b; b++)
if(b->isBasic()) {
ada.domain().copy((*EXIST_HIT_PREV_IN(b))[set], ACSSecurity(ada.store().get(b)));
ada.domain().copy((*EXIST_HIT_PREV_IN(b))[set], ada.store().get(b));
if(logFor(LOG_BLOCK))
log << "\t\t\t" << *b << ": " << ada.domain().print(ada.store().get(b)) << io::endl;
}
......@@ -90,6 +90,7 @@ p::declare ExistHitPrevAnalysis::reg = p::init("lrusecurity::ExistHitPrevAnalysi
.require(COLLECTED_CFG_FEATURE)
.require(icat3::MUST_PERS_ANALYSIS_FEATURE)
.require(icat3::CATEGORY_FEATURE)
.require(lrumc::EXIST_HIT_ANALYSIS_FEATURE)
.provide(EXIST_HIT_PREV_ANALYSIS_FEATURE)
.make<ExistHitPrevAnalysis>();
......
......@@ -10,13 +10,13 @@ ExistHitPrevDomain::ExistHitPrevDomain(
int set,
const t *init) :
_n(coll[set].count()),
_bot(icat3::ACS(_n, icat3::BOT_AGE)),
_top(icat3::ACS(_n, 0)),
_bot(_n),
_top(_n),
_set(set),
_coll(coll),
_A(coll.A()),
_init(init ? *init : _top),
_tmp(icat3::ACS( _n))
_tmp(_n)
{
}
......@@ -30,29 +30,34 @@ bool ExistHitPrevDomain::equals(const t& acss, const t& bcss) const
void ExistHitPrevDomain::join(t& dcss, const t& scss)
{
for (int i = 0; i < _n; i++)
if (scss[i] != Address())
dcss[i] = scss[i];
}
void ExistHitPrevDomain::fetch(t& acss, const icat3::LBlock *lb, lrupreanalysis::ACSManager& mustManager)
void ExistHitPrevDomain::fetch(t& acss, const icache::Access& access, lrumc::ACSManager& ehManager)
{
int b = lb->index;
icat3::LBlock *lb = icat3::LBLOCK(access);
int b = lb->index();
for (int i = 0; i < _n; i++)
if (i == b)
acss[i] = access.address();
else if (ehManager.existHitAge(lb) == _A)
acss[i] = Address();
}
void ExistHitPrevDomain::update(const icache::Access& access, t& a, lrupreanalysis::ACSManager& mustManager)
void ExistHitPrevDomain::update(const icache::Access& access, t& a, lrumc::ACSManager& ehManager)
{
switch(access.kind()) {
case icache::FETCH:
if(_coll.cache()->set(access.address()) == _set)
fetch(a, access, mustManager);
fetch(a, access, ehManager);
break;
case icache::PREFETCH:
if(_coll.cache()->set(access.address()) == _set) {
copy(_tmp, a);
fetch(a, access, mustManager);
fetch(a, access, ehManager);
join(a, _tmp);
}
break;
......
#include <otawa/proc/ProcessorPlugin.h>
namespace lrusecurity {
using namespace elm;
using namespace otawa;
class Plugin: public ProcessorPlugin {
public:
Plugin(void): ProcessorPlugin("lrusecurity", Version(1, 0, 0), OTAWA_PROC_VERSION) { }
};
} // namespace lrusecurity
lrusecurity::Plugin lrusecurity_plugin;
ELM_PLUGIN(lrusecurity_plugin, OTAWA_PROC_HOOK);
......@@ -5,10 +5,8 @@
#include <otawa/proc/BBProcessor.h>
#include <otawa/prog/Process.h>
#include <otawa/icat3/features.h>
#include <otawa/icache/features.h>
using namespace otawa;
using namespace otawa;
namespace lrusecurity
{
......@@ -80,11 +78,11 @@ protected:
for(Block::EdgeIter edgeIter(bb->ins()); edgeIter; ++edgeIter) {
const Edge* e = *edgeIter;
const Bag<icache::Access>& bag = icache::ACCESSES(e);
const Bag<icache::Access>& bag = otawa::icache::ACCESSES(e);
processBag(ws, cfg, bag, bb);
}
const Bag<icache::Access>& bag = icache::ACCESSES(bb);
const Bag<icache::Access>& bag = otawa::icache::ACCESSES(bb);
processBag(ws, cfg, bag, bb);
}
......@@ -94,25 +92,22 @@ protected:
processAccess(ws, cfg, &bag[i], bb);
}
void processAccess(WorkSpace* ws, CFG*, const icache::Access* access, BasicBlock* bb)
void processAccess(WorkSpace* ws, CFG*, const otawa::icache::Access* access, BasicBlock* bb)
{
SecurityCategory cat = SECURITY_CATEGORY(access);
if(cat == SecurityCategory::UNSAFE){
_out << access->address() << "\t";
switch(access->kind()){
case icache::NONE: _out << "NONE\t"; break;
case icache::FETCH: _out << "FETCH\t"; break;
case icache::PREFETCH: _out << "PREFETCH\t"; break;
case otawa::icache::NONE: _out << "NONE\t"; break;
case otawa::icache::FETCH: _out << "FETCH\t"; break;
case otawa::icache::PREFETCH: _out << "PREFETCH\t"; break;
}
int set = icat3::LBLOCKS(ws)->cache()->set(access->address());
_out << "UNSAFE ";
int set = otawa::icat3::LBLOCK(access)->set();
if (bb->hasProp(EXIST_HIT_PREV_IN)) {
Bag<icache::Access> prev = (*EXIST_HIT_PREV_IN(bb))[set]._prev;
ACSSecurity prev = (*EXIST_HIT_PREV_IN(bb))[set];
for (int i = 0; i < prev.size(); ++i)
_out << prev[i].address();
_out << prev[i];
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment