Skip to content

Add Thread Sanitizer support to QEMU

Robert Foley qemu-devel 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest13 patches 1 replyIn review
  2. v213 patches 11 repliesSuperseded
  3. v112 patches 11 repliesSuperseded

Changes in v3 from the cover letter

- Fixed issue in tsan changes to start_switch_fiber(), found by --enable-sanitizers testing.
- Removed the UC_TRACE() code.
- Removed the tb_destroy callback.

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/13configure: add --enable-tsan flag + fiber annotations for coroutine-ucontextconfigure util/coroutine-ucontext.c+103 -100 replies
2/13cpu: convert queued work to a QSIMPLEQcpus-common.c cpus.c hw/core/cpu.c +1 more+24 -220 replies
3/13thread: add qemu_spin_destroyinclude/qemu/thread.h+3 -00 replies
4/13cputlb: destroy CPUTLB with tlb_destroyaccel/tcg/cputlb.c exec.c include/exec/exec-all.h+24 -00 replies
5/13qht: call qemu_spin_destroy for head bucketsutil/qht.c+1 -00 replies
6/13tcg: call qemu_spin_destroy for tb->jmp_lockaccel/tcg/translate-all.c include/tcg/tcg.h tcg/tcg.c+18 -00 replies
7/13translate-all: call qemu_spin_destroy for PageDescaccel/tcg/translate-all.c+9 -00 replies
8/13thread: add tsan annotations to QemuSpininclude/qemu/thread.h+36 -30 replies
9/13tests/docker: Added docker build support for TSan.tests/docker/dockerfiles/ubuntu2004.docker tests/docker/test-tsan tests/tsan/blacklist.tsan +1 more+133 -00 replies
10/13include/qemu: Added tsan.h for annotations.include/qemu/tsan.h+71 -00 replies
11/13util: Added tsan annotate for thread name.util/qemu-thread-posix.c+2 -00 replies
12/13docs: Added details on TSan to testing.rstdocs/devel/testing.rst+107 -00 replies
13/13tests: Disable select tests under TSan, which hit TSan issue.tests/Makefile.include tests/qtest/Makefile.include+12 -40 replies

Reviews trailers per patch

12 of 13 patches have a Reviewed-by or Acked-by.

PatchAlex BennéeRichard HendersonPhilippe Mathieu-DaudéEmilio G. Cota
1/13R-b
2/13R-b R-b R-b
3/13R-b
4/13R-b
5/13R-b
6/13
7/13R-b
8/13R-b
9/13R-b
10/13R-b R-b
11/13R-b
12/13R-b R-b
13/13R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 4 reviewers.

Read the v3 thread

Cover letter [PATCH v3 00/13] Add Thread Sanitizer support to QEMU

Changes in v3:
- Fixed issue in tsan changes to start_switch_fiber(), found by --enable-sanitizers testing.
- Removed the UC_TRACE() code.
- Removed the tb_destroy callback.

v2: https://lists.gnu.org/archive/html/qemu-devel/2020-06/msg01534.html

This patch series continues the work done by Emilio Cota and others to add Thread Sanitizer (TSan) support to QEMU.

The starting point for this work was Emilio's branch here:
https://github.com/cota/qemu/commits/tsan
specifically this commit: 0be125fc0afd47218b34d2019abdd19b644f3199

The main purpose of this patch is to enable TSan support so that QEMU developers can start using the tool.
We found this tool useful and even ran it on our recent changes in the cpu-locks series, which fixes many warnings.
Clearly there is work to do here to clean up all the warnings. :) We have also made an effort to introduce enough of the TSan suppression mechanisms, so that others can continue this work.

This series adds support for:
- configure option for --enable-tsan.
- testing.rst has the full details on how to use TSan with or without docker, including all the suppression mechanisms.
- We added an Ubuntu 20.04 docker that supports TSan builds.
- test-tsan is a new docker test that builds and runs make check under TSan.
- We added an example blacklist file for files or functions TSan should ignore at compile time. This can now be specified manually.
- Added a suppression file for TSan to suppress certain warnings at run time.
- Added tsan.h with annotations which also can be used to suppress warnings.

Emilio G. Cota (7):
cpu: convert queued work to a QSIMPLEQ
thread: add qemu_spin_destroy
cputlb: destroy CPUTLB with tlb_destroy
qht: call qemu_spin_destroy for head buckets
tcg: call qemu_spin_destroy for tb->jmp_lock
translate-all: call qemu_spin_destroy for PageDesc
thread: add tsan annotations to QemuSpin

Lingfeng Yang (1):
configure: add --enable-tsan flag + fiber annotations for
coroutine-ucontext

Robert Foley (5):
tests/docker: Added docker build support for TSan. include/qemu: Added tsan.h for annotations.
util: Added tsan annotate for thread name.
docs: Added details on TSan to testing.rst
tests: Disable select tests under TSan, which hit TSan issue.

 accel/tcg/cputlb.c                         |  15 +++
 accel/tcg/translate-all.c                  |  17 ++++
 configure                                  |  47 ++++++++-
 cpus-common.c                              |  25 ++---
 cpus.c                                     |  14 ++-
 docs/devel/testing.rst                     | 107 +++++++++++++++++++++
 exec.c                                     |   1 +
 hw/core/cpu.c                              |   1 +
 include/exec/exec-all.h                    |   8 ++
 include/hw/core/cpu.h                      |   6 +-
 include/qemu/thread.h                      |  38 +++++++-
 include/qemu/tsan.h                        |  71 ++++++++++++++
 include/tcg/tcg.h                          |   1 +
 tcg/tcg.c                                  |   9 ++
 tests/Makefile.include                     |   9 +-
 tests/docker/dockerfiles/ubuntu2004.docker |  65 +++++++++++++
 tests/docker/test-tsan                     |  44 +++++++++
 tests/qtest/Makefile.include               |   7 +-
 tests/tsan/blacklist.tsan                  |  10 ++
 tests/tsan/suppressions.tsan               |  14 +++
 util/coroutine-ucontext.c                  |  66 +++++++++++--
 util/qemu-thread-posix.c                   |   2 +
 util/qht.c                                 |   1 +
 23 files changed, 541 insertions(+), 37 deletions(-)
 create mode 100644 include/qemu/tsan.h
 create mode 100644 tests/docker/dockerfiles/ubuntu2004.docker
 create mode 100755 tests/docker/test-tsan
 create mode 100644 tests/tsan/blacklist.tsan
 create mode 100644 tests/tsan/suppressions.tsan
Signature · 1 line
2.17.1