Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

lrusecurity_SecurityCatBuilder.cpp 3.31 KB
Newer Older
1
2
#ifndef LRUSECURITY_SECURITY_CAT_BUILDER_H_
#define LRUSECURITY_SECURITY_CAT_BUILDER_H_
3
4
5
6
7
8

#include <otawa/proc/BBProcessor.h>
#include <otawa/icat3/features.h>
#include <otawa/hard/Memory.h>
#include <lrumc/ACSManager.h>
#include <lrusecurity/features.h>
Valentin Touzeau's avatar
Valentin Touzeau committed
9
#include <lruexact/features.h>
10
11
12
13
14
using namespace otawa;

namespace lrusecurity
{

15
  class SecurityCatBuilder: public BBProcessor
16
17
18
{
public:
	static p::declare reg;
19
	SecurityCatBuilder(void): BBProcessor(reg), _ways(0), _man(nullptr)
20
21
22
23
24
25
26
27
28
29
	{
	}

protected:

	virtual void setup(WorkSpace *ws)
	{
		const otawa::icat3::LBlockCollection* coll = icat3::LBLOCKS(ws);
		ASSERT(coll);
		_ways = coll->A();
Maeva Ramarjiaona's avatar
Maeva Ramarjiaona committed
30
		_man = new lrumc::ACSManager(ws);
31
32
33
34
35
36
	}

	virtual void cleanup(WorkSpace*) {
		delete _man;
	}

Maeva Ramarjiaona's avatar
Maeva Ramarjiaona committed
37
	virtual void processBB(WorkSpace*, CFG* cfg, Block *v)
38
39
40
41
42
43
44
45
	{
		for(Block::EdgeIter e = v->outs(); e; e++) {
			if(logFor(LOG_BLOCK))
				log << "\t\t\t\tprocess " << *e << io::endl;
			if(v->isSynth() && v->toSynth()->callee())
				_man->start(v->toSynth()->callee()->exit());
			else
				_man->start(v);
Maeva Ramarjiaona's avatar
Maeva Ramarjiaona committed
46
47
48
49
			//otawa::sgraph::LoopIdentifier loopv = otawa::sgraph::LoopIdentifier::loopOf(v);
			///otawa::sgraph::LoopIdentifier loope = otawa::sgraph::LoopIdentifier::loopOf(e.sink());
			processAccesses(*icache::ACCESSES(v));
			processAccesses(*icache::ACCESSES(e));
50
51
52
		}
	}

Maeva Ramarjiaona's avatar
Maeva Ramarjiaona committed
53
  void processAccesses(Bag<icache::Access>& accs) {
54
		for(int i = 0; i < accs.count(); i++) {
55
		  lrusecurity::SecurityCategory cat;
Valentin Touzeau's avatar
Valentin Touzeau committed
56
57
		        if (lruexact::EXACT_CATEGORY(accs[i]) ==
			    lruexact::ExactCategory::DU)
58
			    cat = SecurityCategory::UNSAFE;
59
			else
60
			  cat = SecurityCategory::SAFE;
61
62
63
64

			if(logFor(LOG_BLOCK)) {
				log << "\t\t\t\t\tAccess " << accs[i] << " is ";
				switch(cat) {
65
66
					case SecurityCategory::SAFE:
						log << "SAFE";
67
					break;
68
					case SecurityCategory::UNSAFE:
69
						log << "UNSAFE";
70
71
72
73
74
					break;
				}
				log << io::endl;
			}

75
			SECURITY_CATEGORY(accs[i]) = cat;
76
77
78
79
80
			_man->update(accs[i]);
		}
	}

	int _ways;
Maeva Ramarjiaona's avatar
Maeva Ramarjiaona committed
81
        lrumc::ACSManager* _man;
82
83
};

84
p::declare SecurityCatBuilder::reg = p::init("lrusecurity::SecurityCatBuilder", Version(1, 0, 0))
85
	.extend<BBProcessor>()
86
	.make<SecurityCatBuilder>()
87
88
	.require(otawa::icat3::LBLOCKS_FEATURE)
	.require(otawa::hard::MEMORY_FEATURE)
Valentin Touzeau's avatar
Valentin Touzeau committed
89
        .require(lruexact::LRU_CLASSIFICATION_FEATURE)
90
	.provide(lrusecurity::SECURITY_CATEGORY_FEATURE);
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107


/**
 * This feature ensures that definitely unknown category information is stored on each
 * @ref icache::Access found in the blocks and in the CFG of the current workspace.
 * Such information is made of @ref DUCategory specifying the behaviour of the cache
 * (EH -- Exist Hit, EM -- Exist Miss, DU -- Definitely Unknown (Exist Hit and Exist
 * Miss), NC -- Not-classified).
 *
 * @par Properties
 * @li @ref DU_CATEGORY
 *
 * @par Default implementation
 * @li @ref DUCatBuilder
 *
 * @ingroup lrusecurity
 */
108
p::feature SECURITY_CATEGORY_FEATURE("lrusecurity::SECURITY_CATEGORY_FEATURE", SecurityCatBuilder::reg);
109
110
111
112
113
114
115
116
117
118
119
120
121
122


/**
 * Defines the instruction cache Definitely Unknown category for the @ref icache::Access where
 * this property is set.
 *
 * @par Hooks
 * @li @ref icache::Access
 *
 * @par Features
 * @li @ref DU_CATEGORY_FEATURE
 *
 * @ingroup lrusecurity
 */
123
p::id<SecurityCategory> SECURITY_CATEGORY("lrusecurity::SECURITY_CATEGORY", SecurityCategory::SAFE);
124
125
126

} // namespace lrusecurity

127
#endif // LRUSECURITY_SECURITY_CAT_BUILDER_H_
128