diff mbox series

[05/10] KVM: nVMX: Use vpid_sync_vcpu_addr() to emulate INVVPID with address

Message ID 20200220204356.8837-6-sean.j.christopherson@intel.com (mailing list archive)
State New, archived
Headers show
Series KVM: x86: Clean up VMX's TLB flushing code | expand

Commit Message

Sean Christopherson Feb. 20, 2020, 8:43 p.m. UTC
Use vpid_sync_vcpu_addr() to emulate the "individual address" variant of
INVVPID now that said function handles the fallback case of the (host)
CPU not supporting "individual address".

Note, the "vpid == 0" checks in the vpid_sync_*() helpers aren't
actually redundant with the "!operand.vpid" check in handle_invvpid(),
as the vpid passed to vpid_sync_vcpu_addr() is a KVM (host) controlled
value, i.e. vpid02 can be zero even if operand.vpid is non-zero.

No functional change intended.

Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
---
 arch/x86/kvm/vmx/nested.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

Comments

Vitaly Kuznetsov Feb. 21, 2020, 1:43 p.m. UTC | #1
Sean Christopherson <sean.j.christopherson@intel.com> writes:

> Use vpid_sync_vcpu_addr() to emulate the "individual address" variant of
> INVVPID now that said function handles the fallback case of the (host)
> CPU not supporting "individual address".
>
> Note, the "vpid == 0" checks in the vpid_sync_*() helpers aren't
> actually redundant with the "!operand.vpid" check in handle_invvpid(),
> as the vpid passed to vpid_sync_vcpu_addr() is a KVM (host) controlled
> value, i.e. vpid02 can be zero even if operand.vpid is non-zero.
>
> No functional change intended.
>
> Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
> ---
>  arch/x86/kvm/vmx/nested.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
>
> diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
> index 19ac4083667f..5a174be314e5 100644
> --- a/arch/x86/kvm/vmx/nested.c
> +++ b/arch/x86/kvm/vmx/nested.c
> @@ -5150,11 +5150,7 @@ static int handle_invvpid(struct kvm_vcpu *vcpu)
>  		    is_noncanonical_address(operand.gla, vcpu))
>  			return nested_vmx_failValid(vcpu,
>  				VMXERR_INVALID_OPERAND_TO_INVEPT_INVVPID);
> -		if (cpu_has_vmx_invvpid_individual_addr()) {
> -			__invvpid(VMX_VPID_EXTENT_INDIVIDUAL_ADDR,
> -				vpid02, operand.gla);
> -		} else
> -			vpid_sync_context(vpid02);
> +		vpid_sync_vcpu_addr(vpid02, operand.gla);
>  		break;
>  	case VMX_VPID_EXTENT_SINGLE_CONTEXT:
>  	case VMX_VPID_EXTENT_SINGLE_NON_GLOBAL:

Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>
diff mbox series

Patch

diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
index 19ac4083667f..5a174be314e5 100644
--- a/arch/x86/kvm/vmx/nested.c
+++ b/arch/x86/kvm/vmx/nested.c
@@ -5150,11 +5150,7 @@  static int handle_invvpid(struct kvm_vcpu *vcpu)
 		    is_noncanonical_address(operand.gla, vcpu))
 			return nested_vmx_failValid(vcpu,
 				VMXERR_INVALID_OPERAND_TO_INVEPT_INVVPID);
-		if (cpu_has_vmx_invvpid_individual_addr()) {
-			__invvpid(VMX_VPID_EXTENT_INDIVIDUAL_ADDR,
-				vpid02, operand.gla);
-		} else
-			vpid_sync_context(vpid02);
+		vpid_sync_vcpu_addr(vpid02, operand.gla);
 		break;
 	case VMX_VPID_EXTENT_SINGLE_CONTEXT:
 	case VMX_VPID_EXTENT_SINGLE_NON_GLOBAL: