From: "Abdul Lateef Attar via groups.io" <AbdulLateef.Attar=amd.com@groups.io>
To: <devel@edk2.groups.io>
Cc: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>,
Sami Mujawar <Sami.Mujawar@arm.com>,
Pierre Gondois <pierre.gondois@arm.com>
Subject: [edk2-devel] [PATCH v1 3/3] DynamicTablesPkg: Adds ACPI WSMT Table generator
Date: Tue, 20 Feb 2024 12:18:42 +0530 [thread overview]
Message-ID: <5048bd919b4751e9eae2ca15e8347e6fcecf3196.1708411357.git.AbdulLateef.Attar@amd.com> (raw)
In-Reply-To: <cover.1708411357.git.AbdulLateef.Attar@amd.com>
From: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
Adds generic ACPI WSMT table generator library.
Register/Deregister WSMT table.
Update the WSMT table during boot as per specification.
Cc: Sami Mujawar <Sami.Mujawar@arm.com>
Cc: Pierre Gondois <pierre.gondois@arm.com>
Signed-off-by: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
---
DynamicTablesPkg/DynamicTables.dsc.inc | 2 +
DynamicTablesPkg/Include/AcpiTableGenerator.h | 1 +
.../Include/ArchNameSpaceObjects.h | 10 +
.../Library/Acpi/AcpiWsmtLib/AcpiWsmtLib.inf | 34 +++
.../Library/Acpi/AcpiWsmtLib/WsmtGenerator.c | 221 ++++++++++++++++++
5 files changed, 268 insertions(+)
create mode 100644 DynamicTablesPkg/Library/Acpi/AcpiWsmtLib/AcpiWsmtLib.inf
create mode 100644 DynamicTablesPkg/Library/Acpi/AcpiWsmtLib/WsmtGenerator.c
diff --git a/DynamicTablesPkg/DynamicTables.dsc.inc b/DynamicTablesPkg/DynamicTables.dsc.inc
index af70785520..5e66f5cd02 100644
--- a/DynamicTablesPkg/DynamicTables.dsc.inc
+++ b/DynamicTablesPkg/DynamicTables.dsc.inc
@@ -36,6 +36,7 @@
#
DynamicTablesPkg/Library/Acpi/AcpiFadtLib/AcpiFadtLib.inf
DynamicTablesPkg/Library/Acpi/AcpiHpetLib/AcpiHpetLib.inf
+ DynamicTablesPkg/Library/Acpi/AcpiWsmtLib/AcpiWsmtLib.inf
#
# Dynamic Table Factory Dxe
@@ -44,6 +45,7 @@
<LibraryClasses>
NULL|DynamicTablesPkg/Library/Acpi/AcpiFadtLib/AcpiFadtLib.inf
NULL|DynamicTablesPkg/Library/Acpi/AcpiHpetLib/AcpiHpetLib.inf
+ NULL|DynamicTablesPkg/Library/Acpi/AcpiWsmtLib/AcpiWsmtLib.inf
}
[Components.ARM, Components.AARCH64]
diff --git a/DynamicTablesPkg/Include/AcpiTableGenerator.h b/DynamicTablesPkg/Include/AcpiTableGenerator.h
index 18b5f99f47..a32ef46ecb 100644
--- a/DynamicTablesPkg/Include/AcpiTableGenerator.h
+++ b/DynamicTablesPkg/Include/AcpiTableGenerator.h
@@ -100,6 +100,7 @@ typedef enum StdAcpiTableId {
EStdAcpiTableIdSsdtPciExpress, ///< SSDT Pci Express Generator
EStdAcpiTableIdPcct, ///< PCCT Generator
EStdAcpiTableIdHpet, ///< HPET Generator
+ EStdAcpiTableIdWsmt, ///< WSMT Generator
EStdAcpiTableIdMax
} ESTD_ACPI_TABLE_ID;
diff --git a/DynamicTablesPkg/Include/ArchNameSpaceObjects.h b/DynamicTablesPkg/Include/ArchNameSpaceObjects.h
index b421c4cd29..ad3045dfec 100644
--- a/DynamicTablesPkg/Include/ArchNameSpaceObjects.h
+++ b/DynamicTablesPkg/Include/ArchNameSpaceObjects.h
@@ -39,6 +39,7 @@ typedef enum ArchObjectID {
EArchObjFadtArmBootArch, ///< 11 - ARM boot arch information
EArchObjFadtHypervisorVendorId, ///< 12 - Hypervisor vendor identity information
EArchObjFadtMiscInfo, ///< 13 - Legacy fields; RTC, latency, flush stride, etc
+ EArchObjWsmtProtectionFlags, ///< 14 - WSMT protection flags
EArchObjMax
} E_ARCH_OBJECT_ID;
@@ -214,4 +215,13 @@ typedef struct CmArchFadtMiscInfo {
UINT8 Century;
} CM_ARCH_FADT_MISC_INFO;
+/** A structure that describes the
+ protection flags for the WSMT fields information.
+
+ ID: EArchObjWsmtProtectionFlags
+*/
+typedef struct CmArchWsmtProtectionFlags {
+ UINT32 ProtectionFlags;
+} CM_ARCH_WSMT_PROTECTION_FLAGS;
+
#endif
diff --git a/DynamicTablesPkg/Library/Acpi/AcpiWsmtLib/AcpiWsmtLib.inf b/DynamicTablesPkg/Library/Acpi/AcpiWsmtLib/AcpiWsmtLib.inf
new file mode 100644
index 0000000000..f8683a5005
--- /dev/null
+++ b/DynamicTablesPkg/Library/Acpi/AcpiWsmtLib/AcpiWsmtLib.inf
@@ -0,0 +1,34 @@
+## @file
+# WSMT Table Generator
+#
+# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+[Defines]
+ INF_VERSION = 1.27
+ BASE_NAME = AcpiWsmtLib
+ FILE_GUID = D6C34086-C914-4F8E-B56A-08329B4D1271
+ VERSION_STRING = 1.0
+ MODULE_TYPE = DXE_DRIVER
+ LIBRARY_CLASS = NULL|DXE_DRIVER
+ CONSTRUCTOR = AcpiWsmtLibConstructor
+ DESTRUCTOR = AcpiWsmtLibDestructor
+
+[Sources]
+ WsmtGenerator.c
+
+[Packages]
+ DynamicTablesPkg/DynamicTablesPkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ MdePkg/MdePkg.dec
+
+[LibraryClasses]
+ BaseLib
+ DebugLib
+ PcdLib
+
+[Pcd]
+ gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultCreatorId
+ gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultCreatorRevision
diff --git a/DynamicTablesPkg/Library/Acpi/AcpiWsmtLib/WsmtGenerator.c b/DynamicTablesPkg/Library/Acpi/AcpiWsmtLib/WsmtGenerator.c
new file mode 100644
index 0000000000..c102152974
--- /dev/null
+++ b/DynamicTablesPkg/Library/Acpi/AcpiWsmtLib/WsmtGenerator.c
@@ -0,0 +1,221 @@
+/** @file
+ WSMT Table Generator
+
+ Copyright (c) 2017 - 2023, Arm Limited. All rights reserved.
+ Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+ @par Reference(s):
+ - ACPI 6.5 Specification, Aug 29, 2022
+ - WSMT spec, version 1.0, April 18, 2016
+
+**/
+
+#include <AcpiTableGenerator.h>
+#include <ConfigurationManagerHelper.h>
+#include <ConfigurationManagerObject.h>
+#include <IndustryStandard/WindowsSmmSecurityMitigationTable.h>
+#include <Library/DebugLib.h>
+#include <Library/TableHelperLib.h>
+#include <Protocol/ConfigurationManagerProtocol.h>
+#include <Uefi/UefiBaseType.h>
+#include <Uefi/UefiSpec.h>
+#include <ArchNameSpaceObjects.h>
+
+/** This macro expands to a function that retrieves the
+ protection flags information for WSMT Table.
+*/
+GET_OBJECT_LIST (
+ EObjNameSpaceArch,
+ EArchObjWsmtProtectionFlags,
+ CM_ARCH_WSMT_PROTECTION_FLAGS
+ );
+
+/** The AcpiWsmt is a template EFI_ACPI_WSMT_TABLE
+ structure used for generating the WSMT Table.
+*/
+STATIC
+EFI_ACPI_WSMT_TABLE mAcpiWsmt = {
+ ACPI_HEADER (
+ EFI_ACPI_WINDOWS_SMM_SECURITY_MITIGATION_TABLE_SIGNATURE,
+ EFI_ACPI_WSMT_TABLE,
+ EFI_WSMT_TABLE_REVISION
+ ),
+ EFI_WSMT_PROTECTION_FLAGS_SYSTEM_RESOURCE_PROTECTION|EFI_WSMT_PROTECTION_FLAGS_COMM_BUFFER_NESTED_PTR_PROTECTION|EFI_WSMT_PROTECTION_FLAGS_FIXED_COMM_BUFFERS
+};
+
+/** Construct the WSMT table.
+
+ This function invokes the Configuration Manager protocol interface
+ to get the required hardware information for generating the ACPI
+ table.
+
+ If this function allocates any resources then they must be freed
+ in the FreeXXXXTableResources function.
+
+ @param [in] This Pointer to the table generator.
+ @param [in] AcpiTableInfo Pointer to the ACPI Table Info.
+ @param [in] CfgMgrProtocol Pointer to the Configuration Manager
+ Protocol Interface.
+ @param [out] Table Pointer to the constructed ACPI Table.
+
+ @retval EFI_SUCCESS Table generated successfully.
+ @retval EFI_INVALID_PARAMETER A parameter is invalid.
+ @retval EFI_NOT_FOUND The required object was not found.
+ @retval EFI_BAD_BUFFER_SIZE The size returned by the Configuration
+ Manager is less than the Object size for the
+ requested object.
+**/
+STATIC
+EFI_STATUS
+BuildWsmtTable (
+ IN CONST ACPI_TABLE_GENERATOR *CONST This,
+ IN CONST CM_STD_OBJ_ACPI_TABLE_INFO *CONST AcpiTableInfo,
+ IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol,
+ OUT EFI_ACPI_DESCRIPTION_HEADER **CONST Table
+ )
+{
+ EFI_STATUS Status;
+ CM_ARCH_WSMT_PROTECTION_FLAGS *ProtectionFlags;
+
+ ASSERT (This != NULL);
+ ASSERT (AcpiTableInfo != NULL);
+ ASSERT (CfgMgrProtocol != NULL);
+ ASSERT (Table != NULL);
+ ASSERT (AcpiTableInfo->TableGeneratorId == This->GeneratorID);
+ ASSERT (AcpiTableInfo->AcpiTableSignature == This->AcpiTableSignature);
+
+ if ((AcpiTableInfo->AcpiTableRevision < This->MinAcpiTableRevision) ||
+ (AcpiTableInfo->AcpiTableRevision > This->AcpiTableRevision))
+ {
+ DEBUG ((
+ DEBUG_ERROR,
+ "ERROR: WSMT: Requested table revision = %d, is not supported."
+ "Supported table revision: Minimum = %d, Maximum = %d\n",
+ AcpiTableInfo->AcpiTableRevision,
+ This->MinAcpiTableRevision,
+ This->AcpiTableRevision
+ ));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ *Table = NULL;
+
+ Status = AddAcpiHeader (
+ CfgMgrProtocol,
+ This,
+ (EFI_ACPI_DESCRIPTION_HEADER *)&mAcpiWsmt,
+ AcpiTableInfo,
+ sizeof (EFI_ACPI_WSMT_TABLE)
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((
+ DEBUG_ERROR,
+ "ERROR: WSMT: Failed to add ACPI header. Status = %r\n",
+ Status
+ ));
+ return Status;
+ }
+
+ Status = GetEArchObjWsmtProtectionFlags (
+ CfgMgrProtocol,
+ CM_NULL_TOKEN,
+ &ProtectionFlags,
+ NULL
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((
+ DEBUG_ERROR,
+ "ERROR: WSMT: Failed to get protection flags information." \
+ " Status = %r\n",
+ Status
+ ));
+ } else {
+ mAcpiWsmt.ProtectionFlags = ProtectionFlags->ProtectionFlags;
+ }
+
+ *Table = (EFI_ACPI_DESCRIPTION_HEADER *)&mAcpiWsmt;
+
+ return Status;
+}
+
+/** The interface for the WSMT Table Generator.
+*/
+STATIC
+CONST
+ACPI_TABLE_GENERATOR mWsmtGenerator = {
+ // Generator ID
+ CREATE_STD_ACPI_TABLE_GEN_ID (EStdAcpiTableIdWsmt),
+ // Generator Description
+ L"ACPI.STD.WSMT.GENERATOR",
+ // ACPI Table Signature
+ EFI_ACPI_WINDOWS_SMM_SECURITY_MITIGATION_TABLE_SIGNATURE,
+ // ACPI Table Revision supported by this Generator
+ EFI_WSMT_TABLE_REVISION,
+ // Minimum supported ACPI Table Revision
+ EFI_WSMT_TABLE_REVISION,
+ // Creator ID
+ FixedPcdGet32 (PcdAcpiDefaultCreatorId),
+ // Creator Revision
+ FixedPcdGet32 (PcdAcpiDefaultCreatorRevision),
+ // Build Table function
+ BuildWsmtTable,
+ // No additional resources are allocated by the generator.
+ // Hence the Free Resource function is not required.
+ NULL,
+ // Extended build function not needed
+ NULL,
+ // Extended build function not implemented by the generator.
+ // Hence extended free resource function is not required.
+ NULL
+};
+
+/** Register the Generator with the ACPI Table Factory.
+
+ @param [in] ImageHandle The handle to the image.
+ @param [in] SystemTable Pointer to the System Table.
+
+ @retval EFI_SUCCESS The Generator is registered.
+ @retval EFI_INVALID_PARAMETER A parameter is invalid.
+ @retval EFI_ALREADY_STARTED The Generator for the Table ID
+ is already registered.
+**/
+EFI_STATUS
+EFIAPI
+AcpiWsmtLibConstructor (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_STATUS Status;
+
+ Status = RegisterAcpiTableGenerator (&mWsmtGenerator);
+ DEBUG ((DEBUG_INFO, "WSMT: Register Generator. Status = %r\n", Status));
+ ASSERT_EFI_ERROR (Status);
+ return Status;
+}
+
+/** Deregister the Generator from the ACPI Table Factory.
+
+ @param [in] ImageHandle The handle to the image.
+ @param [in] SystemTable Pointer to the System Table.
+
+ @retval EFI_SUCCESS The Generator is deregistered.
+ @retval EFI_INVALID_PARAMETER A parameter is invalid.
+ @retval EFI_NOT_FOUND The Generator is not registered.
+**/
+EFI_STATUS
+EFIAPI
+AcpiWsmtLibDestructor (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_STATUS Status;
+
+ Status = DeregisterAcpiTableGenerator (&mWsmtGenerator);
+ DEBUG ((DEBUG_INFO, "WSMT: Deregister Generator. Status = %r\n", Status));
+ ASSERT_EFI_ERROR (Status);
+ return Status;
+}
--
2.34.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#115635): https://edk2.groups.io/g/devel/message/115635
Mute This Topic: https://groups.io/mt/104463462/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
next prev parent reply other threads:[~2024-02-20 6:49 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-20 6:48 [edk2-devel] [PATCH v1 0/3] DynamicTablesPkg: Adds generic FADT, HPET and WSMT table generators Abdul Lateef Attar via groups.io
2024-02-20 6:48 ` [edk2-devel] [PATCH v1 1/3] DynamicTablesPkg: Adds ACPI FADT Table generator Abdul Lateef Attar via groups.io
2024-02-27 16:02 ` PierreGondois
2024-02-20 6:48 ` [edk2-devel] [PATCH v1 2/3] DynamicTablesPkg: Adds ACPI HPET " Abdul Lateef Attar via groups.io
2024-02-27 16:02 ` PierreGondois
2024-02-28 12:53 ` Abdul Lateef Attar via groups.io
2024-02-20 6:48 ` Abdul Lateef Attar via groups.io [this message]
2024-02-27 16:02 ` [edk2-devel] [PATCH v1 3/3] DynamicTablesPkg: Adds ACPI WSMT " PierreGondois
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5048bd919b4751e9eae2ca15e8347e6fcecf3196.1708411357.git.AbdulLateef.Attar@amd.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox