[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] x86/viridian: fix calling of viridian_time_domain_{freeze,thaw}()


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • Date: Wed, 26 Nov 2025 12:29:42 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Z+ZmMJMLo4gnVQALzODxbOeXoU5clQ278LQY4anXF9s=; b=IJu7Q8n7CBW0h+XaUvITdac1DtkHloOqFXAWoWopB2NJx+vEHCGgTg8vMD8Qcv6g1kY7lU6qJoj538NWgyVQtcHAcW1NaW2G7XX2vRcdkTkq6WJTpUU8ec3ViW/lVcWWVOfgBZGN7+Gtfh1l6KSzw5qQg8SJp7HkXhtoTVicU2KDY9qDZt9M0EhPFGag/veVuGg1PqrmSDcqthvb2TGDXXDPvuFK0iFvkqOOX277Qttqi660sihkQippkVsNAozbvRP0Jtu7IF2i0A6/3yPG4OefwSB+0vbRRnUWm7nZkOGVIKluAEqLFJ5Op6Z94PSN+jrgfoJDj5Z4l7+GC8aKZA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Y9ouSEMjRhLMSiQkECHXnYtcf/3ZKgLshERMYHjJ5IOGpcWxOPusU1pZPUL6SaGrZmv9givF+r8nHXp7f6F+jdIpP2dMOkDxeaNry55ArZ3yXTLWPtWOMY5N1ZwQYpHZ3iQuAEzjZ4X/gTtY5CY30kGzIyj8qHLrP5LgCzdeGrCT0dyEJPnkKGygvDCmxP26M7pp5/pTx0aPgRC9eQ9LhA0aQRNM5bRKHYsIySUEaA/KZEAw+rBLJ4SGGkKIT1h/+1SDJAqltbz+qHI1DkBT8jAw6Z2tU6s52OMl35SGYIXFNkiEGFNoZB9Il5cgb6GqYO6i0eGtbARX1Yy5ft0H8Q==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Roger Pau Monne <roger.pau@xxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>
  • Delivery-date: Wed, 26 Nov 2025 11:30:00 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

The current hook placement in domain_{,un}pause() calls arch_domain_pause()
unconditionally, regardless of whether the domain is already paused or not
unpaused (so no state change).  However the underlying Viridian unpause
function (time_ref_count_thaw()) expects the call to only be done once
there's a transition from paused to active.

Adjust the calling of arch_domain_{,un}pause() so it's only done for state
changes, to accommodate for the behavior expected by the Viridian hooks.
Note there are no other implementations of arch_domain_{,un}pause() apart
from the Viridian use cases, and hence the change is non-functional for all
other architectures (or for x86 if Viridian is disabled).

Fixes: f6a07643e1cc ('x86/viridian: freeze time reference counter when domain 
is paused')
Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
 xen/common/domain.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/xen/common/domain.c b/xen/common/domain.c
index 3b6e9471c413..e0ca71a53bc1 100644
--- a/xen/common/domain.c
+++ b/xen/common/domain.c
@@ -1547,8 +1547,7 @@ int vcpu_unpause_by_systemcontroller(struct vcpu *v)
 static void _domain_pause(struct domain *d, bool sync)
 {
     struct vcpu *v;
-
-    atomic_inc(&d->pause_count);
+    bool was_paused = atomic_inc_return(&d->pause_count) - 1;
 
     if ( sync )
         for_each_vcpu ( d, v )
@@ -1557,7 +1556,8 @@ static void _domain_pause(struct domain *d, bool sync)
         for_each_vcpu ( d, v )
             vcpu_sleep_nosync(v);
 
-    arch_domain_pause(d);
+    if ( !was_paused )
+        arch_domain_pause(d);
 }
 
 void domain_pause(struct domain *d)
@@ -1575,11 +1575,12 @@ 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.51.0




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.