|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen staging] evtchn/fifo: Don't set PENDING bit if guest misbehaves
commit 8aa0e9d2d1a4815516607eabe9b2e850f284a2f8
Author: Raphael Ning <raphning@xxxxxxxxxx>
AuthorDate: Wed Mar 16 18:38:41 2022 +0000
Commit: Julien Grall <jgrall@xxxxxxxxxx>
CommitDate: Mon Mar 21 10:28:33 2022 +0000
evtchn/fifo: Don't set PENDING bit if guest misbehaves
Currently, evtchn_fifo_set_pending() will mark the event as PENDING even
if it fails to lock the FIFO event queue(s), or if the guest has not
initialized the FIFO control block for the target vCPU. A well-behaved
guest should never trigger either of these cases.
There is no good reason to set the PENDING bit (the guest should not
depend on this behaviour anyway) or check for pollers in such corner
cases, so skip that. In fact, both the comment above the for loop and
the commit message for
41a822c39263 xen/events: rework fifo queue locking
suggest that the bit should be set after the FIFO queue(s) are locked.
Take the opportunity to rename the was_pending variable (flipping its
sense) and switch to the standard bool type.
Suggested-by: David Vrabel <dvrabel@xxxxxxxxxxxx>
Signed-off-by: Raphael Ning <raphning@xxxxxxxxxx>
Acked-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
Reviewed-by: David Vrabel <dvrabel@xxxxxxxxxxxx>
Tested-by: Luca Fancellu <luca.fancellu@xxxxxxx>
---
xen/common/event_fifo.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/xen/common/event_fifo.c b/xen/common/event_fifo.c
index ed4d3beb10..0766358e9e 100644
--- a/xen/common/event_fifo.c
+++ b/xen/common/event_fifo.c
@@ -165,7 +165,7 @@ static void cf_check evtchn_fifo_set_pending(
unsigned int port;
event_word_t *word;
unsigned long flags;
- bool_t was_pending;
+ bool check_pollers = false;
struct evtchn_fifo_queue *q, *old_q;
unsigned int try;
bool linked = true;
@@ -226,8 +226,6 @@ static void cf_check evtchn_fifo_set_pending(
spin_unlock_irqrestore(&q->lock, flags);
}
- was_pending = guest_test_and_set_bit(d, EVTCHN_FIFO_PENDING, word);
-
/* If we didn't get the lock bail out. */
if ( try == 3 )
{
@@ -249,6 +247,8 @@ static void cf_check evtchn_fifo_set_pending(
goto unlock;
}
+ check_pollers = !guest_test_and_set_bit(d, EVTCHN_FIFO_PENDING, word);
+
/*
* Link the event if it unmasked and not already linked.
*/
@@ -314,7 +314,7 @@ static void cf_check evtchn_fifo_set_pending(
&v->evtchn_fifo->control_block->ready) )
vcpu_mark_events_pending(v);
- if ( !was_pending )
+ if ( check_pollers )
evtchn_check_pollers(d, port);
}
--
generated by git-patchbot for /home/xen/git/xen.git#staging
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |