[04/29] KVM: VMX: Save RSI to an unused output in the vCPU-run asm blob
diff mbox series

Message ID 20190118212037.24412-5-sean.j.christopherson@intel.com
State New
Headers show
Series
  • KVM: VMX: Move vCPU-run to proper asm sub-routine
Related show

Commit Message

Sean Christopherson Jan. 18, 2019, 9:20 p.m. UTC
RSI is clobbered by the vCPU-run asm blob, but it's not marked as such,
probably because GCC doesn't let you mark inputs as clobbered.  "Save"
RSI to a dummy output so that GCC recognizes it as being clobbered.

Fixes: 773e8a0425c9 ("x86/kvm: use Enlightened VMCS when running on Hyper-V")
Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
---
 arch/x86/kvm/vmx/vmx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jim Mattson Jan. 18, 2019, 11:48 p.m. UTC | #1
On Fri, Jan 18, 2019 at 1:22 PM Sean Christopherson
<sean.j.christopherson@intel.com> wrote:
>
> RSI is clobbered by the vCPU-run asm blob, but it's not marked as such,
> probably because GCC doesn't let you mark inputs as clobbered.  "Save"
> RSI to a dummy output so that GCC recognizes it as being clobbered.
>
> Fixes: 773e8a0425c9 ("x86/kvm: use Enlightened VMCS when running on Hyper-V")
> Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
> ---
>  arch/x86/kvm/vmx/vmx.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
> index adf59fd23a6c..e8e2e289828d 100644
> --- a/arch/x86/kvm/vmx/vmx.c
> +++ b/arch/x86/kvm/vmx/vmx.c
> @@ -6472,7 +6472,7 @@ static void __vmx_vcpu_run(struct kvm_vcpu *vcpu, struct vcpu_vmx *vmx)
>                 "xor %%esi, %%esi \n\t"
>                 "xor %%edi, %%edi \n\t"
>                 "pop  %%" _ASM_BP "; pop  %%" _ASM_DX " \n\t"
> -             : ASM_CALL_CONSTRAINT
> +             : ASM_CALL_CONSTRAINT, "=S"((int){0})
>               : "c"(vmx), "d"((unsigned long)HOST_RSP), "S"(evmcs_rsp),
>                 [launched]"i"(offsetof(struct vcpu_vmx, __launched)),
>                 [fail]"i"(offsetof(struct vcpu_vmx, fail)),

Nice use of a compound literal to avoid a dummy declaration. I haven't
seen that idiom before.

Reviewed-by: Jim Mattson <jmattson@google.com>

Patch
diff mbox series

diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
index adf59fd23a6c..e8e2e289828d 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -6472,7 +6472,7 @@  static void __vmx_vcpu_run(struct kvm_vcpu *vcpu, struct vcpu_vmx *vmx)
 		"xor %%esi, %%esi \n\t"
 		"xor %%edi, %%edi \n\t"
 		"pop  %%" _ASM_BP "; pop  %%" _ASM_DX " \n\t"
-	      : ASM_CALL_CONSTRAINT
+	      : ASM_CALL_CONSTRAINT, "=S"((int){0})
 	      : "c"(vmx), "d"((unsigned long)HOST_RSP), "S"(evmcs_rsp),
 		[launched]"i"(offsetof(struct vcpu_vmx, __launched)),
 		[fail]"i"(offsetof(struct vcpu_vmx, fail)),