All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/kvm/nVMX: don't skip emulated instruction twice when vmptr address is not backed
@ 2019-01-09 17:22 Vitaly Kuznetsov
  2019-01-09 17:27 ` Sean Christopherson
  2019-01-09 17:51 ` Cornelia Huck
  0 siblings, 2 replies; 3+ messages in thread
From: Vitaly Kuznetsov @ 2019-01-09 17:22 UTC (permalink / raw)
  To: kvm
  Cc: Paolo Bonzini, Radim Krčmář,
	linux-kernel, Andrew Jones, Cornelia Huck, Jim Mattson,
	Sean Christopherson

Since commit 09abb5e3e5e50 ("KVM: nVMX: call kvm_skip_emulated_instruction
in nested_vmx_{fail,succeed}") nested_vmx_failValid() results in
kvm_skip_emulated_instruction() so doing it again in handle_vmptrld() when
vmptr address is not backed is wrong, we end up advancing RIP twice.

Fixes: fca91f6d60b6e ("kvm: nVMX: Set VM instruction error for VMPTRLD of unbacked page")
Reported-by: Cornelia Huck <cohuck@redhat.com>
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
---
 arch/x86/kvm/vmx/nested.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
index 3170e291215d..2616bd2c7f2c 100644
--- a/arch/x86/kvm/vmx/nested.c
+++ b/arch/x86/kvm/vmx/nested.c
@@ -4540,9 +4540,8 @@ static int handle_vmptrld(struct kvm_vcpu *vcpu)
 			 * given physical address won't match the required
 			 * VMCS12_REVISION identifier.
 			 */
-			nested_vmx_failValid(vcpu,
+			return nested_vmx_failValid(vcpu,
 				VMXERR_VMPTRLD_INCORRECT_VMCS_REVISION_ID);
-			return kvm_skip_emulated_instruction(vcpu);
 		}
 		new_vmcs12 = kmap(page);
 		if (new_vmcs12->hdr.revision_id != VMCS12_REVISION ||
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] x86/kvm/nVMX: don't skip emulated instruction twice when vmptr address is not backed
  2019-01-09 17:22 [PATCH] x86/kvm/nVMX: don't skip emulated instruction twice when vmptr address is not backed Vitaly Kuznetsov
@ 2019-01-09 17:27 ` Sean Christopherson
  2019-01-09 17:51 ` Cornelia Huck
  1 sibling, 0 replies; 3+ messages in thread
From: Sean Christopherson @ 2019-01-09 17:27 UTC (permalink / raw)
  To: Vitaly Kuznetsov
  Cc: kvm, Paolo Bonzini, Radim Krčmář,
	linux-kernel, Andrew Jones, Cornelia Huck, Jim Mattson

On Wed, Jan 09, 2019 at 06:22:56PM +0100, Vitaly Kuznetsov wrote:
> Since commit 09abb5e3e5e50 ("KVM: nVMX: call kvm_skip_emulated_instruction
> in nested_vmx_{fail,succeed}") nested_vmx_failValid() results in
> kvm_skip_emulated_instruction() so doing it again in handle_vmptrld() when
> vmptr address is not backed is wrong, we end up advancing RIP twice.
> 
> Fixes: fca91f6d60b6e ("kvm: nVMX: Set VM instruction error for VMPTRLD of unbacked page")
> Reported-by: Cornelia Huck <cohuck@redhat.com>
> Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>

Reviewed-by: Sean Christopherson <sean.j.christopherson@intel.com>

> ---
>  arch/x86/kvm/vmx/nested.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
> index 3170e291215d..2616bd2c7f2c 100644
> --- a/arch/x86/kvm/vmx/nested.c
> +++ b/arch/x86/kvm/vmx/nested.c
> @@ -4540,9 +4540,8 @@ static int handle_vmptrld(struct kvm_vcpu *vcpu)
>  			 * given physical address won't match the required
>  			 * VMCS12_REVISION identifier.
>  			 */
> -			nested_vmx_failValid(vcpu,
> +			return nested_vmx_failValid(vcpu,
>  				VMXERR_VMPTRLD_INCORRECT_VMCS_REVISION_ID);
> -			return kvm_skip_emulated_instruction(vcpu);
>  		}
>  		new_vmcs12 = kmap(page);
>  		if (new_vmcs12->hdr.revision_id != VMCS12_REVISION ||
> -- 
> 2.20.1
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] x86/kvm/nVMX: don't skip emulated instruction twice when vmptr address is not backed
  2019-01-09 17:22 [PATCH] x86/kvm/nVMX: don't skip emulated instruction twice when vmptr address is not backed Vitaly Kuznetsov
  2019-01-09 17:27 ` Sean Christopherson
@ 2019-01-09 17:51 ` Cornelia Huck
  1 sibling, 0 replies; 3+ messages in thread
From: Cornelia Huck @ 2019-01-09 17:51 UTC (permalink / raw)
  To: Vitaly Kuznetsov
  Cc: kvm, Paolo Bonzini, Radim Krčmář,
	linux-kernel, Andrew Jones, Jim Mattson, Sean Christopherson

On Wed,  9 Jan 2019 18:22:56 +0100
Vitaly Kuznetsov <vkuznets@redhat.com> wrote:

> Since commit 09abb5e3e5e50 ("KVM: nVMX: call kvm_skip_emulated_instruction
> in nested_vmx_{fail,succeed}") nested_vmx_failValid() results in
> kvm_skip_emulated_instruction() so doing it again in handle_vmptrld() when
> vmptr address is not backed is wrong, we end up advancing RIP twice.
> 
> Fixes: fca91f6d60b6e ("kvm: nVMX: Set VM instruction error for VMPTRLD of unbacked page")
> Reported-by: Cornelia Huck <cohuck@redhat.com>
> Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
> ---
>  arch/x86/kvm/vmx/nested.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
> index 3170e291215d..2616bd2c7f2c 100644
> --- a/arch/x86/kvm/vmx/nested.c
> +++ b/arch/x86/kvm/vmx/nested.c
> @@ -4540,9 +4540,8 @@ static int handle_vmptrld(struct kvm_vcpu *vcpu)
>  			 * given physical address won't match the required
>  			 * VMCS12_REVISION identifier.
>  			 */
> -			nested_vmx_failValid(vcpu,
> +			return nested_vmx_failValid(vcpu,
>  				VMXERR_VMPTRLD_INCORRECT_VMCS_REVISION_ID);
> -			return kvm_skip_emulated_instruction(vcpu);
>  		}
>  		new_vmcs12 = kmap(page);
>  		if (new_vmcs12->hdr.revision_id != VMCS12_REVISION ||

Not that I would be a nested vmx expert, but this looks correct.

Reviewed-by: Cornelia Huck <cohuck@redhat.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-01-09 17:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-09 17:22 [PATCH] x86/kvm/nVMX: don't skip emulated instruction twice when vmptr address is not backed Vitaly Kuznetsov
2019-01-09 17:27 ` Sean Christopherson
2019-01-09 17:51 ` Cornelia Huck

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.