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
German Leon
Carol-fi
Commits
27bf99f6
Commit
27bf99f6
authored
Dec 22, 2020
by
German Leon
Browse files
Implementado INST_OUT
parent
cc607270
Changes
6
Show whitespace changes
Inline
Side-by-side
classes/BitFlip.py
View file @
27bf99f6
...
@@ -22,7 +22,7 @@ class BitFlip:
...
@@ -22,7 +22,7 @@ class BitFlip:
self
.
__fault_model
=
kwargs
.
get
(
'fault_model'
)
self
.
__fault_model
=
kwargs
.
get
(
'fault_model'
)
self
.
__logging
=
kwargs
.
get
(
'logging'
)
self
.
__logging
=
kwargs
.
get
(
'logging'
)
self
.
__injection_site
=
kwargs
.
get
(
'injection_site'
)
self
.
__injection_site
=
kwargs
.
get
(
'injection_site'
)
self
.
__maxregs
=
kwargs
.
get
(
'max_regs'
)
self
.
__maxregs
=
int
(
kwargs
.
get
(
'max_regs'
)
)
self
.
fault_injected
=
False
self
.
fault_injected
=
False
"""
"""
...
@@ -37,6 +37,100 @@ class BitFlip:
...
@@ -37,6 +37,100 @@ class BitFlip:
"""
"""
TODO: Describe the method
TODO: Describe the method
"""
"""
def
asmline
(
self
):
#Leo la linea de ejecucion
return
cf
.
execute_command
(
gdb
=
gdb
,
to_execute
=
"x/1i $pc"
)
def
reg_asmline
(
self
):
#Obtengo los registros de la instruccion
linea
=
self
.
asmline
()
self
.
__assmline
=
"ASSM_LINE:{}"
.
format
(
linea
[
0
])
#print (linea)#+"-"+str(len(linea))+"-"+linea[0])
#print ("============")
lista
=
re
.
findall
(
r
"R(\d+)"
,
linea
[
0
])
setlista
=
set
()
setlista
.
update
(
lista
)
#self.__logging.info(str(len(setlista)))
return
setlista
def
regmod
(
self
):
lista
=
self
.
reg_asmline
()
while
len
(
lista
)
==
0
:
#Habria que poner un limite.
#Busco una instruccion que referiencia algun registro
self
.
__logging
.
info
(
"INSTRUCTION WITHOUT DESTINATION REGISTER"
)
gdb
.
execute
(
"nexti"
)
lista
=
self
.
reg_asmline
()
listareg
=
[
" R{} "
.
format
(
x
)
for
x
in
lista
]
strlistareg
=
"info registers "
for
x
in
listareg
:
strlistareg
+=
x
;
#print (strlistareg)
self
.
__stringregs
=
strlistareg
#self.__logging.info("REFERED REGISTERS :"+strlistareg)
#Obtengo el valor de los registro referenciados
valores
=
cf
.
execute_command
(
gdb
=
gdb
,
to_execute
=
strlistareg
)
return
valores
def
nextinstr
(
self
):
#Obtengo el valor de los registro referenciados por la primera instruccipn
#self.__logging.info("===============================")
gdb
.
execute
(
"nexti"
)
#self.__logging.info("==============================="+self.__stringregs)
linea
=
self
.
asmline
()
#self.__logging.info("ASSM_LINE:{}".format(linea))
valores
=
cf
.
execute_command
(
gdb
=
gdb
,
to_execute
=
self
.
__stringregs
)
return
valores
def
dictreg
(
self
,
valores
):
#self.__logging.info("Execute dictreg")
#Almaceno en un dictionario los valores de los registros
regs
=
{}
for
x
in
valores
:
print
(
x
)
m
=
re
.
match
(
r
".*R(\d+).*0x([0-9a-fA-F]+).*"
,
x
)
if
m
:
regs
[
m
.
group
(
1
)]
=
m
.
group
(
2
)
print
(
str
(
m
.
group
(
1
))
+
":= "
+
str
(
m
.
group
(
2
)))
#print(regs)
#print ("========DR")
return
regs
def
cmpregdst
(
self
,
valores
,
regs
):
#Comparo los regsitros, para saber cuales he modificado.
#self.__logging.info("Execute cmpregdst------------")#+str(type(valores)))
regdst
=
set
()
#print("==cmpregdst")
#print("Arg;..valores...")
#print(type(valores))
#print (valores)
for
x
in
valores
:
m
=
re
.
match
(
r
".*R(\d+).*0x([0-9a-fA-F]+).*"
,
x
)
if
m
:
#print("El registro {} tiene {} y tenia{}".format(m.group(1),m.group(2),regs[m.group(1)]))
if
(
regs
[
m
.
group
(
1
)]
!=
m
.
group
(
2
)):
#print("Diferente")
regdst
.
add
(
m
.
group
(
1
))
#self.__logging.info(str(len(regdst)))
return
regdst
def
__inst_generic_injector
(
self
):
#def miinst_out():
#self.__logging.info("Comienzo")
regs
=
self
.
dictreg
(
self
.
regmod
())
#self.__logging.info("Reg1")
valores
=
self
.
nextinstr
()
#self.__logging.info("Ejecutado sfte instuccion")
r
=
self
.
cmpregdst
(
valores
,
regs
)
#self.__logging.info("Se han modificado {}".format(len(r)))
while
(
len
(
r
)
==
0
):
self
.
__logging
.
info
(
"INSTRUCTION WITHOUT OPERANDS"
)
gdb
.
execute
(
"nexti"
)
regs
=
self
.
dictreg
(
self
.
regmod
())
valores
=
self
.
nextinstr
()
r
=
self
.
cmpregdst
(
valores
,
regs
)
self
.
__register
=
"R{}"
.
format
(
r
.
pop
())
self
.
__logging
.
info
(
"SELECTED_REGISTER:{}"
.
format
(
self
.
__register
))
self
.
__logging
.
info
(
"ASSM_LINE:{}"
.
format
(
self
.
__assmline
))
# __rf_generic_injector will set fault_injected attribute
self
.
__rf_generic_injector
()
def
single_event
(
self
):
def
single_event
(
self
):
# fault_injected attribute will be set by the methods that perform fault injection
# fault_injected attribute will be set by the methods that perform fault injection
...
@@ -210,13 +304,14 @@ class BitFlip:
...
@@ -210,13 +304,14 @@ class BitFlip:
#self.__logging.info ("LIne salida:{}".format(m.group(1))
#self.__logging.info ("LIne salida:{}".format(m.group(1))
# max_num_register += 1
# max_num_register += 1
#self.__logging.info("LIne entrada {}--max{}".format(line,max_num_register))
#self.__logging.info("LIne entrada {}--max{}".format(line,max_num_register))
self
.
__register
=
"R{}"
.
format
(
random
.
randint
(
0
,
self
.
__maxregs
-
1
))
#self.__logging.info("MAX_NUM_REGISTER:{}".format(self.__maxregs))
self
.
__logging
.
info
(
"MAX_NUM_REGISTER:{}"
.
format
(
self
.
__maxregs
))
self
.
__register
=
"R{}"
.
format
(
random
.
randint
(
0
,
(
self
.
__maxregs
)
-
1
))
"""
"""
Instruction injector
Instruction injector
"""
"""
def
__inst_generic_injector
(
self
):
def
__inst_generic_injector
_old
(
self
):
disassemble_array
=
cf
.
execute_command
(
gdb
=
gdb
,
to_execute
=
"disassemble"
)
disassemble_array
=
cf
.
execute_command
(
gdb
=
gdb
,
to_execute
=
"disassemble"
)
# Search the line to inject
# Search the line to inject
# -1 will use the next instruction after program counter
# -1 will use the next instruction after program counter
...
...
classes/SignalApp.py
View file @
27bf99f6
...
@@ -48,7 +48,8 @@ class SignalApp(Thread):
...
@@ -48,7 +48,8 @@ class SignalApp(Thread):
#except threading.BrokenBarrierError:
#except threading.BrokenBarrierError:
except
:
except
:
(
self
.
_syncro
).
abort
()
(
self
.
_syncro
).
abort
()
print
(
"Breakpoint fuera de tiempo"
)
print
(
"Breakpoint inicial fuera de tiempo"
)
(
self
.
_syncro
).
reset
()
hang
=
True
hang
=
True
self
.
__log
.
info
(
"Timeout syncron of breakpoint
\n
"
)
self
.
__log
.
info
(
"Timeout syncron of breakpoint
\n
"
)
...
@@ -58,6 +59,13 @@ class SignalApp(Thread):
...
@@ -58,6 +59,13 @@ class SignalApp(Thread):
for
signals
in
range
(
0
,
self
.
__signals_to_send
):
for
signals
in
range
(
0
,
self
.
__signals_to_send
):
os
.
system
(
"{} > /dev/null 2>/dev/null"
.
format
(
self
.
__signal_cmd
))
os
.
system
(
"{} > /dev/null 2>/dev/null"
.
format
(
self
.
__signal_cmd
))
self
.
__log
.
info
(
"sending signal {}"
.
format
(
signals
))
self
.
__log
.
info
(
"sending signal {}"
.
format
(
signals
))
#try:
# (self._syncro).wait()
#except threading.BrokenBarrierError:
#except:
# (self._syncro).abort()
# print("Breakpoint fuera de tiempo")
#(self._syncro).reset()
time
.
sleep
(
self
.
__time_to_sleep
)
time
.
sleep
(
self
.
__time_to_sleep
)
(
self
.
_syncro
).
reset
()
(
self
.
_syncro
).
reset
()
try
:
try
:
...
...
classes/__pycache__/SignalApp.cpython-37.pyc
View file @
27bf99f6
No preview for this file type
codes/mmElem/matrixmul.conf
View file @
27bf99f6
...
@@ -17,7 +17,9 @@ faultModel = 0
...
@@ -17,7 +17,9 @@ faultModel = 0
# RF -> Register File
# RF -> Register File
# INST_OUT -> Instruction Output (NOT IMPLEMENTED YET)
# INST_OUT -> Instruction Output (NOT IMPLEMENTED YET)
# INST_composed -> Instruction Adress (NOT IMPLEMENTED YET)
# INST_composed -> Instruction Adress (NOT IMPLEMENTED YET)
injectionSite
=
RF
#injectionSite = RF
injectionSite
=
INST_OUT
# Max time factor to finish the app, this will be multiplied by the application running time
# Max time factor to finish the app, this will be multiplied by the application running time
# For example if your app spend 2s, and the maxWaitTimes is 5, the max running time before it is
# For example if your app spend 2s, and the maxWaitTimes is 5, the max running time before it is
# Considered as a crash is 10s
# Considered as a crash is 10s
...
...
fault_injector.py
View file @
27bf99f6
...
@@ -223,17 +223,22 @@ def check_sdcs_and_app_crash(logging, sdc_check_script, inj_output_path, inj_err
...
@@ -223,17 +223,22 @@ def check_sdcs_and_app_crash(logging, sdc_check_script, inj_output_path, inj_err
with
open
(
diff_log_path
,
'r'
)
as
fi
:
with
open
(
diff_log_path
,
'r'
)
as
fi
:
out_lines
=
fi
.
readlines
()
out_lines
=
fi
.
readlines
()
if
len
(
out_lines
)
!=
0
:
if
len
(
out_lines
)
!=
0
:
# Check if NVIDIA signals on output
# Check if NVIDIA signals on output
for
line
in
out_lines
:
for
line
in
out_lines
:
if
'PASS'
in
line
:
if
'PASS'
in
line
:
print
(
"PASS=="
+
line
+
"===="
)
is_masked
=
True
is_masked
=
True
break
break
if
'FAIL'
in
line
:
if
'FAIL'
in
line
:
print
(
"FAIL=="
+
line
+
"===="
)
is_sdc
=
True
is_sdc
=
True
break
break
for
carol_fi_signal
in
cp
.
SIGNALS
:
for
carol_fi_signal
in
cp
.
SIGNALS
:
for
line
in
out_lines
:
for
line
in
out_lines
:
if
carol_fi_signal
in
line
:
if
carol_fi_signal
in
line
:
print
(
"FAIL=="
+
line
+
"===="
)
is_app_crash
[
0
]
=
True
is_app_crash
[
0
]
=
True
if
len
(
is_app_crash
)
==
1
:
if
len
(
is_app_crash
)
==
1
:
is_app_crash
.
append
(
carol_fi_signal
)
is_app_crash
.
append
(
carol_fi_signal
)
...
@@ -300,7 +305,7 @@ def check_injection_outcome(host_thread, logging, injection_site):
...
@@ -300,7 +305,7 @@ def check_injection_outcome(host_thread, logging, injection_site):
# if fault was injected ASSM_LINE MUST be in the logfile
# if fault was injected ASSM_LINE MUST be in the logfile
assm_line
=
logging
.
search
(
"ASSM_LINE"
)
assm_line
=
logging
.
search
(
"ASSM_LINE"
)
instruction
=
re
.
match
(
r
".*:\t(\S+) .*"
,
assm_line
).
group
(
1
)
instruction
=
re
.
match
(
r
".*:\t(\S+) .*"
,
assm_line
).
group
(
1
)
instruction
=
assm_line
#
instruction = assm_line
except
TypeError
as
te
:
except
TypeError
as
te
:
instruction
=
new_value
=
old_value
=
None
instruction
=
new_value
=
old_value
=
None
...
@@ -333,7 +338,7 @@ def gdb_inject_fault(**kwargs):
...
@@ -333,7 +338,7 @@ def gdb_inject_fault(**kwargs):
seq_signals
=
kwargs
.
get
(
'seq_signals'
)
seq_signals
=
kwargs
.
get
(
'seq_signals'
)
init_sleep
=
kwargs
.
get
(
'init_sleep'
)
init_sleep
=
kwargs
.
get
(
'init_sleep'
)
sdc_check_script
=
kwargs
.
get
(
'gold_check_script'
)
sdc_check_script
=
kwargs
.
get
(
'gold_check_script'
)
maxregs
=
kwargs
.
get
(
'max_regs'
)
.
maxregs
=
kwargs
.
get
(
'max_regs'
)
# signalCmd
# signalCmd
signal_cmd
=
kwargs
.
get
(
"signal_cmd"
)
signal_cmd
=
kwargs
.
get
(
"signal_cmd"
)
...
@@ -357,7 +362,7 @@ def gdb_inject_fault(**kwargs):
...
@@ -357,7 +362,7 @@ def gdb_inject_fault(**kwargs):
logging
.
info
(
"Starting GDB script"
)
logging
.
info
(
"Starting GDB script"
)
# Generate configuration file for specific test
# Generate configuration file for specific test
gdb_env_string
=
"{}|{}|{}|{}|{}|{}|file {}; set args {}|{}"
.
format
(
gdb_kernel
,
os
.
getpid
(),
max
_
regs
,
","
.
join
(
str
(
i
)
for
i
in
bits_to_flip
),
fault_model
,
gdb_env_string
=
"{}|{}|{}|{}|{}|{}|file {}; set args {}|{}"
.
format
(
gdb_kernel
,
os
.
getpid
(),
maxregs
,
","
.
join
(
str
(
i
)
for
i
in
bits_to_flip
),
fault_model
,
flip_log_file
,
benchmark_binary
,
benchmark_args
,
flip_log_file
,
benchmark_binary
,
benchmark_args
,
injection_site
)
injection_site
)
...
...
flip_value.py
View file @
27bf99f6
...
@@ -38,9 +38,8 @@ def set_event(event):
...
@@ -38,9 +38,8 @@ def set_event(event):
bp
.
enabled
=
False
bp
.
enabled
=
False
gdb
.
execute
(
'c'
)
gdb
.
execute
(
'c'
)
# #os.system ("killall -2 python3")
# #os.system ("killall -2 python3")
el
se
:
el
if
(
isinstance
(
event
,
gdb
.
SignalEvent
))
:
try
:
try
:
# Just checking if it was hit
# Just checking if it was hit
if
bit_flip
.
fault_injected
is
False
:
if
bit_flip
.
fault_injected
is
False
:
bit_flip
.
single_event
()
bit_flip
.
single_event
()
...
@@ -49,7 +48,7 @@ def set_event(event):
...
@@ -49,7 +48,7 @@ def set_event(event):
except
Exception
as
err
:
except
Exception
as
err
:
global_logging
.
exception
(
"EVENT DIFFERENT FROM STOP SIGNAL: {}"
.
format
(
str
(
err
)))
global_logging
.
exception
(
"EVENT DIFFERENT FROM STOP SIGNAL: {}"
.
format
(
str
(
err
)))
#De esta forma, si llega un event por nexti (event.stop), no realiza nada.
"""
"""
Main function
Main function
"""
"""
...
...
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