This is an archive of the discontinued LLVM Phabricator instance.

[HWASan] Add script to run binaries in QEMU with LAM.
AbandonedPublic

Authored by morehouse on May 13 2021, 5:17 PM.

Details

Summary

Can be used in combination with the COMPILER_RT_EMULATOR CMake variable
and check-hwasan-lam to test LAM functionality in QEMU.

Diff Detail

Event Timeline

morehouse requested review of this revision.May 13 2021, 5:17 PM
morehouse created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptMay 13 2021, 5:17 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript
vitalybuka added inline comments.May 13 2021, 6:49 PM
compiler-rt/lib/hwasan/scripts/run_in_qemu_with_lam.sh
115

can we mount build dir?

158

maybe more convenient is to have two scripts:

  1. Prepare and run VM and save somewhere SSH endpoint
  2. run the command in VM

Then we run the first one before ninja check* call
and use the second in COMPILER_RT_EMULATOR

morehouse added inline comments.May 14 2021, 9:45 AM
compiler-rt/lib/hwasan/scripts/run_in_qemu_with_lam.sh
115

It can be done if the custom kernel is built with a certain config to enable virtio and 9p filesytem. I don't remember the exact config required anymore.

IIRC there were also permissions issues if qemu wanted to write any files in the mounted directory. I ended having to run qemu as root.

For the hwasan tests scp seems to work fine.

158

The nice thing about the current script is that it is self-contained. We don't need to manage a pool of qemu VMs and remember which ones need to be closed. Instead, each VM is booted up to run a single binary and then shutdown immediately.

The tradeoff is that tests take longer with the current script, since we do lots of booting and shutting down. But on my 48 core machine, check-hwasan-lam finishes in 15 minutes, so I haven't felt a need to invest in making it faster.

morehouse abandoned this revision.May 14 2021, 10:48 AM

Moving this to github.com/google/sanitizers after offline discussion.