[3/5] KVM: nVMX: Skip VM-Entry Control checks that are necessary only if VMCS12 is dirty
diff mbox series

Message ID 20190707071147.11651-4-krish.sadhukhan@oracle.com
State New
Headers show
Series
  • KVM: nVMX: Skip vmentry checks that are necessary only if VMCS12 is dirty
Related show

Commit Message

Krish Sadhukhan July 7, 2019, 7:11 a.m. UTC
..so that every nested vmentry is not slowed down by those checks.

Signed-off-by: Krish Sadhukhan <krish.sadhukhan@oracle.com>
---
 arch/x86/kvm/vmx/nested.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

Comments

Paolo Bonzini July 10, 2019, 4:28 p.m. UTC | #1
On 07/07/19 09:11, Krish Sadhukhan wrote:
> @@ -2603,7 +2612,8 @@ static int nested_check_vm_entry_controls(struct kvm_vcpu *vcpu,
>  		}
>  	}
>  
> -	if (nested_vmx_check_entry_msr_switch_controls(vcpu, vmcs12))
> +	if ((vmx->nested.dirty_vmcs12) &&
> +	    nested_check_vm_entry_controls_full(vcpu, vmcs12))
>  		return -EINVAL;
>  
>  	return 0;
> -- 

The vmx_control_verify above can be moved to the "rare" case.

Paolo

Patch
diff mbox series

diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
index 056eba497730..ffeeeb5ff520 100644
--- a/arch/x86/kvm/vmx/nested.c
+++ b/arch/x86/kvm/vmx/nested.c
@@ -2534,6 +2534,15 @@  static int nested_check_vm_exit_controls(struct kvm_vcpu *vcpu,
 	return 0;
 }
 
+static int nested_check_vm_entry_controls_full(struct kvm_vcpu *vcpu,
+					       struct vmcs12 *vmcs12)
+{
+	if (nested_vmx_check_entry_msr_switch_controls(vcpu, vmcs12))
+		return -EINVAL;
+
+	return 0;
+}
+
 /*
  * Checks related to VM-Entry Control Fields
  */
@@ -2603,7 +2612,8 @@  static int nested_check_vm_entry_controls(struct kvm_vcpu *vcpu,
 		}
 	}
 
-	if (nested_vmx_check_entry_msr_switch_controls(vcpu, vmcs12))
+	if ((vmx->nested.dirty_vmcs12) &&
+	    nested_check_vm_entry_controls_full(vcpu, vmcs12))
 		return -EINVAL;
 
 	return 0;