Skip to content

Commit 43ce76c

Browse files
ubizjakbonzini
authored andcommitted
KVM/x86: Use 32bit xor to clear registers in svm.c
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>
1 parent c4f5519 commit 43ce76c

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

arch/x86/kvm/svm.c

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5637,26 +5637,24 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
56375637
"mov %%r13, %c[r13](%[svm]) \n\t"
56385638
"mov %%r14, %c[r14](%[svm]) \n\t"
56395639
"mov %%r15, %c[r15](%[svm]) \n\t"
5640-
#endif
56415640
/*
56425641
* Clear host registers marked as clobbered to prevent
56435642
* speculative use.
56445643
*/
5645-
"xor %%" _ASM_BX ", %%" _ASM_BX " \n\t"
5646-
"xor %%" _ASM_CX ", %%" _ASM_CX " \n\t"
5647-
"xor %%" _ASM_DX ", %%" _ASM_DX " \n\t"
5648-
"xor %%" _ASM_SI ", %%" _ASM_SI " \n\t"
5649-
"xor %%" _ASM_DI ", %%" _ASM_DI " \n\t"
5650-
#ifdef CONFIG_X86_64
5651-
"xor %%r8, %%r8 \n\t"
5652-
"xor %%r9, %%r9 \n\t"
5653-
"xor %%r10, %%r10 \n\t"
5654-
"xor %%r11, %%r11 \n\t"
5655-
"xor %%r12, %%r12 \n\t"
5656-
"xor %%r13, %%r13 \n\t"
5657-
"xor %%r14, %%r14 \n\t"
5658-
"xor %%r15, %%r15 \n\t"
5644+
"xor %%r8d, %%r8d \n\t"
5645+
"xor %%r9d, %%r9d \n\t"
5646+
"xor %%r10d, %%r10d \n\t"
5647+
"xor %%r11d, %%r11d \n\t"
5648+
"xor %%r12d, %%r12d \n\t"
5649+
"xor %%r13d, %%r13d \n\t"
5650+
"xor %%r14d, %%r14d \n\t"
5651+
"xor %%r15d, %%r15d \n\t"
56595652
#endif
5653+
"xor %%ebx, %%ebx \n\t"
5654+
"xor %%ecx, %%ecx \n\t"
5655+
"xor %%edx, %%edx \n\t"
5656+
"xor %%esi, %%esi \n\t"
5657+
"xor %%edi, %%edi \n\t"
56605658
"pop %%" _ASM_BP
56615659
:
56625660
: [svm]"a"(svm),

arch/x86/kvm/vmx.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262

6363
#define __ex(x) __kvm_handle_fault_on_reboot(x)
6464
#define __ex_clear(x, reg) \
65-
____kvm_handle_fault_on_reboot(x, "xorl " reg " , " reg)
65+
____kvm_handle_fault_on_reboot(x, "xor " reg ", " reg)
6666

6767
MODULE_AUTHOR("Qumranet");
6868
MODULE_LICENSE("GPL");
@@ -11285,6 +11285,10 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
1128511285
"mov %%r13, %c[r13](%0) \n\t"
1128611286
"mov %%r14, %c[r14](%0) \n\t"
1128711287
"mov %%r15, %c[r15](%0) \n\t"
11288+
/*
11289+
* Clear host registers marked as clobbered to prevent
11290+
* speculative use.
11291+
*/
1128811292
"xor %%r8d, %%r8d \n\t"
1128911293
"xor %%r9d, %%r9d \n\t"
1129011294
"xor %%r10d, %%r10d \n\t"

0 commit comments

Comments
 (0)