From nobody Thu Nov 14 17:06:06 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+71915+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+71915+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 1613978396256389.00393091151443; Sun, 21 Feb 2021 23:19:56 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id chqeYY1788612xfqFzcOXozx; Sun, 21 Feb 2021 23:19:54 -0800 X-Received: from aserp2120.oracle.com (aserp2120.oracle.com [141.146.126.78]) by mx.groups.io with SMTP id smtpd.web12.31930.1613978389308722014 for ; Sun, 21 Feb 2021 23:19:49 -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 11M7Dv4f131242; Mon, 22 Feb 2021 07:19:46 GMT X-Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 36ttcm2kea-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 22 Feb 2021 07:19:46 +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 11M7GNIN155898; Mon, 22 Feb 2021 07:19:45 GMT X-Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2176.outbound.protection.outlook.com [104.47.59.176]) by userp3030.oracle.com with ESMTP id 36ucbvqk4f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 22 Feb 2021 07:19:45 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UpZWeUaddvqwPQwqAh8/3HSOjIXrvi7rNf7Op9GELZLaJT7/stj2oJFNz+IR2phqY8KbpPEG46/Ye0whhaKg/bpU+fuz8dQzgSVELIXZ5I6TYNLxfRbbGMVF7ssplqqds1x6iBq/CQXf2pML78H+sskfSzPizmEYc/7/7rLteE9gvKtdxFUK6Qs/ziJmCnPXNXjaoj/e1Bw2boxyMIwhraXHxBE9HifLV2MBeoU//W5R+Z3kf+vD7cCZEFhYcf+BQrXCGqKmOsAq6sYotUBt3xWJw1uxR/tBtIVlD9NCHKhS0rk/ioUccOouovs/FnOUeCL0aIm3AB0d50MHHtrDug== 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=LzATsUXOtO2tyolujm5gPjZRml3oRtgFkccyRTcCjt4t29sv+Ve19KhkxF4YLW7JJKwEW/T+kMpCS2QE+aKhca246/4+taZHr//3+GEsySZrOPLzKwVg7C12auyq1B4dMM6RWQmwneT4BzyL+18T5/fLU+3p5U56ZZDYwMIjyEJy8A7C8TZcRGi0Ek8KCO5z7XIhEmUNpQS9qLEM2badWAeuuWfoB/ky7aEY+PmexCxvX/oKvVq478SniU62AWU4Vh0CZPtWqngw9H9iTo4VCwRmM2XRPHdU2l4s8kyTM9uNWtEmmFQtd7nN+MCi90D64YvzJhs9KvUUMVuWePaqNw== 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 BYAPR10MB3191.namprd10.prod.outlook.com (2603:10b6:a03:14f::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3868.29; Mon, 22 Feb 2021 07:19:42 +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.033; Mon, 22 Feb 2021 07:19:42 +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 v8 04/10] OvmfPkg/CpuHotplugSmm: introduce UnplugCpus() Date: Sun, 21 Feb 2021 23:19:22 -0800 Message-Id: <20210222071928.1401820-5-ankur.a.arora@oracle.com> In-Reply-To: <20210222071928.1401820-1-ankur.a.arora@oracle.com> References: <20210222071928.1401820-1-ankur.a.arora@oracle.com> X-Originating-IP: [148.87.23.11] X-ClientProxiedBy: MWHPR17CA0065.namprd17.prod.outlook.com (2603:10b6:300:93::27) 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.11) by MWHPR17CA0065.namprd17.prod.outlook.com (2603:10b6:300:93::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3868.27 via Frontend Transport; Mon, 22 Feb 2021 07:19:41 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 888238dc-774e-47e8-ee49-08d8d7023938 X-MS-TrafficTypeDiagnostic: BYAPR10MB3191: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X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3GQHXwlyISgRPLwmoiUKTwL2FF//zldd6blH7aWFgs0N7RnjgxwQaSN4BKSf?= =?us-ascii?Q?jcihaY/SLSiS/Glx6MkLemZLfSzMD4hjqRbAm0OUzHATw/Pv8ZeKIad0AJ4P?= =?us-ascii?Q?Zd78sjmFvHibTp1hqaNJSvzY?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 888238dc-774e-47e8-ee49-08d8d7023938 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR10MB4605.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Feb 2021 07:19:42.4675 (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: HOxMZ44QpF6MnZmO+yml46uC1qz/ddSrzWhpoEgb9GUAl0K2wbTJR8jK6AQKPLcjnxE5AfBQBe5nYX1ukDiwTOUsni0Ykc2Lu7gVJeOUT6U= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3191 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: S1Q7DJKtlW533dlWByNb1wn1x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1613978394; bh=FBidQ8vDv/s06vozTuNSKisKvFFdbuoeCmHqa6PjjSc=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=ocB/+MsAnlw1wReyXaxLaodYVtAjecpo44qt7SuwaTQWbitheA6k8bdsRQIT1HyfFKz 0zwue5lcTB1Fwk1NXVX/wl73r/m8NAjNCs1PUk/hj003ybOCBTiTk2XUNabMndvBZh6C2 FuUN73MRp1AiQ6Ib9h3IYOg5vjxRzL3VM+8= 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 Reviewed-by: Laszlo Ersek --- 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 (#71915): https://edk2.groups.io/g/devel/message/71915 Mute This Topic: https://groups.io/mt/80819859/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-