From 71c6d12dab8ef57dfb2fd58511460c6ec1fb3eef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Berkay=20=C3=9Cr=C3=BCn?= Date: Mon, 4 Mar 2024 15:43:58 +0100 Subject: [PATCH] Variable length instructions for single faults --- controller.py | 3 --- goldenrun.py | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/controller.py b/controller.py index 5f564db..8c645a7 100755 --- a/controller.py +++ b/controller.py @@ -198,9 +198,6 @@ def build_fault_list(conf_list, combined_faults, ret_faults): for tcounter in build_ranges(faultdev["trigger_counter"]): for numbytes in build_ranges(faultdev["num_bytes"]): if isinstance(fmask, dict): - assert ( - wildcard_fault - ), "only wildcard faults can be evaluated, if fault.mask is a dict" assert ftype == detect_type( "instruction" ), "fault.type has to be 'instruction', if fault.mask is a dict" diff --git a/goldenrun.py b/goldenrun.py index c38dc81..1651168 100644 --- a/goldenrun.py +++ b/goldenrun.py @@ -108,6 +108,7 @@ def run_goldenrun( tbexec = pd.DataFrame(experiment["data"]["tbexec"]) tbinfo = pd.DataFrame(experiment["data"]["tbinfo"]) process_wildcard_faults(faultconfig, tbexec, tbinfo) + process_single_faults(faultconfig, tbexec, tbinfo) calculate_trigger_addresses(faultconfig, tbexec, tbinfo) faultconfig = checktriggers_in_tb(faultconfig, experiment["data"]) @@ -418,3 +419,34 @@ def process_wildcard_faults(faultconfig, tbexec, tbinfo): new_fault_entry["faultlist"] = [wildcard_faults[i]] new_fault_entry["delete"] = False faultconfig.append(new_fault_entry) + + +def process_single_faults(faultconfig, tbexec, tbinfo): + for faultentry in faultconfig: + for fault in faultentry["faultlist"]: + if not isinstance(fault.mask, dict): + continue + + tbinfo_tb_indexed = tbinfo.set_index("id") + for tb in tqdm(tbexec["tb"], leave=False): + tb_info_asm = tbinfo_tb_indexed.at[tb, "assembler"] + tb_info_total_size = tbinfo_tb_indexed.at[tb, "size"] + + tb_info_asm = [ + int(instr.split("]")[0], 16) + for instr in tb_info_asm.split("[ ")[1:] + ] + tb_info_size = list(numpy.diff(tb_info_asm)) + tb_info_size.append( + tb_info_total_size - sum(tb_info_size) + ) # calculate the last instr size + + try: + fault_inx = tb_info_asm.index(fault.address) + + fault.mask = fault.mask[str(tb_info_size[fault_inx])] + fault.num_bytes = tb_info_size[fault_inx] + + return + except ValueError: + pass