diff --git a/hypervisor/arch/x86/assign.c b/hypervisor/arch/x86/assign.c index 3469c3c9c..89760ef1f 100644 --- a/hypervisor/arch/x86/assign.c +++ b/hypervisor/arch/x86/assign.c @@ -629,7 +629,6 @@ int ptdev_msix_remap(struct vm *vm, uint16_t virt_bdf, struct ptdev_msi_info *info) { struct ptdev_remapping_info *entry; - bool lowpri = !is_vm0(vm); /* * Device Model should pre-hold the mapping entries by calling @@ -668,7 +667,7 @@ int ptdev_msix_remap(struct vm *vm, uint16_t virt_bdf, if (!is_entry_active(entry)) { /* update msi source and active entry */ - ptdev_activate_entry(entry, IRQ_INVALID, lowpri); + ptdev_activate_entry(entry, IRQ_INVALID); } /* build physical config MSI, update to info->pmsi_xxx */ @@ -738,7 +737,6 @@ int ptdev_intx_pin_remap(struct vm *vm, struct ptdev_intx_info *info) union ioapic_rte rte; uint32_t phys_irq; uint8_t phys_pin; - bool lowpri = !is_vm0(vm); bool need_switch_vpin_src = false; struct ptdev_intx_info *intx; @@ -874,7 +872,7 @@ int ptdev_intx_pin_remap(struct vm *vm, struct ptdev_intx_info *info) activate_physical_ioapic(vm, entry); } else { /* active entry */ - ptdev_activate_entry(entry, phys_irq, lowpri); + ptdev_activate_entry(entry, phys_irq); activate_physical_ioapic(vm, entry); diff --git a/hypervisor/arch/x86/guest/vioapic.c b/hypervisor/arch/x86/guest/vioapic.c index 7e2d05acd..4692094c0 100644 --- a/hypervisor/arch/x86/guest/vioapic.c +++ b/hypervisor/arch/x86/guest/vioapic.c @@ -472,7 +472,7 @@ vioapic_process_eoi(struct vm *vm, uint32_t vector) uint32_t pin, pincount = vioapic_pincount(vm); union ioapic_rte rte; - if (vector < VECTOR_FOR_INTR_START || vector > NR_MAX_VECTOR) { + if (vector < VECTOR_DYNAMIC_START || vector > NR_MAX_VECTOR) { pr_err("vioapic_process_eoi: invalid vector %u", vector); } diff --git a/hypervisor/arch/x86/ioapic.c b/hypervisor/arch/x86/ioapic.c index 6a22ddc7c..954905b6c 100644 --- a/hypervisor/arch/x86/ioapic.c +++ b/hypervisor/arch/x86/ioapic.c @@ -372,7 +372,7 @@ void setup_ioapic_irq(void) * for legacy irq, reserved vector and never free */ if (gsi < NR_LEGACY_IRQ) { - vr = irq_desc_alloc_vector(gsi, false); + vr = irq_desc_alloc_vector(gsi); if (vr > NR_MAX_VECTOR) { pr_err("failed to alloc VR"); gsi++; diff --git a/hypervisor/arch/x86/irq.c b/hypervisor/arch/x86/irq.c index 14a629f70..d48e15e79 100644 --- a/hypervisor/arch/x86/irq.c +++ b/hypervisor/arch/x86/irq.c @@ -31,24 +31,14 @@ static void init_irq_desc(void) } /* - * alloc vector 0x20-0xDF for irq - * lowpri: 0x20-0x7F - * highpri: 0x80-0xDF + * find available vector VECTOR_DYNAMIC_START ~ VECTOR_DYNAMIC_END */ -static uint32_t find_available_vector(bool lowpri) +static uint32_t find_available_vector() { - uint32_t i, start, end; - - if (lowpri) { - start = VECTOR_FOR_NOR_LOWPRI_START; - end = VECTOR_FOR_NOR_LOWPRI_END; - } else { - start = VECTOR_FOR_NOR_HIGHPRI_START; - end = VECTOR_FOR_NOR_HIGHPRI_END; - } + uint32_t i; /* TODO: vector lock required */ - for (i = start; i < end; i++) { + for (i = VECTOR_DYNAMIC_START; i <= VECTOR_DYNAMIC_END; i++) { if (vector_to_irq[i] == IRQ_INVALID) { return i; } @@ -269,11 +259,11 @@ common_register_handler(uint32_t irq_arg, OUT: if (added) { /* it is safe to call irq_desc_alloc_vector multiple times*/ - if (info->vector >= VECTOR_FOR_PRI_START && - info->vector <= VECTOR_FOR_PRI_END) { + if (info->vector >= VECTOR_FIXED_START && + info->vector <= VECTOR_FIXED_END) { irq_desc_set_vector(irq, info->vector); } else if (info->vector > NR_MAX_VECTOR) { - irq_desc_alloc_vector(irq, info->lowpri); + irq_desc_alloc_vector(irq); } else { pr_err("the input vector is not correct"); free(node); @@ -296,7 +286,7 @@ OUT: } /* it is safe to call irq_desc_alloc_vector multiple times*/ -uint32_t irq_desc_alloc_vector(uint32_t irq, bool lowpri) +uint32_t irq_desc_alloc_vector(uint32_t irq) { uint32_t vr = VECTOR_INVALID; struct irq_desc *desc; @@ -316,7 +306,7 @@ uint32_t irq_desc_alloc_vector(uint32_t irq, bool lowpri) } /* FLAT mode, a irq connected to every cpu's same vector */ - vr = find_available_vector(lowpri); + vr = find_available_vector(); if (vr > NR_MAX_VECTOR) { pr_err("no vector found for irq[%d]", irq); goto OUT; @@ -634,20 +624,18 @@ UNLOCK_EXIT: } /* - * Allocate IRQ with Vector from 0x20 ~ 0xDF + * Allocate IRQ with Vector from VECTOR_DYNAMIC_START ~ VECTOR_DYNAMIC_END */ struct dev_handler_node* normal_register_handler(uint32_t irq, dev_handler_t func, void *dev_data, bool share, - bool lowpri, const char *name) { struct irq_request_info info; info.vector = VECTOR_INVALID; - info.lowpri = lowpri; info.func = func; info.dev_data = dev_data; info.share = share; @@ -657,7 +645,7 @@ normal_register_handler(uint32_t irq, } /* - * Allocate IRQ with vector from 0xE0 ~ 0xFF + * Allocate IRQ with vector from VECTOR_FIXED_START ~ VECTOR_FIXED_END * Allocate a IRQ and install isr on that specific cpu * User can install same irq/isr on different CPU by call this function multiple * times @@ -671,12 +659,11 @@ pri_register_handler(uint32_t irq, { struct irq_request_info info; - if (vector < VECTOR_FOR_PRI_START || vector > VECTOR_FOR_PRI_END) { + if (vector < VECTOR_FIXED_START || vector > VECTOR_FIXED_END) { return NULL; } info.vector = vector; - info.lowpri = false; info.func = func; info.dev_data = dev_data; info.share = true; diff --git a/hypervisor/arch/x86/vtd.c b/hypervisor/arch/x86/vtd.c index 62387fa15..f3fb8df4e 100644 --- a/hypervisor/arch/x86/vtd.c +++ b/hypervisor/arch/x86/vtd.c @@ -827,7 +827,7 @@ static int dmar_setup_interrupt(struct dmar_drhd_rt *dmar_uint) dmar_uint->dmar_irq_node = normal_register_handler(IRQ_INVALID, dmar_fault_handler, - dmar_uint, true, false, + dmar_uint, true, "dmar_fault_event"); if (dmar_uint->dmar_irq_node == NULL) { diff --git a/hypervisor/common/ptdev.c b/hypervisor/common/ptdev.c index 274c2d6b8..a10381796 100644 --- a/hypervisor/common/ptdev.c +++ b/hypervisor/common/ptdev.c @@ -129,14 +129,13 @@ static int ptdev_interrupt_handler(__unused int irq, void *data) /* active intr with irq registering */ void -ptdev_activate_entry(struct ptdev_remapping_info *entry, uint32_t phys_irq, - bool lowpri) +ptdev_activate_entry(struct ptdev_remapping_info *entry, uint32_t phys_irq) { struct dev_handler_node *node; /* register and allocate host vector/irq */ node = normal_register_handler(phys_irq, ptdev_interrupt_handler, - (void *)entry, true, lowpri, "dev assign"); + (void *)entry, true, "dev assign"); ASSERT(node != NULL, "dev register failed"); entry->node = node; diff --git a/hypervisor/include/arch/x86/irq.h b/hypervisor/include/arch/x86/irq.h index fd8bba655..ac5ee6184 100644 --- a/hypervisor/include/arch/x86/irq.h +++ b/hypervisor/include/arch/x86/irq.h @@ -9,18 +9,14 @@ #include -/* vectors for normal, usually for devices */ -#define VECTOR_FOR_NOR_LOWPRI_START 0x20U -#define VECTOR_FOR_NOR_LOWPRI_END 0x7FU -#define VECTOR_FOR_NOR_HIGHPRI_START 0x80U -#define VECTOR_FOR_NOR_HIGHPRI_END 0xDFU -#define VECTOR_FOR_NOR_END VECTOR_FOR_NOR_HIGHPRI_END +/* vectors range for dynamic allocation, usually for devices */ +#define VECTOR_DYNAMIC_START 0x20U +#define VECTOR_DYNAMIC_END 0xDFU -#define VECTOR_FOR_INTR_START VECTOR_FOR_NOR_LOWPRI_START +/* vectors range for fixed vectors, usually for HV service */ +#define VECTOR_FIXED_START 0xE0U +#define VECTOR_FIXED_END 0xFFU -/* vectors for priority, usually for HV service */ -#define VECTOR_FOR_PRI_START 0xE0U -#define VECTOR_FOR_PRI_END 0xFFU #define VECTOR_TIMER 0xEFU #define VECTOR_NOTIFY_VCPU 0xF0U #define VECTOR_VIRT_IRQ_VHM 0xF7U diff --git a/hypervisor/include/common/irq.h b/hypervisor/include/common/irq.h index 5537bfb01..5e9003f83 100644 --- a/hypervisor/include/common/irq.h +++ b/hypervisor/include/common/irq.h @@ -33,7 +33,6 @@ struct irq_request_info { dev_handler_t func; void *dev_data; bool share; - bool lowpri; char *name; }; @@ -61,7 +60,7 @@ struct dev_handler_node { uint32_t irq_mark_used(uint32_t irq); -uint32_t irq_desc_alloc_vector(uint32_t irq, bool lowpri); +uint32_t irq_desc_alloc_vector(uint32_t irq); void irq_desc_try_free_vector(uint32_t irq); uint32_t irq_to_vector(uint32_t irq); @@ -80,7 +79,6 @@ normal_register_handler(uint32_t irq, dev_handler_t func, void *dev_data, bool share, - bool lowpri, const char *name); void unregister_handler_common(struct dev_handler_node *node); diff --git a/hypervisor/include/common/ptdev.h b/hypervisor/include/common/ptdev.h index ac73c2d5e..39864c777 100644 --- a/hypervisor/include/common/ptdev.h +++ b/hypervisor/include/common/ptdev.h @@ -75,7 +75,7 @@ struct ptdev_remapping_info *alloc_entry(struct vm *vm, void release_entry(struct ptdev_remapping_info *entry); void ptdev_activate_entry( struct ptdev_remapping_info *entry, - uint32_t phys_irq, bool lowpri); + uint32_t phys_irq); void ptdev_deactivate_entry(struct ptdev_remapping_info *entry); #ifdef HV_DEBUG