Skip to contentSkip to conversation

tests/tcg/x86_64: Add cross-modifying code test

PATCH In review Ilya Leoshkevich 2 participants 2 messages Oct 1, 2024 – Oct 3, 2024

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 tests/tcg/x86_64: Add cross-modifying code test

commit f025692c992c ("accel/tcg: Clear PAGE_WRITE before translation") fixed cross-modifying code handling, but did not add a test. The changed code was further improved recently [1], and I was not sure whether these modifications were safe (spoiler: they were fine).

Add a test to make sure there are no regressions.

[1] https://lists.gnu.org/archive/html/qemu-devel/2022-09/msg00034.html

---

v3: https://lore.kernel.org/qemu-devel/[email protected]/
v3 -> v4: Rebase.
I've been looking into the .NET failures under QEMU again and what this test looks for was a suspect. It turned out to be
https://gitlab.com/qemu-project/qemu/-/issues/2600
but it would be good to have this test upstream to ensure there are no regressions.

v2: https://patchew.org/QEMU/[email protected]/
v2 -> v3: Resend with a trivial rebase.

v1: https://lists.gnu.org/archive/html/qemu-devel/2022-09/msg00455.html
v1 -> v2: Fix tweaking the flags (Alex).
Keep the custom build rule for now.

 tests/tcg/x86_64/Makefile.target        |  4 ++
 tests/tcg/x86_64/cross-modifying-code.c | 80 +++++++++++++++++++++++++
 2 files changed, 84 insertions(+)
 create mode 100644 tests/tcg/x86_64/cross-modifying-code.c
tests/tcg/x86_64/Makefile.target +4 -0
index 783ab5b21ad..d6dff559c7d 100644
@@ -17,6 +17,7 @@ X86_64_TESTS += cmpxchg
 X86_64_TESTS += adox
 X86_64_TESTS += test-1648
 X86_64_TESTS += test-2175
+X86_64_TESTS += cross-modifying-code
 TESTS=$(MULTIARCH_TESTS) $(X86_64_TESTS) test-x86_64
 else
 TESTS=$(MULTIARCH_TESTS)
@@ -27,6 +28,9 @@ adox: CFLAGS=-O2
 run-test-i386-ssse3: QEMU_OPTS += -cpu max
 run-plugin-test-i386-ssse3-%: QEMU_OPTS += -cpu max
 
+cross-modifying-code: CFLAGS+=-pthread
+cross-modifying-code: LDFLAGS+=-pthread
+
 test-x86_64: LDFLAGS+=-lm -lc
 test-x86_64: test-i386.c test-i386.h test-i386-shift.h test-i386-muldiv.h
 	$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)
tests/tcg/x86_64/cross-modifying-code.c new file +80 -0

80 lines not on this page · raw message

Signature · 1 line
2.46.2
Reviewed-by on v4 1/1
#1 lore raw
Quoted 23 lines · Ilya Leoshkevich

commit f025692c992c ("accel/tcg: Clear PAGE_WRITE before translation") fixed cross-modifying code handling, but did not add a test. The changed code was further improved recently [1], and I was not sure whether these modifications were safe (spoiler: they were fine).

Add a test to make sure there are no regressions.

[1]https://lists.gnu.org/archive/html/qemu-devel/2022-09/msg00034.html

---

v3:https://lore.kernel.org/qemu-devel/[email protected]/ v3 -> v4: Rebase.
I've been looking into the .NET failures under QEMU again and what this test looks for was a suspect. It turned out to be
https://gitlab.com/qemu-project/qemu/-/issues/2600
but it would be good to have this test upstream to ensure there are no regressions.

v2:https://patchew.org/QEMU/[email protected]/ v2 -> v3: Resend with a trivial rebase.

Quoted 8 lines

v1:https://lists.gnu.org/archive/html/qemu-devel/2022-09/msg00455.html v1 -> v2: Fix tweaking the flags (Alex).
Keep the custom build rule for now.

  tests/tcg/x86_64/Makefile.target        |  4 ++
  tests/tcg/x86_64/cross-modifying-code.c | 80 +++++++++++++++++++++++++
  2 files changed, 84 insertions(+)

create mode 100644 tests/tcg/x86_64/cross-modifying-code.c

r~