* [edk2-devel] [PATCH v2 0/2] ShellPkg/AcpiView: Adds HPET and WSMT parser
@ 2024-03-08 7:22 Abdul Lateef Attar via groups.io
2024-03-08 7:22 ` [edk2-devel] [PATCH v2 1/2] ShellPkg/Acpiview: Adds HPET parser Abdul Lateef Attar via groups.io
2024-03-08 7:22 ` [edk2-devel] [PATCH v2 2/2] ShellPkg/Acpiview: Adds ACPI WSMT Table parse Abdul Lateef Attar via groups.io
0 siblings, 2 replies; 6+ messages in thread
From: Abdul Lateef Attar via groups.io @ 2024-03-08 7:22 UTC (permalink / raw)
To: devel; +Cc: Abdul Lateef Attar, Zhichao Gao, Pierre Gondois
From: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
PR : https://github.com/tianocore/edk2/pull/5449
Adds HPET and WSMT parser for acpiview.
V2 delta changes:
Addressed review comments.
Added validation functions as per the comments.
Cc: Zhichao Gao <zhichao.gao@intel.com>
Cc: Pierre Gondois <pierre.gondois@arm.com>
Abdul Lateef Attar (2):
ShellPkg/Acpiview: Adds HPET parser
ShellPkg/Acpiview: Adds ACPI WSMT Table parse
.../UefiShellAcpiViewCommandLib/AcpiParser.h | 34 +++
.../Parsers/Hpet/HpetParser.c | 222 ++++++++++++++++++
.../Parsers/Wsmt/WsmtParser.c | 147 ++++++++++++
.../UefiShellAcpiViewCommandLib.c | 2 +
.../UefiShellAcpiViewCommandLib.inf | 2 +
5 files changed, 407 insertions(+)
create mode 100644 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Hpet/HpetParser.c
create mode 100644 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Wsmt/WsmtParser.c
--
2.34.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#116488): https://edk2.groups.io/g/devel/message/116488
Mute This Topic: https://groups.io/mt/104804846/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 6+ messages in thread
* [edk2-devel] [PATCH v2 1/2] ShellPkg/Acpiview: Adds HPET parser
2024-03-08 7:22 [edk2-devel] [PATCH v2 0/2] ShellPkg/AcpiView: Adds HPET and WSMT parser Abdul Lateef Attar via groups.io
@ 2024-03-08 7:22 ` Abdul Lateef Attar via groups.io
2024-03-08 7:22 ` [edk2-devel] [PATCH v2 2/2] ShellPkg/Acpiview: Adds ACPI WSMT Table parse Abdul Lateef Attar via groups.io
1 sibling, 0 replies; 6+ messages in thread
From: Abdul Lateef Attar via groups.io @ 2024-03-08 7:22 UTC (permalink / raw)
To: devel; +Cc: Abdul Lateef Attar, Zhichao Gao, Pierre Gondois
From: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
Adds HPET parse to the UefiShellAcpiViewCommandLib library.
Cc: Zhichao Gao <zhichao.gao@intel.com>
Cc: Pierre Gondois <pierre.gondois@arm.com>
Signed-off-by: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
Reviewed-by: Pierre Gondois <pierre.gondois@arm.com>
---
.../UefiShellAcpiViewCommandLib/AcpiParser.h | 17 ++
.../Parsers/Hpet/HpetParser.c | 222 ++++++++++++++++++
.../UefiShellAcpiViewCommandLib.c | 1 +
.../UefiShellAcpiViewCommandLib.inf | 1 +
4 files changed, 241 insertions(+)
create mode 100644 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Hpet/HpetParser.c
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
index 4b4397961b..ba3364f2c2 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
@@ -730,6 +730,23 @@ ParseAcpiHmat (
IN UINT8 AcpiTableRevision
);
+/**
+ This function parses the ACPI HPET table.
+
+ @param [in] Trace If TRUE, trace the ACPI fields.
+ @param [in] Ptr Pointer to the start of the buffer.
+ @param [in] AcpiTableLength Length of the ACPI table.
+ @param [in] AcpiTableRevision Revision of the ACPI table.
+**/
+VOID
+EFIAPI
+ParseAcpiHpet (
+ IN BOOLEAN Trace,
+ IN UINT8 *Ptr,
+ IN UINT32 AcpiTableLength,
+ IN UINT8 AcpiTableRevision
+ );
+
/**
This function parses the ACPI IORT table.
When trace is enabled this function parses the IORT table and
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Hpet/HpetParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Hpet/HpetParser.c
new file mode 100644
index 0000000000..1b4c38f2af
--- /dev/null
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Hpet/HpetParser.c
@@ -0,0 +1,222 @@
+/** @file
+ HPET table parser
+
+ Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+ @par Reference(s):
+ - HPET spec, version 1.0a
+**/
+
+#include <Library/UefiLib.h>
+#include "AcpiParser.h"
+
+STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
+
+/**
+ This function prints HPET page protection flags.
+ If no format string is specified the Format must be NULL.
+
+ @param [in] Format Optional format string for tracing the data.
+ @param [in] Ptr Pointer to the start of the buffer.
+**/
+VOID
+EFIAPI
+DumpHpetPageProtectionFlag (
+ IN CONST CHAR16 *Format OPTIONAL,
+ IN UINT8 *Ptr
+ )
+{
+ if (Format != NULL) {
+ Print (Format, *(UINT8 *)Ptr);
+ return;
+ }
+
+ Print (L"0x%X ", *(UINT8 *)Ptr);
+ switch (*Ptr) {
+ case 0:
+ Print (L"(no guarantee for page protection)");
+ break;
+ case 1:
+ Print (L"(4K page protection)");
+ break;
+ case 2:
+ Print (L"(64K page protection)");
+ break;
+ default:
+ IncrementErrorCount ();
+ Print (L"(OEM Reserved)");
+ break;
+ }
+
+ return;
+}
+
+/**
+ An ACPI_PARSER array describing the ACPI HPET flags.
+**/
+STATIC CONST ACPI_PARSER DumpHpetFlagParser[] = {
+ { L"Page Protection Flag", 4, 0, NULL, DumpHpetPageProtectionFlag, NULL, NULL, NULL },
+ { L"OEM Attributes", 4, 4, L"0x%x", NULL, NULL, NULL, NULL }
+};
+
+/**
+ This function prints HPET Flags fields.
+ If no format string is specified the Format must be NULL.
+
+ @param [in] Format Optional format string for tracing the data.
+ @param [in] Ptr Pointer to the start of the buffer.
+**/
+VOID
+EFIAPI
+DumpHpetFlag (
+ IN CONST CHAR16 *Format OPTIONAL,
+ IN UINT8 *Ptr
+ )
+{
+ if (Format != NULL) {
+ Print (Format, *(UINT8 *)Ptr);
+ return;
+ }
+
+ Print (L"0x%X\n", *(UINT8 *)Ptr);
+ ParseAcpiBitFields (
+ TRUE,
+ 2,
+ NULL,
+ Ptr,
+ 4,
+ PARSER_PARAMS (DumpHpetFlagParser)
+ );
+}
+
+/**
+ This function prints HPET Counter size fields.
+ If no format string is specified the Format must be NULL.
+
+ @param [in] Format Optional format string for tracing the data.
+ @param [in] Ptr Pointer to the start of the buffer.
+**/
+VOID
+EFIAPI
+DumpCounterSize (
+ IN CONST CHAR16 *Format OPTIONAL,
+ IN UINT8 *Ptr
+ )
+{
+ if (Format != NULL) {
+ Print (Format, *(UINT32 *)Ptr);
+ return;
+ }
+
+ Print (L"0x%X ", *(UINT32 *)Ptr);
+ if (*Ptr == 0) {
+ Print (L"(Max 32-bit counter size)");
+ } else {
+ Print (L"(Max 64-bit counter size)");
+ }
+}
+
+/**
+ This function validates the flags.
+
+ @param [in] Ptr Pointer to the start of the field data.
+ @param [in] Context Pointer to context specific information e.g. this
+ could be a pointer to the ACPI table header.
+**/
+STATIC
+VOID
+EFIAPI
+ValidateHpetRevId (
+ IN UINT8 *Ptr,
+ IN VOID *Context
+ )
+{
+ if ((*(UINT8 *)Ptr) == 0) {
+ IncrementErrorCount ();
+ Print (
+ L"\nERROR: HPET Hardware Rev ID must be set."
+ );
+ }
+}
+
+/**
+ An ACPI_PARSER array describing the ACPI HPET Event Timer Block ID.
+**/
+STATIC CONST ACPI_PARSER HpetEventTimerBlockIdFlagParser[] = {
+ { L"Hardware Rev ID", 8, 0, L"0x%x", NULL, NULL, ValidateHpetRevId, NULL },
+ { L"Comparators in 1st Timer Block", 5, 8, L"0x%x", NULL, NULL, NULL, NULL },
+ { L"Counter max size", 1, 13, NULL, DumpCounterSize, NULL, NULL, NULL },
+ { L"Reserved", 1, 14, L"%d", NULL, NULL, NULL, NULL },
+ { L"LegacyReplacement IRQ Routing", 1, 15, L"%d", NULL, NULL, NULL, NULL },
+ { L"PCI Vendor ID of 1st Timer Block", 16, 16, L"0x%x", NULL, NULL, NULL, NULL }
+};
+
+/**
+ This function prints Hardware ID of HPET Event timer block.
+ If no format string is specified the Format must be NULL.
+
+ @param [in] Format Optional format string for tracing the data.
+ @param [in] Ptr Pointer to the start of the buffer.
+**/
+VOID
+EFIAPI
+DumpHpetEventTimerBlockId (
+ IN CONST CHAR16 *Format OPTIONAL,
+ IN UINT8 *Ptr
+ )
+{
+ if (Format != NULL) {
+ Print (Format, *(UINT32 *)Ptr);
+ return;
+ }
+
+ Print (L"0x%X\n", *(UINT32 *)Ptr);
+ ParseAcpiBitFields (
+ TRUE,
+ 2,
+ NULL,
+ Ptr,
+ 4,
+ PARSER_PARAMS (HpetEventTimerBlockIdFlagParser)
+ );
+}
+
+/**
+ An ACPI_PARSER array describing the ACPI HPET Table.
+**/
+STATIC CONST ACPI_PARSER HpetParser[] = {
+ PARSE_ACPI_HEADER (&AcpiHdrInfo),
+ { L"Event Timer Block ID", 4, 36, NULL, DumpHpetEventTimerBlockId, NULL, NULL, NULL },
+ { L"Base Address", 12, 40, NULL, DumpGas, NULL, NULL, NULL },
+ { L"HPET Number", 1, 52, L"0x%x", NULL, NULL, NULL, NULL },
+ { L"Minimum Clock Ticks", 2, 53, L"0x%x", NULL, NULL, NULL, NULL },
+ { L"Page Protection and OEM Attributes",1, 55, NULL, DumpHpetFlag, NULL, NULL, NULL }
+};
+
+/**
+ This function parses the ACPI HPET table.
+
+ @param [in] Trace If TRUE, trace the ACPI fields.
+ @param [in] Ptr Pointer to the start of the buffer.
+ @param [in] AcpiTableLength Length of the ACPI table.
+ @param [in] AcpiTableRevision Revision of the ACPI table.
+**/
+VOID
+EFIAPI
+ParseAcpiHpet (
+ IN BOOLEAN Trace,
+ IN UINT8 *Ptr,
+ IN UINT32 AcpiTableLength,
+ IN UINT8 AcpiTableRevision
+ )
+{
+ ParseAcpi (
+ Trace,
+ 0,
+ "HPET",
+ Ptr,
+ AcpiTableLength,
+ PARSER_PARAMS (HpetParser)
+ );
+}
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c
index bbac125bb9..9e15979ea2 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c
@@ -59,6 +59,7 @@ ACPI_TABLE_PARSER ParserList[] = {
{ EFI_ACPI_6_2_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE, ParseAcpiFadt },
{ EFI_ACPI_6_4_GENERIC_TIMER_DESCRIPTION_TABLE_SIGNATURE, ParseAcpiGtdt },
{ EFI_ACPI_6_4_HETEROGENEOUS_MEMORY_ATTRIBUTE_TABLE_SIGNATURE, ParseAcpiHmat },
+ { EFI_ACPI_6_5_HIGH_PRECISION_EVENT_TIMER_TABLE_SIGNATURE, ParseAcpiHpet },
{ EFI_ACPI_6_2_IO_REMAPPING_TABLE_SIGNATURE, ParseAcpiIort },
{ EFI_ACPI_6_2_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE, ParseAcpiMadt },
{ EFI_ACPI_6_2_PCI_EXPRESS_MEMORY_MAPPED_CONFIGURATION_SPACE_BASE_ADDRESS_DESCRIPTION_TABLE_SIGNATURE,
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf
index a38965a4bf..3338e04379 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf
@@ -38,6 +38,7 @@
Parsers/Fadt/FadtParser.c
Parsers/Gtdt/GtdtParser.c
Parsers/Hmat/HmatParser.c
+ Parsers/Hpet/HpetParser.c
Parsers/Iort/IortParser.c
Parsers/Madt/MadtParser.c
Parsers/Madt/MadtParser.h
--
2.34.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#116489): https://edk2.groups.io/g/devel/message/116489
Mute This Topic: https://groups.io/mt/104804848/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [edk2-devel] [PATCH v2 2/2] ShellPkg/Acpiview: Adds ACPI WSMT Table parse
2024-03-08 7:22 [edk2-devel] [PATCH v2 0/2] ShellPkg/AcpiView: Adds HPET and WSMT parser Abdul Lateef Attar via groups.io
2024-03-08 7:22 ` [edk2-devel] [PATCH v2 1/2] ShellPkg/Acpiview: Adds HPET parser Abdul Lateef Attar via groups.io
@ 2024-03-08 7:22 ` Abdul Lateef Attar via groups.io
2024-03-08 9:20 ` PierreGondois
1 sibling, 1 reply; 6+ messages in thread
From: Abdul Lateef Attar via groups.io @ 2024-03-08 7:22 UTC (permalink / raw)
To: devel; +Cc: Abdul Lateef Attar, Zhichao Gao, Pierre Gondois
From: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
Adds WSMT parse to the UefiShellAcpiViewCommandLib library.
Cc: Zhichao Gao <zhichao.gao@intel.com>
Cc: Pierre Gondois <pierre.gondois@arm.com>
Signed-off-by: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
Reviewed-by: Pierre Gondois <pierre.gondois@arm.com>
---
.../UefiShellAcpiViewCommandLib/AcpiParser.h | 17 ++
.../Parsers/Wsmt/WsmtParser.c | 147 ++++++++++++++++++
.../UefiShellAcpiViewCommandLib.c | 1 +
.../UefiShellAcpiViewCommandLib.inf | 1 +
4 files changed, 166 insertions(+)
create mode 100644 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Wsmt/WsmtParser.c
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
index ba3364f2c2..6468fe5d8c 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
@@ -985,6 +985,23 @@ ParseAcpiSsdt (
IN UINT8 AcpiTableRevision
);
+/**
+ This function parses the ACPI WSMT table.
+
+ @param [in] Trace If TRUE, trace the ACPI fields.
+ @param [in] Ptr Pointer to the start of the buffer.
+ @param [in] AcpiTableLength Length of the ACPI table.
+ @param [in] AcpiTableRevision Revision of the ACPI table.
+**/
+VOID
+EFIAPI
+ParseAcpiWsmt (
+ IN BOOLEAN Trace,
+ IN UINT8 *Ptr,
+ IN UINT32 AcpiTableLength,
+ IN UINT8 AcpiTableRevision
+ );
+
/**
This function parses the ACPI XSDT table
and optionally traces the ACPI table fields.
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Wsmt/WsmtParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Wsmt/WsmtParser.c
new file mode 100644
index 0000000000..3c7252b0bf
--- /dev/null
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Wsmt/WsmtParser.c
@@ -0,0 +1,147 @@
+/** @file
+ WSMT table parser
+
+ Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+ @par Reference(s):
+ - Windows SMM Security Mitigation Table spec, version 1.0
+**/
+
+#include <Library/UefiLib.h>
+#include <IndustryStandard/WindowsSmmSecurityMitigationTable.h>
+#include "AcpiParser.h"
+
+STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
+
+/**
+ This function validates the WSMT Protection flag.
+
+ @param [in] Ptr Pointer to the start of the buffer.
+ @param [in] Context Pointer to context specific information e.g. this
+ could be a pointer to the ACPI table header.
+
+**/
+STATIC
+VOID
+EFIAPI
+ValidateWsmtProtectionFlag (
+ IN UINT8 *Ptr,
+ IN VOID *Context
+ )
+{
+ UINT32 ProtectionFlag;
+
+ ProtectionFlag = *(UINT32 *)Ptr;
+
+ if ((ProtectionFlag & EFI_WSMT_PROTECTION_FLAGS_COMM_BUFFER_NESTED_PTR_PROTECTION) \
+ == EFI_WSMT_PROTECTION_FLAGS_COMM_BUFFER_NESTED_PTR_PROTECTION)
+ {
+ if ((ProtectionFlag & EFI_WSMT_PROTECTION_FLAGS_FIXED_COMM_BUFFERS) \
+ != EFI_WSMT_PROTECTION_FLAGS_FIXED_COMM_BUFFERS)
+ {
+ IncrementErrorCount ();
+ Print (L"ERROR: COMM_BUFFER_NESTED_PTR_PROTECTION is set but FIXED_COMM_BUFFERS is not set.\n");
+ }
+ }
+}
+
+/**
+ This function validates the reserved bits in the WSMT Protection flag.
+
+ @param [in] Ptr Pointer to the start of the buffer.
+ @param [in] Context Pointer to context specific information e.g. this
+ could be a pointer to the ACPI table header.
+**/
+STATIC
+VOID
+EFIAPI
+ValidateReserved (
+ IN UINT8 *Ptr,
+ IN VOID *Context
+ )
+{
+ UINT32 ProtectionFlag;
+
+ ProtectionFlag = *(UINT32 *)Ptr;
+
+ if ((ProtectionFlag & 0xFFFFFFF8) != 0) {
+ IncrementErrorCount ();
+ Print (L"ERROR: Reserved bits are not zero.\n");
+ }
+}
+
+/**
+ An ACPI_PARSER array describing the WSMT Protection flag .
+**/
+STATIC CONST ACPI_PARSER WsmtProtectionFlagParser[] = {
+ { L"FIXED_COMM_BUFFERS ", 1, 0, L"0x%x", NULL, NULL, NULL, NULL },
+ { L"COMM_BUFFER_NESTED_PTR_PROTECTION ", 1, 1, L"0x%x", NULL, NULL, NULL, NULL },
+ { L"SYSTEM_RESOURCE_PROTECTION ", 1, 2, L"0x%x", NULL, NULL, NULL, NULL },
+ { L"Reserved ", 29, 3, L"0x%x", NULL, NULL, ValidateReserved, NULL },
+};
+
+/**
+ This function prints WSMT Protection flag.
+ If no format string is specified the Format must be NULL.
+
+ @param [in] Format Optional format string for tracing the data.
+ @param [in] Ptr Pointer to the start of the buffer.
+**/
+VOID
+EFIAPI
+DumpWsmtProtectionFlag (
+ IN CONST CHAR16 *Format OPTIONAL,
+ IN UINT8 *Ptr
+ )
+{
+ if (Format != NULL) {
+ Print (Format, *(UINT32 *)Ptr);
+ return;
+ }
+
+ Print (L"0x%X\n", *(UINT32 *)Ptr);
+ ParseAcpiBitFields (
+ TRUE,
+ 2,
+ NULL,
+ Ptr,
+ 4,
+ PARSER_PARAMS (WsmtProtectionFlagParser)
+ );
+}
+
+/**
+ An ACPI_PARSER array describing the ACPI WSMT Table.
+**/
+STATIC CONST ACPI_PARSER WsmtParser[] = {
+ PARSE_ACPI_HEADER (&AcpiHdrInfo),
+ { L"Protection Flag", 4,36, NULL, DumpWsmtProtectionFlag, NULL, ValidateWsmtProtectionFlag, NULL }
+};
+
+/**
+ This function parses the ACPI WSMT table.
+
+ @param [in] Trace If TRUE, trace the ACPI fields.
+ @param [in] Ptr Pointer to the start of the buffer.
+ @param [in] AcpiTableLength Length of the ACPI table.
+ @param [in] AcpiTableRevision Revision of the ACPI table.
+**/
+VOID
+EFIAPI
+ParseAcpiWsmt (
+ IN BOOLEAN Trace,
+ IN UINT8 *Ptr,
+ IN UINT32 AcpiTableLength,
+ IN UINT8 AcpiTableRevision
+ )
+{
+ ParseAcpi (
+ Trace,
+ 0,
+ "WSMT",
+ Ptr,
+ AcpiTableLength,
+ PARSER_PARAMS (WsmtParser)
+ );
+}
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c
index 9e15979ea2..0bdf068fe0 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c
@@ -73,6 +73,7 @@ ACPI_TABLE_PARSER ParserList[] = {
{ EFI_ACPI_6_2_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE, ParseAcpiSpcr },
{ EFI_ACPI_6_2_SYSTEM_RESOURCE_AFFINITY_TABLE_SIGNATURE, ParseAcpiSrat },
{ EFI_ACPI_6_2_SECONDARY_SYSTEM_DESCRIPTION_TABLE_SIGNATURE, ParseAcpiSsdt },
+ { EFI_ACPI_6_5_WINDOWS_SMM_SECURITY_MITIGATION_TABLE_SIGNATURE, ParseAcpiWsmt },
{ EFI_ACPI_6_2_EXTENDED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE, ParseAcpiXsdt }
};
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf
index 3338e04379..e62366116c 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf
@@ -52,6 +52,7 @@
Parsers/Spcr/SpcrParser.c
Parsers/Srat/SratParser.c
Parsers/Ssdt/SsdtParser.c
+ Parsers/Wsmt/WsmtParser.c
Parsers/Xsdt/XsdtParser.c
UefiShellAcpiViewCommandLib.c
UefiShellAcpiViewCommandLib.uni
--
2.34.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#116490): https://edk2.groups.io/g/devel/message/116490
Mute This Topic: https://groups.io/mt/104804849/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [edk2-devel] [PATCH v2 2/2] ShellPkg/Acpiview: Adds ACPI WSMT Table parse
2024-03-08 7:22 ` [edk2-devel] [PATCH v2 2/2] ShellPkg/Acpiview: Adds ACPI WSMT Table parse Abdul Lateef Attar via groups.io
@ 2024-03-08 9:20 ` PierreGondois
2024-03-08 12:45 ` Abdul Lateef Attar via groups.io
0 siblings, 1 reply; 6+ messages in thread
From: PierreGondois @ 2024-03-08 9:20 UTC (permalink / raw)
To: Abdul Lateef Attar, devel; +Cc: Abdul Lateef Attar, Zhichao Gao
Hello Abdul,
On 3/8/24 08:22, Abdul Lateef Attar wrote:
> From: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
>
> Adds WSMT parse to the UefiShellAcpiViewCommandLib library.
>
> Cc: Zhichao Gao <zhichao.gao@intel.com>
> Cc: Pierre Gondois <pierre.gondois@arm.com>
> Signed-off-by: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
> Reviewed-by: Pierre Gondois <pierre.gondois@arm.com>
> ---
> .../UefiShellAcpiViewCommandLib/AcpiParser.h | 17 ++
> .../Parsers/Wsmt/WsmtParser.c | 147 ++++++++++++++++++
> .../UefiShellAcpiViewCommandLib.c | 1 +
> .../UefiShellAcpiViewCommandLib.inf | 1 +
> 4 files changed, 166 insertions(+)
> create mode 100644 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Wsmt/WsmtParser.c
>
> diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
> index ba3364f2c2..6468fe5d8c 100644
> --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
> +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
> @@ -985,6 +985,23 @@ ParseAcpiSsdt (
> IN UINT8 AcpiTableRevision
> );
>
> +/**
> + This function parses the ACPI WSMT table.
> +
> + @param [in] Trace If TRUE, trace the ACPI fields.
> + @param [in] Ptr Pointer to the start of the buffer.
> + @param [in] AcpiTableLength Length of the ACPI table.
> + @param [in] AcpiTableRevision Revision of the ACPI table.
> +**/
> +VOID
> +EFIAPI
> +ParseAcpiWsmt (
> + IN BOOLEAN Trace,
> + IN UINT8 *Ptr,
> + IN UINT32 AcpiTableLength,
> + IN UINT8 AcpiTableRevision
> + );
> +
> /**
> This function parses the ACPI XSDT table
> and optionally traces the ACPI table fields.
> diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Wsmt/WsmtParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Wsmt/WsmtParser.c
> new file mode 100644
> index 0000000000..3c7252b0bf
> --- /dev/null
> +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Wsmt/WsmtParser.c
> @@ -0,0 +1,147 @@
> +/** @file
> + WSMT table parser
> +
> + Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> + @par Reference(s):
> + - Windows SMM Security Mitigation Table spec, version 1.0
> +**/
> +
> +#include <Library/UefiLib.h>
> +#include <IndustryStandard/WindowsSmmSecurityMitigationTable.h>
> +#include "AcpiParser.h"
> +
> +STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
> +
> +/**
> + This function validates the WSMT Protection flag.
> +
> + @param [in] Ptr Pointer to the start of the buffer.
> + @param [in] Context Pointer to context specific information e.g. this
> + could be a pointer to the ACPI table header.
> +
> +**/
> +STATIC
> +VOID
> +EFIAPI
> +ValidateWsmtProtectionFlag (
> + IN UINT8 *Ptr,
> + IN VOID *Context
> + )
> +{
> + UINT32 ProtectionFlag;
> +
> + ProtectionFlag = *(UINT32 *)Ptr;
> +
> + if ((ProtectionFlag & EFI_WSMT_PROTECTION_FLAGS_COMM_BUFFER_NESTED_PTR_PROTECTION) \
> + == EFI_WSMT_PROTECTION_FLAGS_COMM_BUFFER_NESTED_PTR_PROTECTION)
> + {
> + if ((ProtectionFlag & EFI_WSMT_PROTECTION_FLAGS_FIXED_COMM_BUFFERS) \
> + != EFI_WSMT_PROTECTION_FLAGS_FIXED_COMM_BUFFERS)
> + {
> + IncrementErrorCount ();
> + Print (L"ERROR: COMM_BUFFER_NESTED_PTR_PROTECTION is set but FIXED_COMM_BUFFERS is not set.\n");
> + }
> + }
> +}
> +
> +/**
> + This function validates the reserved bits in the WSMT Protection flag.
> +
> + @param [in] Ptr Pointer to the start of the buffer.
> + @param [in] Context Pointer to context specific information e.g. this
> + could be a pointer to the ACPI table header.
> +**/
> +STATIC
> +VOID
> +EFIAPI
> +ValidateReserved (
> + IN UINT8 *Ptr,
> + IN VOID *Context
> + )
> +{
> + UINT32 ProtectionFlag;
> +
> + ProtectionFlag = *(UINT32 *)Ptr;
> +
> + if ((ProtectionFlag & 0xFFFFFFF8) != 0) {
> + IncrementErrorCount ();
> + Print (L"ERROR: Reserved bits are not zero.\n");
> + }
> +}
> +
> +/**
> + An ACPI_PARSER array describing the WSMT Protection flag .
> +**/
> +STATIC CONST ACPI_PARSER WsmtProtectionFlagParser[] = {
> + { L"FIXED_COMM_BUFFERS ", 1, 0, L"0x%x", NULL, NULL, NULL, NULL },
> + { L"COMM_BUFFER_NESTED_PTR_PROTECTION ", 1, 1, L"0x%x", NULL, NULL, NULL, NULL },
> + { L"SYSTEM_RESOURCE_PROTECTION ", 1, 2, L"0x%x", NULL, NULL, NULL, NULL },
> + { L"Reserved ", 29, 3, L"0x%x", NULL, NULL, ValidateReserved, NULL },
I think we misunderstood each other here.
We should check that if COMM_BUFFER_NESTED_PTR_PROTECTION,
then FIXED_COMM_BUFFERS is also set.
So I think we need to:
- store the value of FIXED_COMM_BUFFERS (cf. ACPI_PARSER::ItemPtr in other parsers)
- add a validate to COMM_BUFFER_NESTED_PTR_PROTECTION to check the above
I don't think it is necessary to check the reserved bits,
Regards,
Pierre
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#116496): https://edk2.groups.io/g/devel/message/116496
Mute This Topic: https://groups.io/mt/104804849/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [edk2-devel] [PATCH v2 2/2] ShellPkg/Acpiview: Adds ACPI WSMT Table parse
2024-03-08 9:20 ` PierreGondois
@ 2024-03-08 12:45 ` Abdul Lateef Attar via groups.io
2024-03-08 14:01 ` PierreGondois
0 siblings, 1 reply; 6+ messages in thread
From: Abdul Lateef Attar via groups.io @ 2024-03-08 12:45 UTC (permalink / raw)
To: devel, pierre.gondois, Abdul Lateef Attar; +Cc: Zhichao Gao
Hi Pierre,
I think the provided patch also serve the same purpose of
validating the COMM_BUFFER_NESTED_PTR_PROTECTION against FIXED_COMM_BUFFERS.
Do you want me to remove the "ValidateReserved" implementation?
Here is the sample test results.
1)
Protection Flag : 0x5
FIXED_COMM_BUFFERS : 0x1
COMM_BUFFER_NESTED_PTR_PROTECTION : 0x0
SYSTEM_RESOURCE_PROTECTION : 0x1
Reserved : 0x0
Table Statistics:
0 Error(s)
0 Warning(s)
Shell>
2)
Protection Flag : 0x6
FIXED_COMM_BUFFERS : 0x0
COMM_BUFFER_NESTED_PTR_PROTECTION : 0x1
SYSTEM_RESOURCE_PROTECTION : 0x1
Reserved : 0x0
ERROR: COMM_BUFFER_NESTED_PTR_PROTECTION is set but FIXED_COMM_BUFFERS
is not set.
Table Statistics:
1 Error(s)
0 Warning(s)
Shell>
Thanks
AbduL
On 08-03-2024 14:50, PierreGondois via groups.io wrote:
> Caution: This message originated from an External Source. Use proper
> caution when opening attachments, clicking links, or responding.
>
>
> Hello Abdul,
>
> On 3/8/24 08:22, Abdul Lateef Attar wrote:
>> From: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
>>
>> Adds WSMT parse to the UefiShellAcpiViewCommandLib library.
>>
>> Cc: Zhichao Gao <zhichao.gao@intel.com>
>> Cc: Pierre Gondois <pierre.gondois@arm.com>
>> Signed-off-by: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
>> Reviewed-by: Pierre Gondois <pierre.gondois@arm.com>
>> ---
>> .../UefiShellAcpiViewCommandLib/AcpiParser.h | 17 ++
>> .../Parsers/Wsmt/WsmtParser.c | 147 ++++++++++++++++++
>> .../UefiShellAcpiViewCommandLib.c | 1 +
>> .../UefiShellAcpiViewCommandLib.inf | 1 +
>> 4 files changed, 166 insertions(+)
>> create mode 100644
>> ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Wsmt/WsmtParser.c
>>
>> diff --git
>> a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
>> b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
>> index ba3364f2c2..6468fe5d8c 100644
>> --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
>> +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
>> @@ -985,6 +985,23 @@ ParseAcpiSsdt (
>> IN UINT8 AcpiTableRevision
>> );
>>
>> +/**
>> + This function parses the ACPI WSMT table.
>> +
>> + @param [in] Trace If TRUE, trace the ACPI fields.
>> + @param [in] Ptr Pointer to the start of the buffer.
>> + @param [in] AcpiTableLength Length of the ACPI table.
>> + @param [in] AcpiTableRevision Revision of the ACPI table.
>> +**/
>> +VOID
>> +EFIAPI
>> +ParseAcpiWsmt (
>> + IN BOOLEAN Trace,
>> + IN UINT8 *Ptr,
>> + IN UINT32 AcpiTableLength,
>> + IN UINT8 AcpiTableRevision
>> + );
>> +
>> /**
>> This function parses the ACPI XSDT table
>> and optionally traces the ACPI table fields.
>> diff --git
>> a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Wsmt/WsmtParser.c
>> b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Wsmt/WsmtParser.c
>> new file mode 100644
>> index 0000000000..3c7252b0bf
>> --- /dev/null
>> +++
>> b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Wsmt/WsmtParser.c
>> @@ -0,0 +1,147 @@
>> +/** @file
>> + WSMT table parser
>> +
>> + Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
>> + SPDX-License-Identifier: BSD-2-Clause-Patent
>> +
>> + @par Reference(s):
>> + - Windows SMM Security Mitigation Table spec, version 1.0
>> +**/
>> +
>> +#include <Library/UefiLib.h>
>> +#include <IndustryStandard/WindowsSmmSecurityMitigationTable.h>
>> +#include "AcpiParser.h"
>> +
>> +STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
>> +
>> +/**
>> + This function validates the WSMT Protection flag.
>> +
>> + @param [in] Ptr Pointer to the start of the buffer.
>> + @param [in] Context Pointer to context specific information e.g. this
>> + could be a pointer to the ACPI table header.
>> +
>> +**/
>> +STATIC
>> +VOID
>> +EFIAPI
>> +ValidateWsmtProtectionFlag (
>> + IN UINT8 *Ptr,
>> + IN VOID *Context
>> + )
>> +{
>> + UINT32 ProtectionFlag;
>> +
>> + ProtectionFlag = *(UINT32 *)Ptr;
>> +
>> + if ((ProtectionFlag &
>> EFI_WSMT_PROTECTION_FLAGS_COMM_BUFFER_NESTED_PTR_PROTECTION) \
>> + == EFI_WSMT_PROTECTION_FLAGS_COMM_BUFFER_NESTED_PTR_PROTECTION)
>> + {
>> + if ((ProtectionFlag &
>> EFI_WSMT_PROTECTION_FLAGS_FIXED_COMM_BUFFERS) \
>> + != EFI_WSMT_PROTECTION_FLAGS_FIXED_COMM_BUFFERS)
>> + {
>> + IncrementErrorCount ();
>> + Print (L"ERROR: COMM_BUFFER_NESTED_PTR_PROTECTION is set but
>> FIXED_COMM_BUFFERS is not set.\n");
>> + }
>> + }
>> +}
>> +
>> +/**
>> + This function validates the reserved bits in the WSMT Protection
>> flag.
>> +
>> + @param [in] Ptr Pointer to the start of the buffer.
>> + @param [in] Context Pointer to context specific information e.g. this
>> + could be a pointer to the ACPI table header.
>> +**/
>> +STATIC
>> +VOID
>> +EFIAPI
>> +ValidateReserved (
>> + IN UINT8 *Ptr,
>> + IN VOID *Context
>> + )
>> +{
>> + UINT32 ProtectionFlag;
>> +
>> + ProtectionFlag = *(UINT32 *)Ptr;
>> +
>> + if ((ProtectionFlag & 0xFFFFFFF8) != 0) {
>> + IncrementErrorCount ();
>> + Print (L"ERROR: Reserved bits are not zero.\n");
>> + }
>> +}
>> +
>> +/**
>> + An ACPI_PARSER array describing the WSMT Protection flag .
>> +**/
>> +STATIC CONST ACPI_PARSER WsmtProtectionFlagParser[] = {
>> + { L"FIXED_COMM_BUFFERS ", 1, 0, L"0x%x", NULL,
>> NULL, NULL, NULL },
>> + { L"COMM_BUFFER_NESTED_PTR_PROTECTION ", 1, 1, L"0x%x", NULL,
>> NULL, NULL, NULL },
>> + { L"SYSTEM_RESOURCE_PROTECTION ", 1, 2, L"0x%x", NULL,
>> NULL, NULL, NULL },
>> + { L"Reserved ", 29, 3, L"0x%x", NULL,
>> NULL, ValidateReserved, NULL },
>
> I think we misunderstood each other here.
> We should check that if COMM_BUFFER_NESTED_PTR_PROTECTION,
> then FIXED_COMM_BUFFERS is also set.
>
> So I think we need to:
> - store the value of FIXED_COMM_BUFFERS (cf. ACPI_PARSER::ItemPtr in
> other parsers)
> - add a validate to COMM_BUFFER_NESTED_PTR_PROTECTION to check the above
>
> I don't think it is necessary to check the reserved bits,
>
> Regards,
> Pierre
>
>
>
>
>
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#116505): https://edk2.groups.io/g/devel/message/116505
Mute This Topic: https://groups.io/mt/104804849/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [edk2-devel] [PATCH v2 2/2] ShellPkg/Acpiview: Adds ACPI WSMT Table parse
2024-03-08 12:45 ` Abdul Lateef Attar via groups.io
@ 2024-03-08 14:01 ` PierreGondois
0 siblings, 0 replies; 6+ messages in thread
From: PierreGondois @ 2024-03-08 14:01 UTC (permalink / raw)
To: Attar, AbdulLateef (Abdul Lateef), devel, Abdul Lateef Attar; +Cc: Zhichao Gao
Hell Abdul,
On 3/8/24 13:45, Attar, AbdulLateef (Abdul Lateef) wrote:
> Hi Pierre,
>
> I think the provided patch also serve the same purpose of
> validating the COMM_BUFFER_NESTED_PTR_PROTECTION against FIXED_COMM_BUFFERS.
Ok right,
I didn't see it was checked in ValidateWsmtProtectionFlag().
>
> Do you want me to remove the "ValidateReserved" implementation?
It should also be ok I think,
All good for me then, sorry for the noise,
Regards,
Pierre
>
> Here is the sample test results.
>
> 1)
> Protection Flag : 0x5
> FIXED_COMM_BUFFERS : 0x1
> COMM_BUFFER_NESTED_PTR_PROTECTION : 0x0
> SYSTEM_RESOURCE_PROTECTION : 0x1
> Reserved : 0x0
>
>
> Table Statistics:
> 0 Error(s)
> 0 Warning(s)
> Shell>
>
> 2)
>
> Protection Flag : 0x6
> FIXED_COMM_BUFFERS : 0x0
> COMM_BUFFER_NESTED_PTR_PROTECTION : 0x1
> SYSTEM_RESOURCE_PROTECTION : 0x1
> Reserved : 0x0
> ERROR: COMM_BUFFER_NESTED_PTR_PROTECTION is set but FIXED_COMM_BUFFERS
> is not set.
>
>
> Table Statistics:
> 1 Error(s)
> 0 Warning(s)
> Shell>
>
> Thanks
>
> AbduL
>
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#116520): https://edk2.groups.io/g/devel/message/116520
Mute This Topic: https://groups.io/mt/104804849/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-03-08 14:01 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-08 7:22 [edk2-devel] [PATCH v2 0/2] ShellPkg/AcpiView: Adds HPET and WSMT parser Abdul Lateef Attar via groups.io
2024-03-08 7:22 ` [edk2-devel] [PATCH v2 1/2] ShellPkg/Acpiview: Adds HPET parser Abdul Lateef Attar via groups.io
2024-03-08 7:22 ` [edk2-devel] [PATCH v2 2/2] ShellPkg/Acpiview: Adds ACPI WSMT Table parse Abdul Lateef Attar via groups.io
2024-03-08 9:20 ` PierreGondois
2024-03-08 12:45 ` Abdul Lateef Attar via groups.io
2024-03-08 14:01 ` PierreGondois
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox