LAPIC passthrough is supported based on vLAPIC, the guest OS first boots with vLAPIC in xAPIC mode and then switches to x2APIC mode to enable the LAPIC passthrough.
In case of LAPIC passthrough based on vLAPIC, the system will have the following characteristics.
IRQs received by the LAPIC can be handled by the Guest VM without vmexit
Guest VM always see virtual LAPIC IDs for security consideration
most MSRs are directly accessible from Guest VM except for XAPICID, LDR and ICR. Write operations to ICR will be trapped to avoid malicious IPIs. Read operations to XAPIC and LDR will be trapped in order to make the Guest VM always see the virtual LAPIC IDs instead of the physical ones.
/* * After switch to x2apic mode, most MSRs are passthrough to guest, but vlapic is still valid * for virtualization of some MSRs for security consideration: * - XAPICID/LDR: Read to XAPICID/LDR need to be trapped to guarantee guest always see right vlapic_id. * - ICR: Write to ICR need to be trapped to avoid milicious IPI. */
/* * If vLAPIC is in xAPIC mode and guest tries to access x2APIC MSRs * inject a GP to guest */ vlapic = vcpu_vlapic(vcpu); if (is_x2apic_enabled(vlapic)) { if (is_lapic_pt_configured(vcpu->vm)) { switch (msr) { case MSR_IA32_EXT_APIC_ICR: error = vlapic_x2apic_pt_icr_access(vcpu, val); break; ...