Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collection of various fixes #49

Merged
merged 11 commits into from
Aug 11, 2022
6 changes: 0 additions & 6 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -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
17 changes: 13 additions & 4 deletions controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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)
Expand Down
46 changes: 16 additions & 30 deletions faultclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"])
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions faultplugin/faultdata.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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");
Expand Down
6 changes: 3 additions & 3 deletions faultplugin/faultdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
4 changes: 2 additions & 2 deletions faultplugin/faultplugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions faultplugin/lib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
1 change: 0 additions & 1 deletion faultplugin/lib/avl
Submodule avl deleted from 9f30f7
Binary file removed faultplugin/lib/avl.o
Binary file not shown.
4 changes: 3 additions & 1 deletion hdf5logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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()
Expand Down
1 change: 0 additions & 1 deletion miniblink/libopencm3-examples
Submodule libopencm3-examples deleted from 3a8911