mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-06 17:23:56 -06:00
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----- 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>
This commit is contained in:
commit
dd64bcea00
3 changed files with 101 additions and 28 deletions
|
@ -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)
|
||||
|
|
42
tests/tcg/x86_64/cmpxchg.c
Normal file
42
tests/tcg/x86_64/cmpxchg.c
Normal file
|
@ -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;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue