mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-21 08:50:27 +00:00
hv: distinguish between LAPIC_PASSTHROUGH configured vs enabled
ACRN supports LAPIC emulation for guests using x86 APICv. When guest OS/BIOS switches from xAPIC to x2APIC mode of operation, ACRN also supports switching froom LAPIC emulation to LAPIC passthrough to guest. User/developer needs to configure GUEST_FLAG_LAPIC_PASSTHROUGH for guest_flags in the corresponding VM's config for ACRN to enable LAPIC passthrough. This patch does the following 1)Fixes a bug in the abovementioned feature. For a guest that is configured with GUEST_FLAG_LAPIC_PASSTHROUGH, during the time period guest is using xAPIC mode of LAPIC, virtual interrupts are not delivered. This can be manifested as guest hang when it does not receive virtual timer interrupts. 2)ACRN exposes physical topology via CPUID leaf 0xb to LAPIC PT VMs. This patch removes that condition and exposes virtual topology via CPUID leaf 0xb. Tracked-On: #3136 Signed-off-by: Sainath Grandhi <sainath.grandhi@intel.com> Reviewed-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
committed by
Eddie Dong
parent
cb6a3e8f08
commit
536c69b9ff
@@ -1768,7 +1768,7 @@ int32_t vlapic_set_apicbase(struct acrn_vlapic *vlapic, uint64_t new)
|
||||
changed = vlapic->msr_apicbase ^ new;
|
||||
|
||||
if ((changed == APICBASE_X2APIC) && ((new & APICBASE_X2APIC) == APICBASE_X2APIC)) {
|
||||
vlapic->msr_apicbase = new;
|
||||
atomic_set64(&vlapic->msr_apicbase, changed);
|
||||
vlapic_build_x2apic_id(vlapic);
|
||||
switch_apicv_mode_x2apic(vlapic->vcpu);
|
||||
ret = 0;
|
||||
@@ -2075,7 +2075,7 @@ int32_t vlapic_x2apic_read(struct acrn_vcpu *vcpu, uint32_t msr, uint64_t *val)
|
||||
*/
|
||||
vlapic = vcpu_vlapic(vcpu);
|
||||
if (is_x2apic_enabled(vlapic)) {
|
||||
if (is_lapic_pt(vcpu->vm)) {
|
||||
if (is_lapic_pt_configured(vcpu->vm)) {
|
||||
switch (msr) {
|
||||
case MSR_IA32_EXT_APIC_LDR:
|
||||
case MSR_IA32_EXT_XAPICID:
|
||||
@@ -2109,7 +2109,7 @@ int32_t vlapic_x2apic_write(struct acrn_vcpu *vcpu, uint32_t msr, uint64_t val)
|
||||
*/
|
||||
vlapic = vcpu_vlapic(vcpu);
|
||||
if (is_x2apic_enabled(vlapic)) {
|
||||
if (is_lapic_pt(vcpu->vm)) {
|
||||
if (is_lapic_pt_configured(vcpu->vm)) {
|
||||
switch (msr) {
|
||||
case MSR_IA32_EXT_APIC_ICR:
|
||||
error = vlapic_x2apic_pt_icr_access(vcpu->vm, val);
|
||||
@@ -2575,3 +2575,14 @@ void vlapic_set_apicv_ops(void)
|
||||
apicv_ops = &apicv_basic_ops;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @pre vm != NULL
|
||||
* @pre vm->vmid < CONFIG_MAX_VM_NUM
|
||||
*/
|
||||
bool is_lapic_pt_enabled(struct acrn_vm *vm)
|
||||
{
|
||||
struct acrn_vcpu *vcpu = vcpu_from_vid(vm, 0U);
|
||||
|
||||
return ((is_x2apic_enabled(vcpu_vlapic(vcpu))) && (is_lapic_pt_configured(vm)));
|
||||
}
|
||||
|
Reference in New Issue
Block a user