fix: process interrupt type before checking pending
Enabling a virtual interrupt which is already pending could be
incorrectly processed as IRQ while requested type is FIQ. Moving the
interrupt type check before pending interrupt processing.
Signed-off-by: Nicolas Guyomard <nicolas.guyomard@trustonic.com>
Signed-off-by: Maksims Svecovs <maksims.svecovs@arm.com>
Change-Id: I536cf1ea0e1ef0c32fa0b852017b67195ae8a425
diff --git a/src/api.c b/src/api.c
index b232a1a..b713b7c 100644
--- a/src/api.c
+++ b/src/api.c
@@ -1747,6 +1747,14 @@
current_locked = vcpu_lock(current);
if (enable) {
+ if (type == INTERRUPT_TYPE_IRQ) {
+ current->interrupts.interrupt_type[intid_index] &=
+ ~intid_mask;
+ } else if (type == INTERRUPT_TYPE_FIQ) {
+ current->interrupts.interrupt_type[intid_index] |=
+ intid_mask;
+ }
+
/*
* If it is pending and was not enabled before, increment the
* count.
@@ -1764,14 +1772,6 @@
}
current->interrupts.interrupt_enabled[intid_index] |=
intid_mask;
-
- if (type == INTERRUPT_TYPE_IRQ) {
- current->interrupts.interrupt_type[intid_index] &=
- ~intid_mask;
- } else if (type == INTERRUPT_TYPE_FIQ) {
- current->interrupts.interrupt_type[intid_index] |=
- intid_mask;
- }
} else {
/*
* If it is pending and was enabled before, decrement the count.