diff options
author | Sam Kaynor <Sam.Kaynor@arm.com> | 2024-01-10 12:48:17 -0600 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2024-07-10 06:13:07 +0000 |
commit | f46b5b06c69dcd0a7997b416789617e5d33ae18a (patch) | |
tree | 6abd535949b271614d1e00a9c4050985184b87e6 /ShellPkg | |
parent | 749065300a42d86e55074f461feed23533a77ab3 (diff) | |
download | edk2-f46b5b06c69dcd0a7997b416789617e5d33ae18a.tar.gz edk2-f46b5b06c69dcd0a7997b416789617e5d33ae18a.tar.bz2 edk2-f46b5b06c69dcd0a7997b416789617e5d33ae18a.zip |
ShellPkg: UefiShellDebug1CommandsLib: Image Execution Table in Dmem.c
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>
Tested-by: Stuart Yoder <stuart.yoder@arm.com>
Reviewed-by: Stuart Yoder <stuart.yoder@arm.com>
Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
Diffstat (limited to 'ShellPkg')
-rw-r--r-- | ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c | 136 | ||||
-rw-r--r-- | ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni | 3 |
2 files changed, 139 insertions, 0 deletions
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c index d4030798f3..80c779a0b3 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c @@ -139,6 +139,138 @@ DisplayRtProperties ( return (ShellStatus);
}
+/**
+ Retrieve the ImageExecutionTable Entry ImageName from ImagePath
+
+ @param[in] FileName The full path of the image.
+ @param[out] BaseName The name of the image.
+**/
+EFI_STATUS
+GetBaseName (
+ IN CHAR16 *FileName,
+ OUT CHAR16 **BaseName
+ )
+{
+ UINTN 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.
+**/
+EFI_STATUS
+GetImageExecutionInfo (
+ )
+{
+ EFI_STATUS Status;
+ EFI_IMAGE_EXECUTION_INFO_TABLE *ExecInfoTablePtr;
+ EFI_IMAGE_EXECUTION_INFO *InfoPtr;
+ CHAR8 *ptr;
+ CHAR16 *ImagePath;
+ CHAR16 *ImageName;
+ UINTN Image;
+ UINTN *NumberOfImages;
+ CHAR16 *ActionType;
+
+ EfiGetSystemConfigurationTable (&gEfiImageSecurityDatabaseGuid, (VOID **)&ExecInfoTablePtr);
+
+ NumberOfImages = &ExecInfoTablePtr->NumberOfImages;
+
+ ptr = (CHAR8 *)ExecInfoTablePtr + 1;
+
+ for (Image = 0; Image < *NumberOfImages; Image++, ptr += InfoPtr->InfoSize) {
+ InfoPtr = (EFI_IMAGE_EXECUTION_INFO *)ptr;
+ ImagePath = (CHAR16 *)(InfoPtr + 1);
+
+ GetBaseName (ImagePath, &ImageName);
+
+ switch (InfoPtr->Action) {
+ case EFI_IMAGE_EXECUTION_AUTHENTICATION:
+ ActionType = L"AUTHENTICATION";
+ break;
+ case EFI_IMAGE_EXECUTION_AUTH_UNTESTED:
+ ActionType = L"AUTH_UNTESTED";
+ break;
+ case EFI_IMAGE_EXECUTION_AUTH_SIG_FAILED:
+ ActionType = L"AUTH_SIG_FAILED";
+ break;
+ case EFI_IMAGE_EXECUTION_AUTH_SIG_PASSED:
+ ActionType = L"AUTH_SIG_PASSED";
+ break;
+ case EFI_IMAGE_EXECUTION_AUTH_SIG_NOT_FOUND:
+ ActionType = L"AUTH_SIG_NOT_FOUND";
+ break;
+ case EFI_IMAGE_EXECUTION_AUTH_SIG_FOUND:
+ ActionType = L"AUTH_SIG_FOUND";
+ break;
+ case EFI_IMAGE_EXECUTION_POLICY_FAILED:
+ ActionType = L"POLICY_FAILED";
+ break;
+ case EFI_IMAGE_EXECUTION_INITIALIZED:
+ ActionType = L"INITIALIZED";
+ break;
+ default:
+ ActionType = L"invalid action";
+ }
+
+ Status = ShellPrintHiiEx (
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_DMEM_IMG_EXE_ENTRY),
+ gShellDebug1HiiHandle,
+ ImageName,
+ ActionType
+ );
+ }
+
+ return Status;
+}
+
+/**
+ Display the ImageExecutionTable entries
+
+ @param[in] Address The pointer to the ImageExecutionTable.
+**/
+SHELL_STATUS
+DisplayImageExecutionEntries (
+ IN UINT64 Address
+ )
+{
+ SHELL_STATUS ShellStatus;
+ EFI_STATUS Status;
+
+ ShellStatus = SHELL_SUCCESS;
+
+ if (Address != 0) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMEM_IMG_EXE_TABLE), gShellDebug1HiiHandle);
+ Status = GetImageExecutionInfo ();
+ if (EFI_ERROR (Status)) {
+ ShellStatus = SHELL_ABORTED;
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMEM_ERR_GET_FAIL), gShellDebug1HiiHandle, L"ImageExecutionTable");
+ }
+ } 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 },
@@ -369,6 +501,10 @@ ShellCommandRunDmem ( if (ShellStatus == SHELL_SUCCESS) {
ShellStatus = DisplayRtProperties (RtPropertiesTableAddress);
}
+
+ if (ShellStatus == SHELL_SUCCESS) {
+ ShellStatus = DisplayImageExecutionEntries (ImageExecutionTableAddress);
+ }
}
} else {
ShellStatus = DisplayMmioMemory (Address, (UINTN)Size);
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni index a2241614f1..3b730164dd 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 "%20s: %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"
|