From e301c61fb32e511a2663064c0b036d8c1e63a094 Mon Sep 17 00:00:00 2001 From: Yin Fengwei Date: Tue, 29 Dec 2020 11:27:08 +0800 Subject: [PATCH] hv: ptirq: Shouldn't change sid if intx irq mapping was added Now, we use hash table to maintain intx irq mapping by using the key generated from sid. So once the entry is added,we can not update source ide any more. Otherwise, we can't locate the entry with the key generated from new source ide. For source id change, remove_remapping/add_remapping is used instead of update source id directly if entry was added already. Tracked-On: #5640 Signed-off-by: Yin Fengwei Acked-by: Eddie Dong --- hypervisor/arch/x86/guest/assign.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/hypervisor/arch/x86/guest/assign.c b/hypervisor/arch/x86/guest/assign.c index 3c2166e83..ab62e5775 100644 --- a/hypervisor/arch/x86/guest/assign.c +++ b/hypervisor/arch/x86/guest/assign.c @@ -706,14 +706,23 @@ int32_t ptirq_intx_pin_remap(struct acrn_vm *vm, uint32_t virt_gsi, enum intx_ct entry = find_ptirq_entry(PTDEV_INTR_INTX, &alt_virt_sid, vm); if (entry != NULL) { - entry->virt_sid.value = virt_sid.value; - dev_dbg(DBG_LEVEL_IRQ, - "IOAPIC gsi=%hhu pirq=%u vgsi=%d switch from %s to %s for vm%d", + uint32_t phys_gsi = virt_gsi; + + remove_intx_remapping(vm, alt_virt_sid.intx_id.gsi, + alt_virt_sid.intx_id.ctlr); + entry = add_intx_remapping(vm, virt_gsi, phys_gsi, vgsi_ctlr); + if (entry == NULL) { + pr_err("%s, add intx remapping failed", __func__); + status = -ENODEV; + } else { + dev_dbg(DBG_LEVEL_IRQ, + "IOAPIC gsi=%hhu pirq=%u vgsi=%d from %s to %s for vm%d", entry->phys_sid.intx_id.gsi, entry->allocated_pirq, entry->virt_sid.intx_id.gsi, (vgsi_ctlr == INTX_CTLR_IOAPIC) ? "vPIC" : "vIOAPIC", (vgsi_ctlr == INTX_CTLR_IOAPIC) ? "vIOPIC" : "vPIC", entry->vm->vm_id); + } } }