From nobody Thu Nov 14 16:46:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+72703+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+72703+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 1615530439868177.45571250821536; Thu, 11 Mar 2021 22:27:19 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id xODqYY1788612xbzOjYt8jMu; Thu, 11 Mar 2021 22:27:19 -0800 X-Received: from aserp2120.oracle.com (aserp2120.oracle.com [141.146.126.78]) by mx.groups.io with SMTP id smtpd.web12.4952.1615530433710301494 for ; Thu, 11 Mar 2021 22:27:13 -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 12C693kV167608; Fri, 12 Mar 2021 06:27:10 GMT X-Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 3741pmrya4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Mar 2021 06:27:09 +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 12C6PY04079482; Fri, 12 Mar 2021 06:27:09 GMT X-Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam07lp2040.outbound.protection.outlook.com [104.47.56.40]) by userp3030.oracle.com with ESMTP id 374kp243k0-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Mar 2021 06:27:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DRl1Yk64527aqSpxzyzY674m2DSpFbKPoofsAANyiWA0jkVirJmUY3hHk11vcgikkXN4pBZ5Q9g39R6fQ8owSrG8BtTNeuHDMIYg7Ah6Dfw9NmSEe2N7F3XFssG//hCzBzPyTa5HrLch5Hb1SNF+ISN3Bl1ldhZsaxI6GvDR74xwKDBWzejdICJkcLIWIsZUBER+Rt37ypsUEAmVjs6Fo8zd+LQZWiNTQLHpRT/Oezrl9FCMizNenC21kfBRa+NC7bWiAsLJYg7BGQWBfjqZXp7SXJBkkD+phqrBeUdy53bzqy+s83KCpiUmqW/cVMRW2JV22Xpl5RVwGedWv2fHMQ== 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=NTCk2WrFvQNF5TkXALW4K6sgpJkNzV8FnJVhu2jvS0E=; b=Ai/dR2aztd94e8AFx0SU/R/73TKjIyidG2WbIlbg1YIcaGlwVRP2BJ0C7j2sCVRt1hyRuBkffQgkmwLSlgXd/VcBfsvoZFRhOnu7HYbubVvstYDGBlKk3k/kEZsFQ4bSlCrBVwx0F9noAPNxZVCjsaxYZEOYlL2R5LNvNCk7Dhh0L0GaoUKE0B3SRGB4HO96eutRfNyPtGQSEsKu+hi4W1CjGdBeT05T7yb6yakfBudmJmik41zWOgqo+IpReZAg1M5H61BvLG42NuA2LnGlyNALBSzLi3x/cbQz88T9CJir8IWOwb+CMzTmn+Aafu9ycw3XHhEq8BukPkykVIRbZw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none X-Received: from SJ0PR10MB4605.namprd10.prod.outlook.com (2603:10b6:a03:2d9::24) by BYAPR10MB3191.namprd10.prod.outlook.com (2603:10b6:a03:14f::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.24; Fri, 12 Mar 2021 06:27:06 +0000 X-Received: from SJ0PR10MB4605.namprd10.prod.outlook.com ([fe80::a021:790:7ce6:6f16]) by SJ0PR10MB4605.namprd10.prod.outlook.com ([fe80::a021:790:7ce6:6f16%6]) with mapi id 15.20.3912.030; Fri, 12 Mar 2021 06:27:06 +0000 From: "Ankur Arora" To: devel@edk2.groups.io Cc: lersek@redhat.com, imammedo@redhat.com, boris.ostrovsky@oracle.com, Ankur Arora , Jordan Justen , Ard Biesheuvel , Aaron Young Subject: [edk2-devel] [PATCH v9 01/10] OvmfPkg/CpuHotplugSmm: refactor hotplug logic Date: Thu, 11 Mar 2021 22:26:47 -0800 Message-Id: <20210312062656.2477515-2-ankur.a.arora@oracle.com> In-Reply-To: <20210312062656.2477515-1-ankur.a.arora@oracle.com> References: <20210312062656.2477515-1-ankur.a.arora@oracle.com> X-Originating-IP: [148.87.23.12] X-ClientProxiedBy: MWHPR02CA0018.namprd02.prod.outlook.com (2603:10b6:300:4b::28) To SJ0PR10MB4605.namprd10.prod.outlook.com (2603:10b6:a03:2d9::24) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Received: from prion.us.oracle.com (148.87.23.12) by MWHPR02CA0018.namprd02.prod.outlook.com (2603:10b6:300:4b::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3912.17 via Frontend Transport; Fri, 12 Mar 2021 06:27:05 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 48c87423-efdb-4e29-0cf8-08d8e51fdbaa X-MS-TrafficTypeDiagnostic: BYAPR10MB3191: 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: kAYNfCQ8P81QngEmxJy2UxAlGpI+FvLVvExDTOVo8NwfqJLymD3uyWi45/nKDs9soBUJijW+WDD/tIoM04ze3DNqaBbJPLpqawUD4Uy4Dv+0oz6jRMojOM3FiawJYZgTFhy9zQWoa5ifet5ChnkzADw4G3AjDD6IRJXqysA8dcEVTvkhnUw0P0rUhXtt+9uXpIRMXmth/M5C+EvkRzDRYtqhfoKBDvR611l2bncr4WhkzUKVKEbg4AT8AUP11h12Q02i30W61+uAfD4V5GHckLYqy4w81OYrgNK0t8loXjxfFYLiNa/vmQ4XtD/2iGY4KXG6XlMG30JMXVbPAwmdt924e/NSvgMMLqumOx1nXHUm3On3V9a/4gB0AK+B8lpMKQxmaas2Eq/Veox2ojDsphqHsNARH4lB6wEllG3S9cmAzH3jU1OezdTPp+JglizqxXaSKCSZbNQpte5sRFmZ0lxdfR5JtC/aAC/0ygn0s0KKit5S1EDI7VdRaf7FDDj4WL8Qo0Ly/qC2DnQ1xH1Um0wM9YgWRmSGVxEyz6x9nyn1egVA/T7WXI99134xNlXGbUwotuH7Z9p4OPsTss/47jCE53hQcouVIOPRhRuaTag= X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?ts9SHkFTVoeD2pj/21kXkU1XX7FQgXCl+i50gpD9N7/1q3YflszDDSSTuiaM?= =?us-ascii?Q?76eZya8WYeOJPYjB8t4squRR+wb2mZfzXfPdan3UNN2/RZ2Evs+AIT0/Beia?= =?us-ascii?Q?fojeL2hvRwYfACckhLSOvf/mYoRA3uQVmYy25Qd6FWNXEVltKGtz8l/d8PZH?= =?us-ascii?Q?htn7RuOTW+F+kTJ68DKn1dVhojJw8R82hQLueaFnnLKTPi0HFBC5nSmQMLm/?= =?us-ascii?Q?K9dhk2m7BPruiuQkQAhGydlzI40KoicEWWNX4FwHZ1gryewnAOJUNP9tZyDW?= =?us-ascii?Q?ZIrGXKbjK5lkSlJ1hrVn/7O5F9b72QoA2xH9u23ijmyCL//MigMjh/PrO9rp?= =?us-ascii?Q?Z260hzxO2sLrup6XsqrglLQSC0K0YU96jItpdQEZdqmtdVXBsBxP01ser0xS?= =?us-ascii?Q?zruP7AKZdlvJnkOp9mOlgxm9rkwIo6AX8f2KubRD3fjxSfzLt04aLzVXswck?= =?us-ascii?Q?JVNu5Kt+IpwdRr6EWPkMig70iurbL3624L2nVlXY7WCtWbTuMftiNBxMS9CX?= =?us-ascii?Q?fHqhZHEpJ7qUZpMzUm/rhJsYVTS1qlbY+2pHCjWRI4R/so0QchFsf4fBKiVe?= =?us-ascii?Q?fs110lrTrbdaJBmwpi0wMDBuZGEsSoCwnwIuQ+Ib51bTEvDxhvyWPpXmi1pX?= =?us-ascii?Q?i3sA+klCcBm4os3EDmID11HrvRp/EOmB6lONQgroJPMeEPd5V0tUVN/QoDJ6?= =?us-ascii?Q?OK+FM86oKjY1BCASCHHsv38WenSUh+qFuqhbJFZpSIwgrEi4Rg1qdDY29F/9?= =?us-ascii?Q?vs2A51Hkeiflowu/okpuOFysaqRXP2SfVqmfTwC+qz/ulyWufOvWzhMLtluc?= =?us-ascii?Q?aowOCJIyIw0ta/2zlVbB0Tot5AAkwAbdz0N0pORg4MauA2ck5/gPHVz7teaO?= =?us-ascii?Q?yJ4TKbhWpYU98OkCZTMoeGWbc5qdJc60LteHPRmjiggYgjVDzMkGWFzKbJEb?= =?us-ascii?Q?ev2oSswiu3yo8oMZMKDS/sktB3gjTmLdWppBK0Fp9jfH/3jC02l7zLNU0Ji3?= =?us-ascii?Q?w0CUkPD2gg747LYcjeZS4QzPgtJG+pqYE88hZekwjfX0SKbd/wWRcYTMaQOb?= =?us-ascii?Q?DFeAwpAs9yw9+znQA2u7aNQfVG8hmxureUulPTeilOpdyaDkNQoCSh4gxtJ1?= =?us-ascii?Q?zqzJ0YRjaS9YTpu2iVmukQLBjWHkSOIM6UgDKzrFIy9VcYT9D9XHKkihQP8+?= =?us-ascii?Q?cpijyqDsdPHZEeLw5Z12OMtSWIWbYdwZPwiOBtKMXQRM/pkofcUNHqihmo0g?= =?us-ascii?Q?0aSWqnC2x0HbCK4hMswpE3TAsbJpDWsB0JQIN+XSfLxnZr2rn6NzOiuLz20d?= =?us-ascii?Q?jOduP8B5QT3/EDqCqGD2zmtY?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 48c87423-efdb-4e29-0cf8-08d8e51fdbaa X-MS-Exchange-CrossTenant-AuthSource: SJ0PR10MB4605.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Mar 2021 06:27:06.6779 (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: exFNFGRX8dbMAxKQ/Zu31uDrKHWBZgRFJLXg43WQZbR7Dy3rCkRMYMSgm9jzM6ETtCrf7r7gQGZRya1Oqb6JFnWuNu7rMdgZZwe49+IlGB8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3191 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,ankur.a.arora@oracle.com X-Gm-Message-State: I0kFZKxPEkv2KJoqZIidM0Zex1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1615530439; bh=JYXDSVkDB0TZQFohjdM9qrCwbc1naPPxUChYCwYrAwM=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=foTvzuhggApMa2yKoWIF6ohdnnxisDeGKyDxigJPlJseVR1BbuGn82IT6hbnMI2S/MI jqh0r7VMRuNRuzd32ighS6Xc5vV81vOE8gcACCnCYRSMbi0F5+WcwGtki65a2aFU1Po92 L4RgQmIs7RJCIPzoKWYsDvB8VOUQJi8p90I= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Refactor CpuHotplugMmi() to pull out the CPU hotplug logic into ProcessHotAddedCpus(). 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 Reviewed-by: Laszlo Ersek --- OvmfPkg/CpuHotplugSmm/CpuHotplug.c | 210 ++++++++++++++++++++++-----------= ---- 1 file changed, 126 insertions(+), 84 deletions(-) diff --git a/OvmfPkg/CpuHotplugSmm/CpuHotplug.c b/OvmfPkg/CpuHotplugSmm/Cpu= Hotplug.c index cfe698ed2b5e..bf68fcd42914 100644 --- a/OvmfPkg/CpuHotplugSmm/CpuHotplug.c +++ b/OvmfPkg/CpuHotplugSmm/CpuHotplug.c @@ -62,6 +62,129 @@ STATIC UINT32 mPostSmmPenAddress; // STATIC EFI_HANDLE mDispatchHandle; =20 +/** + Process CPUs that have been hot-added, per QemuCpuhpCollectApicIds(). + + For each such CPU, relocate the SMBASE, and report the CPU to PiSmmCpuDx= eSmm + via EFI_SMM_CPU_SERVICE_PROTOCOL. If the supposedly hot-added CPU is alr= eady + known, skip it silently. + + @param[in] PluggedApicIds The APIC IDs of the CPUs that have been + hot-plugged. + + @param[in] PluggedCount The number of filled-in APIC IDs in + PluggedApicIds. + + @retval EFI_SUCCESS CPUs corresponding to all the APIC IDs are + populated. + + @retval EFI_OUT_OF_RESOURCES Out of APIC ID space in "mCpuHotPlugData". + + @return Error codes propagated from SmbaseRelocate() + and mMmCpuService->AddProcessor(). +**/ +STATIC +EFI_STATUS +ProcessHotAddedCpus ( + IN APIC_ID *PluggedApicIds, + IN UINT32 PluggedCount + ) +{ + EFI_STATUS Status; + UINT32 PluggedIdx; + UINT32 NewSlot; + + // + // 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)); + return EFI_OUT_OF_RESOURCES; + } + + // + // 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 processed this batch of hot-added CPUs. + // + return EFI_SUCCESS; + +RevokeNewSlot: + mCpuHotPlugData->ApicId[NewSlot] =3D MAX_UINT64; + + return Status; +} =20 /** CPU Hotplug MMI handler function. @@ -122,8 +245,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 +300,11 @@ 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); - - 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)); + if (PluggedCount > 0) { + Status =3D ProcessHotAddedCpus (mPluggedApicIds, PluggedCount); + if (EFI_ERROR (Status)) { 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++; } =20 // @@ -267,9 +312,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 (#72703): https://edk2.groups.io/g/devel/message/72703 Mute This Topic: https://groups.io/mt/81273602/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 16:46:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+72704+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+72704+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 161553044398527.721356309728208; Thu, 11 Mar 2021 22:27:23 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 904xYY1788612xmulHgYcM5w; Thu, 11 Mar 2021 22:27:23 -0800 X-Received: from aserp2130.oracle.com (aserp2130.oracle.com [141.146.126.79]) by mx.groups.io with SMTP id smtpd.web10.4847.1615530434239456035 for ; Thu, 11 Mar 2021 22:27:14 -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 12C6APDJ139263; Fri, 12 Mar 2021 06:27:10 GMT X-Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2130.oracle.com with ESMTP id 373y8c14as-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Mar 2021 06:27:10 +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 12C6PY05079482; Fri, 12 Mar 2021 06:27:09 GMT X-Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam07lp2040.outbound.protection.outlook.com [104.47.56.40]) by userp3030.oracle.com with ESMTP id 374kp243k0-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Mar 2021 06:27:09 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eYKDeq+Lbg9RKU9gXN6rNQHJFIgNorFgkFxkbdFoQKRNT4F55abpc71uvVdUUGPcyhVM514c95LNQG8LJg025MR7unW8ilr4iGGUpJ36DUmPCAVBBcwb+9U/+KowmUIw5qP2DZPBE6OyLg4DVQzs/V+Ku8BiFcZDZvXJhEY4JYwhDz/XqrZE/88NLW9H+7ow0z4x6R/DL7GmXRBhUEKP9WDuKx40y5UegfAulTIO9fR5tDHfgBl2qDk3lo9KV0IOt/n5Ve68ew8mgGt2KkYGgcTKY2WlrjCH15kUWzoVDGSwzFaJEM+/2ys33lrngilbMaew3l+4RhGsL45Kym1/0A== 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=IyGh2hGyPNEI+2m0OrCnDZEcNOlJaF8tmhqHfhD22sw=; b=iCCxKdWB6145wB6qoYqUHg7bbECs5FfVnyrQ8g4nQaBwL9SuiR9zdpAWzLNphnJ6ISZkOEVPww8vBjDbeGu8wOt7nujgAqUbC07qlsZh6OxCvoXzAm57wrmkWf98RqWq6G30l7kyx1Qtx7s6AnYJ0F3q2yf4o3/9wNt+Y9Gdy1eKiNG4gSlTHMpg5oQOEFK0KbiUbIFMsxKBwBWmFym79pqhC/H57z/5+NBzKHHCjGidEfyX8ufeoPW6fQPQBoiopV3C3+qYAZO3v+7D6tKqHJ4h+MXJoJVABcRRwkTX9IOtGPRe1OJ5bfaBdkkUzIkMHZzG1803FJuDkZuW3PyyiA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none X-Received: from SJ0PR10MB4605.namprd10.prod.outlook.com (2603:10b6:a03:2d9::24) by BYAPR10MB3191.namprd10.prod.outlook.com (2603:10b6:a03:14f::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.24; Fri, 12 Mar 2021 06:27:08 +0000 X-Received: from SJ0PR10MB4605.namprd10.prod.outlook.com ([fe80::a021:790:7ce6:6f16]) by SJ0PR10MB4605.namprd10.prod.outlook.com ([fe80::a021:790:7ce6:6f16%6]) with mapi id 15.20.3912.030; Fri, 12 Mar 2021 06:27:08 +0000 From: "Ankur Arora" To: devel@edk2.groups.io Cc: lersek@redhat.com, imammedo@redhat.com, boris.ostrovsky@oracle.com, Ankur Arora , Jordan Justen , Ard Biesheuvel , Aaron Young Subject: [edk2-devel] [PATCH v9 02/10] OvmfPkg/CpuHotplugSmm: collect hot-unplug events Date: Thu, 11 Mar 2021 22:26:48 -0800 Message-Id: <20210312062656.2477515-3-ankur.a.arora@oracle.com> In-Reply-To: <20210312062656.2477515-1-ankur.a.arora@oracle.com> References: <20210312062656.2477515-1-ankur.a.arora@oracle.com> X-Originating-IP: [148.87.23.12] X-ClientProxiedBy: MWHPR02CA0018.namprd02.prod.outlook.com (2603:10b6:300:4b::28) To SJ0PR10MB4605.namprd10.prod.outlook.com (2603:10b6:a03:2d9::24) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Received: from prion.us.oracle.com (148.87.23.12) by MWHPR02CA0018.namprd02.prod.outlook.com (2603:10b6:300:4b::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3912.17 via Frontend Transport; Fri, 12 Mar 2021 06:27:06 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8d8cd79d-535d-4d3f-3777-08d8e51fdc65 X-MS-TrafficTypeDiagnostic: BYAPR10MB3191: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:167; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: yKvWDDhGJOHXCfrm6a+SWgIWWoGRTZv02NOgcuBjusXvlBmifokW07Ut1fR/d9tXqmQ+OS457SBrpn/igN7SRK4hAyDTPONYtC/5INrP8YZC1X7lCHzFyyjrnL4YS3pZXJOQTtgNE8BU1ZwhiU/oGUc+7JCvfmjUrt4DtycSayEVhu0TpEbthyC2Zi6FxjXhgnDFBLHv5DibLom1KvWedBEqXMXLEH0C76LaBth4+KaTJ3VngY9GpypKsMqeSgIwjzEGF4+y1563cTC06TWlw3lg1w/ospSGd9wmCQ45FSWZs6eLk+h+EQ3NOTLb9WrDcY0qk4DljN7KVD9zNkyfbg1YK3xDBaoKJgwJuRqi75/BEGqYnf0zsTCARdSxja9G269ifP2eBcWWyBQFFlnwZrC0JBuWP/S/kas0dLSGgCzXUxHCKZDTrBZ9L38Geh69i5yrx6+3YO/kt4P6dv8Uj/8aShzL90k8YRw7bvdQGcv5W9hPSff5JGzgZvwVS3aWK//fZKSH/ofO+oMvwx9HuVq8oRIDWkhH8CIzWvrs0gKGKH45Vi5PsNxrIWNqaPQsKDDLZYT6oqzBsb9f3uOnBr/zRPXU1AyoLSUcLEFS/AA= X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?lw4kQxzquqFy4GY7Wz1hs8Jp2f+EGM/Dtpsb1iiGJ9PEC2qzGtv0Ez2y/YWp?= =?us-ascii?Q?gXdfuF8T669y1uMj821+57l2S2bwYrr2X7XLmaneHXhRr6XKIuBblX1hmki0?= =?us-ascii?Q?Q9SKL3cPcAr5X7m3vZT8RuLPkzzatt5ws0sqv/f18mWg99pQB9VesXNBogA1?= =?us-ascii?Q?h0vuDKjhvXlxk3syxvMMk6WzszH6HHShmzICOZF6uzoslkLtCAu5g0Doe9jx?= =?us-ascii?Q?9mZAWq4VWTi5ikl7SnMEZ8iqIQUxKdcFyCYwOLL83Plz00BwMyyrYyGrVr5l?= =?us-ascii?Q?Vd8nTrKroFx/1KAihMwIMxVb6F9QK4ZMDAeW6UscKla5c00u/wHmvzDhyIKN?= =?us-ascii?Q?Z/8Yb9PsnQBh0O3z1By5GQJ2xOyblgPJ4s2g1FREYji27zz77XnvN3oDYV+N?= =?us-ascii?Q?Y8ATruKfKmHW8k5HAbymS7DEnO/ZjWtYZCvqCrFUs+O2BJGyP87JUhdQEj5b?= =?us-ascii?Q?JXwHJ4G6U7yuenNnIIPT3cDRSJ7Ps6myT+HK1MuXgCRqz73llf4e2czaux8k?= =?us-ascii?Q?0FXV/adNOTUMn1yH/bmmNfz1J9jRE7YhqXNHw4Y7Btz9kqSh+Y73E2VinLLC?= =?us-ascii?Q?IDzXhXwDVxIn2EDX1Ovs6psL7W1viJARKbPXr/tYM53BapjseXxPzWB98DCF?= =?us-ascii?Q?UrpaKcR3N83jl+n+nqj1Biwa4DIXncfpf2fr2h7nqUp7hTJSbi+mqrVR9H0q?= =?us-ascii?Q?yDDtRG1oCIQqllQwtkXCrJHxHBBRodu03DY2E3YxWNnI4j/kAH4TNRsg+GbK?= =?us-ascii?Q?JoRZjDbdusbT06EA96mUasRpUlu2ccYOBGEsnXBlKEDJRqYKTwgbRHs0xk4i?= =?us-ascii?Q?MCamw/ElAdeLAuprDu8RmtB7MCCmNj7ppjnbXUwTfKCrUo/l2kyIbfHhGFyj?= =?us-ascii?Q?BxhXLKjup3EZPXpRsHxs969CDv8mpBjLJuxBA1AndzXSF3DkzUGnv39S03tN?= =?us-ascii?Q?Es8eXWyh26O/ilTZf5LYDWK8Gj5yG+SykkHEjtDBIayYkZ09xuhJkLd+gRyZ?= =?us-ascii?Q?lNw6dOiwjszccxMFANkBOWWYXJXkZEltgnpnvuqtIwVVQdFhB/jnIvC4sEOs?= =?us-ascii?Q?F58MYH7i6jNByWn5wbzqrAnWzGOaA00C4UKfb6tKxeApBeiFa8v3AuWm7PU0?= =?us-ascii?Q?4LN0L+S/Towuwxa9B2e6r/zbH8pPjdP4yu/tc3WUxq/3rO1SoyEbdMicqj1a?= =?us-ascii?Q?ggfETtJ75W9dDxSi8ydRgabdOJrQToC7hAte5pVsYKR/YTrBliG+n7zitGtM?= =?us-ascii?Q?Wc8W9s9hVJoau7AOkEdA8XdAudzMSEnkaD1zQlrcV6naW1LLTcsIIZnacOYL?= =?us-ascii?Q?aqqK0hV2w1FdgQoH9W2RxWTs?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8d8cd79d-535d-4d3f-3777-08d8e51fdc65 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR10MB4605.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Mar 2021 06:27:07.9184 (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: TCOokEFuHjku8skuLqr2dqmJCXO+Ziodff4RZ2zsTqFQJBO9+J/CvrtRoDq/Nqv+Rhm7EHYoa3ZOzQlBkQ3fJFot+DG5MyAXVmioZMtQ9G0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3191 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,ankur.a.arora@oracle.com X-Gm-Message-State: YdFTCSruovMHafKhtk7mbkTTx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1615530443; bh=HNobZkkDv/RpZLS/MZHDKcA/wN6+JA08Wv/wg/MAYec=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=PotlkIH2QyQxYFJyKon4nw9eI2UqUjW0b/IRKIWyhjwzz7kNkJM/JuhQhiuE6FZaE99 /zo/cQZ0k95C90OjV9MqE+ef2dPMM6Kcbd8ipa6UixAbo+/2dn2laMz7R8f+LJNzmiTd0 +vGW25ksmwTYpi7BdpoRLaujjrOX24zZCx4= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Process fw_remove events in QemuCpuhpCollectApicIds(), and collect APIC IDs and QEMU CPU Selectors for CPUs 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/ Cc: Laszlo Ersek Cc: Jordan Justen Cc: Ard Biesheuvel Cc: Igor Mammedov Cc: Boris Ostrovsky Cc: Aaron Young Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3132 Signed-off-by: Ankur Arora Reviewed-by: Laszlo Ersek --- Notes: Addresses the following comments from v8: (1) Fix commit message to mention that we collect cpu-selectors as we= ll. (2,3,6) s/UnplugSelector/UnplugSelectors/ in CpuHotplug.c, QemuCpuhp.c (4) Fix comment above the declaration of the now renamed mToUnplugSel= ector. (5) Fix spacing around "||". (7) Fix QemuCpuCollectApicIds() comments to line up descriptions for ToUnplugSelectors and other params. (8) s/ExtendSel/ExtendSels/. (9) Add the (ExtendSels =3D> ExtendIds) assert. (10) Fix the missing CurrentSelector++ bug. OvmfPkg/CpuHotplugSmm/QemuCpuhp.h | 1 + OvmfPkg/Include/IndustryStandard/QemuCpuHotplug.h | 1 + OvmfPkg/CpuHotplugSmm/CpuHotplug.c | 29 +++++-- OvmfPkg/CpuHotplugSmm/QemuCpuhp.c | 101 +++++++++++++++---= ---- 4 files changed, 93 insertions(+), 39 deletions(-) diff --git a/OvmfPkg/CpuHotplugSmm/QemuCpuhp.h b/OvmfPkg/CpuHotplugSmm/Qemu= Cpuhp.h index 8adaa0ad91f0..3e2c2192e1c0 100644 --- a/OvmfPkg/CpuHotplugSmm/QemuCpuhp.h +++ b/OvmfPkg/CpuHotplugSmm/QemuCpuhp.h @@ -55,6 +55,7 @@ QemuCpuhpCollectApicIds ( OUT APIC_ID *PluggedApicIds, OUT UINT32 *PluggedCount, OUT APIC_ID *ToUnplugApicIds, + OUT UINT32 *ToUnplugSelectors, OUT UINT32 *ToUnplugCount ); =20 diff --git a/OvmfPkg/Include/IndustryStandard/QemuCpuHotplug.h b/OvmfPkg/In= clude/IndustryStandard/QemuCpuHotplug.h index a34a6d3fae61..2ec7a107a64d 100644 --- a/OvmfPkg/Include/IndustryStandard/QemuCpuHotplug.h +++ b/OvmfPkg/Include/IndustryStandard/QemuCpuHotplug.h @@ -34,6 +34,7 @@ #define QEMU_CPUHP_STAT_ENABLED BIT0 #define QEMU_CPUHP_STAT_INSERT BIT1 #define QEMU_CPUHP_STAT_REMOVE BIT2 +#define QEMU_CPUHP_STAT_FW_REMOVE BIT4 =20 #define QEMU_CPUHP_RW_CMD_DATA 0x8 =20 diff --git a/OvmfPkg/CpuHotplugSmm/CpuHotplug.c b/OvmfPkg/CpuHotplugSmm/Cpu= Hotplug.c index bf68fcd42914..ee1497b93140 100644 --- a/OvmfPkg/CpuHotplugSmm/CpuHotplug.c +++ b/OvmfPkg/CpuHotplugSmm/CpuHotplug.c @@ -45,13 +45,16 @@ STATIC CPU_HOT_PLUG_DATA *mCpuHotPlugData; // don't want to allocate SMRAM at OS runtime, and potentially fail (or // fragment the SMRAM map). // -// These arrays provide room for ("possible CPU count" minus one) APIC IDs -// each, as we don't expect every possible CPU to appear, or disappear, in= a -// single MMI. The numbers of used (populated) elements in the arrays are +// The first array stores APIC IDs for hot-plug events, the second and the +// third store APIC IDs and QEMU CPU Selectors (both indexed similarly) for +// hot-unplug events. All of these provide room for "possible CPU count" m= inus +// one elements as we don't expect every possible CPU to appear, or disapp= ear, +// in a single MMI. The numbers of used (populated) elements in the arrays= are // determined on every MMI separately. // STATIC APIC_ID *mPluggedApicIds; STATIC APIC_ID *mToUnplugApicIds; +STATIC UINT32 *mToUnplugSelectors; // // Address of the non-SMRAM reserved memory page that contains the Post-SM= M Pen // for hot-added CPUs. @@ -289,6 +292,7 @@ CpuHotplugMmi ( mPluggedApicIds, &PluggedCount, mToUnplugApicIds, + mToUnplugSelectors, &ToUnplugCount ); if (EFI_ERROR (Status)) { @@ -333,7 +337,9 @@ CpuHotplugEntry ( ) { EFI_STATUS Status; + UINTN Len; UINTN Size; + UINTN SizeSel; =20 // // This module should only be included when SMM support is required. @@ -387,8 +393,9 @@ CpuHotplugEntry ( // // Allocate the data structures that depend on the possible CPU count. // - if (RETURN_ERROR (SafeUintnSub (mCpuHotPlugData->ArrayLength, 1, &Size))= || - RETURN_ERROR (SafeUintnMult (sizeof (APIC_ID), Size, &Size))) { + if (RETURN_ERROR (SafeUintnSub (mCpuHotPlugData->ArrayLength, 1, &Len)) = || + RETURN_ERROR (SafeUintnMult (sizeof (APIC_ID), Len, &Size)) || + RETURN_ERROR (SafeUintnMult (sizeof (UINT32), Len, &SizeSel))) { Status =3D EFI_ABORTED; DEBUG ((DEBUG_ERROR, "%a: invalid CPU_HOT_PLUG_DATA\n", __FUNCTION__)); goto Fatal; @@ -405,6 +412,12 @@ CpuHotplugEntry ( DEBUG ((DEBUG_ERROR, "%a: MmAllocatePool(): %r\n", __FUNCTION__, Statu= s)); goto ReleasePluggedApicIds; } + Status =3D gMmst->MmAllocatePool (EfiRuntimeServicesData, SizeSel, + (VOID **)&mToUnplugSelectors); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: MmAllocatePool(): %r\n", __FUNCTION__, Statu= s)); + goto ReleaseToUnplugApicIds; + } =20 // // Allocate the Post-SMM Pen for hot-added CPUs. @@ -412,7 +425,7 @@ CpuHotplugEntry ( Status =3D SmbaseAllocatePostSmmPen (&mPostSmmPenAddress, SystemTable->BootServices); if (EFI_ERROR (Status)) { - goto ReleaseToUnplugApicIds; + goto ReleaseToUnplugSelectors; } =20 // @@ -472,6 +485,10 @@ ReleasePostSmmPen: SmbaseReleasePostSmmPen (mPostSmmPenAddress, SystemTable->BootServices); mPostSmmPenAddress =3D 0; =20 +ReleaseToUnplugSelectors: + gMmst->MmFreePool (mToUnplugSelectors); + mToUnplugSelectors =3D NULL; + ReleaseToUnplugApicIds: gMmst->MmFreePool (mToUnplugApicIds); mToUnplugApicIds =3D NULL; diff --git a/OvmfPkg/CpuHotplugSmm/QemuCpuhp.c b/OvmfPkg/CpuHotplugSmm/Qemu= Cpuhp.c index 8d4a6693c8d6..8434dd446b96 100644 --- a/OvmfPkg/CpuHotplugSmm/QemuCpuhp.c +++ b/OvmfPkg/CpuHotplugSmm/QemuCpuhp.c @@ -145,27 +145,30 @@ QemuCpuhpWriteCommand ( =20 On error, the contents of the output parameters are undefined. =20 - @param[in] MmCpuIo The EFI_MM_CPU_IO_PROTOCOL instance for - accessing IO Ports. + @param[in] MmCpuIo The EFI_MM_CPU_IO_PROTOCOL instance for + accessing IO Ports. =20 - @param[in] PossibleCpuCount The number of possible CPUs in the system. = Must - be positive. + @param[in] PossibleCpuCount The number of possible CPUs in the system= . Must + be positive. =20 - @param[in] ApicIdCount The number of elements each one of the - PluggedApicIds and ToUnplugApicIds arrays c= an - accommodate. Must be positive. + @param[in] ApicIdCount The number of elements each one of the + PluggedApicIds and ToUnplugApicIds arrays= can + accommodate. Must be positive. =20 - @param[out] PluggedApicIds The APIC IDs of the CPUs that have been - hot-plugged. + @param[out] PluggedApicIds The APIC IDs of the CPUs that have been + hot-plugged. =20 - @param[out] PluggedCount The number of filled-in APIC IDs in - PluggedApicIds. + @param[out] PluggedCount The number of filled-in APIC IDs in + PluggedApicIds. =20 - @param[out] ToUnplugApicIds The APIC IDs of the CPUs that are about to = be - hot-unplugged. + @param[out] ToUnplugApicIds The APIC IDs of the CPUs that are about t= o be + hot-unplugged. =20 - @param[out] ToUnplugCount The number of filled-in APIC IDs in - ToUnplugApicIds. + @param[out] ToUnplugSelectors The QEMU Selectors of the CPUs that are a= bout + to be hot-unplugged. + + @param[out] ToUnplugCount The number of filled-in APIC IDs in + ToUnplugApicIds. =20 @retval EFI_INVALID_PARAMETER PossibleCpuCount is zero, or ApicIdCount = is zero. @@ -187,6 +190,7 @@ QemuCpuhpCollectApicIds ( OUT APIC_ID *PluggedApicIds, OUT UINT32 *PluggedCount, OUT APIC_ID *ToUnplugApicIds, + OUT UINT32 *ToUnplugSelectors, OUT UINT32 *ToUnplugCount ) { @@ -204,6 +208,7 @@ QemuCpuhpCollectApicIds ( UINT32 PendingSelector; UINT8 CpuStatus; APIC_ID *ExtendIds; + UINT32 *ExtendSels; UINT32 *ExtendCount; APIC_ID NewApicId; =20 @@ -245,10 +250,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)); @@ -259,33 +264,63 @@ QemuCpuhpCollectApicIds ( CurrentSelector)); =20 ExtendIds =3D PluggedApicIds; + ExtendSels =3D NULL; ExtendCount =3D PluggedCount; - } else if ((CpuStatus & QEMU_CPUHP_STAT_REMOVE) !=3D 0) { - DEBUG ((DEBUG_VERBOSE, "%a: CurrentSelector=3D%u: remove\n", __FUNCT= ION__, - CurrentSelector)); + } 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", + __FUNCTION__, CurrentSelector)); =20 ExtendIds =3D ToUnplugApicIds; + ExtendSels =3D ToUnplugSelectors; ExtendCount =3D ToUnplugCount; + } else if ((CpuStatus & QEMU_CPUHP_STAT_REMOVE) !=3D 0) { + // + // Let the OSPM deal with the "remove" event. + // + DEBUG ((DEBUG_VERBOSE, "%a: CurrentSelector=3D%u: remove (ignored)\n= ", + __FUNCTION__, CurrentSelector)); + + ExtendIds =3D NULL; + ExtendSels =3D NULL; + ExtendCount =3D NULL; } else { DEBUG ((DEBUG_VERBOSE, "%a: CurrentSelector=3D%u: no event\n", __FUNCTION__, CurrentSelector)); break; } =20 - // - // Save the APIC ID of the CPU with the pending event, to the correspo= nding - // APIC ID array. - // - if (*ExtendCount =3D=3D ApicIdCount) { - DEBUG ((DEBUG_ERROR, "%a: APIC ID array too small\n", __FUNCTION__)); - return EFI_BUFFER_TOO_SMALL; - } - QemuCpuhpWriteCommand (MmCpuIo, QEMU_CPUHP_CMD_GET_ARCH_ID); - NewApicId =3D QemuCpuhpReadCommandData (MmCpuIo); - DEBUG ((DEBUG_VERBOSE, "%a: ApicId=3D" FMT_APIC_ID "\n", __FUNCTION__, - NewApicId)); - ExtendIds[(*ExtendCount)++] =3D NewApicId; + ASSERT ((ExtendIds =3D=3D NULL) =3D=3D (ExtendCount =3D=3D NULL)); + ASSERT ((ExtendSels =3D=3D NULL) || (ExtendIds !=3D NULL)); =20 + if (ExtendIds !=3D NULL) { + // + // Save the APIC ID of the CPU with the pending event, to the + // corresponding APIC ID array. + // For unplug events, also save the CurrentSelector. + // + if (*ExtendCount =3D=3D ApicIdCount) { + DEBUG ((DEBUG_ERROR, "%a: APIC ID array too small\n", __FUNCTION__= )); + return EFI_BUFFER_TOO_SMALL; + } + QemuCpuhpWriteCommand (MmCpuIo, QEMU_CPUHP_CMD_GET_ARCH_ID); + NewApicId =3D QemuCpuhpReadCommandData (MmCpuIo); + DEBUG ((DEBUG_VERBOSE, "%a: ApicId=3D" FMT_APIC_ID "\n", __FUNCTION_= _, + NewApicId)); + if (ExtendSels !=3D NULL) { + ExtendSels[(*ExtendCount)] =3D CurrentSelector; + } + ExtendIds[(*ExtendCount)++] =3D NewApicId; + } // // We've processed the CPU with (known) pending events, but we must ne= ver // clear events. Therefore we need to advance past this CPU manually; --=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 (#72704): https://edk2.groups.io/g/devel/message/72704 Mute This Topic: https://groups.io/mt/81273603/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 16:46:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+72705+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+72705+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 1615530443141991.4465596916398; Thu, 11 Mar 2021 22:27:23 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id Q9ZBYY1788612xKKrLEQ3yh1; Thu, 11 Mar 2021 22:27:22 -0800 X-Received: from userp2130.oracle.com (userp2130.oracle.com [156.151.31.86]) by mx.groups.io with SMTP id smtpd.web10.4848.1615530434478996917 for ; Thu, 11 Mar 2021 22:27:14 -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 12C6A7Ik178512; Fri, 12 Mar 2021 06:27:11 GMT X-Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 37415rgyeg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Mar 2021 06:27:11 +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 12C6PAsL055220; Fri, 12 Mar 2021 06:27:11 GMT X-Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam07lp2049.outbound.protection.outlook.com [104.47.56.49]) by userp3020.oracle.com with ESMTP id 374kgw3bq3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Mar 2021 06:27:11 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eqlN4DxSdLd9OyCAncyaX3WHw6bEHOCpB8L0qRWse4Dii3PbnquF7+lttvhnuMUb7MNp0GvXwVT6U3Nwsq4ZdsNQxUFKXBMYu0WX9xu/V7nvl505P9iwXlgIoDQC8sBB2rEzdU54OV1PgC9BoQWy0ePhGcWCVpBSWzypE/M2u1IQPrYdVi0A+mW2G/XpkZECEo71zzHnDMq23LeoNR/P2pPkr58Vk9nDl0eUBWCjTnS0yTLfDtHmz7VTcG6RiCDrGKAhQcQR3tANfXEUv3bTZ+9RwsUcp8NpxAVk5GNRKRNxK8mjI2V3GRgcilEBQjfNXqD2opLb9VfuV1H0MlrADA== 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=nOhyQYWxPMB/Ll/aIs9h+tZp4+HvVz8O7MSZMdON6VA=; b=czWAV0vd8xfhdK0hYpWo0ZHWXQ18qT2ymh1XSkWMx4pUDbsVgQ9h8drOfBIclx5Pdek4tI/0TxZgrGJLYM7x44tDjd6GOOgebtXJlW0U0FR72dIFfS0J13bSHq5Ty8uLEiSVFrszlvhEssa8GHKrv2kyU5cAibtpcP/B1GjES9QmE+7+TbXW3b8PYc4sCKEV9ivACbmua0bTsyV2sckase6e9yTwz/D9yEzoUx3G+0cyYRnBnBwH2hzQfGbHYD6yHfBgUtxQNSEOf/rDbhG63bH5hGgxoeMp8OQUuSxk4Ay1UlzB9WNfEUkC01uttjQS140kqKS1RjQx4LZWwutP9w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none X-Received: from SJ0PR10MB4605.namprd10.prod.outlook.com (2603:10b6:a03:2d9::24) by BYAPR10MB3191.namprd10.prod.outlook.com (2603:10b6:a03:14f::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.24; Fri, 12 Mar 2021 06:27:09 +0000 X-Received: from SJ0PR10MB4605.namprd10.prod.outlook.com ([fe80::a021:790:7ce6:6f16]) by SJ0PR10MB4605.namprd10.prod.outlook.com ([fe80::a021:790:7ce6:6f16%6]) with mapi id 15.20.3912.030; Fri, 12 Mar 2021 06:27:09 +0000 From: "Ankur Arora" To: devel@edk2.groups.io Cc: lersek@redhat.com, imammedo@redhat.com, boris.ostrovsky@oracle.com, Ankur Arora , Jordan Justen , Ard Biesheuvel , Aaron Young Subject: [edk2-devel] [PATCH v9 03/10] OvmfPkg/CpuHotplugSmm: add Qemu Cpu Status helper Date: Thu, 11 Mar 2021 22:26:49 -0800 Message-Id: <20210312062656.2477515-4-ankur.a.arora@oracle.com> In-Reply-To: <20210312062656.2477515-1-ankur.a.arora@oracle.com> References: <20210312062656.2477515-1-ankur.a.arora@oracle.com> X-Originating-IP: [148.87.23.12] X-ClientProxiedBy: MWHPR02CA0018.namprd02.prod.outlook.com (2603:10b6:300:4b::28) To SJ0PR10MB4605.namprd10.prod.outlook.com (2603:10b6:a03:2d9::24) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Received: from prion.us.oracle.com (148.87.23.12) by MWHPR02CA0018.namprd02.prod.outlook.com (2603:10b6:300:4b::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3912.17 via Frontend Transport; Fri, 12 Mar 2021 06:27:08 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f62ad2f4-7e80-4e64-9f8b-08d8e51fdd1f X-MS-TrafficTypeDiagnostic: BYAPR10MB3191: 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: 5d5UUtJ8Zp5eOP9shK601A164NG/mIVTltshvOGAegaaVuYZoh+w+bxCM/dsWvDohvyMczZLTKaCSUzGXnM7CjdbRqeDML+hHMWy3yalA3q1j0EGGm34QDPvZOUSyTAQnAuy0TTf+S3lNVseujFIkVAwa20SaIWrpNzeXJUaHyUV63G+nVc3/cESDQUT3S2MLbB58WVmvN45S3VXXirhHsQ7Vl5iTTxa/ELYJpigjZQux5YYGpPK76voX6rBEt7t4URl+ta3NLqbcQo6p9om0amEGokdNYmWm82ffssrqVglte1nKEou8+hnAIBa3L6LjJ5JV/61SVq+068Ldc3qJYmdf5SSBm1zFidQfNFwNiE4npDhnPuth/aa21A9lPHVgm6eXISMtypMZOaJfWqGJEyTavKWiL35fT8f8LKZQURdHLXQJF09lNJejEbv4VoJapQzmVBvfAVqc2cUGbJ0sZWeRL5cVz6EZZ/e0uiAcMyrB4TJGPzj5+fbh3kAF+e+WPuB9WWtve+KGfgk0/DWSiDYydOp82IuBO+AYz4MArJdgtZB37n1lEibPt6GrYtd37UWfpgy3/veutrXMJJmQV1knJDAKXpP7JrQb8O5O2Y= X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?Bp0/vSRqcSCv5ZF/mfrzblgohytIvpPR++9rEyrXZNEOs69fKMqTRpqZtwxl?= =?us-ascii?Q?u5cBRgQ2+wyea5bViAZbmfb5Ylq/mSqFhwIvQJ3HFUHGC77ZdFjdPF7/SEK1?= =?us-ascii?Q?jvb0vmZL7HGfuqwEZPi7u+eAUQ47nachfNV/Se0i+9LyeAy2TtupM1voVX49?= =?us-ascii?Q?7kVIC3QGN9hVgeh90VvYotvw1tsxSFc1OfqFWkSVBz0tlkBTlyH31MCR3+Jm?= =?us-ascii?Q?xy2Edcn5ojNHVnONMrtfiy3S5bglktR3za4Vg2LN29fmP4IMduSAXrEgPb2s?= =?us-ascii?Q?RveiaQ1er64ofscmJe6MqUEMf48htXfzKU2mcxY9/alnKzW+cF9SbFtBKc6E?= =?us-ascii?Q?jko02xsMfgd/fwXIwrn76nZa2jSjqicEaJgG09STuCFw/eB91/Fq1K5q8Orm?= =?us-ascii?Q?0x1FLslxmMgAiW6uy4KisYJgGU6nHwkJQEJTKIvG4ZPm1y0DtwEivjQS7yTb?= =?us-ascii?Q?NNzDNm5W+HpU4EvLdJwBwqNcWopE384Uod83NjSlDFFjXnGD9feGs95m0oPV?= =?us-ascii?Q?P1UD5ZKtdCvUAyv0uOcwhSYkNRTEla/sKM7GVvyRYlTl7UPM16V/jzJrEH1D?= =?us-ascii?Q?QJ7cLQLfjy/r5PqFhotDSuGGVixAQafymeO/gwRwJnSj7HAb7iWUIsRyYg09?= =?us-ascii?Q?64/X2jjkIgbjNBZIb9688ZVBkduW6q34g1Sejk9IzBZCZ4kS86690mUAbQsC?= =?us-ascii?Q?cNj0goOY2J9G1/ZODPGtZYAa2ByhgWCsbnZVQTnDt7OJ4dd0jK96NXhE7CFp?= =?us-ascii?Q?h2pFMxA7ZTczGIHDV12GlNbQ+KQKWQ+DZ3A9kT9iEdkUxBuxUAcA6bTJjYPQ?= =?us-ascii?Q?T8r0/EXHgvAeHgWVLcskkAZdvmAnD5+nDG1+oLgkxjxqIfOqvf8MoEwxLz99?= =?us-ascii?Q?lxXlldYJH2ETnvFpZAVVEYAdQ1/xj0Ael/VdJY1dHF7Uma3HWuYU85QeEE37?= =?us-ascii?Q?aOfEazBpCmQQ3nR6Wb+W4ChBSYqsnSbVFlqtm9HhfMG3vg8m6A0mUENXXpaO?= =?us-ascii?Q?K523t8mvMG70tascmNocxMwNk2aHm6u0ePk1Fvt526OVh1HKK5ZAEDbbIsN9?= =?us-ascii?Q?RdOd58X7nQulVKv70M1EEV/bbzSs6wsAp6+QIWsAtlb+/00DSLJ+d4cicwpZ?= =?us-ascii?Q?J5aAtB6lfEt9nGWOml8PA1hRgiOjATTAgqkOlplRFE2LsATT0jvf455Z+x8o?= =?us-ascii?Q?I1+pgNOPQjtpkieCRMirBAJpPjFuMTXKSNtvLxFL31skAMVzBFaPA0MFSiGQ?= =?us-ascii?Q?63Lm6fWijeNebaZ+054SsxD7E4D/92djpmXcbvXV1YdVSsHIYg70lyetDNom?= =?us-ascii?Q?K7AtAvZoWGJTXsUTLkP0togv?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f62ad2f4-7e80-4e64-9f8b-08d8e51fdd1f X-MS-Exchange-CrossTenant-AuthSource: SJ0PR10MB4605.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Mar 2021 06:27:09.1291 (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: dTxl2abGWk5dfwGkspyQMunHejbzbG9pz8fb+l36sOCgjB4ZrI9s4QvsQAiie/P9kJEexUVtq5uV+D4jHe4S4tM2f8k8QPvaiRWT2zUcEl4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3191 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,ankur.a.arora@oracle.com X-Gm-Message-State: BaSFXME2lMUowMJdLvtIuDULx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1615530442; bh=uS8abgOVmAU6AFvEzElfFq8GatWN+o71QfQpM1x0a70=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=rgfZPIaURTA9G7+3ezwa9hXFN7Eq2yMho+OrA2gWijR0780s5Rh4CZnrou+CfiJuu2q UfDH5tfjcbh6L1KlauuLEDE7TV6hApyVjSvEMuvjAFI35Vl3fUEVMblOHLfdW00Wml2jx G46BQ9Dzgj3jV9xT3bd9Wqb6HzJq6R5R5N4= 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 Reviewed-by: Laszlo Ersek --- 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 3e2c2192e1c0..8bb3c66e9b44 100644 --- a/OvmfPkg/CpuHotplugSmm/QemuCpuhp.h +++ b/OvmfPkg/CpuHotplugSmm/QemuCpuhp.h @@ -42,6 +42,12 @@ QemuCpuhpWriteCpuSelector ( ); =20 VOID +QemuCpuhpWriteCpuStatus ( + IN CONST EFI_MM_CPU_IO_PROTOCOL *MmCpuIo, + IN UINT8 CpuStatus + ); + +VOID QemuCpuhpWriteCommand ( IN CONST EFI_MM_CPU_IO_PROTOCOL *MmCpuIo, IN UINT8 Command diff --git a/OvmfPkg/CpuHotplugSmm/QemuCpuhp.c b/OvmfPkg/CpuHotplugSmm/Qemu= Cpuhp.c index 8434dd446b96..dc86ab96777a 100644 --- a/OvmfPkg/CpuHotplugSmm/QemuCpuhp.c +++ b/OvmfPkg/CpuHotplugSmm/QemuCpuhp.c @@ -114,6 +114,28 @@ QemuCpuhpWriteCpuSelector ( } =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 (); + } +} + +VOID QemuCpuhpWriteCommand ( IN CONST EFI_MM_CPU_IO_PROTOCOL *MmCpuIo, IN UINT8 Command --=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 (#72705): https://edk2.groups.io/g/devel/message/72705 Mute This Topic: https://groups.io/mt/81273604/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 16:46:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+72706+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+72706+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=oracle.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 16155304452051018.6747982456727; Thu, 11 Mar 2021 22:27:25 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id l1QFYY1788612xJlenwQjYXT; Thu, 11 Mar 2021 22:27:24 -0800 X-Received: from aserp2120.oracle.com (aserp2120.oracle.com [141.146.126.78]) by mx.groups.io with SMTP id smtpd.web08.4833.1615530436464209442 for ; Thu, 11 Mar 2021 22:27:16 -0800 X-Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 12C68p0B167414; Fri, 12 Mar 2021 06:27:13 GMT X-Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 3741pmrya7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Mar 2021 06:27:13 +0000 X-Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 12C6PAsM055220; Fri, 12 Mar 2021 06:27:12 GMT X-Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam07lp2049.outbound.protection.outlook.com [104.47.56.49]) by userp3020.oracle.com with ESMTP id 374kgw3bq3-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Mar 2021 06:27:11 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JXH1FwJkpCS0OgLvae7LzKjgqeQvv8mt+nkW+zq3uOCjwRQubz7gbnrCGukX3idBUtG/we0eVwUueH7fCTaHmQV0DE51lyU4qQA5B/TxeyjpzYipMq0Ii94gJsZJrzJ3e84NUBo4Kq5Px4+/uX73AF1/9DXSbQy5XrZAXE6OSNnEvf3hiZyYV8SBBMKc9HLmW1LojxqfEF+rp2gEzQkx4Uxcv5OJGXpOrPanuSskEMVHAgULuH8fyy94FofTDcFFxY88M+DViJGx6/v0FSNmZU4vJ9OnUSOKXDW0Qx1eUKsUxZkw2l1qtfeNo65Gvh7yX2woZh39V+mAJQTYsUf6Iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=W4G/9tJMJE8B66m+q8RYiTcxRG8s0I9WhzY+9kdJExs=; b=Wx451MEDGZQpMCB1N0ls6itQWrn99Dhfp31VlVQxBOkLOlxrJYxudHXU8/XamrlnpkFt5fjucycIYrVPBv03xOjzmJhBglfS7S2d/fvQzkuu9UxRdRAyAPDVv9eai3WOKbnuf1Zsd2a/xAM38KonOcoyCz9aR3fSNGumUTABrRB+esCUuXfmFmlA4ByDmK3OmpK2oJnFo/DFUZQF+qe98TcbRfJNkmO4YJZxWxfN5GpkySnsgu7qybYLA6hC1hgw0IHP8bXF12azWMbeKFGdRSOGI8MISuycZmimUHFqAEkkRf1570MjMs8f2z8OhVfX+F2ucRV1KBukhczKQKd2Jg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none X-Received: from SJ0PR10MB4605.namprd10.prod.outlook.com (2603:10b6:a03:2d9::24) by BYAPR10MB3191.namprd10.prod.outlook.com (2603:10b6:a03:14f::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.24; Fri, 12 Mar 2021 06:27:10 +0000 X-Received: from SJ0PR10MB4605.namprd10.prod.outlook.com ([fe80::a021:790:7ce6:6f16]) by SJ0PR10MB4605.namprd10.prod.outlook.com ([fe80::a021:790:7ce6:6f16%6]) with mapi id 15.20.3912.030; Fri, 12 Mar 2021 06:27:10 +0000 From: "Ankur Arora" To: devel@edk2.groups.io Cc: lersek@redhat.com, imammedo@redhat.com, boris.ostrovsky@oracle.com, Ankur Arora , Jordan Justen , Ard Biesheuvel , Aaron Young Subject: [edk2-devel] [PATCH v9 04/10] OvmfPkg/CpuHotplugSmm: introduce UnplugCpus() Date: Thu, 11 Mar 2021 22:26:50 -0800 Message-Id: <20210312062656.2477515-5-ankur.a.arora@oracle.com> In-Reply-To: <20210312062656.2477515-1-ankur.a.arora@oracle.com> References: <20210312062656.2477515-1-ankur.a.arora@oracle.com> X-Originating-IP: [148.87.23.12] X-ClientProxiedBy: MWHPR02CA0018.namprd02.prod.outlook.com (2603:10b6:300:4b::28) To SJ0PR10MB4605.namprd10.prod.outlook.com (2603:10b6:a03:2d9::24) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Received: from prion.us.oracle.com (148.87.23.12) by MWHPR02CA0018.namprd02.prod.outlook.com (2603:10b6:300:4b::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3912.17 via Frontend Transport; Fri, 12 Mar 2021 06:27:09 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: da5b5b40-798b-4787-b9d3-08d8e51fddd9 X-MS-TrafficTypeDiagnostic: BYAPR10MB3191: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: 99mbkdRbqaYc/5hJK7D0IYH1C71Og9kXgvshatq5kFKTfETWf6j13BXVJfCOMyEZY1F18FUKAGDaAcCTJSOKWjmo9+yTZhHSW5pI+OWex/9Avjp6JLVcQ05ybk2XQwFX1gZnDpB64Y8a5ymbND2jkzOqwIwhOCmq0JWOC5id97KxdKgfGcPH4sKMy2K1J5Jxt47iHaIVNBo48Fgf+4CAn1sF+sSbC7jqmi1idwVX3Qkz6aHSi89dx5dd1nPvF5FoUJZOAhggkq+GGXp38gt6ghF5kwpaQ8NrOqpdRyxwq82PPjUnFjEne0bwZZ+S6OYf5xhN56r6iYnWVLsWL1gnIrIwTKLicXi7xDN1S255TQyiDdPR04/RY8jMvSjB0uedz9U2J1rVlSpktZfzYBwh1O5ZbMI/JEc05zJkIH4VC2g+oAlZ42YGVIIGbUrfx33Xeb+ov2gMD2q+Hn+nO792opH5eeWK/BvgsIaW/vQP8xbfe7WlGkHLB6vcjTrGZzhddjD79iip6jExZlLbzZ+nvb9/7GTwXqTfcpp31aaF2MqqwfDnbdFzJaoh85jrwPyvP1qOND125I+uDsmymGR11622OcY582ZotpFT9BMt1Jw= X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?8fHl3ViafkL0nEUyxohHrgyhpg+4Uew/iEevT1ErDnQFEvIlPqhnpy0b6J83?= =?us-ascii?Q?nXafwfnxNgnprNC6utepoFh+sQpn556zuHdBHQK3qRhkKmVoJds7LIC5bFWQ?= =?us-ascii?Q?QxyfVybNd3SruPmbjxkm6hl0q5nUJYx0A7OvpsPT8t9Qsr0LPzPhn9/Pny0r?= =?us-ascii?Q?GrtpaZ4A6hw2sEycOVwMBJCsk0Kpn04BcHrJnAfY/M+2zKY6XH5YruA5bdJz?= =?us-ascii?Q?/T9HazFGqWAMpSam5XH3yz1w55ps93mmKPoCB4pqywYT833IXVDyDGXnPy/l?= =?us-ascii?Q?J2gvNG7Hrle6wA66NacfyigYRgsj1NkmqdKmz44V4berSFZ6YgMZHY37C7rO?= =?us-ascii?Q?0DyGkmJNKx8KQWeV9EXb/AFseMKJeffUyD5rZJVt/CAkmBwSTAGZI8kaqtGE?= =?us-ascii?Q?NQxQrgeE3ShKdPpY1cQSbAubpp+J/8a1bbl9ikRv9NVo/XSvYOR38irvO/Uh?= =?us-ascii?Q?UsepEBcQmZ3nyNrTbO6XfyRfvCLgXCa+A7VbeIlosCavEBIlFY2IboVyZDQO?= =?us-ascii?Q?8e+XDyhf5QZd2f4AxtoVygH4U2/4iTZ51Xql+VhTUX6q2/1VtJ+KGpCFDFSN?= =?us-ascii?Q?0qf1WiOH99waNnuR3xXLnOuL4Ej56O+dICrP+WcU8P7UaRfG0wKyHpEzsC6v?= =?us-ascii?Q?wB6lxXHSf26T6oGjhWPsKVBpIwDVc7+ltr+qDqLEYusW1hMaykDP8WRI38f2?= =?us-ascii?Q?rXNFBCbTkuK8uQRwvUrxBKWdvrP1gUVkgE7jvZxrHWgldJUijQ2RFhoxQuUu?= =?us-ascii?Q?JSAKFcQNsCba6ld9Z1Jj9cKYq9AzrWr1U9Nx35rC+tocZy0wC9BYQfe1fASH?= =?us-ascii?Q?96YgN9MIYh8VuslsmATz6+2+YXgTZvr3kVp1MfLWRoqmcRyHc8l/vf/0AxYx?= =?us-ascii?Q?KT3zgeipMnFA9tGaNQXnxqHT81/6pvHPs9eqdmnCjXXIAR7yR/P1vvs+Rbpn?= =?us-ascii?Q?4hOzrqC/2l8P/7xTkHtzoELFnY3/M/k2J/gRhWOI28CD3+QFKAEBcG9LFsxE?= =?us-ascii?Q?VloG/R1VlvgBbZ82MyBh533oWrLQu15To+NhbwrnR9OoSmQqL075/NZqVTx5?= =?us-ascii?Q?ir+NF2M+u7rRcLm8ylfZcTp2cv352jD1Vg1s7Ik1yPw+jLxKjzj7GBUeJLo3?= =?us-ascii?Q?Oc7fYNJLl6NtI3uqCJXfIbX25TspRlNHX2Z/+HW6dlo7x10+vro/sZIV02//?= =?us-ascii?Q?z7gjnSkZP+9ep2n+fFR606Hde+BC5UbPL8cAifdHSg94GpZINZekwlfSI+kZ?= =?us-ascii?Q?NUxvD+YvKj3wwrdvw7qMDWsysUVn+bGyIk8z4VO8PQDhAsRfeOW0xCb7L7kU?= =?us-ascii?Q?tUNerGcwx9vmfxT4u7RPKHa+?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: da5b5b40-798b-4787-b9d3-08d8e51fddd9 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR10MB4605.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Mar 2021 06:27:10.3507 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: WAoyr17h1360igIJ8aqIDFvDCOX+xrT9dZd5kCMi4xr72viullb5F4YwkavuMDEoLRh1OG2sRVvECcCGkaZghMaJJeiLo4ZF1jN80qCFyF8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3191 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,ankur.a.arora@oracle.com X-Gm-Message-State: 4fX7MEQ6PG0I8GhASifuLG10x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1615530444; bh=qLazBEg7+u+fnvxHoaMkC6L+zZNobLOZJxWe0kDpk2I=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=UMK6A78JEpii8buMYkDJL/e/HNrWDA+tb4SR4pVzp4d2XFWXx3JcwlL394DGdXJTDhy elCL51xpnivAfh1/lD1wzVJRpQKnwe2j3+7qiqEcbeOyiRFGTqowZd/NDwCpsX5kDACXB BL+TL3Vu4zSCVd6fwXdhNaQmBjTr0pK3xfo= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Introduce UnplugCpus() which maps each APIC ID being unplugged onto the hardware ID of the processor and informs PiSmmCpuDxeSmm of removal by calling EFI_SMM_CPU_SERVICE_PROTOCOL.RemoveProcessor(). With this change we handle the first phase of unplug where we collect the CPUs that need to be unplugged and mark them for removal in SMM data structures. Cc: Laszlo Ersek Cc: Jordan Justen Cc: Ard Biesheuvel Cc: Igor Mammedov Cc: Boris Ostrovsky Cc: Aaron Young Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3132 Signed-off-by: Ankur Arora Reviewed-by: Laszlo Ersek --- OvmfPkg/CpuHotplugSmm/CpuHotplug.c | 84 ++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 84 insertions(+) diff --git a/OvmfPkg/CpuHotplugSmm/CpuHotplug.c b/OvmfPkg/CpuHotplugSmm/Cpu= Hotplug.c index ee1497b93140..59f000eb7886 100644 --- a/OvmfPkg/CpuHotplugSmm/CpuHotplug.c +++ b/OvmfPkg/CpuHotplugSmm/CpuHotplug.c @@ -190,6 +190,83 @@ RevokeNewSlot: } =20 /** + Process to be hot-unplugged CPUs, per QemuCpuhpCollectApicIds(). + + For each such CPU, report the CPU to PiSmmCpuDxeSmm via + EFI_SMM_CPU_SERVICE_PROTOCOL. If the to be hot-unplugged CPU is + unknown, skip it silently. + + @param[in] ToUnplugApicIds The APIC IDs of the CPUs that are about to= be + hot-unplugged. + + @param[in] ToUnplugCount The number of filled-in APIC IDs in + ToUnplugApicIds. + + @retval EFI_SUCCESS Known APIC IDs have been removed from SMM = data + structures. + + @return Error codes propagated from + mMmCpuService->RemoveProcessor(). +**/ +STATIC +EFI_STATUS +UnplugCpus ( + IN APIC_ID *ToUnplugApicIds, + IN UINT32 ToUnplugCount + ) +{ + EFI_STATUS Status; + UINT32 ToUnplugIdx; + UINTN ProcessorNum; + + ToUnplugIdx =3D 0; + while (ToUnplugIdx < ToUnplugCount) { + APIC_ID RemoveApicId; + + RemoveApicId =3D ToUnplugApicIds[ToUnplugIdx]; + + // + // mCpuHotPlugData->ApicId maps ProcessorNum -> ApicId. Use it to find + // the ProcessorNum for the APIC ID to be removed. + // + for (ProcessorNum =3D 0; + ProcessorNum < mCpuHotPlugData->ArrayLength; + ProcessorNum++) { + if (mCpuHotPlugData->ApicId[ProcessorNum] =3D=3D RemoveApicId) { + break; + } + } + + // + // Ignore the unplug if APIC ID not found + // + if (ProcessorNum =3D=3D mCpuHotPlugData->ArrayLength) { + DEBUG ((DEBUG_VERBOSE, "%a: did not find APIC ID " FMT_APIC_ID + " to unplug\n", __FUNCTION__, RemoveApicId)); + ToUnplugIdx++; + continue; + } + + // + // Mark ProcessorNum for removal from SMM data structures + // + Status =3D mMmCpuService->RemoveProcessor (mMmCpuService, ProcessorNum= ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: RemoveProcessor(" FMT_APIC_ID "): %r\n", + __FUNCTION__, RemoveApicId, Status)); + return Status; + } + + ToUnplugIdx++; + } + + // + // We've removed this set of APIC IDs from SMM data structures. + // + return EFI_SUCCESS; +} + +/** CPU Hotplug MMI handler function. =20 This is a root MMI handler. @@ -311,6 +388,13 @@ CpuHotplugMmi ( } } =20 + if (ToUnplugCount > 0) { + Status =3D UnplugCpus (mToUnplugApicIds, ToUnplugCount); + if (EFI_ERROR (Status)) { + goto Fatal; + } + } + // // We've handled this MMI. // --=20 2.9.3 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#72706): https://edk2.groups.io/g/devel/message/72706 Mute This Topic: https://groups.io/mt/81273605/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Thu Nov 14 16:46:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+72708+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+72708+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 16155304450911010.484750711073; Thu, 11 Mar 2021 22:27:25 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id LEnyYY1788612xiXjjoueTkn; Thu, 11 Mar 2021 22:27:24 -0800 X-Received: from aserp2130.oracle.com (aserp2130.oracle.com [141.146.126.79]) by mx.groups.io with SMTP id smtpd.web11.4907.1615530438004316117 for ; Thu, 11 Mar 2021 22:27:18 -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 12C69ddh138956; Fri, 12 Mar 2021 06:27:14 GMT X-Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2130.oracle.com with ESMTP id 373y8c14at-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Mar 2021 06:27:14 +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 12C6PApm055289; Fri, 12 Mar 2021 06:27:13 GMT X-Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam07lp2049.outbound.protection.outlook.com [104.47.56.49]) by userp3020.oracle.com with ESMTP id 374kgw3bqs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Mar 2021 06:27:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NMbYBY6HRIJKGGHdtMyfCUPpsKdkJqxUMP5uTzan2PsMK+km9TRljJ66IVdPkWBZ2PAk/AZVuVVDYm4td0pSdQPmUt0ZzN7TTSpS7SW8T2lkOqwRnKiu+FDi8PcSAE4tZ2UOwogfiRqEgCP/pMP9OrJy1yrzQSKXZ+NL/v3svmf5C4wU2dMqMVuNBxoWmCd4CHq5uTRgmwjeo7czGPBaOyCJXODrww/scjyDhOMr0/P4nTDuJzWLs1o7BCzAgx1A99dMovQXp94yWbidPgtqC4Ht3AIoulZDU7enZaW3ZKV6NfNfstRgMNprFOo9DTnKivkNwNhEtUF3eM5PZ9r2QQ== 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=ZKwOjsA/j2uhFjAO7h8+5U4/CjyACPw7z4wyzxrfMKY=; b=ghB1m/DF7MnNlmXJ6IDYOl5tmedDC2eFv5DQHOvxQyWJn4ped3g+Kgey2e6bKGEWEQ9HZinXIaCUv0KZky6apJzn1XUE8xvEkzlVcaHYTao0GiPl4TDFGTcFhGsXXLDUZAAGLYY+AnQO4aVgKDcMEydxfuZ7pZntdTK8aWCXC3f1QzFulvU3gyGMEgAOuwR9x2KrStFWtBR/BLNOhvKBjEBDpTtMLKaJFC5lKZEP2+jQPxDfRj3loEA8jKZYeva5TJyfd+5zK3pnzi8vuoRJAQCvWI1+Nq3UoNUxbNJKXZwnS952nkgciSCV9B/9TeeR9Ce9n8CF38IC263mqoSk7Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none X-Received: from SJ0PR10MB4605.namprd10.prod.outlook.com (2603:10b6:a03:2d9::24) by BYAPR10MB3191.namprd10.prod.outlook.com (2603:10b6:a03:14f::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.24; Fri, 12 Mar 2021 06:27:11 +0000 X-Received: from SJ0PR10MB4605.namprd10.prod.outlook.com ([fe80::a021:790:7ce6:6f16]) by SJ0PR10MB4605.namprd10.prod.outlook.com ([fe80::a021:790:7ce6:6f16%6]) with mapi id 15.20.3912.030; Fri, 12 Mar 2021 06:27:11 +0000 From: "Ankur Arora" To: devel@edk2.groups.io Cc: lersek@redhat.com, imammedo@redhat.com, boris.ostrovsky@oracle.com, Ankur Arora , Jordan Justen , Ard Biesheuvel , Aaron Young Subject: [edk2-devel] [PATCH v9 05/10] OvmfPkg: define CPU_HOT_EJECT_DATA Date: Thu, 11 Mar 2021 22:26:51 -0800 Message-Id: <20210312062656.2477515-6-ankur.a.arora@oracle.com> In-Reply-To: <20210312062656.2477515-1-ankur.a.arora@oracle.com> References: <20210312062656.2477515-1-ankur.a.arora@oracle.com> X-Originating-IP: [148.87.23.12] X-ClientProxiedBy: MWHPR02CA0018.namprd02.prod.outlook.com (2603:10b6:300:4b::28) To SJ0PR10MB4605.namprd10.prod.outlook.com (2603:10b6:a03:2d9::24) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Received: from prion.us.oracle.com (148.87.23.12) by MWHPR02CA0018.namprd02.prod.outlook.com (2603:10b6:300:4b::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3912.17 via Frontend Transport; Fri, 12 Mar 2021 06:27:10 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a5ca63e7-b106-456c-5c02-08d8e51fde8e X-MS-TrafficTypeDiagnostic: BYAPR10MB3191: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:568; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: SoW/vj5/OWisMZyR2wRE2tJdxI8ZaV5yv1hOBeCbkf0rDIcUorh9lHvwD8RbTSONavklNU9qzBBWFZjhIatPPUZ6zJYlgnTXx72wjZBYmjs+kq81ruUpW2dItqYTXNxQfQasvTFsILr7+XvuvFE5byGDWYybKiOfa7cI4lWzkAn+hddRO2FG7rAt6XfUzw6sNwhf9rL2YvcF4goSQJeUjBDAXJt45wIVjP1FxO8Wlt2wGbZ8nHZx/uLh/Qbk7cSkfZznThEG/5p43+R8O5yAXCE9WWQX0TMO8n2dLhUgGwC1HEEN9IX0NYF+XX/lzVq7DwJyXz6cUYJn5zGwHkjo7Vlh7fgiXqJKMVyKSw7uksE7EvyFhiEz0w20ccLfBmKbfRL0qlPTlIxUhJE5QUJbHeeWOnjm40lVWJq1/tMxO/KM0zNFVZ+3rEhs8Za31Sn3cyyNJj5zyptiB2FtIjAlje/uZ/POE0IKvE0+aWRKdtIXbAWy1ZX4Hspf1AhmN0N4DAY3+TD3QwdDjLVCxZxfn7XfKVt6oE9s61HvkfWY/pAVjlnSy3objiR6N0C6RH5FFkjB0iKoYxX7D/8pQWbUjZ2aQujIF1oWbVKAYy7nO8w= X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?VoGU6uvZyI4WCVDhZ7EkjPaQrIBWagBZugtNxbQ+MPsP9EgtWWGgRMmjEh7e?= =?us-ascii?Q?OiAFAIvVmnOqtTY8WoCevhelyZkUtTEd7YeUexfYDowQsTmikAXNSHaEVYhu?= =?us-ascii?Q?ZptT/lw3txl1OqNDl2yvn/wlT4PDxevqCZfcjLSSsYl1wqoxTADaMmBPuBmz?= =?us-ascii?Q?Cv8eAD2YucL7fFQqa5h1UEoWy+sBWltQyT76UoZHTbK3VNGqjfZFxP5vgPgD?= =?us-ascii?Q?TdtQFedVfUHRuZf4yjbl5NkdlAU3BIwvoTMhS5ZqteKCVgAnW6gaELNQwzgs?= =?us-ascii?Q?bc3o5pIixaUKP9HoNDItJbs0pV9GzxrpJinCrpne11aLZyi7cBJiuKlqq7xR?= =?us-ascii?Q?tJTHQsbp6HEmqqqo14fLLYaan/njBuXkB8oB2efiGNTbb+Qoct4/dtEfFJFr?= =?us-ascii?Q?/PSrn9iTlR7I1jDBOixUucfNHUa6ppztIqmGSEIUkrzBze3ir90AEXc4makn?= =?us-ascii?Q?m6uFB72/OAdXchRXghyGuifADJTNfIYRYMNcnEVuRTRSkux2Z9XsQfIRFg0X?= =?us-ascii?Q?PhKLazqIPk9hTwcHpHIkG9FJa3NQ302rHv0TSyX4WZXSmA1LtfKzDBLyvAM2?= =?us-ascii?Q?G8lh1RnbR97cXS9VUgp4oyt2RASXvaWAQVNFHlCTK033Q7MwYJ49OtfKbLrg?= =?us-ascii?Q?m+H1LqORZWMQ/GIUPsN2GeccH4YUSsp9om+4HjbXzthaC90i4UFTNi0s64Nm?= =?us-ascii?Q?YxYBLZ22KZiKj0AMcVxpyCXP/p0DvYXNv1g+lxkby/8sTt3HPJwE2oeZApoe?= =?us-ascii?Q?rln805Zn95dCxtGvtVGsMm/8XY3mZoj3Jnz9zeby7RjuT3+g8r6ZP962X9kk?= =?us-ascii?Q?Ru0jTOILc0uyj7MhcxE6rsmBe4yMeFM2U3bqYEoPjq8tYppd4Jrvhvj4GIes?= =?us-ascii?Q?VVCVTZ02Oz/9X15VWGuBny6xmdgNPODphKRKwv8Jbgt9OwgM3v2WPzVX3fU/?= =?us-ascii?Q?oG/1ofxqjX9WqxfyiUVQMvDehpcfH9LfZqVSCI0GrctfuGhd9J4QoYYMhKke?= =?us-ascii?Q?vtTQ+pwmkofWlOmMDmfJMZ8sWwe4BpL5cOs4E6Bsm1rwkY+UNgYjCSokADFO?= =?us-ascii?Q?gEXShY0TZWfhDdkXcxZuPk3L5WBOel8c7gz/b8qH6ndfEyjGe0bQzl/MSMZ4?= =?us-ascii?Q?fTUeEHhLJ0GZP1DH96iPo+SPtAU+UcRe0Y2A4YqmNjvHpVoWYD9koAW1Zki8?= =?us-ascii?Q?t6s/XkW+fpaLE9YXB+8sHzWy9pP8L6Pvyt+fNXM/m0nb46L47ruEm4faLXKU?= =?us-ascii?Q?gBBZcBIwsZOAQSnWG+AR0s7f5/HJTB8kw13FZKXC8oP4Jx52mdhb1wrpkhuV?= =?us-ascii?Q?8jhlxb/XsgZ8Q6R9Q5aKrV0y?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a5ca63e7-b106-456c-5c02-08d8e51fde8e X-MS-Exchange-CrossTenant-AuthSource: SJ0PR10MB4605.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Mar 2021 06:27:11.5335 (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: 2q6qFWT0hSBNuFIxbWToQUespVRlmBBzUDRrotBzCK4w8k8NEoJyiT3YN6nuno875Kfef4vz39Cv2f6btLhk2mU/UByJhqo3U4EDaXGG1iA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3191 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,ankur.a.arora@oracle.com X-Gm-Message-State: XNgG4ZRbbsEID1AXPJ7eimNax1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1615530444; bh=RagIO/qagabkVnYx8ssT1Dbe2vG1A3eieRdodJC1LwY=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=lUwpToYVh+KPDYRMaRuaS9nzc0s82iD1MosA//F7ZJCdPh1yl/OEUrEBDPFwpKfj/dW 0O7RFYqbNiQzXb9thiG991Ojk0iEoPyAZAcXnmu4fwwRuI5RIRm3ZIODMbWykGIagNams pOczAngk/UkA1b5aeR/Sl9seOKRrFF3FT9c= 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 Reviewed-by: Laszlo Ersek --- Notes: Addresses the following comments from v8: =20 (1) Get rid of the unnecessary commit specifier from the subject. (2) s/MaxNumberOfCpus/PcdCpuMaxLogicalProcessorNumber/ (3) Shifted the comments to be above each structure field. OvmfPkg/OvmfPkg.dec | 4 +++ OvmfPkg/Include/Pcd/CpuHotEjectData.h | 60 +++++++++++++++++++++++++++++++= ++++ 2 files changed, 64 insertions(+) create mode 100644 OvmfPkg/Include/Pcd/CpuHotEjectData.h diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec index 4348bb45c64a..9629707020ba 100644 --- a/OvmfPkg/OvmfPkg.dec +++ b/OvmfPkg/OvmfPkg.dec @@ -352,6 +352,10 @@ [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 OVMF's SmmCpuFeaturesLib + # instance in PiSmmCpuDxeSmm, and CpuHotplugSmm. + gUefiOvmfPkgTokenSpaceGuid.PcdCpuHotEjectDataAddress|0|UINT64|0x46 + [PcdsFeatureFlag] gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderPciTranslation|TRUE|BOOLEAN|0= x1c gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderMmioTranslation|FALSE|BOOLEAN= |0x1d diff --git a/OvmfPkg/Include/Pcd/CpuHotEjectData.h b/OvmfPkg/Include/Pcd/Cp= uHotEjectData.h new file mode 100644 index 000000000000..06714375526c --- /dev/null +++ b/OvmfPkg/Include/Pcd/CpuHotEjectData.h @@ -0,0 +1,60 @@ +/** @file + Definition for the CPU_HOT_EJECT_DATA structure, which shares + CPU hot-eject state between OVMF's SmmCpuFeaturesLib instance in + PiSmmCpuDxeSmm, and CpuHotplugSmm. + + CPU_HOT_EJECT_DATA is allocated in SMRAM, and pointed-to by + PcdCpuHotEjectDataAddress. + + PcdCpuHotEjectDataAddress is valid when SMM_REQUIRE is TRUE + and PcdCpuMaxLogicalProcessorNumber > 1. + + Copyright (C) 2021, Oracle Corporation. + + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef CPU_HOT_EJECT_DATA_H_ +#define CPU_HOT_EJECT_DATA_H_ + +/** + CPU Hot-eject handler, called from SmmCpuFeaturesRendezvousExit() + on each CPU at exit from SMM. + + @param[in] ProcessorNum ProcessorNum denotes the CPU exiting SMM, + and will be used as an index into + CPU_HOT_EJECT_DATA->QemuSelectorMap. It is + identical to the processor handle in + EFI_SMM_CPU_SERVICE_PROTOCOL. +**/ +typedef +VOID +(EFIAPI *CPU_HOT_EJECT_HANDLER) ( + IN UINTN ProcessorNum + ); + +// +// CPU_EJECT_QEMU_SELECTOR_INVALID marks CPUs not being ejected in +// CPU_HOT_EJECT_DATA->QemuSelectorMap. +// +// QEMU CPU Selector is UINT32, so we choose an invalid value larger +// than that type. +// +#define CPU_EJECT_QEMU_SELECTOR_INVALID (MAX_UINT64) + +typedef struct { + // + // Maps ProcessorNum -> QemuSelector for pending hot-ejects + // + volatile UINT64 *QemuSelectorMap; + // + // Handler to do the CPU ejection + // + volatile CPU_HOT_EJECT_HANDLER Handler; + // + // Entries in the QemuSelectorMap + // + UINT32 ArrayLength; +} 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 (#72708): https://edk2.groups.io/g/devel/message/72708 Mute This Topic: https://groups.io/mt/81273608/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 16:46:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+72707+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+72707+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 1615530444465992.7168280249679; Thu, 11 Mar 2021 22:27:24 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 7SW0YY1788612xr6QmqaJkTt; Thu, 11 Mar 2021 22:27:24 -0800 X-Received: from userp2130.oracle.com (userp2130.oracle.com [156.151.31.86]) by mx.groups.io with SMTP id smtpd.web12.4953.1615530437937203933 for ; Thu, 11 Mar 2021 22:27:18 -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 12C6ACEv178525; Fri, 12 Mar 2021 06:27:15 GMT X-Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 37415rgyek-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Mar 2021 06:27:15 +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 12C6PApo055289; Fri, 12 Mar 2021 06:27:14 GMT X-Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam07lp2049.outbound.protection.outlook.com [104.47.56.49]) by userp3020.oracle.com with ESMTP id 374kgw3bqs-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Mar 2021 06:27:14 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MjtXmxi9FWne2I0JgflTvPbccquw7LTgdOSoMpXptTlpEgs63c+UWbyWXem8EJyryLWecMHm9lRkj5xnAfM+ramU2OgeIP9PeiFa8+FIMmEjZQ4lekxG5hH7i8a9bIAMdOVbUxP+c9hN19O8KFCXHnERvEmdVs8fsRI+3BLHgjfsqgGnABWtBxHQuwmJRsjPglRWSXfOS7QhmmxzG62gnNh3kUVT1tZQz2OrppDIFLFKmyVlWeNHh8pXM6o5MNBjX75GEimCI2tIq9wF+FBWvwl4GIjbgntb3uH1UFzLh0gcKsInYsbyrD4dwi1XzQLuBzKcI9UYW22kxHmEXc/PrA== 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=403GKhoEcxX7WidGJ/pPPepIXdVa3BzVG5cEbqee9Yw=; b=SOLtRiOWdfjGz1BOcDJvcQRBgIe1uoaaYmyfr2SAyAMFXLDNcVhimwM2BE5Zlyu4TnWLJN2LXQFaHLbxLxxxmERAgtOdYW3ChGvgDs9r8jigI7og9Y7kR2QYwUzk6FgOrtiMCMjzArKvtJxQxjgKSuOHidIWlgloYgkuwv56rMzMgwc3E5nUYnZfe1BeeSnKyMBi1S4unMjk6jx6Fv5MR2qIyEwr63QZTIF3A+Ssa9KGq4NDmWrtIwCoV08Ya7OUSgYtRqup/7W6AfaX4mq1rdod9s7W6ukOWgB4v3OBzkCZJf4sl3Fw8sNlTOqCtSJDb9CjiPhw6f54u/Xnjjhhrw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none X-Received: from SJ0PR10MB4605.namprd10.prod.outlook.com (2603:10b6:a03:2d9::24) by BYAPR10MB3191.namprd10.prod.outlook.com (2603:10b6:a03:14f::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.24; Fri, 12 Mar 2021 06:27:12 +0000 X-Received: from SJ0PR10MB4605.namprd10.prod.outlook.com ([fe80::a021:790:7ce6:6f16]) by SJ0PR10MB4605.namprd10.prod.outlook.com ([fe80::a021:790:7ce6:6f16%6]) with mapi id 15.20.3912.030; Fri, 12 Mar 2021 06:27:12 +0000 From: "Ankur Arora" To: devel@edk2.groups.io Cc: lersek@redhat.com, imammedo@redhat.com, boris.ostrovsky@oracle.com, Ankur Arora , Jordan Justen , Ard Biesheuvel , Aaron Young Subject: [edk2-devel] [PATCH v9 06/10] OvmfPkg/SmmCpuFeaturesLib: init CPU ejection state Date: Thu, 11 Mar 2021 22:26:52 -0800 Message-Id: <20210312062656.2477515-7-ankur.a.arora@oracle.com> In-Reply-To: <20210312062656.2477515-1-ankur.a.arora@oracle.com> References: <20210312062656.2477515-1-ankur.a.arora@oracle.com> X-Originating-IP: [148.87.23.12] X-ClientProxiedBy: MWHPR02CA0018.namprd02.prod.outlook.com (2603:10b6:300:4b::28) To SJ0PR10MB4605.namprd10.prod.outlook.com (2603:10b6:a03:2d9::24) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Received: from prion.us.oracle.com (148.87.23.12) by MWHPR02CA0018.namprd02.prod.outlook.com (2603:10b6:300:4b::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3912.17 via Frontend Transport; Fri, 12 Mar 2021 06:27:11 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b4a56906-7594-4d06-55d1-08d8e51fdf46 X-MS-TrafficTypeDiagnostic: BYAPR10MB3191: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: FhJ5OCA3cmI9DdolZ7VUCd92tTXB0DTRSkbdQs+6kXfGZJVMSzyN1ypfIsT+FZSalHw/5uLlvTcCkcUmnXmsm6CY0qok3r4wlrEEUo8LjAkn0L7LaYpmu+rac7BVdlp2WVQ99b0xHXWtOqqtY40XTJlUGJA6yd7B9cM/JJpuTzXv7j8Eb3wwEC0pN7C4uI45WbjiQ6FhFJBh4+4HZugZSVREahvYUbGupF3ruw7tlf548rHr3eqTDaucEvoCLUvFGy9R9lilPFJdYcRu93FtwSyBBI8PWg41RCEkYoeQ2iSHlVsmqmiPoCGeUcOyyM24vRYJ5Mkx8nx9rZS/QeDkCishww84d+iNX01fq1eanqMkr5ULbqweyIE2yIql5nne6gvPLHQZ56Fw/W9E17kF+IA6cp7hXOznms+pCOxMoWxNbqz7R2tqEBl0Z4t7zXB8+Yhphamps3bVyKzGcibeDJv8oO0O07PBFw72JjV78lBwXvWldOPSAShVMiL3HdfKjO2fNfIxuJGgMxWtVFQ7mClZeYd6oRCkw/+wX4bl5n+XlcVKzQq1D9AdrPqXFhtXAk9bYTabX0BDjEp8r5o+ao2H+v5GgxJcvrp25EFnOX8= X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?5tuFN4OCKGiRgbV1EPqu4DoQ5HMXwOtrQqCR4PLTlcG+bBOpasPbwtmSZAEC?= =?us-ascii?Q?F56srpnYxh7x/obLiTcEWkbthsZGzNpGXTFucXd3ulzHS5WQ1WoZAZ1d2GTV?= =?us-ascii?Q?KbpumQ8SnUrdI43GwvwwIC/wEv6Wa6NPforSryo0DdBTD3nrHKIa1IdJkx5B?= =?us-ascii?Q?jkdBDuHbjoYykyj8xkVfMtfR45ojGdkkJxhe7ChDDiwgPjQEBZajxVliXSDq?= =?us-ascii?Q?berWKD9cy1XU+L68k2tAoPIBTVRBjmKIe2X5V0+plOcZu4tnvhSe4XC69VhU?= =?us-ascii?Q?h7It9tJsWXUHBOSbtVYkjWSZ2NvPWhVCXdF+uXKfD5CWKrU3nPTeGvc+Q3dh?= =?us-ascii?Q?PTnJ4tW7OeVOK4VXe+R/4EGR0eJP4CuowP+GsnEmF1vO60kwFORDZFwgEGrz?= =?us-ascii?Q?6U+yrBaQj7+xJkT9DZWmSUkr8GY4HF5wgpFFRXyA7YV4VHHghaD85iCvZSWj?= =?us-ascii?Q?XA2HQs2Rfi6UgUo2lcziWC8SiM4h6VNkHqLvamkDemr1xEE5Xq+udn1QEPXU?= =?us-ascii?Q?8LmiR0DUM6hAwDr1gH55qOYg3bBsdJ3kdgnhm/jDX9Z/NnQaf1ZjUtg6IjjQ?= =?us-ascii?Q?k9DKA19i5XExP3nOrWTeR6UVM0vRxZFFlCkhSXdzQN0Dyd9vD+XH3t5y6hmK?= =?us-ascii?Q?h+jl+H8Wtepep2Fh+5x9GataKJ+QDX45JqmJhaJldO2Koc8E7niY8iMQrjPp?= =?us-ascii?Q?Qwc71J5uob/tLeejedMLarG9tpaLWmqsR8oDmQUladKTO4qjrRXXk+HwoGyd?= =?us-ascii?Q?wwFJmy7pLC5YRF3NPJJbae3jqlb6QzDbQAqBXyJLwKXJvk51E+tMlOQEUUv1?= =?us-ascii?Q?NnBz4N9ULO5Ar8RfNfdCWNEm6NS1+mvuxyBuhevbCBXBBaXC7BfslpVmQIye?= =?us-ascii?Q?Xkv07zob6L4Y9gkHyhTaB6TWx2aQaozBzYHouoytxgJyOugnD7SAEFKpmpYJ?= =?us-ascii?Q?UWkWmpviXZsTzF0k6kwBViiM82fbO//xD+P95z0kXtDKb6wtm2bpCQZE0HsN?= =?us-ascii?Q?Qhat5UNhzM/Ga03ukZyGI1RX2gSOk1y3oie9A33VhrWSjRL1OIcWHGu1c5cS?= =?us-ascii?Q?yyJfujDs1SyTJDKvtVem8rSYWUXbpC2FJYxexwVClq1k+36gT+1sjzA0BI9G?= =?us-ascii?Q?birXjYFmDdIo6qsgAxg/llyJnDMqDkfSFoiDqqO0vn6nQG+Db5yXTRJUq9zp?= =?us-ascii?Q?2sT39TsJ54e4IjJg8YGrzDabqNA5taEJKimiKiKxO9J55REVXtNaK7odVmAW?= =?us-ascii?Q?yEznxOhDC7VW7FC7wGTcFUWCaet3/NjJLuw77n+gyUDje7wF5KW7goFOBnPD?= =?us-ascii?Q?+m9MjGMtlXJameeka3SgF9y0?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b4a56906-7594-4d06-55d1-08d8e51fdf46 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR10MB4605.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Mar 2021 06:27:12.7751 (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: 11zJSz0bRH14k3MnS5zHtotRgcT0s+CVz/ighLZZpuVhMO7EqtJV+vlS1/s/K6Eo/lXEjC5kE3Pmr2JDlrw31FQUfwZIb4+Uu+FGlskm6eg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3191 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,ankur.a.arora@oracle.com X-Gm-Message-State: GsbMvyQMCyVfmUiPnZUcOXF3x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1615530444; bh=+VbRqnfbWTfJcrX7qjWZ/PBRoUl9Ng3wn9C2FSqwOuA=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=oVNBW2b+yX+uAL3Zo292UC42eOdO2v7HJFZEAdm+yxUxhgE7yCqIXFLbkE+XIhWyyOH 8Vg3rHWahkfZAXpM1fbckPQi3/S3b9XHt76iuuX9bfiS//NhR2Z0q/GgXrEdLdZDGmjkc gmtflyN/UtW3gEQBhrrlV42cuTKTxpdfNU4= 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. The init happens via SmmCpuFeaturesSmmRelocationComplete(), and so it will run as part of the PiSmmCpuDxeSmm entry point function, PiCpuSmmEntry(). Once inited, CPU_HOT_EJECT_DATA is exposed via PcdCpuHotEjectDataAddress. The CPU hot-eject handler (CPU_HOT_EJECT_DATA->Handler) is setup when there is an ejection request via CpuHotplugSmm. Cc: Laszlo Ersek Cc: Jordan Justen Cc: Ard Biesheuvel Cc: Igor Mammedov Cc: Boris Ostrovsky Cc: Aaron Young Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3132 Signed-off-by: Ankur Arora Reviewed-by: Laszlo Ersek --- Notes: Addresses the following comments from v8: =20 (1) Remove line before the "if (MaxNumberofCpus =3D=3D 1)" check. (3) Fixup the space around "||". (2,6) Simplify the three SafeInt multiplication into the ones suggested by Laszlo. (4) Get rid of the mixed sizeof(mCpuHotEjectData->QemuSelectorMap[0]) a= nd sizeof(UINT64) in favour of UINT64 everywhere. I was planning to use the first, but describing the alignment needed is easier in terms o= f the second. Also, as Laszlo's comments on v8-patch-9 mention, we don't really n= eed this alignment for correctness reasons. This patch retains it, so we don't pay access penalty for unaligned access. (5) Change alignment from UINT64 to UINT64-1. (7) Use the more idiomatic ALIGN_POINTER instead of ALIGN_VALUE. (8) RETURN_ERROR -> ASSERT_RETURN_ERROR. .../SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf | 4 ++ .../Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c | 77 ++++++++++++++++++= ++++ 2 files changed, 81 insertions(+) diff --git a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf b/Ovmf= Pkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf index 97a10afb6e27..8a426a4c10fb 100644 --- a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf +++ b/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf @@ -30,9 +30,13 @@ [LibraryClasses] BaseMemoryLib DebugLib MemEncryptSevLib + MemoryAllocationLib PcdLib + SafeIntLib SmmServicesTableLib UefiBootServicesTableLib =20 [Pcd] + gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber + gUefiOvmfPkgTokenSpaceGuid.PcdCpuHotEjectDataAddress gUefiOvmfPkgTokenSpaceGuid.PcdQ35SmramAtDefaultSmbase diff --git a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c b/OvmfPk= g/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c index 7ef7ed98342e..5c025bc717c3 100644 --- a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c +++ b/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c @@ -11,10 +11,13 @@ #include #include #include +#include #include +#include #include #include #include +#include #include #include #include @@ -171,6 +174,77 @@ SmmCpuFeaturesHookReturnFromSmm ( return OriginalInstructionPointer; } =20 +STATIC CPU_HOT_EJECT_DATA *mCpuHotEjectData =3D NULL; + +/** + Initialize mCpuHotEjectData if PcdCpuMaxLogicalProcessorNumber > 1. + + Also setup the corresponding PcdCpuHotEjectDataAddress. +**/ +STATIC +VOID +InitCpuHotEjectData ( + VOID + ) +{ + UINTN Size; + UINT32 Idx; + UINT32 MaxNumberOfCpus; + RETURN_STATUS PcdStatus; + + MaxNumberOfCpus =3D PcdGet32 (PcdCpuMaxLogicalProcessorNumber); + if (MaxNumberOfCpus =3D=3D 1) { + return; + } + + // + // We allocate CPU_HOT_EJECT_DATA and CPU_HOT_EJECT_DATA->QemuSelectorMa= p[] + // in a single allocation, and explicitly align the QemuSelectorMap[] (w= hich + // is a UINT64 array) at its natural boundary. + // Accordingly, allocate: + // sizeof(*mCpuHotEjectData) + (MaxNumberOfCpus * sizeof(UINT64)) + // and, add sizeof(UINT64) - 1 to use as padding if needed. + // + + if (RETURN_ERROR (SafeUintnMult (MaxNumberOfCpus, sizeof (UINT64), &Size= )) || + RETURN_ERROR (SafeUintnAdd (Size, sizeof (*mCpuHotEjectData), &Size)= ) || + RETURN_ERROR (SafeUintnAdd (Size, sizeof (UINT64) - 1, &Size))) { + DEBUG ((DEBUG_ERROR, "%a: invalid CPU_HOT_EJECT_DATA\n", __FUNCTION__)= ); + goto Fatal; + } + + mCpuHotEjectData =3D AllocatePool (Size); + if (mCpuHotEjectData =3D=3D NULL) { + ASSERT (mCpuHotEjectData !=3D NULL); + goto Fatal; + } + + mCpuHotEjectData->Handler =3D NULL; + mCpuHotEjectData->ArrayLength =3D MaxNumberOfCpus; + + mCpuHotEjectData->QemuSelectorMap =3D ALIGN_POINTER (mCpuHotEjectData + = 1, + sizeof (UINT64)); + // + // We use mCpuHotEjectData->QemuSelectorMap to map + // ProcessorNum -> QemuSelector. Initialize to invalid values. + // + for (Idx =3D 0; Idx < mCpuHotEjectData->ArrayLength; Idx++) { + mCpuHotEjectData->QemuSelectorMap[Idx] =3D CPU_EJECT_QEMU_SELECTOR_INV= ALID; + } + + // + // Expose address of CPU Hot eject Data structure + // + PcdStatus =3D PcdSet64S (PcdCpuHotEjectDataAddress, + (UINTN)(VOID *)mCpuHotEjectData); + ASSERT_RETURN_ERROR (PcdStatus); + + return; + +Fatal: + CpuDeadLoop (); +} + /** 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 +262,9 @@ SmmCpuFeaturesSmmRelocationComplete ( UINTN MapPagesBase; UINTN MapPagesCount; =20 + + InitCpuHotEjectData (); + if (!MemEncryptSevIsEnabled ()) { return; } --=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 (#72707): https://edk2.groups.io/g/devel/message/72707 Mute This Topic: https://groups.io/mt/81273607/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 16:46:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+72709+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+72709+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 1615530445706708.5760774680898; Thu, 11 Mar 2021 22:27:25 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 6bo3YY1788612xcZyNiAYHU0; Thu, 11 Mar 2021 22:27:25 -0800 X-Received: from userp2130.oracle.com (userp2130.oracle.com [156.151.31.86]) by mx.groups.io with SMTP id smtpd.web10.4849.1615530439754786011 for ; Thu, 11 Mar 2021 22:27:19 -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 12C6A64s178494; Fri, 12 Mar 2021 06:27:16 GMT X-Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 37415rgyen-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Mar 2021 06:27:16 +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 12C6P9bs055196; Fri, 12 Mar 2021 06:27:16 GMT X-Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2109.outbound.protection.outlook.com [104.47.55.109]) by userp3020.oracle.com with ESMTP id 374kgw3bs0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Mar 2021 06:27:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WI8IVw0eT5qaZjS9E7kLura7Bwhc6V0VoFBDh+ULxBgFbnlC6jLSHye+NmebwiYnXgOPb4rBx6Tw5JWEiyRooh4CgYjkFImsjndzUt1WETXal2WoMtyYQu8QNpI+POnEidUavhkRUosHUl5MopR0CL55pRaBKE2vPGmWJSza1PZrqa0B5ijEH1ORBdNX5sv1BZgRe6zQRWpz4dV+GkVNfcxNfLzKovbVEbvlZC3EiGkgZnxK7+f/tQIP7xmu6Lb1zGGXaec0zJ8HUoHlXU8tfGXGlVWFoYCTaWtNI7tiB1PhV9EwvpIckwGjGoXehcuI4Wv2xiigQGMr4bl5smpJYw== 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=3OWrUIIbd1oenoDL+1GkDyLmB2u83RTuk/kTz8vCYRs=; b=HOIq1wyi4T0Jccm2ToSjfRTe5Pr1eip6D8REAuzQXDeXpLbjveJJOA4mFbGCdmP9kkkLvf4fD+zDhydPG9TGk4L7pxw1Qf+spRz8JQYpLUgXH5E2jI3FhnL5/AfohVkgKL2qyt26yZT91O4mPsJrBMLuxRo7UutP6Nz6YictvcmFTE0sqE+a47xp+r6qqa70HnbVNhnIyc6Nffs0tOtdOJA66wqQOPVSA/5SI2R06jzIS7TiAUkpI+oiFzP8BpljNO8Iybau4cEreG78hV1s35EwKDOO3d8JlIv0UMTawi4/u6YIvrfF9rVLZQTg/HzYMHR2Pt2gON7OzAn+q4bjHw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none X-Received: from SJ0PR10MB4605.namprd10.prod.outlook.com (2603:10b6:a03:2d9::24) by SJ0PR10MB4544.namprd10.prod.outlook.com (2603:10b6:a03:2ad::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3933.31; Fri, 12 Mar 2021 06:27:14 +0000 X-Received: from SJ0PR10MB4605.namprd10.prod.outlook.com ([fe80::a021:790:7ce6:6f16]) by SJ0PR10MB4605.namprd10.prod.outlook.com ([fe80::a021:790:7ce6:6f16%6]) with mapi id 15.20.3912.030; Fri, 12 Mar 2021 06:27:14 +0000 From: "Ankur Arora" To: devel@edk2.groups.io Cc: lersek@redhat.com, imammedo@redhat.com, boris.ostrovsky@oracle.com, Ankur Arora , Jordan Justen , Ard Biesheuvel , Aaron Young Subject: [edk2-devel] [PATCH v9 07/10] OvmfPkg/SmmCpuFeaturesLib: call CPU hot-eject handler Date: Thu, 11 Mar 2021 22:26:53 -0800 Message-Id: <20210312062656.2477515-8-ankur.a.arora@oracle.com> In-Reply-To: <20210312062656.2477515-1-ankur.a.arora@oracle.com> References: <20210312062656.2477515-1-ankur.a.arora@oracle.com> X-Originating-IP: [148.87.23.12] X-ClientProxiedBy: MWHPR02CA0018.namprd02.prod.outlook.com (2603:10b6:300:4b::28) To SJ0PR10MB4605.namprd10.prod.outlook.com (2603:10b6:a03:2d9::24) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Received: from prion.us.oracle.com (148.87.23.12) by MWHPR02CA0018.namprd02.prod.outlook.com (2603:10b6:300:4b::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3912.17 via Frontend Transport; Fri, 12 Mar 2021 06:27:13 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 94b01732-fee4-47e4-59e3-08d8e51fe00d X-MS-TrafficTypeDiagnostic: SJ0PR10MB4544: 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: 2BYYmgBXf9VrHJlULpfvMgLJG9Kev9I/r+VSNLpEcedkAOOrwyLcChhb+uA967Hius/iRA4Ark4hcOsorc/T7coocc2+lpi2pOqkSUH5v/Y+W7wZwsFmnOqThvrUw3bSWX3GLUp3uGQzLEJ/0f8gxH/xkl/d6x4DQWzEa8TaxmsMjtmMpwAPPT6YEfdZm6b5pSbVexOjTnLuDmMl//vEOGF1ksItrffafSkStXlSzoL1AE5jn5jIjwTnC8xrbswTk8NFbv9XYc+dDqBO+JTQy/Tl8NNEJynlsamEJFGtFMFppvXBLVlwx5SAn3Ztae7DwasXVdVQip71+oV8tqNtKFEXJXNGPeOFh2LSJJsZKZFkMT587D0mdu4YWQpB+XFRJU4PD35vQt7DJ6x+rAYLn/9WF6SXVC/EvMNL+qjMHNjZyiSSXOhbwYEzNH8j5PXGnv4NKIAd3UE1QgQzug7ffv5myKn6z3PDvR2e6tjfoOeEGvP4dbq+H3sRB162vHf6mikeDJOqalNQjCgqzkp/HefOhX9KG0Gzp1iEp8TYchig08Bv99UGAi71qjDK0k5lzv4MqmsYHJTX/gmFf91BKOlGV4ABEUu7mKlIy/T48K0ksYZWerqI6o0tW9mEAdvF1ojf6SsmthlZoCA1LJdhnw== X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?BOTc14FsleBqE/qZmku48El6f/awz2NHEkP2hXzLpvYm1ZXBHVkXIzQC/mTb?= =?us-ascii?Q?FXOL8CY8mpjv84SrIgCk075lYpGHk4e8BboGJ6NKm2/OwqPXiStGr/6JgpYW?= =?us-ascii?Q?VzBjUSo3JjfCA70RbFnYOwJvpLdqQ8d0owZtkgtD2BBuP+1emof7mIuQ6IRh?= =?us-ascii?Q?UMN3QAp6MYAU1PjXiQLKV/Kbgcz86u4RMgFbY/jlN+w1oYxb0u763+SM+EZn?= =?us-ascii?Q?JfUoPsZ2pmn4qRMOHPONebGwVQJFgKTewHxj1IYql1WH9DO52gOcr2pulJR0?= =?us-ascii?Q?kAJbu/H2APFWXe6O2rCI/O4ixcXFLleU7jil4m6wEsl7O5JKMMSYb5joE8O3?= =?us-ascii?Q?GYeUm93xgdsL6dlnM+fr+rAMNxfQXV+Cxz0Je99RFeZB+wPyS3xLStB3jWNA?= =?us-ascii?Q?GO/Qnnea0x91s0CB5ydVKbBMr2WyhMy0Y7845POC+4Zx1by2BGk7PeBhhyHq?= =?us-ascii?Q?fU6XRUJFrGD40ardhtUiQmEdwvRBcLj2cHlEL/4RPpab+/NWEocLkTZZaOgy?= =?us-ascii?Q?0IRmZH5hKItyGWgO+ZT19AnOsS5smwbgsydPhMcQ5lbdkL4bd6NRWWZk2iqF?= =?us-ascii?Q?d/tL1tykJBsYpPPtTcZS/BvDPOVjHFU4BvcRpEoLG4/Lam6EyB3YpZNZ1O0H?= =?us-ascii?Q?biIREHjeCpbM/9XSfS96kEvqnbzEiRD+cF5BZGIJNmZIeLMJ+LrUHsPPbcar?= =?us-ascii?Q?pTqmqKg8UmlWvG5VLcKmtV1l2v4sU8IQ8EbhUr+o2DpdnqwJgGsKY+JzjvPB?= =?us-ascii?Q?i+wq0CBVHpASEvyZG3aj9VpgK525x+oXkXs+VQnNYwbxr6xW4aBNKLlb6gGB?= =?us-ascii?Q?DcderCKhLi6tfIZCg4qZwqhgxxDPMt3sCuXphbZV42svMAwBWO+LicXWbbK5?= =?us-ascii?Q?3csIp6dDBT0lAzsJd6DhpnVpa8VzDYWRtYEH6jaseglTsUCEOTaYkTql/EXo?= =?us-ascii?Q?7RGv/ApkmE/PDnu2gqrVzEpRDt8Etz2GnvxOXWHRW0BGT1VNmlAsKvZk+d/v?= =?us-ascii?Q?5EnVgjiyYRULtZZubKLbVcfpjk+yY169e9xnma0F2q/W8u/JKRCKrd/nmwyQ?= =?us-ascii?Q?dLWloWtZ5jaGaGKZds8yDfBHgMGyTuKSSFHxAPIUnmY1Tr1x63yTFlXaT2Ui?= =?us-ascii?Q?xX+ThBYpEXIClJWjI7AdC27Oyhw3LZdrIKuYrkNq30U8qJ889i2IDejg3HHB?= =?us-ascii?Q?joDcXJHL1oXLYeSo//W1ginRim8xMbv3wL6Rs26bGJCkxU3h3squ/Fc2m8LC?= =?us-ascii?Q?y0it6xDSehoUhPwF+SuOKrt6e9nxc5+AqBBMMYmiNYu0fVvrIRDVKiDhHRmH?= =?us-ascii?Q?W0M+qN3X8jSy/tS3onS/YRUB?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 94b01732-fee4-47e4-59e3-08d8e51fe00d X-MS-Exchange-CrossTenant-AuthSource: SJ0PR10MB4605.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Mar 2021 06:27:14.0216 (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: FWeP0RW8gGmFWcRlJwOLWRgD6f/RwTJxBizAZI30RMBI2Y08UEBViANgthmJoOgUIk6J+IRUTr4FbcZJBs9axVQ9xXMaGEhKc5b3DjgiZ6k= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4544 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: nONGu6cVtFEMVK3SgLgaGeYMx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1615530445; bh=mUECUoiEzvvDvmXCKsUF9JV15M43Mt6w8D9kxr+Y4rc=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=FhwywfHscZJ7YPBefiSxFwMnvqbGlHR9B1mUsKiXjwM5ozo9AZyoUEYKNjowLIaYS8o TAQdmX2lmhHY3EXOWMQLz/Ajbi/sdYXGTN1Iu+Edv9sOi65CV+Q3zIyg3GuquQC4898yz k6PcloIAAF8UbXBCYEBcWZDbQgAYlAPBx4o= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Call the CPU hot-eject handler if one is installed. The condition for installation is (PcdCpuMaxLogicalProcessorNumber > 1), and there's a hot-unplug request. The handler is called from SmmCpuFeaturesRendezvousExit(), which is in-turn called at the tail-end of SmiRendezvous() after the BSP has signalled an SMI exit via the "AllCpusInSync" loop. Cc: Laszlo Ersek Cc: Jordan Justen Cc: Ard Biesheuvel Cc: Igor Mammedov Cc: Boris Ostrovsky Cc: Aaron Young Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3132 Signed-off-by: Ankur Arora Reviewed-by: Laszlo Ersek --- Notes: Addresses the following comments from v8: =20 (1) Add a MemoryFence() before accessing mCpuHotEjctData->Handler (and comment to that effect.) .../Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c | 34 ++++++++++++++++++= ++++ 1 file changed, 34 insertions(+) diff --git a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c b/OvmfPk= g/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c index 5c025bc717c3..fdf2380974fa 100644 --- a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c +++ b/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c @@ -452,6 +452,40 @@ SmmCpuFeaturesRendezvousExit ( IN UINTN CpuIndex ) { + // + // We only call the Handler if CPU hot-eject is enabled + // (PcdCpuMaxLogicalProcessorNumber > 1), and hot-eject is needed + // in this SMI exit (otherwise mCpuHotEjectData->Handler is not armed.) + // + + if (mCpuHotEjectData !=3D NULL) { + CPU_HOT_EJECT_HANDLER Handler; + + // + // As the comment above mentions, mCpuHotEjectData->Handler might be + // written to on the BSP as part of handling of the CPU-ejection. + // + // We know that any initial assignment to mCpuHotEjectData->Handler + // (on the BSP, in the CpuHotplugMmi() context) is ordered-before the + // load below, since it is guaranteed to happen before the + // control-dependency of the BSP's SMI exit signal -- by way of a store + // to AllCpusInSync (on the BSP, in BspHandler()) and the corresponding + // AllCpusInSync loop (on the APs, in SmiRendezvous()) which depends on + // that store. + // + // This guarantees that these pieces of code can never execute + // simultaneously. In addition, we ensure that the following load is + // ordered-after the AllCpusInSync loop by using a MemoryFence() with + // acquire semantics. + // + MemoryFence(); + + Handler =3D mCpuHotEjectData->Handler; + + if (Handler !=3D NULL) { + 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 (#72709): https://edk2.groups.io/g/devel/message/72709 Mute This Topic: https://groups.io/mt/81273609/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 16:46:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+72711+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+72711+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 1615530446615338.80352554807814; Thu, 11 Mar 2021 22:27:26 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id FyF5YY1788612x0v3rRKEqlJ; Thu, 11 Mar 2021 22:27:26 -0800 X-Received: from aserp2120.oracle.com (aserp2120.oracle.com [141.146.126.78]) by mx.groups.io with SMTP id smtpd.web11.4908.1615530441279466488 for ; Thu, 11 Mar 2021 22:27:21 -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 12C68vva167464; Fri, 12 Mar 2021 06:27:18 GMT X-Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 3741pmryaa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Mar 2021 06:27:17 +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 12C6P9bu055196; Fri, 12 Mar 2021 06:27:17 GMT X-Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2109.outbound.protection.outlook.com [104.47.55.109]) by userp3020.oracle.com with ESMTP id 374kgw3bs0-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Mar 2021 06:27:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iB58DLIb+Ix0pwmRJ6czeMWRwNekk/iNhQYk/6yJwYf/86WcsrvHsyLwPv+G3cCIM0gEhAtVxXIA2JG3Oxuz4vD/n5lCv7Db2IqA+oTi45KCgoqa0Z+BEV+JTb8/GYq9TRev4AOL9eBQXHVOkyKA4U/OJRnFNix6/SWTzuN9vL/VGP31Y6OkZfmlFNzpyBgJlXuU8SJfnUyVES5KbKDIUbPw02MpB0c4Y3zqBxVbrZh7NvkV4laDtrR8Y/MhxfPlSFJvP/Vr/1TSBe7ATk/QpA5qodNp+7q6Ac2pAWJ/nRJfKI06DwIzNQp6/kT8I4FxrewpZ939hxUiG7imR9ScZg== 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=SVBy6Dr1CxfbqFJQ//fGo3VS5yVWlGZUKq15HXAWjk0=; b=PH/+9fpTgOuSnhyOKTZtxtclCvOyOAtozhvhpcNxedhLvQYAd47o5xuidy4TOP/Z2qgfLoxS9CNuiSSVmeLB2j7/UyxQbNVuHT7Hwp3FOxPmbwlzx9JACw+hL2XOe4/9+wKFDx6HkVw0KrxK6k4AVuJzOQ6JTrHo0CvY5L3AWZ3WLquGWaC8VAvxpQLa3BNAarsIKdm2bOFsgjGu++5eB9nUwLaGUlO6FvXbXKPG96kuh5g6NbNZCk331Bd3yHV21QppbS2FZba2kR4IQN4GVz2x8ZT/phshGhIVS/fPx6VHZJfjtQk+2vYtRWRh3OkjYPTxzHqc8gnQbTCAnsUUrw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none X-Received: from SJ0PR10MB4605.namprd10.prod.outlook.com (2603:10b6:a03:2d9::24) by SJ0PR10MB4544.namprd10.prod.outlook.com (2603:10b6:a03:2ad::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3933.31; Fri, 12 Mar 2021 06:27:15 +0000 X-Received: from SJ0PR10MB4605.namprd10.prod.outlook.com ([fe80::a021:790:7ce6:6f16]) by SJ0PR10MB4605.namprd10.prod.outlook.com ([fe80::a021:790:7ce6:6f16%6]) with mapi id 15.20.3912.030; Fri, 12 Mar 2021 06:27:15 +0000 From: "Ankur Arora" To: devel@edk2.groups.io Cc: lersek@redhat.com, imammedo@redhat.com, boris.ostrovsky@oracle.com, Ankur Arora , Jordan Justen , Ard Biesheuvel , Aaron Young Subject: [edk2-devel] [PATCH v9 08/10] OvmfPkg/CpuHotplugSmm: add EjectCpu() Date: Thu, 11 Mar 2021 22:26:54 -0800 Message-Id: <20210312062656.2477515-9-ankur.a.arora@oracle.com> In-Reply-To: <20210312062656.2477515-1-ankur.a.arora@oracle.com> References: <20210312062656.2477515-1-ankur.a.arora@oracle.com> X-Originating-IP: [148.87.23.12] X-ClientProxiedBy: MWHPR02CA0018.namprd02.prod.outlook.com (2603:10b6:300:4b::28) To SJ0PR10MB4605.namprd10.prod.outlook.com (2603:10b6:a03:2d9::24) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Received: from prion.us.oracle.com (148.87.23.12) by MWHPR02CA0018.namprd02.prod.outlook.com (2603:10b6:300:4b::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3912.17 via Frontend Transport; Fri, 12 Mar 2021 06:27:14 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 61f1457d-da2e-4664-94a5-08d8e51fe0c9 X-MS-TrafficTypeDiagnostic: SJ0PR10MB4544: 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: 6sZsfqf/GUBs3W5NllUgaMh63H5vL2uPN2gpGy35kwtVdsG9iGBO2MYixvVZL7GDNGAzi1yftlg7DcVDHrdvGWD4em2+d/puUuycZ90es81KSP3GOp0bDoGQ6+PxkA9xzkE2+rsS2FuLRc/NOiV44gxNqf2QKOPVFQgdAUMsmbl1IcRnH9UO8J6YrI5AdvHRGwsxPwUNRCIXWf5aZKg8nJt15o/RNkkx7HCjcxJLF9BOh5WIb9T6QXNhFDNO6SBHr4VH7oFW1GPvSbDBKmlZpbCaSE+dT0I3Nz4IIAUmm0xpK8M6m9pdKLtqs/FDj3zDwNeG3rEQBPYO8ac8/kYFCuVCsvOTck+C4F8oZR7c70ektZCT9wfk2pSj7uGjvRCcXjdr0pTeXe3VmbXMQTJOzJDI2aBKfChq24CKot6p7hygVVr6dYES4XBpzk4CqlcO7Xl8eu2v4Z+M0d0YN5K1J/rwjL7N0l0JgzF60oqg5rOp2Lrn0eG1YuQiYZrqJrrR/LRu34Aq5/BEUplvXYvwD5eswOQ3M28i1uYGOoP1u/mUWkmWC9mlbc199yxCIgWHjwgpAU6vgWhsC//IwtNfZXu85d1AGOJgQ2gm/FebfMlO8+N0VfcQhkBOz+37EvTtdGkFWPmVCdEK/QA2IwKQ6Q== X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?ZlBGd//bAKhVIobsiIl/ADmiHnyBEsBZ2ilerrPytTUyg9mmF79lXfPsoQxS?= =?us-ascii?Q?kXj69DgKf0HKw7OxgOTX4L4sBIozavu1DjY91oEzgcrPlhOvTjzSdA32p/MW?= =?us-ascii?Q?UXhmMi2Sb2vG0m1qS6P5eEPabP8l6eAyWzrbvr9ZDVYvnr5nu5Y5EWl4qzyO?= =?us-ascii?Q?ezxUnjEOhmz3v/CPyzaPe3SK8wbEAb59vyASSVKVsPViqV+sPNTQDMTeU9MW?= =?us-ascii?Q?cnFotjf818oA8b12pN9pC1hIY9PSwzzE0yeMar2xllFs90xFMk+HU7Oq/vz1?= =?us-ascii?Q?6Bg56tfR4+IrWPXeVZkyqK0h3FhZBwyz5fJ5R16q0OtJkNI/Z7AQ1Xqljiol?= =?us-ascii?Q?6pS/MmDBn9ow0dEtX45bRVuPoXnIu4D+9XbqJVoYSnP51OFMxo1B1JyMeCDw?= =?us-ascii?Q?LX3eZNShWSKbE9KFHfDDcCWlz8oSF+6zmSljzVKi5B5Q3LLaOE+g2/XJzhYD?= =?us-ascii?Q?dZttDmLFPS/KpgyG2FYv33vpn0jYb3c71+mvS+Zh81wdK5vgV1b3Uz6VCMLw?= =?us-ascii?Q?4KHQDhifbvKsm1Yulj2zQ57ZIH4LECE7u5bQoxKKXJgDzlOl5FM/NDnQMzbX?= =?us-ascii?Q?v+DyZ5BBBf/lBu1CsqyFKQ9FvKgdKV8nsK2RcXVmvdtqwqg3wp2Pxnjfi+re?= =?us-ascii?Q?Ld6c1a6/SDaPXQzx7BiZ8xn+IN9EqaM10wTzoTVY1gtK2WeGtggWs1RjmDHj?= =?us-ascii?Q?ccw8nF6YIz+/eJiyL4kBLqufbMK/SkJ95WmmxDFsdqd0J+lpCnpEowvl9Jvg?= =?us-ascii?Q?G68DxIij6vfejJxRzNhBGPsJLQC9tE3lqFt5wt0A5I/8JnuOpP3dkuqXNpZf?= =?us-ascii?Q?5ncp1kMhZezfg5QWPHtK0+BoBDw91ph/V6BwZZu1jTa7vS1hBlam0MiSgM3D?= =?us-ascii?Q?+yRhEKG6j9UB4NoftxlHUwu/rikg8GMZK123pSkTFHENcyHY35rTXMeVgiNV?= =?us-ascii?Q?ke2E/d8DdEd+nDfen1mIP8dYJWISL7J0AGzH7Tuu+XwEPN+t0xLY/Xh8rS/B?= =?us-ascii?Q?b5/wfcd/cjsSHEue9MYUxUwnJlTY6kWTOkOMvYKQDga7QxSylCQ3aFnqd5uu?= =?us-ascii?Q?3fPnf3rfx2L6mhBNfjNf5go2o5czCUUXeq9YuQMLjfBwvfFlCxN31dPOM1P3?= =?us-ascii?Q?w+FEKc76ioNLjsYi4on9JpPDMUt7lKQemFWv12NxDFWWKqGV/5fXzyuk+Teq?= =?us-ascii?Q?dWUToyzD3SP+SxcL0tc9Z4lXW/oyiVrYFzqwCRd6MwS3h5IxrXZ6/M9u/ga1?= =?us-ascii?Q?MWEL00U8hdRjn6Ri6yyuIhEB1YMlLTlyunBqDYZ50merA38JaK16PcjvjcS4?= =?us-ascii?Q?Tatadnta34+5gtW4sKHlc/3K?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 61f1457d-da2e-4664-94a5-08d8e51fe0c9 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR10MB4605.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Mar 2021 06:27:15.2661 (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: 8iq/lJaeIEVssGcLz0hV9lfW7s7NNrtWLE/Pt7k5/sRxBbNvGzeaPpa1FCoXxBz1HadQtvlf4OdXWSQUu/J8wrIptjLkODymZw6zBZ1WgRY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4544 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: rRabuutQdNXbP2K62HLOtVyRx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1615530446; bh=CDDRmfpAiMKnveEsH2kWsS0FOPXmx/sEQ49ii1VZCBk=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=FwQerlCG69Amg9GqTC+T0oMAZI5iUItpoR1L28uYhmXiSXaVPoKlRqijPGDvCGunFs0 zHAxRevLixQu+FISsCTXx9XsQp2T77au6vJzTsNUAs5+8B3xDCOl2VFSdwPGpDOz6getF 35ZLIkhHE1KGdu9EHuaet0KEGp2Dm+AHQDQ= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Add EjectCpu(), 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 QEMU Selectors of CPUs which need to be ejected in CPU_HOT_EJECT_DATA.QemuSelectorMap. This is used by EjectCpu() to identify CPUs marked for ejection. Cc: Laszlo Ersek Cc: Jordan Justen Cc: Ard Biesheuvel Cc: Igor Mammedov Cc: Boris Ostrovsky Cc: Aaron Young Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3132 Signed-off-by: Ankur Arora Reviewed-by: Laszlo Ersek --- Notes: Addresses the following comments from v8: =20 (1) Fixup the coment about UnplugCpus() to reference stashing QEMU Cpu Selectors instead of APIC IDs. (2) s/ToUnplugSelector/ToUnplugSelectors/ (3) Use plural for APIC ID in comment describing retval EFI_ALREADY_STA= RTED. (4) Fixup indentation in check against CPU_EJECT_QEMU_SELECTOR_INVALID. (5) Clarify comment: - // never match more than one APIC ID and by transitivity, more than= one - // QemuSelector in a single invocation of UnplugCpus(). + // never match more than one APIC ID -- nor, by transitivity, desig= nate + // more than one QemuSelector -- in a single invocation of UnplugCp= us(). (6a) Remove unnecessary UINT64 cast for mCpuHotEjectData->QemuSelectorM= ap[ProcessorNum]. (6b) Switch from 0x%Lx -> %Lu for QemuSelectorMap[ProcessorNum]. (6c) Switch from 0x%Lx -> %u for QemuSelector (7) Switch to "return EFI_ALREADY_STARTED". (8a) Replace "QemuSelector 0x%Lx" with "QemuSelector %u". (8b) Replace the mCpuHotEjectData->QemuSelectorMap[ProcessorNum] argume= nt with just QemuSelector in DEBUG call. (9) Clarify comment and make the language complementary to that in patc= h-7 Explicitly mention release memory fence. OvmfPkg/CpuHotplugSmm/CpuHotplugSmm.inf | 2 + OvmfPkg/CpuHotplugSmm/CpuHotplug.c | 154 ++++++++++++++++++++++++++++= ++-- 2 files changed, 148 insertions(+), 8 deletions(-) diff --git a/OvmfPkg/CpuHotplugSmm/CpuHotplugSmm.inf b/OvmfPkg/CpuHotplugSm= m/CpuHotplugSmm.inf index 04322b0d7855..ebcc7e2ac63a 100644 --- a/OvmfPkg/CpuHotplugSmm/CpuHotplugSmm.inf +++ b/OvmfPkg/CpuHotplugSmm/CpuHotplugSmm.inf @@ -40,6 +40,7 @@ [Packages] [LibraryClasses] BaseLib BaseMemoryLib + CpuLib DebugLib LocalApicLib MmServicesTableLib @@ -54,6 +55,7 @@ [Protocols] =20 [Pcd] gUefiCpuPkgTokenSpaceGuid.PcdCpuHotPlugDataAddress ## CON= SUMES + gUefiOvmfPkgTokenSpaceGuid.PcdCpuHotEjectDataAddress ## CON= SUMES gUefiOvmfPkgTokenSpaceGuid.PcdQ35SmramAtDefaultSmbase ## CON= SUMES =20 [FeaturePcd] diff --git a/OvmfPkg/CpuHotplugSmm/CpuHotplug.c b/OvmfPkg/CpuHotplugSmm/Cpu= Hotplug.c index 59f000eb7886..2eeb4567a262 100644 --- a/OvmfPkg/CpuHotplugSmm/CpuHotplug.c +++ b/OvmfPkg/CpuHotplugSmm/CpuHotplug.c @@ -10,10 +10,12 @@ #include // ICH9_APM_CNT #include // QEMU_CPUHP_CMD_GET_PENDING #include // CpuDeadLoop() +#include // CpuSleep() #include // ASSERT() #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 +34,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. @@ -190,18 +193,71 @@ RevokeNewSlot: } =20 /** + CPU Hot-eject handler, called from SmmCpuFeaturesRendezvousExit() + on each CPU at exit from SMM. + + If, the executing CPU is not being ejected, nothing to be done. + If, the executing CPU is being ejected, wait in a halted loop + until ejected. + + @param[in] ProcessorNum ProcessorNum denotes the CPU exiting SMM, + and will be used as an index into + CPU_HOT_EJECT_DATA->QemuSelectorMap. It is + identical to the processor handle number in + EFI_SMM_CPU_SERVICE_PROTOCOL. +**/ +VOID +EFIAPI +EjectCpu ( + IN UINTN ProcessorNum + ) +{ + UINT64 QemuSelector; + + QemuSelector =3D mCpuHotEjectData->QemuSelectorMap[ProcessorNum]; + if (QemuSelector =3D=3D CPU_EJECT_QEMU_SELECTOR_INVALID) { + return; + } + + // + // APs being unplugged get here from SmmCpuFeaturesRendezvousExit() + // after having been cleared to exit the SMI and so have no SMM + // processing remaining. + // + // Keep them penned here until the BSP tells QEMU to eject them. + // + for (;;) { + DisableInterrupts (); + CpuSleep (); + } +} + +/** Process to be hot-unplugged CPUs, per QemuCpuhpCollectApicIds(). =20 For each such CPU, report the CPU to PiSmmCpuDxeSmm via - EFI_SMM_CPU_SERVICE_PROTOCOL. If the to be hot-unplugged CPU is - unknown, skip it silently. + EFI_SMM_CPU_SERVICE_PROTOCOL and stash the QEMU Cpu Selectors for later + ejection. If the to be hot-unplugged CPU is unknown, skip it silently. + + Additonally, if we do stash any Cpu Selectors, also install a CPU eject + handler which would handle the ejection. =20 @param[in] ToUnplugApicIds The APIC IDs of the CPUs that are about to= be hot-unplugged. =20 + @param[in] ToUnplugSelectors The QEMU Selectors of the CPUs that are ab= out to + be hot-unplugged. + @param[in] ToUnplugCount The number of filled-in APIC IDs in ToUnplugApicIds. =20 + @retval EFI_ALREADY_STARTED For the ProcessorNum that + EFI_SMM_CPU_SERVICE_PROTOCOL had assigned = to + one of the APIC IDs in ToUnplugApicIds, + mCpuHotEjectData->QemuSelectorMap already = has + the QemuSelector value stashed. (This shou= ld + never happen.) + @retval EFI_SUCCESS Known APIC IDs have been removed from SMM = data structures. =20 @@ -212,23 +268,36 @@ STATIC EFI_STATUS UnplugCpus ( IN APIC_ID *ToUnplugApicIds, + IN UINT32 *ToUnplugSelectors, IN UINT32 ToUnplugCount ) { EFI_STATUS Status; UINT32 ToUnplugIdx; + UINT32 EjectCount; UINTN ProcessorNum; =20 ToUnplugIdx =3D 0; + EjectCount =3D 0; while (ToUnplugIdx < ToUnplugCount) { APIC_ID RemoveApicId; + UINT32 QemuSelector; =20 RemoveApicId =3D ToUnplugApicIds[ToUnplugIdx]; + QemuSelector =3D ToUnplugSelectors[ToUnplugIdx]; =20 // - // mCpuHotPlugData->ApicId maps ProcessorNum -> ApicId. Use it to find - // the ProcessorNum for the APIC ID to be removed. + // mCpuHotPlugData->ApicId maps ProcessorNum -> ApicId. Use RemoveApic= Id + // to find the corresponding ProcessorNum for the CPU to be removed. // + // With this we can establish a 3 way mapping: + // APIC_ID -- ProcessorNum -- QemuSelector + // + // We stash the ProcessorNum -> QemuSelector mapping so it can later be + // used for CPU hot-eject in SmmCpuFeaturesRendezvousExit() context (w= here + // we only have ProcessorNum available.) + // + for (ProcessorNum =3D 0; ProcessorNum < mCpuHotPlugData->ArrayLength; ProcessorNum++) { @@ -257,11 +326,62 @@ UnplugCpus ( return Status; } =20 + if (mCpuHotEjectData->QemuSelectorMap[ProcessorNum] !=3D + CPU_EJECT_QEMU_SELECTOR_INVALID) { + // + // mCpuHotEjectData->QemuSelectorMap[ProcessorNum] is set to + // CPU_EJECT_QEMU_SELECTOR_INVALID when mCpuHotEjectData->QemuSelect= orMap + // is allocated, and once the subject processsor is ejected. + // + // Additionally, mMmCpuService->RemoveProcessor(ProcessorNum) invali= dates + // mCpuHotPlugData->ApicId[ProcessorNum], so a given ProcessorNum can + // never match more than one APIC ID -- nor, by transitivity, design= ate + // more than one QemuSelector -- in a single invocation of UnplugCpu= s(). + // + DEBUG ((DEBUG_ERROR, "%a: ProcessorNum %Lu maps to QemuSelector %Lu,= " + "cannot also map to %u\n", __FUNCTION__, (UINT64)ProcessorNum, + mCpuHotEjectData->QemuSelectorMap[ProcessorNum], QemuSelector)); + + return EFI_ALREADY_STARTED; + } + + // + // Stash the QemuSelector so we can do the actual ejection later. + // + mCpuHotEjectData->QemuSelectorMap[ProcessorNum] =3D (UINT64)QemuSelect= or; + + DEBUG ((DEBUG_INFO, "%a: Started hot-unplug on ProcessorNum %Lu, APIC = ID " + FMT_APIC_ID ", QemuSelector %u\n", __FUNCTION__, (UINT64)ProcessorNu= m, + RemoveApicId, QemuSelector)); + + EjectCount++; ToUnplugIdx++; } =20 + if (EjectCount !=3D 0) { + // + // We have processors to be ejected; install the handler. + // + mCpuHotEjectData->Handler =3D EjectCpu; + + // + // The BSP and APs load mCpuHotEjectData->Handler, and + // mCpuHotEjectData->QemuSelectorMap[] in SmmCpuFeaturesRendezvousExit= () + // and EjectCpu(). + // + // The comment in SmmCpuFeaturesRendezvousExit() details how we use + // the AllCpusInSync control-dependency to ensure that any loads are + // ordered-after the stores above. + // + // Ensure that the stores above are ordered-before the AllCpusInSync s= tore + // by using a MemoryFence() with release semantics. + // + MemoryFence (); + } + // - // We've removed this set of APIC IDs from SMM data structures. + // We've removed this set of APIC IDs from SMM data structures and + // have installed an ejection handler if needed. // return EFI_SUCCESS; } @@ -389,7 +509,7 @@ CpuHotplugMmi ( } =20 if (ToUnplugCount > 0) { - Status =3D UnplugCpus (mToUnplugApicIds, ToUnplugCount); + Status =3D UnplugCpus (mToUnplugApicIds, mToUnplugSelectors, ToUnplugC= ount); if (EFI_ERROR (Status)) { goto Fatal; } @@ -460,9 +580,14 @@ CpuHotplugEntry ( =20 // // Our DEPEX on EFI_SMM_CPU_SERVICE_PROTOCOL guarantees that PiSmmCpuDxe= Smm - // has pointed PcdCpuHotPlugDataAddress to CPU_HOT_PLUG_DATA in SMRAM. + // has pointed: + // - PcdCpuHotPlugDataAddress to CPU_HOT_PLUG_DATA in SMRAM, + // - PcdCpuHotEjectDataAddress to CPU_HOT_EJECT_DATA in SMRAM, if the + // possible CPU count is greater than 1. // 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)); @@ -474,6 +599,19 @@ CpuHotplugEntry ( if (mCpuHotPlugData->ArrayLength =3D=3D 1) { return EFI_UNSUPPORTED; } + + if (mCpuHotEjectData =3D=3D NULL) { + Status =3D EFI_NOT_FOUND; + } else if (mCpuHotPlugData->ArrayLength !=3D mCpuHotEjectData->ArrayLeng= th) { + Status =3D EFI_INVALID_PARAMETER; + } else { + Status =3D EFI_SUCCESS; + } + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: CPU_HOT_EJECT_DATA: %r\n", __FUNCTION__, Sta= tus)); + goto Fatal; + } + // // Allocate the data structures that depend on the possible CPU count. // --=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 (#72711): https://edk2.groups.io/g/devel/message/72711 Mute This Topic: https://groups.io/mt/81273611/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 16:46:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+72710+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+72710+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 1615530448754886.5490639787704; Thu, 11 Mar 2021 22:27:28 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id DbmPYY1788612xcEzkrQ013V; Thu, 11 Mar 2021 22:27:26 -0800 X-Received: from userp2130.oracle.com (userp2130.oracle.com [156.151.31.86]) by mx.groups.io with SMTP id smtpd.web08.4834.1615530440956790408 for ; Thu, 11 Mar 2021 22:27:21 -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 12C6AxGW179410; Fri, 12 Mar 2021 06:27:18 GMT X-Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 37415rgyer-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Mar 2021 06:27:18 +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 12C6P9bv055196; Fri, 12 Mar 2021 06:27:17 GMT X-Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2109.outbound.protection.outlook.com [104.47.55.109]) by userp3020.oracle.com with ESMTP id 374kgw3bs0-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Mar 2021 06:27:17 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FP+sNkfLaEWGlUEhxfy+6nfkAgDh7+E047oYjoYDetGZ/5kC/GNSy6PD+KM8xpkcAigiOU2PO2q3/KGNMLy0ZW6YWnIzZgkq9eReIGxo0LxxAnSsCH9vmCvNErvAiIxULGWoL+AJvtYNiR7c/wT942hGFU3TxDKJToZuYu6wdNSg0VesoxQY0HvCrYgzGDlGqF+ART3OaUk9/Fs1wvW1AIe13Gb++JZmSIIh+BqP5zuQw6Z4PyI8Jcy6tKN/5AcLw191j7JTCOyNGOBZrc08t/uVCZr8+z1W6UY4vjTvF2fekR9RaVTM8l1VRgWNiNxBXfAKof48UIMRRLF0axB7MA== 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=41U0p8zpgTKCTq//Ujgd7ZD8QZAhgkb1JaTATjLn7MA=; b=GVULVwyuHeWfKRKNrdP7wV3LM8v5y5BOKr1T44R+pGFJJjZ6IUQO+hfmCNmTcP0K1kE6afISWStO5PD/1Pa+BLyWMIYhpp3Q9hvBLAaUmNB0iSNCjEx2UJMtdr+uWqvbePkqaKzY3A8QXrAdemNt/K1tWXLWEsWyTeGridREX0BDHoMf3JcGp/UzXq+SQ11oZQh4vzw5ayJ5dtuxRfZ/2lz2dmH7Almgf4bgenZCUFqyOtjueNJMteUl3Wz490D8KykQ8CmjBx4N1/xxLq+wGHDSjRPqsa4aCENm9kbh/HWkSTMf97JBfrXmjP6L25A9ayeoFhp9NIHxloOnk0HHDA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none X-Received: from SJ0PR10MB4605.namprd10.prod.outlook.com (2603:10b6:a03:2d9::24) by SJ0PR10MB4544.namprd10.prod.outlook.com (2603:10b6:a03:2ad::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3933.31; Fri, 12 Mar 2021 06:27:16 +0000 X-Received: from SJ0PR10MB4605.namprd10.prod.outlook.com ([fe80::a021:790:7ce6:6f16]) by SJ0PR10MB4605.namprd10.prod.outlook.com ([fe80::a021:790:7ce6:6f16%6]) with mapi id 15.20.3912.030; Fri, 12 Mar 2021 06:27:16 +0000 From: "Ankur Arora" To: devel@edk2.groups.io Cc: lersek@redhat.com, imammedo@redhat.com, boris.ostrovsky@oracle.com, Ankur Arora , Jordan Justen , Ard Biesheuvel , Aaron Young Subject: [edk2-devel] [PATCH v9 09/10] OvmfPkg/CpuHotplugSmm: do actual CPU hot-eject Date: Thu, 11 Mar 2021 22:26:55 -0800 Message-Id: <20210312062656.2477515-10-ankur.a.arora@oracle.com> In-Reply-To: <20210312062656.2477515-1-ankur.a.arora@oracle.com> References: <20210312062656.2477515-1-ankur.a.arora@oracle.com> X-Originating-IP: [148.87.23.12] X-ClientProxiedBy: MWHPR02CA0018.namprd02.prod.outlook.com (2603:10b6:300:4b::28) To SJ0PR10MB4605.namprd10.prod.outlook.com (2603:10b6:a03:2d9::24) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Received: from prion.us.oracle.com (148.87.23.12) by MWHPR02CA0018.namprd02.prod.outlook.com (2603:10b6:300:4b::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3912.17 via Frontend Transport; Fri, 12 Mar 2021 06:27:15 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 884db05b-4ee1-42ba-984b-08d8e51fe184 X-MS-TrafficTypeDiagnostic: SJ0PR10MB4544: 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: 1+9BZIlsAbToHGJoVlaSxlqCE8Je07I24gdHEqNFdte/VHU1la+nRkINvpEVOzJMhwRZjoJyis560Bdnf72UxJru0WDCKFVjhjYrcqhV2Oylj5CpKvzSmZdPyTLlUv/219SyPYtApaKuJoLmicxWSz3+lXS2gtJfOn6gJJESPNjaN0fWCWyW4ApAEyLzy8UQUZK3ZI0cF1k23cHNOMTUXY1v8GXK2wVi0+jssbX5oL8qvKJh+SDNp3iTusVR5uxn8kBam4mx20Y96MLDMxCV66abkvefMYf/70xeCBZFUMere04VdYiRFgi3Mgvq3hLNtjej3eKIr26BQKBj4qqPbc3LI7Q3C8SVzaYitPCDMgDGqr1UjqJ0cZIBNpjkJGTJjDMpfNKTs3OD+DARw1LEwlb71YGtVxkR8IvbXum7wn0KL6R+AhGuuiCI/2eJgIzQUrXo1HkHmdN3S7HqLrxdNXQPo3Jb+CoOIk23n9zVspcY7sdQ1axWaJqivf6MtdqjoTMXbqmHmbd5ik/rWJQQOO9jOrLu23kafVLtU0Nsa3txsFgFOoJhAOPw4+tE+1doj845Teedx7+ZOjNUTLCIE7/S6z3V2bdqYQtlaoMDZ481ddgI3CwEftWDSEJ7OmeL8kPoI21pjunuKrfvnUz0qg== X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?qtV0letuzxAyqLGGwN1/vOCSoy5eAu/VnvmVSKAY9yXp+BEJ/dAo1sR8ggf5?= =?us-ascii?Q?vdhEHhnzEi6wlZEVzRUl54+LdPXptbNTqIMKOVN/EJUdKwNo3t3CWrFncyN2?= =?us-ascii?Q?VeFiE81PuV69rxOWYd639uOESr6eM6XxEqgKRD+3P2ksbEX346+BVYiozGs9?= =?us-ascii?Q?chAibKmcvx+iiEqYbJU4Z/umJWoTNAZtqejl4+qubaR9bqvT0IN+6uBJhhuZ?= =?us-ascii?Q?wnSPfrcwA1CT4giDP/PIP7ug9OokznAVAMmVpdtg2xUB0XfjS/O+OQCTRZ1Z?= =?us-ascii?Q?aVpPh627uf85I9/50nWIDLwOguy++G+lIcdjrct1REDRBP62MwF+U6i42+b+?= =?us-ascii?Q?ErPzTIYYhCHFiNuBuSpwzn70XMzswxzSyUf0U0rKNVDHN5JnByEDO+mTmZ+W?= =?us-ascii?Q?tqSIUkctiL+QFPz1sdTiEzm6vIhd/1/3d1943DRElFmjKA62cy1Sz2571Nhp?= =?us-ascii?Q?vIBIhatlTIzVkp5YJrDNjh58SI1La+hrS0n6S57DIV36/yikVoGG9yflWkia?= =?us-ascii?Q?jw3UMpkBIth1OtFt4VTJ7+kjE8DZbZTbf3brWLDVvMaxogS4/hk+Hw/xS8Z6?= =?us-ascii?Q?umqv5Cy31WggMPmWbZgVQK0IWzC3zUvttYMzQc3Vo7SJ+VqbxoxK7b1HXXQy?= =?us-ascii?Q?Mt0usaM47TnN7xD0CHVsOCuqyHoQYlhbt8eVn+v5wRScw4sOjgbzsXnqqxh4?= =?us-ascii?Q?UQIxfWhfLN+64ioUkYdmbs8Vs8LOqFGc+io6T57ySKTn5o7CyuCHxO5uyDqE?= =?us-ascii?Q?SBmV0z66zGibzSd7tfrxhuvCSZsD2p/QpuT2bHb+OhV1709pU/wXFQ5pnaYb?= =?us-ascii?Q?SMcTLqzWtL+a5hbsCpPKEc3kutssdw/zbGg8f9jx3tugOMUDm4W1XSS7IQqQ?= =?us-ascii?Q?Hd032WDwBYXfm7/z3zuNXbY/3lAMovXD+ZPZ3/Nb0Jyw6zpaV5NsjJfhnAHT?= =?us-ascii?Q?aBf4hESsyskj5fxHrTrF4V2A+TVhpyLX+vri1OLO+wBp/+u/EjxqRHVQTOqN?= =?us-ascii?Q?75az16j/ssWzFF9TJ4GiwxZCFBFFd9gGcoKmVdMyLorJUaDxLN8ro32Fnuu+?= =?us-ascii?Q?AKK9n6Putr3wtFXFrQoU5INB3YZlQFWv5xcbFb9S2q3+P+QpjycKXWzksq8E?= =?us-ascii?Q?aF13CSiGRYW57OdrqnCrs610vuUr+Dc/2rbjzljKNSHMp8CJtqWM2KIQL71G?= =?us-ascii?Q?i/8dSgjTf/dO9976+i5Kyf/pM1VbphIHvJm8Nd+tEKSYl4QBX3ABZwkiAdtW?= =?us-ascii?Q?JAD1V/vmH2yuS0mig6JMxa9xNSP6eljlad8zCJVYNKlEomex66gRP/lAXdXh?= =?us-ascii?Q?5hEfGvmxgl/Gcy7mtDUcdCUs?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 884db05b-4ee1-42ba-984b-08d8e51fe184 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR10MB4605.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Mar 2021 06:27:16.5057 (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: qch7qVbepeTmD65/V7gOEO9R6fOZOxmLG0EW02tEB4HqxY7D2Vz0mQopPiTTpVmkA5rmDrXl+qgfXFGCE9GFHPoLSKdVsY3dKC8UzkJnW5w= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4544 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: xBnK8qGA78BAawNbl12w5XEtx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1615530446; bh=819qcinTe5pwQVZv8KmYvaOYd90cUPyu2gtwf3Ixc+M=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=ZChBibhQvlP0Tbi5aMYm4E3dUkRswDRwlCzaLXw8AxF6okZ/7Wq4oUrS0p0RssPyaxx dLqpd6BPOW8JpsZAxpTGfh/p0Q0Do+alIM4XFK6tsX9Pj41GdBjzTPmL0lEJI7HmhcZz4 iXUU0htPZGq9jnhlC03pMsvEMirPqTYnsJs= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Add logic in EjectCpu() to do the actual the CPU ejection. On the BSP, ejection happens by first selecting the CPU via its QemuSelector and then sending the QEMU "eject" command. QEMU in-turn signals the remote VCPU thread which context-switches the CPU out of the SMI handler. Meanwhile the CPU being ejected, waits around in its holding area until it is context-switched out. Note that it is possible that a slow CPU gets ejected before it reaches the wait loop. However, this would never happen before it has executed the "AllCpusInSync" loop in SmiRendezvous(). It can mean that an ejected CPU does not execute code after that point but given that the CPU state will be destroyed by QEMU, the missed cleanup is no great loss. Cc: Laszlo Ersek Cc: Jordan Justen Cc: Ard Biesheuvel Cc: Igor Mammedov Cc: Boris Ostrovsky Cc: Aaron Young Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3132 Signed-off-by: Ankur Arora Reviewed-by: Laszlo Ersek --- Notes: Addresses the following comments from v8: =20 (1a,1b) CheckIfBsp(): get rid of ProcessorNum, document retval. (2) Line up IsBsp and ApicBaseMsr (3) s/ongoing SMI iteration/ongoing SMI/ (4) Get rid of the allusions to alignment in the comment in EjectCpu(). () Also reduce some of the repetitive detail in this comment. (5) EjectCpu(): reorder logic to cleanly separate the AP and the BSP po= rtions. (6) Get rid of unnecessary MemoryFence() between QemuCpuhpWrite and clearing of the eject status. (7) Change type of QemuSelector to %Lu in DEBUG statement (8) Get rid of the repetitive comment in SmmCpuFeaturesRendezvousExit(). The necessary parts of this got moved to patch-7. OvmfPkg/Include/IndustryStandard/QemuCpuHotplug.h | 1 + OvmfPkg/CpuHotplugSmm/CpuHotplug.c | 113 ++++++++++++++++++= ++-- 2 files changed, 108 insertions(+), 6 deletions(-) diff --git a/OvmfPkg/Include/IndustryStandard/QemuCpuHotplug.h b/OvmfPkg/In= clude/IndustryStandard/QemuCpuHotplug.h index 2ec7a107a64d..d0e83102c13f 100644 --- a/OvmfPkg/Include/IndustryStandard/QemuCpuHotplug.h +++ b/OvmfPkg/Include/IndustryStandard/QemuCpuHotplug.h @@ -34,6 +34,7 @@ #define QEMU_CPUHP_STAT_ENABLED BIT0 #define QEMU_CPUHP_STAT_INSERT BIT1 #define QEMU_CPUHP_STAT_REMOVE BIT2 +#define QEMU_CPUHP_STAT_EJECT BIT3 #define QEMU_CPUHP_STAT_FW_REMOVE BIT4 =20 #define QEMU_CPUHP_RW_CMD_DATA 0x8 diff --git a/OvmfPkg/CpuHotplugSmm/CpuHotplug.c b/OvmfPkg/CpuHotplugSmm/Cpu= Hotplug.c index 2eeb4567a262..ae3abd525900 100644 --- a/OvmfPkg/CpuHotplugSmm/CpuHotplug.c +++ b/OvmfPkg/CpuHotplugSmm/CpuHotplug.c @@ -18,6 +18,7 @@ #include // CPU_HOT_EJECT_DATA #include // EFI_MM_CPU_IO_PROTOCOL #include // EFI_SMM_CPU_SERVICE_PROTOC= OL +#include // MSR_IA32_APIC_BASE_REGISTER #include // EFI_STATUS =20 #include "ApicId.h" // APIC_ID @@ -193,12 +194,40 @@ RevokeNewSlot: } =20 /** + EjectCpu needs to know the BSP at SMI exit at a point when + some of the EFI_SMM_CPU_SERVICE_PROTOCOL state has been torn + down. + Reuse the logic from OvmfPkg::PlatformSmmBspElection() to + do that. + + @retval TRUE If the CPU executing this function is the BSP. + + @retval FALSE If the CPU executing this function is an AP. +**/ +STATIC +BOOLEAN +CheckIfBsp ( + VOID + ) +{ + MSR_IA32_APIC_BASE_REGISTER ApicBaseMsr; + BOOLEAN IsBsp; + + ApicBaseMsr.Uint64 =3D AsmReadMsr64 (MSR_IA32_APIC_BASE); + IsBsp =3D (BOOLEAN)(ApicBaseMsr.Bits.BSP =3D=3D 1); + return IsBsp; +} + +/** CPU Hot-eject handler, called from SmmCpuFeaturesRendezvousExit() on each CPU at exit from SMM. =20 - If, the executing CPU is not being ejected, nothing to be done. + If, the executing CPU is neither the BSP, nor being ejected, nothing + to be done. If, the executing CPU is being ejected, wait in a halted loop until ejected. + If, the executing CPU is the BSP, set QEMU CPU status to eject + for CPUs being ejected. =20 @param[in] ProcessorNum ProcessorNum denotes the CPU exiting SMM, and will be used as an index into @@ -214,6 +243,83 @@ EjectCpu ( { UINT64 QemuSelector; =20 + if (CheckIfBsp ()) { + UINT32 Idx; + + for (Idx =3D 0; Idx < mCpuHotEjectData->ArrayLength; Idx++) { + UINT64 QemuSelector; + + QemuSelector =3D mCpuHotEjectData->QemuSelectorMap[Idx]; + + if (QemuSelector !=3D CPU_EJECT_QEMU_SELECTOR_INVALID) { + // + // This to-be-ejected-CPU has already received the BSP's SMI exit + // signal and will execute SmmCpuFeaturesRendezvousExit() + // followed by this callback or is already penned in the + // CpuSleep() loop below. + // + // Tell QEMU to context-switch it out. + // + QemuCpuhpWriteCpuSelector (mMmCpuIo, (UINT32) QemuSelector); + QemuCpuhpWriteCpuStatus (mMmCpuIo, QEMU_CPUHP_STAT_EJECT); + + // + // Now that we've ejected the CPU corresponding to QemuSelectorMap= [Idx], + // clear its eject status to ensure that an invalid future SMI does + // not end up trying a spurious eject or a newly hotplugged CPU do= es + // not get penned in the CpuSleep() loop. + // + // Note that the QemuCpuhpWriteCpuStatus() command above is a writ= e to + // a different address space and uses the EFI_MM_CPU_IO_PROTOCOL. + // + // This means that we are guaranteed that the following assignment + // will not be reordered before the eject. And, so we can safely + // do this write here. + // + mCpuHotEjectData->QemuSelectorMap[Idx] =3D + CPU_EJECT_QEMU_SELECTOR_INVALID; + + DEBUG ((DEBUG_INFO, "%a: Unplugged ProcessorNum %u, " + "QemuSelector %Lu\n", __FUNCTION__, Idx, QemuSelector)); + } + } + + // + // We are done until the next hot-unplug; clear the handler. + // + // mCpuHotEjectData->Handler is a NOP for any CPU not under ejection. + // So, once we are done with all the ejections, we can safely reset it + // here since any CPU dereferencing it would only see either the old + // or the new value (since it is aligned at a natural boundary.) + // + mCpuHotEjectData->Handler =3D NULL; + return; + } + + // + // Reached only on APs + // + + // + // mCpuHotEjectData->QemuSelectorMap[ProcessorNum] is updated + // on the BSP in the ongoing SMI at two places: + // + // - UnplugCpus() where the BSP determines if a CPU is under ejection + // or not. As a comment in UnplugCpus() at set-up, and in + // SmmCpuFeaturesRendezvousExit() where it is dereferenced describe, + // any such updates are guaranteed to be ordered-before the + // dereference below. + // + // - EjectCpu() on the BSP (above) updates QemuSelectorMap[ProcessorNum] + // for a CPU once it's ejected. + // + // The CPU under ejection: might be executing anywhere between the + // AllCpusInSync loop in SmiRendezvous(), to about to dereference + // QemuSelectorMap[ProcessorNum]. + // As described in the comment above where we do the reset, this + // is not a problem since the ejected CPU never sees the after value. + // CPUs not-under ejection: never see any changes so they are fine. + // QemuSelector =3D mCpuHotEjectData->QemuSelectorMap[ProcessorNum]; if (QemuSelector =3D=3D CPU_EJECT_QEMU_SELECTOR_INVALID) { return; @@ -495,11 +601,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 ProcessHotAddedCpus (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 (#72710): https://edk2.groups.io/g/devel/message/72710 Mute This Topic: https://groups.io/mt/81273610/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 16:46:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+72712+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+72712+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 161553044906937.70386532707255; Thu, 11 Mar 2021 22:27:29 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 9tKOYY1788612x0OqAfherfY; Thu, 11 Mar 2021 22:27:26 -0800 X-Received: from userp2130.oracle.com (userp2130.oracle.com [156.151.31.86]) by mx.groups.io with SMTP id smtpd.web10.4850.1615530443436306720 for ; Thu, 11 Mar 2021 22:27:23 -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 12C6AP2d178589; Fri, 12 Mar 2021 06:27:20 GMT X-Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 37415rgyes-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Mar 2021 06:27:20 +0000 X-Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 12C6PZJ6028260; Fri, 12 Mar 2021 06:27:19 GMT X-Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2100.outbound.protection.outlook.com [104.47.55.100]) by aserp3030.oracle.com with ESMTP id 374kasv216-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Mar 2021 06:27:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=n/m9z3mIfRjH4l/OGXO9p5eJS/tVsycxYRttW1gxn96iNtSZZ/Ba8AGjdTgGsrNMnemQRbVGYXstr288hR7uOyEZar0SLuBFAGPkHytws/JRvzze1C412aaXzTeT+UrOkCHngqNF/NTlW8dRDsxFMJgmgz/ik6si+vWAqtFwcLCIqu3z3/RyC1UiCmoAhlFOoXf/UgkDwTH8br4PL6RxgSaUZZTE4wh2qXDVOCj6e7gv1nLRpwdHs+1p6mWu9QZov6sFV/q8SLD05dpJmLxNClYxYaVR7cuoVn/ckXfln/hndvKfhwXKnTrLhHG7yPDkQYvto13RB4jNrIbC/FD5sA== 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=ISCXpDOj5a8zRtidYkvfukmM3hiGm7++3qxBHtTwxe8=; b=VqzsfMvGqn0XkU72FSuMS6t5BLdJex2K1FXOtmxvJSb57e7PBEwVvIhx4nnLvYJWGFxpH8pUuK8XCQNd9tuT2XO9Dcyu12yp+dp8M13nIV/cq4WQqqIWDM6Q5CRLjXrPv8B9QoA7EiMkXvIe7g1tbQxz2uYGE7qP0UD6pUOUcu9kpylA9ac6nnliBRBOXksO2bqgul3HknH8tcLQspHXbQihyqbfqLamKLkw0/DBqZzvCudzW7JAtVm83UnsYe+p4BbBhF4QExA9+TftdwUSz4UyExfTD0MTX+Ev2KC3xciTma+n5wjlBujj6on7g14K9CiEYlxGzMA9Qq6Ch96n4Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none X-Received: from SJ0PR10MB4605.namprd10.prod.outlook.com (2603:10b6:a03:2d9::24) by SJ0PR10MB4544.namprd10.prod.outlook.com (2603:10b6:a03:2ad::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3933.31; Fri, 12 Mar 2021 06:27:17 +0000 X-Received: from SJ0PR10MB4605.namprd10.prod.outlook.com ([fe80::a021:790:7ce6:6f16]) by SJ0PR10MB4605.namprd10.prod.outlook.com ([fe80::a021:790:7ce6:6f16%6]) with mapi id 15.20.3912.030; Fri, 12 Mar 2021 06:27:17 +0000 From: "Ankur Arora" To: devel@edk2.groups.io Cc: lersek@redhat.com, imammedo@redhat.com, boris.ostrovsky@oracle.com, Ankur Arora , Jordan Justen , Ard Biesheuvel , Aaron Young Subject: [edk2-devel] [PATCH v9 10/10] OvmfPkg/SmmControl2Dxe: negotiate CPU hot-unplug Date: Thu, 11 Mar 2021 22:26:56 -0800 Message-Id: <20210312062656.2477515-11-ankur.a.arora@oracle.com> In-Reply-To: <20210312062656.2477515-1-ankur.a.arora@oracle.com> References: <20210312062656.2477515-1-ankur.a.arora@oracle.com> X-Originating-IP: [148.87.23.12] X-ClientProxiedBy: MWHPR02CA0018.namprd02.prod.outlook.com (2603:10b6:300:4b::28) To SJ0PR10MB4605.namprd10.prod.outlook.com (2603:10b6:a03:2d9::24) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Received: from prion.us.oracle.com (148.87.23.12) by MWHPR02CA0018.namprd02.prod.outlook.com (2603:10b6:300:4b::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3912.17 via Frontend Transport; Fri, 12 Mar 2021 06:27:16 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0234e88d-4e57-4aa9-987e-08d8e51fe23a X-MS-TrafficTypeDiagnostic: SJ0PR10MB4544: 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: bchyoEFcvJhYxMjYS0RY/d9FgpELm0+tHevD0rdRk7NmDeMfyCPxdMNtCFvXTq22qinX2Z/M+UcVa9HK/ySLyud6tl/5bG+TCU3a1zrlnSpfyE12AdFfq+NjP92OvuzJ5qRsRbsoxcH5YWnu/N24WocFQzIUW0drixdyPIGiv4CbZNYtGKL7cRzVOaTumvuTbzcpf34HJnqbKRyXHbS2lpE0pExlqa57sWHBgujGHQlDBI+l/hCo+Lr0CxrST1hn8n8zsonGvNTjWpBag+F3Zne78NmGjaeYLIsTFjTCkB0LnTsiB35Y2kh3MgBupsnFIJSwa17EqVp6QUCGjz08N+tpa3jttuSQlMdHURd4pUBljlg5WMUvjSWW+snfvh0HHvBU2hB6qPjGcxrZe1L98grIFMjTaj/l320MSY3c57l+/qYt2SintxG7UD8E2EVGcBRbkw2GwhEiTqWbnWp3qlDN0B8/dIKe/TZrJTJGaBCFNSse3+543xRi3oV4XR9SinUI4yI/WZNrjOqqG83N6Y7cC+fnjdVPhKiuusYKIYcY5Av8TixUixMJpydzCecfnzkhTttQ5f6UGLIYz2l7VoB+V0CMVTCMEvdKHcvTbtIC0DBhUUBdMIB/PvqR/ZnPlA5b/DzbIDD/N7evVwrG/w== X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?bMOYh3lS7DWFpxPN2kNyRaaM692WiLzDV3xpnINlJ6hevnLd+JRNTblqwS/9?= =?us-ascii?Q?D7b2SUHJq+Sx7LE7qoX69fWbbPuaLX66AQR/R4cJYnMAMp6qkkNKfLaSUxlO?= =?us-ascii?Q?o1rKbKqbC33QdKGr1EuGX0KNrpFPY5BmFALg2TmhMo9N8IFjngwSzxFOL9nq?= =?us-ascii?Q?WJt0qGaR4PONM+tbfEYr3jPHfIVNUJ802sjBr/b93Lb/BwwFOt10XCV9gBdC?= =?us-ascii?Q?pgzBr9pAfU+vXhBeAtjUgLLX6WmKTrVez+YwKpzG5Z3PUJQG+RwyhXRpWodq?= =?us-ascii?Q?qcXqyCHo+MqLslhxd4aHPbbKqzCRMwCLuUCpS6Qqy5qg5aBfUKUhne5TeEmW?= =?us-ascii?Q?QhkkmtQMbN7bY5H8SXNg6u5SfWlzVs00rxGAxhQr9c64Zu2J1gn93uKiDisa?= =?us-ascii?Q?LSKznqp+TGknHo1jPHDUidpq+6Hh969YUy8ftsxZ1ZvX1hB3KF6jSTU31Z1l?= =?us-ascii?Q?KVdFUWTWw14XFRyVzfgTa+lN7WCQTNpv3A9p8SNkHS1aElKEJ4gDq4o1ur1I?= =?us-ascii?Q?hYh4bHnoV1mWbwzo7FFNNxUQg/UTNcc4skI7P2V9M93SRXjyzocpQz6gyMky?= =?us-ascii?Q?jbClLWWBrGe9ZQnu1oBPRrR0NX0lZCnn530ecvyO7vOkSXBCbN9AGO2lkDio?= =?us-ascii?Q?964TZV3zlEGXefXk7oV2WvhqnUJ5k1k6q0Ja0bBWUgricmCzJzbpz0AnXgyg?= =?us-ascii?Q?n+C7WtzAwVN+P6cfB8CPZxEC/Vcf3ePTab6aEqKEuYNth/7UYKZCggqCKDRB?= =?us-ascii?Q?e2UXCoFdvoJwhjJXmpClkK+hK3c9BMhh2AssomMlGU+nJ3FXfb5bHJsohNAP?= =?us-ascii?Q?UfEzFsmuu6nc+wsXuniqoVMb99MSKV5We6DT3c9hDrPNursy+pfkPhs/S4aL?= =?us-ascii?Q?pbFXLtKgWQ8j045oiAsdCup4luKpTfjYi4QyIjdJFTjK1PcfT6U9EpOh5cha?= =?us-ascii?Q?/Zj+RMyNwGa5FuQ3cx8D2XDwP1OUldT/9N35Vdh8bY+4eh9jK9FMUVmytkNP?= =?us-ascii?Q?YC6A0VvylmoCz1gENKWgZdJzQa+YkhN5gstURCl75t4Qh2eMBbsr4ehTJ7Ve?= =?us-ascii?Q?YYUbGGBxRC6wUjhiUMn7u+cAWz+mQf2oR2CSYRkuAw8EcgLKHv/QemsV7T69?= =?us-ascii?Q?TW3BGRm3R/iXHZOmwbAFeW7x/MZErgb5V4BdLpsxYWzFeftHguK3pFx17o8N?= =?us-ascii?Q?xhh+hxlmmQTE3fBXcWe+jPFzF+ZZ37k8y9LGhad/UI+aqYB/8rhwdntQK0r0?= =?us-ascii?Q?7c9fihutqTPw+zhT2mN/63AsFJbafqHwxP6iFwrtdj7QbRPyIblAYiu8Pzdj?= =?us-ascii?Q?OvkQwuQYPw0ERWyk/OLAzBTK?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0234e88d-4e57-4aa9-987e-08d8e51fe23a X-MS-Exchange-CrossTenant-AuthSource: SJ0PR10MB4605.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Mar 2021 06:27:17.7174 (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: uSavlIv9wnnwZp1toZH59uxhuqgHn16zyGGVpx1TQQ50QU7R0nCs96T/1kdNEeMKaJiOjpEWsxGiv4ax7FVpYde4nIN7KHZ9WP5i2e4duC0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4544 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: HsB43gFC8QFqxsQBZqCo0i90x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1615530446; bh=dA9ye+dN4tbSEZzd703qlYC2FsC3jjRNJ9QhVXVILNo=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=orisjZKZk9c6aL9kvnkeikSNwkys4EoEf+EJLxICMk3PR4NSZ9wvpR9oyeXNH13orG5 l6yrajocfK1dtxXFoynoV7OnLnWtsWZLeXUUKIZGL2nCxXdFvmMGKBMI0AJ4O1upfrcjy gZWVLnk0hbq1k0H4S0FrtRUSUcYT62HF2EU= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Advertise OVMF support for CPU hot-unplug and negotiate it if QEMU requests the feature. Cc: Laszlo Ersek Cc: Jordan Justen Cc: Ard Biesheuvel Cc: Igor Mammedov Cc: Boris Ostrovsky Cc: Aaron Young Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3132 Signed-off-by: Ankur Arora Reviewed-by: Laszlo Ersek --- Notes: Addresses the following comments from v8: =20 (1) Remove inconsistent comment style (and stray newline) around the ne= wly added ICH9_LPC_SMI_F_CPU_HOT_UNPLUG. (2) Remove spurious empty line. OvmfPkg/SmmControl2Dxe/SmiFeatures.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/OvmfPkg/SmmControl2Dxe/SmiFeatures.c b/OvmfPkg/SmmControl2Dxe/= SmiFeatures.c index c9d875543205..3e2e61e4dbd0 100644 --- a/OvmfPkg/SmmControl2Dxe/SmiFeatures.c +++ b/OvmfPkg/SmmControl2Dxe/SmiFeatures.c @@ -28,7 +28,12 @@ // "etc/smi/supported-features" and "etc/smi/requested-features" fw_cfg fi= les. // #define ICH9_LPC_SMI_F_CPU_HOTPLUG BIT1 - +// +// The following bit value stands for "enable CPU hot-unplug, and inject a= n SMI +// with control value ICH9_APM_CNT_CPU_HOTPLUG upon hot-unplug", in the +// "etc/smi/supported-features" and "etc/smi/requested-features" fw_cfg fi= les. +// +#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 +117,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, SMI on CPU hot-unplug + // and nothing else. // RequestedFeaturesMask =3D ICH9_LPC_SMI_F_BROADCAST; if (!MemEncryptSevIsEnabled ()) { @@ -120,6 +126,7 @@ 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; QemuFwCfgSelectItem (mRequestedFeaturesItem); @@ -166,6 +173,13 @@ NegotiateSmiFeatures ( __FUNCTION__)); } =20 + if ((mSmiFeatures & ICH9_LPC_SMI_F_CPU_HOT_UNPLUG) =3D=3D 0) { + DEBUG ((DEBUG_INFO, "%a: CPU hot-unplug not negotiated\n", __FUNCTION_= _)); + } else { + DEBUG ((DEBUG_INFO, "%a: CPU hot-unplug with SMI negotiated\n", + __FUNCTION__)); + } + // // Negotiation successful (although we may not have gotten the optimal // feature set). --=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 (#72712): https://edk2.groups.io/g/devel/message/72712 Mute This Topic: https://groups.io/mt/81273612/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-