From patchwork Thu Jul 18 21:57:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 13736756 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7BECCC3DA49 for ; Thu, 18 Jul 2024 21:58:06 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.760735.1170642 (Exim 4.92) (envelope-from ) id 1sUZ8O-0003EA-1M; Thu, 18 Jul 2024 21:57:56 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 760735.1170642; Thu, 18 Jul 2024 21:57:55 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sUZ8N-0003Cv-RQ; Thu, 18 Jul 2024 21:57:55 +0000 Received: by outflank-mailman (input) for mailman id 760735; Thu, 18 Jul 2024 21:57:54 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sUZ8M-0003BD-6A for xen-devel@lists.xenproject.org; Thu, 18 Jul 2024 21:57:54 +0000 Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [2a00:1450:4864:20::229]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id c8087f40-4550-11ef-bbfd-fd08da9f4363; Thu, 18 Jul 2024 23:57:52 +0200 (CEST) Received: by mail-lj1-x229.google.com with SMTP id 38308e7fff4ca-2eedea0fd88so17559621fa.2 for ; Thu, 18 Jul 2024 14:57:52 -0700 (PDT) Received: from andrewcoop.eng.citrite.net ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7a33de74e5sm5294266b.147.2024.07.18.14.57.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 14:57:50 -0700 (PDT) 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: c8087f40-4550-11ef-bbfd-fd08da9f4363 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1721339871; x=1721944671; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zwFWzFvgZNrEVHvyRBE8cy2ybaA/G1NJTsH6Emb+MEQ=; b=r+Vu8uaXA/MHX011CptwK1aHeMR5A1/I9RhXtxeeA/sC31JVuYUnhvZLqi+8LnC6QP g/1HvrBIXn0FNjZIYsZaSnJlpPHst7g0aMw+CvE2nPTHPcqJy/IKh1Q2nE0fHIlxtv3u PB5FT7fX1yj2OvsCSvn+u6BCBHEMbuY55aiPM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721339871; x=1721944671; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zwFWzFvgZNrEVHvyRBE8cy2ybaA/G1NJTsH6Emb+MEQ=; b=VK981onbRL7G4/2U26bNbEKETPirUPSX5YyA/NnABQQNs5jGb2pqsLzcfXSYs3XG2D CY8dBWxp8niAYn0fhQ6ChcuIs+0Xe3Q7f72EQxEpH+gLgqMhPqthxt7r0qYXGp/uXj+L yOkMLWuGczBI9qQH3OjF+vBhz78bM3ZQjRuisD4VDcdG1lH+kwBDN1kB9vOVobh4XfV8 bSOLkP/kIdp3MJTkPDgD8O6ohuQJFPXChY58DdF1ZqlEkT/sjWN3jEZPfx9irFM5PKB/ Gdc5P2guOPtMeyDI1pWDb+BO72T/L5qM3ZwEKf424fM3t7Mia1XbqHzIq89ZPA+IJdAM xZMA== X-Gm-Message-State: AOJu0Yw6iC1qE+PC9HdF3IKTAiG+k0WzNTbZSCPcBprVOrxP/OeOokOW KzuDnpyS6GqgLJ9FOzKQSSXa6noQ0ekNecEgjVKzmNT6s9k4K6I9CgkYOjh4pmqhu1zpX7KY86A 1 X-Google-Smtp-Source: AGHT+IFRHnZO7GLRxxpq0OV++qcIOqQIfYWu2izeKn140Dl3ATRuCUEfGAbfWVvQK4LITKnoUg8qmA== X-Received: by 2002:a05:6512:682:b0:52c:e040:7d9 with SMTP id 2adb3069b0e04-52ee5428af2mr4540350e87.59.1721339871272; Thu, 18 Jul 2024 14:57:51 -0700 (PDT) From: Andrew Cooper To: Xen-devel Cc: Andrew Cooper , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Bertrand Marquis , Michal Orzel , Oleksii Kurochko Subject: [PATCH 1/4] xen/domain: Introduce arch_init_idle_domain() Date: Thu, 18 Jul 2024 22:57:41 +0100 Message-Id: <20240718215744.3892072-2-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240718215744.3892072-1-andrew.cooper3@citrix.com> References: <20240718215744.3892072-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 The idle domain causes a large amount of complexity in domain_create() because of x86's need to initialise d->arch.ctxt_switch in arch_domain_create(). In order to address this, introduce an optional hook to perform extra initialisation of the idle domain. No functional change. Signed-off-by: Andrew Cooper Reviewed-by: Stefano Stabellini --- CC: Jan Beulich CC: Roger Pau Monné CC: Stefano Stabellini CC: Julien Grall CC: Volodymyr Babchuk CC: Bertrand Marquis CC: Michal Orzel CC: Oleksii Kurochko --- xen/common/domain.c | 3 +++ xen/include/xen/sched.h | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/xen/common/domain.c b/xen/common/domain.c index fb262dcec919..e312c820d641 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -685,6 +685,9 @@ struct domain *domain_create(domid_t domid, rangeset_domain_initialise(d); + if ( is_idle_domain(d) ) + arch_init_idle_domain(d); + /* DOMID_{XEN,IO,etc} (other than IDLE) are sufficiently constructed. */ if ( is_system_domain(d) && !is_idle_domain(d) ) return d; diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 2dcd1d1a4f8a..90666576c2f8 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -728,6 +728,11 @@ struct domain *domain_create(domid_t domid, struct xen_domctl_createdomain *config, unsigned int flags); +#ifndef arch_init_idle_domain +/* Optional, if there's any construction necessary for DOMID_IDLE */ +static inline void arch_init_idle_domain(struct domain *d) {} +#endif + /* * rcu_lock_domain_by_id() is more efficient than get_domain_by_id(). * This is the preferred function if the returned domain reference From patchwork Thu Jul 18 21:57:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 13736755 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2A189C3DA6F for ; Thu, 18 Jul 2024 21:58:04 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.760736.1170657 (Exim 4.92) (envelope-from ) id 1sUZ8P-0003es-5a; Thu, 18 Jul 2024 21:57:57 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 760736.1170657; Thu, 18 Jul 2024 21:57:57 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sUZ8P-0003eC-2K; Thu, 18 Jul 2024 21:57:57 +0000 Received: by outflank-mailman (input) for mailman id 760736; Thu, 18 Jul 2024 21:57:55 +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 1sUZ8N-0002ha-LT for xen-devel@lists.xenproject.org; Thu, 18 Jul 2024 21:57:55 +0000 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [2a00:1450:4864:20::62d]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id c8c7e146-4550-11ef-8776-851b0ebba9a2; Thu, 18 Jul 2024 23:57:54 +0200 (CEST) Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-a77ec5d3b0dso142087166b.0 for ; Thu, 18 Jul 2024 14:57:54 -0700 (PDT) Received: from andrewcoop.eng.citrite.net ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7a33de74e5sm5294266b.147.2024.07.18.14.57.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 14:57:51 -0700 (PDT) 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: c8c7e146-4550-11ef-8776-851b0ebba9a2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1721339873; x=1721944673; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4GWn57rc3KL1PwUW4FYINxfwiapH7y2BIUBNdFS5IEE=; b=d+pdsbs/RoAFns/vM3tUJkFHJlIQYRydN8LQ/gz1QR7WROYNiK0B9rU6ZPac+YC6Zm AAdA26TeNwGKxxqpiVD8v9nxS8s04P1mOZY1YBXSzHbjRFL9lZtqDRWtOS3h9h5qSL7q 4slXc+JfOYdatcY9WJW6v4QqEzyHOYEjSIaNM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721339873; x=1721944673; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4GWn57rc3KL1PwUW4FYINxfwiapH7y2BIUBNdFS5IEE=; b=eDgBQP6ftG6/7g06MKaIs0VzsfI7N/n5M6YaZ8kfOquC/YM3IdDVwzeUcrX6n1Ep39 on6pJkGmnEA0aaOdhV3MIzjPilTSvCLQGv2rrKWBVk1NlyXE8V0By+jQCwd9jvofe+K4 J57VxKF2XHPpcmZFzknGMkpZoAK/O6nnn0u62io9xiafJyKCXu4462Yj8KUnZIpeX77B 2flFBl45C6NenjhZY7txC5JL4qIXTuPDGFQhpGCTZOROF9uiv0bJE+cigvdVNh0wob+S LutsOY9rVQO4cYflo28BS1aqM38y6uGWYNHLfOSQUs0goLBNHCP4xpUwHCUp0D2FD7pS WGRw== X-Gm-Message-State: AOJu0YwEexa1C6uC+sfjZq8cmiaqieZomtfg9lJOywldHycxz1faPhHC RAV69anmyBHhBE2VG29bbOqh7LpQyJY+4Pj1ygGLpVv2xbqPfLcbBwHIrI0GaRi1gJJ3h1V3hGz j X-Google-Smtp-Source: AGHT+IE3GGRKISsIRhYfJ2h3x/9H/KPzRnvd/7V4dLwQxc5o97oAu/KglCBD0nhQcEY4Ch4NIYTFfg== X-Received: by 2002:a17:906:eb57:b0:a75:360a:6cb0 with SMTP id a640c23a62f3a-a7a0115669bmr386806366b.29.1721339873212; Thu, 18 Jul 2024 14:57:53 -0700 (PDT) From: Andrew Cooper To: Xen-devel Cc: Andrew Cooper , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Bertrand Marquis , Michal Orzel , Oleksii Kurochko Subject: [PATCH 2/4] x86/domain: Implement arch_init_idle_domain() Date: Thu, 18 Jul 2024 22:57:42 +0100 Message-Id: <20240718215744.3892072-3-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240718215744.3892072-1-andrew.cooper3@citrix.com> References: <20240718215744.3892072-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 The idle domain needs d->arch.ctxt_switch initialised on x86. Implement the new arch_init_idle_domain() in order to do this. Right now this double-initalises the ctxt_switch pointer, but it's safe and will stop happening when domain_create() is cleaned up as a consequence. No practical change. Signed-off-by: Andrew Cooper --- CC: Jan Beulich CC: Roger Pau Monné CC: Stefano Stabellini CC: Julien Grall CC: Volodymyr Babchuk CC: Bertrand Marquis CC: Michal Orzel CC: Oleksii Kurochko --- xen/arch/x86/domain.c | 19 ++++++++++++------- xen/arch/x86/include/asm/domain.h | 3 +++ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index ccadfe0c9e70..eff905c6c6e5 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -768,6 +768,17 @@ static bool emulation_flags_ok(const struct domain *d, uint32_t emflags) return true; } +void __init arch_init_idle_domain(struct domain *d) +{ + static const struct arch_csw idle_csw = { + .from = paravirt_ctxt_switch_from, + .to = paravirt_ctxt_switch_to, + .tail = idle_loop, + }; + + d->arch.ctxt_switch = &idle_csw; +} + int arch_domain_create(struct domain *d, struct xen_domctl_createdomain *config, unsigned int flags) @@ -783,13 +794,7 @@ int arch_domain_create(struct domain *d, /* Minimal initialisation for the idle domain. */ if ( unlikely(is_idle_domain(d)) ) { - static const struct arch_csw idle_csw = { - .from = paravirt_ctxt_switch_from, - .to = paravirt_ctxt_switch_to, - .tail = idle_loop, - }; - - d->arch.ctxt_switch = &idle_csw; + arch_init_idle_domain(d); d->arch.cpu_policy = ZERO_BLOCK_PTR; /* Catch stray misuses. */ diff --git a/xen/arch/x86/include/asm/domain.h b/xen/arch/x86/include/asm/domain.h index f5daeb182baa..bca3258d69ac 100644 --- a/xen/arch/x86/include/asm/domain.h +++ b/xen/arch/x86/include/asm/domain.h @@ -779,6 +779,9 @@ struct arch_vcpu_io { /* Maxphysaddr supportable by the paging infrastructure. */ unsigned int domain_max_paddr_bits(const struct domain *d); +#define arch_init_idle_domain arch_init_idle_domain +void arch_init_idle_domain(struct domain *d); + #endif /* __ASM_DOMAIN_H__ */ /* From patchwork Thu Jul 18 21:57:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 13736757 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 87515C3DA61 for ; Thu, 18 Jul 2024 21:58:06 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.760738.1170667 (Exim 4.92) (envelope-from ) id 1sUZ8Q-0003vB-Dz; Thu, 18 Jul 2024 21:57:58 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 760738.1170667; Thu, 18 Jul 2024 21:57:58 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sUZ8Q-0003v2-9y; Thu, 18 Jul 2024 21:57:58 +0000 Received: by outflank-mailman (input) for mailman id 760738; Thu, 18 Jul 2024 21:57:57 +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 1sUZ8P-0002ha-1r for xen-devel@lists.xenproject.org; Thu, 18 Jul 2024 21:57:57 +0000 Received: from mail-lj1-x22d.google.com (mail-lj1-x22d.google.com [2a00:1450:4864:20::22d]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id c99aefcf-4550-11ef-8776-851b0ebba9a2; Thu, 18 Jul 2024 23:57:55 +0200 (CEST) Received: by mail-lj1-x22d.google.com with SMTP id 38308e7fff4ca-2eeb2d60efbso20289261fa.1 for ; Thu, 18 Jul 2024 14:57:55 -0700 (PDT) Received: from andrewcoop.eng.citrite.net ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7a33de74e5sm5294266b.147.2024.07.18.14.57.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 14:57:53 -0700 (PDT) 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: c99aefcf-4550-11ef-8776-851b0ebba9a2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1721339874; x=1721944674; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0kD2ViH5db6Uhco+HhIi3wbdU8JjVgf/T8jwX9hiBjs=; b=ANnUEvxc/vpl9CEkHpCop9xNZHENXl93pV0kHUKa+CTQ/vcGluBBuBpf6JSIfF9Lj2 HXY1mX1bzCJwai6fPNzjLLHtZ7IjwZmerDHEz/+gRIqsCOyysL8RfOPDi9zNVg+PtzVG hXXipgtRDf6S1ZMhYMZROGlB5k5oje/tguD2k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721339874; x=1721944674; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0kD2ViH5db6Uhco+HhIi3wbdU8JjVgf/T8jwX9hiBjs=; b=Y8ezOTb66sZwZCt0wfcSSgTvdcFMQO0/nWlQbpYuhTWYYZAJfwGj7nwjxVnIs1aRql EqX6vvLRgCrW1DW5yEjRsHUKodOnnrTacQqVxECBp/Iu11eTle5MRs8aGMggM4yx7q2C 97ozrdmv7O2r00Del0frhQBnnv6JuC+CMO06wt2qpzoX/imm+mU8Wg76He1DxeJnAtuK gbJeP+/J0fQEmALBtAoieIaypO/5TNO8DeGBUZMpjw/ukkov1a2/+ebxHqh9j4CxPsLf hmLK1k20A0oZuhAQ+auez/SqAKNFjenOKB301McGndOQ6QOmu6YOWsBCF7Toz72LinDN DNzg== X-Gm-Message-State: AOJu0Yw+yvVzRjO6PHvHPvtEo0JVq85V+8NHJuwsKN1wMutXJopyaVPs omRGAo/psi5+48/Kq3VouSYDhVe7brr0jrsFnEze2oYkAxMPf6dNwU7wcMfh8SZeXlTle7N9d1K G X-Google-Smtp-Source: AGHT+IGHlZV97i3PU5wQnBNAb4+RoZtIr+55cNa39VxMHty8bOFfUy/Rr/pg4MsU3ofnYw53Ne+R8Q== X-Received: by 2002:a05:6512:6c7:b0:52e:9670:e40b with SMTP id 2adb3069b0e04-52ee53d2c31mr4190759e87.39.1721339874564; Thu, 18 Jul 2024 14:57:54 -0700 (PDT) From: Andrew Cooper To: Xen-devel Cc: Andrew Cooper , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Bertrand Marquis , Michal Orzel , Oleksii Kurochko Subject: [PATCH 3/4] xen/domain: Simpliy domain_create() now the idle domain is complete earlier Date: Thu, 18 Jul 2024 22:57:43 +0100 Message-Id: <20240718215744.3892072-4-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240718215744.3892072-1-andrew.cooper3@citrix.com> References: <20240718215744.3892072-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 With x86 implementing arch_init_idle_domain(), there is no longer any need to call arch_domain_create() with the idle domain. Have the idle domain exit early with all other system domains. Move the static-analysis ASSERT() earlier. Then, remove the !is_idle_domain() protections around the majority of domain_create() and remove one level of indentation. No practical change. Signed-off-by: Andrew Cooper Reviewed-by: Stefano Stabellini --- CC: Jan Beulich CC: Roger Pau Monné CC: Stefano Stabellini CC: Julien Grall CC: Volodymyr Babchuk CC: Bertrand Marquis CC: Michal Orzel CC: Oleksii Kurochko --- xen/common/domain.c | 127 +++++++++++++++++++++----------------------- 1 file changed, 60 insertions(+), 67 deletions(-) diff --git a/xen/common/domain.c b/xen/common/domain.c index e312c820d641..8bc0bcd06ca5 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -688,95 +688,88 @@ struct domain *domain_create(domid_t domid, if ( is_idle_domain(d) ) arch_init_idle_domain(d); - /* DOMID_{XEN,IO,etc} (other than IDLE) are sufficiently constructed. */ - if ( is_system_domain(d) && !is_idle_domain(d) ) + /* DOMID_{XEN,IO,IDLE,etc} are sufficiently constructed. */ + if ( is_system_domain(d) ) return d; + /* + * The assertion helps static analysis tools infer that config cannot be + * NULL in this branch, which in turn means that it can be safely + * dereferenced. Therefore, this assertion is not redundant. + */ + ASSERT(config); + #ifdef CONFIG_HAS_PIRQ - if ( !is_idle_domain(d) ) - { - if ( !is_hardware_domain(d) ) - d->nr_pirqs = nr_static_irqs + extra_domU_irqs; - else - d->nr_pirqs = extra_hwdom_irqs ? nr_static_irqs + extra_hwdom_irqs - : arch_hwdom_irqs(d); - d->nr_pirqs = min(d->nr_pirqs, nr_irqs); + if ( !is_hardware_domain(d) ) + d->nr_pirqs = nr_static_irqs + extra_domU_irqs; + else + d->nr_pirqs = extra_hwdom_irqs ? nr_static_irqs + extra_hwdom_irqs + : arch_hwdom_irqs(d); + d->nr_pirqs = min(d->nr_pirqs, nr_irqs); - radix_tree_init(&d->pirq_tree); - } + radix_tree_init(&d->pirq_tree); #endif if ( (err = arch_domain_create(d, config, flags)) != 0 ) goto fail; init_status |= INIT_arch; - if ( !is_idle_domain(d) ) - { - /* - * The assertion helps static analysis tools infer that config cannot - * be NULL in this branch, which in turn means that it can be safely - * dereferenced. Therefore, this assertion is not redundant. - */ - ASSERT(config); - - watchdog_domain_init(d); - init_status |= INIT_watchdog; + watchdog_domain_init(d); + init_status |= INIT_watchdog; - err = -ENOMEM; - d->iomem_caps = rangeset_new(d, "I/O Memory", RANGESETF_prettyprint_hex); - d->irq_caps = rangeset_new(d, "Interrupts", 0); - if ( !d->iomem_caps || !d->irq_caps ) - goto fail; + err = -ENOMEM; + d->iomem_caps = rangeset_new(d, "I/O Memory", RANGESETF_prettyprint_hex); + d->irq_caps = rangeset_new(d, "Interrupts", 0); + if ( !d->iomem_caps || !d->irq_caps ) + goto fail; - if ( (err = xsm_domain_create(XSM_HOOK, d, config->ssidref)) != 0 ) - goto fail; + if ( (err = xsm_domain_create(XSM_HOOK, d, config->ssidref)) != 0 ) + goto fail; - d->controller_pause_count = 1; - atomic_inc(&d->pause_count); + d->controller_pause_count = 1; + atomic_inc(&d->pause_count); - if ( (err = evtchn_init(d, config->max_evtchn_port)) != 0 ) - goto fail; - init_status |= INIT_evtchn; + if ( (err = evtchn_init(d, config->max_evtchn_port)) != 0 ) + goto fail; + init_status |= INIT_evtchn; - if ( (err = grant_table_init(d, config->max_grant_frames, - config->max_maptrack_frames, - config->grant_opts)) != 0 ) - goto fail; - init_status |= INIT_gnttab; + if ( (err = grant_table_init(d, config->max_grant_frames, + config->max_maptrack_frames, + config->grant_opts)) != 0 ) + goto fail; + init_status |= INIT_gnttab; - if ( (err = argo_init(d)) != 0 ) - goto fail; + if ( (err = argo_init(d)) != 0 ) + goto fail; - err = -ENOMEM; + err = -ENOMEM; + d->pbuf = xzalloc_array(char, DOMAIN_PBUF_SIZE); + if ( !d->pbuf ) + goto fail; - d->pbuf = xzalloc_array(char, DOMAIN_PBUF_SIZE); - if ( !d->pbuf ) - goto fail; + if ( (err = sched_init_domain(d, config->cpupool_id)) != 0 ) + goto fail; - if ( (err = sched_init_domain(d, config->cpupool_id)) != 0 ) - goto fail; + if ( (err = late_hwdom_init(d)) != 0 ) + goto fail; - if ( (err = late_hwdom_init(d)) != 0 ) - goto fail; + /* + * Must not fail beyond this point, as our caller doesn't know whether + * the domain has been entered into domain_list or not. + */ - /* - * Must not fail beyond this point, as our caller doesn't know whether - * the domain has been entered into domain_list or not. - */ + spin_lock(&domlist_update_lock); + pd = &domain_list; /* NB. domain_list maintained in order of domid. */ + for ( pd = &domain_list; *pd != NULL; pd = &(*pd)->next_in_list ) + if ( (*pd)->domain_id > d->domain_id ) + break; + d->next_in_list = *pd; + d->next_in_hashbucket = domain_hash[DOMAIN_HASH(domid)]; + rcu_assign_pointer(*pd, d); + rcu_assign_pointer(domain_hash[DOMAIN_HASH(domid)], d); + spin_unlock(&domlist_update_lock); - spin_lock(&domlist_update_lock); - pd = &domain_list; /* NB. domain_list maintained in order of domid. */ - for ( pd = &domain_list; *pd != NULL; pd = &(*pd)->next_in_list ) - if ( (*pd)->domain_id > d->domain_id ) - break; - d->next_in_list = *pd; - d->next_in_hashbucket = domain_hash[DOMAIN_HASH(domid)]; - rcu_assign_pointer(*pd, d); - rcu_assign_pointer(domain_hash[DOMAIN_HASH(domid)], d); - spin_unlock(&domlist_update_lock); - - memcpy(d->handle, config->handle, sizeof(d->handle)); - } + memcpy(d->handle, config->handle, sizeof(d->handle)); return d; From patchwork Thu Jul 18 21:57:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 13736758 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4153CC3DA70 for ; Thu, 18 Jul 2024 21:58:09 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.760739.1170677 (Exim 4.92) (envelope-from ) id 1sUZ8R-0004Bb-P7; Thu, 18 Jul 2024 21:57:59 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 760739.1170677; Thu, 18 Jul 2024 21:57:59 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sUZ8R-0004BC-Jj; Thu, 18 Jul 2024 21:57:59 +0000 Received: by outflank-mailman (input) for mailman id 760739; Thu, 18 Jul 2024 21:57:58 +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 1sUZ8Q-0002ha-Fc for xen-devel@lists.xenproject.org; Thu, 18 Jul 2024 21:57:58 +0000 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [2a00:1450:4864:20::636]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id ca7955d4-4550-11ef-8776-851b0ebba9a2; Thu, 18 Jul 2024 23:57:57 +0200 (CEST) Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-a77b60cafecso124216166b.1 for ; Thu, 18 Jul 2024 14:57:57 -0700 (PDT) Received: from andrewcoop.eng.citrite.net ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7a33de74e5sm5294266b.147.2024.07.18.14.57.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 14:57:54 -0700 (PDT) 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: ca7955d4-4550-11ef-8776-851b0ebba9a2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1721339876; x=1721944676; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pK2gBpeR70VDp1XL+JhXx1V184ewFc/upF4kiKIMrfA=; b=fRaLajRIwFrm1Uv0PtCIKgo9YHsDVVF5cpWV6w1BGcPJYprt4WiLyUD7GGzl9STZWk UtClffa3ytaFydikIxZHXQF/aP9XTo1x+ZnKZC+dB60xjQXLXoVBOA+nNVFwU8MoEj1d YvZWNDq/ymAhaxljliElkL9HiwKLlpPTvmrwI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721339876; x=1721944676; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pK2gBpeR70VDp1XL+JhXx1V184ewFc/upF4kiKIMrfA=; b=q4wYmMYUkvEQmuKu3JNNFFH85x1EYf2xTYZ02GJPkluvhEvrgMmRpqZtEnTeGSpqRM 5tpRXpeC5PjFQ0y3aeu1lF7tsryxaRVtRrf88mQ08pmuY7MRpbce9fXdaNRDzLGKHJdh 959KOmw9X0ptny+O/UUa0ilHQutcE7oobXu82dhSIzETGXA8daT0re+WY/Q+QUp4HZPr probWaCqmIZXU5NAXLpnv2k+URS+p097nAk33EH+qc63tOpkZsRUPgazVkdjTZbdW5pM wMOOg2Dn1FW/nNRIZYpCa5x/Mb5jLR7KlK/5j5sqMFb62KWKKCvZyMvIL6OSv/M4CNyu gfhw== X-Gm-Message-State: AOJu0YyaW+cLdGOfTDV6n3/BSmSW0cCT7Qnbf40m+aHl0YpsEWPEWggV /bTprDL4ENA8X4/J0PEpRErhVGx6/InvLGpT8kEl8TWlf4hlyOLzAoa+CPjw5ZM73BUfqzJBNhG l X-Google-Smtp-Source: AGHT+IFB7yjppIhAgZ8m4CBxVfzIr48DXBLeUPrXLqCUrWuO+0kxLeiYLzO/mUuOjamiLIWw3mAohg== X-Received: by 2002:a17:906:f212:b0:a77:cb9c:e808 with SMTP id a640c23a62f3a-a7a01360756mr371966466b.69.1721339875805; Thu, 18 Jul 2024 14:57:55 -0700 (PDT) From: Andrew Cooper To: Xen-devel Cc: Andrew Cooper , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Bertrand Marquis , Michal Orzel , Oleksii Kurochko Subject: [PATCH 4/4] arch/domain: Clean up the idle domain remnants in arch_domain_create() Date: Thu, 18 Jul 2024 22:57:44 +0100 Message-Id: <20240718215744.3892072-5-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240718215744.3892072-1-andrew.cooper3@citrix.com> References: <20240718215744.3892072-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 With arch_domain_create() no longer being called with the idle domain, drop the last remaining logic. No functional change. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich Reviewed-by: Stefano Stabellini --- CC: Jan Beulich CC: Roger Pau Monné CC: Stefano Stabellini CC: Julien Grall CC: Volodymyr Babchuk CC: Bertrand Marquis CC: Michal Orzel CC: Oleksii Kurochko --- xen/arch/arm/domain.c | 6 ------ xen/arch/x86/domain.c | 17 ----------------- 2 files changed, 23 deletions(-) diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index 7cfcefd27944..3ba959f86633 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -706,12 +706,6 @@ int arch_domain_create(struct domain *d, BUILD_BUG_ON(GUEST_MAX_VCPUS < MAX_VIRT_CPUS); - /* Idle domains do not need this setup */ - if ( is_idle_domain(d) ) - return 0; - - ASSERT(config != NULL); - #ifdef CONFIG_IOREQ_SERVER ioreq_domain_init(d); #endif diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index eff905c6c6e5..c71b9023cb1a 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -791,23 +791,6 @@ int arch_domain_create(struct domain *d, spin_lock_init(&d->arch.e820_lock); - /* Minimal initialisation for the idle domain. */ - if ( unlikely(is_idle_domain(d)) ) - { - arch_init_idle_domain(d); - - d->arch.cpu_policy = ZERO_BLOCK_PTR; /* Catch stray misuses. */ - - return 0; - } - - if ( !config ) - { - /* Only IDLE is allowed with no config. */ - ASSERT_UNREACHABLE(); - return -EINVAL; - } - if ( d->domain_id && cpu_has_amd_erratum(&boot_cpu_data, AMD_ERRATUM_121) ) { if ( !opt_allow_unsafe )