From nobody Thu Nov 14 17:01:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+70877+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+70877+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=oracle.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1611882184382263.99187722458737; Thu, 28 Jan 2021 17:03:04 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id TYKYYY1788612x2jkwkrgBRd; Thu, 28 Jan 2021 17:03:03 -0800 X-Received: from aserp2120.oracle.com (aserp2120.oracle.com [141.146.126.78]) by mx.groups.io with SMTP id smtpd.web09.3217.1611882168345181138 for ; Thu, 28 Jan 2021 17:02:48 -0800 X-Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 10T0f7T2064508; Fri, 29 Jan 2021 01:02:45 GMT X-Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 368brkxsda-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 29 Jan 2021 01:02:45 +0000 X-Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 10T0eG4O081854; Fri, 29 Jan 2021 01:00:44 GMT X-Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2170.outbound.protection.outlook.com [104.47.56.170]) by userp3030.oracle.com with ESMTP id 368wr13fqw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 29 Jan 2021 01:00:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ad8lKitAkP3rl9yj2GsQxc1+EiNcbPKQWrX557om1HLKA2YCypRG/ACTb/2HChxA3ZqABg2reixXHMcfljq7tuHit/Em52hFEKDa4TfoKsFD8UcpMZ13FeFAd/kOahpuSG5K4akxsE25oRZyJHb/8DWWWfal8SIAyQZBWrm4vpoRdHeYWfslNXyGTJ52bkVAaGJ9ARs9+3Ip5obUrmnPqUOXVykRVPX8pNbT7Fz3zOddVaG2JHIwpsyTux3Q+tDrGrlvGJGG8BhFaFjRdyqYyld943iWQkaafdrdBdN3WdsTFBA0njNb+XP4FdkUVRd2o92hCynydym/d1azghxc/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rgPTXAvtTPqel57nufZeHYm4FztS/OLvF3zj0LifChc=; b=Y/O07WcA8X3q3LW13c1u5/NXMHz03oNoCx/4uW7YuU4zYJW6GMi1quUcXh2YMEVJTIEa3Gv5c4BpSd9HUx0tk4wALFi7zV1j2ZB6kAS/6bYZpRFr/lYb5HoqQqmssp3sUzDZJNP3RUBjQ6Vedl6hNaSBqvyn1Hn56jJhoGZxe/Pz8OaPvSGJFPrDvUqswAiW+bp3TZ/W5FESXd8Ni3ZeNyzRK8p/fGYL18jd+gfI6RiP5xqhcCkMIvJFZoTLZHrrizl/KrOrWrKPz245GZq6vnyG+cnEmU/DtznRSiF4C64RbleD0HQtqC9zbLN15SJL8Nv7yP557edTPz/W4X7I6g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none X-Received: from CY4PR10MB1718.namprd10.prod.outlook.com (2603:10b6:910:9::17) by CY4PR1001MB2246.namprd10.prod.outlook.com (2603:10b6:910:41::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.16; Fri, 29 Jan 2021 01:00:03 +0000 X-Received: from CY4PR10MB1718.namprd10.prod.outlook.com ([fe80::39dc:6ba7:9397:cb6]) by CY4PR10MB1718.namprd10.prod.outlook.com ([fe80::39dc:6ba7:9397:cb6%6]) with mapi id 15.20.3805.019; Fri, 29 Jan 2021 01:00:03 +0000 From: "Ankur Arora" To: devel@edk2.groups.io Cc: lersek@redhat.com, imammedo@redhat.com, boris.ostrovsky@oracle.com, Ankur Arora , Jordan Justen , Ard Biesheuvel , Aaron Young Subject: [edk2-devel] [PATCH v6 4/9] OvmfPkg/CpuHotplugSmm: introduce UnplugCpus() Date: Thu, 28 Jan 2021 16:59:45 -0800 Message-Id: <20210129005950.467638-5-ankur.a.arora@oracle.com> In-Reply-To: <20210129005950.467638-1-ankur.a.arora@oracle.com> References: <20210129005950.467638-1-ankur.a.arora@oracle.com> X-Originating-IP: [148.87.23.8] X-ClientProxiedBy: MWHPR1401CA0022.namprd14.prod.outlook.com (2603:10b6:301:4b::32) To CY4PR10MB1718.namprd10.prod.outlook.com (2603:10b6:910:9::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Received: from prion.us.oracle.com (148.87.23.8) by MWHPR1401CA0022.namprd14.prod.outlook.com (2603:10b6:301:4b::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.17 via Frontend Transport; Fri, 29 Jan 2021 01:00:02 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 11f5ab6d-172c-4a65-5bd1-08d8c3f135ad X-MS-TrafficTypeDiagnostic: CY4PR1001MB2246: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 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DpdK0lFL4+UeeNQfnOFkS?= =?us-ascii?Q?iT56yCOgYly4D9I+Fq2uT9LXDwt5WuByd7y9JQl3/AQBQguhMdwGN8PszGAS?= =?us-ascii?Q?wZI7eVjNNKQ9OJcUxM7Y2ZVeWKGK5vTWXMeJm1X7+Ac1SQN4ym8PoDhXjh08?= =?us-ascii?Q?kbk7BGNtEaHK11l5dCK7UOVfm6UGRcE/1i5QhK6Q/CdSBzmAHF9Pt78DMz21?= =?us-ascii?Q?OgTZwh0gK9GGakCTpOApkT75W5dZ39T9AQ88UWvGXv2FKb7AIqSy9rDZBNX1?= =?us-ascii?Q?ev7j3XCiXWzbiUj8N+801m7uKM/YromWVwCvEmRfuPvhdlYBA4FBh9ZLpXVf?= =?us-ascii?Q?PeTDKZju88fV3ZadEGeQOERNPmHkYXL1vB3yXUzKnxUvLR5I23cSPYB4XenB?= =?us-ascii?Q?GDLE9pHImJd2Lab1fyw40DVWlYDvJYwnicTP4YOEwdfYtpxOc0/cHsob88Wf?= =?us-ascii?Q?NtImhlJoZD0rhjn1mhVyRl1z04Pg49LtJn1G03UyNdBxmREmvtFH65RZY05u?= =?us-ascii?Q?1ZujwSWTQypTYr7FqpYCOXZgxZdLSotpUHIlC/5pupr7sdlriUOY3kSpijBh?= =?us-ascii?Q?+uqegdagzx9et2FjH2kr6uJo6IHf2/Gz5FYDk9jt6F2GSJE9m5ei3UnP4Pbf?= =?us-ascii?Q?+Dqlol+xLjffZuxLEipfGiJ3X59uZi+sxLMO7SveoRGe8G/CpuyZ0faVTwHd?= =?us-ascii?Q?yx2CmecT5umHrNcyxVqA83lslxtgIzod7Snptg4N7EwvnYcLbmtFO2ZOTpT/?= =?us-ascii?Q?utuuN3Is?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 11f5ab6d-172c-4a65-5bd1-08d8c3f135ad X-MS-Exchange-CrossTenant-AuthSource: CY4PR10MB1718.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2021 01:00:03.0222 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: rga/amoKbgTsDAXa4HM8H/pAYiKbwQ1uWI141JaIEC2NmuZQB/1LeP9inldO2jDy3l0LpOhuntoV8XZftmeik582lAbkHSP5ohWqca+SyNw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1001MB2246 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,ankur.a.arora@oracle.com X-Gm-Message-State: gkEk1MfEsvvQzPdDmdTCveBgx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1611882183; bh=CXNalx704ijWd1zkS4RWYk8Bt7MoYFDrXZdPH3dvkfw=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=LUgDHMb7laXh+n982O1tF+H80poG8Pkbpnn+m5u0JyBYzZYb/Rek+W/UUqFyHoiu5mp l03VOmlHqK0FmJgDH3hX8RWZN1K1S4mugjKF1KbwtWrvqRK0J+Q+EgVK/ha6B2qECQveJ b6aKqX3VRVycly33pRs5zxvBwpL9PS1XlLI= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Introduce UnplugCpus() which maps each APIC ID being unplugged onto the hardware ID of the processor and informs PiSmmCpuDxeSmm of removal by calling EFI_SMM_CPU_SERVICE_PROTOCOL.RemoveProcessor(). With this change we handle the first phase of unplug where we collect the CPUs that need to be unplugged and mark them for removal in SMM data structures. Cc: Laszlo Ersek Cc: Jordan Justen Cc: Ard Biesheuvel Cc: Igor Mammedov Cc: Boris Ostrovsky Cc: Aaron Young Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3132 Signed-off-by: Ankur Arora --- OvmfPkg/CpuHotplugSmm/CpuHotplug.c | 84 ++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 84 insertions(+) diff --git a/OvmfPkg/CpuHotplugSmm/CpuHotplug.c b/OvmfPkg/CpuHotplugSmm/Cpu= Hotplug.c index 05b1f8cb63a6..70d69f6ed65b 100644 --- a/OvmfPkg/CpuHotplugSmm/CpuHotplug.c +++ b/OvmfPkg/CpuHotplugSmm/CpuHotplug.c @@ -188,6 +188,88 @@ RevokeNewSlot: } =20 /** + Process to be hot-unplugged CPUs, per QemuCpuhpCollectApicIds(). + + For each such CPU, report the CPU to PiSmmCpuDxeSmm via + EFI_SMM_CPU_SERVICE_PROTOCOL. If the to be hot-unplugged CPU is + unknown, skip it silently. + + @param[in] ToUnplugApicIds The APIC IDs of the CPUs that are about to= be + hot-unplugged. + + @param[in] ToUnplugCount The number of filled-in APIC IDs in + ToUnplugApicIds. + + @retval EFI_SUCCESS Known APIC IDs have been removed from SMM = data + structures. + + @return Error codes propagated from + mMmCpuService->RemoveProcessor(). + +**/ +STATIC +EFI_STATUS +UnplugCpus ( + IN APIC_ID *ToUnplugApicIds, + IN UINT32 ToUnplugCount + ) +{ + EFI_STATUS Status; + UINT32 ToUnplugIdx; + UINTN ProcessorNum; + + ToUnplugIdx =3D 0; + while (ToUnplugIdx < ToUnplugCount) { + APIC_ID RemoveApicId; + + RemoveApicId =3D ToUnplugApicIds[ToUnplugIdx]; + + // + // mCpuHotPlugData->ApicId maps ProcessorNum -> ApicId. Use it to find + // the ProcessorNum for the APIC ID to be removed. + // + for (ProcessorNum =3D 0; + ProcessorNum < mCpuHotPlugData->ArrayLength; + ProcessorNum++) { + if (mCpuHotPlugData->ApicId[ProcessorNum] =3D=3D RemoveApicId) { + break; + } + } + + // + // Ignore the unplug if APIC ID not found + // + if (ProcessorNum =3D=3D mCpuHotPlugData->ArrayLength) { + DEBUG ((DEBUG_INFO, "%a: did not find APIC ID " FMT_APIC_ID + " to unplug\n", __FUNCTION__, RemoveApicId)); + ToUnplugIdx++; + continue; + } + + // + // Mark ProcessorNum for removal from SMM data structures + // + Status =3D mMmCpuService->RemoveProcessor (mMmCpuService, ProcessorNum= ); + + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: RemoveProcessor(" FMT_APIC_ID "): %r\n", + __FUNCTION__, RemoveApicId, Status)); + goto Fatal; + } + + ToUnplugIdx++; + } + + // + // We've removed this set of APIC IDs from SMM data structures. + // + return EFI_SUCCESS; + +Fatal: + return Status; +} + +/** CPU Hotplug MMI handler function. =20 This is a root MMI handler. @@ -303,6 +385,8 @@ CpuHotplugMmi ( =20 if (PluggedCount > 0) { Status =3D ProcessHotAddedCpus (mPluggedApicIds, PluggedCount); + } else if (ToUnplugCount > 0) { + Status =3D UnplugCpus (mToUnplugApicIds, ToUnplugCount); } =20 if (EFI_ERROR(Status)) { --=20 2.9.3 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#70877): https://edk2.groups.io/g/devel/message/70877 Mute This Topic: https://groups.io/mt/80199964/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-