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:
Sainath Grandhi
2019-05-15 15:55:09 -07:00
committed by Eddie Dong
parent cb6a3e8f08
commit 536c69b9ff
10 changed files with 26 additions and 18 deletions

View File

@@ -27,7 +27,7 @@ void vcpu_thread(struct sched_object *obj)
init_vmcs(vcpu);
}
if (!is_lapic_pt(vcpu->vm)) {
if (!is_lapic_pt_enabled(vcpu->vm)) {
/* handle pending softirq when irq enable*/
do_softirq();
CPU_IRQ_DISABLE();
@@ -64,7 +64,7 @@ void vcpu_thread(struct sched_object *obj)
profiling_pre_vmexit_handler(vcpu);
if (!is_lapic_pt(vcpu->vm)) {
if (!is_lapic_pt_enabled(vcpu->vm)) {
CPU_IRQ_ENABLE();
}
/* Dispatch handler */

View File

@@ -479,7 +479,7 @@ int32_t hcall_inject_msi(struct acrn_vm *vm, uint16_t vmid, uint64_t param)
pr_err("%s: Unable copy param to vm\n", __func__);
} else {
/* For target cpu with lapic pt, send ipi instead of injection via vlapic */
if (is_lapic_pt(target_vm)) {
if (is_lapic_pt_enabled(target_vm)) {
inject_msi_lapic_pt(target_vm, &msi);
ret = 0;
} else {