From nobody Thu Nov 14 22:47:37 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+72706+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+72706+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 16155304452051018.6747982456727; Thu, 11 Mar 2021 22:27:25 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id l1QFYY1788612xJlenwQjYXT; Thu, 11 Mar 2021 22:27:24 -0800 X-Received: from aserp2120.oracle.com (aserp2120.oracle.com [141.146.126.78]) by mx.groups.io with SMTP id smtpd.web08.4833.1615530436464209442 for ; Thu, 11 Mar 2021 22:27:16 -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 12C68p0B167414; Fri, 12 Mar 2021 06:27:13 GMT X-Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 3741pmrya7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Mar 2021 06:27:13 +0000 X-Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 12C6PAsM055220; Fri, 12 Mar 2021 06:27:12 GMT X-Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam07lp2049.outbound.protection.outlook.com [104.47.56.49]) by userp3020.oracle.com with ESMTP id 374kgw3bq3-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Mar 2021 06:27:11 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JXH1FwJkpCS0OgLvae7LzKjgqeQvv8mt+nkW+zq3uOCjwRQubz7gbnrCGukX3idBUtG/we0eVwUueH7fCTaHmQV0DE51lyU4qQA5B/TxeyjpzYipMq0Ii94gJsZJrzJ3e84NUBo4Kq5Px4+/uX73AF1/9DXSbQy5XrZAXE6OSNnEvf3hiZyYV8SBBMKc9HLmW1LojxqfEF+rp2gEzQkx4Uxcv5OJGXpOrPanuSskEMVHAgULuH8fyy94FofTDcFFxY88M+DViJGx6/v0FSNmZU4vJ9OnUSOKXDW0Qx1eUKsUxZkw2l1qtfeNo65Gvh7yX2woZh39V+mAJQTYsUf6Iw== 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=W4G/9tJMJE8B66m+q8RYiTcxRG8s0I9WhzY+9kdJExs=; b=Wx451MEDGZQpMCB1N0ls6itQWrn99Dhfp31VlVQxBOkLOlxrJYxudHXU8/XamrlnpkFt5fjucycIYrVPBv03xOjzmJhBglfS7S2d/fvQzkuu9UxRdRAyAPDVv9eai3WOKbnuf1Zsd2a/xAM38KonOcoyCz9aR3fSNGumUTABrRB+esCUuXfmFmlA4ByDmK3OmpK2oJnFo/DFUZQF+qe98TcbRfJNkmO4YJZxWxfN5GpkySnsgu7qybYLA6hC1hgw0IHP8bXF12azWMbeKFGdRSOGI8MISuycZmimUHFqAEkkRf1570MjMs8f2z8OhVfX+F2ucRV1KBukhczKQKd2Jg== 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.3890.24; Fri, 12 Mar 2021 06:27:10 +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.3912.030; Fri, 12 Mar 2021 06:27:10 +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 v9 04/10] OvmfPkg/CpuHotplugSmm: introduce UnplugCpus() Date: Thu, 11 Mar 2021 22:26:50 -0800 Message-Id: <20210312062656.2477515-5-ankur.a.arora@oracle.com> In-Reply-To: <20210312062656.2477515-1-ankur.a.arora@oracle.com> References: <20210312062656.2477515-1-ankur.a.arora@oracle.com> X-Originating-IP: [148.87.23.12] X-ClientProxiedBy: MWHPR02CA0018.namprd02.prod.outlook.com (2603:10b6:300:4b::28) 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.12) by MWHPR02CA0018.namprd02.prod.outlook.com (2603:10b6:300:4b::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3912.17 via Frontend Transport; Fri, 12 Mar 2021 06:27:09 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: da5b5b40-798b-4787-b9d3-08d8e51fddd9 X-MS-TrafficTypeDiagnostic: BYAPR10MB3191: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: 99mbkdRbqaYc/5hJK7D0IYH1C71Og9kXgvshatq5kFKTfETWf6j13BXVJfCOMyEZY1F18FUKAGDaAcCTJSOKWjmo9+yTZhHSW5pI+OWex/9Avjp6JLVcQ05ybk2XQwFX1gZnDpB64Y8a5ymbND2jkzOqwIwhOCmq0JWOC5id97KxdKgfGcPH4sKMy2K1J5Jxt47iHaIVNBo48Fgf+4CAn1sF+sSbC7jqmi1idwVX3Qkz6aHSi89dx5dd1nPvF5FoUJZOAhggkq+GGXp38gt6ghF5kwpaQ8NrOqpdRyxwq82PPjUnFjEne0bwZZ+S6OYf5xhN56r6iYnWVLsWL1gnIrIwTKLicXi7xDN1S255TQyiDdPR04/RY8jMvSjB0uedz9U2J1rVlSpktZfzYBwh1O5ZbMI/JEc05zJkIH4VC2g+oAlZ42YGVIIGbUrfx33Xeb+ov2gMD2q+Hn+nO792opH5eeWK/BvgsIaW/vQP8xbfe7WlGkHLB6vcjTrGZzhddjD79iip6jExZlLbzZ+nvb9/7GTwXqTfcpp31aaF2MqqwfDnbdFzJaoh85jrwPyvP1qOND125I+uDsmymGR11622OcY582ZotpFT9BMt1Jw= X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?8fHl3ViafkL0nEUyxohHrgyhpg+4Uew/iEevT1ErDnQFEvIlPqhnpy0b6J83?= =?us-ascii?Q?nXafwfnxNgnprNC6utepoFh+sQpn556zuHdBHQK3qRhkKmVoJds7LIC5bFWQ?= =?us-ascii?Q?QxyfVybNd3SruPmbjxkm6hl0q5nUJYx0A7OvpsPT8t9Qsr0LPzPhn9/Pny0r?= =?us-ascii?Q?GrtpaZ4A6hw2sEycOVwMBJCsk0Kpn04BcHrJnAfY/M+2zKY6XH5YruA5bdJz?= =?us-ascii?Q?/T9HazFGqWAMpSam5XH3yz1w55ps93mmKPoCB4pqywYT833IXVDyDGXnPy/l?= =?us-ascii?Q?J2gvNG7Hrle6wA66NacfyigYRgsj1NkmqdKmz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gjnSkZP+9ep2n+fFR606Hde+BC5UbPL8cAifdHSg94GpZINZekwlfSI+kZ?= =?us-ascii?Q?NUxvD+YvKj3wwrdvw7qMDWsysUVn+bGyIk8z4VO8PQDhAsRfeOW0xCb7L7kU?= =?us-ascii?Q?tUNerGcwx9vmfxT4u7RPKHa+?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: da5b5b40-798b-4787-b9d3-08d8e51fddd9 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR10MB4605.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Mar 2021 06:27:10.3507 (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: WAoyr17h1360igIJ8aqIDFvDCOX+xrT9dZd5kCMi4xr72viullb5F4YwkavuMDEoLRh1OG2sRVvECcCGkaZghMaJJeiLo4ZF1jN80qCFyF8= 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: 4fX7MEQ6PG0I8GhASifuLG10x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1615530444; bh=qLazBEg7+u+fnvxHoaMkC6L+zZNobLOZJxWe0kDpk2I=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=UMK6A78JEpii8buMYkDJL/e/HNrWDA+tb4SR4pVzp4d2XFWXx3JcwlL394DGdXJTDhy elCL51xpnivAfh1/lD1wzVJRpQKnwe2j3+7qiqEcbeOyiRFGTqowZd/NDwCpsX5kDACXB BL+TL3Vu4zSCVd6fwXdhNaQmBjTr0pK3xfo= 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 --- OvmfPkg/CpuHotplugSmm/CpuHotplug.c | 84 ++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 84 insertions(+) diff --git a/OvmfPkg/CpuHotplugSmm/CpuHotplug.c b/OvmfPkg/CpuHotplugSmm/Cpu= Hotplug.c index ee1497b93140..59f000eb7886 100644 --- a/OvmfPkg/CpuHotplugSmm/CpuHotplug.c +++ b/OvmfPkg/CpuHotplugSmm/CpuHotplug.c @@ -190,6 +190,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. @@ -311,6 +388,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 (#72706): https://edk2.groups.io/g/devel/message/72706 Mute This Topic: https://groups.io/mt/81273605/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-