hf_mailbox_receive should not block if there is a pending interrupt.
This matches the behaviour of WFI, which only traps (and so causes Hafnium
to block the vCPU) if there is not currently a pending interrupt, ignoring
PSTATE.
Bug: 127686530
Change-Id: I06ef4513d3b9f5adf7988f6f77c178cba40b1762
diff --git a/src/api.c b/src/api.c
index ff44291..31943ca 100644
--- a/src/api.c
+++ b/src/api.c
@@ -916,8 +916,12 @@
goto out;
}
- /* No pending message so fail if not allowed to block. */
- if (!block) {
+ /*
+ * No pending message so fail if not allowed to block. Don't block if
+ * there are enabled and pending interrupts, to match behaviour of
+ * wait_for_interrupt.
+ */
+ if (!block || current->interrupts.enabled_and_pending_count > 0) {
goto out;
}