Multi-Arch Support: We support IA-32, RISCV-32, and RISCV-64
This commit is contained in:
121
Makefile
121
Makefile
@ -6,12 +6,12 @@ all: help
|
||||
|
||||
BUILD_DIR := build-${ARCH}
|
||||
FAIL_BIN ?= ${BUILD_DIR}/bin
|
||||
BOCHS_RUNNER ?= ${FAIL_BIN}/bochs-experiment-runner
|
||||
FAIL_SERVER ?= ${FAIL_BIN}/generic-experiment-server
|
||||
FAIL_TRACE ?= ${FAIL_BIN}/fail-generic-tracing
|
||||
FAIL_INJECT ?= ${FAIL_BIN}/fail-generic-experiment
|
||||
FAIL_IMPORT ?= ${FAIL_BIN}/import-trace --enable-sanitychecks
|
||||
FAIL_IMPORT ?= ${FAIL_BIN}/import-trace --enable-sanitychecks
|
||||
FAIL_PRUNE ?= ${FAIL_BIN}/prune-trace
|
||||
BOCHS_RUNNER ?= ${FAIL_BIN}/bochs-experiment-runner
|
||||
|
||||
EXPERIMENTS := $(patsubst %.c,%,$(shell echo *.c))
|
||||
|
||||
@ -33,11 +33,10 @@ help:
|
||||
|
||||
docker:
|
||||
@echo Starting Docker with ARCH=$(ARCH)
|
||||
docker run \
|
||||
-v ${PWD}:/home/fail/fail \
|
||||
-e ARCH=${ARCH} \
|
||||
-w /home/fail/fail \
|
||||
-it danceos/fail-ci-build
|
||||
@echo "ARCH=${ARCH}" > .env.${ARCH}
|
||||
docker-compose --env-file .env.${ARCH} up -d
|
||||
docker-compose --env-file .env.${ARCH} run --entrypoint bash shell
|
||||
|
||||
|
||||
################################################################
|
||||
# Download
|
||||
@ -50,10 +49,10 @@ ${BUILD_DIR}/bin/fail-client:
|
||||
|
||||
|
||||
clean:
|
||||
@rm -rf build
|
||||
rm -rf ${BUILD_DIR}
|
||||
|
||||
clean-%:
|
||||
@rm -rf ${BUILD_DIR}/$(patsubst build-%,%,$@)
|
||||
rm -rf ${BUILD_DIR}/$(patsubst clean-%,%,$@)
|
||||
|
||||
build-%:
|
||||
@echo "****************************************************************\n\
|
||||
@ -65,36 +64,33 @@ build-%:
|
||||
****************************************************************"
|
||||
|
||||
|
||||
trace-%: %/system.elf %/system.iso
|
||||
${BOCHS_RUNNER} -e $< -i $(shell dirname $<)/system.iso -1 \
|
||||
-V vgabios.bin -b BIOS-bochs-latest \
|
||||
-f ${FAIL_TRACE} -- \
|
||||
-Wf,--start-symbol=os_main \
|
||||
-Wf,--save-symbol=os_main \
|
||||
-Wf,--end-symbol=stop_trace \
|
||||
-Wf,--check-bounds \
|
||||
-Wf,--state-file=$(shell dirname $<)/state \
|
||||
-Wf,--trace-file=$(shell dirname $<)/trace.pb -Wf,--elf-file=$< -q
|
||||
trace-%:
|
||||
@echo "****************************************************************\n\
|
||||
* The trace is now generated. It can be viewed with\n\
|
||||
*\n\
|
||||
* $ dump-trace $(shell dirname $<)/trace.pb\n\
|
||||
* $ make dump-$(patsubst trace-%,%,$@)\n\
|
||||
*\n\
|
||||
* Next, we have to import the trace into the database\n\
|
||||
*\n\
|
||||
* $ make import-$(shell dirname $<)\n\
|
||||
* $ make import-$(patsubst trace-%,%,$@)\n\
|
||||
****************************************************************"
|
||||
|
||||
dump-%: ${BUILD_DIR}/%/trace.pb
|
||||
${BUILD_DIR}/bin/dump-trace $(shell dirname $<)/trace.pb
|
||||
|
||||
import-%: %/trace.pb
|
||||
${FAIL_IMPORT} -t $< -i mem -e $(shell dirname $<)/system.elf -v $(shell dirname $<) -b mem
|
||||
${FAIL_IMPORT} -t $< -i regs -e $(shell dirname $<)/system.elf -v $(shell dirname $<) -b regs --flags
|
||||
${FAIL_IMPORT} -t $< -i regs -e $(shell dirname $<)/system.elf -v $(shell dirname $<) -b ip --no-gp --ip
|
||||
${FAIL_IMPORT} -t $< -i FullTraceImporter -v $(shell dirname $<) -b ip
|
||||
${FAIL_IMPORT} -t $< -i ElfImporter --objdump objdump -e $(shell dirname $<)/system.elf -v $(shell dirname $<) -b ip
|
||||
${FAIL_IMPORT} -t $< -i ElfImporter --objdump objdump -e $(shell dirname $<)/system.elf -v $(shell dirname $<) -b mem
|
||||
${FAIL_IMPORT} -t $< -i ElfImporter --objdump objdump -e $(shell dirname $<)/system.elf -v $(shell dirname $<) -b regs
|
||||
${FAIL_PRUNE} -v $(shell dirname $<) -b %% --overwrite
|
||||
${HOME}/.my.cnf:
|
||||
@echo "[client]" > $@
|
||||
@echo "user=fail" >> $@
|
||||
@echo "database=fail" >> $@
|
||||
@echo "password=fail" >> $@
|
||||
@echo "host=db" >> $@
|
||||
@echo "port=3306" >> $@
|
||||
|
||||
import-%: ${BUILD_DIR}/%/trace.pb ${HOME}/.my.cnf
|
||||
${FAIL_IMPORT} -v ${ARCH}/$(patsubst import-%,%,$@) -b mem -t $< -e $(shell dirname $<)/system.elf -i mem
|
||||
${FAIL_IMPORT} -v ${ARCH}/$(patsubst import-%,%,$@) -b regs -t $< -e $(shell dirname $<)/system.elf -i regs
|
||||
${FAIL_IMPORT} -v ${ARCH}/$(patsubst import-%,%,$@) -b ip -t $< -e $(shell dirname $<)/system.elf -i regs --no-gp --ip
|
||||
${FAIL_PRUNE} -v ${ARCH}/$(patsubst import-%,%,$@) -b %% --overwrite
|
||||
@echo "****************************************************************\n\
|
||||
* The golden run sits now within the MySQL database. If you are interested,\n\
|
||||
* use the 'mysql' command to inspect the curent state of the DB. The tables\n\
|
||||
@ -102,75 +98,26 @@ import-%: %/trace.pb
|
||||
*\n\
|
||||
* Next, we have to run the campaign sever and the injection client\n\
|
||||
*\n\
|
||||
* $ make server-$(shell dirname $<) &\n\
|
||||
* $ make client-$(shell dirname $<) \n\
|
||||
* $ make server-$(patsubst import-%,%,$@) &\n\
|
||||
* $ make client-$(patsubst import-%,%,$@) \n\n\
|
||||
* Afterwards, the results can be viewd with\n\
|
||||
* $ make result-$(subst import-,,$@)\n\
|
||||
****************************************************************"
|
||||
|
||||
server-%:
|
||||
${FAIL_SERVER} -v $(subst server-,,$@) -b %
|
||||
|
||||
|
||||
import-jump-%: %/trace.pb
|
||||
${FAIL_BIN}/import-trace -t $< -i RandomJumpImporter \
|
||||
--jump-from $(shell dirname $<).map \
|
||||
--jump-to $(shell dirname $<).map \
|
||||
-e $(shell dirname $<)/system.elf \
|
||||
-v $(shell dirname $<)/jump -b jump
|
||||
${FAIL_PRUNE} -v $(shell dirname $<)/jump -b %% --overwrite
|
||||
|
||||
server-jump-%:
|
||||
${FAIL_SERVER} --inject-randomjumps -v $(subst server-jump-,,$@)/jump -b %
|
||||
|
||||
|
||||
client-%:
|
||||
${BOCHS_RUNNER} -e $(subst client-,,$@)/system.elf \
|
||||
-j $(shell getconf _NPROCESSORS_ONLN) \
|
||||
-i $(subst client-,,$@)/system.iso \
|
||||
-V vgabios.bin -b BIOS-bochs-latest \
|
||||
-f ${FAIL_INJECT} -- \
|
||||
-Wf,--state-dir=$(subst client-,,$@)/state \
|
||||
-Wf,--trap -Wf,--timeout=10 \
|
||||
-Wf,--ok-marker=stop_trace \
|
||||
-Wf,--fail-marker=fail_marker \
|
||||
-Wf,--catch-write-textsegment \
|
||||
-Wf,--catch-outerspace \
|
||||
2>/dev/null | grep -B 2 -A 8 'INJECT'
|
||||
|
||||
inject-%:
|
||||
${BOCHS_RUNNER} -e $(subst inject-,,$@)/system.elf \
|
||||
-j 1 \
|
||||
-i $(subst inject-,,$@)/system.iso \
|
||||
-V vgabios.bin -b BIOS-bochs-latest \
|
||||
-f ${FAIL_INJECT} -- \
|
||||
-Wf,--state-dir=$(subst inject-,,$@)/state \
|
||||
-Wf,--trap -Wf,--timeout=10 \
|
||||
-Wf,--ok-marker=stop_trace \
|
||||
-Wf,--fail-marker=fail_marker \
|
||||
-Wf,--catch-write-textsegment \
|
||||
-Wf,--catch-outerspace -Wf,--catch-outerspace
|
||||
|
||||
@echo "****************************************************************\n\
|
||||
* Congratiulations! You've run your first FAIL* injection campaign.\n\
|
||||
* The results can be viewd with\n\
|
||||
* $ make result-$(subst client-,,$@)\n\
|
||||
*\n\
|
||||
* For a more detailed information, have a look at the web-based resultbrowser.\n\
|
||||
*\n\
|
||||
* $ make resultbrowser\n\
|
||||
****************************************************************"
|
||||
${FAIL_SERVER} -v ${ARCH}/$(subst server-,,$@) -b %
|
||||
|
||||
result-%:
|
||||
@echo "select variant, benchmark, resulttype, sum(t.time2 - t.time1 + 1)\
|
||||
@echo "select variant, benchmark, resulttype, sum(t.time2 - t.time1 + 1) as faults\
|
||||
FROM variant v \
|
||||
JOIN trace t ON v.id = t.variant_id \
|
||||
JOIN fspgroup g ON g.variant_id = t.variant_id AND g.instr2 = t.instr2 AND g.data_address = t.data_address\
|
||||
JOIN result_GenericExperimentMessage r ON r.pilot_id = g.pilot_id \
|
||||
JOIN fsppilot p ON r.pilot_id = p.id \
|
||||
WHERE v.variant = \"${ARCH}/$(patsubst result-%,%,$@)\"\
|
||||
GROUP BY v.id, resulttype \
|
||||
ORDER BY variant, benchmark,sum(t.time2-t.time1+1);" | mysql -t
|
||||
ORDER BY variant, benchmark, resulttype;" |mysql -t
|
||||
|
||||
resultbrowser:
|
||||
resultbrowser -s 0.0.0.0
|
||||
|
||||
# Do never remove implicitly generated stuff
|
||||
.SECONDARY:
|
||||
|
||||
@ -18,12 +18,63 @@ ${BUILD_DIR}/%/system.elf: ${BUILD_DIR}/%/system.o ${BUILD_DIR}/startup.o
|
||||
${BUILD_DIR}/%/system.iso: ${BUILD_DIR}/%/system.elf
|
||||
rm -rf $(shell dirname $<)/grub
|
||||
mkdir -p $(shell dirname $<)/grub/boot/grub
|
||||
cp grub.cfg $(shell dirname $<)/grub/boot/grub
|
||||
cp arch/bochs/grub.cfg $(shell dirname $<)/grub/boot/grub
|
||||
cp $< $(shell dirname $<)/grub/boot/system.elf
|
||||
grub-mkrescue -o $@ $(shell dirname $<)/grub
|
||||
|
||||
BOCHS_RUNNER_ARGS = \
|
||||
-V arch/bochs/vgabios.bin \
|
||||
-b arch/bochs/BIOS-bochs-latest \
|
||||
|
||||
${BUILD_DIR}/%/trace.pb: ${BUILD_DIR}/%/system.iso
|
||||
${BOCHS_RUNNER} ${BOCHS_RUNNER_ARGS} -1 \
|
||||
-f ${FAIL_TRACE} \
|
||||
-e $(shell dirname $<)/system.elf \
|
||||
-i $(shell dirname $<)/system.iso \
|
||||
-- \
|
||||
-Wf,--state-file=$(shell dirname $<)/state \
|
||||
-Wf,--trace-file=$(shell dirname $<)/trace.pb \
|
||||
-Wf,--start-symbol=start_trace \
|
||||
-Wf,--end-symbol=stop_trace \
|
||||
-Wf,--check-bounds
|
||||
|
||||
|
||||
client-%:
|
||||
${BOCHS_RUNNER} ${BOCHS_RUNNER_ARGS} \
|
||||
-f ${FAIL_INJECT} \
|
||||
-e ${BUILD_DIR}/$(subst client-,,$@)/system.elf \
|
||||
-i ${BUILD_DIR}/$(subst client-,,$@)/system.iso \
|
||||
-j $(shell getconf _NPROCESSORS_ONLN) \
|
||||
-- \
|
||||
-Wf,--state-dir=${BUILD_DIR}/$(subst client-,,$@)/state \
|
||||
-Wf,--trap \
|
||||
-Wf,--timeout=10 \
|
||||
-Wf,--ok-marker=ok_marker \
|
||||
-Wf,--fail-marker=fail_marker \
|
||||
-Wf,--catch-write-textsegment \
|
||||
-Wf,--catch-outerspace \
|
||||
2>/dev/null | grep -B 2 -A 8 'INJECT'
|
||||
|
||||
inject-%:
|
||||
${BOCHS_RUNNER} ${BOCHS_RUNNER_ARGS} -1 \
|
||||
-f ${FAIL_INJECT} \
|
||||
-e ${BUILD_DIR}/$(subst inject-,,$@)/system.elf \
|
||||
-i ${BUILD_DIR}/$(subst inject-,,$@)/system.iso \
|
||||
-j 1 -- \
|
||||
-Wf,--state-dir=${BUILD_DIR}/$(subst inject-,,$@)/state \
|
||||
-Wf,--trap \
|
||||
-Wf,--timeout=10 \
|
||||
-Wf,--ok-marker=ok_marker \
|
||||
-Wf,--fail-marker=fail_marker \
|
||||
-Wf,--catch-write-textsegment \
|
||||
-Wf,--catch-outerspace
|
||||
|
||||
define arch-make-targets
|
||||
|
||||
build-$1: ${BUILD_DIR}/$1/system.iso
|
||||
|
||||
trace-$1: ${BUILD_DIR}/$1/trace.pb
|
||||
|
||||
endef
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@ -15,18 +15,51 @@ ${BUILD_DIR}/%/system.elf: ${BUILD_DIR}/startup.o ${BUILD_DIR}/%/system.o
|
||||
${CC} ${CFLAGS} ${LDFLAGS} -o $@ $^
|
||||
|
||||
|
||||
define arch-make-targets
|
||||
build-$1: ${BUILD_DIR}/$1/system.elf
|
||||
|
||||
trace-$1: ${BUILD_DIR}/$1/system.elf
|
||||
${BUILD_DIR}/%/trace.pb: ${BUILD_DIR}/%/system.elf
|
||||
${FAIL_TRACE} \
|
||||
-Wf,--elf-file -Wf,$$< \
|
||||
-Wf,--elf-file -Wf,$< \
|
||||
-Wf,--start-symbol -Wf,start_trace \
|
||||
-Wf,--end-symbol -Wf,stop_trace \
|
||||
-Wf,--check-bounds \
|
||||
-Wf,--state-file=$$(dir $$<)/state \
|
||||
-Wf,--trace-file=$$(dir $$<)/trace.pb \
|
||||
$$<
|
||||
-Wf,--state-file=$(dir $<)/state \
|
||||
-Wf,--trace-file=$(dir $<)/trace.pb \
|
||||
-V $<
|
||||
|
||||
client-%:
|
||||
${BOCHS_RUNNER} --mode sail \
|
||||
-f ${FAIL_INJECT} \
|
||||
-e ${BUILD_DIR}/$(subst client-,,$@)/system.elf \
|
||||
-j $(shell getconf _NPROCESSORS_ONLN) \
|
||||
-- \
|
||||
-Wf,--state-dir=${BUILD_DIR}/$(subst client-,,$@)/state \
|
||||
-Wf,--trap \
|
||||
-Wf,--timeout=100000 \
|
||||
-Wf,--ok-marker=ok_marker \
|
||||
-Wf,--fail-marker=fail_marker \
|
||||
-Wf,--catch-write-textsegment \
|
||||
-Wf,--catch-outerspace \
|
||||
-V 2>/dev/null | grep -B 2 -A 8 'INJECT'
|
||||
|
||||
inject-%:
|
||||
${BOCHS_RUNNER} --mode sail -1 -j 1 \
|
||||
-f ${FAIL_INJECT} \
|
||||
-e ${BUILD_DIR}/$(subst inject-,,$@)/system.elf \
|
||||
-- \
|
||||
-Wf,--state-dir=${BUILD_DIR}/$(subst inject-,,$@)/state \
|
||||
-Wf,--trap \
|
||||
-Wf,--timeout=100000 \
|
||||
-Wf,--ok-marker=ok_marker \
|
||||
-Wf,--fail-marker=fail_marker \
|
||||
-Wf,--catch-write-textsegment \
|
||||
-Wf,--catch-outerspace -V
|
||||
|
||||
|
||||
|
||||
define arch-make-targets
|
||||
build-$1: ${BUILD_DIR}/$1/system.elf
|
||||
|
||||
trace-$1: ${BUILD_DIR}/$1/trace.pb
|
||||
|
||||
|
||||
endef
|
||||
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
#include "arch/riscv/bootcode/boot.h"
|
||||
|
||||
|
||||
#define asm __asm__
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
FAIL_DOWNLOAD_URL = ${FAIL_DOWNLOAD_BASE}?job=build-riscv-generic-tools%3A+%5Briscv64%5D
|
||||
FAIL_DOWNLOAD_URL = ${FAIL_DOWNLOAD_BASE}?job=build-riscv-generic-tools%3A+%5Briscv32%5D
|
||||
|
||||
include arch/riscv-common.mk
|
||||
|
||||
|
||||
5
arch/riscv64.mk
Normal file
5
arch/riscv64.mk
Normal file
@ -0,0 +1,5 @@
|
||||
FAIL_DOWNLOAD_URL = ${FAIL_DOWNLOAD_BASE}?job=build-riscv-generic-tools%3A+%5Briscv64%5D
|
||||
|
||||
include arch/riscv-common.mk
|
||||
|
||||
CFLAGS += -march=rv64im -target riscv64-unknown-freebsd
|
||||
27
docker-compose.yml
Normal file
27
docker-compose.yml
Normal file
@ -0,0 +1,27 @@
|
||||
version: '3'
|
||||
services:
|
||||
db:
|
||||
image: mariadb
|
||||
container_name: db
|
||||
restart: always
|
||||
environment:
|
||||
- MYSQL_ROOT_PASSWORD="secret"
|
||||
- MARIADB_DATABASE=fail
|
||||
- MARIADB_USER=fail
|
||||
- MARIADB_PASSWORD=fail
|
||||
volumes:
|
||||
- ./db:/var/lib/mysql
|
||||
|
||||
shell:
|
||||
image: danceos/fail-ci-build
|
||||
stdin_open: true # docker run -i
|
||||
restart: "no"
|
||||
tty: true # docker run -t
|
||||
entrypoint: ["echo", "Service foo disabled"]
|
||||
links:
|
||||
- db
|
||||
environment:
|
||||
- ARCH=${ARCH}
|
||||
volumes:
|
||||
- .:/home/fail/fail
|
||||
|
||||
17
long-trace.c
Normal file
17
long-trace.c
Normal file
@ -0,0 +1,17 @@
|
||||
#include "lib.c"
|
||||
|
||||
int array[] = {1, 1, 2, 3, 5, 8, 13, 21};
|
||||
int sum;
|
||||
void os_main() {
|
||||
MARKER(start_trace);
|
||||
sum = 20;
|
||||
|
||||
for (int i = 0; i < 1 << 20; i++) {
|
||||
sum += (array[i % (sizeof(array)/sizeof(*array))] * 23) + 1;
|
||||
}
|
||||
|
||||
MARKER(stop_trace);
|
||||
|
||||
MARKER(ok_marker);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user