]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
KVM/x86: Use 32bit xor to clear registers in svm.c
authorUros Bizjak <ubizjak@gmail.com>
Wed, 17 Oct 2018 14:46:57 +0000 (16:46 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 17 Oct 2018 17:08:21 +0000 (19:08 +0200)
x86_64 zero-extends 32bit xor operation to a full 64bit register.

Also add a comment and remove unnecessary instruction suffix in vmx.c

Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/svm.c
arch/x86/kvm/vmx.c

index 1086bebaeea3fb9f1137683e16f5b58078bca82c..f416f5c7f2aee11816f82f79f64da25919047b95 100644 (file)
@@ -5637,26 +5637,24 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
                "mov %%r13, %c[r13](%[svm]) \n\t"
                "mov %%r14, %c[r14](%[svm]) \n\t"
                "mov %%r15, %c[r15](%[svm]) \n\t"
-#endif
                /*
                * Clear host registers marked as clobbered to prevent
                * speculative use.
                */
-               "xor %%" _ASM_BX ", %%" _ASM_BX " \n\t"
-               "xor %%" _ASM_CX ", %%" _ASM_CX " \n\t"
-               "xor %%" _ASM_DX ", %%" _ASM_DX " \n\t"
-               "xor %%" _ASM_SI ", %%" _ASM_SI " \n\t"
-               "xor %%" _ASM_DI ", %%" _ASM_DI " \n\t"
-#ifdef CONFIG_X86_64
-               "xor %%r8, %%r8 \n\t"
-               "xor %%r9, %%r9 \n\t"
-               "xor %%r10, %%r10 \n\t"
-               "xor %%r11, %%r11 \n\t"
-               "xor %%r12, %%r12 \n\t"
-               "xor %%r13, %%r13 \n\t"
-               "xor %%r14, %%r14 \n\t"
-               "xor %%r15, %%r15 \n\t"
+               "xor %%r8d, %%r8d \n\t"
+               "xor %%r9d, %%r9d \n\t"
+               "xor %%r10d, %%r10d \n\t"
+               "xor %%r11d, %%r11d \n\t"
+               "xor %%r12d, %%r12d \n\t"
+               "xor %%r13d, %%r13d \n\t"
+               "xor %%r14d, %%r14d \n\t"
+               "xor %%r15d, %%r15d \n\t"
 #endif
+               "xor %%ebx, %%ebx \n\t"
+               "xor %%ecx, %%ecx \n\t"
+               "xor %%edx, %%edx \n\t"
+               "xor %%esi, %%esi \n\t"
+               "xor %%edi, %%edi \n\t"
                "pop %%" _ASM_BP
                :
                : [svm]"a"(svm),
index 91f4f528815020b9f2c634e2217aaaad5f106055..3677609145a4f9082d35d49fe2e82b80f8f230b0 100644 (file)
@@ -62,7 +62,7 @@
 
 #define __ex(x) __kvm_handle_fault_on_reboot(x)
 #define __ex_clear(x, reg) \
-       ____kvm_handle_fault_on_reboot(x, "xorl " reg " , " reg)
+       ____kvm_handle_fault_on_reboot(x, "xor " reg ", " reg)
 
 MODULE_AUTHOR("Qumranet");
 MODULE_LICENSE("GPL");
@@ -11285,6 +11285,10 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
                "mov %%r13, %c[r13](%0) \n\t"
                "mov %%r14, %c[r14](%0) \n\t"
                "mov %%r15, %c[r15](%0) \n\t"
+               /*
+               * Clear host registers marked as clobbered to prevent
+               * speculative use.
+               */
                "xor %%r8d,  %%r8d \n\t"
                "xor %%r9d,  %%r9d \n\t"
                "xor %%r10d, %%r10d \n\t"