Message ID | 20180411051017.12959-2-krish.sadhukhan@oracle.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Tue, Apr 10, 2018 at 10:10 PM, Krish Sadhukhan <krish.sadhukhan@oracle.com> wrote: > According to the sub-section titled 'VM-Execution Control Fields' in the > section titled 'Basic VM-Entry Checks' in Intel SDM vol. 3C, the following > vmentry check must be enforced: > > If the “virtualize APIC-accesses” VM-execution control is 1, the > APIC-access address must satisfy the following checks: > > - Bits 11:0 of the address must be 0. > - The address should not set any bits beyond the processor’s > physical-address width. > > This patch adds the necessary check to conform to this rule. If the check > fails, we cause the L2 VMENTRY to fail which is what the associated unit > test (following patch) expects. > > Signed-off-by: Krish Sadhukhan <krish.sadhukhan@oracle.com> > Reviewed-by: Mihai Carabas <mihai.carabas@oracle.com> > Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Reviewed-by: Jim Mattson <jmattson@google.com>
2018-04-12 5:44 GMT+08:00 Jim Mattson <jmattson@google.com>: > On Tue, Apr 10, 2018 at 10:10 PM, Krish Sadhukhan > <krish.sadhukhan@oracle.com> wrote: >> According to the sub-section titled 'VM-Execution Control Fields' in the >> section titled 'Basic VM-Entry Checks' in Intel SDM vol. 3C, the following >> vmentry check must be enforced: >> >> If the “virtualize APIC-accesses” VM-execution control is 1, the >> APIC-access address must satisfy the following checks: >> >> - Bits 11:0 of the address must be 0. >> - The address should not set any bits beyond the processor’s >> physical-address width. >> >> This patch adds the necessary check to conform to this rule. If the check >> fails, we cause the L2 VMENTRY to fail which is what the associated unit >> test (following patch) expects. >> >> Signed-off-by: Krish Sadhukhan <krish.sadhukhan@oracle.com> >> Reviewed-by: Mihai Carabas <mihai.carabas@oracle.com> >> Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> > Reviewed-by: Jim Mattson <jmattson@google.com> Reviewed-by: Wanpeng Li <wanpengli@tencent.com> Regards, Wanpeng Li
On 12/04/2018 03:10, Wanpeng Li wrote: > 2018-04-12 5:44 GMT+08:00 Jim Mattson <jmattson@google.com>: >> On Tue, Apr 10, 2018 at 10:10 PM, Krish Sadhukhan >>> Reviewed-by: Mihai Carabas <mihai.carabas@oracle.com> >>> Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> >> Reviewed-by: Jim Mattson <jmattson@google.com> > > Reviewed-by: Wanpeng Li <wanpengli@tencent.com> The more the merrier! Thanks all, I queued the patch. Paolo
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 051dab7..591c2ae 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -10305,6 +10305,16 @@ static inline bool nested_vmx_prepare_msr_bitmap(struct kvm_vcpu *vcpu, return true; } +static int nested_vmx_check_apic_access_controls(struct kvm_vcpu *vcpu, + struct vmcs12 *vmcs12) +{ + if (nested_cpu_has2(vmcs12, SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES) && + !page_address_valid(vcpu, vmcs12->apic_access_addr)) + return -EINVAL; + else + return 0; +} + static int nested_vmx_check_apicv_controls(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12) { @@ -10973,6 +10983,9 @@ static int check_vmentry_prereqs(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12) if (nested_vmx_check_msr_bitmap_controls(vcpu, vmcs12)) return VMXERR_ENTRY_INVALID_CONTROL_FIELD; + if (nested_vmx_check_apic_access_controls(vcpu, vmcs12)) + return VMXERR_ENTRY_INVALID_CONTROL_FIELD; + if (nested_vmx_check_tpr_shadow_controls(vcpu, vmcs12)) return VMXERR_ENTRY_INVALID_CONTROL_FIELD;