Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EA29E606A31A for ; Wed, 2 Dec 2026 10:22:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=suse.com header.i=@suse.com header.a=rsa-sha256 header.s=susede1 header.b=aHzeLiHs; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.a=rsa-sha256 header.s=susede1 header.b=aHzeLiHs Received: from list by lists.xenproject.org with outflank-mailman.1509823.1702433 (Exim 4.92) (envelope-from ) id 1xYhTp-0002Me-Gj; Wed, 02 Dec 2026 10:22:29 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 1509823.1702433; Wed, 02 Dec 2026 10:22:29 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xYhTp-0002MW-Dl; Wed, 02 Dec 2026 10:22:29 +0000 Received: by outflank-mailman (input) for mailman id 1509823; Wed, 02 Dec 2026 10:22:28 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xYhTo-0002MM-QR for xen-devel@lists.xenproject.org; Wed, 02 Dec 2026 10:22:28 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xYhTn-008BeZ-Q1 for xen-devel@lists.xenproject.org; Wed, 02 Dec 2026 11:22:27 +0100 Received: from [10.42.69.6] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6b0ff151-8faa-0a2a0a5109dd-0a2a450688da-18 for ; Wed, 02 Dec 2026 11:22:27 +0100 Received: from [195.135.223.130] (helo=smtp-out1.suse.de) by tlsNG-16d1c6.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6b0ff163-195a-0a2a45060019-c387df82afb8-3 for ; Wed, 02 Dec 2026 11:22:27 +0100 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 042F4221B9; Wed, 2 Dec 2026 10:22:27 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 897A613505; Wed, 2 Dec 2026 10:22:26 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id YTboF2LxD2tJYwAAD6G6ig (envelope-from ); Wed, 02 Dec 2026 10:22:26 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Post: List-Help: List-Subscribe: , Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=susede1 header.d=suse.com header.i="@suse.com" header.h="From:Date:Message-ID:To:Cc:MIME-Version:Content-Transfer-Encoding"; dkim=pass header.s=susede1 header.d=suse.com header.i="@suse.com" header.h="From:Date:Message-ID:To:Cc:MIME-Version:Content-Transfer-Encoding" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1796206947; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=J87vC1/Pk9gj7EDuK7qu9BTWFG7epXBo8LahClR54Qc=; b=aHzeLiHsX3FtD8EkM2wvEwWHxkPhRFeumuIje4FV3DSeuiSCcdllB3Jmcy4XokHnpUuqdr mCGkJh+5IsYnRnvHz7fOIyS3nMButtP9ZdhX4N3HN6FhLoe7LC9AiJeH8IBn7hSxzKJ8LN 1gKu2tUMq6GUDvD8l2Aw2tknJwb3u5o= Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.com header.s=susede1 header.b=aHzeLiHs DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1796206947; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=J87vC1/Pk9gj7EDuK7qu9BTWFG7epXBo8LahClR54Qc=; b=aHzeLiHsX3FtD8EkM2wvEwWHxkPhRFeumuIje4FV3DSeuiSCcdllB3Jmcy4XokHnpUuqdr mCGkJh+5IsYnRnvHz7fOIyS3nMButtP9ZdhX4N3HN6FhLoe7LC9AiJeH8IBn7hSxzKJ8LN 1gKu2tUMq6GUDvD8l2Aw2tknJwb3u5o= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini Subject: [PATCH v2] xen/domain: fix domain_pause() and domain_unpause() Date: Wed, 2 Dec 2026 11:22:20 +0100 Message-ID: <20261202102220.164146-1-jgross@suse.com> X-Mailer: git-send-email 2.56.0 X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spamd-Result: default: False [-12.01 / 50.00]; SUSE_INTERNAL_BYPASS(-9.00)[]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.com:s=susede1]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; DKIM_TRACE(0.00)[suse.com:+]; TO_DN_SOME(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCVD_TLS_ALL(0.00)[]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:104:10:150:64:97:from,2a07:de40:b281:106:10:150:64:167:received]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; RCPT_COUNT_SEVEN(0.00)[9]; RCVD_VIA_SMTP_AUTH(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email,suse.com:dkim,imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Action: no action X-Spam-Score: -12.01 X-Spam-Level: X-Rspamd-Queue-Id: 042F4221B9 X-purgate-ID: tlsNG-16d1c6/1796206947-1F6C877B-9277DF26/35/110847 X-purgate-type: clean X-purgate-size: 1767 X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_PASS, SPF_PASS,UNPARSEABLE_RELAY,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 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 --- V2: - always call arch_domain_pause() (Jan Beulich) --- xen/common/domain.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/xen/common/domain.c b/xen/common/domain.c index 0bef436ef3..b2af89fe51 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -1625,15 +1625,16 @@ static void _domain_pause(struct domain *d, bool sync) { struct vcpu *v; - atomic_inc(&d->pause_count); - - for_each_vcpu ( d, v ) - vcpu_sleep_nosync(v); + if ( atomic_inc_and_test(&d->pause_count) ) + 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); + /* 2 nosync calls might race with each other, so do below call always. */ arch_domain_pause(d); } @@ -1652,11 +1653,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