From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mx.groups.io with SMTP id smtpd.web09.986.1613177921593217349 for ; Fri, 12 Feb 2021 16:58:41 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@linux.microsoft.com header.s=default header.b=O8VBbL5f; spf=pass (domain: linux.microsoft.com, ip: 13.77.154.182, mailfrom: mikuback@linux.microsoft.com) Received: from localhost.localdomain (unknown [131.107.174.202]) by linux.microsoft.com (Postfix) with ESMTPSA id 22AC620B57A0; Fri, 12 Feb 2021 16:58:41 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 22AC620B57A0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1613177921; bh=DgAxMQqBeofpY0Z53hhYUtGriIdHKNaWVipgL4S6Bd4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O8VBbL5fDU8ugbvVAJXVAbxf4D9UpR2fKIyEyuY6EVQRDDkm83EmJz1kSewsTKNUm UhmLuML++ikoDEc2Q2Rd3tV8XZLQ9H5V+FUKEXCMb+ja02PxbYl4/98DFQAOjh1m/9 wychjdRU1zUGpnCyVUouJGEaQ8uunSwlW/EqMD2k= From: "Michael Kubacki" To: devel@edk2.groups.io Cc: Eric Dong , Ray Ni , Laszlo Ersek , Rahul Kumar Subject: [PATCH v2 4/4] UefiCpuPkg/SmmCpuFeaturesLib: Add Standalone MM support Date: Fri, 12 Feb 2021 16:58:06 -0800 Message-Id: <20210213005806.2927-5-mikuback@linux.microsoft.com> X-Mailer: git-send-email 2.28.0.windows.1 In-Reply-To: <20210213005806.2927-1-mikuback@linux.microsoft.com> References: <20210213005806.2927-1-mikuback@linux.microsoft.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Michael Kubacki REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D3218 Adds an INF for StandaloneMmCpuFeaturesLib, which supports building the SmmCpuFeaturesLib code for Standalone MM. Minimal code changes are made to allow reuse of existing code for Standalone MM. The original INF file names are left intact (continue to use SMM terminology) to retain backward compatibility with platforms that use those INFs. Similarly, the pre-existing C file names are unchanged to be consistent with the INF file names. Cc: Eric Dong Cc: Ray Ni Cc: Laszlo Ersek Cc: Rahul Kumar Signed-off-by: Michael Kubacki --- UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c | 2= +- UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibNoStm.c | 2= +- UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.c | 2= +- UefiCpuPkg/Library/SmmCpuFeaturesLib/StandaloneMmCpuFeaturesLib.c | 51= ++++++++++++++++++++ UefiCpuPkg/Library/SmmCpuFeaturesLib/StandaloneMmCpuFeaturesLib.inf | 38= +++++++++++++++ UefiCpuPkg/UefiCpuPkg.dsc | 1= + 6 files changed, 93 insertions(+), 3 deletions(-) diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c b/U= efiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c index a494988898b8..990fdb098865 100644 --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c +++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c @@ -7,7 +7,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ =20 -#include +#include #include #include #include diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibNoStm.= c b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibNoStm.c index eebbbfd00a83..5946081afbb7 100644 --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibNoStm.c +++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibNoStm.c @@ -8,7 +8,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ =20 -#include +#include #include #include "CpuFeaturesLib.h" =20 diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.c b/UefiCpuPkg/L= ibrary/SmmCpuFeaturesLib/SmmStm.c index 4b6bf958cedf..cda1ab8e78de 100644 --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.c +++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.c @@ -6,7 +6,7 @@ =20 **/ =20 -#include +#include #include #include #include diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/StandaloneMmCpuFeatures= Lib.c b/UefiCpuPkg/Library/SmmCpuFeaturesLib/StandaloneMmCpuFeaturesLib.c new file mode 100644 index 000000000000..114b177e5e57 --- /dev/null +++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/StandaloneMmCpuFeaturesLib.c @@ -0,0 +1,51 @@ +/** @file +Standalone MM CPU specific programming. + +Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.
+Copyright (c) Microsoft Corporation.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include "CpuFeaturesLib.h" + +/** + Gets the maximum number of logical processors from the PCD PcdCpuMaxLo= gicalProcessorNumber. + + This access is abstracted from the PCD services to enforce that the PC= D be + FixedAtBuild in the Standalone MM build of this driver. + + @retval The value of PcdCpuMaxLogicalProcessorNumber. + + +**/ +UINT32 +GetCpuMaxLogicalProcessorNumber ( + VOID + ) +{ + return FixedPcdGet32 (PcdCpuMaxLogicalProcessorNumber); +} + +/** + The Standalone MM library constructor. + + @param[in] ImageHandle Image handle of this driver. + @param[in] SystemTable A Pointer to the EFI System Table. + + @retval EFI_SUCCESS This constructor always returns success. + +**/ +EFI_STATUS +EFIAPI +StandaloneMmCpuFeaturesLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_MM_SYSTEM_TABLE *SystemTable + ) +{ + CpuFeaturesLibInitialization (); + + return EFI_SUCCESS; +} diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/StandaloneMmCpuFeatures= Lib.inf b/UefiCpuPkg/Library/SmmCpuFeaturesLib/StandaloneMmCpuFeaturesLib= .inf new file mode 100644 index 000000000000..64f0a0853337 --- /dev/null +++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/StandaloneMmCpuFeaturesLib.inf @@ -0,0 +1,38 @@ +## @file +# Standalone MM CPU specific programming. +# +# Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved. +# Copyright (c) Microsoft Corporation.
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D StandaloneMmCpuFeaturesLib + MODULE_UNI_FILE =3D SmmCpuFeaturesLib.uni + FILE_GUID =3D BB554A2D-F5DF-41D3-8C62-46476A2B2B1= 8 + MODULE_TYPE =3D MM_STANDALONE + VERSION_STRING =3D 1.0 + PI_SPECIFICATION_VERSION =3D 0x00010032 + LIBRARY_CLASS =3D SmmCpuFeaturesLib + CONSTRUCTOR =3D StandaloneMmCpuFeaturesLibConstruct= or + +[Sources] + CpuFeaturesLib.h + StandaloneMmCpuFeaturesLib.c + SmmCpuFeaturesLib.c + SmmCpuFeaturesLibNoStm.c + +[Packages] + MdePkg/MdePkg.dec + UefiCpuPkg/UefiCpuPkg.dec + +[LibraryClasses] + BaseLib + DebugLib + MemoryAllocationLib + PcdLib + +[FixedPcd] + gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber ## SO= METIMES_CONSUMES diff --git a/UefiCpuPkg/UefiCpuPkg.dsc b/UefiCpuPkg/UefiCpuPkg.dsc index 9128cef076dd..7db419471deb 100644 --- a/UefiCpuPkg/UefiCpuPkg.dsc +++ b/UefiCpuPkg/UefiCpuPkg.dsc @@ -154,6 +154,7 @@ [Components.IA32, Components.X64] UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull= .inf UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf + UefiCpuPkg/Library/SmmCpuFeaturesLib/StandaloneMmCpuFeaturesLib.inf UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPei.inf UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationSmm.inf --=20 2.28.0.windows.1