From nobody Sun Feb 8 19:38:05 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 header.i=dpsmith@apertussolutions.com; 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; arc=pass (i=1 dmarc=pass fromdomain=apertussolutions.com) ARC-Seal: i=2; a=rsa-sha256; t=1690921261; cv=pass; d=zohomail.com; s=zohoarc; b=RenHJ5fxnRSnSA0JhfZak29/6DLkroDG/eKKTQ53Ig4snWChvYsk3uI27vlzYHSptKNypiSMx5t+8Pg0q9gcSdqu/HiQRsR3DLOMkVmlkYJwGuOqmzfsubDbiEsCOjneWmvapnjFhpTkZjwi5gsObl5uV8atyz5ngGeC/NQooio= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690921261; 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=QxHgg6odiTfgWhhWOuj3R7wSlDiixIdY8mSDQ2Z3eHA=; b=h2DLuA5jG22nWuaqYcNa3CSIJrIlFzSbedwQbJsi0nlH9ftw+zpQnGJmAjZMYOvbAG1PiefMD+HC+Nh2mKzDFPSEvfwSwhlW1DJXM6PqS7TfT//qy7iiPeEfZL6pSPlrtUXVcLcKNfnwDskSJuusabmS/0ZwmpCKSjj7SlhMUtQ= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=dpsmith@apertussolutions.com; 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; arc=pass (i=1 dmarc=pass fromdomain=apertussolutions.com) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1690921260776385.59330703641297; Tue, 1 Aug 2023 13:21:00 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.574496.899816 (Exim 4.92) (envelope-from ) id 1qQvr6-00088b-My; Tue, 01 Aug 2023 20:20:32 +0000 Received: by outflank-mailman (output) from mailman id 574496.899816; Tue, 01 Aug 2023 20:20:32 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qQvr6-00088U-K0; Tue, 01 Aug 2023 20:20:32 +0000 Received: by outflank-mailman (input) for mailman id 574496; Tue, 01 Aug 2023 20:20:31 +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 1qQvr5-0007tB-6f for xen-devel@lists.xenproject.org; Tue, 01 Aug 2023 20:20:31 +0000 Received: from sender4-of-o50.zoho.com (sender4-of-o50.zoho.com [136.143.188.50]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id db082af5-30a8-11ee-8613-37d641c3527e; Tue, 01 Aug 2023 22:20:29 +0200 (CEST) Received: from sisyou.hme. (static-72-81-132-2.bltmmd.fios.verizon.net [72.81.132.2]) by mx.zohomail.com with SMTPS id 1690921219023154.7244666059837; Tue, 1 Aug 2023 13:20:19 -0700 (PDT) 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: db082af5-30a8-11ee-8613-37d641c3527e ARC-Seal: i=1; a=rsa-sha256; t=1690921221; cv=none; d=zohomail.com; s=zohoarc; b=lNiYjknsKhksJuvxpu+1YL5h1k8mUf7MfDMTehx9xU9qY5ePFGqwxPnrerUsLBUENjnbLVykTx6E+3375JIzcLHVjrH1owt/cSAJx4+MsyWXAOYsyQ8QyOhYARJSdBcWS7hfpcs2IHDbWgZ0pPzTKoy12sj88af3NZYp1j/eQc8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690921221; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=QxHgg6odiTfgWhhWOuj3R7wSlDiixIdY8mSDQ2Z3eHA=; b=QxaM6Mozt3aw6tfNbgM0mdmi6SZMN2qq8JWlFgWqRoVslhpfCKnpUG/ju1IJ8IHddkjWz3pKHO9jlZ6yqU6s/BvvLgeOITobNtuGmvPmm+JYx7JaL4W1axtMW4kQXTeMnhZ6yUSd74Cmq86A25KWy88w6SpnkfXs7KLG9/tpICQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1690921221; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=QxHgg6odiTfgWhhWOuj3R7wSlDiixIdY8mSDQ2Z3eHA=; b=JENP3hnykOC520uj6z57yLCmOzl6QU/5aI46l4vND4WKa2l/AGeUazOqIK8Vtu6y MapOgQvnxH7eaGAvDTmUhJDP+KGAsizdabjmyucONUw15X0hwzYwxdOfkJHLBZsU9aj hpPLkJScrv/frwb24yryVd6pgxcf0S297t3YL7CE= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org, xen-devel@dornerworks.com Cc: "Daniel P. Smith" , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu , Nathan Studer , Stewart Hildebrand , Dario Faggioli Subject: [RFC 1/6] dom0: replace explict zero checks Date: Tue, 1 Aug 2023 16:20:01 -0400 Message-Id: <20230801202006.20322-2-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20230801202006.20322-1-dpsmith@apertussolutions.com> References: <20230801202006.20322-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External X-ZohoMail-DKIM: pass (identity dpsmith@apertussolutions.com) X-ZM-MESSAGEID: 1690921263493100003 Content-Type: text/plain; charset="utf-8" A legacy concept is that the initial domain will have a domain id of zero. = As a result there are places where a check that a domain is the inital domain is determined by an explicit check that the domid is zero. This commit seeks to abstract this check into a function call and replace a= ll check locations with the function call. Signed-off-by: Daniel P. Smith --- xen/common/domain.c | 4 ++-- xen/common/sched/arinc653.c | 2 +- xen/common/sched/core.c | 4 ++-- xen/include/xen/sched.h | 7 +++++++ 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/xen/common/domain.c b/xen/common/domain.c index 304aa04fa6..8fb3c052f5 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -309,7 +309,7 @@ static int late_hwdom_init(struct domain *d) struct domain *dom0; int rv; =20 - if ( d !=3D hardware_domain || d->domain_id =3D=3D 0 ) + if ( d !=3D hardware_domain || is_initial_domain(d) ) return 0; =20 rv =3D xsm_init_hardware_domain(XSM_HOOK, d); @@ -612,7 +612,7 @@ struct domain *domain_create(domid_t domid, d->is_privileged =3D flags & CDF_privileged; =20 /* Sort out our idea of is_hardware_domain(). */ - if ( domid =3D=3D 0 || domid =3D=3D hardware_domid ) + if ( is_initial_domain(d) || domid =3D=3D hardware_domid ) { if ( hardware_domid < 0 || hardware_domid >=3D DOMID_FIRST_RESERVE= D ) panic("The value of hardware_dom must be a valid domain ID\n"); diff --git a/xen/common/sched/arinc653.c b/xen/common/sched/arinc653.c index a82c0d7314..31e8270af3 100644 --- a/xen/common/sched/arinc653.c +++ b/xen/common/sched/arinc653.c @@ -404,7 +404,7 @@ a653sched_alloc_udata(const struct scheduler *ops, stru= ct sched_unit *unit, * Add every one of dom0's units to the schedule, as long as there are * slots available. */ - if ( unit->domain->domain_id =3D=3D 0 ) + if ( is_initial_domain(unit->domain) ) { entry =3D sched_priv->num_schedule_entries; =20 diff --git a/xen/common/sched/core.c b/xen/common/sched/core.c index 022f548652..210ad30f94 100644 --- a/xen/common/sched/core.c +++ b/xen/common/sched/core.c @@ -585,7 +585,7 @@ int sched_init_vcpu(struct vcpu *v) */ sched_set_affinity(unit, cpumask_of(0), cpumask_of(0)); } - else if ( d->domain_id =3D=3D 0 && opt_dom0_vcpus_pin ) + else if ( is_initial_domain(d) && opt_dom0_vcpus_pin ) { /* * If dom0_vcpus_pin is specified, dom0 vCPUs are pinned 1:1 to @@ -594,7 +594,7 @@ int sched_init_vcpu(struct vcpu *v) sched_set_affinity(unit, cpumask_of(processor), &cpumask_all); } #ifdef CONFIG_X86 - else if ( d->domain_id =3D=3D 0 ) + else if ( is_initial_domain(d) ) { /* * In absence of dom0_vcpus_pin instead, the hard and soft affinit= y of diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 854f3e32c0..a9276a7bed 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -1058,6 +1058,13 @@ void scheduler_disable(void); void watchdog_domain_init(struct domain *d); void watchdog_domain_destroy(struct domain *d); =20 +static always_inline bool is_initial_domain(const struct domain *d) +{ + static int init_domain_id =3D 0; + + return d->domain_id =3D=3D init_domain_id; +} + /* * Use this check when the following are both true: * - Using this feature or interface requires full access to the hardware --=20 2.20.1