diff options
author | Bill Wendling <morbo@google.com> | 2019-10-30 14:04:19 -0700 |
---|---|---|
committer | Thomas Huth <thuth@redhat.com> | 2020-06-16 15:00:07 +0200 |
commit | 2d9e3a376b9adcc93f9b9874f7bc5408a1269a22 (patch) | |
tree | e5e4408ec315d22873520fc450b7edc73065f2fa | |
parent | f3154609b29ad92746c77d46bca03e3b79431437 (diff) | |
download | kvm-unit-tests-2d9e3a376b9adcc93f9b9874f7bc5408a1269a22.tar.gz |
x86: use inline asm to retrieve stack pointer
According to GCC's documentation, the only supported use for specifying
registers for local variables is "to specify registers for input and
output operands when calling Extended asm." Using it as a shortcut to
get the value in a register isn't guaranteed to work, and clang
complains that the variable is uninitialized.
Signed-off-by: Bill Wendling <morbo@google.com>
Message-Id: <20191030210419.213407-7-morbo@google.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
-rw-r--r-- | x86/vmx_tests.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c index 68f93d3..fcd97a1 100644 --- a/x86/vmx_tests.c +++ b/x86/vmx_tests.c @@ -2253,7 +2253,9 @@ static void into_guest_main(void) .offset = (uintptr_t)&&into, .selector = KERNEL_CS32, }; - register uintptr_t rsp asm("rsp"); + uintptr_t rsp; + + asm volatile ("mov %%rsp, %0" : "=r"(rsp)); if (fp.offset != (uintptr_t)&&into) { printf("Code address too high.\n"); @@ -3349,7 +3351,9 @@ static void try_compat_invvpid(void *unused) .offset = (uintptr_t)&&invvpid, .selector = KERNEL_CS32, }; - register uintptr_t rsp asm("rsp"); + uintptr_t rsp; + + asm volatile ("mov %%rsp, %0" : "=r"(rsp)); TEST_ASSERT_MSG(fp.offset == (uintptr_t)&&invvpid, "Code address too high."); |