From nobody Thu Nov 14 17:04:12 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+71833+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+71833+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 1613725507234224.8839556458788; Fri, 19 Feb 2021 01:05:07 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id mGwSYY1788612xk6elic6MRg; Fri, 19 Feb 2021 01:05:06 -0800 X-Received: from userp2130.oracle.com (userp2130.oracle.com [156.151.31.86]) by mx.groups.io with SMTP id smtpd.web12.6144.1613725506144600680 for ; Fri, 19 Feb 2021 01:05:06 -0800 X-Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 11J952fx093498; Fri, 19 Feb 2021 09:05:02 GMT X-Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 36p66r8rdt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 19 Feb 2021 09:05:02 +0000 X-Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 11J8uJSF131491; Fri, 19 Feb 2021 09:05:01 GMT X-Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2177.outbound.protection.outlook.com [104.47.55.177]) by aserp3020.oracle.com with ESMTP id 36prp2pa12-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 19 Feb 2021 09:05:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lpOMPKX0vBjLJ3Pl4iW1WexB0Rjv9zT343TY0ZnNarHEAz+4lYNScN/33AtYbQFH0Fb6iiYQlPDPMu3e9u2Dqmk7i2eee+l3SohUn9xHzefLuSZ6i2wD2RhMX7KbgDcBIZ0g1+AO20wK+oPugIXMNAwkm7EiN7xKhbeWgTB37XDEQJbPGnjWudgIgw3AD1nQhsa40ykSj1WP48XptR0gXQE9kECFzhqI0m0hdPxYNJNZLHbAbWxz+YDoKArKDdSlt5qAgjRk5oA4oNEWiUV8nYo4MfmqABojjsF6iYvlm+jbqkACEVkxLHS5qBctkkkF15UiHVTC9760r+m1zHZ/HA== 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=b2bE66bX2QhqReGUL5sLF1Eh2kfjXO969oJmWd9P7zo=; b=Of9fup8BsWxD7w/NjhT3EDh9PW56H2cHaS6eTG6EHLCtoyi3h5XguGMLhAykyav8bhLWLIyOSiIRs7gW5lwZ9DwLP5mp+1JeLoXWgxxoLkG/TP6twJwRdLfrSvDjX3nMMEcZdLyi+YLnearcEz3A4GfIvOniwMEAcgoZKUwE8RWYxY+j0FaZ7PWiXpUMa0hVp7clq/CUBB1W6uKDHsZT+lfxnCxyZFEAX7k40DuBgQ9mTB0qtn68YPumFHvYa2yd5/2E1wUGhAQgCWWCfTYG+S6afL/2i4pjzVsdmBNGqgcXhSbk6FoI7pbq8bJ4Id399v8adwtCdI/T9nGuy0j93A== 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 SJ0PR10MB4605.namprd10.prod.outlook.com (2603:10b6:a03:2d9::24) by BYAPR10MB3605.namprd10.prod.outlook.com (2603:10b6:a03:129::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.27; Fri, 19 Feb 2021 09:04:58 +0000 X-Received: from SJ0PR10MB4605.namprd10.prod.outlook.com ([fe80::a021:790:7ce6:6f16]) by SJ0PR10MB4605.namprd10.prod.outlook.com ([fe80::a021:790:7ce6:6f16%6]) with mapi id 15.20.3868.029; Fri, 19 Feb 2021 09:04:58 +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 v7 04/10] OvmfPkg/CpuHotplugSmm: introduce UnplugCpus() Date: Fri, 19 Feb 2021 01:04:38 -0800 Message-Id: <20210219090444.1332380-5-ankur.a.arora@oracle.com> In-Reply-To: <20210219090444.1332380-1-ankur.a.arora@oracle.com> References: <20210219090444.1332380-1-ankur.a.arora@oracle.com> X-Originating-IP: [148.87.23.5] X-ClientProxiedBy: MWHPR13CA0004.namprd13.prod.outlook.com (2603:10b6:300:16::14) To SJ0PR10MB4605.namprd10.prod.outlook.com (2603:10b6:a03:2d9::24) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Received: from prion.us.oracle.com (148.87.23.5) by MWHPR13CA0004.namprd13.prod.outlook.com (2603:10b6:300:16::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.8 via Frontend Transport; Fri, 19 Feb 2021 09:04:57 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a0bb102f-2608-405c-5544-08d8d4b56eac X-MS-TrafficTypeDiagnostic: BYAPR10MB3605: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderAD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ii?Q?IAy3e+RNUXtxk7ImbRqn2Maqo4wk0Fveb5NtyMtH8j+/vvB21YtJUbRhtHbc?= =?us-ascii?Q?u57r+UOXbY/gr4ZLyZGAPHC9iXCVKKDdwLhzCMBuB6Z6gUpH0W1F9wJ6g+ht?= =?us-ascii?Q?BVuixpy6kQErVog8sBJPeJvA?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a0bb102f-2608-405c-5544-08d8d4b56eac X-MS-Exchange-CrossTenant-AuthSource: SJ0PR10MB4605.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Feb 2021 09:04:58.5943 (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: kAn1JVcEdPeXhMR94wcjNylE+a32wwAiruKiK6sG2ZyyLyB6vO0gQISwnB26dUuiBcnU2xIuN0pN74keYnm3tlgQpc/pv00RFQe1bJ9rNik= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3605 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: 7DXd68reDmMuBAS7D34qZMMTx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1613725506; bh=jz9wJCt2U6/aI/um0kae9yaMIoNBZ5igbzA6yBJ4eh0=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=NYYS7WDrFBUHODzTlT9niCgZ1ngnW4rDNfk+Bb/ZpgsSX64DayI3axgEht6/bZf4RC/ 8l7MicJVIVb/yF5fyXU5kPgtOuH8bbaqyDMWg12gGKIJJHjQE7K6fJ5i75KK5idLDQ3zo 9A8cADoGNkBxIXSqbd1CWEwD6xcLmmGpCjM= 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 --- Notes: Addresses these review comments from v6: (1) Drop the empty line in the comment block around UnplugCpus(). (2) Make the "did not find APIC ID" DEBUG_VERBOSE instead of DEBUG_INF= O. (3) Un-Indented ("Outdented") the line following the comment "Ignore t= he unplug if APIC ID. (4) Remove the empty line between Status assignment and check. (5) Drop the "goto Fatal" logic and just return Status directly. (6) Handle both Plugging and Unplugging of CPUs in one go. (7) Also nest the EFI_STATUS check. OvmfPkg/CpuHotplugSmm/CpuHotplug.c | 84 ++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 84 insertions(+) diff --git a/OvmfPkg/CpuHotplugSmm/CpuHotplug.c b/OvmfPkg/CpuHotplugSmm/Cpu= Hotplug.c index 3192bfea1f15..f07b5072749a 100644 --- a/OvmfPkg/CpuHotplugSmm/CpuHotplug.c +++ b/OvmfPkg/CpuHotplugSmm/CpuHotplug.c @@ -188,6 +188,83 @@ 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_VERBOSE, "%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)); + return Status; + } + + ToUnplugIdx++; + } + + // + // We've removed this set of APIC IDs from SMM data structures. + // + return EFI_SUCCESS; +} + +/** CPU Hotplug MMI handler function. =20 This is a root MMI handler. @@ -309,6 +386,13 @@ CpuHotplugMmi ( } } =20 + if (ToUnplugCount > 0) { + Status =3D UnplugCpus (mToUnplugApicIds, ToUnplugCount); + if (EFI_ERROR (Status)) { + goto Fatal; + } + } + // // We've handled this MMI. // --=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 (#71833): https://edk2.groups.io/g/devel/message/71833 Mute This Topic: https://groups.io/mt/80751397/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-