From eff945911071c9e582d2b2ab0dc43787eb49943a Mon Sep 17 00:00:00 2001 From: Kaige Fu Date: Tue, 18 Dec 2018 11:01:36 +0000 Subject: [PATCH] HV: x86: fix "Procedure has more than one exit point" IEC 61508, ISO 26262 standards highly recommand single-exit rule. Tracked-On: #861 Signed-off-by: Kaige Fu Acked-by: Eddie Dong --- hypervisor/arch/x86/ioapic.c | 6 ++++-- hypervisor/arch/x86/notify.c | 35 +++++++++++++++-------------------- 2 files changed, 19 insertions(+), 22 deletions(-) diff --git a/hypervisor/arch/x86/ioapic.c b/hypervisor/arch/x86/ioapic.c index b0093fedf..d6b21211e 100644 --- a/hypervisor/arch/x86/ioapic.c +++ b/hypervisor/arch/x86/ioapic.c @@ -262,13 +262,15 @@ uint8_t irq_to_pin(uint32_t irq) uint32_t pin_to_irq(uint8_t pin) { uint32_t i; + uint32_t irq = IRQ_INVALID; for (i = 0U; i < nr_gsi; i++) { if (gsi_table[i].pin == pin) { - return i; + irq = i; + break; } } - return IRQ_INVALID; + return irq; } static void diff --git a/hypervisor/arch/x86/notify.c b/hypervisor/arch/x86/notify.c index 7e3ef679d..a951867e1 100644 --- a/hypervisor/arch/x86/notify.c +++ b/hypervisor/arch/x86/notify.c @@ -60,35 +60,30 @@ static int32_t request_notification_irq(irq_action_t func, void *data) int32_t retval; if (notification_irq != IRQ_INVALID) { - pr_info("%s, Notification vector already allocated on this CPU", - __func__); - return -EBUSY; + pr_info("%s, Notification vector already allocated on this CPU", __func__); + retval = -EBUSY; + } else { + /* all cpu register the same notification vector */ + retval = request_irq(NOTIFY_IRQ, func, data, IRQF_NONE); + if (retval < 0) { + pr_err("Failed to add notify isr"); + retval = -ENODEV; + } else { + notification_irq = (uint32_t)retval; + } } - /* all cpu register the same notification vector */ - retval = request_irq(NOTIFY_IRQ, func, data, IRQF_NONE); - if (retval < 0) { - pr_err("Failed to add notify isr"); - return -ENODEV; - } - - notification_irq = (uint32_t)retval; - - return 0; + return retval; } +/* + * @pre be called only by BSP initialization process + */ void setup_notification(void) { - uint16_t cpu = get_cpu_id(); - - if (cpu > 0U) { - return; - } - /* support IPI notification, VM0 will register all CPU */ if (request_notification_irq(kick_notification, NULL) < 0) { pr_err("Failed to setup notification"); - return; } dev_dbg(ACRN_DBG_PTIRQ, "NOTIFY: irq[%d] setup vector %x",