From nobody Sun Dec 14 11:18:45 2025 Delivered-To: importer@patchew.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; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1765512441; cv=pass; d=zohomail.com; s=zohoarc; b=ZK45sYewNMLjzqBIwY7a/81W/B0SmpwDYlF9mJVcdyEiuU+3iJsR9HZ29M0Uj7YxFOqcde+yVEJ+Gcq8a9U+L7uIwAkH/vbwhjHqU6R8DMGX/vJJJmaG7LwcHqC+Jui7PhaMKQCRnAg5UE3j9ea+fC4e33WET5W+BAxhoLT89lg= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1765512441; h=Content-Type: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=zSnQFrn0+BNHOUVlVgs7xAwawlO9+RHttRTFHT2TiAk=; b=EWEpdEVOat2dDqCznRGHJwt0M+GJPXYwPxmJNW6zSiO92AhkWSSot8bboNLMQDXhQbv2CaltmpMlRzyg3tCeeAybm56VbgS3DUB7AL+IUAYrMJIZZk76DdTa8hUjPCtu6gnQgihi9P2lNMb1t7J1mF9ZnWZmejwRzxpYT2kY1FU= ARC-Authentication-Results: i=2; 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; arc=pass (i=1 dmarc=pass fromdomain=amd.com); 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 1765512441838289.42917083745067; Thu, 11 Dec 2025 20:07:21 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1184902.1507242 (Exim 4.92) (envelope-from ) id 1vTuQc-0000gJ-2d; Fri, 12 Dec 2025 04:06:50 +0000 Received: by outflank-mailman (output) from mailman id 1184902.1507242; Fri, 12 Dec 2025 04:06:50 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vTuQb-0000g6-TP; Fri, 12 Dec 2025 04:06:49 +0000 Received: by outflank-mailman (input) for mailman id 1184902; Fri, 12 Dec 2025 04:06:49 +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 1vTuQa-0007Dl-Vv for xen-devel@lists.xenproject.org; Fri, 12 Dec 2025 04:06:48 +0000 Received: from MW6PR02CU001.outbound.protection.outlook.com (mail-westus2azlp170120002.outbound.protection.outlook.com [2a01:111:f403:c007::2]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id fa09c7b2-d70f-11f0-b15b-2bf370ae4941; Fri, 12 Dec 2025 05:06:48 +0100 (CET) Received: from BL0PR02CA0015.namprd02.prod.outlook.com (2603:10b6:207:3c::28) by LV3PR12MB9437.namprd12.prod.outlook.com (2603:10b6:408:21d::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9412.9; Fri, 12 Dec 2025 04:06:43 +0000 Received: from BL02EPF00029929.namprd02.prod.outlook.com (2603:10b6:207:3c:cafe::9e) by BL0PR02CA0015.outlook.office365.com (2603:10b6:207:3c::28) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9412.8 via Frontend Transport; Fri, 12 Dec 2025 04:06:45 +0000 Received: from satlexmb07.amd.com (165.204.84.17) by BL02EPF00029929.mail.protection.outlook.com (10.167.249.54) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9412.4 via Frontend Transport; Fri, 12 Dec 2025 04:06:43 +0000 Received: from penny-System-Product-Name.amd.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.17; Thu, 11 Dec 2025 22:06:40 -0600 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: fa09c7b2-d70f-11f0-b15b-2bf370ae4941 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=QGgh36HewgveIhSJU++TcdjVKNraelM3k76wzNfO8TBp0Ze3IEi8gmsaHHnNRk2hIfryPzJEfx3VRGabfwMniRtibZigKM03XwzTDZ4CqZWubcSZy/U2y/+gXbsoH4rhixRW7yLshNGTaQ9GqY1X5Q78VYyuhmiz0FSjvhkl4lVBHRzIJ0sKJ4aoMEsLveropRuZW39cZhu1H7MInPBTOTs7yUylAkcdXmmz7nDeBnYTjicyUal5mly4UQYQzZIVq0ywcYOQ2Gydlyf+ph8mPsbIwmqjz4bUyK5pVW3Io3I4EDFRNM4VyNoKZavGBwvsszTTSKSi0XZ+bVHL4uizBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=zSnQFrn0+BNHOUVlVgs7xAwawlO9+RHttRTFHT2TiAk=; b=FybDXFltopW2HQ0CAbfhsT/jfWTIipOmoNZEwiyhrXrM3FjCeK838nyPEE85yiyo6oszQjBw+yDWLg79G+RPV4oSgpijatynQk3ylMH+zbX3aIw5eP9UdAJ2BpWZCZIFxD0MK3ZNouFTYW4VjA2Kv8c4booXEcxZT3hIvkno6K3FXDjGJQYCvxpT28hL82tVwHWgqri3/FPX5A4UQMB5z6RI6Vgc8yCE4TWyaIw1FHKaUcEfpLrqfqKPlZJgl736f/AZUCFy8bz5IPYsDBtVsR2wIuP9A7JdJX1+kaPncLk2sUbPLY5QhL9o7jGizYOc+Bd84xDNMRbnr+5jIqcvOQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zSnQFrn0+BNHOUVlVgs7xAwawlO9+RHttRTFHT2TiAk=; b=RaK6Kwizq+AaPl2RY3oggT0922Y0C/zu+BYVaekc1+X8rqtIbkEEG3/cnb0ofcSxnigrvgoaVCe6hnKSn0HTFB3/RoP4bPQJmUX53zh8lldGlCZ8j7CIhja3v8C6lDX6LQ2I7HXeWdh9ppKMmy/SZNF5zb0pmFX9mvsRjO/RbQ0= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; 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; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C From: Penny Zheng To: CC: , , Penny Zheng , Andrew Cooper , "Anthony PERARD" , Michal Orzel , "Jan Beulich" , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , "Stefano Stabellini" Subject: [PATCH v5 07/24] xen/domctl: consolidate domain.c towards MGMT_HYPERCALLS Date: Fri, 12 Dec 2025 12:01:52 +0800 Message-ID: <20251212040209.1970553-8-Penny.Zheng@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251212040209.1970553-1-Penny.Zheng@amd.com> References: <20251212040209.1970553-1-Penny.Zheng@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF00029929:EE_|LV3PR12MB9437:EE_ X-MS-Office365-Filtering-Correlation-Id: 2feafb55-1327-4aaf-ff01-08de3933dc1c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|82310400026|376014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?wDv1/wjajMPCINF+B1yiOk8U9MdJyDoyBjz7dhHpUTeapHVhnhQcw1qfUqcT?= =?us-ascii?Q?xloY6kPS2VXeVOX4zl3U3dqc9w3wipcLuGElQHtsSBMF9URL2AdHAXlxBmt5?= =?us-ascii?Q?YZkVo989kCV50q+fPVDwf26jiw7DXQ36fWPOWZRKqukat5KL2EMBTB6NRM+v?= =?us-ascii?Q?P/Yehx03m0fFj9giA/fY/6dv/v/WJCYjK4LKeJlFqu38Hz0gB3+q2C2hYpIF?= =?us-ascii?Q?kj8nNri5GIkdCZqBqC/XPzxaht8XqW9dDyerYL6lddc7pMeWsVuX0ufV4Bn/?= =?us-ascii?Q?0AALrgu6056YjH0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z0Rv9a?= =?us-ascii?Q?c1UqFxz9T/Tk+/27/r8nrFFZrKt61UOB5RVUlk34mst6a5jzr7rTnpuKNtsI?= =?us-ascii?Q?XPhsf6LqHj9KxyymhGHecloPlxmqR8jALM2zhMSDfiRQQ5EqRGoRkGMRufmu?= =?us-ascii?Q?VhJYGv7wNJZd7kD/Y+7CXB0FRwJRItFBdhp2qna9TH2uKPc/LYlvakr5y3FS?= =?us-ascii?Q?BwLDFCk9oee3Y+zbwg8fOgPTp0+bOBh3IJ3DuZKjcKAG7jDN8gD/dBXI6DTI?= =?us-ascii?Q?3Kw/MDuuTU4UmKpldMLVybMkWBKpCv7N/yvMfQa+070Qh/gJgF6+DRHihGfi?= =?us-ascii?Q?A6uD0yxvG8fpzLxVv1tjpEq7MSf1ClC/8QLHMU1aW0BVxRMhGaATha+J5Bku?= =?us-ascii?Q?a8jnG4g6MPFhILJsLbo=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(1800799024)(82310400026)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Dec 2025 04:06:43.1849 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2feafb55-1327-4aaf-ff01-08de3933dc1c X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF00029929.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR12MB9437 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1765512442115158500 Content-Type: text/plain; charset="utf-8" The following functions, scattered in common/domain.c, and are only referen= ced and responsible for domctl-op: - domain_pause_by_systemcontroller - domain_resume - domain_set_node_affinity So they shall be wrapped with CONFIG_MGMT_HYPERCALLS. Otherwise it will become unreachable codes when MGMT_HYPERCALLS=3Dn, and hence violating Misra rule 2.1. Move them together to avoid scattering #ifdef. And add a leading blank befo= re label to conform to ./CODING_STYLE. Signed-off-by: Penny Zheng Acked-by: Jan Beulich --- v3 - v4: - combine commit "xen/domctl: wrap domain_pause_by_systemcontroller() with = MGMT_HYPERCALLS", "xen/domctl: wrap domain_resume() with CONFIG_MGMT_HYPERCALLS", and "xen/domctl: wrap domain_set_node_affinity() with CONFIG_MGMT_HYPERCALLS" --- v4 -> v5: - coding format correction and title refinement --- xen/common/domain.c | 114 ++++++++++++++++++++++---------------------- 1 file changed, 58 insertions(+), 56 deletions(-) diff --git a/xen/common/domain.c b/xen/common/domain.c index 93c71bc766..f24f3675aa 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -1125,35 +1125,6 @@ void __init setup_system_domains(void) #endif } =20 -int domain_set_node_affinity(struct domain *d, const nodemask_t *affinity) -{ - /* Being disjoint with the system is just wrong. */ - if ( !nodes_intersects(*affinity, node_online_map) ) - return -EINVAL; - - spin_lock(&d->node_affinity_lock); - - /* - * Being/becoming explicitly affine to all nodes is not particularly - * useful. Let's take it as the `reset node affinity` command. - */ - if ( nodes_full(*affinity) ) - { - d->auto_node_affinity =3D 1; - goto out; - } - - d->auto_node_affinity =3D 0; - d->node_affinity =3D *affinity; - -out: - spin_unlock(&d->node_affinity_lock); - - domain_update_node_affinity(d); - - return 0; -} - /* rcu_read_lock(&domlist_read_lock) must be held. */ static struct domain *domid_to_domain(domid_t dom) { @@ -1371,33 +1342,6 @@ int domain_shutdown(struct domain *d, u8 reason) return 0; } =20 -void domain_resume(struct domain *d) -{ - struct vcpu *v; - - /* - * Some code paths assume that shutdown status does not get reset under - * their feet (e.g., some assertions make this assumption). - */ - domain_pause(d); - - spin_lock(&d->shutdown_lock); - - d->is_shutting_down =3D d->is_shut_down =3D 0; - d->shutdown_code =3D SHUTDOWN_CODE_INVALID; - - for_each_vcpu ( d, v ) - { - if ( v->paused_for_shutdown ) - vcpu_unpause(v); - v->paused_for_shutdown =3D 0; - } - - spin_unlock(&d->shutdown_lock); - - domain_unpause(d); -} - int vcpu_start_shutdown_deferral(struct vcpu *v) { if ( v->defer_shutdown ) @@ -1626,10 +1570,68 @@ static int _domain_pause_by_systemcontroller(struct= domain *d, bool sync) return 0; } =20 +#ifdef CONFIG_MGMT_HYPERCALLS +int domain_set_node_affinity(struct domain *d, const nodemask_t *affinity) +{ + /* Being disjoint with the system is just wrong. */ + if ( !nodes_intersects(*affinity, node_online_map) ) + return -EINVAL; + + spin_lock(&d->node_affinity_lock); + + /* + * Being/becoming explicitly affine to all nodes is not particularly + * useful. Let's take it as the `reset node affinity` command. + */ + if ( nodes_full(*affinity) ) + { + d->auto_node_affinity =3D 1; + goto out; + } + + d->auto_node_affinity =3D 0; + d->node_affinity =3D *affinity; + + out: + spin_unlock(&d->node_affinity_lock); + + domain_update_node_affinity(d); + + return 0; +} + +void domain_resume(struct domain *d) +{ + struct vcpu *v; + + /* + * Some code paths assume that shutdown status does not get reset under + * their feet (e.g., some assertions make this assumption). + */ + domain_pause(d); + + spin_lock(&d->shutdown_lock); + + d->is_shutting_down =3D d->is_shut_down =3D 0; + d->shutdown_code =3D SHUTDOWN_CODE_INVALID; + + for_each_vcpu ( d, v ) + { + if ( v->paused_for_shutdown ) + vcpu_unpause(v); + v->paused_for_shutdown =3D 0; + } + + spin_unlock(&d->shutdown_lock); + + domain_unpause(d); +} + int domain_pause_by_systemcontroller(struct domain *d) { return _domain_pause_by_systemcontroller(d, true /* sync */); } +#endif /* CONFIG_MGMT_HYPERCALLS */ =20 int domain_pause_by_systemcontroller_nosync(struct domain *d) { --=20 2.34.1