aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/tcg/x86_64/Makefile.target2
-rw-r--r--tests/tcg/x86_64/test-2413.c30
2 files changed, 32 insertions, 0 deletions
diff --git a/tests/tcg/x86_64/Makefile.target b/tests/tcg/x86_64/Makefile.target
index 5fedf22..eda9bd7 100644
--- a/tests/tcg/x86_64/Makefile.target
+++ b/tests/tcg/x86_64/Makefile.target
@@ -8,6 +8,8 @@
include $(SRC_PATH)/tests/tcg/i386/Makefile.target
+X86_64_TESTS += test-2413
+
ifeq ($(filter %-linux-user, $(TARGET)),$(TARGET))
X86_64_TESTS += vsyscall
X86_64_TESTS += noexec
diff --git a/tests/tcg/x86_64/test-2413.c b/tests/tcg/x86_64/test-2413.c
new file mode 100644
index 0000000..456e533
--- /dev/null
+++ b/tests/tcg/x86_64/test-2413.c
@@ -0,0 +1,30 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/* Copyright 2024 Linaro, Ltd. */
+/* See https://gitlab.com/qemu-project/qemu/-/issues/2413 */
+
+#include <assert.h>
+
+void test(unsigned long *a, unsigned long *d, unsigned long c)
+{
+ asm("xorl %%eax, %%eax\n\t"
+ "xorl %%edx, %%edx\n\t"
+ "testb $0x20, %%cl\n\t"
+ "sete %%al\n\t"
+ "setne %%dl\n\t"
+ "shll %%cl, %%eax\n\t"
+ "shll %%cl, %%edx\n\t"
+ : "=a"(*a), "=d"(*d)
+ : "c"(c));
+}
+
+int main(void)
+{
+ unsigned long a, c, d;
+
+ for (c = 0; c < 64; c++) {
+ test(&a, &d, c);
+ assert(a == (c & 0x20 ? 0 : 1u << (c & 0x1f)));
+ assert(d == (c & 0x20 ? 1u << (c & 0x1f) : 0));
+ }
+ return 0;
+}