Appendix
Triforce Mod to allow test cases isolated execution
Each time QEMU does full system emulation, it creates three threads that manage the next parts: control over the Central Processing Unit (CPU), Input/Output (I/O) of the system, and Read-Copy Update (RCU) for synchronization. The trick consists of stopping the Virtual CPU (vCPU); with this, it will go out from the CPU loop, the state is recorded, and the thread still exists, keeping only the RCU and I/O threads. The process to manage the CPU will be forked, and the child process will contain the thread from the vCPU.
We can find the process in the startForkserver
method from the qemu_mode/qemu/target-*/translate.c
file from the different supported architectures, then we move to the afl_forkserver
method, which will call the POSIX fork
function to start the new process:
static target_ulong startForkserver(CPUArchState *env, target_ulong enableTicks) { … afl_setup(); afl_forkserver(env); … #endif return...