mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-19 04:02:05 +00:00
hv: Move error checking for hypercall parameters out of assign module
Moving checks on validity of IOAPIC interrupt remapping hypercall parameters to hypercall module Tracked-On: #4151 Signed-off-by: Sainath Grandhi <sainath.grandhi@intel.com> Acked-by: Eddie Dong <eddie.dong@Intel.com>
This commit is contained in:
parent
37eb369f89
commit
9e21c5bda4
@ -350,11 +350,6 @@ static struct ptirq_remapping_info *add_intx_remapping(struct acrn_vm *vm, uint3
|
||||
DEFINE_INTX_SID(virt_sid, virt_pin, vpin_ctlr);
|
||||
uint32_t phys_irq = ioapic_pin_to_irq(phys_pin);
|
||||
|
||||
if (((vpin_ctlr == INTX_CTLR_IOAPIC) && (virt_pin >= vioapic_pincount(vm))) || ((vpin_ctlr == INTX_CTLR_PIC) && (virt_pin >= vpic_pincount()))) {
|
||||
pr_err("ptirq_add_intx_remapping fails!\n");
|
||||
} else if (!ioapic_irq_is_gsi(phys_irq)) {
|
||||
pr_err("%s, invalid phys_pin: %d <-> irq: 0x%x is not a GSI\n", __func__, phys_pin, phys_irq);
|
||||
} else {
|
||||
entry = ptirq_lookup_entry_by_sid(PTDEV_INTR_INTX, &phys_sid, NULL);
|
||||
if (entry == NULL) {
|
||||
if (ptirq_lookup_entry_by_sid(PTDEV_INTR_INTX, &virt_sid, vm) == NULL) {
|
||||
@ -388,14 +383,15 @@ static struct ptirq_remapping_info *add_intx_remapping(struct acrn_vm *vm, uint3
|
||||
* required. */
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ptirq entry is either created or transferred from SOS VM to Post-launched VM
|
||||
*/
|
||||
|
||||
if (entry != NULL) {
|
||||
dev_dbg(DBG_LEVEL_IRQ, "VM%d INTX add pin mapping vpin%d:ppin%d",
|
||||
entry->vm->vm_id, virt_pin, phys_pin);
|
||||
}
|
||||
}
|
||||
|
||||
return entry;
|
||||
}
|
||||
@ -408,9 +404,6 @@ static void remove_intx_remapping(const struct acrn_vm *vm, uint32_t virt_pin, e
|
||||
struct intr_source intr_src;
|
||||
DEFINE_INTX_SID(virt_sid, virt_pin, vpin_ctlr);
|
||||
|
||||
if (((vpin_ctlr == INTX_CTLR_IOAPIC) && (virt_pin >= vioapic_pincount(vm))) || ((vpin_ctlr == INTX_CTLR_PIC) && (virt_pin >= vpic_pincount()))) {
|
||||
pr_err("virtual irq pin is invalid!\n");
|
||||
} else {
|
||||
entry = ptirq_lookup_entry_by_sid(PTDEV_INTR_INTX, &virt_sid, vm);
|
||||
if (entry != NULL) {
|
||||
if (is_entry_active(entry)) {
|
||||
@ -433,7 +426,6 @@ static void remove_intx_remapping(const struct acrn_vm *vm, uint32_t virt_pin, e
|
||||
|
||||
ptirq_release_entry(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void ptirq_handle_intx(struct acrn_vm *vm,
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include <hypercall.h>
|
||||
#include <errno.h>
|
||||
#include <logmsg.h>
|
||||
#include <ioapic.h>
|
||||
|
||||
#define DBG_LEVEL_HYCALL 6U
|
||||
|
||||
@ -905,8 +906,14 @@ int32_t hcall_set_ptdev_intr_info(struct acrn_vm *vm, uint16_t vmid, uint64_t pa
|
||||
vdev = pci_find_vdev(vpci, bdf);
|
||||
spinlock_release(&vpci->lock);
|
||||
if ((vdev != NULL) && (vdev->pdev->bdf.value == irq.phys_bdf)) {
|
||||
if ((((!irq.intx.pic_pin) && (irq.intx.virt_pin < vioapic_pincount(target_vm))) ||
|
||||
((irq.intx.pic_pin) && (irq.intx.virt_pin < vpic_pincount()))) &&
|
||||
ioapic_irq_is_gsi(irq.intx.phys_pin)) {
|
||||
ret = ptirq_add_intx_remapping(target_vm, irq.intx.virt_pin,
|
||||
irq.intx.phys_pin, irq.intx.pic_pin);
|
||||
} else {
|
||||
pr_err("%s: Invalid phys pin or virt pin\n", __func__);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
pr_err("%s: Invalid irq type: %u\n", __func__, irq.type);
|
||||
@ -948,8 +955,13 @@ hcall_reset_ptdev_intr_info(struct acrn_vm *vm, uint16_t vmid, uint64_t param)
|
||||
vdev = pci_find_vdev(vpci, bdf);
|
||||
spinlock_release(&vpci->lock);
|
||||
if ((vdev != NULL) && (vdev->pdev->bdf.value == irq.phys_bdf)) {
|
||||
if (((!irq.intx.pic_pin) && (irq.intx.virt_pin < vioapic_pincount(target_vm))) ||
|
||||
((irq.intx.pic_pin) && (irq.intx.virt_pin < vpic_pincount()))) {
|
||||
ptirq_remove_intx_remapping(target_vm, irq.intx.virt_pin, irq.intx.pic_pin);
|
||||
ret = 0;
|
||||
} else {
|
||||
pr_err("%s: Invalid virt pin\n", __func__);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
pr_err("%s: Invalid irq type: %u\n", __func__, irq.type);
|
||||
|
Loading…
Reference in New Issue
Block a user