From nobody Wed Dec 4 19:34:06 2024 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=1729689078; cv=none; d=zohomail.com; s=zohoarc; b=Ufv0Z5H/6V/vGKnNJIKfmUynBaixNiz7TZYOjL5onB+de2KQriMB+hnU3nv02OGnplslVNNzQ8+93IpQu2a5nLNhxWJsQyKn97uYHzEizmDCLuf6NnvBETOsFPqmokpRlVo37h1aSJYCxWmOUF2c8V0GITOaPio7SoqSYjnn+GA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729689078; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=i3xMtPXgKn6GG8oVuMqyejq+21hcqPaJBGgXHENl+cw=; b=bSnqBkgU+CW7Za+dxzpn3Wik+0Yiz0LQQntjCtem6vw/feMi29ZM90zp0rYmLKC4G7ZCMzVbVTCP5i1Kyiav70AqdTEQrgi2EKR7R14tjZrcTer3K5Zg5Xdt/AMI4VrhHwP4oRksJJT8uPIyxWXfQTRzm77TyTTcFht4cJJ/alM= 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 1729689078355898.6783153489391; Wed, 23 Oct 2024 06:11:18 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.824607.1238768 (Exim 4.92) (envelope-from ) id 1t3b84-0006yZ-2e; Wed, 23 Oct 2024 13:10:24 +0000 Received: by outflank-mailman (output) from mailman id 824607.1238768; Wed, 23 Oct 2024 13:10:24 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t3b83-0006yS-W0; Wed, 23 Oct 2024 13:10:23 +0000 Received: by outflank-mailman (input) for mailman id 824607; Wed, 23 Oct 2024 13:10:22 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t3b82-0006Ra-2K for xen-devel@lists.xenproject.org; Wed, 23 Oct 2024 13:10:22 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [2a07:de40:b251:101:10:150:64:2]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 2779cc7c-9140-11ef-99a3-01e77a169b0f; Wed, 23 Oct 2024 15:10:20 +0200 (CEST) Received: from imap1.dmz-prg2.suse.org (unknown [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-out2.suse.de (Postfix) with ESMTPS id A1E6D1FDA3; Wed, 23 Oct 2024 13:10:19 +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 6BC0613A63; Wed, 23 Oct 2024 13:10:19 +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 HKDkGLv1GGfGdwAAD6G6ig (envelope-from ); Wed, 23 Oct 2024 13:10:19 +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: 2779cc7c-9140-11ef-99a3-01e77a169b0f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1729689019; 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=i3xMtPXgKn6GG8oVuMqyejq+21hcqPaJBGgXHENl+cw=; b=PaOzNzSZcG26XL9qxihvCawE2U283fnLlqlhDp0dF1PsI/69+igiohrJUAXLahinNr43hC YbnnVwBxmuClh1LiFklCmovZLDe6IfTgv5r29F1ShW+ZF6cL800yYg+wA/fADwV+xwokbC D2+eJB+unAz2x4HiLr1jk8Z9pBuY5QE= Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1729689019; 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=i3xMtPXgKn6GG8oVuMqyejq+21hcqPaJBGgXHENl+cw=; b=PaOzNzSZcG26XL9qxihvCawE2U283fnLlqlhDp0dF1PsI/69+igiohrJUAXLahinNr43hC YbnnVwBxmuClh1LiFklCmovZLDe6IfTgv5r29F1ShW+ZF6cL800yYg+wA/fADwV+xwokbC D2+eJB+unAz2x4HiLr1jk8Z9pBuY5QE= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Andrew Cooper , Jan Beulich , Julien Grall , Stefano Stabellini Subject: [PATCH 2/6] xen: add bitmap to indicate per-domain state changes Date: Wed, 23 Oct 2024 15:10:01 +0200 Message-ID: <20241023131005.32144-3-jgross@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241023131005.32144-1-jgross@suse.com> References: <20241023131005.32144-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.80 X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[99.99%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_FIVE(0.00)[6]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo]; RCVD_TLS_ALL(0.00)[] X-Spam-Flag: NO X-Spam-Level: X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1729689079883116600 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 | 21 +++++++++++++++++++++ xen/common/event_channel.c | 2 ++ xen/include/xen/sched.h | 2 ++ 3 files changed, 25 insertions(+) diff --git a/xen/common/domain.c b/xen/common/domain.c index 3948640fb0..61b7899cb8 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -138,6 +138,22 @@ bool __read_mostly vmtrace_available; =20 bool __read_mostly vpmu_is_available; =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; @@ -152,6 +168,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 @@ -832,6 +849,7 @@ struct domain *domain_create(domid_t domid, */ domlist_insert(d); =20 + set_bit(d->domain_id, dom_state_changed); memcpy(d->handle, config->handle, sizeof(d->handle)); =20 return d; @@ -1097,6 +1115,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 */ @@ -1286,6 +1305,8 @@ static void cf_check complete_domain_destroy(struct r= cu_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 8db2ca4ba2..9b87d29968 100644 --- a/xen/common/event_channel.c +++ b/xen/common/event_channel.c @@ -1296,6 +1296,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 1dd8a425f9..667863263d 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -800,6 +800,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.43.0