Skip to content

Commit eff9459

Browse files
KaigeFuwenlingz
authored andcommitted
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 <kaige.fu@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent e283e77 commit eff9459

File tree

2 files changed

+19
-22
lines changed

2 files changed

+19
-22
lines changed

hypervisor/arch/x86/ioapic.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,13 +262,15 @@ uint8_t irq_to_pin(uint32_t irq)
262262
uint32_t pin_to_irq(uint8_t pin)
263263
{
264264
uint32_t i;
265+
uint32_t irq = IRQ_INVALID;
265266

266267
for (i = 0U; i < nr_gsi; i++) {
267268
if (gsi_table[i].pin == pin) {
268-
return i;
269+
irq = i;
270+
break;
269271
}
270272
}
271-
return IRQ_INVALID;
273+
return irq;
272274
}
273275

274276
static void

hypervisor/arch/x86/notify.c

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -60,35 +60,30 @@ static int32_t request_notification_irq(irq_action_t func, void *data)
6060
int32_t retval;
6161

6262
if (notification_irq != IRQ_INVALID) {
63-
pr_info("%s, Notification vector already allocated on this CPU",
64-
__func__);
65-
return -EBUSY;
66-
}
67-
68-
/* all cpu register the same notification vector */
69-
retval = request_irq(NOTIFY_IRQ, func, data, IRQF_NONE);
70-
if (retval < 0) {
71-
pr_err("Failed to add notify isr");
72-
return -ENODEV;
63+
pr_info("%s, Notification vector already allocated on this CPU", __func__);
64+
retval = -EBUSY;
65+
} else {
66+
/* all cpu register the same notification vector */
67+
retval = request_irq(NOTIFY_IRQ, func, data, IRQF_NONE);
68+
if (retval < 0) {
69+
pr_err("Failed to add notify isr");
70+
retval = -ENODEV;
71+
} else {
72+
notification_irq = (uint32_t)retval;
73+
}
7374
}
7475

75-
notification_irq = (uint32_t)retval;
76-
77-
return 0;
76+
return retval;
7877
}
7978

79+
/*
80+
* @pre be called only by BSP initialization process
81+
*/
8082
void setup_notification(void)
8183
{
82-
uint16_t cpu = get_cpu_id();
83-
84-
if (cpu > 0U) {
85-
return;
86-
}
87-
8884
/* support IPI notification, VM0 will register all CPU */
8985
if (request_notification_irq(kick_notification, NULL) < 0) {
9086
pr_err("Failed to setup notification");
91-
return;
9287
}
9388

9489
dev_dbg(ACRN_DBG_PTIRQ, "NOTIFY: irq[%d] setup vector %x",

0 commit comments

Comments
 (0)