Skip to content

Commit

Permalink
tmp: add segfault reproduce insns
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmikhalevich authored and edubart committed Oct 8, 2023
1 parent 9da6036 commit 5f2630d
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions hypervisor.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,42 @@ $ ${CROSS_COMPILE}strip lkvm-static
```

The above commands will create `kvmtool/lkvm-static` that you need to copy to your host root file system.

## kvmtool segfault reproduce

The segfault bug does not reproduce each time the hypervisor lauches. The reproducibility depends on the delays in the code, e.g. executing `sleep` or putting more printfs influences the reproducibility. The usual reproducibility rate is around 13-16%. It is also important to mention that virtio driver should be used (`-n virtio`) to reproduce the issue.

The issue reproduces by booting hypervisor with no command:
```
/hp/lkvm-static run --kernel /hp/Image --console serial --params "console=ttyS0 earlycon=sbi" -n virtio -d /hp/rootfs-virt.ext2 -m 100M
```

To test issue fixes I crafted a script that executes the hypervisor 100 times and checks the output fot segfault.

```
#!/bin/sh
SEG_FAULT_COUNT=0
TOTAL_RUNS=100
CURRENT_RUN=1
FILE=.test_file
while [ "$CURRENT_RUN" -le "$TOTAL_RUNS" ]; do
/hp/lkvm-static run --kernel /hp/Image --console serial --params "console=ttyS0 earlycon=sbi -- /benchmarks/sleep; dmesg" -d /hp/rootfs-virt.ext2 -n virtio -m 100M &> $FILE
segfault=$(cat $FILE | grep "Segmentation fault")
if [ -z "$segfault" ]; then
echo "Run $CURRENT_RUN: No segmentation fault"
else
SEG_FAULT_COUNT=$((SEG_FAULT_COUNT + 1))
cat $FILE
echo "Run $CURRENT_RUN: Segmentation fault"
fi
CURRENT_RUN=$((CURRENT_RUN + 1))
done
rm $FILE
echo "Total Segmentation Faults: $SEG_FAULT_COUNT out of $TOTAL_RUNS runs"
```

0 comments on commit 5f2630d

Please sign in to comment.