* [edk2-devel] [PATCH v1 0/3] Adding support for verbose UEFI Table dumping to Dmem.c @ 2024-01-24 20:56 Sam Kaynor 2024-01-24 20:56 ` [edk2-devel] [PATCH v1 1/3] ShellPkg: UefiShellDebug1CommandsLib: Dumping RT Properties in Dmem.c Sam Kaynor ` (2 more replies) 0 siblings, 3 replies; 7+ messages in thread From: Sam Kaynor @ 2024-01-24 20:56 UTC (permalink / raw) To: devel Cc: stuart.yoder, Sam Kaynor, Ray Ni, Zhichao Gao, Michael D Kinney, Liming Gao, Zhiguang Liu This adds an additional option to the dmem UEFI shell command for verbose dumping of a couple of UEFI tables. The tables specified are the RT Properties Table, the Image Execution Table, and the Conformance Profiles table. Supporting objects are added in the .inf and .uni files relating to Dmem.c and an additional header file for the Conformance Profiles table was added. REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4352 Cc: Ray Ni <ray.ni@intel.com> Cc: Zhichao Gao <zhichao.gao@intel.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Cc: Zhiguang Liu <zhiguang.liu@intel.com> Signed-off-by: Sam Kaynor <Sam.Kaynor@arm.com> Sam Kaynor (3): ShellPkg: UefiShellDebug1CommandsLib: Dumping RT Properties in Dmem.c ShellPkg: UefiShellDebug1CommandsLib: Image Execution Table in Dmem.c ShellPkg: UefiShellDebug1CommandsLib: Conformance Profiles in Dmem.c MdePkg/MdePkg.dec | 7 + ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.inf | 3 + MdePkg/Include/Guid/ConformanceProfiles.h | 57 ++++ ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c | 277 ++++++++++++++++++++ ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni | 30 ++- 5 files changed, 372 insertions(+), 2 deletions(-) create mode 100644 MdePkg/Include/Guid/ConformanceProfiles.h -- 2.25.1 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [edk2-devel] [PATCH v1 1/3] ShellPkg: UefiShellDebug1CommandsLib: Dumping RT Properties in Dmem.c 2024-01-24 20:56 [edk2-devel] [PATCH v1 0/3] Adding support for verbose UEFI Table dumping to Dmem.c Sam Kaynor @ 2024-01-24 20:56 ` Sam Kaynor 2024-03-04 19:32 ` Stuart Yoder 2024-01-24 20:56 ` [edk2-devel] [PATCH v1 2/3] ShellPkg: UefiShellDebug1CommandsLib: Image Execution Table " Sam Kaynor 2024-01-24 20:56 ` [edk2-devel] [PATCH v1 3/3] ShellPkg: UefiShellDebug1CommandsLib: Conformance Profiles " Sam Kaynor 2 siblings, 1 reply; 7+ messages in thread From: Sam Kaynor @ 2024-01-24 20:56 UTC (permalink / raw) To: devel; +Cc: stuart.yoder, Sam Kaynor, Ray Ni, Zhichao Gao REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4352 Implemented the dumping of the UEFI RT Properties Table using Dmem.c Cc: Ray Ni <ray.ni@intel.com> Cc: Zhichao Gao <zhichao.gao@intel.com> Signed-off-by: Sam Kaynor <Sam.Kaynor@arm.com> --- ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c | 62 ++++++++++++++++++++ ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni | 22 ++++++- 2 files changed, 82 insertions(+), 2 deletions(-) diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c index a609971f345e..1ae7b1f3d85c 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c @@ -84,8 +84,63 @@ DisplayMmioMemory ( return (ShellStatus); } +/** + Display the RtPropertiesTable entries + + @param[in] Address The pointer to the RtPropertiesTable. +**/ +SHELL_STATUS +DisplayRtProperties ( + IN UINT64 Address + ) +{ + EFI_RT_PROPERTIES_TABLE *RtPropertiesTable; + UINT32 RtServices; + SHELL_STATUS ShellStatus; + EFI_STATUS Status; + + ShellStatus = SHELL_SUCCESS; + + if (Address != 0) { + Status = EfiGetSystemConfigurationTable (&gEfiRtPropertiesTableGuid, (VOID **)&RtPropertiesTable); + if (EFI_ERROR (Status)) { + ShellStatus = SHELL_NOT_FOUND; + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMEM_ERR_GET_FAIL), gShellDebug1HiiHandle, L"RtPropertiesTable"); + } else { + RtServices = (UINT32)RtPropertiesTable->RuntimeServicesSupported; + ShellPrintHiiEx ( + -1, + -1, + NULL, + STRING_TOKEN (STR_DMEM_RT_PROPERTIES), + gShellDebug1HiiHandle, + EFI_RT_PROPERTIES_TABLE_VERSION, + (RtServices & EFI_RT_SUPPORTED_GET_TIME) ? 1 : 0, + (RtServices & EFI_RT_SUPPORTED_SET_TIME) ? 1 : 0, + (RtServices & EFI_RT_SUPPORTED_GET_WAKEUP_TIME) ? 1 : 0, + (RtServices & EFI_RT_SUPPORTED_SET_WAKEUP_TIME) ? 1 : 0, + (RtServices & EFI_RT_SUPPORTED_GET_VARIABLE) ? 1 : 0, + (RtServices & EFI_RT_SUPPORTED_GET_NEXT_VARIABLE_NAME) ? 1 : 0, + (RtServices & EFI_RT_SUPPORTED_SET_VARIABLE) ? 1 : 0, + (RtServices & EFI_RT_SUPPORTED_SET_VIRTUAL_ADDRESS_MAP) ? 1 : 0, + (RtServices & EFI_RT_SUPPORTED_CONVERT_POINTER) ? 1 : 0, + (RtServices & EFI_RT_SUPPORTED_GET_NEXT_HIGH_MONOTONIC_COUNT) ? 1 : 0, + (RtServices & EFI_RT_SUPPORTED_RESET_SYSTEM) ? 1 : 0, + (RtServices & EFI_RT_SUPPORTED_UPDATE_CAPSULE) ? 1 : 0, + (RtServices & EFI_RT_SUPPORTED_QUERY_CAPSULE_CAPABILITIES) ? 1 : 0, + (RtServices & EFI_RT_SUPPORTED_QUERY_VARIABLE_INFO) ? 1 : 0 + ); + } + } else { + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMEM_ERR_NOT_FOUND), gShellDebug1HiiHandle, L"RtPropertiesTable"); + } + + return (ShellStatus); +} + STATIC CONST SHELL_PARAM_ITEM ParamList[] = { { L"-mmio", TypeFlag }, + { L"-verbose", TypeFlag }, { NULL, TypeMax } }; @@ -308,6 +363,13 @@ ShellCommandRunDmem ( ConformanceProfileTableAddress ); } + + if (ShellCommandLineGetFlag (Package, L"-verbose")) { + if (ShellStatus == SHELL_SUCCESS) { + ShellStatus = DisplayRtProperties (RtPropertiesTableAddress); + } + } + } else { ShellStatus = DisplayMmioMemory (Address, (UINTN)Size); } diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni index 4041f0cd483e..299b0ba44f31 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni @@ -126,8 +126,26 @@ "Memory Range Capsule %016LX\r\n" "Hii Database Export Buffer %016LX\r\n" "Conformance Profile Table %016LX\r\n" - - +#string STR_DMEM_RT_PROPERTIES #language en-US "\r\nRT Properties Table\r\n" + "----------------------------------------\r\n" + "Version 0x%01LX\r\n" + "Runtime Services Supported:\r\n" + " GET_TIME %d\r\n" + " GET_WAKEUP_TIME %d\r\n" + " SET_TIME %d\r\n" + " SET_WAKEUP_TIME %d\r\n" + " GET_VARIABLE %d\r\n" + " GET_NEXT_VARIABLE_NAME %d\r\n" + " SET_VARIABLE %d\r\n" + " SET_VIRTUAL_ADDRESS_MAP %d\r\n" + " CONVERT_POINTERS %d\r\n" + " GET_NEXT_HIGH_MONOTONIC_COUNT %d\r\n" + " RESET_SYSTEM %d\r\n" + " UPDATE_CAPSULE %d\r\n" + " QUERY_CAPSULE_CAPABILITIES %d\r\n" + " QUERY_VARIABLE_INFO %d\r\n" +#string STR_DMEM_ERR_NOT_FOUND #language en-US "\r\n%H%s%N: Table address not found.\r\n" +#string STR_DMEM_ERR_GET_FAIL #language en-US "\r\n%H%s%N: Unable to get table information.\r\n" #string STR_LOAD_PCI_ROM_RES #language en-US "Image '%B%s%N' load result: %r\r\n" #string STR_LOADPCIROM_CORRUPT #language en-US "%H%s%N: File '%B%s%N' Image %d is corrupt.\r\n" -- 2.25.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [edk2-devel] [PATCH v1 1/3] ShellPkg: UefiShellDebug1CommandsLib: Dumping RT Properties in Dmem.c 2024-01-24 20:56 ` [edk2-devel] [PATCH v1 1/3] ShellPkg: UefiShellDebug1CommandsLib: Dumping RT Properties in Dmem.c Sam Kaynor @ 2024-03-04 19:32 ` Stuart Yoder 0 siblings, 0 replies; 7+ messages in thread From: Stuart Yoder @ 2024-03-04 19:32 UTC (permalink / raw) To: Sam Kaynor, devel; +Cc: Ray Ni, Zhichao Gao Hi Sam, See inline comments... On 1/24/24 2:56 PM, Sam Kaynor wrote: > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4352 > > Implemented the dumping of the UEFI RT Properties Table using Dmem.c > > Cc: Ray Ni <ray.ni@intel.com> > Cc: Zhichao Gao <zhichao.gao@intel.com> > Signed-off-by: Sam Kaynor <Sam.Kaynor@arm.com> > --- > ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c | 62 ++++++++++++++++++++ > ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni | 22 ++++++- > 2 files changed, 82 insertions(+), 2 deletions(-) > > diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c > index a609971f345e..1ae7b1f3d85c 100644 > --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c > +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c > @@ -84,8 +84,63 @@ DisplayMmioMemory ( > return (ShellStatus); > } > > +/** > + Display the RtPropertiesTable entries > + > + @param[in] Address The pointer to the RtPropertiesTable. > +**/ > +SHELL_STATUS > +DisplayRtProperties ( > + IN UINT64 Address > + ) > +{ > + EFI_RT_PROPERTIES_TABLE *RtPropertiesTable; > + UINT32 RtServices; > + SHELL_STATUS ShellStatus; > + EFI_STATUS Status; > + > + ShellStatus = SHELL_SUCCESS; > + > + if (Address != 0) { > + Status = EfiGetSystemConfigurationTable (&gEfiRtPropertiesTableGuid, (VOID **)&RtPropertiesTable); Why do you get the table address here, when it was already passed as an argument to this function. Thanks, Stuart -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#116342): https://edk2.groups.io/g/devel/message/116342 Mute This Topic: https://groups.io/mt/103940858/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=- ^ permalink raw reply [flat|nested] 7+ messages in thread
* [edk2-devel] [PATCH v1 2/3] ShellPkg: UefiShellDebug1CommandsLib: Image Execution Table in Dmem.c 2024-01-24 20:56 [edk2-devel] [PATCH v1 0/3] Adding support for verbose UEFI Table dumping to Dmem.c Sam Kaynor 2024-01-24 20:56 ` [edk2-devel] [PATCH v1 1/3] ShellPkg: UefiShellDebug1CommandsLib: Dumping RT Properties in Dmem.c Sam Kaynor @ 2024-01-24 20:56 ` Sam Kaynor 2024-03-04 19:10 ` Stuart Yoder 2024-01-24 20:56 ` [edk2-devel] [PATCH v1 3/3] ShellPkg: UefiShellDebug1CommandsLib: Conformance Profiles " Sam Kaynor 2 siblings, 1 reply; 7+ messages in thread From: Sam Kaynor @ 2024-01-24 20:56 UTC (permalink / raw) To: devel; +Cc: stuart.yoder, Sam Kaynor, Ray Ni, Zhichao Gao REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4352 Implemented dumping of the Image Execution Table using Dmem.c Cc: Ray Ni <ray.ni@intel.com> Cc: Zhichao Gao <zhichao.gao@intel.com> Signed-off-by: Sam Kaynor <Sam.Kaynor@arm.com> --- ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c | 139 ++++++++++++++++++++ ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni | 3 + 2 files changed, 142 insertions(+) diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c index 1ae7b1f3d85c..5b0730b75268 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c @@ -138,6 +138,142 @@ DisplayRtProperties ( return (ShellStatus); } +/** + Retrieve the ImageExecutionTable Entry ImageName from Device Path + + @param[in] Address The pointer to the ImageExecutionTable. +**/ +EFI_STATUS +GetBaseName ( + IN CHAR16 *FileName, + OUT CHAR16 **BaseName + ) +{ + UINT32 StrLen; + CHAR16 *StrTail; + + StrLen = StrSize(FileName); + + for (StrTail = FileName + StrLen - 1; StrTail != FileName && *StrTail != L'\\'; StrTail--) { + } + + if (StrTail == FileName) { + return EFI_NOT_FOUND; + } + *BaseName = StrTail+1; + + return EFI_SUCCESS; +} + +/** + Retrieve the ImageExecutionTable entries + + @param[in] Address The pointer to the ImageExecutionTable. +**/ +EFI_STATUS +GetImageExecutionInfo ( + IN UINT64 Address + ) +{ + EFI_STATUS Status; + EFI_IMAGE_EXECUTION_INFO *InfoPtr; + VOID *ptr; + CHAR16 *ImagePath; + CHAR16 *ImageName; + UINTN *NumberOfImages; + CHAR16 *ActionType; + + Status = EfiGetSystemConfigurationTable (&gEfiImageSecurityDatabaseGuid, &ptr); + + NumberOfImages = ptr; + + ptr += sizeof(NumberOfImages); + + for (int Image = 0; Image < *NumberOfImages; Image++) { + InfoPtr = ptr; + ImagePath = ptr + sizeof(EFI_IMAGE_EXECUTION_INFO); + + GetBaseName(ImagePath,&ImageName); + + switch(InfoPtr->Action) { + case EFI_IMAGE_EXECUTION_AUTHENTICATION: + ActionType = L"AUTHENTICATION"; + break; + case EFI_IMAGE_EXECUTION_AUTH_UNTESTED: + ActionType = L"AUTHENTICATION UNTESTED"; + break; + case EFI_IMAGE_EXECUTION_AUTH_SIG_FAILED: + ActionType = L"AUTHENTICATION SIGNATURE FAILED"; + break; + case EFI_IMAGE_EXECUTION_AUTH_SIG_PASSED: + ActionType = L"AUTHENTICATION SIGNATURE PASSED"; + break; + case EFI_IMAGE_EXECUTION_AUTH_SIG_NOT_FOUND: + ActionType = L"AUTHENTICATION SIGNATURE NOT FOUND"; + break; + case EFI_IMAGE_EXECUTION_AUTH_SIG_FOUND: + ActionType = L"AUTHENTICATION SIGNATURE FOUND"; + break; + case EFI_IMAGE_EXECUTION_POLICY_FAILED: + ActionType = L"POILCY FAILED"; + break; + case EFI_IMAGE_EXECUTION_INITIALIZED: + ActionType = L"INITIALIZED"; + break; + default: + ActionType = L"invalid action"; + } + + ShellPrintHiiEx( + -1, + -1, + NULL, + STRING_TOKEN (STR_DMEM_IMG_EXE_ENTRY), + gShellDebug1HiiHandle, + ImageName, + ActionType + ); + + ptr += InfoPtr->InfoSize; + } + + return Status; +} + +/** + Display the ImageExecutionTable entries + + @param[in] Address The pointer to the ImageExecutionTable. +**/ +SHELL_STATUS +DisplayImageExecutionEntries ( + IN UINT64 Address + ) +{ + EFI_IMAGE_EXECUTION_INFO_TABLE *ImageExecutionTable; + SHELL_STATUS ShellStatus; + EFI_STATUS Status; + + ShellStatus = SHELL_SUCCESS; + + if (Address != 0) { + Status = EfiGetSystemConfigurationTable (&gEfiImageSecurityDatabaseGuid, (VOID **)&ImageExecutionTable); + if (EFI_ERROR (Status)) { + ShellStatus = SHELL_NOT_FOUND; + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMEM_ERR_GET_FAIL), gShellDebug1HiiHandle, L"ImageExecutionTable"); + } else { + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMEM_IMG_EXE_TABLE), gShellDebug1HiiHandle); + Status = GetImageExecutionInfo(Address); + } + } else { + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMEM_ERR_NOT_FOUND), gShellDebug1HiiHandle, L"ImageExecutionTable"); + } + + return (ShellStatus); +} + + + STATIC CONST SHELL_PARAM_ITEM ParamList[] = { { L"-mmio", TypeFlag }, { L"-verbose", TypeFlag }, @@ -368,6 +504,9 @@ ShellCommandRunDmem ( if (ShellStatus == SHELL_SUCCESS) { ShellStatus = DisplayRtProperties (RtPropertiesTableAddress); } + if (ShellStatus == SHELL_SUCCESS) { + ShellStatus = DisplayImageExecutionEntries (ImageExecutionTableAddress); + } } } else { diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni index 299b0ba44f31..eee9384e3ffb 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni @@ -144,6 +144,9 @@ " UPDATE_CAPSULE %d\r\n" " QUERY_CAPSULE_CAPABILITIES %d\r\n" " QUERY_VARIABLE_INFO %d\r\n" +#string STR_DMEM_IMG_EXE_TABLE #language en-US "\r\nImage Execution Table\r\n" + "----------------------------------------\r\n" +#string STR_DMEM_IMG_EXE_ENTRY #language en-US "%s: %s\r\n" #string STR_DMEM_ERR_NOT_FOUND #language en-US "\r\n%H%s%N: Table address not found.\r\n" #string STR_DMEM_ERR_GET_FAIL #language en-US "\r\n%H%s%N: Unable to get table information.\r\n" -- 2.25.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [edk2-devel] [PATCH v1 2/3] ShellPkg: UefiShellDebug1CommandsLib: Image Execution Table in Dmem.c 2024-01-24 20:56 ` [edk2-devel] [PATCH v1 2/3] ShellPkg: UefiShellDebug1CommandsLib: Image Execution Table " Sam Kaynor @ 2024-03-04 19:10 ` Stuart Yoder 0 siblings, 0 replies; 7+ messages in thread From: Stuart Yoder @ 2024-03-04 19:10 UTC (permalink / raw) To: Sam Kaynor, devel; +Cc: Ray Ni, Zhichao Gao Hi Sam, See inline comments... On 1/24/24 2:56 PM, Sam Kaynor wrote: > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4352 > > Implemented dumping of the Image Execution Table using Dmem.c > > Cc: Ray Ni <ray.ni@intel.com> > Cc: Zhichao Gao <zhichao.gao@intel.com> > Signed-off-by: Sam Kaynor <Sam.Kaynor@arm.com> > --- > ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c | 139 ++++++++++++++++++++ > ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni | 3 + > 2 files changed, 142 insertions(+) > > diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c > index 1ae7b1f3d85c..5b0730b75268 100644 > --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c > +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c > @@ -138,6 +138,142 @@ DisplayRtProperties ( > return (ShellStatus); > } > > +/** > + Retrieve the ImageExecutionTable Entry ImageName from Device Path > + > + @param[in] Address The pointer to the ImageExecutionTable. > +**/ > +EFI_STATUS > +GetBaseName ( > + IN CHAR16 *FileName, > + OUT CHAR16 **BaseName > + ) > +{ > + UINT32 StrLen; > + CHAR16 *StrTail; > + > + StrLen = StrSize(FileName); > + > + for (StrTail = FileName + StrLen - 1; StrTail != FileName && *StrTail != L'\\'; StrTail--) { > + } > + > + if (StrTail == FileName) { > + return EFI_NOT_FOUND; > + } > + *BaseName = StrTail+1; > + > + return EFI_SUCCESS; > +} > + > +/** > + Retrieve the ImageExecutionTable entries > + > + @param[in] Address The pointer to the ImageExecutionTable. > +**/ > +EFI_STATUS > +GetImageExecutionInfo ( > + IN UINT64 Address > + ) > +{ > + EFI_STATUS Status; > + EFI_IMAGE_EXECUTION_INFO *InfoPtr; > + VOID *ptr; > + CHAR16 *ImagePath; > + CHAR16 *ImageName; > + UINTN *NumberOfImages; > + CHAR16 *ActionType; > + > + Status = EfiGetSystemConfigurationTable (&gEfiImageSecurityDatabaseGuid, &ptr); > + > + NumberOfImages = ptr; > + > + ptr += sizeof(NumberOfImages); The arithmetic to advance to the table entries isn't super clear as written. I think you need to define a variable for the table header EFI_IMAGE_EXECUTION_INFO_TABLE and use that. The Memory Attribute Table is similar. Take a look at how they handled the pointer arithmetic here: https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Core/Dxe/Misc/MemoryAttributesTable.c#L197 > + for (int Image = 0; Image < *NumberOfImages; Image++) { > + InfoPtr = ptr; > + ImagePath = ptr + sizeof(EFI_IMAGE_EXECUTION_INFO); > + > + GetBaseName(ImagePath,&ImageName); > + > + switch(InfoPtr->Action) { > + case EFI_IMAGE_EXECUTION_AUTHENTICATION: > + ActionType = L"AUTHENTICATION"; > + break; > + case EFI_IMAGE_EXECUTION_AUTH_UNTESTED: > + ActionType = L"AUTHENTICATION UNTESTED"; > + break; > + case EFI_IMAGE_EXECUTION_AUTH_SIG_FAILED: > + ActionType = L"AUTHENTICATION SIGNATURE FAILED"; > + break; > + case EFI_IMAGE_EXECUTION_AUTH_SIG_PASSED: > + ActionType = L"AUTHENTICATION SIGNATURE PASSED"; > + break; > + case EFI_IMAGE_EXECUTION_AUTH_SIG_NOT_FOUND: > + ActionType = L"AUTHENTICATION SIGNATURE NOT FOUND"; > + break; > + case EFI_IMAGE_EXECUTION_AUTH_SIG_FOUND: > + ActionType = L"AUTHENTICATION SIGNATURE FOUND"; > + break; > + case EFI_IMAGE_EXECUTION_POLICY_FAILED: > + ActionType = L"POILCY FAILED"; > + break; > + case EFI_IMAGE_EXECUTION_INITIALIZED: > + ActionType = L"INITIALIZED"; > + break; > + default: > + ActionType = L"invalid action"; > + } > + > + ShellPrintHiiEx( > + -1, > + -1, > + NULL, > + STRING_TOKEN (STR_DMEM_IMG_EXE_ENTRY), > + gShellDebug1HiiHandle, > + ImageName, > + ActionType > + ); When running this code I noticed that the column of action type strings were not aligned. Can you set a field width to align them? > + > + ptr += InfoPtr->InfoSize; Move the above to the part of the for loop statement that increments for each iteration of the loop. > + } > + > + return Status; > +} > + > +/** > + Display the ImageExecutionTable entries > + > + @param[in] Address The pointer to the ImageExecutionTable. > +**/ > +SHELL_STATUS > +DisplayImageExecutionEntries ( > + IN UINT64 Address > + ) > +{ > + EFI_IMAGE_EXECUTION_INFO_TABLE *ImageExecutionTable; > + SHELL_STATUS ShellStatus; > + EFI_STATUS Status; > + > + ShellStatus = SHELL_SUCCESS; > + > + if (Address != 0) { > + Status = EfiGetSystemConfigurationTable (&gEfiImageSecurityDatabaseGuid, (VOID **)&ImageExecutionTable); > + if (EFI_ERROR (Status)) { > + ShellStatus = SHELL_NOT_FOUND; > + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMEM_ERR_GET_FAIL), gShellDebug1HiiHandle, L"ImageExecutionTable"); > + } else { > + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMEM_IMG_EXE_TABLE), gShellDebug1HiiHandle); > + Status = GetImageExecutionInfo(Address); > + } > + } else { > + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMEM_ERR_NOT_FOUND), gShellDebug1HiiHandle, L"ImageExecutionTable"); > + } > + > + return (ShellStatus); > +} > + > + > + > STATIC CONST SHELL_PARAM_ITEM ParamList[] = { > { L"-mmio", TypeFlag }, > { L"-verbose", TypeFlag }, > @@ -368,6 +504,9 @@ ShellCommandRunDmem ( > if (ShellStatus == SHELL_SUCCESS) { > ShellStatus = DisplayRtProperties (RtPropertiesTableAddress); > } > + if (ShellStatus == SHELL_SUCCESS) { > + ShellStatus = DisplayImageExecutionEntries (ImageExecutionTableAddress); > + } > } > > } else { > diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni > index 299b0ba44f31..eee9384e3ffb 100644 > --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni > +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni > @@ -144,6 +144,9 @@ > " UPDATE_CAPSULE %d\r\n" > " QUERY_CAPSULE_CAPABILITIES %d\r\n" > " QUERY_VARIABLE_INFO %d\r\n" > +#string STR_DMEM_IMG_EXE_TABLE #language en-US "\r\nImage Execution Table\r\n" > + "----------------------------------------\r\n" > +#string STR_DMEM_IMG_EXE_ENTRY #language en-US "%s: %s\r\n" > #string STR_DMEM_ERR_NOT_FOUND #language en-US "\r\n%H%s%N: Table address not found.\r\n" > #string STR_DMEM_ERR_GET_FAIL #language en-US "\r\n%H%s%N: Unable to get table information.\r\n" > -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#116339): https://edk2.groups.io/g/devel/message/116339 Mute This Topic: https://groups.io/mt/103940859/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=- ^ permalink raw reply [flat|nested] 7+ messages in thread
* [edk2-devel] [PATCH v1 3/3] ShellPkg: UefiShellDebug1CommandsLib: Conformance Profiles in Dmem.c 2024-01-24 20:56 [edk2-devel] [PATCH v1 0/3] Adding support for verbose UEFI Table dumping to Dmem.c Sam Kaynor 2024-01-24 20:56 ` [edk2-devel] [PATCH v1 1/3] ShellPkg: UefiShellDebug1CommandsLib: Dumping RT Properties in Dmem.c Sam Kaynor 2024-01-24 20:56 ` [edk2-devel] [PATCH v1 2/3] ShellPkg: UefiShellDebug1CommandsLib: Image Execution Table " Sam Kaynor @ 2024-01-24 20:56 ` Sam Kaynor 2024-03-04 19:31 ` Stuart Yoder 2 siblings, 1 reply; 7+ messages in thread From: Sam Kaynor @ 2024-01-24 20:56 UTC (permalink / raw) To: devel Cc: stuart.yoder, Sam Kaynor, Ray Ni, Zhichao Gao, Michael D Kinney, Liming Gao, Zhiguang Liu REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4352 Implemented dumping of the UEFI Conformance Profiles Table using Dmem.c Additionally added the base support for the table with new header file ConformanceProfiles.h (Cc'd maintainers of MdePkg for this) Cc: Ray Ni <ray.ni@intel.com> Cc: Zhichao Gao <zhichao.gao@intel.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Cc: Zhiguang Liu <zhiguang.liu@intel.com> Signed-off-by: Sam Kaynor <Sam.Kaynor@arm.com> --- MdePkg/MdePkg.dec | 7 ++ ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.inf | 3 + MdePkg/Include/Guid/ConformanceProfiles.h | 57 +++++++++++++++ ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c | 76 ++++++++++++++++++++ ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni | 5 ++ 5 files changed, 148 insertions(+) diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec index 2ee112cc087a..d22320d7bdae 100644 --- a/MdePkg/MdePkg.dec +++ b/MdePkg/MdePkg.dec @@ -740,6 +740,13 @@ [Guids] ## Include/Protocol/SerilaIo.h gEfiSerialTerminalDeviceTypeGuid = { 0x6AD9A60F, 0x5815, 0x4C7C, { 0x8A, 0x10, 0x50, 0x53, 0xD2, 0xBF, 0x7A, 0x1B }} + # GUIDs defined in UEFI 2.10 + # + ## Include/Guid/ConformanceProfiles.h + gEfiConfProfilesTableGuid = { 0x36122546, 0xf7e7, 0x4c8f, { 0xbd, 0x9b, 0xeb, 0x85, 0x25, 0xb5, 0x0c, 0x0b }} + gEfiConfProfilesUefiSpecGuid = { 0x523c91af, 0xa195, 0x4382, { 0x81, 0x8d, 0x29, 0x5f, 0xe4, 0x00, 0x64, 0x65 }} + gEfiConfProfilesEbbrSpecGuid = { 0xcce33c35, 0x74ac, 0x4087, { 0xbc, 0xe7, 0x8b, 0x29, 0xb0, 0x2e, 0xeb, 0x27 }} + # # GUID defined in PI1.0 # diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.inf b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.inf index 3741dac5d94c..172ac2862ba1 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.inf +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.inf @@ -139,3 +139,6 @@ [Guids] gEfiJsonConfigDataTableGuid ## SOMETIMES_CONSUMES ## SystemTable gEfiJsonCapsuleDataTableGuid ## SOMETIMES_CONSUMES ## SystemTable gEfiJsonCapsuleResultTableGuid ## SOMETIMES_CONSUMES ## SystemTable + gEfiConfProfilesTableGuid ## SOMETIMES_CONSUMES ## SystemTable + gEfiConfProfilesUefiSpecGuid ## SOMETIMES_CONSUMES ## GUID + gEfiConfProfilesEbbrSpecGuid ## SOMETIMES_CONSUMES ## GUID diff --git a/MdePkg/Include/Guid/ConformanceProfiles.h b/MdePkg/Include/Guid/ConformanceProfiles.h new file mode 100644 index 000000000000..88517eaaad25 --- /dev/null +++ b/MdePkg/Include/Guid/ConformanceProfiles.h @@ -0,0 +1,57 @@ +/** @file + Legal information + +**/ + +#ifndef __CONFORMANCE_PROFILES_TABLE_GUID_H__ +#define __CONFORMANCE_PROFILES_TABLE_GUID_H__ + + +// +// (This is copied straight from the 2.10 spec, to be modified) +// This table allows the platform to advertise its UEFI specification conformance +// in the form of pre-defined profiles. Each profile is identified by a GUID, with +// known profiles listed in the section below. +// The absence of this table shall indicate that the platform implementation is +// conformant with the UEFI specification requirements, as defined in Section 2.6. +// This is equivalent to publishing this configuration table with the +// EFI_CONFORMANCE_PROFILES_UEFI_SPEC_GUID conformance profile. +// +#define EFI_CONFORMANCE_PROFILES_TABLE_GUID \ + { \ + 0x36122546, 0xf7e7, 0x4c8f, { 0xbd, 0x9b, 0xeb, 0x85, 0x25, 0xb5, 0x0c, 0x0b } \ + } + +#pragma pack(1) + +typedef struct { + /// + /// Version of the table must be 0x1 + /// + UINT16 Version; + /// + /// The number of profiles GUIDs present in ConformanceProfiles + /// + UINT16 NumberOfProfiles; + /// + /// An array of conformance profile GUIDs that are supported by this system. + /// EFI_GUID ConformanceProfiles[]; + /// +} EFI_CONFORMANCE_PROFILES_TABLE; + +#define EFI_CONFORMANCE_PROFILES_TABLE_VERSION 0x1 + +// +// GUID defined in spec. +// +#define EFI_CONFORMANCE_PROFILES_UEFI_SPEC_GUID \ + { 0x523c91af, 0xa195, 0x4382, \ + { 0x81, 0x8d, 0x29, 0x5f, 0xe4, 0x00, 0x64, 0x65 }} +#define EFI_CONFORMANCE_PROFILE_EBBR_2_1_GUID \ + { 0xcce33c35, 0x74ac, 0x4087, \ + { 0xbc, 0xe7, 0x8b, 0x29, 0xb0, 0x2e, 0xeb, 0x27 }} + +extern EFI_GUID gEfiConfProfilesTableGuid; +extern EFI_GUID gEfiConfProfilesUefiSpecGuid; + +#endif diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c index 5b0730b75268..ad20ef028e99 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c @@ -19,6 +19,7 @@ #include <Guid/SystemResourceTable.h> #include <Guid/DebugImageInfoTable.h> #include <Guid/ImageAuthentication.h> +#include <Guid/ConformanceProfiles.h> /** Make a printable character. @@ -272,7 +273,74 @@ DisplayImageExecutionEntries ( return (ShellStatus); } +/** + Display the ConformanceProfileTable entries + @param[in] Address The pointer to the ConformanceProfileTable. +**/ +SHELL_STATUS +DisplayConformanceProfiles ( + IN UINT64 Address + ) +{ + SHELL_STATUS ShellStatus; + EFI_STATUS Status; + VOID *EntryPtr; + EFI_GUID *EntryGuid; + CHAR16 *GuidName; + EFI_CONFORMANCE_PROFILES_TABLE *ConfProfTable; + + ShellStatus = SHELL_SUCCESS; + + if (Address != 0) { + Status = EfiGetSystemConfigurationTable (&gEfiConfProfilesTableGuid, (VOID **)&ConfProfTable); + if (EFI_ERROR (Status)) { + ShellStatus = SHELL_NOT_FOUND; + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMEM_ERR_GET_FAIL), gShellDebug1HiiHandle, L"ConformanceProfileTable"); + } else { + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMEM_CONF_PRO_TABLE), gShellDebug1HiiHandle); + + EntryPtr = ConfProfTable; + + EntryPtr += sizeof(ConfProfTable->Version); + EntryPtr += sizeof(ConfProfTable->NumberOfProfiles); + + for (int Profile = 0; Profile < ConfProfTable->NumberOfProfiles; Profile++) { + EntryGuid = EntryPtr; + GuidName = L"Unknown_Profile"; + + if (CompareGuid (EntryGuid, &gEfiConfProfilesEbbrSpecGuid)) { + GuidName = L"EBBR_2.1"; + } + + ShellPrintHiiEx ( + -1, + -1, + NULL, + STRING_TOKEN (STR_DMEM_CONF_PRO_ROW), + gShellDebug1HiiHandle, + GuidName, + EntryGuid + ); + + EntryPtr += sizeof(EFI_GUID); + } + } + } else { + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMEM_CONF_PRO_TABLE), gShellDebug1HiiHandle); + ShellPrintHiiEx ( + -1, + -1, + NULL, + STRING_TOKEN (STR_DMEM_CONF_PRO_ROW), + gShellDebug1HiiHandle, + L"EFI_CONFORMANCE_PROFILES_UEFI_SPEC_GUID", + &gEfiConfProfilesUefiSpecGuid + ); + } + + return (ShellStatus); +} STATIC CONST SHELL_PARAM_ITEM ParamList[] = { { L"-mmio", TypeFlag }, @@ -464,6 +532,11 @@ ShellCommandRunDmem ( HiiDatabaseExportBufferAddress = (UINT64)(UINTN)gST->ConfigurationTable[TableWalker].VendorTable; continue; } + + if (CompareGuid (&gST->ConfigurationTable[TableWalker].VendorGuid, &gEfiConfProfilesTableGuid)) { + ConformanceProfileTableAddress = (UINT64)(UINTN)gST->ConfigurationTable[TableWalker].VendorTable; + continue; + } } ShellPrintHiiEx ( @@ -507,6 +580,9 @@ ShellCommandRunDmem ( if (ShellStatus == SHELL_SUCCESS) { ShellStatus = DisplayImageExecutionEntries (ImageExecutionTableAddress); } + if (ShellStatus == SHELL_SUCCESS) { + ShellStatus = DisplayConformanceProfiles(ConformanceProfileTableAddress); + } } } else { diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni index eee9384e3ffb..c99c881776b6 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni @@ -147,6 +147,11 @@ #string STR_DMEM_IMG_EXE_TABLE #language en-US "\r\nImage Execution Table\r\n" "----------------------------------------\r\n" #string STR_DMEM_IMG_EXE_ENTRY #language en-US "%s: %s\r\n" +#string STR_DMEM_CONF_PRO_TABLE #language en-US "\r\nConformance Profile Table\r\n" + "----------------------------------------\r\n" + "Version 0x1\r\n" + "Profile GUIDs:\r\n" +#string STR_DMEM_CONF_PRO_ROW #language en-US " %s %g\r\n" #string STR_DMEM_ERR_NOT_FOUND #language en-US "\r\n%H%s%N: Table address not found.\r\n" #string STR_DMEM_ERR_GET_FAIL #language en-US "\r\n%H%s%N: Unable to get table information.\r\n" -- 2.25.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [edk2-devel] [PATCH v1 3/3] ShellPkg: UefiShellDebug1CommandsLib: Conformance Profiles in Dmem.c 2024-01-24 20:56 ` [edk2-devel] [PATCH v1 3/3] ShellPkg: UefiShellDebug1CommandsLib: Conformance Profiles " Sam Kaynor @ 2024-03-04 19:31 ` Stuart Yoder 0 siblings, 0 replies; 7+ messages in thread From: Stuart Yoder @ 2024-03-04 19:31 UTC (permalink / raw) To: Sam Kaynor, devel Cc: Ray Ni, Zhichao Gao, Michael D Kinney, Liming Gao, Zhiguang Liu Hi Sam, See inline comments... On 1/24/24 2:56 PM, Sam Kaynor wrote: > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4352 > > Implemented dumping of the UEFI Conformance Profiles Table using Dmem.c > Additionally added the base support for the table with new > header file ConformanceProfiles.h (Cc'd maintainers of MdePkg for this) > > Cc: Ray Ni <ray.ni@intel.com> > Cc: Zhichao Gao <zhichao.gao@intel.com> > Cc: Michael D Kinney <michael.d.kinney@intel.com> > Cc: Liming Gao <gaoliming@byosoft.com.cn> > Cc: Zhiguang Liu <zhiguang.liu@intel.com> > Signed-off-by: Sam Kaynor <Sam.Kaynor@arm.com> > --- > MdePkg/MdePkg.dec | 7 ++ > ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.inf | 3 + > MdePkg/Include/Guid/ConformanceProfiles.h | 57 +++++++++++++++ > ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c | 76 ++++++++++++++++++++ > ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni | 5 ++ > 5 files changed, 148 insertions(+) > > diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec > index 2ee112cc087a..d22320d7bdae 100644 > --- a/MdePkg/MdePkg.dec > +++ b/MdePkg/MdePkg.dec > @@ -740,6 +740,13 @@ [Guids] > ## Include/Protocol/SerilaIo.h > gEfiSerialTerminalDeviceTypeGuid = { 0x6AD9A60F, 0x5815, 0x4C7C, { 0x8A, 0x10, 0x50, 0x53, 0xD2, 0xBF, 0x7A, 0x1B }} > > + # GUIDs defined in UEFI 2.10 > + # > + ## Include/Guid/ConformanceProfiles.h > + gEfiConfProfilesTableGuid = { 0x36122546, 0xf7e7, 0x4c8f, { 0xbd, 0x9b, 0xeb, 0x85, 0x25, 0xb5, 0x0c, 0x0b }} > + gEfiConfProfilesUefiSpecGuid = { 0x523c91af, 0xa195, 0x4382, { 0x81, 0x8d, 0x29, 0x5f, 0xe4, 0x00, 0x64, 0x65 }} > + gEfiConfProfilesEbbrSpecGuid = { 0xcce33c35, 0x74ac, 0x4087, { 0xbc, 0xe7, 0x8b, 0x29, 0xb0, 0x2e, 0xeb, 0x27 }} > + > # > # GUID defined in PI1.0 > # > diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.inf b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.inf > index 3741dac5d94c..172ac2862ba1 100644 > --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.inf > +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.inf > @@ -139,3 +139,6 @@ [Guids] > gEfiJsonConfigDataTableGuid ## SOMETIMES_CONSUMES ## SystemTable > gEfiJsonCapsuleDataTableGuid ## SOMETIMES_CONSUMES ## SystemTable > gEfiJsonCapsuleResultTableGuid ## SOMETIMES_CONSUMES ## SystemTable > + gEfiConfProfilesTableGuid ## SOMETIMES_CONSUMES ## SystemTable > + gEfiConfProfilesUefiSpecGuid ## SOMETIMES_CONSUMES ## GUID > + gEfiConfProfilesEbbrSpecGuid ## SOMETIMES_CONSUMES ## GUID > diff --git a/MdePkg/Include/Guid/ConformanceProfiles.h b/MdePkg/Include/Guid/ConformanceProfiles.h > new file mode 100644 > index 000000000000..88517eaaad25 > --- /dev/null > +++ b/MdePkg/Include/Guid/ConformanceProfiles.h > @@ -0,0 +1,57 @@ > +/** @file > + Legal information > + > +**/ > + > +#ifndef __CONFORMANCE_PROFILES_TABLE_GUID_H__ > +#define __CONFORMANCE_PROFILES_TABLE_GUID_H__ > + > + > +// > +// (This is copied straight from the 2.10 spec, to be modified) Is the "to be modified" comment supposed to be here? > +// This table allows the platform to advertise its UEFI specification conformance > +// in the form of pre-defined profiles. Each profile is identified by a GUID, with > +// known profiles listed in the section below. > +// The absence of this table shall indicate that the platform implementation is > +// conformant with the UEFI specification requirements, as defined in Section 2.6. > +// This is equivalent to publishing this configuration table with the > +// EFI_CONFORMANCE_PROFILES_UEFI_SPEC_GUID conformance profile. > +// > +#define EFI_CONFORMANCE_PROFILES_TABLE_GUID \ > + { \ > + 0x36122546, 0xf7e7, 0x4c8f, { 0xbd, 0x9b, 0xeb, 0x85, 0x25, 0xb5, 0x0c, 0x0b } \ > + } > + > +#pragma pack(1) > + > +typedef struct { > + /// > + /// Version of the table must be 0x1 > + /// > + UINT16 Version; > + /// > + /// The number of profiles GUIDs present in ConformanceProfiles > + /// > + UINT16 NumberOfProfiles; > + /// > + /// An array of conformance profile GUIDs that are supported by this system. > + /// EFI_GUID ConformanceProfiles[]; > + /// > +} EFI_CONFORMANCE_PROFILES_TABLE; > + > +#define EFI_CONFORMANCE_PROFILES_TABLE_VERSION 0x1 > + > +// > +// GUID defined in spec. > +// > +#define EFI_CONFORMANCE_PROFILES_UEFI_SPEC_GUID \ > + { 0x523c91af, 0xa195, 0x4382, \ > + { 0x81, 0x8d, 0x29, 0x5f, 0xe4, 0x00, 0x64, 0x65 }} > +#define EFI_CONFORMANCE_PROFILE_EBBR_2_1_GUID \ > + { 0xcce33c35, 0x74ac, 0x4087, \ > + { 0xbc, 0xe7, 0x8b, 0x29, 0xb0, 0x2e, 0xeb, 0x27 }} > + > +extern EFI_GUID gEfiConfProfilesTableGuid; > +extern EFI_GUID gEfiConfProfilesUefiSpecGuid; > + > +#endif > diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c > index 5b0730b75268..ad20ef028e99 100644 > --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c > +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c > @@ -19,6 +19,7 @@ > #include <Guid/SystemResourceTable.h> > #include <Guid/DebugImageInfoTable.h> > #include <Guid/ImageAuthentication.h> > +#include <Guid/ConformanceProfiles.h> > > /** > Make a printable character. > @@ -272,7 +273,74 @@ DisplayImageExecutionEntries ( > return (ShellStatus); > } > > +/** > + Display the ConformanceProfileTable entries > > + @param[in] Address The pointer to the ConformanceProfileTable. > +**/ > +SHELL_STATUS > +DisplayConformanceProfiles ( > + IN UINT64 Address > + ) > +{ > + SHELL_STATUS ShellStatus; > + EFI_STATUS Status; > + VOID *EntryPtr; > + EFI_GUID *EntryGuid; > + CHAR16 *GuidName; > + EFI_CONFORMANCE_PROFILES_TABLE *ConfProfTable; > + > + ShellStatus = SHELL_SUCCESS; > + > + if (Address != 0) { > + Status = EfiGetSystemConfigurationTable (&gEfiConfProfilesTableGuid, (VOID **)&ConfProfTable); Why do you get the table address here, when it was already passed in as a parameter to this function? > + if (EFI_ERROR (Status)) { > + ShellStatus = SHELL_NOT_FOUND; > + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMEM_ERR_GET_FAIL), gShellDebug1HiiHandle, L"ConformanceProfileTable"); > + } else { > + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMEM_CONF_PRO_TABLE), gShellDebug1HiiHandle); > + > + EntryPtr = ConfProfTable; > + > + EntryPtr += sizeof(ConfProfTable->Version); > + EntryPtr += sizeof(ConfProfTable->NumberOfProfiles); Similar to my comment on the exec info table I would suggest something like: EntryGuid = (EFI_CONFORMANCE_PROFILES_TABLE *)(ConfProfTable + 1); > + > + for (int Profile = 0; Profile < ConfProfTable->NumberOfProfiles; Profile++) { > + EntryGuid = EntryPtr; You shouldn't need EntryPtr. I think the loop works with just the EntryGuid ptr which you increment on each iteration. > + GuidName = L"Unknown_Profile"; > + > + if (CompareGuid (EntryGuid, &gEfiConfProfilesEbbrSpecGuid)) { > + GuidName = L"EBBR_2.1"; > + } > + > + ShellPrintHiiEx ( > + -1, > + -1, > + NULL, > + STRING_TOKEN (STR_DMEM_CONF_PRO_ROW), > + gShellDebug1HiiHandle, > + GuidName, > + EntryGuid > + ); > + > + EntryPtr += sizeof(EFI_GUID); Move the above to the part of the for() loop that increments on each iteration. > + } > + } > + } else { > + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMEM_CONF_PRO_TABLE), gShellDebug1HiiHandle); > + ShellPrintHiiEx ( > + -1, > + -1, > + NULL, > + STRING_TOKEN (STR_DMEM_CONF_PRO_ROW), > + gShellDebug1HiiHandle, > + L"EFI_CONFORMANCE_PROFILES_UEFI_SPEC_GUID", > + &gEfiConfProfilesUefiSpecGuid > + ); > + } > + > + return (ShellStatus); > +} > > STATIC CONST SHELL_PARAM_ITEM ParamList[] = { > { L"-mmio", TypeFlag }, > @@ -464,6 +532,11 @@ ShellCommandRunDmem ( > HiiDatabaseExportBufferAddress = (UINT64)(UINTN)gST->ConfigurationTable[TableWalker].VendorTable; > continue; > } > + > + if (CompareGuid (&gST->ConfigurationTable[TableWalker].VendorGuid, &gEfiConfProfilesTableGuid)) { > + ConformanceProfileTableAddress = (UINT64)(UINTN)gST->ConfigurationTable[TableWalker].VendorTable; > + continue; > + } > } > > ShellPrintHiiEx ( > @@ -507,6 +580,9 @@ ShellCommandRunDmem ( > if (ShellStatus == SHELL_SUCCESS) { > ShellStatus = DisplayImageExecutionEntries (ImageExecutionTableAddress); > } > + if (ShellStatus == SHELL_SUCCESS) { > + ShellStatus = DisplayConformanceProfiles(ConformanceProfileTableAddress); > + } > } > > } else { > diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni > index eee9384e3ffb..c99c881776b6 100644 > --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni > +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni > @@ -147,6 +147,11 @@ > #string STR_DMEM_IMG_EXE_TABLE #language en-US "\r\nImage Execution Table\r\n" > "----------------------------------------\r\n" > #string STR_DMEM_IMG_EXE_ENTRY #language en-US "%s: %s\r\n" > +#string STR_DMEM_CONF_PRO_TABLE #language en-US "\r\nConformance Profile Table\r\n" > + "----------------------------------------\r\n" > + "Version 0x1\r\n" > + "Profile GUIDs:\r\n" > +#string STR_DMEM_CONF_PRO_ROW #language en-US " %s %g\r\n" > #string STR_DMEM_ERR_NOT_FOUND #language en-US "\r\n%H%s%N: Table address not found.\r\n" > #string STR_DMEM_ERR_GET_FAIL #language en-US "\r\n%H%s%N: Unable to get table information.\r\n" > Thanks, Stuart -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#116341): https://edk2.groups.io/g/devel/message/116341 Mute This Topic: https://groups.io/mt/103940860/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=- ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-03-04 19:32 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-01-24 20:56 [edk2-devel] [PATCH v1 0/3] Adding support for verbose UEFI Table dumping to Dmem.c Sam Kaynor 2024-01-24 20:56 ` [edk2-devel] [PATCH v1 1/3] ShellPkg: UefiShellDebug1CommandsLib: Dumping RT Properties in Dmem.c Sam Kaynor 2024-03-04 19:32 ` Stuart Yoder 2024-01-24 20:56 ` [edk2-devel] [PATCH v1 2/3] ShellPkg: UefiShellDebug1CommandsLib: Image Execution Table " Sam Kaynor 2024-03-04 19:10 ` Stuart Yoder 2024-01-24 20:56 ` [edk2-devel] [PATCH v1 3/3] ShellPkg: UefiShellDebug1CommandsLib: Conformance Profiles " Sam Kaynor 2024-03-04 19:31 ` Stuart Yoder
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox