]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
KVM: VMX: Manually load RDX in vCPU-run asm blob
authorSean Christopherson <sean.j.christopherson@intel.com>
Fri, 25 Jan 2019 15:40:53 +0000 (07:40 -0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 12 Feb 2019 12:12:16 +0000 (13:12 +0100)
Load RDX with the VMCS.HOST_RSP field encoding on-demand instead of
delegating to the compiler via an input constraint.  In addition to
saving one whole MOV instruction, this allows RDX to be properly
clobbered (in a future patch) instead of being saved/loaded to/from
the stack.

Despite nested_vmx_check_vmentry_hw() having similar code, leave it
alone, for now.  In that case, RDX is unconditionally used and isn't
clobbered, i.e. sending in HOST_RSP as an input is simpler.

Note that because HOST_RSP is an enum and not a define, it must be
redefined as an immediate instead of using __stringify(HOST_RSP).  The
naming "conflict" between host_rsp and HOST_RSP is slightly confusing,
but the former will be removed in a future patch, at which point
HOST_RSP is absolutely what is desired.

Reviewed-by: Jim Mattson <jmattson@google.com>
Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/vmx/vmx.c

index 3ae51a09f42079394d25c10258bab684c8101d21..b935ba3306aa6fbfbd3937a209f163550a3bc403 100644 (file)
@@ -6390,6 +6390,7 @@ static void __vmx_vcpu_run(struct kvm_vcpu *vcpu, struct vcpu_vmx *vmx)
                "mov %%" _ASM_SP ", (%%" _ASM_SI ") \n\t"
                "jmp 1f \n\t"
                "2: \n\t"
+               "mov $%c[HOST_RSP], %%" _ASM_DX " \n\t"
                __ex("vmwrite %%" _ASM_SP ", %%" _ASM_DX) "\n\t"
                "1: \n\t"
                "add $%c[wordsize], %%" _ASM_SP "\n\t" /* un-adjust RSP */
@@ -6482,10 +6483,11 @@ static void __vmx_vcpu_run(struct kvm_vcpu *vcpu, struct vcpu_vmx *vmx)
                "xor %%ebp, %%ebp \n\t"
                "pop  %%" _ASM_BP "; pop  %%" _ASM_DX " \n\t"
              : ASM_CALL_CONSTRAINT, "=S"((int){0})
-             : "c"(vmx), "d"((unsigned long)HOST_RSP), "S"(evmcs_rsp),
+             : "c"(vmx), "S"(evmcs_rsp),
                [launched]"i"(offsetof(struct vcpu_vmx, __launched)),
                [fail]"i"(offsetof(struct vcpu_vmx, fail)),
                [host_rsp]"i"(offsetof(struct vcpu_vmx, host_rsp)),
+               [HOST_RSP]"i"(HOST_RSP),
                [rax]"i"(offsetof(struct vcpu_vmx, vcpu.arch.regs[VCPU_REGS_RAX])),
                [rbx]"i"(offsetof(struct vcpu_vmx, vcpu.arch.regs[VCPU_REGS_RBX])),
                [rcx]"i"(offsetof(struct vcpu_vmx, vcpu.arch.regs[VCPU_REGS_RCX])),