diff --git a/.gitmodules b/.gitmodules index 215631c..a1a8b17 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,9 +1,3 @@ [submodule "qemu"] path = qemu url = https://github.com/Fraunhofer-AISEC/archie-qemu.git -[submodule "faultplugin/lib/avl"] - path = faultplugin/lib/avl - url = https://git.savannah.gnu.org/git/avl.git -[submodule "miniblink/libopencm3-examples"] - path = miniblink/libopencm3-examples - url = https://github.com/libopencm3/libopencm3-examples.git diff --git a/controller.py b/controller.py index f93a802..c98de43 100644 --- a/controller.py +++ b/controller.py @@ -3,6 +3,7 @@ import lzma from multiprocessing import Manager, Process import pandas as pd +from pathlib import Path import pickle import prctl import subprocess @@ -46,6 +47,8 @@ def build_ranges(fault_range): """ if isinstance(fault_range, dict): return build_ranges_dict(fault_range) + if type(fault_range) == int: + return range(fault_range, fault_range + 1, 1) if len(fault_range) == 3: return range(fault_range[0], fault_range[1], fault_range[2]) elif len(fault_range) == 1: @@ -171,10 +174,8 @@ def get_system_ram(): ps = subprocess.Popen( command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT ) - tmp = " " - while ps.poll() is None: - tmp = tmp + ps.stdout.read().decode("utf-8") - sp = tmp.split("kB") + tmp, _ = ps.communicate() + sp = str(tmp).split("kB") t = sp[0] mem = int(t.split(":")[1], 0) clogger.info("system ram is {}kB".format(mem)) @@ -471,6 +472,14 @@ def process_arguments(args): if args.compressionlevel is None: parguments["compressionlevel"] = 1 + hdf5file = Path(args.hdf5file) + if hdf5file.parent.exists() is False: + print( + f"Parent folder of specified HDF5 file does not exist: " + f"{hdf5file.parent}" + ) + exit(1) + qemu_conf = json.load(args.qemu) args.qemu.close() print(qemu_conf) diff --git a/faultclass.py b/faultclass.py index d406f91..712863c 100644 --- a/faultclass.py +++ b/faultclass.py @@ -48,22 +48,6 @@ def __init__( self.num_bytes = num_bytes def write_to_fifo(self, fifo): - "Write data to the config fifo, which sends binary data" - numbytes = fifo.write(self.address.to_bytes(8, byteorder="big")) - numbytes = numbytes + fifo.write(self.type.to_bytes(8, byteorder="big")) - numbytes = numbytes + fifo.write(self.model.to_bytes(8, byteorder="big")) - numbytes = numbytes + fifo.write(self.lifespan.to_bytes(8, byteorder="big")) - numbytes = numbytes + fifo.write(self.mask.to_bytes(16, byteorder="big")) - numbytes = numbytes + fifo.write( - self.trigger.address.to_bytes(8, byteorder="big") - ) - numbytes = numbytes + fifo.write( - self.trigger.hitcounter.to_bytes(8, byteorder="big") - ) - fifo.flush() - return numbytes - - def write_to_fifo_new(self, fifo): out = "\n$$[Fault]\n" out = out + "% {:d} | {:d} | {:d} | {:d} | {:d} | {:d} | ".format( self.address, @@ -73,10 +57,9 @@ def write_to_fifo_new(self, fifo): self.trigger.address, self.trigger.hitcounter, ) - tmp = self.mask - pow(2, 64) - if tmp < 0: - tmp = 0 - out = out + " {:d} {:d} ".format(tmp, self.mask - tmp) + mask_upper = (self.mask >> 64) & (pow(2, 64) - 1) + mask_lower = self.mask & (pow(2, 64) - 1) + out = out + " {:d} {:d} ".format(mask_upper, mask_lower) out = out + "| {:d} \n".format(self.num_bytes) out = out + "$$[Fault_Ende]\n" tmp = fifo.write(out) @@ -526,9 +509,12 @@ def readout_data( for (flag, keyword, data) in datasets: if not flag: continue - output[keyword] = write_output_wrt_goldenrun( - keyword, data, goldenrun_data - ) + if keyword.endswith("registers"): + output[keyword] = data.to_dict("records") + else: + output[keyword] = write_output_wrt_goldenrun( + keyword, data, goldenrun_data + ) if tbfaulted == 1: output["tbfaulted"] = tbfaultedlist @@ -649,21 +635,21 @@ def configure_qemu(control, config_qemu, num_faults, memorydump_list): if "tb_exec_list" in config_qemu: if config_qemu["tb_exec_list"] is False: - out = out + "$$disable_tb_exec_list" + out = out + "$$disable_tb_exec_list\n" else: - out = out + "$$enable_tb_exec_list" + out = out + "$$enable_tb_exec_list\n" if "tb_info" in config_qemu: if config_qemu["tb_info"] is False: - out = out + "$$disable_tb_info" + out = out + "$$disable_tb_info\n" else: - out = out + "$$enable_tb_info" + out = out + "$$enable_tb_info\n" if "mem_info" in config_qemu: if config_qemu["mem_info"] is False: - out = out + "$$disable_mem_info" + out = out + "$$disable_mem_info\n" else: - out = out + "$$enable_mem_info" + out = out + "$$enable_mem_info\n" if "start" in config_qemu: out = out + "$$ start_address: {}\n".format((config_qemu["start"])["address"]) @@ -752,7 +738,7 @@ def python_worker( logger.debug("Started QEMU") """Write faults to config pipe""" for fault in fault_list: - fault.write_to_fifo_new(config_fifo) + fault.write_to_fifo(config_fifo) logger.debug("Wrote config to qemu") """ From here Qemu has started execution. Now prepare for diff --git a/faultplugin/faultdata.c b/faultplugin/faultdata.c index 6478354..5a089c2 100644 --- a/faultplugin/faultdata.c +++ b/faultplugin/faultdata.c @@ -233,7 +233,7 @@ int read_memoryregion(uint64_t memorydump_position) return ret; } -int readout_memorydump_dump(uint64_t memorydump_position, uint64_t dump_pos) +void readout_memorydump_dump(uint64_t memorydump_position, uint64_t dump_pos) { g_autoptr(GString) out = g_string_new(""); memorydump_t *current = *(memdump + memorydump_position); @@ -267,7 +267,7 @@ int readout_memorydump_dump(uint64_t memorydump_position, uint64_t dump_pos) } } -int readout_memorydump(uint64_t memorydump_position) +void readout_memorydump(uint64_t memorydump_position) { g_autoptr(GString) out = g_string_new(""); memorydump_t *current = *(memdump + memorydump_position); @@ -284,7 +284,7 @@ int readout_memorydump(uint64_t memorydump_position) } -int readout_all_memorydump(void) +void readout_all_memorydump(void) { g_autoptr(GString) out = g_string_new(""); g_string_printf(out, "$$$[Memdump] \n"); diff --git a/faultplugin/faultdata.h b/faultplugin/faultdata.h index c671e8d..54725f7 100644 --- a/faultplugin/faultdata.h +++ b/faultplugin/faultdata.h @@ -105,7 +105,7 @@ int read_memoryregion(uint64_t memorydump_position); * @param memorydump_position: select which region should be read in vector element * @param dump_pos: select which data dump should be written to pipe. Multiple can be taken during the execution of the config. */ -int readout_memorydump_dump(uint64_t memorydump_position, uint64_t dump_pos); +void readout_memorydump_dump(uint64_t memorydump_position, uint64_t dump_pos); /** * readout_memorydump @@ -114,13 +114,13 @@ int readout_memorydump_dump(uint64_t memorydump_position, uint64_t dump_pos); * dumps are printed to data pipe. Also print config for this memorydump to data pipe * */ -int readout_memorydump(uint64_t memorydump_position); +void readout_memorydump(uint64_t memorydump_position); /** * readout_all_memorydump * * This function will send all memorydumps through the data pipe */ -int readout_all_memorydump(void); +void readout_all_memorydump(void); #endif diff --git a/faultplugin/faultplugin.c b/faultplugin/faultplugin.c index 6d7aa8c..0cf62e3 100644 --- a/faultplugin/faultplugin.c +++ b/faultplugin/faultplugin.c @@ -804,7 +804,7 @@ void plugin_end_information_dump() void tb_exec_end_max_event(unsigned int vcpu_index, void *vcurrent) { size_t ins = (size_t) vcurrent; - if(start_point.hitcounter != 3) + if(start_point.trignum != 3) { if(tb_counter >= tb_counter_max) { @@ -817,7 +817,7 @@ void tb_exec_end_max_event(unsigned int vcpu_index, void *vcurrent) void tb_exec_end_cb(unsigned int vcpu_index, void *vcurrent) { - if(start_point.hitcounter != 3) + if(start_point.trignum != 3) { qemu_plugin_outs("[End]: CB called\n"); if(end_point.hitcounter == 0) diff --git a/faultplugin/lib/README.md b/faultplugin/lib/README.md index 7514178..ea06e33 100644 --- a/faultplugin/lib/README.md +++ b/faultplugin/lib/README.md @@ -2,5 +2,3 @@ This avl library was taken from the GNU libavl. The source can be clonded from [here](git clone https://git.savannah.gnu.org/git/avl.git) The Website of the project can be found under [https://savannah.gnu.org/projects/avl/](https://savannah.gnu.org/projects/avl/) - -Furthermore the git is included as a subgit to this repository. diff --git a/faultplugin/lib/avl b/faultplugin/lib/avl deleted file mode 160000 index 9f30f77..0000000 --- a/faultplugin/lib/avl +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 9f30f77d3738c3a8ea199130ae98b9bf7bf8ac19 diff --git a/faultplugin/lib/avl.o b/faultplugin/lib/avl.o deleted file mode 100644 index f6e57bd..0000000 Binary files a/faultplugin/lib/avl.o and /dev/null differ diff --git a/hdf5logger.py b/hdf5logger.py index 24a2df8..f1d0e0f 100644 --- a/hdf5logger.py +++ b/hdf5logger.py @@ -44,6 +44,7 @@ class fault_table(tables.IsDescription): fault_type = tables.UInt8Col() fault_model = tables.UInt8Col() fault_lifespan = tables.UInt64Col() + fault_mask_upper = tables.UInt64Col() fault_mask = tables.UInt64Col() fault_num_bytes = tables.UInt8Col() @@ -225,7 +226,8 @@ def process_faults(f, group, faultlist, endpoint, myfilter): faultrow["fault_type"] = fault.type faultrow["fault_model"] = fault.model faultrow["fault_lifespan"] = fault.lifespan - faultrow["fault_mask"] = fault.mask + faultrow["fault_mask_upper"] = (fault.mask >> 64) & (pow(2, 64) - 1) + faultrow["fault_mask"] = fault.mask & (pow(2, 64) - 1) faultrow["fault_num_bytes"] = fault.num_bytes faultrow.append() faulttable.flush() diff --git a/miniblink/libopencm3-examples b/miniblink/libopencm3-examples deleted file mode 160000 index 3a89116..0000000 --- a/miniblink/libopencm3-examples +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 3a8911627d45e35ca081e3dbcc891fe3fcd1b13a