Commit 499fa2b4 authored by Maeva Ramarjiaona's avatar Maeva Ramarjiaona

Completing the new security category system (mostly to stay consistent with other analyses)

parent 4fcd6fe9
......@@ -7,21 +7,18 @@
#include <otawa/proc/AbstractFeature.h>
#include <otawa/icat3/features.h>
#include "ACSSecurity.h"
namespace lrusecurity {
// Exist-Hit
// Exist-Hit with previous access
extern otawa::p::feature EXIST_HIT_PREV_ANALYSIS_FEATURE;
extern otawa::p::id<otawa::icat3::Container<otawa::icat3::ACS> > EXIST_HIT_PREV_INIT;
extern otawa::p::id<otawa::icat3::Container<otawa::icat3::ACS> > EXIST_HIT_PREV_IN;
extern otawa::p::feature REFINEMENT_CATEGORY_FEATURE;
//hook: access
extern otawa::p::id<RefinementCategory> REFINEMENT_CATEGORY;
extern otawa::p::id<otawa::icat3::Container<ACSSecurity> > EXIST_HIT_PREV_INIT;
extern otawa::p::id<otawa::icat3::Container<ACSSecurity> > EXIST_HIT_PREV_IN;
// Classification printing
extern otawa::p::id<bool> CLASSIFICATION_TO_FILE;
extern otawa::p::id<elm::sys::Path> CLASSIFICATION_PATH;
enum class SecurityCategory{
SAFE,
UNSAFE
};
} // namespace lrusecurity
......
#ifndef LRUSECURITY_DU_CAT_BUILDER_H_
#define LRUSECURITY_DU_CAT_BUILDER_H_
#ifndef LRUSECURITY_SECURITY_CAT_BUILDER_H_
#define LRUSECURITY_SECURITY_CAT_BUILDER_H_
#include <otawa/proc/BBProcessor.h>
#include <otawa/icat3/features.h>
#include <otawa/hard/Memory.h>
#include <otawa/cfg/Loop.h>
#include <lrumc/ACSManager.h>
#include <lrusecurity/features.h>
#include <lrupreanalysis/features.h>
using namespace otawa;
namespace lrusecurity
{
class DUCatBuilder: public BBProcessor
class SecurityCatBuilder: public BBProcessor
{
public:
static p::declare reg;
DUCatBuilder(void): BBProcessor(reg), _ways(0), _man(nullptr)
SecurityCatBuilder(void): BBProcessor(reg), _ways(0), _man(nullptr)
{
}
......@@ -44,51 +44,39 @@ protected:
_man->start(v->toSynth()->callee()->exit());
else
_man->start(v);
processAccesses(*icache::ACCESSES(v));
processAccesses(*icache::ACCESSES(e));
processAccesses(*icache::ACCESSES(v), v);
processAccesses(*icache::ACCESSES(e), e);
}
}
void processAccesses(Bag<icache::Access>& accs) {
void processAccesses(Bag<icache::Access>& accs, Block *v) {
for(int i = 0; i < accs.count(); i++) {
otawa::icat3::LBlock *lb = icat3::LBLOCK(accs[i]);
int existHitAge = _man->existHitAge(lb);
int existMissAge = _man->existMissAge(lb);
bool eh = (existHitAge != _ways);
bool em = (existMissAge == _ways);
DUCategory cat;
if(eh && em)
cat = DUCategory::DU;
else if(eh)
cat = DUCategory::EH;
else if(em)
cat = DUCategory::EM;
SecurityCategory cat;
if (lrupreanalysis::ExactCategory(accs[i]) ==
lrupreanalysis::ExactCategory::DU) {
if (Loop::of(v) != Loop::top(v->cfg())) {
cat = SecurityCategory::UNSAFE;
}
else
cat = SecurityCategory::SAFE;
}
else
cat = DUCategory::NC;
cat = SecurityCategory::SAFE;
if(logFor(LOG_BLOCK)) {
log << "\t\t\t\t\tAccess " << accs[i] << " is ";
switch(cat) {
case DUCategory::DU:
log << "DU";
break;
case DUCategory::EH:
log << "EH";
break;
case DUCategory::EM:
log << "EM";
case SecurityCategory::SAFE:
log << "SAFE";
break;
case DUCategory::NC:
log << "NC";
case DUCategory::UNSAFE:
log << "UNSAFE";
break;
}
log << io::endl;
}
DU_CATEGORY(accs[i]) = cat;
SECURITY_CATEGORY(accs[i]) = cat;
_man->update(accs[i]);
}
}
......@@ -97,14 +85,13 @@ protected:
ACSManager* _man;
};
p::declare DUCatBuilder::reg = p::init("lrusecurity::DUCatBuilder", Version(1, 0, 0))
p::declare SecurityCatBuilder::reg = p::init("lrusecurity::SecurityCatBuilder", Version(1, 0, 0))
.extend<BBProcessor>()
.make<DUCatBuilder>()
.require(otawa::icat3::LBLOCKS_FEATURE)
.require(otawa::hard::MEMORY_FEATURE)
.require(lrusecurity::EXIST_HIT_ANALYSIS_FEATURE)
.require(lrusecurity::EXIST_MISS_ANALYSIS_FEATURE)
.provide(lrusecurity::DU_CATEGORY_FEATURE);
.require(lrupreanalysis::LRU_CLASSIFICATION_FEATURE)
.provide(lrusecurity::SECURITY_CATEGORY_FEATURE);
/**
......@@ -122,7 +109,7 @@ p::declare DUCatBuilder::reg = p::init("lrusecurity::DUCatBuilder", Version(1, 0
*
* @ingroup lrusecurity
*/
p::feature DU_CATEGORY_FEATURE("lrusecurity::DU_CATEGORY_FEATURE", DUCatBuilder::reg);
p::feature SECURITY_CATEGORY_FEATURE("lrusecurity::SECURITY_CATEGORY_FEATURE", SecurityCatBuilder::reg);
/**
......@@ -137,9 +124,9 @@ p::feature DU_CATEGORY_FEATURE("lrusecurity::DU_CATEGORY_FEATURE", DUCatBuilder:
*
* @ingroup lrusecurity
*/
p::id<DUCategory> DU_CATEGORY("lrusecurity::DU_CATEGORY", DUCategory::NC);
p::id<SecurityCategory> SECURITY_CATEGORY("lrusecurity::SECURITY_CATEGORY", SecurityCategory::SAFE);
} // namespace lrusecurity
#endif // LRUSECURITY_DU_CAT_BUILDER_H_
#endif // LRUSECURITY_SECURITY_CAT_BUILDER_H_
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