|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH 2/2] xen/domain: fix domain_pause() and domain_unpause()
Calls of domain_pause() can be nested. So there should be no action
other than handling the paused counter if a nested call is detected.
Especially calling arch_domain_unpause() unconditionally in
domain_unpause() is wrong, but the actions in domain_pause() can be
skipped, too, if the domain was paused already.
Fixes: f6a07643e1cc ("x86/viridian: freeze time reference counter when domain
is paused")
Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
---
xen/common/domain.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/xen/common/domain.c b/xen/common/domain.c
index 0bef436ef3..2693805f98 100644
--- a/xen/common/domain.c
+++ b/xen/common/domain.c
@@ -1624,17 +1624,19 @@ int vcpu_unpause_by_systemcontroller(struct vcpu *v)
static void _domain_pause(struct domain *d, bool sync)
{
struct vcpu *v;
+ int pausing = atomic_inc_and_test(&d->pause_count);
- atomic_inc(&d->pause_count);
-
- for_each_vcpu ( d, v )
- vcpu_sleep_nosync(v);
+ if ( pausing )
+ for_each_vcpu ( d, v )
+ vcpu_sleep_nosync(v);
+ /* Wait might be needed even if already paused, could have been nosync. */
if ( sync )
for_each_vcpu ( d, v )
vcpu_wait_sleep(v);
- arch_domain_pause(d);
+ if ( pausing )
+ arch_domain_pause(d);
}
void domain_pause(struct domain *d)
@@ -1652,11 +1654,13 @@ void domain_unpause(struct domain *d)
{
struct vcpu *v;
- arch_domain_unpause(d);
-
if ( atomic_dec_and_test(&d->pause_count) )
+ {
+ arch_domain_unpause(d);
+
for_each_vcpu( d, v )
vcpu_wake(v);
+ }
}
static int _domain_pause_by_systemcontroller(struct domain *d, bool sync)
--
2.56.0
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |