diff options
author | Stefan Hajnoczi | 2022-11-15 15:32:17 +0100 |
---|---|---|
committer | Stefan Hajnoczi | 2022-11-15 15:32:17 +0100 |
commit | dd64bcea0016938ef0be7a0c930f98b77d5e1612 (patch) | |
tree | 802587f44f1ba042d7c3f15873e5ada0d8f5d52f /tests | |
parent | Merge tag 'for-upstream' of https://repo.or.cz/qemu/kevin into staging (diff) | |
parent | target/i386: hardcode R_EAX as destination register for LAHF/SAHF (diff) | |
download | qemu-dd64bcea0016938ef0be7a0c930f98b77d5e1612.tar.gz qemu-dd64bcea0016938ef0be7a0c930f98b77d5e1612.tar.xz qemu-dd64bcea0016938ef0be7a0c930f98b77d5e1612.zip |
Merge tag 'pull-x86-20221115' of https://gitlab.com/rth7680/qemu into staging
Fix cmpxchgl writeback to rax.
Fix lahf/sahf for 64-bit
# -----BEGIN PGP SIGNATURE-----
#
# iQFRBAABCgA7FiEEekgeeIaLTbaoWgXAZN846K9+IV8FAmNy0OYdHHJpY2hhcmQu
# aGVuZGVyc29uQGxpbmFyby5vcmcACgkQZN846K9+IV/2XwgAr2yCrG8irdVBmD1B
# rNW8xJJWIwEXqJ3KSPBSMEQ5lCVW7urwIYasnTYPV9TMwXvwwbFzCzovp+pJ402b
# GPCkkjS/DdLHKbFqzEIcVld6IASaYNbcCZjEDeN3U14RZW9X7Aujy1Yg6qWxWnIc
# ony2awzocGq5iafvPCMATmIkPJErnFv6mLttRq52CmBATgVtsSrxEF735NVuZAaq
# t9bfN+gQpXARo+AcGzqTpNtcR4DTzE2hyJrXAMivTJtAeEl8XweOq8eV7PkAf4qw
# ED/AT6G7I38Buzj1o8SN3G54d/v/jwV/L9fWCLs92QZJC/gIi9B7qZf8DglI1ipV
# YCFKQw==
# =xP4E
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon 14 Nov 2022 18:36:06 EST
# gpg: using RSA key 7A481E78868B4DB6A85A05C064DF38E8AF7E215F
# gpg: issuer "richard.henderson@linaro.org"
# gpg: Good signature from "Richard Henderson <richard.henderson@linaro.org>" [full]
# Primary key fingerprint: 7A48 1E78 868B 4DB6 A85A 05C0 64DF 38E8 AF7E 215F
* tag 'pull-x86-20221115' of https://gitlab.com/rth7680/qemu:
target/i386: hardcode R_EAX as destination register for LAHF/SAHF
target/i386: fix cmpxchg with 32-bit register destination
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/tcg/x86_64/Makefile.target | 1 | ||||
-rw-r--r-- | tests/tcg/x86_64/cmpxchg.c | 42 |
2 files changed, 43 insertions, 0 deletions
diff --git a/tests/tcg/x86_64/Makefile.target b/tests/tcg/x86_64/Makefile.target index 6895db1c43..4eac78293f 100644 --- a/tests/tcg/x86_64/Makefile.target +++ b/tests/tcg/x86_64/Makefile.target @@ -11,6 +11,7 @@ include $(SRC_PATH)/tests/tcg/i386/Makefile.target ifeq ($(filter %-linux-user, $(TARGET)),$(TARGET)) X86_64_TESTS += vsyscall X86_64_TESTS += noexec +X86_64_TESTS += cmpxchg TESTS=$(MULTIARCH_TESTS) $(X86_64_TESTS) test-x86_64 else TESTS=$(MULTIARCH_TESTS) diff --git a/tests/tcg/x86_64/cmpxchg.c b/tests/tcg/x86_64/cmpxchg.c new file mode 100644 index 0000000000..5891735161 --- /dev/null +++ b/tests/tcg/x86_64/cmpxchg.c @@ -0,0 +1,42 @@ +#include <assert.h> + +static int mem; + +static unsigned long test_cmpxchgb(unsigned long orig) +{ + unsigned long ret; + mem = orig; + asm("cmpxchgb %b[cmp],%[mem]" + : [ mem ] "+m"(mem), [ rax ] "=a"(ret) + : [ cmp ] "r"(0x77), "a"(orig)); + return ret; +} + +static unsigned long test_cmpxchgw(unsigned long orig) +{ + unsigned long ret; + mem = orig; + asm("cmpxchgw %w[cmp],%[mem]" + : [ mem ] "+m"(mem), [ rax ] "=a"(ret) + : [ cmp ] "r"(0x7777), "a"(orig)); + return ret; +} + +static unsigned long test_cmpxchgl(unsigned long orig) +{ + unsigned long ret; + mem = orig; + asm("cmpxchgl %[cmp],%[mem]" + : [ mem ] "+m"(mem), [ rax ] "=a"(ret) + : [ cmp ] "r"(0x77777777u), "a"(orig)); + return ret; +} + +int main() +{ + unsigned long test = 0xdeadbeef12345678ull; + assert(test == test_cmpxchgb(test)); + assert(test == test_cmpxchgw(test)); + assert(test == test_cmpxchgl(test)); + return 0; +} |