|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH] xen/arm: Ensure the vCPU context is seen before clearing the _VPF_down
From: Julien Grall <jgrall@xxxxxxxxxx>
A vCPU can get scheduled as soon as _VPF_down is cleared. As there is
currently not ordering guarantee in arch_set_info_guest(), it may be
possible that flag can be observed cleared before the new values of vCPU
registers are observed.
Add an smp_mb() before the flag is cleared to prevent re-ordering.
Signed-off-by: Julien Grall <jgrall@xxxxxxxxxx>
---
Barriers should work in pair. However, I am not entirely sure whether to
put the other half. Maybe at the beginning of context_switch_to()?
The issues described here is also quite theoritical because there are
hundreds of instructions executed between the time a vCPU is seen
runnable and scheduled. But better be safe than sorry :).
---
xen/arch/arm/domain.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
index bdd3d3e5b5d5..2b705e66be81 100644
--- a/xen/arch/arm/domain.c
+++ b/xen/arch/arm/domain.c
@@ -914,7 +914,14 @@ int arch_set_info_guest(
v->is_initialised = 1;
if ( ctxt->flags & VGCF_online )
+ {
+ /*
+ * The vCPU can be scheduled as soon as _VPF_down is cleared.
+ * So clear the bit *after* the context was loaded.
+ */
+ smp_mb();
clear_bit(_VPF_down, &v->pause_flags);
+ }
else
set_bit(_VPF_down, &v->pause_flags);
--
2.17.1
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |