Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
631f56e
add full memory and memory map dump option to faultplugin
ks0777 Jan 27, 2023
331f918
dump full memory state after pregoldenrun and pass to unicorn worker
ks0777 Jan 27, 2023
2e84241
add unicorn emulation worker with meminfo logging and pregoldenrun
ks0777 Jan 27, 2023
5b41bd4
implement fault types
ks0777 Feb 8, 2023
5ea4e69
implement fault lifetimes
ks0777 Feb 10, 2023
90cf5b5
add endpoint logging
ks0777 Feb 10, 2023
a1ac90e
add tbinfo logs
ks0777 Feb 11, 2023
b509af9
add tbexec logs
ks0777 Feb 11, 2023
b32f39e
filter tbexec/tbinfo entries
ks0777 Feb 18, 2023
d7a7eb0
add memory and arm/riscv register dumps
ks0777 Feb 19, 2023
575b61c
dump pregoldenrun memory map; handle registerdumps
ks0777 Feb 28, 2023
9757fa8
add logging framework
ks0777 Mar 3, 2023
244c641
remove modified tbs from cache during emulation
ks0777 Apr 25, 2023
0c316e2
fix emulation_worker
ks0777 May 16, 2025
e721d76
read pregoldenrun from backup
ks0777 May 21, 2025
9e8b023
fix log entry in gitignore
ks0777 May 21, 2025
868eee0
include basic unicorn tests in ci pipeline
ks0777 May 21, 2025
9b09415
update python dependencies
ks0777 May 21, 2025
cfdf338
fix register table selection for riscv
ks0777 May 21, 2025
c11682f
fix dead link
ks0777 Nov 17, 2025
6122c8e
undo stm32-timeout-wfi run.sh changes
ks0777 Nov 17, 2025
f818272
remove unused variable
ks0777 Nov 17, 2025
3264dba
remove unused workflow
ks0777 Nov 17, 2025
1f3bad9
controller.py: remove print; remove duplicate engine_output definitio…
ks0777 Nov 17, 2025
a74f941
controller.py: only parse pregoldenrun backup in unicorn mode
ks0777 Nov 17, 2025
8839c34
faultclass.py: remove unnecessary return
ks0777 Nov 18, 2025
1b8dc35
goldenrun.py: fix exception for configs without start address
ks0777 Nov 18, 2025
7cffe59
add aarch64 support to unicorn emulation
ks0777 Jan 5, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 76 additions & 18 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ jobs:
sudo apt install -y build-essential ninja-build libglib2.0-dev libfdt-dev libpixman-1-dev zlib1g-dev libprotobuf-c-dev protobuf-compiler protobuf-c-compiler libcap-dev
pip install -r requirements.txt

- name: Install latest stable Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable

- name: Checkout submodules
run: git submodule update --init

Expand All @@ -29,6 +34,9 @@ jobs:
- name: Build Faultplugin
run: cd faultplugin; make -j; echo "done"

- name: Build Emulation Worker
run: cd emulation_worker; cargo build --release; mv target/release/libemulation_worker.so ../emulation_worker.so; echo "done"

- name: Run ARCHIE
run: cd examples/stm32; ./run.sh; cd ../riscv64; ./run.sh; cd ../stm32-timeout-wfi; ./run.sh; cd ../aarch64-softmmu; ./run.sh

Expand All @@ -49,6 +57,28 @@ jobs:
examples/aarch64-softmmu/*.txt
examples/aarch64-softmmu/*.hdf5

- name: Clean test results
run: |
rm examples/*/log*.txt
rm examples/*/output.hdf5

- name: Run ARCHIE Unicorn
run: cd examples/stm32; ./run.sh --unicorn; cd ../riscv64; ./run.sh --unicorn

- name: Synchronize cached writes for artifact storage
run: sync

- name: Upload test artifacts
uses: actions/upload-artifact@v4
with:
name: test-artifacts-unicorn
path: |
examples/riscv64/*.txt
examples/riscv64/*.hdf5
examples/stm32/*.txt
examples/stm32/*.hdf5


build_with_script:
name: Test build.sh Script
runs-on: ubuntu-latest
Expand Down Expand Up @@ -79,15 +109,26 @@ jobs:
uses: actions/download-artifact@v4
with:
name: test-artifacts
path : .
path : test-artifacts

- name: Download unicorn test artifacts
uses: actions/download-artifact@v4
with:
name: test-artifacts-unicorn
path : test-artifacts-unicorn

- name: Verify stm32 results
run: |
cat stm32/log_-2.txt | grep -A8 800006a | tail -8 | grep 'Reached end point'
cat stm32/log_-1.txt | grep -A8 8000056 | tail -8 | grep 'Reached end point'
cat stm32/log_0.txt | grep -A8 8000070 | tail -8 | grep 'Reached end point'
cat stm32/log_1.txt | grep -A8 8000070 | tail -8 | grep 'Reached end point'
cat stm32/log_2.txt | grep -A8 8000070 | tail -8 | grep 'Reached end point'
cat test-artifacts/stm32/log_-2.txt | grep -A8 800006a | tail -8 | grep 'Reached end point'
cat test-artifacts/stm32/log_-1.txt | grep -A8 8000056 | tail -8 | grep 'Reached end point'
cat test-artifacts/stm32/log_0.txt | grep -A8 8000070 | tail -8 | grep 'Reached end point'
cat test-artifacts/stm32/log_1.txt | grep -A8 8000070 | tail -8 | grep 'Reached end point'
cat test-artifacts/stm32/log_2.txt | grep -A8 8000070 | tail -8 | grep 'Reached end point'
cat test-artifacts-unicorn/stm32/log_-2.txt | grep -A8 800006a | tail -8 | grep 'Reached end point'
cat test-artifacts-unicorn/stm32/log_-1.txt | grep -A8 8000056 | tail -8 | grep 'Reached end point'
cat test-artifacts-unicorn/stm32/log_0.txt | grep 'Reached endpoint at 0x8000070'
cat test-artifacts-unicorn/stm32/log_1.txt | grep 'Reached endpoint at 0x8000070'
cat test-artifacts-unicorn/stm32/log_2.txt | grep 'Reached endpoint at 0x8000070'

verify_stm32-timeout-wfi:
name: Verify results of stm32-timeout-wfi experiment
Expand All @@ -99,15 +140,21 @@ jobs:
uses: actions/download-artifact@v4
with:
name: test-artifacts
path : .
path : test-artifacts

- name: Download unicorn test artifacts
uses: actions/download-artifact@v4
with:
name: test-artifacts-unicorn
path : test-artifacts-unicorn

- name: Verify stm32-timeout-wfi results
run: |
cat stm32-timeout-wfi/log_-2.txt | grep -A8 800006a | tail -8 | grep 'Reached end point'
cat stm32-timeout-wfi/log_-1.txt | grep -A8 8000056 | tail -8 | grep 'Reached end point'
cat stm32-timeout-wfi/log.txt | grep 'Experiment 0 ran into timeout'
cat stm32-timeout-wfi/log.txt | grep 'Experiment 1 ran into timeout'
cat stm32-timeout-wfi/log.txt | grep 'Experiment 2 ran into timeout'
cat test-artifacts/stm32-timeout-wfi/log_-2.txt | grep -A8 800006a | tail -8 | grep 'Reached end point'
cat test-artifacts/stm32-timeout-wfi/log_-1.txt | grep -A8 8000056 | tail -8 | grep 'Reached end point'
cat test-artifacts/stm32-timeout-wfi/log.txt | grep 'Experiment 0 ran into timeout'
cat test-artifacts/stm32-timeout-wfi/log.txt | grep 'Experiment 1 ran into timeout'
cat test-artifacts/stm32-timeout-wfi/log.txt | grep 'Experiment 2 ran into timeout'

verify_riscv64:
name: Verify results of riscv64 experiment
Expand All @@ -119,15 +166,26 @@ jobs:
uses: actions/download-artifact@v4
with:
name: test-artifacts
path : .
path : test-artifacts

- name: Download unicorn test artifacts
uses: actions/download-artifact@v4
with:
name: test-artifacts-unicorn
path : test-artifacts-unicorn

- name: Verify riscv64 results
run: |
cat riscv64/log_-2.txt | grep -A8 80000014 | tail -8 | grep 'Reached end point'
cat riscv64/log_-1.txt | grep -A8 8000002a | tail -8 | grep 'Reached end point'
cat riscv64/log_0.txt | grep -A8 8000003c| tail -8 | grep 'Reached end point'
cat riscv64/log_1.txt | grep -A8 8000003c | tail -8 | grep 'Reached end point'
cat riscv64/log_2.txt | grep -A8 8000003c | tail -8 | grep 'Reached end point'
cat test-artifacts/riscv64/log_-2.txt | grep -A8 80000014 | tail -8 | grep 'Reached end point'
cat test-artifacts/riscv64/log_-1.txt | grep -A8 8000002a | tail -8 | grep 'Reached end point'
cat test-artifacts/riscv64/log_0.txt | grep -A8 8000003c| tail -8 | grep 'Reached end point'
cat test-artifacts/riscv64/log_1.txt | grep -A8 8000003c | tail -8 | grep 'Reached end point'
cat test-artifacts/riscv64/log_2.txt | grep -A8 8000003c | tail -8 | grep 'Reached end point'
cat test-artifacts-unicorn/riscv64/log_-2.txt | grep -A8 80000014 | tail -8 | grep 'Reached end point'
cat test-artifacts-unicorn/riscv64/log_-1.txt | grep -A8 8000002a | tail -8 | grep 'Reached end point'
cat test-artifacts-unicorn/riscv64/log_0.txt | grep 'Reached endpoint at 0x8000003c'
cat test-artifacts-unicorn/riscv64/log_1.txt | grep 'Reached endpoint at 0x8000003c'
cat test-artifacts-unicorn/riscv64/log_2.txt | grep 'Reached endpoint at 0x8000003c'

verify_aarch64-softmmu:
name: Verify results of aarch64-softmmu experiment
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,22 @@ jobs:
- run: |
black --version
black --check --diff *.py analysis/*.py

clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: rustfmt, clippy
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all --manifest-path ./emulation_worker/Cargo.toml -- --check
- run: |
cd emulation_worker
cargo clippy -- -D warnings
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ARCHIE specific debug files
*.hdf5
log_*
log*.txt

# C
## Prerequisites
Expand Down
29 changes: 23 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,12 @@ cd qemu/build
make -j $(nproc)
cd ../../faultplugin/
make
cd emulation_worker
cargo build --release
cp target/release/libemulation_worker.so ../emulation_worker.so
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the advantage of this, can we just leave it in the build dir?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't directly import the .so if its directory is not in the PATH. An alternative would be to add the build directory to the path before importing the .so in faultclass.py. This is easily done with 4 lines of code but overall not really clean either imo. With this solution, however, there would be no more copies of the .so file which might be less confusing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, both solutions are not perfect. Maybe the best would be to adopt the same approach we are currently using for the faultplugin. That would mean not copying the library and instead adding a new config entry to qemuconf.json for specifying its location.

```

With this, *archie-qemu* is build in qemu/build/ and the plugin is build in *faultplugin/*
With this, *archie-qemu* is built in qemu/build/, the plugin is built in *faultplugin/* and the unicorn emulation worker is built and moved to the project's root directory.
If you change the build directory for *archie-qemu*, please change the path in the [Makefile](faultplugin/Makefile) in the *faultplugin/* folder for building the plugin.

## In [archie](https://github.com/Fraunhofer-AISEC/archie)
Expand All @@ -60,11 +63,14 @@ If you change the build directory for *archie-qemu*, please change the path in t

For the Python3 program, the following libraries are needed
```
pandas (tested 0.25.3)
tables (tested 3.6.1)
python-prctl (tested 1.6.1)
numpy (tested 1.17.4)
json (tested 2.0.9), or json5 (tested 0.9.6)
pandas (tested 2.2)
python-prctl (tested 1.8)
tables (tested 3.10)
json (tested 2.0.9), or json5 (tested 0.12)
protobuf (tested 6.31)
tqdm (tested 4.67)
psutil (tested 7.0)
pyelftools (tested 0.32)
```
These python3 libraries can either be installed using your linux-distribution's installation method or by using pip3.
JSON5 is strongly recommended as it allows integers to be represented as hexadecimal numbers.
Expand Down Expand Up @@ -111,3 +117,14 @@ To connect from GDB to the QEMU session use
targ rem:localhost:1234
```
QEMU will wait unil the GDB session is attached. The debugging mode is only suitable for the analysis of a low number of faults. Stepping through a large amount of faults is cumbersome. This should be considered when adjusting the JSON files.

#### Unicorn Engine

Instead of QEMU, the unicorn engine can be used for emulating the experiments.
This feature can be used interchangeably with the QEMU emulation without the need to adjust any of the configuration files.
One exception for this are register faults, which have different target addresses between the two versions.
The mapping for the registers can be looked up in the documentation of unicorn's [Rust bindings](https://docs.rs/unicorn-engine/latest/unicorn_engine/unicorn_const/index.html).
To enable this feature the *--unicorn* flag can be set.

Using the unicorn engine can result in a substantial increase in performance.
However, this mode is not capable of emulating any features related to the hardware of the target platform such as interrupts or communication with devices.
10 changes: 8 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ install_python3_distro() {
if [ "${ID:-linux}" = "debian" ] || [ "${ID_LIKE#*debian*}" != "${ID_LIKE}" ]
then
echo "Looks like Debian!"
sudo apt-get install python3-tables python3-pandas python3-prctl python3-protobuf python3-tqdm python3-psutil python3-json5 python3-setuptools
sudo apt-get install python3-tables python3-pandas python3-prctl python3-protobuf python3-tqdm python3-psutil python3-json5 python3-setuptools python3-pyelftools

echo "Rebuild protobuf files to support the installed package versions"
cd protobuf
Expand Down Expand Up @@ -102,6 +102,12 @@ cd ../../faultplugin/
make clean && make
cd ..

echo "Building emulation worker"
cd emulation_worker
cargo build --release
cp target/release/libemulation_worker.so ../emulation_worker.so
cd -

echo "Test ARCHIE"
cd examples/stm32
./run.sh
Expand All @@ -119,4 +125,4 @@ select yn in "YES" "NO"; do
esac
echo "Please type the number corresponding to Yes or No"
done
echo "Archie was build and tested successfully"
echo "Archie was built and tested successfully"
Loading
Loading