diff mbox series

kvm: nVMX: Fix fault vector for VMX operation at CPL > 0

Message ID 20180727161850.172739-1-jmattson@google.com (mailing list archive)
State New, archived
Headers show
Series kvm: nVMX: Fix fault vector for VMX operation at CPL > 0 | expand

Commit Message

Jim Mattson July 27, 2018, 4:18 p.m. UTC
The fault that should be raised for a privilege level violation is #GP
rather than #UD.

Fixes: 727ba748e110b4 ("kvm: nVMX: Enforce cpl=0 for VMX instructions")
Signed-off-by: Jim Mattson <jmattson@google.com>
---
 arch/x86/kvm/vmx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Paolo Bonzini July 27, 2018, 4:28 p.m. UTC | #1
On 27/07/2018 18:18, Jim Mattson wrote:
> The fault that should be raised for a privilege level violation is #GP
> rather than #UD.
> 
> Fixes: 727ba748e110b4 ("kvm: nVMX: Enforce cpl=0 for VMX instructions")
> Signed-off-by: Jim Mattson <jmattson@google.com>
> ---
>  arch/x86/kvm/vmx.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index 5d8e317c2b04f..cb51808c73206 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -7941,7 +7941,7 @@ static int handle_vmon(struct kvm_vcpu *vcpu)
>  
>  	/* CPL=0 must be checked manually. */
>  	if (vmx_get_cpl(vcpu)) {
> -		kvm_queue_exception(vcpu, UD_VECTOR);
> +		kvm_inject_gp(vcpu, 0);
>  		return 1;
>  	}
>  
> @@ -8005,7 +8005,7 @@ static int handle_vmon(struct kvm_vcpu *vcpu)
>  static int nested_vmx_check_permission(struct kvm_vcpu *vcpu)
>  {
>  	if (vmx_get_cpl(vcpu)) {
> -		kvm_queue_exception(vcpu, UD_VECTOR);
> +		kvm_inject_gp(vcpu, 0);
>  		return 0;
>  	}
>  
> 

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
David Hildenbrand July 30, 2018, 8:30 a.m. UTC | #2
On 27.07.2018 18:18, Jim Mattson wrote:
> The fault that should be raised for a privilege level violation is #GP
> rather than #UD.
> 
> Fixes: 727ba748e110b4 ("kvm: nVMX: Enforce cpl=0 for VMX instructions")
> Signed-off-by: Jim Mattson <jmattson@google.com>
> ---
>  arch/x86/kvm/vmx.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index 5d8e317c2b04f..cb51808c73206 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -7941,7 +7941,7 @@ static int handle_vmon(struct kvm_vcpu *vcpu)
>  
>  	/* CPL=0 must be checked manually. */
>  	if (vmx_get_cpl(vcpu)) {
> -		kvm_queue_exception(vcpu, UD_VECTOR);
> +		kvm_inject_gp(vcpu, 0);
>  		return 1;
>  	}
>  
> @@ -8005,7 +8005,7 @@ static int handle_vmon(struct kvm_vcpu *vcpu)
>  static int nested_vmx_check_permission(struct kvm_vcpu *vcpu)
>  {
>  	if (vmx_get_cpl(vcpu)) {
> -		kvm_queue_exception(vcpu, UD_VECTOR);
> +		kvm_inject_gp(vcpu, 0);
>  		return 0;
>  	}
>  
> 

Reviewed-by: David Hildenbrand <david@redhat.com>
diff mbox series

Patch

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 5d8e317c2b04f..cb51808c73206 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -7941,7 +7941,7 @@  static int handle_vmon(struct kvm_vcpu *vcpu)
 
 	/* CPL=0 must be checked manually. */
 	if (vmx_get_cpl(vcpu)) {
-		kvm_queue_exception(vcpu, UD_VECTOR);
+		kvm_inject_gp(vcpu, 0);
 		return 1;
 	}
 
@@ -8005,7 +8005,7 @@  static int handle_vmon(struct kvm_vcpu *vcpu)
 static int nested_vmx_check_permission(struct kvm_vcpu *vcpu)
 {
 	if (vmx_get_cpl(vcpu)) {
-		kvm_queue_exception(vcpu, UD_VECTOR);
+		kvm_inject_gp(vcpu, 0);
 		return 0;
 	}