Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Valentin Touzeau
lrusecurity
Commits
499fa2b4
Commit
499fa2b4
authored
Jan 24, 2019
by
Maeva Ramarjiaona
Browse files
Completing the new security category system (mostly to stay consistent with other analyses)
parent
4fcd6fe9
Changes
2
Hide whitespace changes
Inline
Side-by-side
include/lrusecurity/features.h
View file @
499fa2b4
...
...
@@ -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
...
...
src/lrusecurity_
DU
CatBuilder.cpp
→
src/lrusecurity_
Security
CatBuilder.cpp
View file @
499fa2b4
#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
DU
CatBuilder
:
public
BBProcessor
class
Security
CatBuilder
:
public
BBProcessor
{
public:
static
p
::
declare
reg
;
DU
CatBuilder
(
void
)
:
BBProcessor
(
reg
),
_ways
(
0
),
_man
(
nullptr
)
Security
CatBuilder
(
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
=
DU
Category
::
NC
;
cat
=
Security
Category
::
SAFE
;
if
(
logFor
(
LOG_BLOCK
))
{
log
<<
"
\t\t\t\t\t
Access "
<<
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
DU
CatBuilder
::
reg
=
p
::
init
(
"lrusecurity::
DU
CatBuilder"
,
Version
(
1
,
0
,
0
))
p
::
declare
Security
CatBuilder
::
reg
=
p
::
init
(
"lrusecurity::
Security
CatBuilder"
,
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"
,
DU
CatBuilder
::
reg
);
p
::
feature
SECURITY
_CATEGORY_FEATURE
(
"lrusecurity::
SECURITY
_CATEGORY_FEATURE"
,
Security
CatBuilder
::
reg
);
/**
...
...
@@ -137,9 +124,9 @@ p::feature DU_CATEGORY_FEATURE("lrusecurity::DU_CATEGORY_FEATURE", DUCatBuilder:
*
* @ingroup lrusecurity
*/
p
::
id
<
DU
Category
>
DU
_CATEGORY
(
"lrusecurity::
DU
_CATEGORY"
,
DU
Category
::
NC
);
p
::
id
<
Security
Category
>
SECURITY
_CATEGORY
(
"lrusecurity::
SECURITY
_CATEGORY"
,
Security
Category
::
SAFE
);
}
// namespace lrusecurity
#endif // LRUSECURITY_
DU
_CAT_BUILDER_H_
#endif // LRUSECURITY_
SECURITY
_CAT_BUILDER_H_
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment