mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-22 17:27:53 +00:00
hv: send IPI instead of irq injection to notify vcpu with lapic pt
For VM with local apic pt for realtime scenatios, we support virtio device with PMD backend. But we still need to inject MSI to notify the front-end, to avoid changing the front-end drivers. Since the lapic is passed through, irq injection to vlapic won't work. This commit fix it by sending IPI with vector need to inject. Tracked-On: #2351 Signed-off-by: Yan, Like <like.yan@intel.com> Acked-by: Anthony Xu <anthony.xu@intel.com>
This commit is contained in:
@@ -101,7 +101,7 @@ vm_lapic_from_vcpu_id(struct acrn_vm *vm, uint16_t vcpu_id)
|
||||
return vcpu_vlapic(vcpu);
|
||||
}
|
||||
|
||||
static uint16_t vm_apicid2vcpu_id(struct acrn_vm *vm, uint8_t lapicid)
|
||||
static uint16_t vm_apicid2vcpu_id(struct acrn_vm *vm, uint32_t lapicid)
|
||||
{
|
||||
uint16_t i;
|
||||
struct acrn_vcpu *vcpu;
|
||||
@@ -117,7 +117,7 @@ static uint16_t vm_apicid2vcpu_id(struct acrn_vm *vm, uint8_t lapicid)
|
||||
|
||||
if (cpu_id == INVALID_CPU_ID) {
|
||||
cpu_id = get_pcpu_nums();
|
||||
pr_err("%s: bad lapicid %hhu", __func__, lapicid);
|
||||
pr_err("%s: bad lapicid %lu", __func__, lapicid);
|
||||
}
|
||||
|
||||
return cpu_id;
|
||||
@@ -1045,7 +1045,7 @@ vlapic_calcdest(struct acrn_vm *vm, uint64_t *dmask, uint32_t dest, bool phys, b
|
||||
* Physical mode: destination is LAPIC ID.
|
||||
*/
|
||||
*dmask = 0UL;
|
||||
vcpu_id = vm_apicid2vcpu_id(vm, (uint8_t)dest);
|
||||
vcpu_id = vm_apicid2vcpu_id(vm, dest);
|
||||
if (vcpu_id < vm->hw.created_vcpus) {
|
||||
bitmap_set_lock(vcpu_id, dmask);
|
||||
}
|
||||
@@ -1135,6 +1135,57 @@ vlapic_calcdest(struct acrn_vm *vm, uint64_t *dmask, uint32_t dest, bool phys, b
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* This function populates 'dmask' with the set of vcpus that is the possible destination
|
||||
* when lapic is passthru.
|
||||
*/
|
||||
void
|
||||
vlapic_calcdest_lapic_pt(struct acrn_vm *vm, uint64_t *dmask, uint32_t dest, bool phys)
|
||||
{
|
||||
struct acrn_vlapic *vlapic;
|
||||
struct acrn_vcpu *vcpu;
|
||||
uint32_t ldr, logical_id, dest_logical_id, dest_cluster_id;
|
||||
uint16_t vcpu_id;
|
||||
|
||||
if (dest == 0xffU) {
|
||||
/*
|
||||
* Broadcast in both logical and physical modes.
|
||||
*/
|
||||
*dmask = vm_active_cpus(vm);
|
||||
} else if (phys) {
|
||||
/*
|
||||
* Physical mode: destination is LAPIC ID.
|
||||
*/
|
||||
*dmask = 0UL;
|
||||
vcpu_id = vm_apicid2vcpu_id(vm, dest);
|
||||
if (vcpu_id < vm->hw.created_vcpus) {
|
||||
bitmap_set_lock(vcpu_id, dmask);
|
||||
}
|
||||
dev_dbg(ACRN_DBG_LAPICPT, "%s: phys destmod, dmask: 0x%016llx", __func__, *dmask);
|
||||
} else {
|
||||
/*
|
||||
* Logical mode: match each APIC that has a bit set
|
||||
* in its LDR that matches a bit in the ldest.
|
||||
*/
|
||||
foreach_vcpu(vcpu_id, vm, vcpu) {
|
||||
vlapic = vm_lapic_from_vcpu_id(vm, vcpu_id);
|
||||
|
||||
ldr = vlapic->apic_page.ldr.v;
|
||||
logical_id = ldr & 0xFFFFU;
|
||||
|
||||
dest_cluster_id = (dest >> 16U) & 0xFFFFU;
|
||||
dest_logical_id = dest & 0xFFFFU;
|
||||
if (dest_cluster_id != ((ldr >> 16U) & 0xFFFFU)) {
|
||||
continue;
|
||||
}
|
||||
if ((dest_logical_id & logical_id) != 0U) {
|
||||
bitmap_set_lock(vcpu_id, dmask);
|
||||
}
|
||||
}
|
||||
dev_dbg(ACRN_DBG_LAPICPT, "%s: logical destmod, dmask: 0x%016llx", __func__, *dmask);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
vlapic_set_tpr(struct acrn_vlapic *vlapic, uint32_t val)
|
||||
{
|
||||
|
@@ -6,27 +6,6 @@
|
||||
|
||||
#include <hypervisor.h>
|
||||
|
||||
/* x2APIC Interrupt Command Register (ICR) structure */
|
||||
union apic_icr {
|
||||
uint64_t value;
|
||||
struct {
|
||||
uint32_t lo_32;
|
||||
uint32_t hi_32;
|
||||
} value_32;
|
||||
struct {
|
||||
uint32_t vector:8;
|
||||
uint32_t delivery_mode:3;
|
||||
uint32_t destination_mode:1;
|
||||
uint32_t rsvd_1:2;
|
||||
uint32_t level:1;
|
||||
uint32_t trigger_mode:1;
|
||||
uint32_t rsvd_2:2;
|
||||
uint32_t shorthand:2;
|
||||
uint32_t rsvd_3:12;
|
||||
uint32_t dest_field:32;
|
||||
} bits;
|
||||
};
|
||||
|
||||
union lapic_base_msr {
|
||||
uint64_t value;
|
||||
struct {
|
||||
|
Reference in New Issue
Block a user