From nobody Thu Nov 14 16:52:39 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+70481+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+70481+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1610951712; cv=none; d=zohomail.com; s=zohoarc; b=mHsnGXpICxe7qMLATqd0VYkrMhgXb+kuNFgyZTBMGFdSWeurL1jacoMQq78mipTTkxE3u/HeS7ZiCowOs5SuEh9oDj0xYr2gm2anOlRhyKqvu1Cz6Pzs47DLYdZ6DmN8Z69R3bo8ERa5WdTv3Q7ot/9pZ3TrO8N0tWjj0ThbBE4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610951712; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=D66yt7Ax7HzQArAAMlFDq4MhnY2iM1Pi2/Yd7GNC3lM=; b=NmNrKf0AmodBXurETlx5FrMA6cYV3VhXkoJT4Bpgr8zT+N0m7UqdBXf7zSuQCyocHM6pvn9jhPcw0XVp4S1fiDqdvT90BhuukLTluKO+ImdWAYap7pXKV+mkV1AEJQi1WIWuZowkBXi1eHCsuSlMwiy0sA1OuUJUeiVjbLPvZm4= ARC-Authentication-Results: i=1; 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+70481+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1610951712158967.2774601897842; Sun, 17 Jan 2021 22:35:12 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 75iSYY1788612x9wrQzL5AFR; Sun, 17 Jan 2021 22:35:11 -0800 X-Received: from aserp2120.oracle.com (aserp2120.oracle.com [141.146.126.78]) by mx.groups.io with SMTP id smtpd.web12.30045.1610951711360780878 for ; Sun, 17 Jan 2021 22:35:11 -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 10I6Y976093292; Mon, 18 Jan 2021 06:35:08 GMT X-Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 363r3kkm5d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Jan 2021 06:35:08 +0000 X-Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 10I6TucR098992; Mon, 18 Jan 2021 06:35:07 GMT X-Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3020.oracle.com with ESMTP id 364a1vywp6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Jan 2021 06:35:07 +0000 X-Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 10I6Z7ms011778; Mon, 18 Jan 2021 06:35:07 GMT X-Received: from prion.us.oracle.com (/10.159.226.191) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 17 Jan 2021 22:35:06 -0800 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 v4 6/9] OvmfPkg/SmmCpuFeaturesLib: init CPU ejection state Date: Sun, 17 Jan 2021 22:34:54 -0800 Message-Id: <20210118063457.358581-7-ankur.a.arora@oracle.com> In-Reply-To: <20210118063457.358581-1-ankur.a.arora@oracle.com> References: <20210118063457.358581-1-ankur.a.arora@oracle.com> MIME-Version: 1.0 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: uY71OSDTU6zYVtn43iYKqA3Ex1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1610951711; bh=mXkN4uPmltqSraog8HImjAQ0vodmYaY2jtCITRpRn8k=; h=Cc:Date:From:Reply-To:Subject:To; b=m46xUZ2ABwOjfhFsBQ0w+WEPkRHw6njYFP8J/9KLumNrYIjExOmXF0GSdx9g1Y0HuMy 5WZJ1OS6G3zD71zKdBJc+O3EjQ1UL+SbNbPc5BEDRu4xxWACWS76my4phL9EnUiDsY+BQ 2HaE3BJ8p1GMP/H8ehIL2eEfBU6R6cCTumk= 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 --- .../Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c | 62 ++++++++++++++++++= ++++ .../SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf | 3 ++ 2 files changed, 65 insertions(+) diff --git a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c b/OvmfPk= g/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c index 7ef7ed98342e..70313fb754e2 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,54 @@ SmmCpuFeaturesHookReturnFromSmm ( return OriginalInstructionPointer; } =20 +GLOBAL_REMOVE_IF_UNREFERENCED +CPU_HOT_EJECT_DATA *mCpuHotEjectData =3D NULL; + +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 +238,9 @@ SmmCpuFeaturesSmmRelocationComplete ( UINTN MapPagesBase; UINTN MapPagesCount; =20 + + SmmCpuFeaturesSmmInitHotEject(); + if (!MemEncryptSevIsEnabled ()) { return; } @@ -375,6 +428,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 /** diff --git a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf b/Ovmf= Pkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf index 97a10afb6e27..c27b0f2c4d03 100644 --- a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf +++ b/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf @@ -35,4 +35,7 @@ UefiBootServicesTableLib =20 [Pcd] + gUefiCpuPkgTokenSpaceGuid.PcdCpuHotPlugSupport + gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber + gUefiOvmfPkgTokenSpaceGuid.PcdCpuHotEjectDataAddress gUefiOvmfPkgTokenSpaceGuid.PcdQ35SmramAtDefaultSmbase --=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 (#70481): https://edk2.groups.io/g/devel/message/70481 Mute This Topic: https://groups.io/mt/79917578/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-