x86: clobber registers in switch_stack_and_jump() when !LIVEPATCH
authorJan Beulich <jbeulich@suse.com>
Wed, 16 Dec 2020 15:41:46 +0000 (16:41 +0100)
committerJan Beulich <jbeulich@suse.com>
Wed, 16 Dec 2020 15:41:46 +0000 (16:41 +0100)
In order to have the same effect on registers as a call to
check_for_livepatch_work() may have, clobber all call-clobbered
registers in debug builds.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Wei Liu <wl@xen.org>
xen/include/asm-x86/current.h

index 4d8822f78c9bf9f01e6ca74c48df4cf7f388705b..231994a2453d0f264b2a76a6981bf42650b5aff4 100644 (file)
@@ -120,6 +120,14 @@ unsigned long get_stack_dump_bottom (unsigned long sp);
 
 #ifdef CONFIG_LIVEPATCH
 # define CHECK_FOR_LIVEPATCH_WORK "call check_for_livepatch_work;"
+#elif defined(CONFIG_DEBUG)
+/* Mimic the clobbering effect a call has on registers. */
+# define CHECK_FOR_LIVEPATCH_WORK \
+    "mov $0x1234567890abcdef, %%rax\n\t" \
+    "mov %%rax, %%rcx; mov %%rax, %%rdx\n\t" \
+    "mov %%rax, %%rsi; mov %%rax, %%rdi\n\t" \
+    "mov %%rax, %%r8; mov %%rax, %%r9\n\t" \
+    "mov %%rax, %%r10; mov %%rax, %%r11\n\t"
 #else
 # define CHECK_FOR_LIVEPATCH_WORK ""
 #endif