From nobody Tue Feb 10 06:25:08 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1631622988; cv=none; d=zohomail.com; s=zohoarc; b=NCqYR3dihc1Pepnj0J/JKaLuFHshzwZU8B3hHJrT5jye8oP673NupUyBM4CRVeY8DYv3SC1WOe95MM2ncSzPg2xWHUxEPsdu2UcB/ejsdkOKHWr0jkfmTYze08azX+iKRJcG8JvW7Up0ti9EVWpdmufHs3QVO4Sjzwpg0Faumg8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631622988; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=gmpX0RV1KtNAd1QGZZ8I7TEoSv8qu+7eNCb6tbvk9tE=; b=TSV/RVShWzdPfHHUhAF+XhvG+ae9RnlMwx202a+NZysrPRdD2lBpKgEjrYT209ZlM6b9hKypEe8m/BhuiDj0FXAsjON05cFDQWOBMqyOo6F7le70a3lJ2DVAVj/o9RcJU1RTUFScdvFvQITwADiNKgR1cWG31271098qJlG8SWs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1631622988279888.2368113952134; Tue, 14 Sep 2021 05:36:28 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.186544.335307 (Exim 4.92) (envelope-from ) id 1mQ7fc-0007yo-4x; Tue, 14 Sep 2021 12:36:16 +0000 Received: by outflank-mailman (output) from mailman id 186544.335307; Tue, 14 Sep 2021 12:36:16 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mQ7fc-0007yc-1U; Tue, 14 Sep 2021 12:36:16 +0000 Received: by outflank-mailman (input) for mailman id 186544; Tue, 14 Sep 2021 12:36:14 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mQ7fa-00070M-Gg for xen-devel@lists.xenproject.org; Tue, 14 Sep 2021 12:36:14 +0000 Received: from smtp-out1.suse.de (unknown [195.135.220.28]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 0816215a-03ed-47af-b250-f3bce5de19ac; Tue, 14 Sep 2021 12:36:04 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 7F8F9220E7; Tue, 14 Sep 2021 12:36:03 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 3637413342; Tue, 14 Sep 2021 12:36:03 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id EHaWCzOXQGE7MAAAMHmgww (envelope-from ); Tue, 14 Sep 2021 12:36:03 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 0816215a-03ed-47af-b250-f3bce5de19ac DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1631622963; 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: in-reply-to:in-reply-to:references:references; bh=gmpX0RV1KtNAd1QGZZ8I7TEoSv8qu+7eNCb6tbvk9tE=; b=h3Z9wwfBYUyrkUqm9vPejr3MHUGnNFISxmcAAQEWYJ+PVYI2Kgz35r4YNLWCzXkrGniN+M xSYPhZUr/BRnzTiRUxqfDi1GGHoTGCwpwyzQTb1P66bZQGIcwDB4/YBC1SDQN7S9G0MmVH 6uoW9xA8LX7E/2V1Lfu1AiSvVSalaLs= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Andrew Cooper , George Dunlap , Ian Jackson , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu Subject: [PATCH RFC 2/4] xen: add bitmap to indicate per-domain state changes Date: Tue, 14 Sep 2021 14:35:58 +0200 Message-Id: <20210914123600.1626-3-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210914123600.1626-1-jgross@suse.com> References: <20210914123600.1626-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1631622990218100001 Content-Type: text/plain; charset="utf-8" Add a bitmap with one bit per possible domid indicating the respective domain has changed its state (created, deleted, dying, crashed, shutdown). Registering the VIRQ_DOM_EXC event will result in setting the bits for all existing domains and resetting all other bits. Resetting a bit will be done in a future patch. This information is needed for Xenstore to keep track of all domains. Signed-off-by: Juergen Gross --- xen/common/domain.c | 22 ++++++++++++++++++++++ xen/common/event_channel.c | 2 ++ xen/include/xen/sched.h | 2 ++ 3 files changed, 26 insertions(+) diff --git a/xen/common/domain.c b/xen/common/domain.c index 755349b93f..14a427e2ef 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -87,6 +87,22 @@ bool __read_mostly vmtrace_available; /* Unique domain identifier, protected by domctl lock. */ static uint64_t unique_id; =20 +static DECLARE_BITMAP(dom_state_changed, DOMID_MASK + 1); + +void domain_reset_states(void) +{ + struct domain *d; + + bitmap_zero(dom_state_changed, DOMID_MASK + 1); + + rcu_read_lock(&domlist_read_lock); + + for_each_domain ( d ) + set_bit(d->domain_id, dom_state_changed); + + rcu_read_unlock(&domlist_read_lock); +} + static void __domain_finalise_shutdown(struct domain *d) { struct vcpu *v; @@ -101,6 +117,7 @@ static void __domain_finalise_shutdown(struct domain *d) return; =20 d->is_shut_down =3D 1; + set_bit(d->domain_id, dom_state_changed); if ( (d->shutdown_code =3D=3D SHUTDOWN_suspend) && d->suspend_evtchn ) evtchn_send(d, d->suspend_evtchn); else @@ -720,6 +737,8 @@ struct domain *domain_create(domid_t domid, rcu_assign_pointer(domain_hash[DOMAIN_HASH(domid)], d); spin_unlock(&domlist_update_lock); =20 + set_bit(d->domain_id, dom_state_changed); + memcpy(d->handle, config->handle, sizeof(d->handle)); } =20 @@ -954,6 +973,7 @@ int domain_kill(struct domain *d) /* Mem event cleanup has to go here because the rings=20 * have to be put before we call put_domain. */ vm_event_cleanup(d); + set_bit(d->domain_id, dom_state_changed); put_domain(d); send_global_virq(VIRQ_DOM_EXC); /* fallthrough */ @@ -1141,6 +1161,8 @@ static void complete_domain_destroy(struct rcu_head *= head) =20 xfree(d->vcpu); =20 + set_bit(d->domain_id, dom_state_changed); + _domain_destroy(d); =20 send_global_virq(VIRQ_DOM_EXC); diff --git a/xen/common/event_channel.c b/xen/common/event_channel.c index da88ad141a..e2a416052b 100644 --- a/xen/common/event_channel.c +++ b/xen/common/event_channel.c @@ -1218,6 +1218,8 @@ long do_event_channel_op(int cmd, XEN_GUEST_HANDLE_PA= RAM(void) arg) rc =3D evtchn_bind_virq(&bind_virq, 0); if ( !rc && __copy_to_guest(arg, &bind_virq, 1) ) rc =3D -EFAULT; /* Cleaning up here would be a mess! */ + if ( !rc && bind_virq.virq =3D=3D VIRQ_DOM_EXC ) + domain_reset_states(); break; } =20 diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index b827c5af8d..2ae26bc50e 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -730,6 +730,8 @@ void domain_resume(struct domain *d); =20 int domain_soft_reset(struct domain *d, bool resuming); =20 +void domain_reset_states(void); + int vcpu_start_shutdown_deferral(struct vcpu *v); void vcpu_end_shutdown_deferral(struct vcpu *v); =20 --=20 2.26.2