On Thu, Nov 15, 2018 at 12:45:53AM -0500, Krish Sadhukhan wrote: > Separate out the checks in nested_check_vmentry_prereqs(), that are related > to the Host Control Registers and MSRs, to a separate function. The > re-organized cod is easier for readability, enhancement and maintenance. > > Signed-off-by: Krish Sadhukhan <krish.sadhukhan@xxxxxxxxxx> > Reviewed-by: Mihai Carabas <mihai.carabas@xxxxxxxxxx> > Reviewed-by: Mark Kanda <mark.kanda@xxxxxxxxxx> > --- > arch/x86/kvm/vmx.c | 17 ++++++++++++++--- > 1 file changed, 14 insertions(+), 3 deletions(-) > > diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c > index 368e38d..93e49aa 100644 > --- a/arch/x86/kvm/vmx.c > +++ b/arch/x86/kvm/vmx.c > @@ -12518,6 +12518,19 @@ static int nested_check_vm_entry_ctls(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs > return 0; > } > > +/* > + * Checks related to Host Control Registers and MSRs > + */ > +static int nested_check_host_ctl_regs(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12) Same comment as earlier, spell out "control" and wrap. > +{ > + if (!nested_host_cr0_valid(vcpu, vmcs12->host_cr0) || > + !nested_host_cr4_valid(vcpu, vmcs12->host_cr4) || > + !nested_cr3_valid(vcpu, vmcs12->host_cr3)) > + return -EINVAL; > + > + return 0; > +} > + > static int nested_check_vmentry_prereqs(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12) > { > if (vmcs12->guest_activity_state != GUEST_ACTIVITY_ACTIVE && > @@ -12529,9 +12542,7 @@ static int nested_check_vmentry_prereqs(struct kvm_vcpu *vcpu, struct vmcs12 *vm > nested_check_vm_entry_ctls(vcpu, vmcs12)) > return VMXERR_ENTRY_INVALID_CONTROL_FIELD; > > - if (!nested_host_cr0_valid(vcpu, vmcs12->host_cr0) || > - !nested_host_cr4_valid(vcpu, vmcs12->host_cr4) || > - !nested_cr3_valid(vcpu, vmcs12->host_cr3)) > + if (nested_check_host_ctl_regs(vcpu, vmcs12)) > return VMXERR_ENTRY_INVALID_HOST_STATE_FIELD; > > return 0; > -- > 2.9.5 >