From nobody Thu Nov 14 05:09:20 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+70760+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+70760+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 1611643498544260.48561388097346; Mon, 25 Jan 2021 22:44:58 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 8psiYY1788612xORgcusge6c; Mon, 25 Jan 2021 22:44:58 -0800 X-Received: from aserp2130.oracle.com (aserp2130.oracle.com [141.146.126.79]) by mx.groups.io with SMTP id smtpd.web12.8811.1611643497571663911 for ; Mon, 25 Jan 2021 22:44:57 -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 10Q6ZvEf058587; Tue, 26 Jan 2021 06:44:53 GMT X-Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2130.oracle.com with ESMTP id 3689aagu0y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 26 Jan 2021 06:44:53 +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 10Q6ZWIw002707; Tue, 26 Jan 2021 06:44:52 GMT X-Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2173.outbound.protection.outlook.com [104.47.58.173]) by userp3020.oracle.com with ESMTP id 368wjqs12b-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 26 Jan 2021 06:44:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JzrzSMuCSt6B3iiGyDMuE462iXQvAGbUu6QiDvyFqbKhsUav/AUXi/hq2qszWsupYb8e4KxDYY75WiQ4FEWG8W1AA/y9X1jCbxqzl8St+yXUVdyBVue0xx9m6FL+5hbHmn74qfiNHmWTFPgi8RRe65ulb7/S9C7aR54a+pZjE7z7enZgiKb54sjQpnEHaGrV/AECmY7474D+nZ0rFy7VQFikGz6tvmReZGhhDyWZNjZbgzUhPtyz18cDTD7y9Q2Cr2lIxnRZuLTADbHvLsSpNgi7BjSCXI5r2jIfQSmM9o/mRypHHhVeD31y+mWVcbgvFl0DZ2ePXVEMizckWW8qYQ== 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=W+6TEr5s+CeCtyf1xQDHO0aOpEswCDJxoKuz5AorSlc=; b=MjvgcuUjTZLuqbsEHYYIOpnT2g+mJXt3M1SRRep5Z1L+apYp0810Z/v8zIg9BnR7YkHe9ZcJo+X12gSHcbjrxj7T9fJ3o5HY9sxY4bCx7Rf3VzTAhwqpDqni2tEC+Hjrxym8I+fcv+LT95uzk17P2HEjL/QZOVTyrcNeb9dF8fWxbTs7gb1hVyZxYVWixiXW5wdteN7JxC0VPbXgrpFxMSNobeWC0arTmAcUyNli5bDS6m5B9EjJvfPUabGty+PNbWozQjNLUFBlsBbGtpYJM9eHbO/Hn24+iy2bXRdRs/6ITpeHh8sNI+mpTrtWDz6NW4zCHTcv2P/Ewlo0x48uWQ== 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 CY4PR10MB1781.namprd10.prod.outlook.com (2603:10b6:910:a::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.11; Tue, 26 Jan 2021 06:44:50 +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:50 +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 1/9] OvmfPkg/CpuHotplugSmm: refactor hotplug logic Date: Mon, 25 Jan 2021 22:44:32 -0800 Message-Id: <20210126064440.299596-2-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:49 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: eb4c4c04-6a93-4a18-9b86-08d8c1c5e100 X-MS-TrafficTypeDiagnostic: CY4PR10MB1781: 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: T71wLEgAlWpwRK/7tcF6/5MFMu1j2MZ+2MGIas7FDt1jLfeeDyxgV2mtMw9uh33MQWwHobJmHk8atN5y/yjQYfEabcmF1tXjd6oEyPjAsrlHBKqTen/1ZtKrzfirEAFZdaAWLEfdUVI08xP+PZLy9nmgpWeYMGGXbYPbpbMkGGb5FS9CEo/wOLguHUhHD78ebZ21WgMYFgmTO2DiPEyNH3OlhXcIHy4jZD2uxz+nQuhZd6d9V5WpKa8BumB2Q8E6gAeq3dTQcNMn+YUVd/bL4P2egZzn/lwgIDgamakotHSZLmO5gDBQFFIiJKvN5vP0bG8aVB+U8kzbKZsYMvhvrWOPENyQ04Q4xWlzlNlfF+5vo+OIQnKaokgNhb3PrXsWt8pb4ImJO+z0wI1J5yHoFY+dzFDsW1QOeYaP8dY67gzn3lA0nxakl12fbrFE/iDrucaH8enBVTcDMTf+SWEXcqMbioAAgCErj9FjHTYQpAQStgzy3qjitX7/LXHIJ+hEEAI9qwuFisEcRdpkZGFoEQ== X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?8N8fRVRz9+WNxKu5/XAoavB7NDGKgvYsr1dbhj4gGtd50AIb1At8PhuUD4mL?= =?us-ascii?Q?eWySzN5yg/qPQMGs97leQE4Y1Rrx5aFygMRQXZZANprqKn8CuPiROpDznXXT?= =?us-ascii?Q?wql6qe73ArgW/QUbs2L8CWEDfPLTYkvcX3LPBr2AYIBY0ZGGTt/Sj8bQW64p?= =?us-ascii?Q?Q3FkjlIuLgDFrRcVPl1/1ElNKUAD+AW/MQM1FYiVoR0573cELcbIlHhja6b8?= =?us-ascii?Q?MHpQJfYq/xk/aTcsPjK6Zf5pgdngQJ8kYSY4yIMaDghiddtdLcbHN6I/vAum?= =?us-ascii?Q?t5lbsFvdN9hlposnFFzqgdcW6K1dOTijONh9PhrdYc5fst7XbG/6KznnU2zT?= =?us-ascii?Q?AtGIxg+Nk76XEIXt6EjYW3WIOdqM5bnZXo1vAav6aK1jNys2hAWn9/rmhzqZ?= =?us-ascii?Q?Pk6aL3V1u9RcoixJpvrR+2DvEoEhh1rCwKt7m5NfUMPyXqo+vbaIe5Y1+xpj?= =?us-ascii?Q?r2t1RbKOaiYJqw+J6pK09wF6hEJ30Nw5kFvGCmS+n1cfMVFBIQeYwp9wsvoa?= =?us-ascii?Q?pfuVNqifVkVFGz74Mx/4PcLt40f6WGXqWz+f/eVY+z3HMH8i/1STMrBrTMNo?= =?us-ascii?Q?Agr6JcEa84F87bOSfQAUbn1QsVQOZypH+9kFaNPaXu/Yk9pNoj/ViJxV/bih?= =?us-ascii?Q?A4+74By61g0EOzz8CAcQrtb5GMHeUI5qhcyXpnyXRwgD91W0HtPnCjVI6KWY?= =?us-ascii?Q?rs/UKInyZMCkDNEqWmwm1yUlGRe4Fy+AeF0BwK/bV7cBkKzH+e5MCi3hvRjC?= =?us-ascii?Q?sJSHt1upH74jbx385bm6eIU2PPnrujF0x5qWscxgJouIZLVAZGZ4X5bJq4Pb?= =?us-ascii?Q?0B9aNvssGq2yo9B+jz0ju/K/5VxALlF/0q4I0QW5fyQgBnRINnCfHvsYzd3W?= =?us-ascii?Q?V3k0J+51HnCTPvuZ4FPxCW0XfRXFIFVKiNd0DkSfP3g/S3HN5JcB5EjA0sLD?= =?us-ascii?Q?SoTe4hWh8l1S/aIGGS+SkAB2WjWV2g3gwXgjSmT/f8KfrKZA7NbCKQQolhf9?= =?us-ascii?Q?qbFp09XKcNXjYdoO5kG06SjmEd/Ry81RYWyUW7iZBSZs+1fqhMnbi3VDb79K?= =?us-ascii?Q?8QEdob7Z?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: eb4c4c04-6a93-4a18-9b86-08d8c1c5e100 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:50.2445 (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: AXBBhGRZ4vU0cGTbuuHdvL/8JR/FDnChDb11UoshxrHNnn/eu79vhuL5PftsNfhkeeXNumlwZlFVckB/0OBYX9HqGk/bAZwTXMDrv2IgPdY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR10MB1781 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: Iq4ZL545RYNUJwUVFlj2MCSKx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1611643498; bh=vY8FbPWNKnoZEzQHgcIrb9+mryblvCwgwfmp5uhFTnc=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=Vqv8NMmZ8QnLV5Fc0qyScxqJlMFJUKC4zQV4dG6KpD2rUa2exxv6XwvPvtAqBTwg6SO BhaizxslmVKRb9xrcAaRIpwe4mppNT4AVaf3k2K1AiWhHBU8yFp/8OXrl/oXjTT4++jf2 MPKbzdVRF9DE2uwMbj8Mpv1U1R/WoMvrct4= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Refactor CpuHotplugMmi() to pull out the CPU hotplug logic into PlugCpus(). This is in preparation for supporting CPU hot-unplug. 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 | 208 ++++++++++++++++++++++-----------= ---- 1 file changed, 123 insertions(+), 85 deletions(-) diff --git a/OvmfPkg/CpuHotplugSmm/CpuHotplug.c b/OvmfPkg/CpuHotplugSmm/Cpu= Hotplug.c index cfe698ed2b5e..a5052a501e5a 100644 --- a/OvmfPkg/CpuHotplugSmm/CpuHotplug.c +++ b/OvmfPkg/CpuHotplugSmm/CpuHotplug.c @@ -62,6 +62,124 @@ STATIC UINT32 mPostSmmPenAddress; // STATIC EFI_HANDLE mDispatchHandle; =20 +/** + CPU Hotplug handler function. + + @param[in] PluggedApicIds List of APIC IDs to be plugged. + + @param[in] PluggedCount Count of APIC IDs to be plugged. + + @retval EFI_SUCCESS Some of the requested APIC IDs were hot-p= lugged. + + @retval EFI_INTERRUPT_PENDING Fatal error while hot-plugging. + +**/ +STATIC +EFI_STATUS +EFIAPI +PlugCpus( + IN APIC_ID *PluggedApicIds, + IN UINT32 PluggedCount + ) +{ + EFI_STATUS Status; + UINT32 PluggedIdx; + UINT32 NewSlot; + + // + // Process hot-added CPUs. + // + // The Post-SMM Pen need not be reinstalled multiple times within a sing= le + // root MMI handling. Even reinstalling once per root MMI is only pruden= ce; + // in theory installing the pen in the driver's entry point function sho= uld + // suffice. + // + SmbaseReinstallPostSmmPen (mPostSmmPenAddress); + + PluggedIdx =3D 0; + NewSlot =3D 0; + while (PluggedIdx < PluggedCount) { + APIC_ID NewApicId; + UINT32 CheckSlot; + UINTN NewProcessorNumberByProtocol; + + NewApicId =3D PluggedApicIds[PluggedIdx]; + + // + // Check if the supposedly hot-added CPU is already known to us. + // + for (CheckSlot =3D 0; + CheckSlot < mCpuHotPlugData->ArrayLength; + CheckSlot++) { + if (mCpuHotPlugData->ApicId[CheckSlot] =3D=3D NewApicId) { + break; + } + } + if (CheckSlot < mCpuHotPlugData->ArrayLength) { + DEBUG ((DEBUG_VERBOSE, "%a: APIC ID " FMT_APIC_ID " was hot-plugged " + "before; ignoring it\n", __FUNCTION__, NewApicId)); + PluggedIdx++; + continue; + } + + // + // Find the first empty slot in CPU_HOT_PLUG_DATA. + // + while (NewSlot < mCpuHotPlugData->ArrayLength && + mCpuHotPlugData->ApicId[NewSlot] !=3D MAX_UINT64) { + NewSlot++; + } + if (NewSlot =3D=3D mCpuHotPlugData->ArrayLength) { + DEBUG ((DEBUG_ERROR, "%a: no room for APIC ID " FMT_APIC_ID "\n", + __FUNCTION__, NewApicId)); + goto Fatal; + } + + // + // Store the APIC ID of the new processor to the slot. + // + mCpuHotPlugData->ApicId[NewSlot] =3D NewApicId; + + // + // Relocate the SMBASE of the new CPU. + // + Status =3D SmbaseRelocate (NewApicId, mCpuHotPlugData->SmBase[NewSlot], + mPostSmmPenAddress); + if (EFI_ERROR (Status)) { + goto RevokeNewSlot; + } + + // + // Add the new CPU with EFI_SMM_CPU_SERVICE_PROTOCOL. + // + Status =3D mMmCpuService->AddProcessor (mMmCpuService, NewApicId, + &NewProcessorNumberByProtocol); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: AddProcessor(" FMT_APIC_ID "): %r\n", + __FUNCTION__, NewApicId, Status)); + goto RevokeNewSlot; + } + + DEBUG ((DEBUG_INFO, "%a: hot-added APIC ID " FMT_APIC_ID ", SMBASE 0x%= Lx, " + "EFI_SMM_CPU_SERVICE_PROTOCOL assigned number %Lu\n", __FUNCTION__, + NewApicId, (UINT64)mCpuHotPlugData->SmBase[NewSlot], + (UINT64)NewProcessorNumberByProtocol)); + + NewSlot++; + PluggedIdx++; + } + + // + // We've handled this hotplug. + // + return EFI_SUCCESS; + +RevokeNewSlot: + mCpuHotPlugData->ApicId[NewSlot] =3D MAX_UINT64; + +Fatal: + return EFI_INTERRUPT_PENDING; +} =20 /** CPU Hotplug MMI handler function. @@ -122,8 +240,6 @@ CpuHotplugMmi ( UINT8 ApmControl; UINT32 PluggedCount; UINT32 ToUnplugCount; - UINT32 PluggedIdx; - UINT32 NewSlot; =20 // // Assert that we are entering this function due to our root MMI handler @@ -179,87 +295,12 @@ CpuHotplugMmi ( goto Fatal; } =20 - // - // Process hot-added CPUs. - // - // The Post-SMM Pen need not be reinstalled multiple times within a sing= le - // root MMI handling. Even reinstalling once per root MMI is only pruden= ce; - // in theory installing the pen in the driver's entry point function sho= uld - // suffice. - // - SmbaseReinstallPostSmmPen (mPostSmmPenAddress); + if (PluggedCount > 0) { + Status =3D PlugCpus(mPluggedApicIds, PluggedCount); + } =20 - PluggedIdx =3D 0; - NewSlot =3D 0; - while (PluggedIdx < PluggedCount) { - APIC_ID NewApicId; - UINT32 CheckSlot; - UINTN NewProcessorNumberByProtocol; - - NewApicId =3D mPluggedApicIds[PluggedIdx]; - - // - // Check if the supposedly hot-added CPU is already known to us. - // - for (CheckSlot =3D 0; - CheckSlot < mCpuHotPlugData->ArrayLength; - CheckSlot++) { - if (mCpuHotPlugData->ApicId[CheckSlot] =3D=3D NewApicId) { - break; - } - } - if (CheckSlot < mCpuHotPlugData->ArrayLength) { - DEBUG ((DEBUG_VERBOSE, "%a: APIC ID " FMT_APIC_ID " was hot-plugged " - "before; ignoring it\n", __FUNCTION__, NewApicId)); - PluggedIdx++; - continue; - } - - // - // Find the first empty slot in CPU_HOT_PLUG_DATA. - // - while (NewSlot < mCpuHotPlugData->ArrayLength && - mCpuHotPlugData->ApicId[NewSlot] !=3D MAX_UINT64) { - NewSlot++; - } - if (NewSlot =3D=3D mCpuHotPlugData->ArrayLength) { - DEBUG ((DEBUG_ERROR, "%a: no room for APIC ID " FMT_APIC_ID "\n", - __FUNCTION__, NewApicId)); - goto Fatal; - } - - // - // Store the APIC ID of the new processor to the slot. - // - mCpuHotPlugData->ApicId[NewSlot] =3D NewApicId; - - // - // Relocate the SMBASE of the new CPU. - // - Status =3D SmbaseRelocate (NewApicId, mCpuHotPlugData->SmBase[NewSlot], - mPostSmmPenAddress); - if (EFI_ERROR (Status)) { - goto RevokeNewSlot; - } - - // - // Add the new CPU with EFI_SMM_CPU_SERVICE_PROTOCOL. - // - Status =3D mMmCpuService->AddProcessor (mMmCpuService, NewApicId, - &NewProcessorNumberByProtocol); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a: AddProcessor(" FMT_APIC_ID "): %r\n", - __FUNCTION__, NewApicId, Status)); - goto RevokeNewSlot; - } - - DEBUG ((DEBUG_INFO, "%a: hot-added APIC ID " FMT_APIC_ID ", SMBASE 0x%= Lx, " - "EFI_SMM_CPU_SERVICE_PROTOCOL assigned number %Lu\n", __FUNCTION__, - NewApicId, (UINT64)mCpuHotPlugData->SmBase[NewSlot], - (UINT64)NewProcessorNumberByProtocol)); - - NewSlot++; - PluggedIdx++; + if (EFI_ERROR(Status)) { + goto Fatal; } =20 // @@ -267,9 +308,6 @@ CpuHotplugMmi ( // return EFI_SUCCESS; =20 -RevokeNewSlot: - mCpuHotPlugData->ApicId[NewSlot] =3D MAX_UINT64; - Fatal: ASSERT (FALSE); CpuDeadLoop (); --=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 (#70760): https://edk2.groups.io/g/devel/message/70760 Mute This Topic: https://groups.io/mt/80125308/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- From nobody Thu Nov 14 05:09:20 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+70761+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+70761+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 1611643499116961.6578110720325; Mon, 25 Jan 2021 22:44:59 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 2I2bYY1788612xW4ByouaM3T; Mon, 25 Jan 2021 22:44:58 -0800 X-Received: from aserp2120.oracle.com (aserp2120.oracle.com [141.146.126.78]) by mx.groups.io with SMTP id smtpd.web11.9039.1611643498015058179 for ; Mon, 25 Jan 2021 22:44:58 -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 10Q6YvET010751; Tue, 26 Jan 2021 06:44:54 GMT X-Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 368brkgkq2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 26 Jan 2021 06:44:54 +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 10Q6a5jP097050; Tue, 26 Jan 2021 06:44:53 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-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 26 Jan 2021 06:44:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QygkeQokqI2QvwY1YnkvQSltKeyfqo7vZpKh8g4VsQWHeqBJf6tQFiKdzLrdZlRVLNTab3qAkyc/vS2VV/AFLHKsqp0p//2U2e6aQaRIRSNrfOv5qmfGix9t4bYQK0mQY4gPoU4khFNIruQAl98j+PZhA72T6/yOHsqmPqr7bSL/VfWEokUeoTPPSP58mFAbVxdvI30ZclVRN6dm5hMqanKOTjIOc8xFCRgutxHWUbycxi4fVvRiqS6oo1zDdrMwsmusWctGimt2fDp7HXrq4VYAxzY3U5/s+UQNMNFBlW/w1m7uJsKIUJfCmfa6XCVUAJe2DTEep0Q2fAffqnFAoA== 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=JO/raDJ4HMvhNf8WxomZMZn/nfw/Qb1vg6iTfoNMO4A=; b=Vy8KYxknFXjQhwRAf/IwfZqnUCfBye+FtjlpB88uBtrr+UUln/rlpD7+LQZlekVzGhclLbiGJQ4tQjYcgCDnWBwtchOeYXHetRx9WvtcJOFV6aQyaTga0i1wvP81W0saFPReQuWhPC5CjslU0uC2VA1PuPYh+YwjMzQ0/RWcmYuSEH4RTRPO/e1g8KNZbRe0Mn/UjxW3z/hinixAc1dJlfxCWSLbfjFRUla35um5WdCR3EbStPW1SIROfavsYZh3RzR9puhEY3BwCd6ryRp7Qnj4z5PNou9AOjiMF6lOWJw3wKfx+UQgiw50D40qRgx/eZqy9JeAwfoOyjlt8vcAhw== 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:51 +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:51 +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 2/9] OvmfPkg/CpuHotplugSmm: collect hot-unplug events Date: Mon, 25 Jan 2021 22:44:33 -0800 Message-Id: <20210126064440.299596-3-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:50 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0e4d1287-b0d1-4ce9-40c5-08d8c1c5e170 X-MS-TrafficTypeDiagnostic: CY4PR1001MB2184: 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: MSZfxnWMTm6o1bSYiL/uv1/qI1aPYo2gpX9ynTO1GJfJtX1tUKyZIebLF78tHlFrgjB4F592qGIqeTbaSQCxgo4phCtyDkeVqPDi5oRqELFaI3JGLgtAKFsNU0fxdsiGnWtcGCgn9YRBQ/11zSSDj/GY1gkbNkdd89+BgM5iODv8dy1XlxL+8dWmXmLPvbXO9JdKi39iUhwIA8qnrUuiLPR7MsryzzYveEKBfnXz8ykWhJycQq24QVF/xdKefETTMbUC9IPHTTg7UXocm2ZORWH2Ojm6xv4NR4A0m0Y2ZlrzMPAfcrm1BkwztNZ4zmU+K73TqgPIgAPYPwSq9LHv5ckrpdFxhQyS5R/MgTrUCXKCTs4YbOVyNLR8tVE8syVm+Z3k0SzcspuhS7Ar46qeDtEZTGOSFv8OwHKvsH55tjfVrfe2lIxrN567zjwivyk5VLqsT7kH8mJ4NmNZ4s7uOPOYdo2tubMmqjpzNOQJjVBiJiOgL4M3IQJ1KC8n8QNIdQ/I1RR73mG4LO5jWDH14g== X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?EOUkZJaJ+CPdOMI4EYZLiKLs6Ut5Rdv0T0EJ/+mFc3RDDZj1bv1BYH1bHP7H?= =?us-ascii?Q?ph1DxODxROB1byAeHyQfsD/VNM/tgQFIehmZBts+60Ofz3Ap/GKMdODatWS/?= =?us-ascii?Q?S1PT2sdsZC6aUvbgCI1jzYJkXesH4ukxpzv8Uapen8zl50fAkOmkeqpLpQaW?= =?us-ascii?Q?7zMJhAROa5gbbyNX9DZrS8fQdws12LO/SZEbMNlrRagrKMaolaMW+5QWJaA6?= =?us-ascii?Q?oWfw22vmV8s12B/3aLMczW0Rj8ecloJlagwEcGu/ZoipkFd/YwyuXRebRE6a?= =?us-ascii?Q?IYc3eYFDqcJxkgRqzFnpmGJZS1QMGuNf89+T0cpdy/ClQvNynXu46Xu9EWgS?= =?us-ascii?Q?M4UgWkHTjGeA/1PYCxo3AhB0ZMi3EerItPXHNZxriMNg/jHZW1hx7WUTCfEW?= =?us-ascii?Q?0mMpKXRN8jMpDbsqhgoVT+RmbuVqFKN+bjeg3t4vGn4n/mUwyy16kF2YCjyz?= =?us-ascii?Q?GqZJ28Mhcd8KhjlklWsAPU3V9OWp37+n3i6ught/ItHeHxV+WzRtIynwXOJ2?= =?us-ascii?Q?pWout6pckSv7aRGlyPWSsXgeRghIMZFb7lFihEAHWShIIvVWJP+3lo6+ahLA?= =?us-ascii?Q?bsEPRuXk3n+01c9GKHXJZXhqsEBJRvZqMCgoesEDdPAM1uMBzY3ZSC/6Yg/d?= =?us-ascii?Q?NCZsQ307HQI5UkYOtw/qnwmXcu3p0ugXIQ/QAeKT9RM3NlDhbUb/PypycVdz?= =?us-ascii?Q?GOkpL2WS47oyukFWSqWz/O9y76PbQLYS/G3feSp2YF2nWX2KuAo2c4+At/v/?= =?us-ascii?Q?bl0w+hUf5Q2jekGAmxPvLvGilVbnnQoNCOxJJE8psuqaKyHgjUEN9ShdNKpa?= =?us-ascii?Q?wnXXemER/AecNTEL6XogrzckMbGOALLE3vUx5JFz9Zl+7GpbPzt1fkfDf+4Z?= =?us-ascii?Q?46m058gcdQZ4jPEUY+al4k+VkQiy9mSO2XXwJobfmJKDS3sAYaliQVFQn7bX?= =?us-ascii?Q?LpJEBcUy/SK53g3wBqeozl69Dw8FOr1eFg6HWcI975v2NDUGPEvxZ6bHMXLD?= =?us-ascii?Q?HaR7GSzuRp0V+ETz9hju2pWXOrZNB9pGidTrazasRVMUMJA28eeCJ7PZB6ay?= =?us-ascii?Q?xJUhNVa1?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0e4d1287-b0d1-4ce9-40c5-08d8c1c5e170 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:50.9942 (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: TiT19wLIOl0808phvOmfLUfmgnT+inQj2HCtGNylNQYzyO9saThZDkE4GiFlr8OXNs8y3GzADVX/V2th7UqR7aGFhB+smFtvumyVzHqJH/w= 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: S1D2WRlmnL9vvpWBslXJZ26Dx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1611643498; bh=pt2F8mBxaY4O5RUnncFiDRvipBFUJXqv6qLxnYI3Wcg=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=aJoPJr3eHh2h/d1ThhLPYTB3ZwdSvzefQF7JJc1RgbOKIy+59LdX0FKpJG+aAw5BRCl CygqjkpCgZ2OzHIml0mbDbpCw0D2EbHKu1p0zYjpZ2Y69HEwtxmQuQTuXvZEISdnmOOEM zGEtejpHoZWcw6s+zpnEZhA2tJ0NVRRSIKA= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Process fw_remove events in QemuCpuhpCollectApicIds() and collect corresponding APIC IDs for CPUs that are being hot-unplugged. In addition, we now ignore CPUs which only have remove set. These CPUs haven't been processed by OSPM yet. This is based on the QEMU hot-unplug protocol documented here: https://lore.kernel.org/qemu-devel/20201204170939.1815522-3-imammedo@redh= at.com/ Also define QEMU_CPUHP_STAT_EJECTED while we are at it. 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/Include/IndustryStandard/QemuCpuHotplug.h | 2 ++ OvmfPkg/CpuHotplugSmm/QemuCpuhp.c | 35 +++++++++++++++++--= ---- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/OvmfPkg/Include/IndustryStandard/QemuCpuHotplug.h b/OvmfPkg/In= clude/IndustryStandard/QemuCpuHotplug.h index a34a6d3fae61..692e3072598c 100644 --- a/OvmfPkg/Include/IndustryStandard/QemuCpuHotplug.h +++ b/OvmfPkg/Include/IndustryStandard/QemuCpuHotplug.h @@ -34,6 +34,8 @@ #define QEMU_CPUHP_STAT_ENABLED BIT0 #define QEMU_CPUHP_STAT_INSERT BIT1 #define QEMU_CPUHP_STAT_REMOVE BIT2 +#define QEMU_CPUHP_STAT_EJECTED BIT3 +#define QEMU_CPUHP_STAT_FW_REMOVE BIT4 =20 #define QEMU_CPUHP_RW_CMD_DATA 0x8 =20 diff --git a/OvmfPkg/CpuHotplugSmm/QemuCpuhp.c b/OvmfPkg/CpuHotplugSmm/Qemu= Cpuhp.c index 8d4a6693c8d6..2dd783ebf42e 100644 --- a/OvmfPkg/CpuHotplugSmm/QemuCpuhp.c +++ b/OvmfPkg/CpuHotplugSmm/QemuCpuhp.c @@ -205,7 +205,7 @@ QemuCpuhpCollectApicIds ( UINT8 CpuStatus; APIC_ID *ExtendIds; UINT32 *ExtendCount; - APIC_ID NewApicId; + APIC_ID OpApicId; =20 // // Write CurrentSelector (which is valid) to the CPU selector register. @@ -245,10 +245,10 @@ QemuCpuhpCollectApicIds ( if ((CpuStatus & QEMU_CPUHP_STAT_INSERT) !=3D 0) { // // The "insert" event guarantees the "enabled" status; plus it exclu= des - // the "remove" event. + // the "fw_remove" event. // if ((CpuStatus & QEMU_CPUHP_STAT_ENABLED) =3D=3D 0 || - (CpuStatus & QEMU_CPUHP_STAT_REMOVE) !=3D 0) { + (CpuStatus & QEMU_CPUHP_STAT_FW_REMOVE) !=3D 0) { DEBUG ((DEBUG_ERROR, "%a: CurrentSelector=3D%u CpuStatus=3D0x%x: " "inconsistent CPU status\n", __FUNCTION__, CurrentSelector, CpuStatus)); @@ -260,12 +260,31 @@ QemuCpuhpCollectApicIds ( =20 ExtendIds =3D PluggedApicIds; ExtendCount =3D PluggedCount; - } else if ((CpuStatus & QEMU_CPUHP_STAT_REMOVE) !=3D 0) { - DEBUG ((DEBUG_VERBOSE, "%a: CurrentSelector=3D%u: remove\n", __FUNCT= ION__, + } else if ((CpuStatus & QEMU_CPUHP_STAT_FW_REMOVE) !=3D 0) { + // + // "fw_remove" event guarantees "enabled". + // + if ((CpuStatus & QEMU_CPUHP_STAT_ENABLED) =3D=3D 0) { + DEBUG ((DEBUG_ERROR, "%a: CurrentSelector=3D%u CpuStatus=3D0x%x: " + "inconsistent CPU status\n", __FUNCTION__, CurrentSelector, + CpuStatus)); + return EFI_PROTOCOL_ERROR; + } + + DEBUG ((DEBUG_VERBOSE, "%a: CurrentSelector=3D%u: fw_remove\n", __FU= NCTION__, CurrentSelector)); =20 ExtendIds =3D ToUnplugApicIds; ExtendCount =3D ToUnplugCount; + } else if ((CpuStatus & QEMU_CPUHP_STAT_REMOVE) !=3D 0) { + // + // Let the OSPM deal with the "remove" event. + // + DEBUG ((DEBUG_INFO, "%a: CurrentSelector=3D%u: remove (ignored)\n", = __FUNCTION__, + CurrentSelector)); + + CurrentSelector++; + continue; } else { DEBUG ((DEBUG_VERBOSE, "%a: CurrentSelector=3D%u: no event\n", __FUNCTION__, CurrentSelector)); @@ -281,10 +300,10 @@ QemuCpuhpCollectApicIds ( return EFI_BUFFER_TOO_SMALL; } QemuCpuhpWriteCommand (MmCpuIo, QEMU_CPUHP_CMD_GET_ARCH_ID); - NewApicId =3D QemuCpuhpReadCommandData (MmCpuIo); + OpApicId =3D QemuCpuhpReadCommandData (MmCpuIo); DEBUG ((DEBUG_VERBOSE, "%a: ApicId=3D" FMT_APIC_ID "\n", __FUNCTION__, - NewApicId)); - ExtendIds[(*ExtendCount)++] =3D NewApicId; + OpApicId, ExtendCount)); + ExtendIds[(*ExtendCount)++] =3D OpApicId; =20 // // We've processed the CPU with (known) pending events, but we must ne= ver --=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 (#70761): https://edk2.groups.io/g/devel/message/70761 Mute This Topic: https://groups.io/mt/80125309/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- From nobody Thu Nov 14 05:09:20 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+70762+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+70762+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 1611643499211691.4594177836809; Mon, 25 Jan 2021 22:44:59 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id qEJlYY1788612xpdM4HrJwUz; Mon, 25 Jan 2021 22:44:58 -0800 X-Received: from userp2130.oracle.com (userp2130.oracle.com [156.151.31.86]) by mx.groups.io with SMTP id smtpd.web12.8812.1611643498248855445 for ; Mon, 25 Jan 2021 22:44:58 -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 10Q6Z79B054283; Tue, 26 Jan 2021 06:44:54 GMT X-Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 368b7qrnuf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 26 Jan 2021 06:44:54 +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 10Q6a5jQ097050; 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-2 (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=nkd0xoHw6qSrNxY2LurZsoK4xAlUJ9PKYkZqZctj6e/QUR2XykyrYJvJ9k0K0vNO2qGOkBqJhhv24vKvjg9E/lv/GWJetr61Ypq+bhuo7JzDfQLQg1PESSgV17rmz1s+C6+Qhct3nRFyAZym2zeeHI0T0CG274ruxz0c++AejBP8JN9uYvyPULsAzs0KfIbbiGsKLF1Lo353PVEKjkMQZSU1JN2rKv5ol0gouJgMANO2l8D3ddIQDUNi0nTcU/1KANX1HREXebNPKjiCNKQ0VnUCSYwAXfNErnmV0V9tX+oiA9q+9y8rPlYEIr820gmssB9dYNAV9bUkSQiU+zj0+A== 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=5EaL+ZxMNT/nlKN0K1jN7X0CrnwOY2RVEUXcZfsweZY=; b=oRMODvJglnVWaDwI19AIzIyqwMTw3YibCMZL9yaSaZAv6ffeD9tn4NNPBij8IsN3mTYFPM1u+ehH0rbemwm7vApxX3cNkHc5Nq+nywqpZLin2877yJttwK3eQdnZ4X0v8JR98y6J6KYF5dsY0/MPCLEU1UtRVZD7VGf/nKg93Mi940LIch9aX/kcUEp4SgxXaoidili4nsRkoGdPL7sG13/4XjSLNspew+osJbPgOHmxTMnpeSKcEdkPprBgKgDZCYJWNAraN7QS8916c1DivheKAfJBVyNaXLmpF4GcOqhLKHvg5WVsEpAc8WkqTN48qz2B6hWkzlmgqsfvcmml8w== 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:51 +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 3/9] OvmfPkg/CpuHotplugSmm: add Qemu Cpu Status helper Date: Mon, 25 Jan 2021 22:44:34 -0800 Message-Id: <20210126064440.299596-4-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:51 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 41aa5cab-edef-4736-dd2a-08d8c1c5e1e3 X-MS-TrafficTypeDiagnostic: CY4PR1001MB2184: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4714; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: 7zqbh09pLnJyY1j2p5Qitpz3L9hes3GFlP5Nb86T54yZZEIG56HG8uPZryto9KVO0ivS8/CFotLDrlGvRL4QRRlJ+VU0gjP5DzvwcYb89MshepHNlZNuCDXgpGWLhf1LNoiGpPAa9ZOhK/q3gIQzcAe0CiwFiaQS2l4n9EFO60y7OYHYNxX4SIrZftIUcslP6qbF0GzLADkBjEacCkkU5RzYlBheXCajpXw6nIG4/4h0HjxVuLq6UM18rFIwvns1ZpG+d3+zuO5YKGZceLkpSsJFc9K52/Bse+VmWJoxB4M6l80H0ubnaDCUj+Y5I5ZXUj/RdhhwHjERVYr+56aDKsZsFMNHGRsioHZKjFyPofXCX51rE31DdYsgrh1wYyyYDbK3FNY5wGrEqJWanyp6nZN8GHMTQgizeFP00zL4gjI78BsCkJGHi33//Hkaeg+MenqjI/HJVJMpx5EFG1V1pufCrJNqYsozqLSXG0YyiuP37OPkrIZQANuEhUWzNI8Wf4sqakiQM8KP0Eep3O5KZA== X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?ae5ertf05/Z6qNr+dZ6i8f3lyfXEbQYMn+vLvBpUC4fLppBm52EM6LT721vJ?= =?us-ascii?Q?q3FD106cNBuYnTDvadevgDRa2bYu4o2M2O57SSAAtAfmmJzGirprAXwxNmCJ?= =?us-ascii?Q?IkIhh8RV7ZhGsSz68K4zTtMdDlszhCikpvgLEPSsHBpbNpLZ81vC0SHXOAKx?= =?us-ascii?Q?V2USEMnfaKoPIytPHdBpsmCs7Mvh9qOb+p/E1RCJ4mHwBVNum1RjwOiOut3Q?= =?us-ascii?Q?/oGf8+nQO0Yi8OxFtuy3zQxwEoKq3ixHMnEHUf+c4fyUpAEmPpsw7NZ59a9E?= =?us-ascii?Q?3+4L118dEphqHsnG/R0Anor2DWZ5nX3JrzcpKbaOHaoD1v7g0qSR7i2D1laZ?= =?us-ascii?Q?8qXEsOMSx5PJNqeNc3dW09kJUNy1FS6/NVMmqJFH3GeS5HrE0WChka+I2jSM?= =?us-ascii?Q?3F4HwU6XiPKv7q28I5u8HMF2t7ATeewRRRbmJIKtobyzYb2lkFBc6SPKuMrh?= =?us-ascii?Q?6XvFTiLUO33qiAhJhMuJ9z8toJVOmbgaLkRbZniVgKzXexTQtFy6y45y7CNS?= =?us-ascii?Q?onHwI1K1ef9GLaZDgg8cqifzM2Yv+OvYZFZa5L41tOr/FfeNedh+h/qVYTzQ?= =?us-ascii?Q?vT0Da5i8yxSOT9Njb6aOiJJMfzCgKPn8RRMmaatPgKLhoewinRuv3DIEJF78?= =?us-ascii?Q?57/h2okcQH9LJS9FemOHOA7t5dKxwCwteEMXyNJdFRe7xQkLJFYB3Z5oSinp?= =?us-ascii?Q?v3xTl+ElsrqCm2erL8xNe+IHlwrD1IXFLu1BlC4XCOwZe9O2MFs/JKMiu6s7?= =?us-ascii?Q?55KnYSMAOnOTdQCnc4eqfVCLjWQjwiU4g54vas55WPLsUBqv9GiJdGOg+6lo?= =?us-ascii?Q?bcCXBOZSLc1KwLm/YfRh9arpx16cXXTvOG3sOHs6gIU8Fv9qWq6oO+RaY6y4?= =?us-ascii?Q?YCYDMNUFSylCDEZVmFHa2AOWIwQ5opICoKQI/+T5RDPTZq+ViP11M6XLk1n4?= =?us-ascii?Q?7+buo/UceCme4nUcqeh2WlGsUHqnia3ISKBNO5wYZcHCBAMARrseBK+gc+EZ?= =?us-ascii?Q?I5YCYMQtDsBWtW11H+0XAEYkE2l4qSNVV30ejlccmePG+RdHYvImfacT+Oda?= =?us-ascii?Q?oXgt+G4b?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 41aa5cab-edef-4736-dd2a-08d8c1c5e1e3 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:51.9248 (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: ysAuM/fONkPtY+5tULDSF0br5h1qD7KKbBUtiO90mEh9T0D5ny3tY1RG/NBGW+TZd56ZKw06zN8r+DG/7zpymQXUFEAO80xBf8vxmT5APB0= 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: VENxP2sOTM82AuwPeZJlqeU8x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1611643498; bh=agVdRaX7Rt6Fucp5s2mqTp/nzvOiVmJF9CLEpRy1km4=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=p5vaNSb4WD3CeY03tErl8dA1jeh58Epv4oxu0VSXX0yiIE0mHpM8efvxNh8gpklaWdh lUUI/fUpJM7Lt0NVArJgD3PM1AA5u8Qf4RVhmRvkK5hDuotl2wS+vQXGGbrbvjMMw3gLt kOIlJ9ewAZvUH84N22pWN2+OBrHqEksnFmI= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Add QemuCpuhpWriteCpuStatus() which will be used to update the QEMU CPU status register. On error, it hangs in a similar fashion as other helper functions. 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/QemuCpuhp.h | 6 ++++++ OvmfPkg/CpuHotplugSmm/QemuCpuhp.c | 22 ++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/OvmfPkg/CpuHotplugSmm/QemuCpuhp.h b/OvmfPkg/CpuHotplugSmm/Qemu= Cpuhp.h index 8adaa0ad91f0..804809846890 100644 --- a/OvmfPkg/CpuHotplugSmm/QemuCpuhp.h +++ b/OvmfPkg/CpuHotplugSmm/QemuCpuhp.h @@ -30,6 +30,12 @@ QemuCpuhpReadCpuStatus ( IN CONST EFI_MM_CPU_IO_PROTOCOL *MmCpuIo ); =20 +VOID +QemuCpuhpWriteCpuStatus ( + IN CONST EFI_MM_CPU_IO_PROTOCOL *MmCpuIo, + IN UINT8 CpuStatus + ); + UINT32 QemuCpuhpReadCommandData ( IN CONST EFI_MM_CPU_IO_PROTOCOL *MmCpuIo diff --git a/OvmfPkg/CpuHotplugSmm/QemuCpuhp.c b/OvmfPkg/CpuHotplugSmm/Qemu= Cpuhp.c index 2dd783ebf42e..c35ae31d2db0 100644 --- a/OvmfPkg/CpuHotplugSmm/QemuCpuhp.c +++ b/OvmfPkg/CpuHotplugSmm/QemuCpuhp.c @@ -67,6 +67,28 @@ QemuCpuhpReadCpuStatus ( return CpuStatus; } =20 +VOID +QemuCpuhpWriteCpuStatus ( + IN CONST EFI_MM_CPU_IO_PROTOCOL *MmCpuIo, + IN UINT8 CpuStatus + ) +{ + EFI_STATUS Status; + + Status =3D MmCpuIo->Io.Write( + MmCpuIo, + MM_IO_UINT8, + ICH9_CPU_HOTPLUG_BASE + QEMU_CPUHP_R_CPU_STAT, + 1, + &CpuStatus + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: %r\n", __FUNCTION__, Status)); + ASSERT (FALSE); + CpuDeadLoop (); + } +} + UINT32 QemuCpuhpReadCommandData ( IN CONST EFI_MM_CPU_IO_PROTOCOL *MmCpuIo --=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 (#70762): https://edk2.groups.io/g/devel/message/70762 Mute This Topic: https://groups.io/mt/80125310/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- From nobody Thu Nov 14 05:09:20 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- From nobody Thu Nov 14 05:09:20 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+70764+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+70764+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 161164350912868.453361888691; Mon, 25 Jan 2021 22:45:09 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id l1qIYY1788612xTmRn6aIVGf; Mon, 25 Jan 2021 22:45:08 -0800 X-Received: from userp2130.oracle.com (userp2130.oracle.com [156.151.31.86]) by mx.groups.io with SMTP id smtpd.web12.8816.1611643503257729971 for ; Mon, 25 Jan 2021 22:45:03 -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 10Q6Z238054252; Tue, 26 Jan 2021 06:44:59 GMT X-Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 368b7qrnuh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 26 Jan 2021 06:44:59 +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 10Q6a686097113; Tue, 26 Jan 2021 06:44:59 GMT X-Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2177.outbound.protection.outlook.com [104.47.59.177]) by userp3030.oracle.com with ESMTP id 368wqw1qcn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 26 Jan 2021 06:44:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V4Cyc0J4mUNMerKfeCLzQLRA7pJ8doppWvAn5BGsuPNSZfC2kFyQ3FDQzHUjV0XyLGQtoyW470fPvnOqCmZtktGi3x1E1TGyPFhbFFCEiTV3kelG1DKfb9y7Fy/oq7S+ljL3tvVkJP99kWJArPyajUBzjOT+LQY84LAeLSiNZQpyKkjLrL6asNOJKY4MlvWbryXj1yGjYPDQXBey+2L8pRLMGgTAS0L+TMZNZ+09fYKCgMzfLVhmi2S1JTCuFpMRh1CRiKyzKyg4VBEedgCaGxI7DcSFqXRQF50mswk6qMBhycbnMAztjNB9xgNU7YLeV9Bt1zAUXLJWOVdKmQbmnw== 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=KruchKDVRnQGahXUBntvFG5pwlD4Eboc4HOu3NfliRc=; b=nKxx1Ycshp7fZWBvXWuNKsMcPAhnZ+owwF+9KO5hrPJyDeY5dDgzXk1sJs5Okq8uRS2cxfICaPQy1fqPWF8st5kQRlxi7mNysHoiZ2xGWnDWyf8IXaHR/Dt4b+ZFv2pLmeX5O5sygyXTRe62P01nvzaamcm6VTVL/e2RqqQyN1V3f70u63pJ5OS0lWYEpTNCDGUpSh0/HRqW1r7CnwsGQ53NXrVLAZIgKmu5E/BgED6/RVikQ42bQt7OEEvLJXRJlEUUZkKXkD6rRfF6T5rQswdQoCIzwoRjgQwSX6Zg4TQAoU5BGnXv5NCGM4AV952qTdDyAmlvfedXpaPRZcduow== 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:53 +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:53 +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 5/9] OvmfPkg/CpuHotplugSmm: define CPU_HOT_EJECT_DATA Date: Mon, 25 Jan 2021 22:44:36 -0800 Message-Id: <20210126064440.299596-6-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: c43cfe29-780c-4395-92aa-08d8c1c5e2eb X-MS-TrafficTypeDiagnostic: CY4PR1001MB2184: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: EagMOm5Ayu/aB496+OXcWJr3F6mfzbkuJTdiGfD7q9rmtqzfrl0Dihn4kUPXisInIdiGzi624eF11QPBJVVZ2G6DcpDzpLzWK4mYKtVO3OtOgf9onQETiwQrvPnPmuY7KWrSX0UhamlZ1qTIBoX4gun+M8VyBKlxl4x1m1Mt7bwUwC1PzLJwBt+NnLzPzEBLDSkabaJ3gMM7P7T6vlEJ/SsLEWArU0B4T3THk64KYzDEHHxa3+oPYnSdm+Z500ty+QLqcWGEC6d7QIcWk3NFnZxG9WzPPBhoobN4ALji6hLnHRnKqs92qkXr69zVRspyQwuKd7GaSyS0f38wr98bheq3FqyZU18C4v8C+iTh24FokZJRTuSrLON+9r1xWIEc+k9BqEC5Gds01F3rX9R0kMLoxvW2+GfBibmIejf0bkw454zicYimh+wYvgxuzvCb2eaMmpIfF3CLrnAE82B1V1atZCwtojlr03Vv6xvgTJ201Gimuo/o/5xwKYgblhSUQsghWx7je9vVG0ru+KZJLA== X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?pEn+beZ8Hh77S1+QI9QvCE7dDwVFEf1uOlHmBxvOV/8h2DeN9duBj1LLzyNS?= =?us-ascii?Q?Kb2ZDk/Ab40q2S/R2v2FFYWVxAbbElnM75X+erjW3m3pQo6nR0cENLCScz8v?= =?us-ascii?Q?O/mQ1txuSm6fdc67zzv7hQ7JdqzsNOU8pvM+UC2XQlUy+CUjiR3BuipDYFkX?= =?us-ascii?Q?PVyXS0mTPXfAkltG+b/YL58MLzZ/wmMS7GX/ly75E/CvA3s3G8Kix8GjZAnR?= =?us-ascii?Q?kfgjYbURlq13yOfDj1jFp9Ped8vx5ZF6BudZmdBj8LXX3VUxsFSlf+jHeOs8?= =?us-ascii?Q?C3Hx/IbjQqezZrSkVIdYBRZ8hOSRsCF97vcBxtenhyui2nascqkTSl3K9cDo?= =?us-ascii?Q?Nr/S4BQEBFhpWa2dDr11snDkhM+WxZsULPzfnFMZgnCPe8fuf8otq+m+STBJ?= =?us-ascii?Q?ucXCPe7V6RVvSaB9h0RLsJBfy+49aQCdUkxG908lUlvhLKBcOMiatgjOYYq8?= =?us-ascii?Q?mx/A5vlNG8Fy4xuCwBcyz/iQpnm5ZDKd5NBo3M/O6XeHZNhpoZgyd31htwUr?= =?us-ascii?Q?fx+PzzoEERWfLtEFFV6kzv8iagXIociuRMKntxbQcyx+YeQHaeXax1rt+AoU?= =?us-ascii?Q?uDzS3hOPxW/idZcOWzgEqyOMpeMT/v9Yn6M7X4PhdWr/i0FQj//A1slsl+ln?= =?us-ascii?Q?FkRMMMEHydw2dETxMl0VLUemGVty3rzeG3prEcd8nl9OLAeMi8HKEKodd7SR?= =?us-ascii?Q?m/D1PZHmHo/wADIzNK7VsX51lj3hAnWVvK80BHwTegsnyR+biE39i/YxUhye?= =?us-ascii?Q?xM2peMFPfbGtzyQdWJqtHEqz166TUHTHH1MIjTGidLjojTP4cZI5O9eSOkCU?= =?us-ascii?Q?44vrp/clYJM8pP014k+oyMHADFGkaaxwN1eFyaY3ob5HRYMioPzYBZWu/KDK?= =?us-ascii?Q?+jjKEvuwtSLIPitKgV/ym87EmZkM4GvjR4eYVbMCS/Oyuxr+63Wg1JBGw0A8?= =?us-ascii?Q?C95OQUKJ2N2kmcoJM7rnKgTu5vVAmiPq0+gyo8NUI6r5zngHDO8k5LrZctRd?= =?us-ascii?Q?YdiY8kaA3LmZCiRuRnvD0gvn+SZmtd//gzBsoHmT48Xqp86Fs0ylQfzqPG14?= =?us-ascii?Q?tLudD7n2?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: c43cfe29-780c-4395-92aa-08d8c1c5e2eb 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:53.4961 (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: 80Fh+uvPvUSy1g0U1RxcQPfmMopROv/4FyRnly7dTYHUr24rOVTKUPB0tqHw+wiazrLY18XAu/vFVWIJQhe+fI6sGS92XiTCy7mf+2PuR+M= 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: jo9gRImeUegKT06PPeWmAVbsx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1611643508; bh=anxpWbushDT+dqQmDeqHG1EDRtOtb5VUDEVyevwZ9jQ=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=bpG5yRJn3ZKP70xzEXAvhWtrWvsS8ACW9+ZFDLpeWtZH1uLk/R0hBXKtqqWU69rtpZi n+xPaue8XRiZofSRpUWMSG79MxAagMAyBo0ksn2AqEXgOw00cSWYg2rz6pE+G+YgZJA5l 87WCu3/UcSw1Q0J1U/ZZmnlZ8yUP9Mojx8I= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Define CPU_HOT_EJECT_DATA and add PCD PcdCpuHotEjectDataAddress, which will be used to share CPU ejection state between OvmfPkg/CpuHotPlugSmm and PiSmmCpuDxeSmm. 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/OvmfPkg.dec | 10 ++++++++++ OvmfPkg/CpuHotplugSmm/CpuHotplugSmm.inf | 1 + OvmfPkg/Include/Library/CpuHotEjectData.h | 32 +++++++++++++++++++++++++++= ++++ 3 files changed, 43 insertions(+) create mode 100644 OvmfPkg/Include/Library/CpuHotEjectData.h diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec index 4348bb45c64a..e79ff28465e3 100644 --- a/OvmfPkg/OvmfPkg.dec +++ b/OvmfPkg/OvmfPkg.dec @@ -106,6 +106,10 @@ [LibraryClasses] # XenPlatformLib|Include/Library/XenPlatformLib.h =20 + ## @libraryclass Share CPU hot-eject state + # + CpuHotEjectData|Include/Library/CpuHotEjectData.h + [Guids] gUefiOvmfPkgTokenSpaceGuid =3D {0x93bb96af, 0xb9f2, 0x4eb8, {= 0x94, 0x62, 0xe0, 0xba, 0x74, 0x56, 0x42, 0x36}} gEfiXenInfoGuid =3D {0xd3b46f3b, 0xd441, 0x1244, {= 0x9a, 0x12, 0x0, 0x12, 0x27, 0x3f, 0xc1, 0x4d}} @@ -352,6 +356,12 @@ [PcdsDynamic, PcdsDynamicEx] # This PCD is only accessed if PcdSmmSmramRequire is TRUE (see below). gUefiOvmfPkgTokenSpaceGuid.PcdQ35SmramAtDefaultSmbase|FALSE|BOOLEAN|0x34 =20 + ## This PCD adds a communication channel between PiSmmCpuDxe and + # CpuHotplugSmm. + # + # Only accessed if PcdCpuHotPlugSupport is TRUE + gUefiOvmfPkgTokenSpaceGuid.PcdCpuHotEjectDataAddress|0|UINT64|0x46 + [PcdsFeatureFlag] gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderPciTranslation|TRUE|BOOLEAN|0= x1c gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderMmioTranslation|FALSE|BOOLEAN= |0x1d diff --git a/OvmfPkg/CpuHotplugSmm/CpuHotplugSmm.inf b/OvmfPkg/CpuHotplugSm= m/CpuHotplugSmm.inf index 04322b0d7855..e08b572ef169 100644 --- a/OvmfPkg/CpuHotplugSmm/CpuHotplugSmm.inf +++ b/OvmfPkg/CpuHotplugSmm/CpuHotplugSmm.inf @@ -54,6 +54,7 @@ [Protocols] =20 [Pcd] gUefiCpuPkgTokenSpaceGuid.PcdCpuHotPlugDataAddress ## CON= SUMES + gUefiOvmfPkgTokenSpaceGuid.PcdCpuHotEjectDataAddress ## CON= SUMES gUefiOvmfPkgTokenSpaceGuid.PcdQ35SmramAtDefaultSmbase ## CON= SUMES =20 [FeaturePcd] diff --git a/OvmfPkg/Include/Library/CpuHotEjectData.h b/OvmfPkg/Include/Li= brary/CpuHotEjectData.h new file mode 100644 index 000000000000..839ddad6d8f8 --- /dev/null +++ b/OvmfPkg/Include/Library/CpuHotEjectData.h @@ -0,0 +1,32 @@ +/** @file + Definition for a structure sharing state for CPU hot-eject. + + Copyright (C) 2021, Oracle Corporation. + + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef _CPU_HOT_EJECT_DATA_H_ +#define _CPU_HOT_EJECT_DATA_H_ + +typedef +VOID +(EFIAPI *CPU_HOT_EJECT_FN)( + IN UINTN ProcessorNum + ); + +#define CPU_EJECT_INVALID (MAX_UINT64) +#define CPU_EJECT_WORKER (MAX_UINT64-1) + +#define CPU_HOT_EJECT_DATA_REVISION_1 0x00000001 + +typedef struct { + UINT32 Revision; // Used for version identification f= or this structure + UINT32 ArrayLength; // Number of entries for the ApicIdM= ap array + + UINT64 *ApicIdMap; // Pointer to CpuIndex->ApicId map f= or pending ejects + CPU_HOT_EJECT_FN Handler; // Handler to do the CPU ejection + UINT64 Reserved; +} CPU_HOT_EJECT_DATA; + +#endif /* _CPU_HOT_EJECT_DATA_H_ */ --=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 (#70764): https://edk2.groups.io/g/devel/message/70764 Mute This Topic: https://groups.io/mt/80125312/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- From nobody Thu Nov 14 05:09:20 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+70765+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+70765+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 1611643510387607.3500044290194; Mon, 25 Jan 2021 22:45:10 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id cOZqYY1788612x0eDjuPHH1a; Mon, 25 Jan 2021 22:45:10 -0800 X-Received: from aserp2130.oracle.com (aserp2130.oracle.com [141.146.126.79]) by mx.groups.io with SMTP id smtpd.web11.9043.1611643503816550178 for ; Mon, 25 Jan 2021 22:45:03 -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 10Q6Z9xP058326; Tue, 26 Jan 2021 06:45:00 GMT X-Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2130.oracle.com with ESMTP id 3689aagu12-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 26 Jan 2021 06:45:00 +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 10Q6a687097113; Tue, 26 Jan 2021 06:44:59 GMT X-Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2177.outbound.protection.outlook.com [104.47.59.177]) by userp3030.oracle.com with ESMTP id 368wqw1qcn-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 26 Jan 2021 06:44:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jhm3+bPLOlHVD4T8v562b2Iaj0BYeaz27UvlV7Ci84r75Z2R9NwKD3SgXS8kYkWKFoxlBJM0FaHHvy6wLak30ZMwEApoUeyTnvXhkluzi1P6gyU9vrulcaE3TNtTEx4we7Xf2aMSxHAn8XzxSwWG7SaUDymA8MrTJZcuAwpQpUIXZrhLydjlCtihx2IHbBiiBaiAvM6yAOg4efu70aNXCXD38F7uelP5tO+b7DHieYo0NwGTxG0Gr+cAqm/vMoXOKF9Rssj/8MO3ZMWW5SMK12ISNMpUgH9lJwP3+khFk/CSmPAUIJLODWWpAir3m54t1tkGR5PZ5cT6FbdKZsFj0A== 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=rEZIou7OuIqHe0dmF1Nzoj9skeKqs1rwnMMR2GxDFXQ=; b=L0vQjVdcuSGSXR3fIlN38Trd5CMkGfoXvxH08K+e9DbryPZnZA2+IJKKzBoH71sPHJMOVjp2RT1/QzOTY54IRHJUtYE+fC6CKuokQj8s0lLIXPNfYl9ttriIDGILACagVkqCM2iwUyXZ6XY/ggl4hAFaPBPqeGbA/RkNqmCVYEladrEarzIK0hHO1KowoZKK+bnv9v6V+dEqU3Cmq+A4qHSUCs+TNmHF0jpJiyLX1qgNTXE8B4iBnfjq61yVf2R/AAY4Ltf0+JiIgCQfMVwg/heCc+VCvWd/btBMjtExFbGyKZ4z/00wgp0VanKJcgxNGv7UZNObC/X/uROksV9NQA== 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:57 +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:57 +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 6/9] OvmfPkg/SmmCpuFeaturesLib: init CPU ejection state Date: Mon, 25 Jan 2021 22:44:37 -0800 Message-Id: <20210126064440.299596-7-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:53 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 04e365dc-2676-4935-37ec-08d8c1c5e35b X-MS-TrafficTypeDiagnostic: CY4PR1001MB2184: 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: TC1f5VWkZwgyD7++XLvEyDNGhqjNppvQKYdHJpa98VbZxrcwKfvpYFmfr6E0/ofzfQvxmYHj03XuA8z00EVBww/bgkYAUHeiMGjIsNgF2EFwRzLnud/YQIWDlrgQOm8cD4w8enMrQURLG8Sc0zgje503bzk0l0K2OUEyGy89zvxmHpqfSd5CSqXGPxPn9Ttxtd/ZNhN1hNpBZzBmrsg4IZX0LKIdOgNfU3FpmghcxoqLsOkOESY9+MRBhVBCrnUbKajFRPYJG6y9VW0YpncPcHOjcd13MHuWhlim3zFZANJOuLtIHlKmweON59YcAbHh9XmsYzlvsaoug0nb/omJQj8AFqJtXoyb6QHsxtvPYmqfmkWrl5jEUnr8giGqe35TqDtxKAugMaIGLtpko6Hq2+dU4ApwJG74ygy1fWSF8uoXeBKR+FgU8oj+y91uDUD8p+AtA/6HskcR9OzgqEeN1aa1iGOA8AIv29NbnAaICL94isoReXk6YlvU0OU28f9QE1KTpXjswwAPY866i1nDTg== X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?mUxaPq6IPX7753f2lbSPJ/qPRJGn1L/Qr429xYjKqTo6/zZx9879nnmZ9Glz?= =?us-ascii?Q?Nqq6mZx1vM0FhFea+c3HLlBrcrdjons+l+5eQ5Lc7tu+G0w0cmx7R799LHi8?= =?us-ascii?Q?XnHM9H4bYYfeObw/afnQGjt5Is1uqlslq1zNOXDm1RTCXrSmvJKqWuSe4pOO?= =?us-ascii?Q?a5NBWMz/QzKB4i0MXJGr2Z5lNdvoYmb/fswglf+XtqZLe3w4sFfedRIvDqQO?= =?us-ascii?Q?iT4gmKq/JgtRLkVRPvbTByzNoGoU4t4A7qBvir1NmBAPBencwJQFV7IpZreR?= =?us-ascii?Q?JWvGCy7DeVJeSXxjR26g3dYzNNqnMvBpCWNxqBEsYbWGlfx0bXN7wDdNuido?= =?us-ascii?Q?8aUaU31WaND1ANt9dN1Rm7BUd0taVR/yVdyjs2jtI4VJm5qt2mvmh/kVchV6?= =?us-ascii?Q?59bgY0l520mAu9D4QN9IT+bcIXSF1+AEoDc5Cwh/6JqsFPjciTviX3QiN3QT?= =?us-ascii?Q?vky/kausL3R9toNEbW6MkP75PqqcDnVK0m1DDW3nF0HPCqcba1W6kTwi11mH?= =?us-ascii?Q?V8BUdpT04/EAcH1K7u+tGFojquyZyJsLxMJMMQ9Bwdgk2f9XZhL3Ux0MULXf?= =?us-ascii?Q?VrAi6dzebLTmKHyhPi57Kvqof2wCR14pruLTY36ZwggDiYnTjOlOBbueYIe6?= =?us-ascii?Q?T0zpjhsKa87rCJ25RcWAP68biOmGzRweESumFhaIfMqFDlXU0xrrSckw2R+0?= =?us-ascii?Q?JcwKa9pk3yX1+6M9Xi38G9/L+VnGV7AKab4OU2RwgdFg1RUI+kKI4Iicirp6?= =?us-ascii?Q?kiSImMlEJhSZznMkXmvf8eVgzQgHgYUoFCRxFYip2QUvGV3ltqEDK4BLK4vx?= =?us-ascii?Q?KSb14KLQ/k7ghDsEsR/FVnQT6qBLETuA5SYxHMUJSON21X9GttcoMT298ESJ?= =?us-ascii?Q?kYYaX6GKgeRq9T+zY2UQPkfQtgg2fBSRWfBcKn8iofRV3Fxyypbmx9TolXp8?= =?us-ascii?Q?q49dkbfXf/HF4K3TEDcKWoc2VOlzRs9FbnpkQ71N3NfuwJolWGkKJEeUzk1C?= =?us-ascii?Q?LNCcA+we+EEivalsIig0+4SK61qFWb9UhqThtJO68Nl/v5wUG74N4HTGL8Qp?= =?us-ascii?Q?hikw+fxq?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 04e365dc-2676-4935-37ec-08d8c1c5e35b 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:54.1988 (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: g1w6MMBH7QRzSlL5YmMC/B2qk4U2s+bVKu0w8d/GCkrkWBTi6A7r9DkQuqPfWuL+REHvd5+Z0UisweFn/VN6LYpBPbX9J7u82JWfm0KJ1Bg= 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: nPqL6WLI2Gw1IP00mrmU2tEGx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1611643510; bh=2SoNLVs8iznbrpVYl2jeDO5c34Ji+DPtkb3QcyD9ZnA=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=NQ4Obo8ygLBOPd4VfnkLxvXYxoTa6B7PtwpaJ7h35GlpjHTue2RbkNuaFGHwEHVaU1c hnwGz4uhAI1wwgZLpX8vbtO8PbjVBxYDQ6b0IQ72r7SMFCm98iFPDPQJcc56DZo4Nprki KFHwfNByI9LPxRBZl4M7kHMb/chSe/YMGgo= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Init CPU_HOT_EJECT_DATA, which will be used to share CPU ejection state between SmmCpuFeaturesLib (via PiSmmCpuDxeSmm) and CpuHotPlugSmm. CpuHotplugSmm also sets up the CPU ejection mechanism via CPU_HOT_EJECT_DATA->Handler. Additionally, expose CPU_HOT_EJECT_DATA via PcdCpuHotEjectDataAddress. 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 --- .../SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf | 3 + .../Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c | 68 ++++++++++++++++++= ++++ 2 files changed, 71 insertions(+) diff --git a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf b/Ovmf= Pkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf index 97a10afb6e27..32c63722ee62 100644 --- a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf +++ b/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf @@ -35,4 +35,7 @@ [LibraryClasses] UefiBootServicesTableLib =20 [Pcd] + gUefiCpuPkgTokenSpaceGuid.PcdCpuHotPlugSupport + gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber + gUefiOvmfPkgTokenSpaceGuid.PcdCpuHotEjectDataAddress gUefiOvmfPkgTokenSpaceGuid.PcdQ35SmramAtDefaultSmbase diff --git a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c b/OvmfPk= g/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c index 7ef7ed98342e..5c9cdc6710e4 100644 --- a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c +++ b/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c @@ -14,7 +14,9 @@ #include #include #include +#include // AllocatePool() #include +#include #include #include #include @@ -171,6 +173,60 @@ SmmCpuFeaturesHookReturnFromSmm ( return OriginalInstructionPointer; } =20 +GLOBAL_REMOVE_IF_UNREFERENCED +CPU_HOT_EJECT_DATA *mCpuHotEjectData =3D NULL; + +/** + This function initializes CpuHotEjectData if PcdCpuHotPlugSupport is + enabled and if more than 1 CPU is configured. + + Also sets up the corresponding PcdCpuHotEjectDataAddress. +**/ +STATIC +VOID +EFIAPI +SmmCpuFeaturesSmmInitHotEject( + VOID + ) +{ + UINT32 mMaxNumberOfCpus; + EFI_STATUS Status; + + if (!FeaturePcdGet (PcdCpuHotPlugSupport)) { + return; + } + + // PcdCpuHotPlugSupport =3D> PcdCpuMaxLogicalProcessorNumber + mMaxNumberOfCpus =3D PcdGet32 (PcdCpuMaxLogicalProcessorNumber); + + // No spare CPUs to eject + if (mMaxNumberOfCpus =3D=3D 1) { + return; + } + + mCpuHotEjectData =3D + (CPU_HOT_EJECT_DATA *)AllocatePool (sizeof (*mCpuHotEjectData)); + ASSERT (mCpuHotEjectData !=3D NULL); + + // + // Allocate buffer for pointers to array in CPU_HOT_EJECT_DATA. + // + mCpuHotEjectData->Revision =3D CPU_HOT_EJECT_DATA_REVISION_1; // Revis= ion + mCpuHotEjectData->ArrayLength =3D mMaxNumberOfCpus; // Array= Length of APIC ID + mCpuHotEjectData->ApicIdMap =3D // CpuIn= dex -> APIC ID map + (UINT64 *)AllocatePool (sizeof (UINT64) * mCpuHotEjectData->ArrayLengt= h); + mCpuHotEjectData->Handler =3D NULL; // Hot E= ject handler + mCpuHotEjectData->Handler =3D 0; // Reser= ved + + ASSERT (mCpuHotEjectData->ApicIdMap !=3D NULL); + + // + // Expose address of CPU Hot eject Data structure + // + Status =3D PcdSet64S (PcdCpuHotEjectDataAddress, (UINT64)(VOID *)mCpuHot= EjectData); + ASSERT_EFI_ERROR (Status); +} + /** Hook point in normal execution mode that allows the one CPU that was ele= cted as monarch during System Management Mode initialization to perform addit= ional @@ -188,6 +244,9 @@ SmmCpuFeaturesSmmRelocationComplete ( UINTN MapPagesBase; UINTN MapPagesCount; =20 + + SmmCpuFeaturesSmmInitHotEject(); + if (!MemEncryptSevIsEnabled ()) { return; } @@ -375,6 +434,15 @@ SmmCpuFeaturesRendezvousExit ( IN UINTN CpuIndex ) { + // + // CPU Hot eject not enabled. + // + if (mCpuHotEjectData =3D=3D NULL || + mCpuHotEjectData->Handler =3D=3D NULL) { + return; + } + + mCpuHotEjectData->Handler(CpuIndex); } =20 /** --=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 (#70765): https://edk2.groups.io/g/devel/message/70765 Mute This Topic: https://groups.io/mt/80125313/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- From nobody Thu Nov 14 05:09:20 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+70766+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+70766+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 1611643510813895.0472119138601; Mon, 25 Jan 2021 22:45:10 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 37kjYY1788612xzXzNM4hhgA; Mon, 25 Jan 2021 22:45:10 -0800 X-Received: from userp2130.oracle.com (userp2130.oracle.com [156.151.31.86]) by mx.groups.io with SMTP id smtpd.web09.8843.1611643504107837252 for ; Mon, 25 Jan 2021 22:45:04 -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 10Q6XsGM053694; Tue, 26 Jan 2021 06:45:00 GMT X-Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 368b7qrnuk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 26 Jan 2021 06:45:00 +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 10Q6a688097113; Tue, 26 Jan 2021 06:45:00 GMT X-Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2177.outbound.protection.outlook.com [104.47.59.177]) by userp3030.oracle.com with ESMTP id 368wqw1qcn-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 26 Jan 2021 06:45:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=G3MvQ4KWGEKVIcqiRH8Qffa0H73HkSrerjCkJ4YMrNcocgIsLi8DPBP7uu78IMShSwULSycj3hRAtxVQ8Yp3FXUQYMynLiRxBN/lm6E4avLxtwCZG4H9AUZdj7/OIi9LZJotWdvQ3IzcElyXKrQSsg/cWEyijDANkc35ixgeX1FQb/ggBwAUUNaHjFCpsNMTysBvxO8lh9EnrKbeiLCmbqd3QP+tD6HTI/MSFiBwU7iav9qEoIvoGS3G2uOOkO22hKUQv95fDNT7h9RdVn/Pk5/eO7rECRIz5LuLGlu8n+cwSJxA1L9f4eQD51XOEAzBCt/3tmpmJkg5IFht6I1ZBw== 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=DGWFRrEXVuBMKJZS5HEyR44jBu4frhxHnnWSVDSsWsc=; b=jatxgsc7RLgXdraHuI93MMEWIPTPFCJeKiB/JyXYFYgE7P7/P5/hGzVFXEPOF1IFewqiOJ5zHYhvvUvZc0+ldukwc/KrYFQNNmtxGd8BV4LkSCXgT958ikk/+aQQvFsQSWTA3kqtA/gAlNe6J/d8HvQW293YdE6CklagnaaeYK8Qmsh/7D/4tIZNl5L+5SibbrjqhA7YxazYa2twjGNwD0exkbabbJLj1aJy1ghjjlbm2INE3XINb92MLsk1BrdzJtCbKS3MJn9wc1gs4zT96dGgynBJS+HsgGAH/uvS4YJrqKu+9KkPjQqqPaOFg27f29zfjaY6A3ovy0CtOQDeMw== 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:57 +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:57 +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 7/9] OvmfPkg/CpuHotplugSmm: add CpuEject() Date: Mon, 25 Jan 2021 22:44:38 -0800 Message-Id: <20210126064440.299596-8-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:54 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 48f426e5-9121-4c47-0013-08d8c1c5e3c4 X-MS-TrafficTypeDiagnostic: CY4PR1001MB2184: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: Zwz4Kaf9hLCldwrfZ1I0GJ99THtrulNCfkAXMQHO9D+zoVRkrO/4IDaR+Se7EgJGxfiiBzCJ86kvd1q+vomXSId8F5s0DbuVrU/N1QDxMx/FaBtTGn0Y25hOgtPyciqtIW4bFKH4yMCtYS59gftwzgdMhKL6PpIc7zabS1VCy+ESMUSLh5oD/LQ0evhwcSGDZajaJqAp5eYFNM0/11wdfbQwjuX06zzZKuA4uKtNnS46rziRrFSkDreNugneCqzZm4dw/XlOUoVIrA4BGEJOQ+PBeGMLpVKylwr+Xa/8p5bdf1l9mACCzf50Ov/184yW/yjAkcKoqA47A5RfvtMCqGnABC82dm9mDzuBGWe7C5dGz1+7kdKvrXRvjocpoNYgrXAdMjCXTX8v0AVJOL6P3AVLY4Ea/NLxVD/oehmYOvYpbofdg2qfxTn/xLHF3YmLmsuiipzR1BmLEgPNviZjYpmGiKO1SHbMpPGVzVXcnQaOGWfLkxSymfrY00/MnCwUs9aYEDzRSWGYMozp3fDxDQ== X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?v95tPwGgCZlal9KbNdqYBKUZd3RjIb8DRP7cRq4kZkEpdpu3aDPuM0QbwO/w?= =?us-ascii?Q?Br2G7YhoXfBKphz3cpd6i3tcpnbxXoFBTNXM3CXhA4yoX00pWiHjZBBniVMi?= =?us-ascii?Q?rZvFe6O7zYn19oLfpZ2m2Bt0saoC+xRj/KzUgiWO2J5cwvWgx9jYE+idy5Ix?= =?us-ascii?Q?Z+nLhWN1+pFntRWqyqdDtxdaTFnIG5MSOmZk0ZUQZQj0HP2ImAPzyAFnp0Yn?= =?us-ascii?Q?L/Fkj9wh+6OSpfPqmWS2keXyx9OvFwrzqV53+cAPBvfnECK/1/MAnkPLF9T1?= =?us-ascii?Q?tQGTxdavZ6+ObYuYZxeChQLLA7It6XF73PiKvQY82hBX3eZZenuPs2mUs8lT?= =?us-ascii?Q?AVmVAwN72pVItT+sx/dvwTe7uiPEa8gBjfRRkFBGUCPeTcRVfxtXqIw/TjNG?= =?us-ascii?Q?GXfWVH3foJvs9k6paev9BdWfn5K6TazxOuEqCPcLMgvKY4t29eQvN60mFDAC?= =?us-ascii?Q?hgojvprHdEpKP5mbTKG2DB2WhqfSRh8wULsVOis2Ge/qsTzXPLn6Uu0xroqb?= =?us-ascii?Q?uRQAOM/XfGLkmRYvoqLgtNqtd7ZoD+jbTA+aZsfItKfCBXNXWmS8nTrPuZ1+?= =?us-ascii?Q?0ZxxDmNPnLdtiwsS0uTtC9kyfzYNbSNRPMGRkN6zRZTZ92IMk7mDvVCzLuK3?= =?us-ascii?Q?EnGF3bTWcxVM+ujfGI1wkfUX7sB0s/46yoqgA9iMCHSmzOA0jjWWBUkh1fYU?= =?us-ascii?Q?ajsgju++4FFgFWXEZ9D175bF4SCJ/WtbJVA3D2pkJhOENsfMb7ppCWzQ6Yq6?= =?us-ascii?Q?HjC8vG1t8aTchZ3XsrzsOSkXPIgfr15tWZX9zQQwfjCKSUoTmmfLwb5Titlr?= =?us-ascii?Q?g5PjxllSWRRUJzyqAcPe3mqRNsrLdZVlCbiFRJv1nh/eusbvVLS7QU4QarWm?= =?us-ascii?Q?RD3bsK8U5zCSz3Ykh0Tg8QdeadbjD/m+bFGVRa1Na+x6ebh4lcdZw7zgU/Fz?= =?us-ascii?Q?5kC/12yuFo3ee4bWOmFCWkdRXvOw9XwjHA9cchJMRujlktOoRujq2DJkZ31/?= =?us-ascii?Q?CNb3RKNkRf6ZgSxUPdtiH05IJwStIpL3pwBhroMX9GSO2lQz9ofOWK0j9DMD?= =?us-ascii?Q?auibLwBO?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 48f426e5-9121-4c47-0013-08d8c1c5e3c4 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:55.1144 (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: 8VfexRuORZ7mbjFwsqV5WYFDtn93q8Yz3e0qcT9j44H2cSnyIG7baeQLdcxSFRIADKAkB7ybXRk1+3PZRwjaW5C8hZclttfwsKDUaKGCdtU= 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: bMKtuOvhjChkZC3iILZkMg2zx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1611643510; bh=diICOlP6k/U/ZPhYd4rl7BPX7iGqNQJ7XwRvKfPuwjM=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=Gy7WUJLEzzRMU8NlGMqqMfBinaCgKUkWBEoPBSBD1yUBtL8q7bKpnD/WNZSfb64OWjq iLfVhNPH/qdEUbUNHzfkyrXkLIFzFCozzVU+rpx9TkBe2UEiD49ZzIMM5rd3n/l9925Wo 9q+ebBdmqCyIOEpQDovgIXridEiSBSglxV8= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Add CpuEject(), which handles the CPU ejection, and provides a holding area for said CPUs. It is called via SmmCpuFeaturesRendezvousExit(), at the tail end of the SMI handling. Also UnplugCpus() now stashes APIC IDs of CPUs which need to be ejected in CPU_HOT_EJECT_DATA.ApicIdMap. These are used by CpuEject() to identify such CPUs. 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 | 94 ++++++++++++++++++++++++++++++++++= +++- 1 file changed, 93 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/CpuHotplugSmm/CpuHotplug.c b/OvmfPkg/CpuHotplugSmm/Cpu= Hotplug.c index d165d6ccea0d..99e6845a12d9 100644 --- a/OvmfPkg/CpuHotplugSmm/CpuHotplug.c +++ b/OvmfPkg/CpuHotplugSmm/CpuHotplug.c @@ -14,6 +14,7 @@ #include // gMmst #include // PcdGetBool() #include // SafeUintnSub() +#include // CPU_HOT_EJECT_DATA #include // EFI_MM_CPU_IO_PROTOCOL #include // EFI_SMM_CPU_SERVICE_PROTOC= OL #include // EFI_STATUS @@ -32,11 +33,12 @@ STATIC EFI_MM_CPU_IO_PROTOCOL *mMmCpuIo; // STATIC EFI_SMM_CPU_SERVICE_PROTOCOL *mMmCpuService; // -// This structure is a communication side-channel between the +// These structures serve as communication side-channels between the // EFI_SMM_CPU_SERVICE_PROTOCOL consumer (i.e., this driver) and provider // (i.e., PiSmmCpuDxeSmm). // STATIC CPU_HOT_PLUG_DATA *mCpuHotPlugData; +STATIC CPU_HOT_EJECT_DATA *mCpuHotEjectData; // // SMRAM arrays for fetching the APIC IDs of processors with pending event= s (of // known event types), for the time of just one MMI. @@ -182,6 +184,43 @@ Fatal: } =20 /** + CPU Hot-eject handler function. + + If the executing CPU is not being ejected: NOP. + If the executing CPU is being ejected: wait in a CpuDeadLoop() + until ejected. + + @param[in] ProcessorNum Index of executing CPU. +**/ +VOID +EFIAPI +CpuEject( + IN UINTN ProcessorNum + ) +{ + // + // APIC ID is UINT32, but mCpuHotEjectData->ApicIdMap[] is UINT64 + // so use UINT64 throughout. + // + UINT64 ApicId; + + ApicId =3D mCpuHotEjectData->ApicIdMap[ProcessorNum]; + if (ApicId =3D=3D CPU_EJECT_INVALID) { + return; + } + + // + // CPU(s) being unplugged get here from SmmCpuFeaturesSmiRendezvousExit() + // after having been cleared to exit the SMI by the monarch and thus have + // no SMM processing remaining. + // + // Given that we cannot allow them to escape to the guest, we pen them + // here until the SMM monarch tells the HW to unplug them. + // + CpuDeadLoop (); +} + +/** CPU Hot-unplug MMI handler function. =20 @param[in] UnplugApicIds List of APIC IDs to be unplugged. @@ -203,9 +242,11 @@ UnplugCpus( { EFI_STATUS Status; UINT32 ToUnplugIdx; + UINT32 EjectCount; UINTN ProcessorNum; =20 ToUnplugIdx =3D 0; + EjectCount =3D 0; while (ToUnplugIdx < ToUnplugCount) { APIC_ID RemoveApicId; =20 @@ -242,11 +283,35 @@ UnplugCpus( DEBUG ((DEBUG_ERROR, "%a: RemoveProcessor(" FMT_APIC_ID "): %r\n", __FUNCTION__, RemoveApicId, Status)); goto Fatal; + } else { + // + // Stash the APIC IDs so we can do the actual unplug later. + // + if (mCpuHotEjectData->ApicIdMap[ProcessorNum] !=3D CPU_EJECT_INVALID= ) { + // + // Since ProcessorNum and APIC-ID map 1-1, so a valid + // mCpuHotEjectData->ApicIdMap[ProcessorNum] means something + // is horribly wrong. + // + DEBUG ((DEBUG_ERROR, "%a: ProcessorNum %u maps to %llx, cannot map= to " FMT_APIC_ID "\n", + __FUNCTION__, ProcessorNum, mCpuHotEjectData->ApicIdMap[Processo= rNum], RemoveApicId)); + goto Fatal; + } + + mCpuHotEjectData->ApicIdMap[ProcessorNum] =3D (UINT64)RemoveApicId; + EjectCount++; } =20 ToUnplugIdx++; } =20 + if (EjectCount !=3D 0) { + // + // We have processors to be ejected; install the handler. + // + mCpuHotEjectData->Handler =3D CpuEject; + } + // // We've handled this unplug. // @@ -445,7 +510,13 @@ CpuHotplugEntry ( // Our DEPEX on EFI_SMM_CPU_SERVICE_PROTOCOL guarantees that PiSmmCpuDxe= Smm // has pointed PcdCpuHotPlugDataAddress to CPU_HOT_PLUG_DATA in SMRAM. // + // Additionally, CPU Hot-unplug is available only if CPU Hotplug is, so + // the same DEPEX also guarantees that PcdCpuHotEjectDataAddress points + // to CPU_HOT_EJECT_DATA in SMRAM. + // mCpuHotPlugData =3D (VOID *)(UINTN)PcdGet64 (PcdCpuHotPlugDataAddress); + mCpuHotEjectData =3D (VOID *)(UINTN)PcdGet64 (PcdCpuHotEjectDataAddress); + if (mCpuHotPlugData =3D=3D NULL) { Status =3D EFI_NOT_FOUND; DEBUG ((DEBUG_ERROR, "%a: CPU_HOT_PLUG_DATA: %r\n", __FUNCTION__, Stat= us)); @@ -457,6 +528,9 @@ CpuHotplugEntry ( if (mCpuHotPlugData->ArrayLength =3D=3D 1) { return EFI_UNSUPPORTED; } + ASSERT (mCpuHotEjectData && + (mCpuHotPlugData->ArrayLength =3D=3D mCpuHotEjectData->ArrayLeng= th)); + // // Allocate the data structures that depend on the possible CPU count. // @@ -539,6 +613,24 @@ CpuHotplugEntry ( // SmbaseInstallFirstSmiHandler (); =20 + if (mCpuHotEjectData) { + UINT32 Idx; + // + // For CPU ejection we need to map ProcessorNum -> APIC_ID. By the time + // we do that, however, the Processor's APIC ID has already been remov= ed + // from SMM data structures. So we will use mCpuHotEjectData->ApicIdMap + // to map from ProcessorNum -> APIC_ID. + // + for (Idx =3D 0; Idx < mCpuHotEjectData->ArrayLength; Idx++) { + mCpuHotEjectData->ApicIdMap[Idx] =3D CPU_EJECT_INVALID; + } + + // + // Wait to init the handler until an ejection is warranted + // + mCpuHotEjectData->Handler =3D NULL; + } + return EFI_SUCCESS; =20 ReleasePostSmmPen: --=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 (#70766): https://edk2.groups.io/g/devel/message/70766 Mute This Topic: https://groups.io/mt/80125314/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- From nobody Thu Nov 14 05:09:20 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+70767+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+70767+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 1611643511955569.6181809104975; Mon, 25 Jan 2021 22:45:11 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id hIQJYY1788612xQ3P5Duc2eW; Mon, 25 Jan 2021 22:45:11 -0800 X-Received: from aserp2130.oracle.com (aserp2130.oracle.com [141.146.126.79]) by mx.groups.io with SMTP id smtpd.web09.8844.1611643506063631436 for ; Mon, 25 Jan 2021 22:45:06 -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 10Q6Z9xQ058326; Tue, 26 Jan 2021 06:45:01 GMT X-Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2130.oracle.com with ESMTP id 3689aagu16-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 26 Jan 2021 06:45:01 +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 10Q6a689097113; Tue, 26 Jan 2021 06:45:00 GMT X-Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2177.outbound.protection.outlook.com [104.47.59.177]) by userp3030.oracle.com with ESMTP id 368wqw1qcn-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 26 Jan 2021 06:45:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iAmESYs36oaizAZTXCxENgYyZTMc7RtQ6SF8d232z8yr5MQ6zQz4lRKGISPXetp/k5c8gcftW32ddBVNyTA6sDR89z094HQNa+Ih5z0UEQ7wZSqaLiEZbz270VFE1Atj5HZlbTYF/zrtS2iL2vs6PNFoU8LWizrYgzNPXS/3+66xBaNf95dmrJfpXKtp+YNzZtyOFqhgfsV6ZK4HMq+3tjV3ud1IdKOvufxfZLNmIAwFYgO84SRNE+vyvCuzsGD5VXp0c7VDAgV0baAeNemjOi/mcPszO4X/LsGXpVv0QV3uLDQwBPR1xREKrcJyTZdX3MrMO4LHGTpr338+FJy5Xg== 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=L1gPodx8KoROTcPRXS118SD00ecs41MWalErPdya0ZY=; b=T8J5/cM1v7Od4euBX/WcAyabzmRQ7ST9opNWclXSl4UfxCYMnowg1MPiOBXrx4FrQXwvWq2XiXr+BO2Xjc/PPCRKZ2DVMXirPn5gbkUCDxuIccMslCCh+OpiTpkndm++C4ZQZ6dRj3QwthoTkSgJPrhJIMJhwN0qUWvFv1UGspI3cAoDqmpytdPY9f6miQI8xpLotjx7Vq2Kw9d+wnIgrkbqKjW/KaxoBkUznaf0/PNr4DevCNkdIAi2n40dPCEw0yhFtT0LLAiZTKFWYx5zWbC5x6i0ii3a5YEKCfiXq3e1rUmZAB2yHRrHaNurMDYn7LNwQCQVtTDP/JgkrUf8nw== 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:59 +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:59 +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 8/9] OvmfPkg/CpuHotplugSmm: add worker to do CPU ejection Date: Mon, 25 Jan 2021 22:44:39 -0800 Message-Id: <20210126064440.299596-9-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:55 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8e282034-7316-467a-747d-08d8c1c5e452 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: wzIKhLbUKKROs7SL2KXIcHwWPUlQ58FClqVwr9FSVaIcBGH4YtS0cCzqICKKQq1VQ2ee+l8XUHL1nulHPp48x+Ylk9UIdC6TlgfGUGYc4HOIDGGrW99OlThrwsefmeXimyHzSt72m5YT7bbcm5+qDw4y+uhodfd8SIhD3xSSAE3PSTDH24ywNkzgTfmJ0t4E7ecqyhVpuicTnNZuqYgZQSIH4KOsWl3sKKvdvu3kZgSPTQosMA1can0tuq6GgP1kRX8DH5K0yV41E8k2zt+8iUZqPDPvWER8SF3UGQP8Bt36OMw5qLs3WbVGIeEWcU6e875xXD9TKnkk10TE82l4lSrg5hkizkxkhoSph9sasjzXqPprHrvVM/FrJ6r7ISPsUjMTDC6zmiH4LHBH/YMaBYnJPurKTnblmpYYO847I3jfvGrrawtLV4cNZPMKgex44UMCpIOc08HQESsJtwuj9rhOpexOlSkSqgcBh539n18K80cVmph0/2I5QE4byQxu3PpwfC0aguNiKczP0ggjqg== X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?u9s+y5TE87QrK/omzEb5BIImq//eiEGhPFJuqLJWkfW3CirV80XJ+oap6Yer?= =?us-ascii?Q?DP6Z/FP9iJeIHdU36lQgQKzZafFSzF4F3YQCvPrFwOdXeTCynU125NHjSRix?= =?us-ascii?Q?vX5Cf1g7WvfdXV7ke8FvfNUXX11cBb6B2K3gWljZbdpRUfAiO89//RQEbM1g?= =?us-ascii?Q?/36LE6ecOA3rkztBrKL5qULgS5yNfVp5fDV7eibZ9S0qCBGjzedGumKiyl1b?= =?us-ascii?Q?uukdq78MUR4XhsUXhffniXqhlHAsgjIuUXiBMn/hifBMzL3Nzulan3JJkgMu?= =?us-ascii?Q?MruQmBKdlSmMQudxUCDTSZ7K2zP00wshxtnARpH+p2J5bKT+KUnjK/k68DoH?= =?us-ascii?Q?q39OyT9NED8YPfLhMh4stLLdcVHS2ayPbcKNMQ1YYcHgJw4F2c6mAeSBulkW?= =?us-ascii?Q?Vhb3ARPFqcEmt6EfjbXejWZefTmPbZTQ8K3SQsI+gssskUAofnEHtg8afEFA?= =?us-ascii?Q?4dOOIbren760nLkqfS7UAAAyTvhYseQbIOgCgbC9cyanC8INmnayuZDiLj7e?= =?us-ascii?Q?ppTdyVbaEu4zaUsKznFARcqZo/jBsliuOt5HH06IDfNEeu71OkDJJX5xYYc7?= =?us-ascii?Q?E/P0xVtoFXqKwan61om9WB1Kqoznxu268R8k/T1IKZVmDdTTZGOpSaoCOoRx?= =?us-ascii?Q?nLsxKyfvLb88CvWyiH8aT9QDri1VvbDmkOurl3z5UIEe50AtO41XZHSt9nSX?= =?us-ascii?Q?bZNFS9Hwbu7+JNPQUMgwZRnFl0xJc9m9FcJhe2uRsYXJGGhi/5j+dIbYVI/X?= =?us-ascii?Q?u+DxYRtjzE68POoThTqbbke5zJ8H7G0yDkFrHqmblw161KenvDV2tGlGTZa3?= =?us-ascii?Q?XClrIpQLeXI27aqvoRG8c5tr64ZuaxPRz4D3pcLf3L58aZwycTcjea0P3e8l?= =?us-ascii?Q?8/xlof/hVdKUfIslCtluFPgM21+vYMUo91tJivdyHkKEc/kV8MSKTJwXceXV?= =?us-ascii?Q?1CZTo559OWV1giXqzZtnGeEghvG5TzCQuPZ/06pEbJDXvMg88yaCHJp/GZ3R?= =?us-ascii?Q?aKj8Ptry5wopaOfQ+iW58HJD6quDCjFbc/IYamhgtRV+soOVdEafr7vBTiXG?= =?us-ascii?Q?y1l90h9E?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8e282034-7316-467a-747d-08d8c1c5e452 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:55.9860 (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: XrVcoYnP3JGB7/Kg853XSidEq4XZuP9ibtOxOcLHqqsZKHfo2dBQoPh5CB69UV5nTVpwjYj2LrcjwStYlJGZgzHqK3Aj8dZ8IMngJGW2eBI= 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: pZZONDy2jSDzeLrJAVgiwIxnx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1611643511; bh=lyWKZcWTPh3dby+udOQCPL28jC1M/UBAUqjDFGR0OU0=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=f/DGY35m5o7aiURwfOnG+1Ak3Pd8Avxky3YYYLrgE5sMLBUTia2LfAHcc1JZ5ZmjB6G Bjv6hHxYtQZxbYY+FeQJvc6IgYm9aoQ+aV7AKhzl22Gk3ib/+PCjJBJbYNfxIANQFHjzv m80gwfOTjBOCtLkOgIxcCs7R0AMw5wUZHEA= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Designate a worker CPU (we use the one executing the root MMI handler), which will do the actual ejection via QEMU in CpuEject(). CpuEject(), on the worker CPU, ejects each marked CPU by first selecting its APIC ID and then sending the QEMU "eject" command. QEMU in-turn signals the remote VCPU thread which context-switches it out of the SMI. CpuEject(), on the CPU being ejected, spins around in its holding area until this final context-switch. This does mean that there is some CPU state that would ordinarily be restored (in SmiRendezvous() and in SmiEntry.nasm::CommonHandler), but will not be anymore. This unrestored state includes FPU state, CET enable, stuffing of RSB and the final RSM. Since the CPU state is destroyed by QEMU, this should be okay. 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 | 73 ++++++++++++++++++++++++++++++++++= ---- 1 file changed, 67 insertions(+), 6 deletions(-) diff --git a/OvmfPkg/CpuHotplugSmm/CpuHotplug.c b/OvmfPkg/CpuHotplugSmm/Cpu= Hotplug.c index 99e6845a12d9..d4e27d641dc5 100644 --- a/OvmfPkg/CpuHotplugSmm/CpuHotplug.c +++ b/OvmfPkg/CpuHotplugSmm/CpuHotplug.c @@ -186,10 +186,13 @@ Fatal: /** CPU Hot-eject handler function. =20 - If the executing CPU is not being ejected: NOP. + If the executing CPU is neither a worker, nor being ejected: NOP. If the executing CPU is being ejected: wait in a CpuDeadLoop() until ejected. =20 + If the executing CPU is a worker CPU: set QEMU Cpu status to eject + for CPUs being ejected. + @param[in] ProcessorNum Index of executing CPU. **/ VOID @@ -209,6 +212,56 @@ CpuEject( return; } =20 + if (ApicId =3D=3D CPU_EJECT_WORKER) { + UINT32 CpuIndex; + + for (CpuIndex =3D 0; CpuIndex < mCpuHotEjectData->ArrayLength; CpuInde= x++) { + UINT64 RemoveApicId; + + RemoveApicId =3D mCpuHotEjectData->ApicIdMap[CpuIndex]; + + if ((RemoveApicId !=3D CPU_EJECT_INVALID && + RemoveApicId !=3D CPU_EJECT_WORKER)) { + // + // This to-be-ejected-CPU has already received the BSP's SMI exit + // signal and, will execute SmmCpuFeaturesSmiRendezvousExit() + // followed by this callback or is already waiting in the + // CpuDeadLoop() below. + // + // Tell QEMU to context-switch it out. + // + QemuCpuhpWriteCpuSelector (mMmCpuIo, (APIC_ID) RemoveApicId); + QemuCpuhpWriteCpuStatus (mMmCpuIo, QEMU_CPUHP_STAT_EJECTED); + + // + // Compiler barrier to ensure the next store isn't reordered + // + MemoryFence(); + + // + // Clear the eject status for CpuIndex to ensure that an invalid + // SMI later does not end up trying to eject it or a newly + // hotplugged CpuIndex does not go into the dead loop. + // + mCpuHotEjectData->ApicIdMap[CpuIndex] =3D CPU_EJECT_INVALID; + + DEBUG ((DEBUG_INFO, "%a: Unplugged CPU %u -> " FMT_APIC_ID "\n", + __FUNCTION__, CpuIndex, RemoveApicId)); + } + } + + // + // Clear our own worker status. + // + mCpuHotEjectData->ApicIdMap[ProcessorNum] =3D CPU_EJECT_INVALID; + + // + // We are done until the next hot-unplug; clear the handler. + // + mCpuHotEjectData->Handler =3D NULL; + return; + } + // // CPU(s) being unplugged get here from SmmCpuFeaturesSmiRendezvousExit() // after having been cleared to exit the SMI by the monarch and thus have @@ -306,6 +359,19 @@ UnplugCpus( } =20 if (EjectCount !=3D 0) { + UINTN Worker; + + Status =3D mMmCpuService->WhoAmI(mMmCpuService, &Worker); + ASSERT_EFI_ERROR(Status); + // + // UnplugCpus() is called via the root MMI handler and thus we are + // executing in the BSP context. + // + // Mark ourselves as the worker CPU. + // + ASSERT (mCpuHotEjectData->ApicIdMap[Worker] =3D=3D CPU_EJECT_INVALID); + mCpuHotEjectData->ApicIdMap[Worker] =3D CPU_EJECT_WORKER; + // // We have processors to be ejected; install the handler. // @@ -429,11 +495,6 @@ CpuHotplugMmi ( if (EFI_ERROR (Status)) { goto Fatal; } - if (ToUnplugCount > 0) { - DEBUG ((DEBUG_ERROR, "%a: hot-unplug is not supported yet\n", - __FUNCTION__)); - goto Fatal; - } =20 if (PluggedCount > 0) { Status =3D PlugCpus(mPluggedApicIds, PluggedCount); --=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 (#70767): https://edk2.groups.io/g/devel/message/70767 Mute This Topic: https://groups.io/mt/80125315/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- From nobody Thu Nov 14 05:09:20 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+70768+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+70768+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 1611643626229124.56900456807045; Mon, 25 Jan 2021 22:47:06 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id rthcYY1788612xGN4SmHW8FJ; Mon, 25 Jan 2021 22:47:05 -0800 X-Received: from userp2130.oracle.com (userp2130.oracle.com [156.151.31.86]) by mx.groups.io with SMTP id smtpd.web12.8825.1611643625194674426 for ; Mon, 25 Jan 2021 22:47:05 -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 10Q6a3ol054946; Tue, 26 Jan 2021 06:47:02 GMT X-Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 368b7qrny9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 26 Jan 2021 06:47:01 +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 10Q6a68A097113; Tue, 26 Jan 2021 06:45:01 GMT X-Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2177.outbound.protection.outlook.com [104.47.59.177]) by userp3030.oracle.com with ESMTP id 368wqw1qcn-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 26 Jan 2021 06:45:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gl4nJEy8jvWk75BsZ2xLzOUmf7plNbI/JzjBhWJWz74nylK0WzZ8mecKHfHoeqKTg5IeRUS8AuHOfEVRSzyxIjpzHram4re+iouHLQIME4zX5jtSHEys8qGL3uU4XSEF9yrQy3o8L2MUcbHRU8GYv5wHy38+Wq7lAh5bSxhfodVVEL2S37XmwqphH10vf2vrZg5MlXSe3DLyqyFlvHlPnMk+Z5T3QIH1rRZsn7z4teMXSXbtrOt3VtUIdCXvbj+OroOdnjfRP6LEvrQxk0Nb/KmykBx0ulxQwDVuCUy6NYZvoLQJuRs1slDvRafo02zkHyh11sVPj1T2uvFvn8vcFg== 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=7DHNoT91MtJFzMhEBvW0ixXWB1S8RLGtWlpmYOMA0gc=; b=SJw51HcAtNMwNUVduMxSSLfb2wMZzvKi4CtSZK2vMjJvhFlvs03NfRV1+45m0t1Ocl8yci+MY5DIIudL8eNsg0jrlhvM/3/fboa9blC/8GoC/iH52ZDLkE3YpyzlxpsmyW8bVsVmEzgHaULGxSaIuKXtDFiEgcN6hYNJIpU3euv+gIFEg+Nl2hbQ8VjaF1ReyGQNTlwv5OshcUIFPwuQms4UQwwi0PnvggqjAnevV0+rAG1a9mZ7DWAu7mDuy/pH4fIj7/6Xsvcd7pVFcwg2HhTn75atuprjt+AyjLDykxUxjTlv1emhThI07cMc7pMjywmVuAba7c/oMsDFr2INTw== 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:59 +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:59 +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 9/9] OvmfPkg/SmmControl2Dxe: negotiate CPU hot-unplug Date: Mon, 25 Jan 2021 22:44:40 -0800 Message-Id: <20210126064440.299596-10-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:56 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ecafc1ba-6ace-4379-3659-08d8c1c5e4f3 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: ul/DXcbPsnZzBSA1dO27QF+y/HCmjUbGO9y4T/xGvjnr9n8AMKjKVfqYPOisQjkQX3J/oWfbew3csOFsyoxZhA9C4mKY5+f0qB3KhL7PJ06MWuB46PvXbQ4qQQoVzAJGAHPbNCUWTUEQYb9U9LmiYn1f756F+eqYApTGOFQRzNt1BCXAT/n+HE5g6iCaVm9OHBosSH1OeOHPoFnDSAdxbJ7g4o0+QU7DGU3G55Nm9daIJU8VAI58E2iEBJPhZFY50BAhSlIGSESDMp/NXFLNLYV+qePvg96tNKsctzVdd/W+xyNI0uoI8vXce/GpyXR4ncEAjGG0TrZb7DaK0KENuuZUYF8BuQd+5CZntnpxHE5NAeTJmvR6/9955wL8jjFPy8P3+qwKwH7Y7lUPNK4DWkkG4y2U9xrCCgIq+KS2eHTwft/5+BFRNt84gxdOG1fX+phpRY/I9bj+dAQLeQ2dz88m30zE1ZENFSMAO+Zi6+QZkWDUR8N5dycoP6yHpkKXgGC5Lvp84FCes72IZh3KYA== X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?9U7SMQnnaTwOeEQWTlDn8v3SYuhbdPk90xGHkwxDl27ahqVhgXiwbi1LGTNl?= =?us-ascii?Q?tKPg8mRQfc1v910Qo4CeQl1x55UtZIXEWOyGgBr8BHy2i/XzHXEC46jPhAeA?= =?us-ascii?Q?WFsAq6sMdtY5qmVtRvbwU5jO7jvL3b3jnCTeYGSKF/bhmXE8eNU6zYyNczGf?= =?us-ascii?Q?akjFJJyMksjo/psxLRgConYQITpjN8X3X/qEa1BwMoLLCN4YXglHA5Tqvt8D?= =?us-ascii?Q?fvwjaug2IN3z8W/A0UJQoN1ZZifoRs2rPXLEJrMJgf1nx6aYk98EKkxxhw3/?= =?us-ascii?Q?tk0J1haMZ2QD+k49XMF5ysUIuTO8B8U4ljiVglH64WVaBQ1r7vwIQd3F3vr9?= =?us-ascii?Q?ZWj8+udii93I6DDCjcCzjS/fYx3ddylhijwkl1lXtkEzbmsN5Jg1CFSI4wnO?= =?us-ascii?Q?oqsUAcieu+M8r4pvOZz14R/nM91MIYI6pvogB3vP32X1IfyyatHuz6zejtEp?= =?us-ascii?Q?rqeWBnLu8EsI17qYFbgkGnNltHvT0CI1Q391sRWC94/SWJqDxVAXLeBPORKp?= =?us-ascii?Q?dG6jaWVmn9AOUeguEab30kr9IQCdOkjQ0Ht/MVEiFzuQiN6jg3MI74QsREJo?= =?us-ascii?Q?TZvrhS5pUoxmpsL0TjrIRE0E+jCgLInU3dDLX2rE8SMqZ6h/q8BUdUmNwsqm?= =?us-ascii?Q?xA7mgjhwQSX6R0p7QEXi0GO5KhocV3hRWrnHU95448yMqF3DJBl3nGFKH2Kl?= =?us-ascii?Q?X+KhuIVtM/NonwLa/zs5uwcdYNEWF+n0pdLVTtLf7NfweBXBv06/6Z4Ug7Aw?= =?us-ascii?Q?62qWHGme2tnKLdJTwaXcuUN8/rn+Q8BvxrhhRUsJBr1HIbk3cTnYJXU1th/I?= =?us-ascii?Q?jaxJ8UOnlmW3xGgzLMMgKh3xrv4SKfAVfQQGw5YN1g4opKqggeONPgqBEg6A?= =?us-ascii?Q?az89dGDCuG/sFGiJYUSYEeMafLimQhs1tb36/ALQpR2wB/skvsxfqAfVXpOw?= =?us-ascii?Q?cP3ud4mDGEpsYzdfamQYt6DonO608FvJ4Bpesh32eHlrkZQGgOFlps1IEXez?= =?us-ascii?Q?g6TxwNyGWKRyPDOqdxeNeV5Cu4xakwfIt52HUJEVpaBZorcDuLd1pVbiPaHu?= =?us-ascii?Q?iQn2eWok?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ecafc1ba-6ace-4379-3659-08d8c1c5e4f3 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:56.8876 (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: bKN+omVyFwM3d0OpsoZWCO6I4P4KgIC7Ioeadb9T4vB125QCX/WkN/q6dWv8SHYi5ZZqV1GwBz86aU/fuqubgyWNrbc4FIW8f4I9R1Wuecs= 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: Bo2Q3p3r4gkYcTLehmIheQebx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1611643625; bh=I14oCflSu2+dXLMeTWWB4uugaHtDayGRe0Eidyx6F64=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=Umhf+xIH9a5HotC6WMXaj0fkb0EV+msxU1/t2DGhK4+lWLydlcpMjwMnb001+GK97Bx om1+vMCJKeTzWMIgyqJJj9olccfv39w8JCAKR9Inn31N4MUC3AAaH4hdJmQ9WhGOSuijc rfSIOl4bPpg1hVdoQ2xpVTd1APhR7SUr8W4= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" As part of the negotiation treat ICH9_LPC_SMI_F_CPU_HOT_UNPLUG as a subfeature of feature flag ICH9_LPC_SMI_F_CPU_HOTPLUG, so enable it only if the other is also being negotiated. 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/SmmControl2Dxe/SmiFeatures.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/OvmfPkg/SmmControl2Dxe/SmiFeatures.c b/OvmfPkg/SmmControl2Dxe/= SmiFeatures.c index c9d875543205..af01104d69c6 100644 --- a/OvmfPkg/SmmControl2Dxe/SmiFeatures.c +++ b/OvmfPkg/SmmControl2Dxe/SmiFeatures.c @@ -29,6 +29,13 @@ // #define ICH9_LPC_SMI_F_CPU_HOTPLUG BIT1 =20 +// The following bit value stands for "enable CPU hot unplug, and inject a= n SMI +// with control value ICH9_APM_CNT_CPU_HOT_UNPLUG upon hot unplug", in the +// "etc/smi/supported-features" and "etc/smi/requested-features" fw_cfg fi= les. +// Can only be negotiated alongside ICH9_LPC_SMI_F_CPU_HOTPLUG. +// +#define ICH9_LPC_SMI_F_CPU_HOT_UNPLUG BIT2 + // // Provides a scratch buffer (allocated in EfiReservedMemoryType type memo= ry) // for the S3 boot script fragment to write to and read from. @@ -112,7 +119,8 @@ NegotiateSmiFeatures ( QemuFwCfgReadBytes (sizeof mSmiFeatures, &mSmiFeatures); =20 // - // We want broadcast SMI, SMI on CPU hotplug, and nothing else. + // We want broadcast SMI, SMI on CPU hotplug, on CPU hot-unplug + // and nothing else. // RequestedFeaturesMask =3D ICH9_LPC_SMI_F_BROADCAST; if (!MemEncryptSevIsEnabled ()) { @@ -120,8 +128,18 @@ NegotiateSmiFeatures ( // For now, we only support hotplug with SEV disabled. // RequestedFeaturesMask |=3D ICH9_LPC_SMI_F_CPU_HOTPLUG; + RequestedFeaturesMask |=3D ICH9_LPC_SMI_F_CPU_HOT_UNPLUG; } mSmiFeatures &=3D RequestedFeaturesMask; + + if (!(mSmiFeatures & ICH9_LPC_SMI_F_CPU_HOTPLUG) && + (mSmiFeatures & ICH9_LPC_SMI_F_CPU_HOT_UNPLUG)) { + DEBUG ((DEBUG_WARN, "%a CPU host-features %Lx, requested mask %Lx\n", + __FUNCTION__, mSmiFeatures, RequestedFeaturesMask)); + + mSmiFeatures &=3D ~ICH9_LPC_SMI_F_CPU_HOT_UNPLUG; + } + QemuFwCfgSelectItem (mRequestedFeaturesItem); QemuFwCfgWriteBytes (sizeof mSmiFeatures, &mSmiFeatures); =20 @@ -162,8 +180,9 @@ NegotiateSmiFeatures ( if ((mSmiFeatures & ICH9_LPC_SMI_F_CPU_HOTPLUG) =3D=3D 0) { DEBUG ((DEBUG_INFO, "%a: CPU hotplug not negotiated\n", __FUNCTION__)); } else { - DEBUG ((DEBUG_INFO, "%a: CPU hotplug with SMI negotiated\n", - __FUNCTION__)); + DEBUG ((DEBUG_INFO, "%a: CPU hotplug%s with SMI negotiated\n", + __FUNCTION__, + (mSmiFeatures & ICH9_LPC_SMI_F_CPU_HOT_UNPLUG) ? ", unplug" : "")); } =20 // --=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 (#70768): https://edk2.groups.io/g/devel/message/70768 Mute This Topic: https://groups.io/mt/80125324/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-