From nobody Thu Nov 14 17:03:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+70765+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+70765+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=oracle.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1611643510387607.3500044290194; Mon, 25 Jan 2021 22:45:10 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id cOZqYY1788612x0eDjuPHH1a; Mon, 25 Jan 2021 22:45:10 -0800 X-Received: from aserp2130.oracle.com (aserp2130.oracle.com [141.146.126.79]) by mx.groups.io with SMTP id smtpd.web11.9043.1611643503816550178 for ; Mon, 25 Jan 2021 22:45:03 -0800 X-Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 10Q6Z9xP058326; Tue, 26 Jan 2021 06:45:00 GMT X-Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2130.oracle.com with ESMTP id 3689aagu12-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 26 Jan 2021 06:45:00 +0000 X-Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 10Q6a687097113; Tue, 26 Jan 2021 06:44:59 GMT X-Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2177.outbound.protection.outlook.com [104.47.59.177]) by userp3030.oracle.com with ESMTP id 368wqw1qcn-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 26 Jan 2021 06:44:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jhm3+bPLOlHVD4T8v562b2Iaj0BYeaz27UvlV7Ci84r75Z2R9NwKD3SgXS8kYkWKFoxlBJM0FaHHvy6wLak30ZMwEApoUeyTnvXhkluzi1P6gyU9vrulcaE3TNtTEx4we7Xf2aMSxHAn8XzxSwWG7SaUDymA8MrTJZcuAwpQpUIXZrhLydjlCtihx2IHbBiiBaiAvM6yAOg4efu70aNXCXD38F7uelP5tO+b7DHieYo0NwGTxG0Gr+cAqm/vMoXOKF9Rssj/8MO3ZMWW5SMK12ISNMpUgH9lJwP3+khFk/CSmPAUIJLODWWpAir3m54t1tkGR5PZ5cT6FbdKZsFj0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rEZIou7OuIqHe0dmF1Nzoj9skeKqs1rwnMMR2GxDFXQ=; b=L0vQjVdcuSGSXR3fIlN38Trd5CMkGfoXvxH08K+e9DbryPZnZA2+IJKKzBoH71sPHJMOVjp2RT1/QzOTY54IRHJUtYE+fC6CKuokQj8s0lLIXPNfYl9ttriIDGILACagVkqCM2iwUyXZ6XY/ggl4hAFaPBPqeGbA/RkNqmCVYEladrEarzIK0hHO1KowoZKK+bnv9v6V+dEqU3Cmq+A4qHSUCs+TNmHF0jpJiyLX1qgNTXE8B4iBnfjq61yVf2R/AAY4Ltf0+JiIgCQfMVwg/heCc+VCvWd/btBMjtExFbGyKZ4z/00wgp0VanKJcgxNGv7UZNObC/X/uROksV9NQA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none X-Received: from CY4PR10MB1718.namprd10.prod.outlook.com (2603:10b6:910:9::17) by CY4PR1001MB2184.namprd10.prod.outlook.com (2603:10b6:910:45::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.14; Tue, 26 Jan 2021 06:44:57 +0000 X-Received: from CY4PR10MB1718.namprd10.prod.outlook.com ([fe80::39dc:6ba7:9397:cb6]) by CY4PR10MB1718.namprd10.prod.outlook.com ([fe80::39dc:6ba7:9397:cb6%6]) with mapi id 15.20.3784.019; Tue, 26 Jan 2021 06:44:57 +0000 From: "Ankur Arora" To: devel@edk2.groups.io Cc: lersek@redhat.com, imammedo@redhat.com, boris.ostrovsky@oracle.com, Ankur Arora , Jordan Justen , Ard Biesheuvel , Aaron Young Subject: [edk2-devel] [PATCH v5 6/9] OvmfPkg/SmmCpuFeaturesLib: init CPU ejection state Date: Mon, 25 Jan 2021 22:44:37 -0800 Message-Id: <20210126064440.299596-7-ankur.a.arora@oracle.com> In-Reply-To: <20210126064440.299596-1-ankur.a.arora@oracle.com> References: <20210126064440.299596-1-ankur.a.arora@oracle.com> X-Originating-IP: [70.36.60.91] X-ClientProxiedBy: MWHPR18CA0061.namprd18.prod.outlook.com (2603:10b6:300:39::23) To CY4PR10MB1718.namprd10.prod.outlook.com (2603:10b6:910:9::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Received: from localhost.localdomain (70.36.60.91) by MWHPR18CA0061.namprd18.prod.outlook.com (2603:10b6:300:39::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.12 via Frontend Transport; Tue, 26 Jan 2021 06:44:53 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 04e365dc-2676-4935-37ec-08d8c1c5e35b X-MS-TrafficTypeDiagnostic: CY4PR1001MB2184: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: TC1f5VWkZwgyD7++XLvEyDNGhqjNppvQKYdHJpa98VbZxrcwKfvpYFmfr6E0/ofzfQvxmYHj03XuA8z00EVBww/bgkYAUHeiMGjIsNgF2EFwRzLnud/YQIWDlrgQOm8cD4w8enMrQURLG8Sc0zgje503bzk0l0K2OUEyGy89zvxmHpqfSd5CSqXGPxPn9Ttxtd/ZNhN1hNpBZzBmrsg4IZX0LKIdOgNfU3FpmghcxoqLsOkOESY9+MRBhVBCrnUbKajFRPYJG6y9VW0YpncPcHOjcd13MHuWhlim3zFZANJOuLtIHlKmweON59YcAbHh9XmsYzlvsaoug0nb/omJQj8AFqJtXoyb6QHsxtvPYmqfmkWrl5jEUnr8giGqe35TqDtxKAugMaIGLtpko6Hq2+dU4ApwJG74ygy1fWSF8uoXeBKR+FgU8oj+y91uDUD8p+AtA/6HskcR9OzgqEeN1aa1iGOA8AIv29NbnAaICL94isoReXk6YlvU0OU28f9QE1KTpXjswwAPY866i1nDTg== X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?mUxaPq6IPX7753f2lbSPJ/qPRJGn1L/Qr429xYjKqTo6/zZx9879nnmZ9Glz?= =?us-ascii?Q?Nqq6mZx1vM0FhFea+c3HLlBrcrdjons+l+5eQ5Lc7tu+G0w0cmx7R799LHi8?= =?us-ascii?Q?XnHM9H4bYYfeObw/afnQGjt5Is1uqlslq1zNOXDm1RTCXrSmvJKqWuSe4pOO?= =?us-ascii?Q?a5NBWMz/QzKB4i0MXJGr2Z5lNdvoYmb/fswglf+XtqZLe3w4sFfedRIvDqQO?= =?us-ascii?Q?iT4gmKq/JgtRLkVRPvbTByzNoGoU4t4A7qBvir1NmBAPBencwJQFV7IpZreR?= =?us-ascii?Q?JWvGCy7DeVJeSXxjR26g3dYzNNqnMvBpCWNxqBEsYbWGlfx0bXN7wDdNuido?= =?us-ascii?Q?8aUaU31WaND1ANt9dN1Rm7BUd0taVR/yVdyjs2jtI4VJm5qt2mvmh/kVchV6?= =?us-ascii?Q?59bgY0l520mAu9D4QN9IT+bcIXSF1+AEoDc5Cwh/6JqsFPjciTviX3QiN3QT?= =?us-ascii?Q?vky/kausL3R9toNEbW6MkP75PqqcDnVK0m1DDW3nF0HPCqcba1W6kTwi11mH?= =?us-ascii?Q?V8BUdpT04/EAcH1K7u+tGFojquyZyJsLxMJMMQ9Bwdgk2f9XZhL3Ux0MULXf?= =?us-ascii?Q?VrAi6dzebLTmKHyhPi57Kvqof2wCR14pruLTY36ZwggDiYnTjOlOBbueYIe6?= =?us-ascii?Q?T0zpjhsKa87rCJ25RcWAP68biOmGzRweESumFhaIfMqFDlXU0xrrSckw2R+0?= =?us-ascii?Q?JcwKa9pk3yX1+6M9Xi38G9/L+VnGV7AKab4OU2RwgdFg1RUI+kKI4Iicirp6?= =?us-ascii?Q?kiSImMlEJhSZznMkXmvf8eVgzQgHgYUoFCRxFYip2QUvGV3ltqEDK4BLK4vx?= =?us-ascii?Q?KSb14KLQ/k7ghDsEsR/FVnQT6qBLETuA5SYxHMUJSON21X9GttcoMT298ESJ?= =?us-ascii?Q?kYYaX6GKgeRq9T+zY2UQPkfQtgg2fBSRWfBcKn8iofRV3Fxyypbmx9TolXp8?= =?us-ascii?Q?q49dkbfXf/HF4K3TEDcKWoc2VOlzRs9FbnpkQ71N3NfuwJolWGkKJEeUzk1C?= =?us-ascii?Q?LNCcA+we+EEivalsIig0+4SK61qFWb9UhqThtJO68Nl/v5wUG74N4HTGL8Qp?= =?us-ascii?Q?hikw+fxq?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 04e365dc-2676-4935-37ec-08d8c1c5e35b X-MS-Exchange-CrossTenant-AuthSource: CY4PR10MB1718.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jan 2021 06:44:54.1988 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: g1w6MMBH7QRzSlL5YmMC/B2qk4U2s+bVKu0w8d/GCkrkWBTi6A7r9DkQuqPfWuL+REHvd5+Z0UisweFn/VN6LYpBPbX9J7u82JWfm0KJ1Bg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1001MB2184 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,ankur.a.arora@oracle.com X-Gm-Message-State: nPqL6WLI2Gw1IP00mrmU2tEGx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1611643510; bh=2SoNLVs8iznbrpVYl2jeDO5c34Ji+DPtkb3QcyD9ZnA=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=NQ4Obo8ygLBOPd4VfnkLxvXYxoTa6B7PtwpaJ7h35GlpjHTue2RbkNuaFGHwEHVaU1c hnwGz4uhAI1wwgZLpX8vbtO8PbjVBxYDQ6b0IQ72r7SMFCm98iFPDPQJcc56DZo4Nprki KFHwfNByI9LPxRBZl4M7kHMb/chSe/YMGgo= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Init CPU_HOT_EJECT_DATA, which will be used to share CPU ejection state between SmmCpuFeaturesLib (via PiSmmCpuDxeSmm) and CpuHotPlugSmm. CpuHotplugSmm also sets up the CPU ejection mechanism via CPU_HOT_EJECT_DATA->Handler. Additionally, expose CPU_HOT_EJECT_DATA via PcdCpuHotEjectDataAddress. Cc: Laszlo Ersek Cc: Jordan Justen Cc: Ard Biesheuvel Cc: Igor Mammedov Cc: Boris Ostrovsky Cc: Aaron Young Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3132 Signed-off-by: Ankur Arora --- .../SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf | 3 + .../Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c | 68 ++++++++++++++++++= ++++ 2 files changed, 71 insertions(+) diff --git a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf b/Ovmf= Pkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf index 97a10afb6e27..32c63722ee62 100644 --- a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf +++ b/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf @@ -35,4 +35,7 @@ [LibraryClasses] UefiBootServicesTableLib =20 [Pcd] + gUefiCpuPkgTokenSpaceGuid.PcdCpuHotPlugSupport + gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber + gUefiOvmfPkgTokenSpaceGuid.PcdCpuHotEjectDataAddress gUefiOvmfPkgTokenSpaceGuid.PcdQ35SmramAtDefaultSmbase diff --git a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c b/OvmfPk= g/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c index 7ef7ed98342e..5c9cdc6710e4 100644 --- a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c +++ b/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c @@ -14,7 +14,9 @@ #include #include #include +#include // AllocatePool() #include +#include #include #include #include @@ -171,6 +173,60 @@ SmmCpuFeaturesHookReturnFromSmm ( return OriginalInstructionPointer; } =20 +GLOBAL_REMOVE_IF_UNREFERENCED +CPU_HOT_EJECT_DATA *mCpuHotEjectData =3D NULL; + +/** + This function initializes CpuHotEjectData if PcdCpuHotPlugSupport is + enabled and if more than 1 CPU is configured. + + Also sets up the corresponding PcdCpuHotEjectDataAddress. +**/ +STATIC +VOID +EFIAPI +SmmCpuFeaturesSmmInitHotEject( + VOID + ) +{ + UINT32 mMaxNumberOfCpus; + EFI_STATUS Status; + + if (!FeaturePcdGet (PcdCpuHotPlugSupport)) { + return; + } + + // PcdCpuHotPlugSupport =3D> PcdCpuMaxLogicalProcessorNumber + mMaxNumberOfCpus =3D PcdGet32 (PcdCpuMaxLogicalProcessorNumber); + + // No spare CPUs to eject + if (mMaxNumberOfCpus =3D=3D 1) { + return; + } + + mCpuHotEjectData =3D + (CPU_HOT_EJECT_DATA *)AllocatePool (sizeof (*mCpuHotEjectData)); + ASSERT (mCpuHotEjectData !=3D NULL); + + // + // Allocate buffer for pointers to array in CPU_HOT_EJECT_DATA. + // + mCpuHotEjectData->Revision =3D CPU_HOT_EJECT_DATA_REVISION_1; // Revis= ion + mCpuHotEjectData->ArrayLength =3D mMaxNumberOfCpus; // Array= Length of APIC ID + mCpuHotEjectData->ApicIdMap =3D // CpuIn= dex -> APIC ID map + (UINT64 *)AllocatePool (sizeof (UINT64) * mCpuHotEjectData->ArrayLengt= h); + mCpuHotEjectData->Handler =3D NULL; // Hot E= ject handler + mCpuHotEjectData->Handler =3D 0; // Reser= ved + + ASSERT (mCpuHotEjectData->ApicIdMap !=3D NULL); + + // + // Expose address of CPU Hot eject Data structure + // + Status =3D PcdSet64S (PcdCpuHotEjectDataAddress, (UINT64)(VOID *)mCpuHot= EjectData); + ASSERT_EFI_ERROR (Status); +} + /** Hook point in normal execution mode that allows the one CPU that was ele= cted as monarch during System Management Mode initialization to perform addit= ional @@ -188,6 +244,9 @@ SmmCpuFeaturesSmmRelocationComplete ( UINTN MapPagesBase; UINTN MapPagesCount; =20 + + SmmCpuFeaturesSmmInitHotEject(); + if (!MemEncryptSevIsEnabled ()) { return; } @@ -375,6 +434,15 @@ SmmCpuFeaturesRendezvousExit ( IN UINTN CpuIndex ) { + // + // CPU Hot eject not enabled. + // + if (mCpuHotEjectData =3D=3D NULL || + mCpuHotEjectData->Handler =3D=3D NULL) { + return; + } + + mCpuHotEjectData->Handler(CpuIndex); } =20 /** --=20 2.9.3 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#70765): https://edk2.groups.io/g/devel/message/70765 Mute This Topic: https://groups.io/mt/80125313/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-