From nobody Mon Nov 23 22:28:34 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; arc=pass (i=1 dmarc=pass fromdomain=epam.com); dmarc=pass(p=quarantine dis=none) header.from=epam.com ARC-Seal: i=2; a=rsa-sha256; t=1794222787; cv=pass; d=zohomail.com; s=zohoarc; b=MRuZ3cZB2xGOAYehYaYtw24tZknuWqsVB3DDRPbONkhuPN2zT/yJ2q/jc1BlnyBX0pCqNz663QKmRfdSQDrDQflebuxyTwH1zteR03VkqZk0yrdCxh3cXh7n8EnharCqE6BrpTAtrLTxchE6WhKqvGDy4XorKa9/MgGQf3I/alw= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794222787; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=hPWsttjC1WUZeRXqCO/27twOSP1g+3ez+TabzjY7rwc=; b=ZXA5oWx82lVProIipyNMWjgrHYUe+JONk/5bBVKRytVEL21u7TbpAWcmiyr7Uairo+GBekkfi2t6kCUNriM8Xiv7aEhmpcyBkQ+Q9o4gX5tnExLxvNw0TduRbv7ZxlERMRoPwYpsmSK9lXStv7/LRaCQy6nPi+KG2sWZgPuzX8c= 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=epam.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 1794222787064505.7448718100053; Mon, 9 Nov 2026 03:13:07 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1479829.1683728 (Exim 4.92) (envelope-from ) id 1xQNIx-0003t5-Uk; Mon, 09 Nov 2026 11:12:51 +0000 Received: by outflank-mailman (output) from mailman id 1479829.1683728; Mon, 09 Nov 2026 11:12:51 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xQNIx-0003sj-Ox; Mon, 09 Nov 2026 11:12:51 +0000 Received: by outflank-mailman (input) for mailman id 1479829; Mon, 09 Nov 2026 11:12:50 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xQNIw-0003pw-0v for xen-devel@lists.xenproject.org; Mon, 09 Nov 2026 11:12:50 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xQNIv-003aoG-Dn for xen-devel@lists.xenproject.org; Mon, 09 Nov 2026 12:12:49 +0100 Received: from [10.42.69.7] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6af1aaa3-e002-0a2a0a5209dd-0a2a4507d888-26 for ; Mon, 09 Nov 2026 12:12:49 +0100 Received: from [52.101.83.89] (helo=GVXPR05CU001.outbound.protection.outlook.com) by tlsNG-ef75cf.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6af1aab0-b4ea-0a2a45070019-34655359e23e-4 for ; Mon, 09 Nov 2026 12:12:49 +0100 Received: from AS2PR03MB9076.eurprd03.prod.outlook.com (2603:10a6:20b:5fb::5) by BESPR03MB911570.eurprd03.prod.outlook.com (2603:10a6:b10:147::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.592.12; Mon, 9 Nov 2026 11:12:47 +0000 Received: from AS2PR03MB9076.eurprd03.prod.outlook.com ([fe80::bfe6:8f84:2f09:349c]) by AS2PR03MB9076.eurprd03.prod.outlook.com ([fe80::bfe6:8f84:2f09:349c%3]) with mapi id 15.21.0592.010; Mon, 9 Nov 2026 11:12:47 +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" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=epam.com header.i="@epam.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:x-ms-exchange-senderadcheck" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=p4F96I7HoE3qiYwvjhqs1CtNkn5bNwMg43C0oK1lTPlYZzxXWfBy9BwkD3m+FYAOK0kaZGGobbz2rPC/SuyAnA5AaEiHE+6FraUrhIlGSYAgCiOU5ahCTL+UEOXRkixRd3Pq6UC3GiSm77rPWqENVqd8kJttlvN2eDV/cmExIqQMccDe8GQmYVvSclLt8VVPwSgYebCZfpfCFrfqrvXgfIDYptWIE/qqAQGP07Jydv/4FxJgWFmxh0LqzhoPvr359Zhge888oTEoVqLV8z6/HqesT4pVAolCQeuD+TSra7nnUo83diOorsHuHUdVOgg8Vhu9vbP+h7IFGWeXjq3xiA== 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=hPWsttjC1WUZeRXqCO/27twOSP1g+3ez+TabzjY7rwc=; b=b9s59zF7xGDrJMjACz8wzPQPcygY9kpPs9mhdYR58dEO5KFmIgeBK2Nda5e7/MvvKULeiYq1+E0a2P47H0rCFJ1yi9o4aE2WNLklb1+DYcxPCbRAd54+EeX+BWV8anLnRHxw5w6vSawuvp5R7U7KilmJ2PmMCoWuZP7chL/jpxf6DQ7qxkHvKAu05zzHGfV0ccPU7y+w/x4lcNGut3OTQ27Qdujk6g3f5emN9TEjqlvrewBXUxLkXbLoz2fTZyl/+LuubfDx1haY4jpOjMPWVW8KukfPRV0oabFH6HX+K/FWgQ2gJj9cFWU7IRyHa8UwnULaENI3k3igkbdfihhHxQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=epam.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hPWsttjC1WUZeRXqCO/27twOSP1g+3ez+TabzjY7rwc=; b=D8+amlDKgLOiuAgatNEWXCt9FYI7v89aHTYw+e34bmmafJxI9dvR3Ko1qKtlIB3XCfa0UfNYtz4t5Td3KZybISTRazDSTc5eZO5lijczkffwgFJvD4gJ26eoMiZr3WI5AFTJFYar5TvQPojvmvrWx3iph6FCb1mi4rTUCYIR2BhUF1hmLK0ui5Z4kFv/mUfZ3fpvTEVdO6hvD5gjGGyqyPlEp1En4Bs/6/A8eqlDhI7ejfu+X0XGq6B3UJz0vKoQHjCV/uUkf2IIDByoaMjfJUlLz3IaR/ZN61h9Efd1blGdtz3nME88GA3wuAdxegRYavG6lQO5MgboBDqjHyfAvg== From: Mykyta Poturai To: "xen-devel@lists.xenproject.org" CC: Mykyta Poturai , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk Subject: [PATCH v11 1/6] arm/irq: Keep track of irq affinities Thread-Topic: [PATCH v11 1/6] arm/irq: Keep track of irq affinities Thread-Index: AQHdcDtAju59FhkFYkKpO0VICO+n8g== Date: Mon, 9 Nov 2026 11:12:47 +0000 Message-ID: <238164f06cb65244b1f55f9c9bd2347b62c07439.1794222015.git.mykyta_poturai@epam.com> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: AS2PR03MB9076:EE_|BESPR03MB911570:EE_ x-ms-office365-filtering-correlation-id: 6e6e427a-4d63-4794-042b-08df3e5262e2 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0;ARA:13230040|1800799024|366016|23010399003|376014|22082099003|18002099003|10067099003|38070700021|11063799006|261028144727099003|261102123227099003|261022105027099003|261022075727099003|261021123027099003|56012099006|261021121427099003|261026140227099003|261026121527099003|261009223027099003; x-microsoft-antispam-message-info: iLK/STST+qfGhTcysm+ZQ8hN8Fe6gQQbxbo/fBwgUlGCrBc9p5YLNqGGFJh0fa+iEhi3NVfrZWpTXYH95DmdM4FdiU+VtA/8qpHxC+nvoxJgfzc3Sl71iahcM41Nde1cuXzs/foY0r0nA1iKQ9/VHzgZkKOcppkXWcRqjkrUFuWyuZyItS+WdEciz2TgH5/CpOC1obtbU76bx8IHzwXhHwuNK1RNESyPN96PuxZG8hcX7EOCJieQiAGc4w2GihULRJN2jav6yEenJSXQX1ANrCC5wIeCf0QbPgVixDYTGTlRGPEdUcj3kmHoKUT9hfOOv2iJZK+kQcLtEWj5CGU1MZtx2pdrq7/QNzlRM47p86NshY2vU/L0+qA+K5gJP8D7ldgKtO7hqLpa1xd3eaUwLrkZlot7kA9B9v3ZYkiy/x7WrJdypetoNgwiYlFNvOBYbhY3lnnCP82wd0JjnHrha3OkxbqRnaHZQwgsD4acwF2yBHbp9s/If5irSkUIQXRySYFE9k+13T7mw5XPbgNo1ItQS61v/8JpC6ZyioILejBN3969vHLixob7XhueLA9iCde6v/u/UEhhP0j6ivbYB4lr/xJEASi8qSQUCs9mRFQxUjHatxv5TKrDAB5Luyspkpn5L9zoAvho7r+o0ibBKyvEPMmUTW1lAFFm/dCg+W0v4Gu1QSjSg/bSPUuxU35+mkqesaNsEakiwyu6opIgv5f0cYQC5BGHq504RT44OKg= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AS2PR03MB9076.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(23010399003)(376014)(22082099003)(18002099003)(10067099003)(38070700021)(11063799006)(261028144727099003)(261102123227099003)(261022105027099003)(261022075727099003)(261021123027099003)(56012099006)(261021121427099003)(261026140227099003)(261026121527099003)(261009223027099003);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?B+V8IYePtPfO/N33RobTPstmgLqpGa4S9+J928SPYsoPT6wX13OqrjIXpj?= =?iso-8859-1?Q?6h3jFkOQ3ox9KNIFYAC5Q6/iAabPZLzjcW7vPyBPeW0SnGLwvdIoRAFD6r?= =?iso-8859-1?Q?/omhMG3azWm3py/XE3Uhib0gRqS0AhLJQegtRCrtUR3v95tKeewKOi7lOI?= =?iso-8859-1?Q?1CNzmwyJi+fG9I+2Wrio9y7cvVMcp1jpyMdwqXZXtRBZb0mJuSWitgmt45?= =?iso-8859-1?Q?lqks1wTpzT3VlVa4/5AkXMip/cpYsS+JGqaCqbZMov0z03D8Z3Fb0KJYmp?= =?iso-8859-1?Q?ZknDsaQ5t0BqjW/nLaflNAwARpDreHSPjAwHIJcjqsSrsO074BE3GiYLfZ?= =?iso-8859-1?Q?mOUbuYOxrTkFs7ltrpIoq6Lv/9f2kafGTXbo9UiPQXOtvBJmSkGW7xoukC?= =?iso-8859-1?Q?p7T9NnAJ7Y2jc6vRs1hpCSrdR5YB61pngvZFJNxEet9u/VsfGDAt6/bRgB?= =?iso-8859-1?Q?r+OBpy6D7LXwaw4Agj7ep13k+ENm0Ue7gCrpncSOvHxrGeK5wV8gy0mCUL?= =?iso-8859-1?Q?1eLtUX+oy6AgqEVGtAzzlI1Pn/U+7nXXf0QOo7X9FTw7utE880pxOQ5zxm?= =?iso-8859-1?Q?/4vRntiQvjAyg2WjVcgSEF5ezO2Grcc0COFLqFL5qIGl6Aw5cW2vSmSc17?= =?iso-8859-1?Q?7lB7GaqTIlRCuNwny05Sme9RT+g7nYp0OiNU6MBcS/mvEV9SBc+5CtL6sx?= =?iso-8859-1?Q?WGMlGaxCA1Kh+gwYuvnWANSoqkvf0uOZUgipStJavOnvhqDwMkNc4+FH8j?= =?iso-8859-1?Q?S/etjCU7KdMsMMS4NSJKxiOp+2X2FKed3kQZcb6nhZ8SwuOjaSTQX+OHYy?= =?iso-8859-1?Q?xLwRGrWuHtUmV6+oA98c3/hK53fy3x6QXxlGhBs2fH7dmFKNrD7Y07YdxE?= =?iso-8859-1?Q?iIFmZE/3pMLUM/Va749N+obSmzxdOVSMoi5KpGX9QwLyc0hcyG3CMwy2JH?= =?iso-8859-1?Q?dWOD5yY61RRiqR9p8aUXCaQtmhy47isvTYUv/PKinS5diVQu17+MrEJBni?= =?iso-8859-1?Q?0s4vR7320XnZWjVdYweglgjRxPLPww5PCaSJe/QeUGn7o8BhP0A/QnQYnG?= =?iso-8859-1?Q?XOyc4jj2bnOIxGiOsHdVOsv/f1umjIbC4/JGpvnDWBqzVakNmgUVuc3S2y?= =?iso-8859-1?Q?jVj3x7w53qaBbT2RVTzI+qd8MR2OV3FTALTOW0Rhmcui54bqOsL1rZ7B4a?= =?iso-8859-1?Q?JbOs+0gbHpnZDdYQjLd1nvyaxxmnRPelaORfHNWU02dPOP4VwYAu2sp00d?= =?iso-8859-1?Q?eeJaysSPGG4RAXxy2IElYFyP+vwMXb9wGLOY3MAxikOPPR4KX+yigMxfIb?= =?iso-8859-1?Q?NHUULY5BZ9vl7aTvU92dmVih+gCY4CJp4PFJmh9BXi0LPBoJjPwbtSWgrL?= =?iso-8859-1?Q?yjxZZng+zO7G29vT6ndUJ0YoNH8ZJq3w/ZEvtqHn2h8aJ02649VBOelNL7?= =?iso-8859-1?Q?MjzLxwS2DgLvsnf9G1MwQBLNhq7KpKJeLX3wy4MvOJ3YtVkOo4rCM8GAeR?= =?iso-8859-1?Q?HpXZiZR5K0LbCX5tye5Rl6UphiW94ssgHU5aAGyVLixR9TFsXtDFh11leM?= =?iso-8859-1?Q?f8wqUWakbDrbmz5A/2lpGfwbkfpuNANWdWFgvvtJXV7I9ciaF5EbbDDgoG?= =?iso-8859-1?Q?O9t63qNe6i9cI4NNtVRBn3svdn3JnuTHpiqKsKFOy+FsO+7MafO0tqgmU1?= =?iso-8859-1?Q?qqUSJ2XwamvT5mq4l63Wf2e6o+yM+SgqGq6hzltJGlVDRJfKbzg9xfpfXP?= =?iso-8859-1?Q?64K92qs2I5qMPq3faeZ6HnqBR+b3m1QnOF48iD065pGfAPwForS6nUyHD2?= =?iso-8859-1?Q?ybYnt74iOg=3D=3D?= Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: epam.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: AS2PR03MB9076.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6e6e427a-4d63-4794-042b-08df3e5262e2 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Nov 2026 11:12:47.5259 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b41b72d0-4e9f-4c26-8a69-f949f367c91d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 7ITjinC2m/UdQUN4AwcAqLK9XvlU9pu+wCVKP20okQFsj4w3Vr1KwL6cAVzENr7PI3Y+9zrU2ri3LP+/TVb3sA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BESPR03MB911570 X-purgate-ID: tlsNG-ef75cf/1794222769-368D9AE4-E68D35B3/0/0 X-purgate-type: clean X-purgate-size: 7590 X-ZohoMail-DKIM: pass (identity @epam.com) X-ZM-MESSAGEID: 1794222789021158500 Content-Type: text/plain; charset="utf-8" Currently on Arm the desc->affinity mask of an irq is never updated, which makes it hard to know the actual affinity of an interrupt. Fix this by updating the field in irq_set_affinity. Changing desc->affinity requires desc->lock to be held, so add an assertion to ensure that callers of irq_set_affinity are doing so correctly. With desc->lock now being required for irq_set_affinity, add locking around calls to it where it was missing. Signed-off-by: Mykyta Poturai Reviewed-by: Bertrand Marquis --- v10->v11: * no changes v9->v10: * no changes v8->v9: * no changes v7->v8: * no changes v6->v7: * update commit message * fix possible locking on null desc * collect RBs v5->v6: * add missing locking around irq_set_affinity calls v4->v5: * add locking v3->v4: * patch introduced --- xen/arch/arm/gic-vgic.c | 2 ++ xen/arch/arm/irq.c | 9 +++++++-- xen/arch/arm/vgic.c | 14 ++++++++++++-- xen/arch/arm/vgic/vgic-mmio-v2.c | 11 +++++------ xen/arch/arm/vgic/vgic.c | 21 +++++++++++++-------- 5 files changed, 39 insertions(+), 18 deletions(-) diff --git a/xen/arch/arm/gic-vgic.c b/xen/arch/arm/gic-vgic.c index fae80e6cd2..28ad4903b4 100644 --- a/xen/arch/arm/gic-vgic.c +++ b/xen/arch/arm/gic-vgic.c @@ -232,7 +232,9 @@ static void gic_update_one_lr(struct vcpu *v, int i) if ( test_bit(GIC_IRQ_GUEST_MIGRATING, &p->status) ) { struct vcpu *v_target =3D vgic_get_target_vcpu(v, irq); + spin_lock(&p->desc->lock); irq_set_affinity(p->desc, cpumask_of(v_target->processor)); + spin_unlock(&p->desc->lock); clear_bit(GIC_IRQ_GUEST_MIGRATING, &p->status); } } diff --git a/xen/arch/arm/irq.c b/xen/arch/arm/irq.c index 8d3517e761..594aaedd22 100644 --- a/xen/arch/arm/irq.c +++ b/xen/arch/arm/irq.c @@ -224,10 +224,15 @@ static inline struct domain *irq_get_domain(struct ir= q_desc *desc) return irq_get_guest_info(desc)->d; } =20 +/* Must be called with desc->lock held */ void irq_set_affinity(struct irq_desc *desc, const cpumask_t *mask) { - if ( desc !=3D NULL ) - desc->handler->set_affinity(desc, mask); + if ( desc =3D=3D NULL ) + return; + + ASSERT(spin_is_locked(&desc->lock)); + cpumask_copy(desc->affinity, mask); + desc->handler->set_affinity(desc, mask); } =20 int request_irq(unsigned int irq, unsigned int irqflags, diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c index acded6a40f..53f36780d1 100644 --- a/xen/arch/arm/vgic.c +++ b/xen/arch/arm/vgic.c @@ -490,7 +490,9 @@ bool vgic_migrate_irq(struct vcpu *old, struct vcpu *ne= w, unsigned int irq) =20 if ( list_empty(&p->inflight) ) { + spin_lock(&p->desc->lock); irq_set_affinity(p->desc, cpumask_of(new->processor)); + spin_unlock(&p->desc->lock); spin_unlock_irqrestore(&old->arch.vgic.lock, flags); return true; } @@ -498,7 +500,9 @@ bool vgic_migrate_irq(struct vcpu *old, struct vcpu *ne= w, unsigned int irq) if ( !list_empty(&p->lr_queue) ) { vgic_remove_irq_from_queues(old, p); + spin_lock(&p->desc->lock); irq_set_affinity(p->desc, cpumask_of(new->processor)); + spin_unlock(&p->desc->lock); spin_unlock_irqrestore(&old->arch.vgic.lock, flags); vgic_inject_irq(new->domain, new, irq, true); return true; @@ -518,6 +522,7 @@ void arch_move_irqs(struct vcpu *v) struct domain *d =3D v->domain; struct pending_irq *p; struct vcpu *v_target; + unsigned long flags; int i; =20 /* @@ -539,7 +544,13 @@ void arch_move_irqs(struct vcpu *v) p =3D irq_to_pending(v_target, virq); =20 if ( v_target =3D=3D v && !test_bit(GIC_IRQ_GUEST_MIGRATING, &p->s= tatus) ) + { + if ( !p->desc ) + continue; + spin_lock_irqsave(&p->desc->lock, flags); irq_set_affinity(p->desc, cpu_mask); + spin_unlock_irqrestore(&p->desc->lock, flags); + } } } =20 @@ -619,8 +630,8 @@ void vgic_enable_irqs(struct vcpu *v, uint32_t r, unsig= ned int n) spin_unlock_irqrestore(&v_target->arch.vgic.lock, flags); if ( p->desc !=3D NULL ) { - irq_set_affinity(p->desc, cpumask_of(v_target->processor)); spin_lock_irqsave(&p->desc->lock, flags); + irq_set_affinity(p->desc, cpumask_of(v_target->processor)); /* * The irq cannot be a PPI, we only support delivery of SPIs * to guests. @@ -975,4 +986,3 @@ void vgic_check_inflight_irqs_pending(struct vcpu *v, u= nsigned int rank, uint32_ * indent-tabs-mode: nil * End: */ - diff --git a/xen/arch/arm/vgic/vgic-mmio-v2.c b/xen/arch/arm/vgic/vgic-mmio= -v2.c index b7c2d7ce99..fc04741ca1 100644 --- a/xen/arch/arm/vgic/vgic-mmio-v2.c +++ b/xen/arch/arm/vgic/vgic-mmio-v2.c @@ -159,24 +159,23 @@ static void vgic_mmio_write_target(struct vcpu *vcpu, for ( i =3D 0; i < len; i++ ) { struct vgic_irq *irq =3D vgic_get_irq(vcpu->domain, NULL, intid + = i); + struct irq_desc *desc =3D irq_to_desc(irq->hwintid); =20 - spin_lock_irqsave(&irq->irq_lock, flags); + spin_lock_irqsave(&desc->lock, flags); + spin_lock(&irq->irq_lock); =20 irq->targets =3D (val >> (i * 8)) & cpu_mask; if ( irq->targets ) { irq->target_vcpu =3D vcpu->domain->vcpu[ffs(irq->targets) - 1]; if ( irq->hw ) - { - struct irq_desc *desc =3D irq_to_desc(irq->hwintid); - irq_set_affinity(desc, cpumask_of(irq->target_vcpu->proces= sor)); - } } else irq->target_vcpu =3D NULL; =20 - spin_unlock_irqrestore(&irq->irq_lock, flags); + spin_unlock(&irq->irq_lock); + spin_unlock_irqrestore(&desc->lock, flags); vgic_put_irq(vcpu->domain, irq); } } diff --git a/xen/arch/arm/vgic/vgic.c b/xen/arch/arm/vgic/vgic.c index 84212bbefe..663fa16995 100644 --- a/xen/arch/arm/vgic/vgic.c +++ b/xen/arch/arm/vgic/vgic.c @@ -815,22 +815,27 @@ void arch_move_irqs(struct vcpu *v) { struct vgic_irq *irq =3D vgic_get_irq(d, NULL, i + VGIC_NR_PRIVATE= _IRQS); unsigned long flags; + irq_desc_t *desc; =20 if ( !irq ) continue; =20 - spin_lock_irqsave(&irq->irq_lock, flags); - - /* Only hardware mapped vIRQs that are targeting this vCPU. */ - if ( irq->hw && irq->target_vcpu =3D=3D v) + if ( !irq->hw ) { - irq_desc_t *desc =3D irq_to_desc(irq->hwintid); + vgic_put_irq(d, irq); + continue; + } =20 + desc =3D irq_to_desc(irq->hwintid); + spin_lock_irqsave(&desc->lock, flags); + spin_lock(&irq->irq_lock); + + /* Only hardware mapped vIRQs that are targeting this vCPU. */ + if ( irq->target_vcpu =3D=3D v ) irq_set_affinity(desc, cpumask_of(v->processor)); - } =20 - spin_unlock_irqrestore(&irq->irq_lock, flags); - vgic_put_irq(d, irq); + spin_unlock(&irq->irq_lock); + spin_unlock_irqrestore(&desc->lock, flags); } } =20 --=20 2.56.0 From nobody Mon Nov 23 22:28:34 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; arc=pass (i=1 dmarc=pass fromdomain=epam.com); dmarc=pass(p=quarantine dis=none) header.from=epam.com ARC-Seal: i=2; a=rsa-sha256; t=1794222789; cv=pass; d=zohomail.com; s=zohoarc; b=N0Fe6CSWLHnflqQ25tTgNmdG2EV06+LadqjDd8rUrPOZEA6U8boBbR2tTjfIH3dNoZV1joe97ZdrY5Q7DpoY5uKWTY0V59cxJK0ewVqkt9OI1zAsvo8Flt7Gb0US1tmphXckDZU2XhammDpSWIeWCzdyOOs4OPHye91xKGOOV2c= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794222789; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=pAgG82P6VpyxfFPWD1mBEHXFFH7gOBndQxAXp8hw3A8=; b=YjwksgzpoKcbOj7cGn2lnWWtC9uVmdhFStRSLX8Iy+n86MgJrctj6vLtywtvbAm/c2lvY8+1tOzwWsNK+uGkl6j6EO5Lene6udCmmV+ylxYZzMKOQlR/MUSegvit/nwhk61JNPzl/taateyL6tzyz3An/kXQMgRF5LMcexc7l5k= 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=epam.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 1794222789053921.3233335567725; Mon, 9 Nov 2026 03:13:09 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1479830.1683731 (Exim 4.92) (envelope-from ) id 1xQNIy-0003wp-5H; Mon, 09 Nov 2026 11:12:52 +0000 Received: by outflank-mailman (output) from mailman id 1479830.1683731; Mon, 09 Nov 2026 11:12:52 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xQNIx-0003vc-VF; Mon, 09 Nov 2026 11:12:51 +0000 Received: by outflank-mailman (input) for mailman id 1479830; Mon, 09 Nov 2026 11:12:50 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xQNIw-0003q3-Bk for xen-devel@lists.xenproject.org; Mon, 09 Nov 2026 11:12:50 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xQNIv-003aoG-OM for xen-devel@lists.xenproject.org; Mon, 09 Nov 2026 12:12:49 +0100 Received: from [10.42.69.7] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6af1aaa3-e002-0a2a0a5209dd-0a2a4507d888-28 for ; Mon, 09 Nov 2026 12:12:49 +0100 Received: from [52.101.83.89] (helo=GVXPR05CU001.outbound.protection.outlook.com) by tlsNG-ef75cf.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6af1aab0-b4ea-0a2a45070019-34655359e23e-5 for ; Mon, 09 Nov 2026 12:12:49 +0100 Received: from AS2PR03MB9076.eurprd03.prod.outlook.com (2603:10a6:20b:5fb::5) by BESPR03MB911570.eurprd03.prod.outlook.com (2603:10a6:b10:147::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.592.12; Mon, 9 Nov 2026 11:12:48 +0000 Received: from AS2PR03MB9076.eurprd03.prod.outlook.com ([fe80::bfe6:8f84:2f09:349c]) by AS2PR03MB9076.eurprd03.prod.outlook.com ([fe80::bfe6:8f84:2f09:349c%3]) with mapi id 15.21.0592.010; Mon, 9 Nov 2026 11:12:48 +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" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=epam.com header.i="@epam.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:x-ms-exchange-senderadcheck" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZG9agdtrGxAl5R+R1FGCbKbsoI3+XvDKh4uliVAG1Pv9cBFqFeODKJp6ya0KXoDcMMRqAsTOnAJse8l+/PAroXBk9xzEbDIykLDUweZf8cwYO4qoKvgfvBZbLX3un01rtQXqxBU9d4itME3H9eeK3NuIFQfckLKeCPG7lbUoBHvCEu2lu0p8GUjiVdn2Ufagf+kP1+BJXuPfxxnPCOqtrWlFR9tPdFs0zilqW8ntZ/nB0+6oV/zKnwzXpgqIZOH0QfF+BHFncU/6795CmQYKh6M4yCvvs1ICLS7InL96G6+yRRsnmRHYMJGUiWQ+3MEBsmPzHxd3XqgVEzv9ASJb4g== 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=pAgG82P6VpyxfFPWD1mBEHXFFH7gOBndQxAXp8hw3A8=; b=Iq3xp8tHSjA5PD5tsHm0Slbwx456QxYootPjTCvZgETqgnuQSgKw679maMglK88vnhESncFpOATgk4QpK0tN7bTyy3LW04tOBVQfZQPfRxHVuCrmRTVVdGLVs+YTbv0Ge036wDozuYpuWFOD8AhtjHEforMHnPGUEKwpFptbgn8qDHKdkqT2IPMCsCfCRmUE1XTk8KGVDiqa3tTJC9eoEK5/ouv6chg7mRwbeAH9MdhnbVtLNO/DepQbkzdHB4/FJhIQzi5MXcmP6ztPc/ut//c7yFXqAfxRnyydR5rAIb4iTXNEZq0QWb+S6iLMtL271JU9C3T9hbvsvE3AoNaQ4A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=epam.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pAgG82P6VpyxfFPWD1mBEHXFFH7gOBndQxAXp8hw3A8=; b=PAoeKhx72clfmSsT+e5Kh0wJLKhU53QvTWXC2iIHR3pP9opr48/vcnT4ycmuZ+QCVC1s6oS26nC2RQ1kkQ8I/RJtcqGTQiUAIH5YajDw6TLK9lgNJxRe1uBbgPKUNYs/WcFp5kzkKyO6BRxOIRKuiX4L+N5bVsSguZZ8+VIlXpB1eEG5EoxXvEsvSPBqmUyji1+87wcH89SZZfcg1p1Ig4YrOq9vAN+yFww7FhWDUrDob9j+5d/BK5/sW7xWbF0U+ya4wV7NV7btinmxrmyBWIVLTNs5RR9TtW8WJ8UcqCgdu6KK/rhtlB+4DPSE5iOsSBWhWejBpsgooJmyZQYf7w== From: Mykyta Poturai To: "xen-devel@lists.xenproject.org" CC: Mykyta Poturai , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , Volodymyr Babchuk Subject: [PATCH v11 2/6] arm/irq: Migrate IRQs during CPU up/down operations Thread-Topic: [PATCH v11 2/6] arm/irq: Migrate IRQs during CPU up/down operations Thread-Index: AQHdcDtABYwI/ppPt0GzgWxLLvu3XQ== Date: Mon, 9 Nov 2026 11:12:48 +0000 Message-ID: <2a7fa3ba892364b755049763d64646d146c692c8.1794222015.git.mykyta_poturai@epam.com> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: AS2PR03MB9076:EE_|BESPR03MB911570:EE_ x-ms-office365-filtering-correlation-id: 0cdd4148-6697-4ddd-4b70-08df3e52633c x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0;ARA:13230040|1800799024|366016|23010399003|376014|22082099003|18002099003|10067099003|38070700021|11063799006|261028144727099003|261102123227099003|261022105027099003|261022075727099003|56012099006|261021121427099003|261026140227099003|261026121527099003|261009223027099003; x-microsoft-antispam-message-info: M/ioYeLeWH2NWgaZn8RY4fullVKpjLRF+OvdBCP9CIqf5G3RokMzIKaG1KVWqFi+6TNubL0Wuc0JKZzs8mvexAFoOP0llmieO0jPwtT+XdABJJKpxfNGSY54F8L8bkbpcKSE2x34JdrybnxH8s3q15iTTQv14prR62qom+6aPm7ycMqrgZUcDaSiEmwoD0dgYyovwM0YZMZ98QJx1DKwtEGBq/JRFEuRyF65i5ucHakus7Qad5PKVlDp96P4Gaxsl6wPUzhDhMEKP24BuG9v554pdKpUSVuDga906LLv89fbUflkZAjeJEB3eV8TwwfDGW/B4OlgReSNdLit2bKqKWcjVX690LRF77nbduT1mICqd24XU73naZ1VBJVnGjrRr7BMdevLeM5vOqhFR4dzD8kbfsmKRmxyGA4aoYawEcswhdOHIoGdQwyQhzuMG8GahcDTLzmzs5C3N3w0ynq0Avj32LullZUhjFTgLq9jhFfDjohJ60v2dV/UEPejMrxZzJkvwbYdK/H8eCYY16Sks9rogsA7i/2cqwWZLakVlHL9e3msT0g9NTtdUAThjS5pykkyE6izpPMOJ02Qi9kwH677kcbdl/w2WsHag/uiCjkFl9MKurgOQJbKxjys0j/AOwU4DLLcWSZltrUoRw/oe5UeDqiP5ICERMxv7Eh55bUQw8MZXe6TVHp53TYG726xpyS21XXGEz3rj6rUovR5yBIoPBDqEoxM8xnst2CJOwQ= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AS2PR03MB9076.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(23010399003)(376014)(22082099003)(18002099003)(10067099003)(38070700021)(11063799006)(261028144727099003)(261102123227099003)(261022105027099003)(261022075727099003)(56012099006)(261021121427099003)(261026140227099003)(261026121527099003)(261009223027099003);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?piohtuZ0NOeEsnfNLqoOgydSR2s9ovh8wop3LFjiMX18I5j+u1tz/P/BQH?= =?iso-8859-1?Q?zFZQ1BRet/aHMw1xhH+7QLb0frAXgv5+eOVEf19+2bplyzWd/Yr8kmvZup?= =?iso-8859-1?Q?YsbQ8Zofyi8KL1cT9o0tjlrI+jKtkyJqQMNnNiXgHmaX6ZuNAUxwnhN8ai?= =?iso-8859-1?Q?tR0iyBc0k4sNckiNCWVAOaV5z/8I7TejGovcIb4St4y/1ZOvdz4V6kqNgd?= =?iso-8859-1?Q?QWXl/bwHpQ0KgKDoC5oXGD7OP3imuMyfXL+YAwl8BBmVusnbGS6638EQ50?= =?iso-8859-1?Q?h0IoJvfGymZ90xkdfTfwXO51OGMw6POY1MNOPZ55W7vsPXb3V2utUMjaWW?= =?iso-8859-1?Q?fB3jG7Yc2IJLKnLhWTb4mfYRnzNR918APAI/KksWq2oLtJp2XR91a0DRsu?= =?iso-8859-1?Q?lwsG9Jsdi/9JnGdevGz6MxP+P66sMZtb3E1mEfHHoA+62bA5hYNTeXk6B2?= =?iso-8859-1?Q?4Fb7qaAZeTJDPbMpCzK6emcm5cIrT6o8b3YR5onRprC/s03Bt1xvRGAL3c?= =?iso-8859-1?Q?q1a55vkPwtXB4f6+6PFqNWBXYUd3dl2ahji02nqK5Oi5ZykDhdhpwd70/3?= =?iso-8859-1?Q?xZjhVc3Qwx1CPhyZq7gdfmVscCukaHbODHpGgjMoq51AVIIUzyaWO2FSXW?= =?iso-8859-1?Q?ZdQabop2cihwqZpsDi/NG9mynNPIjqddQdCSu7zj8C+ZaeQc0BwDYSKps2?= =?iso-8859-1?Q?0fpO2ih+gc3yy/b/uR/pIL71XfvHFO07tm3xcxP13hXLj0SVDsBZ4mloGI?= =?iso-8859-1?Q?3yfLuz/5Ik1POrEAtvsPGQWgAahfnj90tSm5v26Q4CMvrWKKWVMWntXnnn?= =?iso-8859-1?Q?GgiNedZDhc1WJnB4WeFWgtmYq2DVoO57kV0tMrv2e7NZox3HbvPsKjQOFj?= =?iso-8859-1?Q?ypY8140Ysh6bY9WNaHhRLlpEwMcSMZkwo7JxI0/kuiSYXbNM5DV7ktmNsV?= =?iso-8859-1?Q?hnLLW5aZm2e8xI2XT4WGrzNlA/3YcHL+Bh+BMTj/6jQnaxRLgo6XYH+aXw?= =?iso-8859-1?Q?w6x6zqX2tHmKIqTdSrnuYBK1NY1ZhD12JPiASMvZt+gfaeiT7KoON9WEWt?= =?iso-8859-1?Q?J0x/nGsMjgo3yI4aYGn9xzeU/wPuMo1YkTfy3d8m8eOyTwIf06ctMp/gmx?= =?iso-8859-1?Q?sLoVmnUal5WJlCznPCr5A8Bwsn279b0R/6AF9UY1vDu65DGEilmg467tr9?= =?iso-8859-1?Q?MEB+IpiMDC9zp73f84qIyPVX3f2rukTXZFq/p7eGozx+hCClPQubMZxdZS?= =?iso-8859-1?Q?+6DPhP+z3lJkH5qhAISeckNkgYm+6urWwuMaaFK+EE3UXChwGZKSL66i90?= =?iso-8859-1?Q?2P+Flso0VTenfimFsfXuAUH3m9yKZe2FYk8MZIRiOXna0KfrcL18N2ZjA5?= =?iso-8859-1?Q?p+2GiOEFfWD+eqKDGWkZTWYLaEx0YX1wsGvARM++zK6WFiDReWAN+GrpW0?= =?iso-8859-1?Q?HEj9w9SDo/XqHerGPaWYycZxpv9K2ZrPG+1/4DRC5NPw5p//oCckt8CGt+?= =?iso-8859-1?Q?Sz6o9BdwqLSaJmlEbtRUvvxIDsHNZdT7rCfonac9hAQcAqm8bYYGPdpGFh?= =?iso-8859-1?Q?l2zfVvxUu5z/AiZqrm3uoISCUC4C3spqT36uEtMXL3Oaai2IjToN0erE/r?= =?iso-8859-1?Q?4zg5T5H8LCUKlG+2UtOjtecmnqGyYqeDzvjOmkATWjZNEpzoGW57vfqLwE?= =?iso-8859-1?Q?AXtzzO61Al6Vnjje/B2K+5wvDiMg56ek+YwDAtJNvSn4FPCbElj5Xk+5sr?= =?iso-8859-1?Q?WPOzCAQ8+oVXF7MR+TETHZ+7zY+CEPMS9MPbzdJs3MEsLoMOT84tGQXRN0?= =?iso-8859-1?Q?o59ilOjLYw=3D=3D?= Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: epam.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: AS2PR03MB9076.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0cdd4148-6697-4ddd-4b70-08df3e52633c X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Nov 2026 11:12:48.2055 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b41b72d0-4e9f-4c26-8a69-f949f367c91d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: wjKMvgJfrkhx6gusWDnv8S1sh5IQ3tdh0PSPrrEmKSM2w6iGlf291tkx0+64gW8f044dwzK1Ixb/qQMmDPJFFQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BESPR03MB911570 X-purgate-ID: tlsNG-ef75cf/1794222769-A76D2AE4-63C14133/0/0 X-purgate-type: clean X-purgate-size: 3953 X-ZohoMail-DKIM: pass (identity @epam.com) X-ZM-MESSAGEID: 1794222791028158500 Content-Type: text/plain; charset="utf-8" Move IRQs from dying CPU to the online ones when a CPU is getting offlined. When onlining, rebalance all IRQs in a round-robin fashion. Guest-bound IRQs are already handled by scheduler in the process of moving vCPUs to active pCPUs, so we only need to handle IRQs used by Xen itself. Signed-off-by: Mykyta Poturai Reviewed-by: Volodymyr Babchuk --- v10->v11: * collect RB v9->v10: * make cpu_next static to balance_irq * move the offline path to the CPU_DEAD notifier * make rebalance_irqs static v8->v9: * replace CONFIG_CPU_HOTPLUG with CONFIG_CPU_ONLINE_OFFLINE v7->v8: * check only existings ESPIs v6->v7: * replace ifdef with IS_ENABLED v5->v6: * don't do any balancing on boot * only do balancing when cpu hotplug is enabled v4->v5: * handle CPU onlining as well * more comments * fix crash when ESPI is disabled * don't assume CPU 0 is a boot CPU * use insigned int for irq number * remove assumption that all irqs a bound to CPU 0 by default from the commit message v3->v4: * patch introduced --- xen/arch/arm/irq.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/xen/arch/arm/irq.c b/xen/arch/arm/irq.c index 594aaedd22..d5145a4723 100644 --- a/xen/arch/arm/irq.c +++ b/xen/arch/arm/irq.c @@ -166,6 +166,58 @@ static int init_local_irq_data(unsigned int cpu) return 0; } =20 +static void balance_irq(int irq, unsigned int from, bool up) +{ + static int cpu_next; + struct irq_desc *desc =3D irq_to_desc(irq); + unsigned long flags; + + ASSERT(!cpumask_empty(&cpu_online_map)); + + spin_lock_irqsave(&desc->lock, flags); + if ( likely(!desc->action) ) + goto out; + + if ( likely(test_bit(_IRQ_GUEST, &desc->status) || + test_bit(_IRQ_MOVE_PENDING, &desc->status)) ) + goto out; + + /* + * Setting affinity to a mask of multiple CPUs causes the GIC drivers = to + * select one CPU from that mask. If the dying CPU was included in the= IRQ's + * affinity mask, we cannot determine exactly which CPU the interrupt = is + * currently routed to, as GIC drivers lack a concrete get_affinity AP= I. So + * to be safe we must reroute it to a new, definitely online, CPU. In = the + * case of CPU going down, we move only the interrupt that could resid= e on + * it. Otherwise, we rearrange all interrupts in a round-robin fashion. + */ + if ( !up && !cpumask_test_cpu(from, desc->affinity) ) + goto out; + + cpu_next =3D cpumask_cycle(cpu_next, &cpu_online_map); + irq_set_affinity(desc, cpumask_of(cpu_next)); + +out: + spin_unlock_irqrestore(&desc->lock, flags); +} + +static void rebalance_irqs(unsigned int from, bool up) +{ + int irq; + + if ( cpumask_empty(&cpu_online_map) ) + return; + + for ( irq =3D NR_LOCAL_IRQS; irq < NR_IRQS; irq++ ) + balance_irq(irq, from, up); + +#ifdef CONFIG_GICV3_ESPI + for ( irq =3D ESPI_BASE_INTID; irq < ESPI_BASE_INTID + gic_number_espi= s(); + irq++ ) + balance_irq(irq, from, up); +#endif +} + static int cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu) { @@ -180,6 +232,15 @@ static int cpu_callback(struct notifier_block *nfb, un= signed long action, printk(XENLOG_ERR "Unable to allocate local IRQ for CPU%u\n", cpu); break; + case CPU_ONLINE: + if ( IS_ENABLED(CONFIG_CPU_ONLINE_OFFLINE) && + system_state >=3D SYS_STATE_active ) + rebalance_irqs(cpu, true); + break; + case CPU_DEAD: + if ( IS_ENABLED(CONFIG_CPU_ONLINE_OFFLINE) ) + rebalance_irqs(cpu, false); + break; } =20 return notifier_from_errno(rc); --=20 2.56.0 From nobody Mon Nov 23 22:28:34 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; arc=pass (i=1 dmarc=pass fromdomain=epam.com); dmarc=pass(p=quarantine dis=none) header.from=epam.com ARC-Seal: i=2; a=rsa-sha256; t=1794222797; cv=pass; d=zohomail.com; s=zohoarc; b=mHqpJ7PDqojGNncVD5KOWSNdJPsrPF69TxHcKL+UH7xUJmxWMpn8e+SxidD7WFoifRkP2TyA9jUAL+CDdUt/ulSJqCmC5NlWa3nA2DRTmkbvatX6Nyoj0w6JvdRt6GiTERL4HbSLRul0+1/uOL9bZZYHMIAzo14ml9iojgSHRLE= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794222797; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=j071lkv/T9MKGKKRxrfVTvQM3R2BSkqTGwzSgXyNeIw=; b=g4YRhpoN6m8N3fdKdgZrfU8cZ6leCV9kYFKW+5hKI37+Lu8TaE1MnAylzho9JZUNjJRvzg7HxFYkBIUb39qrLB1FNK0TzvHZnKb+737AkAJAM6n8inpb831Wd2PLoI45WmJW3NK9LGVagadsC8OASa0OPLLtdyPJhTj/NnqqqFw= 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=epam.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 1794222797832801.5038860535127; Mon, 9 Nov 2026 03:13:17 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1479831.1683740 (Exim 4.92) (envelope-from ) id 1xQNIy-000450-Ll; Mon, 09 Nov 2026 11:12:52 +0000 Received: by outflank-mailman (output) from mailman id 1479831.1683740; Mon, 09 Nov 2026 11:12:52 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xQNIy-00043G-E3; Mon, 09 Nov 2026 11:12:52 +0000 Received: by outflank-mailman (input) for mailman id 1479831; Mon, 09 Nov 2026 11:12:50 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1xQNIw-0003qE-MM for xen-devel@lists.xenproject.org; Mon, 09 Nov 2026 11:12:50 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xQNIw-003aoG-2r for xen-devel@lists.xenproject.org; Mon, 09 Nov 2026 12:12:50 +0100 Received: from [10.42.69.7] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6af1aaa3-e002-0a2a0a5209dd-0a2a4507d888-30 for ; Mon, 09 Nov 2026 12:12:50 +0100 Received: from [52.101.83.89] (helo=GVXPR05CU001.outbound.protection.outlook.com) by tlsNG-ef75cf.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6af1aab0-b4ea-0a2a45070019-34655359e23e-6 for ; Mon, 09 Nov 2026 12:12:49 +0100 Received: from AS2PR03MB9076.eurprd03.prod.outlook.com (2603:10a6:20b:5fb::5) by BESPR03MB911570.eurprd03.prod.outlook.com (2603:10a6:b10:147::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.592.12; Mon, 9 Nov 2026 11:12:48 +0000 Received: from AS2PR03MB9076.eurprd03.prod.outlook.com ([fe80::bfe6:8f84:2f09:349c]) by AS2PR03MB9076.eurprd03.prod.outlook.com ([fe80::bfe6:8f84:2f09:349c%3]) with mapi id 15.21.0592.010; Mon, 9 Nov 2026 11:12:48 +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" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=epam.com header.i="@epam.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:x-ms-exchange-senderadcheck" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=cump2jZ0c588s3cOZPAvc0I+v9GNG0p2VsoO6rFFL9/hJ3LgH27l4iEUttf6AtmJtaYpowu4rRHNSzwB579THp7Dnm7WYvHMzJ/0CTRG90DlWkxAfRbrQNBJsmGz4bvTcShjHbps0HycTvBb/bhxJcTm7+XcIdEWZxWdfPkymP9itqgAn9TSAUawAFu8wzaBYEGTy7WASXbLzmmtdtD8NLxI0XkwsAy6sFw8pbHqNP4RoKSA3pMecjjdGTPb8lKcHOiTk8XxPJAWkKg0OkMqMRZFYaq6BLnmD2pfN3VzHy+vdJDvu6sXOqhfbg7cnWCrkXUk9IR66pbkfsXvf18r3Q== 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=j071lkv/T9MKGKKRxrfVTvQM3R2BSkqTGwzSgXyNeIw=; b=ZQmoJmkgc9oi6/iukZCUs5WSDvTdcOFY31B1r58SyXhyoLjOgN4Rk8F0DAGXdEpwtgeBIRH3n1Gaf26XwCeOw0loPzWPvja8Lt0oA9aFCNXnY35Sz20aU2VXHw4/sLvK0jR0Nln3O7lYf+r2OergL2M9hdVxBKqCbADsnIuAWHITdRKPOoZjAhs1wfTKxfzBpgwEBYPrj+ntKOiJPWVi2HHrPtuGd0SjtjgNlE3P3r5KF+qw3vtDAgngyEjxPi5WHrb4iPaikzbx1zqfQ+1JFOmRfEVYu3Rp+TNRbrfYTY4NxTQFe6ZVwF8GMv7NPEO9cyGV66a75iCv34saXo/8gg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=epam.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=j071lkv/T9MKGKKRxrfVTvQM3R2BSkqTGwzSgXyNeIw=; b=ms4S90o+1pbfeP2o1Aq4RGb3RDV9jtJH7F3DU1/7IU0OgV1FnUICT+5Utn+j3FaB3A+IOgBvQZNWllWp/YdBFJ7kNXjTS+BlatxsRDh4h6CjARyy9Gx3UBB6FZCprg7ZFJuwq9RbSH0qcgdHKbOmOekvIfft6RerZi95b4lk3JJDyUoAe0iATP5SBN1RKm3cynLQ3tNr+mqRtcmtmqb+U6ex3Km2oaxqJTxkaYJONwuja3UTjk3Rrm4za9Vn0keFTnS4w0XncqjJS2ZIYCmUTHQtd2xvTTDFKsgpQynQMGNQ9d0rLlOR2pYhgztqB60W2/9muVDDeTSs99aYgaFHRA== From: Mykyta Poturai To: "xen-devel@lists.xenproject.org" CC: Mykyta Poturai , Jan Beulich , Andrew Cooper , =?iso-8859-1?Q?Roger_Pau_Monn=E9?= , Teddy Astie , Anthony PERARD , Michal Orzel , Julien Grall , Stefano Stabellini Subject: [PATCH v11 3/6] Kconfig: Make cpu hotplug configurable Thread-Topic: [PATCH v11 3/6] Kconfig: Make cpu hotplug configurable Thread-Index: AQHdcDtAh71ivUKJ/UmfMX2hXYn9Ww== Date: Mon, 9 Nov 2026 11:12:48 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: AS2PR03MB9076:EE_|BESPR03MB911570:EE_ x-ms-office365-filtering-correlation-id: 03da3311-469f-4fb0-2305-08df3e526376 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0;ARA:13230040|1800799024|366016|23010399003|376014|22082099003|18002099003|10063799003|10067099003|38070700021|11063799006|261028144727099003|261102123227099003|261022105027099003|261022075727099003|56012099006|261021121427099003|261026140227099003|261026121527099003|261009223027099003; x-microsoft-antispam-message-info: 3ABTxXqQCJ20Lv1Q+YQGMo/NtXiaYJLai+smYnxyyYxQDgKw3avF+EojxPFIuiMHWLlBN7wf8E/0vMJe8ncNfWVn6w0ykRkNsb01X4JyhBPEgOv0rKuMthJx2MLopFaIPuTapcd5ILBCO47vID8lE+EqRZMLi/ajmOEPkakCOR+ha5unZ4NuhSCKCpq4ww5H9qSHB4S54aqaDJgxin21Uwytm+e6VUBoOT/OL98OH6e7HeACyiXdGKfm/FFror7Kfz0vkzwlXCTpu4Grj48ShyiJPEa4Qgl6pzAPECOXvz7wZbeHZuwIkmxh3y+2IKxk2LqVOHq+YB7CZTfxZCGEdYlHc1nVTc/HplH/ul2zgjyv/oCOHhuC55mAIOuGicAPxlkVNLp8Kj5JNikg/VNkcBVc/7RD050Vzi1CIiCACORxv+b65OGTLOX45oyArJgQmi00NZDtYHtxbQXgQjVZZY96MPESH0Z9Xkj4JLuN7yDPPjNaIcMReFMDC3r/+fZkZvW3/NwKoy+2Yz4QMsST+i25SaGxs6fp8Hy7kqHZbjaY5MwLx9d3WK1Muv1r1ADmU+9gst5ezqZnClZ3up3K0FNcaWtehNKKwhMfzBhidwpZmgE3gs8NWsxKmhDzaiqZB5Bpl5EOUpIBnd1FTL+5VLm/vQI+8Z33brPWbPPBpq5v9JC/LpgCG4wm6fOnMo1MSZ4gsAgrk81BE9VVd2XtyiA0TnNeG53p74G2Hra2yN4= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AS2PR03MB9076.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(23010399003)(376014)(22082099003)(18002099003)(10063799003)(10067099003)(38070700021)(11063799006)(261028144727099003)(261102123227099003)(261022105027099003)(261022075727099003)(56012099006)(261021121427099003)(261026140227099003)(261026121527099003)(261009223027099003);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?7v4PPdJxlisFb7OFzwgcaHRcbMZ5B6iBD3aKwD8qIenADFkPp+RQYcv4zA?= =?iso-8859-1?Q?v/D6736w9aMq5VUrdr+JwE2oM/U/AUOiUUJeAeIJauqp6bFlV6AxB1F1Dx?= =?iso-8859-1?Q?6ptDahUwp7mnh44qQkhmwxvR0a2iX6H7BzmMMNq46jq56TGsLOn3PYVxOj?= =?iso-8859-1?Q?F0xWwPbCU4feqIvvhRhZr80D3dlJpU+WS/X85KjafcuRGlaq1JNAzVbab/?= =?iso-8859-1?Q?LinOsbD1GxilE7FBd+qMUnwXapaNGuTonMQ+G2Z7M67CrRIDEx2eFlUABM?= =?iso-8859-1?Q?AGYIEmgdNn1LmlNp36NkqTYKSfzcSmPiqOHw3vMBPFdjCDImn67C9AOAEJ?= =?iso-8859-1?Q?XXtF5h7ToNoxokGq03I2zsAOdk9JA0qWZxZgT43uPYR/NBjLzQi53wiEO/?= =?iso-8859-1?Q?hJdQ0NHkcVmojyvxqorYChdD2acbpHhZ2cQk0LzXHczjNBLQ1jK39qo87M?= =?iso-8859-1?Q?Kaq9Gop+8CV1di4c7LdiD6v+G6ubg10FKD2JyGgC9lnn08VH+v5mgBq9mJ?= =?iso-8859-1?Q?e+QAr424tB6Eb6Qlrn77JnxzmgU41lebWyglioTAW8FOJwl2/WQJbasko+?= =?iso-8859-1?Q?pkQILAlZ9daKskr5qTmGnIy+g/ID7vR3bUqIEVut3fSDfkAOPMLNNXyt4N?= =?iso-8859-1?Q?/Cz/L+t0kpQBB77K/sqjQ8c5tDKnmFuvpGnbXqRI+ucg0yrGEJV36s+yor?= =?iso-8859-1?Q?M4wD/ypQeb4owL6KIt62IPT+V39wzeeyYiUxcQpEeG1C2Pqw061vIUQ6Li?= =?iso-8859-1?Q?uq+AF8mFJ9qo9mOx89oiDVPtVjojCfDJ+qvl+t7ITF+6Qp3SDI9IH3ChbU?= =?iso-8859-1?Q?28Fe5mzrvidK2YjyTsn8vxTkm04OC+6x4RXIrJo7d5H3trI3tbMgIQEHPI?= =?iso-8859-1?Q?P06awC7lbJm4raQ0GH1MlK3+oIONgGc2ptQIflgCxD8FZoXm7pbh8+kOBF?= =?iso-8859-1?Q?VM5fpZHYs6DbvbHomPYnokkU8HtJe5jOrZDS7KyS42erq1pC8mlEbeUmDV?= =?iso-8859-1?Q?w+9NhZM0B/hiPwOKoqVyxj4pfM425xzZe6M7auroMo1YQFIHNvY2xMCwi/?= =?iso-8859-1?Q?WMqIWiY4YzaBfdCeFYgDGXnunWvC7kl937vjbwYf2O0s0Uek2sx0uK09hq?= =?iso-8859-1?Q?VcKlA9kq1fUCa8dTGY5lJLYgVOUj5CSqondqswmnuK0p6j9PvkfbUi0Who?= =?iso-8859-1?Q?Kir4uXRysYyz1E0bwQ/GE43smkYcA62yO4ot+PpWCw84rG4/RcBb1/yAtl?= =?iso-8859-1?Q?8+hY7TjPfkk5VzuPEshY+fpbgo2Sa6zkN7+rIvZftsZ+C99TraOBQdf4YU?= =?iso-8859-1?Q?+ljDBqNUOzFmjmczNXimi4XmTsF9kdCJj+rKmdhhZjBz97kbbkEE7TI+4d?= =?iso-8859-1?Q?ioZvGxCaKCd2srNlTfhwp3udE0qg68NIoZgrpcdavD2SUtbmNm7GKyi8zp?= =?iso-8859-1?Q?jTHbn3sc1cMWZE0kE0rCkDP/UNiiENfbGwcQ/iqBOQHkBTVMmRHr8tIVxK?= =?iso-8859-1?Q?4q0/qhf9Qg8Ba01MRbGZVgHboQcNCwx16rvN3HiVmhYi4oQ1HtpR8L35Jx?= =?iso-8859-1?Q?vTzwHyVPK8FElJF5j7PihgPZD1+9LyjCtBoUoy5bmlNztiSAKiNn6FSJF+?= =?iso-8859-1?Q?o9lmvbRRLVzhUKwhbTC9ot443T7m5omBiRBj3LfthK/FlRxVeqPlAxufEr?= =?iso-8859-1?Q?Nhub5AmQLz91Ja5Y6DeURijtygFKFt28i6o0Igt/oH6kDamRqDZD/T64MR?= =?iso-8859-1?Q?Pw0nDrrxDGKipwgQ9ArR7hroU+qOx+wC+sLmAc6l4wNd0N8LfKfRm/6Pxk?= =?iso-8859-1?Q?sscHyUMGDQ=3D=3D?= Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: epam.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: AS2PR03MB9076.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 03da3311-469f-4fb0-2305-08df3e526376 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Nov 2026 11:12:48.6804 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b41b72d0-4e9f-4c26-8a69-f949f367c91d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: VOt9nkce1xvEhfkI/5/ewP8EcNvGtaW1ct+R8W8PAZ6IY3c88FInEzQiBOn04KOF3vEuv7xkif9mwjm/b56fEg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BESPR03MB911570 X-purgate-ID: tlsNG-ef75cf/1794222770-348C9AE4-D8B96799/10/78276251493 X-purgate-type: spam X-purgate-size: 3713 X-ZohoMail-DKIM: pass (identity @epam.com) X-ZM-MESSAGEID: 1794222799117158500 Content-Type: text/plain; charset="utf-8" For the purposes of certification, we want as little code as possible to be unconditionally compiled in. Make CPU hotplug and SMT operations configurable to ease the process. This will also help with introducing CPU hotplug on Arm, where it needs to be configurable. Signed-off-by: Mykyta Poturai Acked-by: Jan Beulich --- v10->v11: * no changes v9->v10: * no changes v8->v9: * add "if EXPERT" * add AB v7->v8: * fix style * s/CPU_HOTPLUG/CPU_ONLINE_OFFLINE/ v6->v7: * new patch --- xen/arch/x86/platform_hypercall.c | 12 ++++++++++++ xen/arch/x86/smp.c | 3 +++ xen/arch/x86/sysctl.c | 12 ++++++++++++ xen/common/Kconfig | 8 ++++++++ 4 files changed, 35 insertions(+) diff --git a/xen/arch/x86/platform_hypercall.c b/xen/arch/x86/platform_hype= rcall.c index 0f3c791fc2..2d43d20143 100644 --- a/xen/arch/x86/platform_hypercall.c +++ b/xen/arch/x86/platform_hypercall.c @@ -735,6 +735,12 @@ ret_t do_platform_op( { int cpu =3D op->u.cpu_ol.cpuid; =20 + if ( !IS_ENABLED(CONFIG_CPU_ONLINE_OFFLINE) ) + { + ret =3D -EOPNOTSUPP; + break; + } + if ( cpu >=3D nr_cpu_ids || !cpu_present(cpu) || clocksource_is_tsc() ) { @@ -757,6 +763,12 @@ ret_t do_platform_op( { int cpu =3D op->u.cpu_ol.cpuid; =20 + if ( !IS_ENABLED(CONFIG_CPU_ONLINE_OFFLINE) ) + { + ret =3D -EOPNOTSUPP; + break; + } + if ( cpu =3D=3D 0 ) { ret =3D -EOPNOTSUPP; diff --git a/xen/arch/x86/smp.c b/xen/arch/x86/smp.c index ae4e5a66d7..e3c4c0d5e0 100644 --- a/xen/arch/x86/smp.c +++ b/xen/arch/x86/smp.c @@ -416,6 +416,7 @@ void cf_check call_function_interrupt(void) smp_call_function_interrupt(); } =20 +#ifdef CONFIG_CPU_ONLINE_OFFLINE long cf_check cpu_up_helper(void *data) { unsigned int cpu =3D (unsigned long)data; @@ -443,8 +444,10 @@ long cf_check cpu_down_helper(void *data) { int cpu =3D (unsigned long)data; int ret =3D cpu_down(cpu); + /* Have one more go on EBUSY. */ if ( ret =3D=3D -EBUSY ) ret =3D cpu_down(cpu); return ret; } +#endif diff --git a/xen/arch/x86/sysctl.c b/xen/arch/x86/sysctl.c index 6bd4e191a7..10d485e633 100644 --- a/xen/arch/x86/sysctl.c +++ b/xen/arch/x86/sysctl.c @@ -53,6 +53,12 @@ static long cf_check smt_up_down_helper(void *data) unsigned int cpu, sibling_mask =3D boot_cpu_data.x86_num_siblings - 1; int ret =3D 0; =20 + if ( !IS_ENABLED(CONFIG_CPU_ONLINE_OFFLINE) ) + { + ASSERT_UNREACHABLE(); + return -EOPNOTSUPP; + } + opt_smt =3D up; =20 for_each_present_cpu ( cpu ) @@ -120,6 +126,12 @@ long arch_do_sysctl( long (*fn)(void *data); void *hcpu; =20 + if ( !IS_ENABLED(CONFIG_CPU_ONLINE_OFFLINE) ) + { + ret =3D -EOPNOTSUPP; + break; + } + switch ( op ) { case XEN_SYSCTL_CPU_HOTPLUG_ONLINE: diff --git a/xen/common/Kconfig b/xen/common/Kconfig index 5b289e444f..5713dc1f9c 100644 --- a/xen/common/Kconfig +++ b/xen/common/Kconfig @@ -646,6 +646,14 @@ config SYSTEM_SUSPEND =20 If unsure, say N. =20 +config CPU_ONLINE_OFFLINE + bool "CPU online/offline support" if EXPERT + depends on X86 + default y + help + Enable support for bringing CPUs online and offline at runtime. On + X86 this is required for disabling SMT. + menu "Supported hypercall interfaces" visible if EXPERT =20 --=20 2.56.0 From nobody Mon Nov 23 22:28:34 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; arc=pass (i=1 dmarc=pass fromdomain=epam.com); dmarc=pass(p=quarantine dis=none) header.from=epam.com ARC-Seal: i=2; a=rsa-sha256; t=1794222792; cv=pass; d=zohomail.com; s=zohoarc; b=VDmefmUOg9Xe186dqqRU+/mzUf8Ukir9HxeShV/PBVfiGHnAXtb0+QN5Ig2nGKnscbwgTUwTIJbQkBDrPtcSJwo1XD4t/RhJ46oCkYrA7JeTbUt2kFanWB99PgE7ZPst+PmLLp6BlDek1tFX9S4NUdPzBzjF81Mx6CXKRyY9G/c= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794222792; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=/8lN2N6zh132Ai8uzBJIHz2N+Q/htJPFUEWYUsnQlCI=; b=GLLRxwJJtFG8Qb42zI3cKLaHKdySPKu0svstJRMIK9GrL3BkynZJI/kAOAa3WyjqMNvSX/xUMZ1nWm12c8wbbt69do1TWsuQupaUiFEF/Mbcf3lw2KHpEsd6kFnAVFbs1nASvRhde6omcXK+u6Lqo0K5yyMarAslHt4CYteSnAg= 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=epam.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 1794222792983726.6982511770661; Mon, 9 Nov 2026 03:13:12 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1479832.1683758 (Exim 4.92) (envelope-from ) id 1xQNJ0-0004c2-1u; Mon, 09 Nov 2026 11:12:54 +0000 Received: by outflank-mailman (output) from mailman id 1479832.1683758; Mon, 09 Nov 2026 11:12:53 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xQNIz-0004bJ-QK; Mon, 09 Nov 2026 11:12:53 +0000 Received: by outflank-mailman (input) for mailman id 1479832; Mon, 09 Nov 2026 11:12:52 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xQNIx-0003qa-Qs for xen-devel@lists.xenproject.org; Mon, 09 Nov 2026 11:12:52 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xQNIx-003asL-6k for xen-devel@lists.xenproject.org; Mon, 09 Nov 2026 12:12:51 +0100 Received: from [10.42.69.7] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6af1aaa3-e002-0a2a0a5209dd-0a2a4507d888-32 for ; Mon, 09 Nov 2026 12:12:51 +0100 Received: from [52.101.83.89] (helo=GVXPR05CU001.outbound.protection.outlook.com) by tlsNG-ef75cf.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6af1aab0-b4ea-0a2a45070019-34655359e23e-7 for ; Mon, 09 Nov 2026 12:12:51 +0100 Received: from AS2PR03MB9076.eurprd03.prod.outlook.com (2603:10a6:20b:5fb::5) by BESPR03MB911570.eurprd03.prod.outlook.com (2603:10a6:b10:147::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.592.12; Mon, 9 Nov 2026 11:12:49 +0000 Received: from AS2PR03MB9076.eurprd03.prod.outlook.com ([fe80::bfe6:8f84:2f09:349c]) by AS2PR03MB9076.eurprd03.prod.outlook.com ([fe80::bfe6:8f84:2f09:349c%3]) with mapi id 15.21.0592.010; Mon, 9 Nov 2026 11:12:49 +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" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=epam.com header.i="@epam.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:x-ms-exchange-senderadcheck" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=TOZ5X9XR3bp7e00TnRMtx3+WEU+ye6wsykJ5jLF8ZU+pjIRnTw88WjX7AHu5NJ+wvE65Tvmus8nFXt7y2dp213NnedBEvr+VHzZylhkSyjgCVPgmXmosEntDkE7kpZCqiaRq97JsrStD/dHc+uoZ5I/AwfOMYHURFmYEmgXDTSXwpIAgjA/HnkLnyytShysOOy1QU/J3i1W80vmjw+KdwPKLG4k7AhzOMgQ+PubsVucJPS5/H3cH9apgNM0+87JynBsEgQjJQBmju3XhnefESwKYLzLnJVxNFSsGOwGzjGiCRtJ5NX+Bv/kXppYhA9r350oJdplmXyA3owwYta33BQ== 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=/8lN2N6zh132Ai8uzBJIHz2N+Q/htJPFUEWYUsnQlCI=; b=UXZEr27oO0PP1PKrYgkrh56Gq4+5aP71zypOFRX/rjVROfIzot7FZwzWjRxGSVgxvOwN7iw8TqCyVu+5oURLkVY+sufOlg1Ymg7vvDTcWCzopBgixPYatBZwwwms5EXjkW5zRFydcr9Opzt8aFdBE3Va6+KDbRbah7pPOnsPX6Sz2pJCf6khteFA6AaVcitoxJsmVtQtrmJAmr3OO8RKrQswFxe/vhUJ3og+dE/+BKdnYmeyuQI6SB1bDcHVLNCY99/HylkBbV2968ZtMbNuREsi/4izOEf83iRn0tipXCJm4h/0Us8/c6tDdvcsgf/JCNs7SW3ojmafquUaLk1R6w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=epam.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/8lN2N6zh132Ai8uzBJIHz2N+Q/htJPFUEWYUsnQlCI=; b=uMmVHKwASrPlpHT6hdh8oUT5NzTTUZ8KPfPLuUzVIhW/3msJ2wcLp/ScVLLfzetHjLXn6usxldPL4J5bf5GdhQqliQMOpkHKLVzSJK1Zg5ulI2LEln1Ikcj1+ZIVcfgrD5z6XkPgVdM329qi/4xRs+HI6umiXYcH503+Z27d+4C2zaUCRjbTN+PGnIWUp0JpsD5rRD8B1RLCcVMHJSsgAwoOQovQxpEZeyiLu5S54ZRNk/GZHn5Po175eQZOd+tI7f+qwRnUWs76Lv0yXQ0lbxuYzP5mydUzAaxDTfK5K+a7JfLjSuPIjpU7YRU3964z2QErJG1SkurDHQBrJK19Fg== From: Mykyta Poturai To: "xen-devel@lists.xenproject.org" CC: Mykyta Poturai , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , Andrew Cooper , Anthony PERARD , Jan Beulich , =?iso-8859-1?Q?Roger_Pau_Monn=E9?= , Teddy Astie , "Daniel P. Smith" Subject: [PATCH v11 4/6] arm/sysctl: Implement cpu hotplug ops Thread-Topic: [PATCH v11 4/6] arm/sysctl: Implement cpu hotplug ops Thread-Index: AQHdcDtB09yqm3vI3UKKICuJZIRK+g== Date: Mon, 9 Nov 2026 11:12:49 +0000 Message-ID: <92f0934ebdc79687f6007f83ec04bf8001f1e0cd.1794222015.git.mykyta_poturai@epam.com> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: AS2PR03MB9076:EE_|BESPR03MB911570:EE_ x-ms-office365-filtering-correlation-id: e3137ac7-95b3-4197-12a6-08df3e5263b7 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0;ARA:13230040|1800799024|366016|23010399003|376014|7416014|22082099003|18002099003|10063799003|10067099003|38070700021|11063799006|261028144727099003|261102123227099003|261022105027099003|261021123027099003|56012099006|261021121427099003|261026140227099003|261026121527099003|261009223027099003; x-microsoft-antispam-message-info: tOX8s8raMEND0IV0Mr9jsIv8kMnYvp80ScoaIDoysrLByjBWXdtF24grzfuRh5Lz1NKw1JqhUqogEla2MOjyx5jckuk+2Ht6pDqKIsf3Epim8NW7MA8hVu34FnxGTkMs2Krh+C4Y+bAidqAUk5+a4piMTcURERtbrakwzVl1D28Pwz617CRRU7l23EXW/3SFvlPPIF5V4D3R97Bj1ADZRVv+/INVO5LwMM0dLoLgMkCBy74QJd9q9admqVttmWRolUq7l8GJ8zXsHI3jB/GsZqtixVM1EHvY9vsA/bp2kGbwaDkJNQP0hXrFiaSCm9hjm5aNgSJZZanTaKFOc2bjjnzkhydew+xU0eLURNyrfWJUeTMxx2XOUsWyiZkcik38rWU65syQ8aJ28zO+UlLJtEiHz0oOWwf84ufBdoqzdMzWFcu1FGhnIMHr2HEF907KIWS50NLPJc7lMrc9cPRib1EbOJeIupSViywYa0ADVqGRcQeFpfAiJCPuQQjUq5vBDfRlDKqXXwgoZmijqFYMpEQxrMhVocClIFbrof1ZxroSJmus9zBy016bvhTN5/f4qqFjoiDsxaKKCCXMB71txDEuNJnXdGBiVQBYLwvLGs4qPth5LWx3mESotpV2J6HR8p+4YQQK4oAxQLnRaGaBLGcEcT/DAXHgkHnMJtAs9TeBacsbdCw15+efAq2CIjoKFPvgnTVQmF39bPUH0JWate84XM1UPvNUolr7Cps+kR0= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AS2PR03MB9076.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(23010399003)(376014)(7416014)(22082099003)(18002099003)(10063799003)(10067099003)(38070700021)(11063799006)(261028144727099003)(261102123227099003)(261022105027099003)(261021123027099003)(56012099006)(261021121427099003)(261026140227099003)(261026121527099003)(261009223027099003);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?Ud7KOz+SlrCoSjk9QL6KzsZ/zmmo/mKxL6kfOdpbgptgFC7JlalYKY/4qm?= =?iso-8859-1?Q?/oiWY1DeQw/CRksYpZxqyIG9PbDdSAPnwL/nG7kv2Ct/YFIVHmzBXWUGC6?= =?iso-8859-1?Q?Y1vH7e81LxL/jKlou/SVwe09lbZXTo6qccOpPH9C/XfcLJxurxbCgPN3gm?= =?iso-8859-1?Q?ZRI/7+Erlk1TY5F9ONer8qvTQ59wbP7AniKjQDovnZxrfMxIrkwi4cOzf+?= =?iso-8859-1?Q?aZCu+BhGONt/N77sh5vhNzkq1mUaN0AyLP6LxP+WifPZ2bPQEevFaFzycR?= =?iso-8859-1?Q?kGk/RzI9habmH6hPEsFwpY9IpWPh29z9wFEu7rcjtKAO1T6q98mhJCR3Jp?= =?iso-8859-1?Q?KNthej6CGm0VCVHHrBv7dtMs9HAWYLMkd847DpdsvYC+3hc0hTglt3pfwT?= =?iso-8859-1?Q?zhW8V2kOrUEC+8QACM+F8OHvktEyN474v0KslgWtrxXcetSj+icNtVYlxv?= =?iso-8859-1?Q?9pjZDlyIUK3mt3dYPf4R2Z7g4BPdMSWCcqG63yMlBio80UgJ37M5H53efi?= =?iso-8859-1?Q?twqRbj4Z/+PlY+0JoKjYeN03kpLoNt3aV/TsXOEbDZLjm+VPYIeEzUAviM?= =?iso-8859-1?Q?eO6FVWGTZhQ2gCejQPtHQHmanzTVTc1mAgKoVL8yA9FVewFHpxJA84hvmm?= =?iso-8859-1?Q?iT9cpJuJmBlWWNEm4e2Ng4cmM6Y1BRRVBAP3kB0TpqQF1V/gonWaaD21b3?= =?iso-8859-1?Q?bSPzaVu3GvDP6sYMhjz5kVz6EZvgd14Zo70+tICX+ppVmpi/pq8INlSFkK?= =?iso-8859-1?Q?OFCq4BCEJsExURVBrFbNzVqhzU37Ng/5fdhnmihA63si8CjyT5jJ2519S9?= =?iso-8859-1?Q?h2j0De2PdPwKdOXa8+v+hfMf2eIy4Oq/gapTFZxOfimFqaf9lpu1919N+/?= =?iso-8859-1?Q?gycU21hMKPCDbRoKV5FZ7NZ8DmCSxvUOZLkj28PfvlFBmL9PA70f/TMl3E?= =?iso-8859-1?Q?d54XLe0tUoRvKmM69yEUrzpnKTjGI2jNsUtx7JdRPIBWgpGrm1PYFFC4CE?= =?iso-8859-1?Q?7eNTl5h+lsEyN8EoupveJ5+iazxrJO4RZkqTlCLYoGVZb4dOm95XZzPrXm?= =?iso-8859-1?Q?RTaME8CeHJBpNrjh2aPpcIhfskWXYEgfovwcr7TerGgdOVj2wpT9Xk24e0?= =?iso-8859-1?Q?VgwvTobzHsB7erM5VMK1JeF3gj0fGZEQDIhKBKnFW9BWBRtcgzWT3Y04EB?= =?iso-8859-1?Q?L5JH9oQXkds6E3rUbUP3ZwapkXffaBiw2vPWqz2y0W+M4aj0sDz3FdHgbT?= =?iso-8859-1?Q?SZczzNHgdvSi7wueW0j+d7yGwTCLpaCfp862VdIHhKNI85Cj8B5Cp0LGZc?= =?iso-8859-1?Q?Bc+71+mBQsUI5KgQlndmu98vm3G0tc87PC8vITE04upuHUnjK9UkZNlwSb?= =?iso-8859-1?Q?UZGOaISCym/DEZ1NX0EWmLfjslZmy12sQp3UtDc7UNfU5VHcq0sqZWkBRG?= =?iso-8859-1?Q?iUSbpL+SK7uiwGJhb0uv1xnzLjOgv8w3DH41WvA9r3wkxJK4StD6lklI2r?= =?iso-8859-1?Q?26aYsQ5QWaolWWQm8Kl4QQR86klDwO1MEt2SVnFYEgQUe3Mvwk0xCuo4C1?= =?iso-8859-1?Q?Na0uUljFCksYKcGzTxwg8R5XBZCZQdgmW42b+ZnJ5GXfB/orIm7ktbheK+?= =?iso-8859-1?Q?zkxkGf8mMEYere6UhiVrfu8VCLljiR1mAerzg01GzsSsnimxf8zaJQEsrD?= =?iso-8859-1?Q?EaXelVF6yDd5bUlsYNBvUoLYf1kpsp1mkv1RJUS+a3R72hrFpXoMXqKO4i?= =?iso-8859-1?Q?hRzv5ljdgxVNvj39Ru7TMQRwqc2vDpKGNtbtlqkbLC6Mlywg7rPGT1ngkn?= =?iso-8859-1?Q?YEn+1sGRUw=3D=3D?= Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: epam.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: AS2PR03MB9076.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: e3137ac7-95b3-4197-12a6-08df3e5263b7 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Nov 2026 11:12:49.0858 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b41b72d0-4e9f-4c26-8a69-f949f367c91d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: LLn7VnO6NUVP3hT/BYWZaWI19B7VnIMJ7/BQOlno1ZpxnWC3dDTuZTJz7SZsV4ot1n06s1G+AmJT0VptHeoCog== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BESPR03MB911570 X-purgate-ID: tlsNG-ef75cf/1794222771-36EDEAE4-9C6FB6FC/0/0 X-purgate-type: clean X-purgate-size: 10690 X-ZohoMail-DKIM: pass (identity @epam.com) X-ZM-MESSAGEID: 1794222795168158500 Content-Type: text/plain; charset="utf-8" SMT-disable enforcement check is moved into a separate architecture-specific function. For now this operations only support Arm64. For proper Arm32 support, there needs to be a mechanism to free per-cpu page tables, allocated in init_domheap_mappings. Also, hotplug is not supported if ITS enabled, and partially supported FFA, or TEE is enabled, as they use non-static IRQ actions. Remove ifdef guards for x86 in flask, as cpu hotplug is now supported on more architectures. Signed-off-by: Mykyta Poturai Acked-by: Jan Beulich Reviewed-by: Volodymyr Babchuk --- v10->v11: * add HAS_CPU_ONLINE_OFFLINE knob v9->v10: * rename arch_cpu_can_stay_online to arch_cpu_keep_online * drop the single-use hp_op and hcpu variables * make CPU_ONLINE_OFFLINE depend on !TEE, as FFA and TEE use non-static IRQ actions v8->v9: * simplify dependencies of config CPU_ONLINE_OFFLINE again * rebased ove XSA-499 v7->v8: * simplify dependencies of config CPU_ONLINE_OFFLINE v6->v7: * use IS_ENABLED istead of ifdef in more places * remove unneded variables * more explicit fallthrough in do_sysctl v5->v6: * fix style issues * rename arch_smt_cpu_disable -> arch_cpu_can_stay_online and invert the logic * use IS_ENABLED istead of ifdef * remove explicit list af arch-specific SYSCTL_CPU_HOTPLUG_* options from the common handler * fix flask issue v4->v5: * move handling to common code * rename config to CPU_HOTPUG * merge with "smp: Move cpu_up/down helpers to common code" v3->v4: * don't reimplement cpu_up/down helpers * add Kconfig option * fixup formatting v2->v3: * no changes v1->v2: * remove SMT ops * remove cpu =3D=3D 0 checks * add XSM hooks * only implement for 64bit Arm --- xen/arch/arm/Kconfig | 1 + xen/arch/arm/smp.c | 11 +++++++++++ xen/arch/x86/Kconfig | 1 + xen/arch/x86/include/asm/smp.h | 3 --- xen/arch/x86/smp.c | 34 +++------------------------------ xen/arch/x86/sysctl.c | 11 ++++------- xen/common/Kconfig | 7 +++++-- xen/common/smp.c | 35 ++++++++++++++++++++++++++++++++++ xen/common/sysctl.c | 32 +++++++++++++++++++++++++++++++ xen/include/xen/smp.h | 6 ++++++ xen/xsm/flask/hooks.c | 2 +- 11 files changed, 99 insertions(+), 44 deletions(-) diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig index b9c5c40678..4569c76615 100644 --- a/xen/arch/arm/Kconfig +++ b/xen/arch/arm/Kconfig @@ -7,6 +7,7 @@ config ARM_64 def_bool y depends on !ARM_32 select 64BIT + select HAS_CPU_ONLINE_OFFLINE if !HAS_ITS && !TEE select HAS_DOMAIN_TYPE select HAS_FAST_MULTIPLY select HAS_VPCI_GUEST_SUPPORT if PCI_PASSTHROUGH diff --git a/xen/arch/arm/smp.c b/xen/arch/arm/smp.c index b372472188..f84f217359 100644 --- a/xen/arch/arm/smp.c +++ b/xen/arch/arm/smp.c @@ -44,6 +44,17 @@ void smp_send_call_function_mask(const cpumask_t *mask) } } =20 +#ifdef CONFIG_CPU_ONLINE_OFFLINE +/* + * We currently don't support SMT on ARM so we don't need any special logi= c for + * CPU disabling + */ +bool arch_cpu_keep_online(unsigned int cpu) +{ + return true; +} +#endif + /* * Local variables: * mode: C diff --git a/xen/arch/x86/Kconfig b/xen/arch/x86/Kconfig index e5535ac484..e5e3134022 100644 --- a/xen/arch/x86/Kconfig +++ b/xen/arch/x86/Kconfig @@ -17,6 +17,7 @@ config X86 select HAS_ALTERNATIVE select HAS_COMPAT select HAS_CPUFREQ + select HAS_CPU_ONLINE_OFFLINE select HAS_DIT select HAS_EHCI select HAS_EX_TABLE diff --git a/xen/arch/x86/include/asm/smp.h b/xen/arch/x86/include/asm/smp.h index 572b39b01c..6c33567cb5 100644 --- a/xen/arch/x86/include/asm/smp.h +++ b/xen/arch/x86/include/asm/smp.h @@ -44,9 +44,6 @@ int cpu_add(uint32_t apic_id, uint32_t acpi_id, uint32_t = pxm); =20 void __stop_this_cpu(void); =20 -long cf_check cpu_up_helper(void *data); -long cf_check cpu_down_helper(void *data); - long cf_check core_parking_helper(void *data); bool core_parking_remove(unsigned int cpu); uint32_t get_cur_idle_nums(void); diff --git a/xen/arch/x86/smp.c b/xen/arch/x86/smp.c index e3c4c0d5e0..b56d8dfd36 100644 --- a/xen/arch/x86/smp.c +++ b/xen/arch/x86/smp.c @@ -417,37 +417,9 @@ void cf_check call_function_interrupt(void) } =20 #ifdef CONFIG_CPU_ONLINE_OFFLINE -long cf_check cpu_up_helper(void *data) +bool arch_cpu_keep_online(unsigned int cpu) { - unsigned int cpu =3D (unsigned long)data; - int ret =3D cpu_up(cpu); - - /* Have one more go on EBUSY. */ - if ( ret =3D=3D -EBUSY ) - ret =3D cpu_up(cpu); - - if ( !ret && !opt_smt && - cpu_data[cpu].compute_unit_id =3D=3D INVALID_CUID && - cpumask_weight(per_cpu(cpu_sibling_mask, cpu)) > 1 ) - { - ret =3D cpu_down_helper(data); - if ( ret ) - printk("Could not re-offline CPU%u (%d)\n", cpu, ret); - else - ret =3D -EPERM; - } - - return ret; -} - -long cf_check cpu_down_helper(void *data) -{ - int cpu =3D (unsigned long)data; - int ret =3D cpu_down(cpu); - - /* Have one more go on EBUSY. */ - if ( ret =3D=3D -EBUSY ) - ret =3D cpu_down(cpu); - return ret; + return opt_smt || cpu_data[cpu].compute_unit_id !=3D INVALID_CUID || + cpumask_weight(per_cpu(cpu_sibling_mask, cpu)) <=3D 1; } #endif diff --git a/xen/arch/x86/sysctl.c b/xen/arch/x86/sysctl.c index 10d485e633..a4254beabb 100644 --- a/xen/arch/x86/sysctl.c +++ b/xen/arch/x86/sysctl.c @@ -121,13 +121,13 @@ long arch_do_sysctl( =20 case XEN_SYSCTL_cpu_hotplug: { - unsigned int cpu =3D sysctl->u.cpu_hotplug.cpu; unsigned int op =3D sysctl->u.cpu_hotplug.op; long (*fn)(void *data); void *hcpu; =20 if ( !IS_ENABLED(CONFIG_CPU_ONLINE_OFFLINE) ) { + ASSERT_UNREACHABLE(); ret =3D -EOPNOTSUPP; break; } @@ -135,13 +135,10 @@ long arch_do_sysctl( switch ( op ) { case XEN_SYSCTL_CPU_HOTPLUG_ONLINE: - fn =3D cpu_up_helper; - hcpu =3D _p(cpu); - break; - case XEN_SYSCTL_CPU_HOTPLUG_OFFLINE: - fn =3D cpu_down_helper; - hcpu =3D _p(cpu); + /* Handled by common code */ + ASSERT_UNREACHABLE(); + ret =3D -EOPNOTSUPP; break; =20 case XEN_SYSCTL_CPU_HOTPLUG_SMT_ENABLE: diff --git a/xen/common/Kconfig b/xen/common/Kconfig index 5713dc1f9c..f1c78b0ac7 100644 --- a/xen/common/Kconfig +++ b/xen/common/Kconfig @@ -121,6 +121,9 @@ config HAS_ALTERNATIVE config HAS_COMPAT bool =20 +config HAS_CPU_ONLINE_OFFLINE + bool + config HAS_DEVICE_TREE_DISCOVERY bool select DEVICE_TREE_PARSE @@ -648,8 +651,8 @@ config SYSTEM_SUSPEND =20 config CPU_ONLINE_OFFLINE bool "CPU online/offline support" if EXPERT - depends on X86 - default y + depends on HAS_CPU_ONLINE_OFFLINE + default X86 help Enable support for bringing CPUs online and offline at runtime. On X86 this is required for disabling SMT. diff --git a/xen/common/smp.c b/xen/common/smp.c index a011f541f1..af532d4873 100644 --- a/xen/common/smp.c +++ b/xen/common/smp.c @@ -16,6 +16,7 @@ * GNU General Public License for more details. */ =20 +#include #include #include #include @@ -104,6 +105,40 @@ void smp_call_function_interrupt(void) irq_exit(); } =20 +#ifdef CONFIG_CPU_ONLINE_OFFLINE +long cf_check cpu_up_helper(void *data) +{ + unsigned int cpu =3D (unsigned long)data; + int ret =3D cpu_up(cpu); + + /* Have one more go on EBUSY. */ + if ( ret =3D=3D -EBUSY ) + ret =3D cpu_up(cpu); + + if ( !ret && !arch_cpu_keep_online(cpu) ) + { + ret =3D cpu_down_helper(data); + if ( ret ) + printk("Could not re-offline CPU%u (%d)\n", cpu, ret); + else + ret =3D -EPERM; + } + + return ret; +} + +long cf_check cpu_down_helper(void *data) +{ + unsigned int cpu =3D (unsigned long)data; + int ret =3D cpu_down(cpu); + + /* Have one more go on EBUSY. */ + if ( ret =3D=3D -EBUSY ) + ret =3D cpu_down(cpu); + return ret; +} +#endif /* CONFIG_CPU_ONLINE_OFFLINE */ + /* * Local variables: * mode: C diff --git a/xen/common/sysctl.c b/xen/common/sysctl.c index 8fb5ff0af3..dd21b6ff7e 100644 --- a/xen/common/sysctl.c +++ b/xen/common/sysctl.c @@ -475,6 +475,38 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_= sysctl) copyback =3D 1; break; =20 + case XEN_SYSCTL_cpu_hotplug: + { + long (*fn)(void *data); + + ret =3D -EOPNOTSUPP; + if ( !IS_ENABLED(CONFIG_CPU_ONLINE_OFFLINE) ) + break; + + switch ( op->u.cpu_hotplug.op ) + { + case XEN_SYSCTL_CPU_HOTPLUG_ONLINE: + fn =3D cpu_up_helper; + break; + + case XEN_SYSCTL_CPU_HOTPLUG_OFFLINE: + fn =3D cpu_down_helper; + break; + + default: + fn =3D NULL; + break; + } + + if ( fn ) + { + ret =3D continue_hypercall_on_cpu(0, fn, _p(op->u.cpu_hotplug.= cpu)); + break; + } + } + + /* Use the arch handler for cases not handled here */ + fallthrough; default: ret =3D arch_do_sysctl(op, u_sysctl); copyback =3D 0; diff --git a/xen/include/xen/smp.h b/xen/include/xen/smp.h index 2ca9ff1bfc..6c011d73ef 100644 --- a/xen/include/xen/smp.h +++ b/xen/include/xen/smp.h @@ -76,4 +76,10 @@ extern void *stack_base[NR_CPUS]; void initialize_cpu_data(unsigned int cpu); int setup_cpu_root_pgt(unsigned int cpu); =20 +#ifdef CONFIG_CPU_ONLINE_OFFLINE +bool arch_cpu_keep_online(unsigned int cpu); +#endif +long cf_check cpu_up_helper(void *data); +long cf_check cpu_down_helper(void *data); + #endif /* __XEN_SMP_H__ */ diff --git a/xen/xsm/flask/hooks.c b/xen/xsm/flask/hooks.c index d65ba0aeae..a1eed309b4 100644 --- a/xen/xsm/flask/hooks.c +++ b/xen/xsm/flask/hooks.c @@ -957,7 +957,7 @@ static int cf_check flask_sysctl(const struct xen_sysct= l *op) case XEN_SYSCTL_getdomaininfolist: return flask_getdomaininfo(dom_xen); =20 -#ifdef CONFIG_X86 +#ifdef CONFIG_CPU_ONLINE_OFFLINE case XEN_SYSCTL_cpu_hotplug: switch ( op->u.cpu_hotplug.op ) { --=20 2.56.0 From nobody Mon Nov 23 22:28:34 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; arc=pass (i=1 dmarc=pass fromdomain=epam.com); dmarc=pass(p=quarantine dis=none) header.from=epam.com ARC-Seal: i=2; a=rsa-sha256; t=1794222803; cv=pass; d=zohomail.com; s=zohoarc; b=WGCempoZEEZydIZBFvg0VlEL8KNfP2xpglMwEZKHW21BS3xqh4OspxMfdjLHFmJUe3OsjIQnaLwptr3o34gtXI3FR3ZWHCKvs6VJtF8dap1Du6AfMf2ODg5fqw/XaQX78NtpvhDgmZrzou6c5rBtnHJRrh/tDuDkn5JymuwSC2k= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794222803; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=vjeJIH8/GtXKcRnCgkL9Zuudi1R07VDPB4wvamxUUAE=; b=llDaCYI88TuT/c6BH0xN+KpMfr4H0UVjWndrkX/D1XBYy1bpdJYTBpAKAIF3zn4aCyDYUD0D/8G5VJ1BgXvmi/vCgWVhwiPjKKHBgi0118KwKfGWXy/zE6pLgYBOufi/ezRxYfH13tWsACWhjHkjdjvWm1T0tutWEB+OZV15ryU= 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=epam.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 1794222803792973.6923735158515; Mon, 9 Nov 2026 03:13:23 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1479833.1683762 (Exim 4.92) (envelope-from ) id 1xQNJ0-0004kU-Hj; Mon, 09 Nov 2026 11:12:54 +0000 Received: by outflank-mailman (output) from mailman id 1479833.1683762; Mon, 09 Nov 2026 11:12:54 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xQNJ0-0004jO-BZ; Mon, 09 Nov 2026 11:12:54 +0000 Received: by outflank-mailman (input) for mailman id 1479833; Mon, 09 Nov 2026 11:12:53 +0000 Received: from mx.expurgate.net ([195.190.135.20]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xQNIy-00043f-KI for xen-devel@lists.xenproject.org; Mon, 09 Nov 2026 11:12:52 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xQNIy-00ELQW-0i for xen-devel@lists.xenproject.org; Mon, 09 Nov 2026 12:12:52 +0100 Received: from [10.42.69.2] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6af1aab3-bab6-0a2a0a5309dd-0a2a45029f4c-10 for ; Mon, 09 Nov 2026 12:12:51 +0100 Received: from [52.101.83.91] (helo=GVXPR05CU001.outbound.protection.outlook.com) by tlsNG-720697.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6af1aab3-6ca4-0a2a45020019-3465535b34ef-3 for ; Mon, 09 Nov 2026 12:12:51 +0100 Received: from AS2PR03MB9076.eurprd03.prod.outlook.com (2603:10a6:20b:5fb::5) by BESPR03MB911570.eurprd03.prod.outlook.com (2603:10a6:b10:147::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.592.12; Mon, 9 Nov 2026 11:12:49 +0000 Received: from AS2PR03MB9076.eurprd03.prod.outlook.com ([fe80::bfe6:8f84:2f09:349c]) by AS2PR03MB9076.eurprd03.prod.outlook.com ([fe80::bfe6:8f84:2f09:349c%3]) with mapi id 15.21.0592.010; Mon, 9 Nov 2026 11:12:49 +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" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=epam.com header.i="@epam.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:x-ms-exchange-senderadcheck" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZitsLZufbBAd0mwqxjzdcoip9aPdCo6ZU9Oo70PROQngN2XmK6rbl9CcD1FYqigcXPaK7Zg9N2WRW92XQFizsnRVMIhnDLQtAfw7Nkym/wJlHnD36s8iWJkY93BTKOeqZQ5miSKM0lbVYPYfYk2aXlMsNO0zx+QxzUJXdOj4SgOirAC21jCSSDZh09Q72W/CifI6MutkO1T6R6UA2oEoUnZRyessH/BVHQEbXWvnp9O6XfUNKlhMeeJrQ12Rt3btMZQt2RjsyDDBUbStyHVhgFuA8b0vFNf2smdkROS5vL7qUesZSwUmMcO9YmLAQc+Do6zG8pxmJXvphCrylXjS4w== 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=vjeJIH8/GtXKcRnCgkL9Zuudi1R07VDPB4wvamxUUAE=; b=dVqxC6mUfL4AMKbUzWEhQC5Yg5PpR0C9vJNIoT5o5MD+RwUNeIrMU0PXhST/gfvwgCr8hb0XCDAT+IGP8GWszVqHKX4D1/Dkn2um+xZF1+N5/9LdGSVZbv3o/+lbTD+redu+FXoHUEQ9RpG05aXE4RcI02Dgtkz3GTjZrEu5gMjENf5Ko8DiiFlybL/rOLRfBToVsUtio+EPOclWqJRxR+H1nRUP+Fs5NW3vJooShJQxiMMgb4rDG/5uFX3vNmMzl9xwnbdh3p1qHyWhHG1AGAIEHTGfVtZTkgbrHkOw2KWMN1N8JxSyxySrc6BHaRvz07CTK32zpYwRr1YjZYKkIw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=epam.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vjeJIH8/GtXKcRnCgkL9Zuudi1R07VDPB4wvamxUUAE=; b=Bc8LYjwn8eOm/wpyziEIHDLmdqgcbWzoOHdj8T6FOF2YRmPJpBWC/tkVQiJ09bXxnUbzt+vXeaPhLGEcgSRwprqvMwQe9E/36wdTcmrGtZnEStNi9UpP5Yp3PEZz/pBf8Sml/21iT+S5Iy5JCmCIexFQN3jvQrnTMHvzdLBOgNkSu3O2VQWXeR9GbFmQedQWcGvja1OVtMga89s2dzuslGwt77XVfdC9AjSJPUEHG4q6sTJqZW6OW9HhvVKnaoQV1IqCdsLWhoUNdYGbZNmmM55Pmf3L/bxRGIKs1rBBuHrPQopJWl+beItTEpBp5xutLbadhaqKBlYhijCOjkDJqw== From: Mykyta Poturai To: "xen-devel@lists.xenproject.org" CC: Mykyta Poturai , Anthony PERARD Subject: [PATCH v11 5/6] tools: Allow building xen-hptool without CONFIG_MIGRATE Thread-Topic: [PATCH v11 5/6] tools: Allow building xen-hptool without CONFIG_MIGRATE Thread-Index: AQHdcDtBCGXUV+OFfEeEYvsjcoIaUA== Date: Mon, 9 Nov 2026 11:12:49 +0000 Message-ID: <618fe620ab22e7a85bd74c0c7b762276722f0fee.1794222015.git.mykyta_poturai@epam.com> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: AS2PR03MB9076:EE_|BESPR03MB911570:EE_ x-ms-office365-filtering-correlation-id: da992ccf-abd0-4a0e-0cc1-08df3e5263fd x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0;ARA:13230040|1800799024|366016|23010399003|376014|22082099003|18002099003|6133799003|10067099003|38070700021|11063799006|261028144727099003|261102123227099003|261022105027099003|261021123027099003|56012099006|261021121427099003|261026140227099003|261026121527099003|261009223027099003|260925022911599003|260925021911599003|260925021311599003; x-microsoft-antispam-message-info: w3j7O1UPmGuhXDcGGAIcnpB524cVyQxZDDvo+t7JI4XS1tHHGP40OynF38VO7jJRua0zPCEoO1GLrYvXtUZ1zlP8zviLDla5uQO98UDAa7EUgpNgFcinrRdbnU42+q4FuYtkjAzLkLg/71lfuBNz+eWurxRochatSO5aWrn0ifHdNRyYHcfeWXcVLWjjeD4sBHuKfVF07xtkl9dxKEixbE9YiLKJDu+F4MOXq+d1acjKlyYN4IjfBjnv2CRgDUcUCX1D2UYBts0q/A2cl2QzEOTTsOIcraphm8yyxvR7GK390vYW/ShYtZhW7B9VgTQr2sQdtNtjeseoN+6AccGRt7dkqUiGVuBwv6/qDGcpCfUOkQTm11iCzl6CL7jCzYSNlmA+8NUnw4DOi9FS59kR2U8Ech3nBU/6038f50/+8xxCY0iRvQeQv7JFVgMhv2BqfNT8Sa6Zw1V2JCszO95IaIVI19A8tdtaTiY/RcIUQnWFfuDc/h5PV59kuwPuzfeWOu1Fn2Ykg9YUFKDfEfcoMiZP+udq9G1FDlyU98e38lgCtg8Xbk0mpmXHMk8K3rYYgWY8sX9oArv+76eiTcGOvM3L1uk2XD7qIK5ZqUAvZICoQePNefKmp48zhPyHh1zoKZJud2lWC+8/ogwLK34vYobrsb12BWS0jfxilPvuvvHce2UqeU+l4ik4Eou5CrstT6xBUKPZ+C2QWP5Iww9n4VVfWqNz8auUg54lyH48z+Y= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AS2PR03MB9076.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(23010399003)(376014)(22082099003)(18002099003)(6133799003)(10067099003)(38070700021)(11063799006)(261028144727099003)(261102123227099003)(261022105027099003)(261021123027099003)(56012099006)(261021121427099003)(261026140227099003)(261026121527099003)(261009223027099003)(260925022911599003)(260925021911599003)(260925021311599003);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?FcIiCdsSpoVCW2NmZgcqp49cq6wX39uSZspXE7k3J7M/Ms6uZCL5571+pi?= =?iso-8859-1?Q?E3edkX2nV1FhgaF6Bp6mdkF+fTUevFbQUYGiLOC566kiHuoHdKbwr/EuV9?= =?iso-8859-1?Q?12nwcRUPTIiIPrmlR1lmmxT7iNLryLb+YjB+8rhtX8x+owE56B4vKVGdq1?= =?iso-8859-1?Q?2YX2j35bTbkEiOFsEOD8l1y9UInIw5HyKLKPhLBCqCSmbzeBJO0XnLRNwr?= =?iso-8859-1?Q?tJQMVUXK2UwEvuyTQdrrjkxFYaoKwLlPSTD1LwIxm9L18PcsmlVpR5nCj4?= =?iso-8859-1?Q?tc/Eqx3dA8R/eWHXX6fy2BjPDNRbh5ZiB9AVlPE2FgCRnG2FC13oGgfWGP?= =?iso-8859-1?Q?Fegm86/hRywrVpS6P7L5Vi75U2a2xX3gZuIkVEkbx3aTLL6yOkCIeMXcIV?= =?iso-8859-1?Q?+nddXunEV3GdMt51bzwsng/Vro9Dj5mlhIbWQgsq+sWLd++iMlzlboFUnR?= =?iso-8859-1?Q?1Mb4R5IB7EapkiCDx6SuSu4f7wcYoMojQgRgBrDq9w5z6EAwLJWUeOraZd?= =?iso-8859-1?Q?CZTNt8jtPBEZgy4kbcPXo/uoBOCXmWyIsSYdoPTPlirHsaqxZuErH/0mLg?= =?iso-8859-1?Q?TNFHiHKCyHocTuclwRs02u4jhikbqoQT5e9Il0K/lgJoHuGEGjJyj1jvCh?= =?iso-8859-1?Q?62oLIema7S+Sor8BGfsowZLJoqk4XDKwaOilZzf2cCcwmZWZMx7r4yKxY/?= =?iso-8859-1?Q?lkXqa2t8F/j1U4dyH3/NvRTl1SON7LNdPs5DPZhsfrXjioOGGh83zyjXhS?= =?iso-8859-1?Q?VdFDm36KrcaPXi4dtnhnwwr7KA274Vv71ukbovLZfOpTTOlnrb/o1hhqcn?= =?iso-8859-1?Q?k7P5cBoAYRL93qKjrKp6BYebax02VOKrUuULRJhrdzrHe01+EE7IuQ3Vo+?= =?iso-8859-1?Q?HVu/vDU8vjUEuhZ3w8k2oe0AmDpyuCPeYTfvKU0bh1FTLQSEoadMdIFo1s?= =?iso-8859-1?Q?JAspYkXN0RJW8Bu3FoIeB3up/0JOTdmYn7uX/ctqHZEMyJe0JMsyv8MinW?= =?iso-8859-1?Q?iCYpf6xuLq9YtHYyzeAV9BxynLWXp7CudR8Ec9Z9Q02py0015fJSz9yaNg?= =?iso-8859-1?Q?nEj5LEE5Qb70eHiQ4B2iZRMLJK+z7S7+iCQMsEiJob5oOCFdxCX4Ex/atE?= =?iso-8859-1?Q?E2M9bZOph3+soqO2GXo4o1scDSS8UhpCUFjk5D86TYa8rXLXvmw9jROydk?= =?iso-8859-1?Q?aK+z5GaPH0yqJOKA0D/SH6ME86q9L+Qi3IQEnMs7fdqGnMsz1nI8rJyKH0?= =?iso-8859-1?Q?IpMpuSN8TzYFIW6rrCT2Jtq2Eku9l99pmuNlIqgUn3AFp6cLysqGvdAOOK?= =?iso-8859-1?Q?NOm9WG53or0ywJw4UlSTOyuDfYYH9OhRMVFISKm+GjnZHU2LiOFXu/Ht1U?= =?iso-8859-1?Q?Wa8yPmg/YkY0UpbWZNxZEVrtiFqpom3cFjysELoAa//yViV4q2v4p4/h3Q?= =?iso-8859-1?Q?2BxzPVQBxLqXrUGLemHZrTtL9L+Uc40iY/3f6YNN8qiYsZIkTXLb7bMBVl?= =?iso-8859-1?Q?XfgJumEdPkbjzpDYHORt8mei5IY8VOXSrOkY9qE4gkqIK/A5Jyij2KV2Sn?= =?iso-8859-1?Q?Euk7FFMJm6DfiHRYZvK65k/26nWgKXZUUttxdsngfDhmapNtyZzfvViUrv?= =?iso-8859-1?Q?G1M67QJ18AeGt/8dxdjl0auZbFdtVjeQCYti9Lb+0YI7nvIrvtH8qhIfEB?= =?iso-8859-1?Q?iFFv0YCBzkGqnIcYLD0jqfooDmOmvjPNGWRncubX9Yc8MBnMwIySSuNXL5?= =?iso-8859-1?Q?3pPVf+I9e5vWPDWSJ9/Wq9ZP+PKagxyQYvBzKTT+gVE115Y0zH8Wh2pkRx?= =?iso-8859-1?Q?FRT8zZktiA=3D=3D?= Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: epam.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: AS2PR03MB9076.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: da992ccf-abd0-4a0e-0cc1-08df3e5263fd X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Nov 2026 11:12:49.5424 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b41b72d0-4e9f-4c26-8a69-f949f367c91d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: W5Sn+mnuTwGvsmNMQ8gf99SLo/K++X1W0/JZ5+TNffzXLvKh/uVZKHZlaBkMCKbx4CSLfZ3NBMg4xFmu+k2iKw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BESPR03MB911570 X-purgate-ID: tlsNG-720697/1794222771-F18AC2AC-92F3E5A0/0/0 X-purgate-type: clean X-purgate-size: 24567 X-ZohoMail-DKIM: pass (identity @epam.com) X-ZM-MESSAGEID: 1794222805362158500 Content-Type: text/plain; charset="utf-8" With CPU hotplug sysctls implemented on Arm it becomes useful to have a tool for calling them. According to the commit history it seems that putting hptool under config MIGRATE was a measure to fix IA64 build. As IA64 is no longer supported it can now be brought back. So build it unconditionally. Operations specific to x86 architecture are moved into a separate file and only built on x86. Signed-off-by: Mykyta Poturai Reviewed-by: Anthony PERARD --- v10->v11: * no change v9->v10: * collect RB v8->v9: * use CONFIG_X86 instead of CONFIG_MIGRATE * fix style issues v7->v8: * move x86 specific function into a separate file v6->v7: * no changes v5->v6: * don't change order in Makefile v4->v5: * make hptool always build v3->v4: * no changes v2->v3: * no changes v1->v2: * switch to configure from legacy config --- tools/misc/Makefile | 9 +- tools/misc/xen-hptool-x86.c | 278 ++++++++++++++++++++++++++++++++++ tools/misc/xen-hptool.c | 293 ++---------------------------------- tools/misc/xen-hptool.h | 15 ++ 4 files changed, 314 insertions(+), 281 deletions(-) create mode 100644 tools/misc/xen-hptool-x86.c create mode 100644 tools/misc/xen-hptool.h diff --git a/tools/misc/Makefile b/tools/misc/Makefile index 6ee783f43e..064ab7c4bd 100644 --- a/tools/misc/Makefile +++ b/tools/misc/Makefile @@ -16,7 +16,7 @@ INSTALL_BIN +=3D xencov_split INSTALL_BIN +=3D $(INSTALL_BIN-y) =20 # Everything to be installed in regular sbin/ -INSTALL_SBIN-$(CONFIG_MIGRATE) +=3D xen-hptool +INSTALL_SBIN +=3D xen-hptool INSTALL_SBIN-$(CONFIG_X86) +=3D xen-hvmcrash INSTALL_SBIN-$(CONFIG_X86) +=3D xen-hvmctx INSTALL_SBIN-$(CONFIG_X86) +=3D xen-lowmemd @@ -104,8 +104,11 @@ xenhypfs: xenhypfs.o xenlockprof: xenlockprof.o $(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(APPEND_LDFLAGS) =20 -xen-hptool: xen-hptool.o - $(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenevtchn) $(LDLIBS_libxenctrl) $(L= DLIBS_libxenguest) $(LDLIBS_libxenstore) $(APPEND_LDFLAGS) +hptool-objs-y :=3D xen-hptool.o +hptool-objs-$(CONFIG_X86) +=3D xen-hptool-x86.o + +xen-hptool: $(hptool-objs-y) + $(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS_libxenevtchn) $(LDLIBS_libxenctrl) $(L= DLIBS_libxenguest) $(LDLIBS_libxenstore) $(APPEND_LDFLAGS) =20 xenhypfs.o: CFLAGS +=3D $(CFLAGS_libxenhypfs) =20 diff --git a/tools/misc/xen-hptool-x86.c b/tools/misc/xen-hptool-x86.c new file mode 100644 index 0000000000..95a7e05990 --- /dev/null +++ b/tools/misc/xen-hptool-x86.c @@ -0,0 +1,278 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#include +#include +#include +#include +#include +#include +#include +#include "xen-hptool.h" + +int hp_mem_online_func(int argc, char *argv[], xc_interface *xch) +{ + uint32_t status; + int ret; + unsigned long mfn; + + if (argc !=3D 1) + { + show_help(); + return -1; + } + + sscanf(argv[0], "%lx", &mfn); + printf("Prepare to online MEMORY mfn %lx\n", mfn); + + ret =3D xc_mark_page_online(xch, mfn, mfn, &status); + + if (ret < 0) + fprintf(stderr, "Onlining page mfn %lx failed, error %x\n", mfn, e= rrno); + else if (status & (PG_ONLINE_FAILED |PG_ONLINE_BROKEN)) { + fprintf(stderr, "Onlining page mfn %lx is broken, " + "Memory online failed\n", mfn); + ret =3D -1; + } + else if (status & PG_ONLINE_ONLINED) + printf("Memory mfn %lx onlined successfully\n", mfn); + else + printf("Memory is already onlined!\n"); + + return ret; +} + +int hp_mem_query_func(int argc, char *argv[], xc_interface *xch) +{ + uint32_t status; + int ret; + unsigned long mfn; + + if (argc !=3D 1) + { + show_help(); + return -1; + } + + sscanf(argv[0], "%lx", &mfn); + printf("Querying MEMORY mfn %lx status\n", mfn); + ret =3D xc_query_page_offline_status(xch, mfn, mfn, &status); + + if (ret < 0) + fprintf(stderr, "Querying page mfn %lx failed, error %x\n", mfn, e= rrno); + else + { + printf("Memory Status %x: [", status); + if ( status & PG_OFFLINE_STATUS_OFFLINE_PENDING) + printf(" PAGE_OFFLINE_PENDING "); + if ( status & PG_OFFLINE_STATUS_BROKEN ) + printf(" PAGE_BROKEND "); + if ( status & PG_OFFLINE_STATUS_OFFLINED ) + printf(" PAGE_OFFLINED "); + else + printf(" PAGE_ONLINED "); + printf("]\n"); + } + + return ret; +} + +static int suspend_guest(xc_interface *xch, xenevtchn_handle *xce, int dom= id, + int *evtchn, int *lockfd) +{ + int port, rc, suspend_evtchn =3D -1; + + *lockfd =3D -1; + + if (!evtchn) + return -1; + + port =3D xs_suspend_evtchn_port(domid); + if (port < 0) + { + fprintf(stderr, "DOM%d: No suspend port, try live migration\n", do= mid); + goto failed; + } + suspend_evtchn =3D xc_suspend_evtchn_init_exclusive(xch, xce, domid, + port, lockfd); + if (suspend_evtchn < 0) + { + fprintf(stderr, "Suspend evtchn initialization failed\n"); + goto failed; + } + *evtchn =3D suspend_evtchn; + + rc =3D xenevtchn_notify(xce, suspend_evtchn); + if (rc < 0) + { + fprintf(stderr, "Failed to notify suspend channel: errno %d\n", rc= ); + goto failed; + } + if (xc_await_suspend(xch, xce, suspend_evtchn) < 0) + { + fprintf(stderr, "Suspend Failed\n"); + goto failed; + } + return 0; + +failed: + if (suspend_evtchn !=3D -1) + xc_suspend_evtchn_release(xch, xce, domid, + suspend_evtchn, lockfd); + + return -1; +} + +int hp_mem_offline_func(int argc, char *argv[], xc_interface *xch) +{ + uint32_t status, domid; + int ret; + unsigned long mfn; + + if (argc !=3D 1) + { + show_help(); + return -1; + } + + sscanf(argv[0], "%lx", &mfn); + printf("Prepare to offline MEMORY mfn %lx\n", mfn); + ret =3D xc_mark_page_offline(xch, mfn, mfn, &status); + if (ret < 0) { + fprintf(stderr, "Offlining page mfn %lx failed, error %x\n", mfn, = errno); + if (status & (PG_OFFLINE_XENPAGE | PG_OFFLINE_FAILED)) + fprintf(stderr, "XEN_PAGE is not permitted be offlined\n"); + else if (status & (PG_OFFLINE_FAILED | PG_OFFLINE_NOT_CONV_RAM)) + fprintf(stderr, "RESERVED RAM is not permitted to be offlined\= n"); + } + else + { + switch(status & PG_OFFLINE_STATUS_MASK) + { + case PG_OFFLINE_OFFLINED: + { + printf("Memory mfn %lx offlined successfully, current stat= e is" + " [PG_OFFLINE_OFFLINED]\n", mfn); + if (status & PG_OFFLINE_BROKEN) + printf("And this offlined PAGE is already marked broke= n" + " before!\n"); + break; + } + case PG_OFFLINE_FAILED: + { + fprintf(stderr, "Memory mfn %lx offline failed\n", mfn); + if ( status & PG_OFFLINE_ANONYMOUS) + fprintf(stderr, "the memory is an anonymous page!\n"); + ret =3D -1; + break; + } + case PG_OFFLINE_PENDING: + { + if (status & PG_OFFLINE_XENPAGE) { + ret =3D -1; + fprintf(stderr, "Memory mfn %lx offlined succssefully," + "this page is xen page, current state is" + " [PG_OFFLINE_PENDING, PG_OFFLINE_XENPAGE]\n",= mfn); + } + else if (status & PG_OFFLINE_OWNED) + { + int result, suspend_evtchn =3D -1, suspend_lockfd =3D = -1; + xenevtchn_handle *xce; + xce =3D xenevtchn_open(NULL, 0); + + if (xce =3D=3D NULL) + { + fprintf(stderr, "When exchange page, fail" + " to open evtchn\n"); + return -1; + } + + domid =3D status >> PG_OFFLINE_OWNER_SHIFT; + if (suspend_guest(xch, xce, domid, + &suspend_evtchn, &suspend_lockfd)) + { + fprintf(stderr, "Failed to suspend guest %d for" + " mfn %lx\n", domid, mfn); + xenevtchn_close(xce); + return -1; + } + + result =3D xc_exchange_page(xch, domid, mfn); + + /* Exchange page successfully */ + if (result =3D=3D 0) + printf("Memory mfn %lx offlined successfully, this= " + "page is DOM%d page and being swapped " + "successfully, current state is " + "[PG_OFFLINE_OFFLINED, PG_OFFLINE_OWNED]\n= ", + mfn, domid); + else { + ret =3D -1; + fprintf(stderr, "Memory mfn %lx offlined successfu= lly" + " , this page is DOM%d page yet failed to = be " + "exchanged. current state is " + "[PG_OFFLINE_PENDING, PG_OFFLINE_OWNED]\n", + mfn, domid); + } + xc_domain_resume(xch, domid, 1); + xc_suspend_evtchn_release(xch, xce, domid, + suspend_evtchn, &suspend_loc= kfd); + xenevtchn_close(xce); + } + break; + } + }//end of switch + }//end of if + + return ret; +} + +int main_smt_enable(int argc, char *argv[], xc_interface *xch) +{ + int ret; + + if ( argc ) + { + show_help(); + return -1; + } + + for ( ;; ) + { + ret =3D xc_smt_enable(xch); + if ( (ret >=3D 0) || (errno !=3D EBUSY) ) + break; + } + + if ( ret < 0 ) + fprintf(stderr, "Unable to enable SMT: errno %d, %s\n", + errno, strerror(errno)); + else + printf("Enabled SMT\n"); + + return ret; +} + +int main_smt_disable(int argc, char *argv[], xc_interface *xch) +{ + int ret; + + if ( argc ) + { + show_help(); + return -1; + } + + for ( ;; ) + { + ret =3D xc_smt_disable(xch); + if ( (ret >=3D 0) || (errno !=3D EBUSY) ) + break; + } + + if ( ret < 0 ) + fprintf(stderr, "Unable to disable SMT: errno %d, %s\n", + errno, strerror(errno)); + else + printf("Disabled SMT\n"); + + return ret; +} diff --git a/tools/misc/xen-hptool.c b/tools/misc/xen-hptool.c index 590810b6eb..7b886e2304 100644 --- a/tools/misc/xen-hptool.c +++ b/tools/misc/xen-hptool.c @@ -6,8 +6,8 @@ #include #include #include +#include "xen-hptool.h" =20 -static xc_interface *xch; =20 void show_help(void) { @@ -18,239 +18,25 @@ void show_help(void) " help display this help\n" " cpu-online online CPU \n" " cpu-offline offline CPU \n" +#if defined(__i386__) || defined(__x86_64__) " mem-online online MEMORY \n" " mem-offline offline MEMORY \n" " mem-status query Memory status\n" " smt-enable onlines all SMT threads\n" " smt-disable offlines all SMT threads\n" +#endif ); } =20 /* wrapper function */ -static int help_func(int argc, char *argv[]) +static int help_func(int argc, char *argv[], xc_interface *xch) { show_help(); return 0; } =20 -static int hp_mem_online_func(int argc, char *argv[]) -{ - uint32_t status; - int ret; - unsigned long mfn; - - if (argc !=3D 1) - { - show_help(); - return -1; - } - - sscanf(argv[0], "%lx", &mfn); - printf("Prepare to online MEMORY mfn %lx\n", mfn); - - ret =3D xc_mark_page_online(xch, mfn, mfn, &status); - - if (ret < 0) - fprintf(stderr, "Onlining page mfn %lx failed, error %x\n", mfn, e= rrno); - else if (status & (PG_ONLINE_FAILED |PG_ONLINE_BROKEN)) { - fprintf(stderr, "Onlining page mfn %lx is broken, " - "Memory online failed\n", mfn); - ret =3D -1; - } - else if (status & PG_ONLINE_ONLINED) - printf("Memory mfn %lx onlined successfully\n", mfn); - else - printf("Memory is already onlined!\n"); - - return ret; -} - -static int hp_mem_query_func(int argc, char *argv[]) -{ - uint32_t status; - int ret; - unsigned long mfn; - - if (argc !=3D 1) - { - show_help(); - return -1; - } - - sscanf(argv[0], "%lx", &mfn); - printf("Querying MEMORY mfn %lx status\n", mfn); - ret =3D xc_query_page_offline_status(xch, mfn, mfn, &status); - - if (ret < 0) - fprintf(stderr, "Querying page mfn %lx failed, error %x\n", mfn, e= rrno); - else - { - printf("Memory Status %x: [", status); - if ( status & PG_OFFLINE_STATUS_OFFLINE_PENDING) - printf(" PAGE_OFFLINE_PENDING "); - if ( status & PG_OFFLINE_STATUS_BROKEN ) - printf(" PAGE_BROKEND "); - if ( status & PG_OFFLINE_STATUS_OFFLINED ) - printf(" PAGE_OFFLINED "); - else - printf(" PAGE_ONLINED "); - printf("]\n"); - } - - return ret; -} - -static int suspend_guest(xc_interface *xch, xenevtchn_handle *xce, int dom= id, - int *evtchn, int *lockfd) -{ - int port, rc, suspend_evtchn =3D -1; - - *lockfd =3D -1; - - if (!evtchn) - return -1; - - port =3D xs_suspend_evtchn_port(domid); - if (port < 0) - { - fprintf(stderr, "DOM%d: No suspend port, try live migration\n", do= mid); - goto failed; - } - suspend_evtchn =3D xc_suspend_evtchn_init_exclusive(xch, xce, domid, - port, lockfd); - if (suspend_evtchn < 0) - { - fprintf(stderr, "Suspend evtchn initialization failed\n"); - goto failed; - } - *evtchn =3D suspend_evtchn; - - rc =3D xenevtchn_notify(xce, suspend_evtchn); - if (rc < 0) - { - fprintf(stderr, "Failed to notify suspend channel: errno %d\n", rc= ); - goto failed; - } - if (xc_await_suspend(xch, xce, suspend_evtchn) < 0) - { - fprintf(stderr, "Suspend Failed\n"); - goto failed; - } - return 0; - -failed: - if (suspend_evtchn !=3D -1) - xc_suspend_evtchn_release(xch, xce, domid, - suspend_evtchn, lockfd); - - return -1; -} - -static int hp_mem_offline_func(int argc, char *argv[]) -{ - uint32_t status, domid; - int ret; - unsigned long mfn; - - if (argc !=3D 1) - { - show_help(); - return -1; - } - - sscanf(argv[0], "%lx", &mfn); - printf("Prepare to offline MEMORY mfn %lx\n", mfn); - ret =3D xc_mark_page_offline(xch, mfn, mfn, &status); - if (ret < 0) { - fprintf(stderr, "Offlining page mfn %lx failed, error %x\n", mfn, = errno); - if (status & (PG_OFFLINE_XENPAGE | PG_OFFLINE_FAILED)) - fprintf(stderr, "XEN_PAGE is not permitted be offlined\n"); - else if (status & (PG_OFFLINE_FAILED | PG_OFFLINE_NOT_CONV_RAM)) - fprintf(stderr, "RESERVED RAM is not permitted to be offlined\= n"); - } - else - { - switch(status & PG_OFFLINE_STATUS_MASK) - { - case PG_OFFLINE_OFFLINED: - { - printf("Memory mfn %lx offlined successfully, current stat= e is" - " [PG_OFFLINE_OFFLINED]\n", mfn); - if (status & PG_OFFLINE_BROKEN) - printf("And this offlined PAGE is already marked broke= n" - " before!\n"); - break; - } - case PG_OFFLINE_FAILED: - { - fprintf(stderr, "Memory mfn %lx offline failed\n", mfn); - if ( status & PG_OFFLINE_ANONYMOUS) - fprintf(stderr, "the memory is an anonymous page!\n"); - ret =3D -1; - break; - } - case PG_OFFLINE_PENDING: - { - if (status & PG_OFFLINE_XENPAGE) { - ret =3D -1; - fprintf(stderr, "Memory mfn %lx offlined succssefully," - "this page is xen page, current state is" - " [PG_OFFLINE_PENDING, PG_OFFLINE_XENPAGE]\n",= mfn); - } - else if (status & PG_OFFLINE_OWNED) - { - int result, suspend_evtchn =3D -1, suspend_lockfd =3D = -1; - xenevtchn_handle *xce; - xce =3D xenevtchn_open(NULL, 0); - - if (xce =3D=3D NULL) - { - fprintf(stderr, "When exchange page, fail" - " to open evtchn\n"); - return -1; - } - - domid =3D status >> PG_OFFLINE_OWNER_SHIFT; - if (suspend_guest(xch, xce, domid, - &suspend_evtchn, &suspend_lockfd)) - { - fprintf(stderr, "Failed to suspend guest %d for" - " mfn %lx\n", domid, mfn); - xenevtchn_close(xce); - return -1; - } - - result =3D xc_exchange_page(xch, domid, mfn); - - /* Exchange page successfully */ - if (result =3D=3D 0) - printf("Memory mfn %lx offlined successfully, this= " - "page is DOM%d page and being swapped " - "successfully, current state is " - "[PG_OFFLINE_OFFLINED, PG_OFFLINE_OWNED]\n= ", - mfn, domid); - else { - ret =3D -1; - fprintf(stderr, "Memory mfn %lx offlined successfu= lly" - " , this page is DOM%d page yet failed to = be " - "exchanged. current state is " - "[PG_OFFLINE_PENDING, PG_OFFLINE_OWNED]\n", - mfn, domid); - } - xc_domain_resume(xch, domid, 1); - xc_suspend_evtchn_release(xch, xce, domid, - suspend_evtchn, &suspend_loc= kfd); - xenevtchn_close(xce); - } - break; - } - }//end of switch - }//end of if - - return ret; -} - -static int exec_cpu_hp_fn(int (*hp_fn)(xc_interface *, int), int cpu) +static int exec_cpu_hp_fn(int (*hp_fn)(xc_interface *, int), int cpu, + xc_interface *xch) { int ret; =20 @@ -265,7 +51,7 @@ static int exec_cpu_hp_fn(int (*hp_fn)(xc_interface *, i= nt), int cpu) return ret; } =20 -static int hp_cpu_online_func(int argc, char *argv[]) +static int hp_cpu_online_func(int argc, char *argv[], xc_interface *xch) { int cpu, ret; =20 @@ -277,7 +63,7 @@ static int hp_cpu_online_func(int argc, char *argv[]) =20 cpu =3D atoi(argv[0]); printf("Prepare to online CPU %d\n", cpu); - ret =3D exec_cpu_hp_fn(xc_cpu_online, cpu); + ret =3D exec_cpu_hp_fn(xc_cpu_online, cpu, xch); if (ret < 0) fprintf(stderr, "CPU %d online failed (error %d: %s)\n", cpu, errno, strerror(errno)); @@ -287,7 +73,7 @@ static int hp_cpu_online_func(int argc, char *argv[]) return ret; =20 } -static int hp_cpu_offline_func(int argc, char *argv[]) +static int hp_cpu_offline_func(int argc, char *argv[], xc_interface *xch) { int cpu, ret; =20 @@ -298,7 +84,7 @@ static int hp_cpu_offline_func(int argc, char *argv[]) } cpu =3D atoi(argv[0]); printf("Prepare to offline CPU %d\n", cpu); - ret =3D exec_cpu_hp_fn(xc_cpu_offline, cpu); + ret =3D exec_cpu_hp_fn(xc_cpu_offline, cpu, xch); if (ret < 0) fprintf(stderr, "CPU %d offline failed (error %d: %s)\n", cpu, errno, strerror(errno)); @@ -308,76 +94,27 @@ static int hp_cpu_offline_func(int argc, char *argv[]) return ret; } =20 -static int main_smt_enable(int argc, char *argv[]) -{ - int ret; - - if ( argc ) - { - show_help(); - return -1; - } - - for ( ;; ) - { - ret =3D xc_smt_enable(xch); - if ( (ret >=3D 0) || (errno !=3D EBUSY) ) - break; - } - - if ( ret < 0 ) - fprintf(stderr, "Unable to enable SMT: errno %d, %s\n", - errno, strerror(errno)); - else - printf("Enabled SMT\n"); - - return ret; -} - -static int main_smt_disable(int argc, char *argv[]) -{ - int ret; - - if ( argc ) - { - show_help(); - return -1; - } - - for ( ;; ) - { - ret =3D xc_smt_disable(xch); - if ( (ret >=3D 0) || (errno !=3D EBUSY) ) - break; - } - - if ( ret < 0 ) - fprintf(stderr, "Unable to disable SMT: errno %d, %s\n", - errno, strerror(errno)); - else - printf("Disabled SMT\n"); - - return ret; -} - struct { const char *name; - int (*function)(int argc, char *argv[]); + int (*function)(int argc, char *argv[], xc_interface *xch); } main_options[] =3D { { "help", help_func }, { "cpu-online", hp_cpu_online_func }, { "cpu-offline", hp_cpu_offline_func }, +#if defined(__i386__) || defined(__x86_64__) { "mem-status", hp_mem_query_func}, { "mem-online", hp_mem_online_func}, { "mem-offline", hp_mem_offline_func}, { "smt-enable", main_smt_enable }, { "smt-disable", main_smt_disable }, +#endif }; =20 =20 int main(int argc, char *argv[]) { int i, ret; + xc_interface *xch; =20 if (argc < 2) { @@ -402,7 +139,7 @@ int main(int argc, char *argv[]) return 1; } =20 - ret =3D main_options[i].function(argc -2, argv + 2); + ret =3D main_options[i].function(argc -2, argv + 2, xch); =20 xc_interface_close(xch); =20 diff --git a/tools/misc/xen-hptool.h b/tools/misc/xen-hptool.h new file mode 100644 index 0000000000..34f492c34b --- /dev/null +++ b/tools/misc/xen-hptool.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef __XEN_HPTOOL_H__ +#define __XEN_HPTOOL_H__ + +#if defined(__i386__) || defined(__x86_64__) +int hp_mem_online_func(int argc, char *argv[], xc_interface *xch); +int hp_mem_query_func(int argc, char *argv[], xc_interface *xch); +int hp_mem_offline_func(int argc, char *argv[], xc_interface *xch); +int main_smt_enable(int argc, char *argv[], xc_interface *xch); +int main_smt_disable(int argc, char *argv[], xc_interface *xch); +#endif + +void show_help(void); + +#endif /* __XEN_HPTOOL_H__ */ --=20 2.56.0 From nobody Mon Nov 23 22:28:34 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; arc=pass (i=1 dmarc=pass fromdomain=epam.com); dmarc=pass(p=quarantine dis=none) header.from=epam.com ARC-Seal: i=2; a=rsa-sha256; t=1794222791; cv=pass; d=zohomail.com; s=zohoarc; b=BO+sxbKVNcWJyp3JjQhBgC/Ex2WkletNlMH+dX65Ue92fDvcoVZMPEYG60+XxMrey5lQqzKvgeM4nqVlUM/WOClA5tsZFzyc8aIJZTfY165y17yMUuaW+Ae0z4fmw7h7ikGCrFStNZOPji4ev3nwF5DPKUKeSfoxVn8KfctZyrc= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794222791; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=So4Usd1efqoEjsORsZeLMMsglUkCSIgwzCwOrZKP+ik=; b=HwczcygLXK3k2yNIwRLkGxsIVaP4hJ28+xseFuBxEk568mSNKk9OWkKTJdE52jCIUO25GNNQXY+iUp4el2t97BormOU9fFXMH4Qok9Cqe2F31pyeMhG0BzPpwT7iHMaLOcTfHoHTw26v0piedRzCnNpqywPVQ1qWJgfRyY0QHYk= 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=epam.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 1794222791147616.0152663161327; Mon, 9 Nov 2026 03:13:11 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1479834.1683768 (Exim 4.92) (envelope-from ) id 1xQNJ1-0004r5-1u; Mon, 09 Nov 2026 11:12:55 +0000 Received: by outflank-mailman (output) from mailman id 1479834.1683768; Mon, 09 Nov 2026 11:12: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 1xQNJ0-0004qK-QD; Mon, 09 Nov 2026 11:12:54 +0000 Received: by outflank-mailman (input) for mailman id 1479834; Mon, 09 Nov 2026 11:12:53 +0000 Received: from mx.expurgate.net ([195.190.135.20]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xQNIy-0004C1-Ub for xen-devel@lists.xenproject.org; Mon, 09 Nov 2026 11:12:53 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xQNIy-00ELQW-Aw for xen-devel@lists.xenproject.org; Mon, 09 Nov 2026 12:12:52 +0100 Received: from [10.42.69.2] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6af1aab3-bab6-0a2a0a5309dd-0a2a45029f4c-12 for ; Mon, 09 Nov 2026 12:12:52 +0100 Received: from [52.101.83.91] (helo=GVXPR05CU001.outbound.protection.outlook.com) by tlsNG-720697.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6af1aab3-6ca4-0a2a45020019-3465535b34ef-4 for ; Mon, 09 Nov 2026 12:12:52 +0100 Received: from AS2PR03MB9076.eurprd03.prod.outlook.com (2603:10a6:20b:5fb::5) by BESPR03MB911570.eurprd03.prod.outlook.com (2603:10a6:b10:147::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.592.12; Mon, 9 Nov 2026 11:12:50 +0000 Received: from AS2PR03MB9076.eurprd03.prod.outlook.com ([fe80::bfe6:8f84:2f09:349c]) by AS2PR03MB9076.eurprd03.prod.outlook.com ([fe80::bfe6:8f84:2f09:349c%3]) with mapi id 15.21.0592.010; Mon, 9 Nov 2026 11:12:50 +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" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=epam.com header.i="@epam.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:x-ms-exchange-senderadcheck" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=JCwpAg+Mfs1X5PBewvmCkbcHhZtr4n0lTnMbNCYGOx1/XPDt3Y6Jx/6kq+9y0Aqvm0wEt6/fAO8PVfjxsL93uRLps4fkJlTq1EhtBa5Gi3XkN3MZS2IF3tO4hnBHQObj0LOt8q4SUsc8bc16T6BwLsjs5MR4KlfihQ1wVizYFpkPhwYvMb3ODwzFyfHLEHaI6feS0VzXx3fogCzzOmtFlRv55Qt4Ua0M94/pw50R/IZCX3Yb+jmiOiloDluRG+WYwH8ePB3lQhBTVPEAjXUZKxhAnLjjI0zW5JfoFbJOd41gr5BI+j3CZrTfTENvXZNrnHcw0ZuUXzMJxOnGowgM1w== 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=So4Usd1efqoEjsORsZeLMMsglUkCSIgwzCwOrZKP+ik=; b=ma8tsOaFwIMNyS6I7W1AtABJziINo/hfIwuFpJaxcafTPbtNQ4GM+Zzxo9Va9mmgZxNKFSWRqjfa26y8M9ECXM8yCfL3cp3Ty1VvBDGCk9rqhdFapWqltfJyS7WAAOfsQHr6FTc5JD0kyQXNrNud/V9Gdk1VpJFpNEK/jf1UeNa5sW8hNUp5N6oS3gpEeY+oF4gcfxl+fF6y4S57TpdkZiaJokyOe5q1E4xTkT2y1VYecy1z40UZrWahdoawdZtD9NWBlI0KxFD/nKtm9oubVY6F9EfQhv7P7DJaKQ2jDgOOpRWBWmN4gJIO9WU0cjRMszvZicA8eMm/ekOmtKjikg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=epam.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=So4Usd1efqoEjsORsZeLMMsglUkCSIgwzCwOrZKP+ik=; b=QIA/69S09xQb8HV2DGk0LxLAsxQff79Jko+/4TiPKhPAr4/BOinajMqQD3FLyBUAU+oShzt4SwRPEvdwFzQf6gpPf4uPxubH4jichPP2+h9FSwAclCiGb/NHNF5AL0V5in0VChwU28UHT8sKJTLxLpP4a00Gr02QAMdvRLXO5Rhb83c+dXPWjUZ+k5l6iApUgwgUFoYZKxoZ3OD3YRJ4K4RH1bArBQIC9GqXmS7V4wI+TZI6NWyY/ArKsAStqYYDMHexyoyzktjaSeWKMmXeebmABdL/pWDQa2WeHlbNorjVkbgzEWFV6oGPyGaAuajT2jaDu/fhThTEnVybMPJRZg== From: Mykyta Poturai To: "xen-devel@lists.xenproject.org" CC: Mykyta Poturai , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?iso-8859-1?Q?Roger_Pau_Monn=E9?= , Stefano Stabellini Subject: [PATCH v11 6/6] docs: Document CPU hotplug Thread-Topic: [PATCH v11 6/6] docs: Document CPU hotplug Thread-Index: AQHdcDtBxh3En5yEU0GTrBnml38UOA== Date: Mon, 9 Nov 2026 11:12:49 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: AS2PR03MB9076:EE_|BESPR03MB911570:EE_ x-ms-office365-filtering-correlation-id: d0e5d2df-9e01-4d94-429e-08df3e526440 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0;ARA:13230040|1800799024|366016|23010399003|376014|22082099003|18002099003|6133799003|10067099003|38070700021|11063799006|261028144727099003|261102123227099003|261022105027099003|261022075727099003|56012099006|261021121427099003|261026140227099003|261026121527099003|261009223027099003|260925022911599003|260925021911599003|260925021311599003; x-microsoft-antispam-message-info: hN8MfVSGPbS4akZd9Qt7hqJteJkZJr+NuwCI4LgsgW1kdRQDHv6zY6s+BMWxoklklJLwPmwwtyZ7SkoQQdXbrOHvLwh1ZXwP0j1MEYMUfGPy08n6UQig348vbaCalADFN4/PR/Cz30INzlFWqk+8FXBi4D+crdf216xf6p82srPBQh167ATJa4j4LucYByZDKnmLz+Ogm2iyTI8EbYKR5r5hzuYvPn6WLNP7QRWdmyWfAm32nOH5AMVBoaqpizU7ZB2mKvBxicMQTjST9mR2yFxrj6pwJxs5bkvliPSil+bocbycY8gNd27bDKclytW4hpxe/DZWZLGW396I1N3v7DX87VTnv3wsq4u8SN2r7DHllMQNa+fTgF0+7d1luRGCqH2RncAfRNCV/O5Gxeu5X+/IVxx6kGDsbVPsJO1Ve2iqF3v8v54VKHbFlvrHhLNKKe6WWGGK7OYAe562l5j957dPWqp/u/S8DFqbU+lC9Ku2V79rIxVTXZ1Ho6m9RCgfyRHAVeYthS8lybzgskpQ8iCxunIyte88x8PknDL/cF2dybjQNo9tT63FLF7v8kwBOZTaA1fR8CKz7U28CPTvmukNL8mjKBemW5eWbDEoXgh+bbcMxLCj3MTDK0Tjy9YVODgfngdXXylHclRzbMK1NLsH5o8E5C9GQLISEvcu3vqqK4XplR7q57uJSHN2kcsrXJzN/6kjG/dPyilnkKnmaPHGbiGDRLK7KJ5fqYSZNZA= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AS2PR03MB9076.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(23010399003)(376014)(22082099003)(18002099003)(6133799003)(10067099003)(38070700021)(11063799006)(261028144727099003)(261102123227099003)(261022105027099003)(261022075727099003)(56012099006)(261021121427099003)(261026140227099003)(261026121527099003)(261009223027099003)(260925022911599003)(260925021911599003)(260925021311599003);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?ISsIXdnyCIenFb6ABUwPEw4CR9uuhNpH5E/DtdTuOkJsDShko2bbjNsCyz?= =?iso-8859-1?Q?qAMYe26wnulZSq+pd6g3ew6c1ck/n+iBtZF6DzUVhSRQLBlPcbXR/8Pkfi?= =?iso-8859-1?Q?bAGMlStehfjoi7KSoXp8aywVKAMsp+rnGKBhz2mTk8THwewonVJp+c/ecd?= =?iso-8859-1?Q?rAZ0nmo7iAR/NVCpIT4juCueE4oqfeEMyZjWn8zI2d86otYzmx5k6B/qLN?= =?iso-8859-1?Q?F2JpcNyFHDl17BfZS8S7jHql9t/CYhrE10E6ILv4b0nVIGnRc9xSq7jbcX?= =?iso-8859-1?Q?7iGMwyOWhB7MfSY6TuwtC7CvFGyiyMwWxxNfCMpwbdJbc7qfjlenWJdM1N?= =?iso-8859-1?Q?WYQfFHPe6ukLh22vIaoBUQ4dEYVvnELLXHUYUAtd7ggV28ww/aNpyKuFp4?= =?iso-8859-1?Q?L/MFJ7QLujQL+Uh4H2vBmTI+A1+f9A+9pUNTUHDVgXNinMxcRHG33TpUuS?= =?iso-8859-1?Q?z2e0IxQMhsdW2bHes70awk3ei1SbuY3hbDfmbeZ/gM5pbEUDsLTugm2DYi?= =?iso-8859-1?Q?LdOf0XmEETjr2V2KaXYdfuMn/i1iQYEnIqGt03e5p9fgD4wVqJysd9Yvek?= =?iso-8859-1?Q?pKJulPNX/zwmRGBu1sTWbEcgmDW+AWSfi9QIzBERitQTuvsxcxpflIymQf?= =?iso-8859-1?Q?CIvrCqMkWxINzpHdhEU+ZYXl1/H5gm7d4o0EXS48Y6DilYkSCd7JzFh88a?= =?iso-8859-1?Q?N9cXYMTAnoPZj7HL7pU8fZTWoHGt9loKISby/Jv2CkYBPVAmI9Wq0grQbt?= =?iso-8859-1?Q?vob4ve9sM9/dJ32BbX4NXzFKP+dcHxWL9BbXtL3+5S3lvNc2BiRelqG9Id?= =?iso-8859-1?Q?9E/kWGHKhLHwUWMwZH6N0ZjusEqUGkLL8DfOjy3HUGxvAf3e85jD3es79E?= =?iso-8859-1?Q?HV3uIPzjKwneDOenoRPdQTdv6Z4IJrj2Rk3KX5hOzGHvmAZRZy1PQi2uuB?= =?iso-8859-1?Q?roNc1qFgRuiblszN2RTE0mHTfu6rtPe1JFOxnosC5UTPsSAXBhl/5rwwdw?= =?iso-8859-1?Q?yf/21a+ZMD8k2LK63HvHIyLoYOSrb38K4kCiQNUB+Db8iBGMDjOR44qKSy?= =?iso-8859-1?Q?hhLmn4kk07XQsHVJ9dIYIx78MSjoUFr58i2+JnZts2pmU5bZKby3o0EXbn?= =?iso-8859-1?Q?xw92H/d5VwdjjDBqtlmkf9125Z/o3lzMcobpCFWyBMQyukHhkrAIiC+ABr?= =?iso-8859-1?Q?Y0BYwmb6N0biPCtxOi87As49akGTdbJNY38N7nBsAbZFiGaM7WhiXVbnGm?= =?iso-8859-1?Q?7k/jqWx+qoLF5QMGzjJz90JQwjgGgJjKbiTK641VkmuC5RFaqJXvf5/aKv?= =?iso-8859-1?Q?q0s1/MeHHkos2YIeXTgZpVOY4rPXVn73BUZ2tMUCwnmtizYdW9WEwRZ4UN?= =?iso-8859-1?Q?14gsZ/W6c6Q+vQR11J24tnyScIyCAlEBtpbHvS4nOoKoOsjzmQHql/uHkx?= =?iso-8859-1?Q?Dya2DRxrxNCHOpXhxMe/Z/O8idx0ur/etkfSBh3UnzLS8O0nlxX/l2+x3V?= =?iso-8859-1?Q?/9PdfHotO8MXC8wmMTvaHUMiskq2tsIqBkyefbyQ8p5WMK7E0SaEI+QJQa?= =?iso-8859-1?Q?bLaCTOAoyomIY4QUcQ+UuhbgpEHqSWvkJo6wQrx96WrK+dSd3wIOoPK5mq?= =?iso-8859-1?Q?5AF3ZcFkB5SVjj9cUh9v/P22fK+Tcu3cg/G8GUcXsAGJ2LuFbIsxjqcauV?= =?iso-8859-1?Q?2o4PnZKexjFdP2NQR6w7d5jS98rJjHX6UQKfVyfpiQ++sU+YyfXi2hrwBv?= =?iso-8859-1?Q?aBAZjpMW0CNYoVQn08X9q9DoovZ5cP3XIJMUVnMQKpqp63BWURn3F6Ed2d?= =?iso-8859-1?Q?H0SPPJPVFg=3D=3D?= Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: epam.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: AS2PR03MB9076.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: d0e5d2df-9e01-4d94-429e-08df3e526440 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Nov 2026 11:12:49.9790 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b41b72d0-4e9f-4c26-8a69-f949f367c91d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 26PXO57uB2d6SG0Bft+/i2dyrDsezE2DJVEFEPGftQGPGWoRii6ZoILJ6ZdghS0gNC7tkr1TkWlJer0rMt+hoQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BESPR03MB911570 X-purgate-ID: tlsNG-720697/1794222772-31FD62AC-BF4806C9/0/0 X-purgate-type: clean X-purgate-size: 4502 X-ZohoMail-DKIM: pass (identity @epam.com) X-ZM-MESSAGEID: 1794222793098158500 Content-Type: text/plain; charset="utf-8" Signed-off-by: Mykyta Poturai Reviewed-by: Volodymyr Babchuk --- v10->v11: * sync with latest changes v9->v10: * explain the actual ITS incompatibility * say FFA and TEE are incompatible, matching the Kconfig dependency v8->v9: * no changes v7->v8: * remove support status update * update config option name v6->v7: * add testing and limitations v5->v6: * no changes v4->v5: * s/supported/implemented/ * update SUPPORT.md v3->v4: * update configuration section v2->v3: * patch introduced --- docs/misc/cpu-hotplug.txt | 102 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 docs/misc/cpu-hotplug.txt diff --git a/docs/misc/cpu-hotplug.txt b/docs/misc/cpu-hotplug.txt new file mode 100644 index 0000000000..e1b474ca69 --- /dev/null +++ b/docs/misc/cpu-hotplug.txt @@ -0,0 +1,102 @@ +CPU Hotplug +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +CPU hotplug is a feature that allows pCPU cores to be added to or removed = from a +running system without requiring a reboot. It is implemented on x86 and Ar= m64 +architectures. + +Implementation Details +---------------------- + +CPU hotplug is implemented through the `XEN_SYSCTL_CPU_HOTPLUG_*` sysctl c= alls. +The specific calls are: + +- `XEN_SYSCTL_CPU_HOTPLUG_ONLINE`: Brings a pCPU online +- `XEN_SYSCTL_CPU_HOTPLUG_OFFLINE`: Takes a pCPU offline +- `XEN_SYSCTL_CPU_HOTPLUG_SMT_ENABLE`: Enables SMT threads (x86 only) +- `XEN_SYSCTL_CPU_HOTPLUG_SMT_DISABLE`: Disables SMT threads (x86 only) + +All cores can be disabled, assuming hardware support, except for the boot = core. +Sysctl calls are routed to the boot core before doing any actual up/down +operations on other cores. + +If there are Xen-bound interrupts pinned to the pCPU being offlined, they = will +be automatically migrated to other online pCPUs. Interrupts used by guest +domains are handled by the scheduler when it reschedules the vCPUs to a ne= w, +online, pCPU. When a pCPU is being onlined, some Xen-bound interrupts will= get +redistributed to the newly onlined pCPU to prevent imbalance. + +If pCPU being offlined has some vCPUs pinned to it, they will be automatic= ally +unpinned and migrated to other online pCPUs. + +Limitations +----------- + +On Arm64 cpu hotplug is currently not compatible with the ITS: the per-CPU= LPI +pending table and GICR_CTLR.EnableLPIs are set up once at boot and are not +re-usable, so onlining a pCPU a second time fails. + +On Arm64 it is also not compatible with the FFA and TEE mediators, as both= use +non-static IRQ actions. + +Configuration +------------- + +CPU hotplug support in Xen is controlled by the CONFIG_CPU_ONLINE_OFFLINE +Kconfig option, which requires EXPERT and depends on HAS_CPU_ONLINE_OFFLIN= E. +HAS_CPU_ONLINE_OFFLINE is selected by x86, and by Arm64 when neither ITS n= or +TEE support is enabled. The option is enabled by default on x86 and disabl= ed +by default on Arm64. + +The xen-hptool userspace tool is built unconditionally. + +Usage +----- + +Disable core: + +$ xen-hptool cpu-offline 2 +Prepare to offline CPU 2 +(XEN) Removing cpu 2 from runqueue 0 +CPU 2 offlined successfully + +Enable core: + +$ xen-hptool cpu-online 2 +Prepare to online CPU 2 +(XEN) Bringing up CPU2 +(XEN) GICv3: CPU2: Found redistributor in region 0 @00000a004005c000 +(XEN) CPU2: Guest atomics will try 1 times before pausing the domain +(XEN) CPU 2 booted. +(XEN) Adding cpu 2 to runqueue 0 +CPU 2 onlined successfully + +Disabling a core with pinned vCPUs: + +$ xl vcpu-pin 0 3 3 3 +$ xl vcpu-pin 0 2 3 3 +$ xl vcpu-pin 0 1 3 3 +$ xl vcpu-pin 0 0 3 3 +$ xen-hptool cpu-offline 3 +Prepare to offline CPU 3 +(XEN) Breaking affinity for d0v0 +(XEN) Breaking affinity for d0v1 +(XEN) Breaking affinity for d0v2 +(XEN) Breaking affinity for d0v3 +(XEN) Removing cpu 3 from runqueue 0 +CPU 3 offlined successfully + +Testing +------- + +The CPU hotplug feature has been tested on both x86 and Arm64 QEMU setups = and on +R-Car Gen5 (Arm64) hardware. + +The tests included: +- Offlining and onlining cores with no pinned vCPUs +- Offlining cores with pinned vCPUs +- Offlining cores with Xen-bound interrupts +- Offlining all cores except the boot core +- Offlining the boot core (expected to fail) +- Enabling and disabling SMT threads (x86 only) +- Offlining cores to which guests with passthrough devices are pinned --=20 2.56.0