[PATCH] KVM: VMX: Improve handle_external_interrupt_irqoff inline assembly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Improve handle_external_interrupt_irqoff inline assembly in several ways:
- use __stringify to use __KERNEL_DS and __KERNEL_CS directly in assembler
- use %rsp instead of _ASM_SP, since we are in CONFIG_X86_64 part
- use $-16 immediate to align %rsp
- avoid earlyclobber by using "l" GCC input operand constraint
- avoid temporary by using current_stack_pointer

The patch introduces no functional change.

Cc: Paolo Bonzini <pbonzini@xxxxxxxxxx>
Cc: Sean Christopherson <sean.j.christopherson@xxxxxxxxx>
Signed-off-by: Uros Bizjak <ubizjak@xxxxxxxxx>
---
 arch/x86/kvm/vmx/vmx.c | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)

diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
index 01330096ff3e..4b0d5f0044ff 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -6233,9 +6233,6 @@ static void handle_external_interrupt_irqoff(struct kvm_vcpu *vcpu)
 {
 	unsigned int vector;
 	unsigned long entry;
-#ifdef CONFIG_X86_64
-	unsigned long tmp;
-#endif
 	gate_desc *desc;
 	u32 intr_info;
 
@@ -6252,23 +6249,19 @@ static void handle_external_interrupt_irqoff(struct kvm_vcpu *vcpu)
 
 	asm volatile(
 #ifdef CONFIG_X86_64
-		"mov %%" _ASM_SP ", %[sp]\n\t"
-		"and $0xfffffffffffffff0, %%" _ASM_SP "\n\t"
-		"push $%c[ss]\n\t"
+		"and $-16, %%rsp\n\t"
+		"push $" __stringify(__KERNEL_DS) "\n\t"
 		"push %[sp]\n\t"
 #endif
 		"pushf\n\t"
-		__ASM_SIZE(push) " $%c[cs]\n\t"
+		__ASM_SIZE(push) " $" __stringify(__KERNEL_CS) "\n\t"
 		CALL_NOSPEC
+		: ASM_CALL_CONSTRAINT
 		:
 #ifdef CONFIG_X86_64
-		[sp]"=&r"(tmp),
+		[sp]"l"(current_stack_pointer),
 #endif
-		ASM_CALL_CONSTRAINT
-		:
-		[thunk_target]"r"(entry),
-		[ss]"i"(__KERNEL_DS),
-		[cs]"i"(__KERNEL_CS)
+		[thunk_target]"r"(entry)
 	);
 
 	kvm_after_interrupt(vcpu);
-- 
2.25.2




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux