Commit df5524e5 authored by Krish Sadhukhan's avatar Krish Sadhukhan Committed by Greg Kroah-Hartman

x86: Add check for APIC access address for vmentry of L2 guests

[ Upstream commit f0f4cf5b ]

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.
Reviewed-by: default avatarMihai Carabas <>
Reviewed-by: default avatarKonrad Rzeszutek Wilk <>
Reviewed-by: default avatarJim Mattson <>
Reviewed-by: default avatarWanpeng Li <>
Signed-off-by: default avatarKrish Sadhukhan <>
Signed-off-by: default avatarPaolo Bonzini <>
Signed-off-by: default avatarSasha Levin <>
Signed-off-by: default avatarGreg Kroah-Hartman <>
parent 9b78e9dd
......@@ -10318,6 +10318,16 @@ static inline bool nested_vmx_merge_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;
return 0;
static int nested_vmx_check_apicv_controls(struct kvm_vcpu *vcpu,
struct vmcs12 *vmcs12)
......@@ -10961,6 +10971,9 @@ static int check_vmentry_prereqs(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12)
if (nested_vmx_check_msr_bitmap_controls(vcpu, vmcs12))
if (nested_vmx_check_apic_access_controls(vcpu, vmcs12))
if (nested_vmx_check_tpr_shadow_controls(vcpu, vmcs12))
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment