Re: [PATCH 2/3][KVM nVMX]: Check "load IA32_PAT" VM-entry control on vmentry of L2 guests

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Mar 18, 2019 at 09:46:23PM -0400, Krish Sadhukhan wrote:
> According to section "CHECKING AND LOADING GUEST STATE" in Intel SDM vol
> 3C, the following check is performed on vmentry of L2 guests:

Same comment about "of L2 guests".

> 
>     If the "load IA32_PAT" VM-entry control is 1, the value of the field
>     for the IA32_PAT MSR must be one that could be written by WRMSR
>     without fault at CPL 0. Specifically, each of the 8 bytes in the
>     field must have one of the values 0 (UC), 1 (WC), 4 (WT), 5 (WP),
>     6 (WB), or 7 (UC-).
> 
> Signed-off-by: Krish Sadhukhan <krish.sadhukhan@xxxxxxxxxx>
> Reviewed-by: Karl Heubaum <karl.heubaum@xxxxxxxxxx>
> ---
>  arch/x86/kvm/vmx/nested.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
> index a1b44d930d26..6185ba4e6e55 100644
> --- a/arch/x86/kvm/vmx/nested.c
> +++ b/arch/x86/kvm/vmx/nested.c
> @@ -2637,6 +2637,20 @@ static int nested_check_host_control_regs(struct kvm_vcpu *vcpu,
>  	return 0;
>  }
>  
> +/*
> + * Checks related to Control Registers, Debug Registers and MSRs in
> + * Guest State Area.
> + */
> +static int nested_check_guest_ctrl_dbg_regs_msrs(struct vmcs12 *vmcs12)
> +{
> +	if (vmcs12->vm_entry_controls & VM_ENTRY_LOAD_IA32_PAT) {
> +		if (nested_check_pat_fields(vmcs12->guest_ia32_pat))

Again, single if statement using &&.

> +			return -EINVAL;
> +	}
> +
> +	return 0;
> +}
> +
>  /*
>   * Checks related to Guest Non-register State
>   */
> @@ -2660,6 +2674,9 @@ static int nested_vmx_check_vmentry_prereqs(struct kvm_vcpu *vcpu,
>  	if (nested_check_host_control_regs(vcpu, vmcs12))
>  		return VMXERR_ENTRY_INVALID_HOST_STATE_FIELD;
>  
> +	if (nested_check_guest_ctrl_dbg_regs_msrs(vmcs12))
> +		return VMXERR_ENTRY_INVALID_CONTROL_FIELD;

This belongs in nested_vmx_check_vmentry_postreqs(), i.e. failed checks
when loading guest state result in VM-Exit.  And there are already control
register checks (cr0 and cr4) in nested_vmx_check_vmentry_postreqs().  It
probably makes sense to first add the PAT check as a direct call along
side the cr0 and cr4 checks, and then tack on a patch to add
nested_check_guest_ctrl_dbg_regs_msrs().

> +
>  	if (nested_check_guest_non_reg_state(vmcs12))
>  		return VMXERR_ENTRY_INVALID_CONTROL_FIELD;
>  
> -- 
> 2.17.2
> 



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux