From 95972f966ebf4b61de8faf214809ef881f4ac129 Mon Sep 17 00:00:00 2001 From: Abdul Lateef Attar Date: Sat, 30 Nov 2024 06:40:48 +0000 Subject: [PATCH] DynamicTablesPkg: Correct parser for X64 architecture objects - Add array size to CmArchCommonSpmiInterfaceInfoParser to correctly parse the SPMI interface object. - Use the size of enum values instead of fixed sizes. - Apply #pragma pack to the X64 object structure to ensure the total size of the structure matches the parser's combined individual field sizes without padding. Cc: Sami Mujawar Cc: Pierre Gondois Signed-off-by: Abdul Lateef Attar --- DynamicTablesPkg/Include/X64NameSpaceObjects.h | 6 +++++- .../TableHelperLib/ConfigurationManagerObjectParser.c | 8 ++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/DynamicTablesPkg/Include/X64NameSpaceObjects.h b/DynamicTablesPkg/Include/X64NameSpaceObjects.h index f07d6d465549..f7bb22dc1226 100644 --- a/DynamicTablesPkg/Include/X64NameSpaceObjects.h +++ b/DynamicTablesPkg/Include/X64NameSpaceObjects.h @@ -15,7 +15,10 @@ #ifndef X64_NAMESPACE_OBJECTS_H_ #define X64_NAMESPACE_OBJECTS_H_ -#include +#include +#include + +#pragma pack(1) /** The LOCAL_APIC_MODE enum describes the Local APIC mode in the X64 Namespace @@ -262,4 +265,5 @@ typedef struct CmX64LocalApicX2ApicNmiInfo { UINT8 LocalApicLint; } CM_X64_LOCAL_APIC_X2APIC_NMI_INFO; +#pragma pack() #endif // X64_NAMESPACE_OBJECTS_H_ diff --git a/DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationManagerObjectParser.c b/DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationManagerObjectParser.c index 7721e44564f0..abb5f7dc0b8d 100755 --- a/DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationManagerObjectParser.c +++ b/DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationManagerObjectParser.c @@ -682,7 +682,7 @@ STATIC CONST CM_OBJ_PARSER CmArchCommonTpm2InterfaceInfo[] = { STATIC CONST CM_OBJ_PARSER CmArchCommonSpmiInterfaceInfoParser[] = { { "InterfaceType", sizeof (UINT8), "0x%x", NULL }, { "BaseAddress", sizeof (EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE), - NULL, NULL, AcpiGenericAddressParser } + NULL, NULL, AcpiGenericAddressParser, ARRAY_SIZE (AcpiGenericAddressParser) }, }; /** A parser for EArchCommonObjSpmiInterruptDeviceInfo. @@ -887,9 +887,9 @@ STATIC CONST CM_OBJ_PARSER CmX64ObjHpetInfoParser[] = { /** A parser for EX64ObjMadtInfo. */ STATIC CONST CM_OBJ_PARSER CmX64ObjMadtInfoParser[] = { - { "LocalApicAddress", 4, "0x%x", NULL }, - { "Flags", 4, "0x%x", NULL }, - { "ApicMode", 1, "0x%x", NULL } + { "LocalApicAddress", 4, "0x%x", NULL }, + { "Flags", 4, "0x%x", NULL }, + { "ApicMode", sizeof (LOCAL_APIC_MODE), "0x%x", NULL } }; /** A parser for CmArchCommonLocalApicX2ApicInfoParser.