From nobody Thu Nov 14 16:52:49 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+70763+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+70763+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 1611643500006406.5350886601; Mon, 25 Jan 2021 22:45:00 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id NU9BYY1788612xUqvAlskbGf; Mon, 25 Jan 2021 22:44:59 -0800 X-Received: from aserp2130.oracle.com (aserp2130.oracle.com [141.146.126.79]) by mx.groups.io with SMTP id smtpd.web12.8813.1611643499072351104 for ; Mon, 25 Jan 2021 22:44:59 -0800 X-Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 10Q6Z9xO058326; Tue, 26 Jan 2021 06:44:55 GMT X-Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2130.oracle.com with ESMTP id 3689aagu10-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 26 Jan 2021 06:44:55 +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 10Q6a5jR097050; Tue, 26 Jan 2021 06:44:54 GMT X-Received: from nam04-bn8-obe.outbound.protection.outlook.com (mail-bn8nam08lp2046.outbound.protection.outlook.com [104.47.74.46]) by userp3030.oracle.com with ESMTP id 368wqw1qb8-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 26 Jan 2021 06:44:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A+5BvB5l51Posh45g3rEyJRy/WWlLI0i4qPGhYvCMmTCYQCF54J+cpiJo0nYKn/XsisjV8RTLVFZLGWHZfcq0AxbOxU13boWizN0KDaypQcWsqcGuf7MbGZOBbjT2jekVtU7khn7gwzWKq3ZlJGl1Dxz7Z2dAaZ9Xh4Uq5/h9ZxCAqXyB/kEy8lpEvbwhud5td80yQPRC7rjMCWg5qnvamUVi7KGh/69NPF9+kdIdzbsKpFhBeOuPJmyxwl5JBnCbn+D1BMXJ2ZYV3NOx8/JzWZIrSjaxi4LXmXS8N1T2dEZa2UQmcClLIA83uCkZM9pgOE0zMkrZIPR+LfuZTGmSA== 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=FBLD3S6BhhkezmyMo/KU1HdKaOOVbIUwYyMXpKUJ4iw=; b=oAhBuuKSbokCMUMDIshZDggAJAVSTih0fnyCIFrsY0pbnPS5vlGIpTh+jKX39bzdkorn/VLvCXvqYWlAVXp6izLiWAYIHWgxcc/NM6zMPAF7ZFeO3w3cqkmSEhvPxg4T6ESNH/5FkcY71DYeY3Ll31NEB27nroO4ntALBnYLl4WCfoL9Z5OHHAgZ+mzjMNON/EaJDvzI5iKyT+knA6H07WJjulUqYarFReKg2w3Ie5Zuzf/lVQEwX7Tlu/xZm7mceCANQ0ztE8bfx34Gp5Saa18sthxckYBd8kHL/vuDyqnJK76n0HsThpGppej1F+29DWamrvrDuSDpMr8H+D6W7A== 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 CY4PR1001MB2184.namprd10.prod.outlook.com (2603:10b6:910:45::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.14; Tue, 26 Jan 2021 06:44:52 +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.3784.019; Tue, 26 Jan 2021 06:44:52 +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 v5 4/9] OvmfPkg/CpuHotplugSmm: introduce UnplugCpus() Date: Mon, 25 Jan 2021 22:44:35 -0800 Message-Id: <20210126064440.299596-5-ankur.a.arora@oracle.com> In-Reply-To: <20210126064440.299596-1-ankur.a.arora@oracle.com> References: <20210126064440.299596-1-ankur.a.arora@oracle.com> X-Originating-IP: [70.36.60.91] X-ClientProxiedBy: MWHPR18CA0061.namprd18.prod.outlook.com (2603:10b6:300:39::23) To CY4PR10MB1718.namprd10.prod.outlook.com (2603:10b6:910:9::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Received: from localhost.localdomain (70.36.60.91) by MWHPR18CA0061.namprd18.prod.outlook.com (2603:10b6:300:39::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.12 via Frontend Transport; Tue, 26 Jan 2021 06:44:52 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a21edd4d-383f-40cc-62e3-08d8c1c5e273 X-MS-TrafficTypeDiagnostic: CY4PR1001MB2184: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: S/hWt7bQfvCu8U3H28h+WumCoQOPfbBxhbmg9GxAa7N993WcdlhWi7cMNDhQzcqqN1r8TkSJIag1WT119gYza8EFLcgCKKERl7Wk0A6ukbU+L/SXEf3cjWvPLG+Q4vLWb++aOEFRVCKPlOIwpzPmV/iYZ9tZQQGabtokanstszNJoss0CjoybRPhw+Lw207sHWOyy5Bi3LdP0PSHzRZQ2vfZ7ZH/1E79XJ2/Y5Y6c1HAb9++gQbd9eGkM569/fOlIcCl30mo7mefrRKlw4vBq0HQY9MixeID5KKad4sYSiWLnjq0yo9sjf7/GXu8LALPmRv8DEX5sYMq76aZ3EZ3FxfsKFDkMm3ztw4//5xQ3U0s0o5IoCBIw41FNFEeMhnZscYCGLZm4Ezo/JMGMimidyh/qTRD45O6RAIgA+TIWnXo/O1W2cLPYwW//AiMcLz+flWkrzuRpSxpYjMQSkeU9SaB6AhETaVgO1f7A8QYPFlqUyih14hIXLNa1Vdyu706ebohMDFhuaRgRhKYqTnHdw== X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?+Fjm81MKOHt8fjvggUHuGygrHHRboup8PfBPG0HK/rdysz9S/3e4SDZUZEm0?= =?us-ascii?Q?23ovIgYSechDRzt8Okl7JJugV8rldWlltbYCMkAySDmphF0KKmTFrp18tso+?= =?us-ascii?Q?eY9olGoWg+78Wwffk3LfsRWMBsyBuQ4F6EpNPEKmX+bKDscBwQS5mR2D8KiE?= =?us-ascii?Q?aiPCTnzon5TjpHllxaFypprRCRjMfhx8eWJjsDpGfhc+6ceFzkNx5x/H4N5y?= =?us-ascii?Q?5ie9hAgGLkPqwx615tnDkI1ZGl5eG6SsBxkGDmwg8K8M4J6hHdQAYJ2Tai+H?= =?us-ascii?Q?6Eqs648fl4hUOBA5Cr0yIeP9yW/gFY9czF6hyVPbZfGeazi7aMq7pNQ7JR0d?= =?us-ascii?Q?Xu3rA4L9DF8dw9LupvoW84pFFRmm260y5hrJztyeRoXsSpi7WubYwVPTdU4j?= =?us-ascii?Q?XWJtORA0qOkiz+atswFfrhXMrCtm+ojxfdlYwpEMNSuITvhqfBD071jge3lA?= =?us-ascii?Q?bTy7FWkIu1//m66fvbzyC3nwNzNPXRFa2oUNK3vTnf6G78prVCRUWf7MqNKF?= =?us-ascii?Q?8cSD/XagmUEGhU69Er10jJJA6CGsQVh9xp1IvticxGG3csvLO+2xXsgBDV9x?= =?us-ascii?Q?XryZ4njgvr9RiYT8lG+SiqsnXs4uzNXxrqPYKsuuBJlQB4sMAZc3vcB4EBfn?= =?us-ascii?Q?NBD2FafNSMqXxmKVmdzX8ssvPrJubs1ezYjdfuYzPwtnEfJK+g3tdlWcmpIg?= =?us-ascii?Q?Wzq+nqVFZhPapibUWMKTOaQiuhDJyN7QPmQob4wbcmvtb6B7ixR5ayTlxhgK?= =?us-ascii?Q?MO9tTq5RH5KoSO3KTRhaVSKbEfJ0ZFBg4sPALfN5yySt/A8G8I4vV6sHzfJT?= =?us-ascii?Q?Xuxa6oLfMuHDQZOtPFWhVsz7h79arEKZe1XUqo6HK59SgsV9q0CB97p/Ho5k?= =?us-ascii?Q?RoyctFHuhs4dlhgSGw3VwRkHRrD3gOCXT6HGlg2mwazK73bt5GdUeVDjLfED?= =?us-ascii?Q?ylqJZPJFdkBYy4eFSCPyvtE4+AC84L/wsS4ftw/wCa+NXGak7TWvrpGUG7bs?= =?us-ascii?Q?jd4GawyfJt9OHZrmLOUV7K6c5oqKhbA30ehPv6O6o+Cxewy1TmxNytfiHIeR?= =?us-ascii?Q?6nBR6g2m?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a21edd4d-383f-40cc-62e3-08d8c1c5e273 X-MS-Exchange-CrossTenant-AuthSource: CY4PR10MB1718.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jan 2021 06:44:52.7185 (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: 7bvO59ulOpXq3RZAGqlI6REKXn/oVPjDmy2Y7zVsR8i1zIXXlpVOWI2UZJmSncwpvWHQ2bgwBnHMxIwEbp8yzzGEVtBWd9IbvEpqxVB9sjg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1001MB2184 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: 1usp3F1jMHc9FhFgeQgpzipyx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1611643499; bh=B+rQMKgg2IqjVxesz0nnyvn7Jt5F2dm8Pi7tUF2SDjc=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=AvKiDFi7nxHBJ9C7NTbBYwdVbhVjXZwx7DYJRGy0r+cD34zmh8DVgiv1+fKeKE5Aec4 4fF9xslkjsDQHB9KTsDoMJpeGf2lbIwCStt0ACSRR+KPzL7emnwveMfBk3brDsNk9/vps 4nbH6DiNATz1gsmi2epaGtcMiPisWtvVYAU= 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 | 77 ++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 77 insertions(+) diff --git a/OvmfPkg/CpuHotplugSmm/CpuHotplug.c b/OvmfPkg/CpuHotplugSmm/Cpu= Hotplug.c index a5052a501e5a..d165d6ccea0d 100644 --- a/OvmfPkg/CpuHotplugSmm/CpuHotplug.c +++ b/OvmfPkg/CpuHotplugSmm/CpuHotplug.c @@ -182,6 +182,81 @@ Fatal: } =20 /** + CPU Hot-unplug MMI handler function. + + @param[in] UnplugApicIds List of APIC IDs to be unplugged. + + @param[in] ToUnplugCount Count of APIC IDs to be unplugged. + + @retval EFI_SUCCESS Some of the requested APIC IDs will be ho= t-unplugged. + + @retval EFI_INTERRUPT_PENDING Fatal error while hot-plugging. + +**/ +STATIC +EFI_STATUS +EFIAPI +UnplugCpus( + IN APIC_ID *UnplugApicIds, + IN UINT32 ToUnplugCount + ) +{ + EFI_STATUS Status; + UINT32 ToUnplugIdx; + UINTN ProcessorNum; + + ToUnplugIdx =3D 0; + while (ToUnplugIdx < ToUnplugCount) { + APIC_ID RemoveApicId; + + RemoveApicId =3D UnplugApicIds[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 unp= lug\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 handled this unplug. + // + return EFI_SUCCESS; + +Fatal: + return EFI_INTERRUPT_PENDING; +} + +/** CPU Hotplug MMI handler function. =20 This is a root MMI handler. @@ -297,6 +372,8 @@ CpuHotplugMmi ( =20 if (PluggedCount > 0) { Status =3D PlugCpus(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 (#70763): https://edk2.groups.io/g/devel/message/70763 Mute This Topic: https://groups.io/mt/80125311/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-