From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 5C504740035 for ; Thu, 4 Apr 2024 21:26:54 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=2Baq/bntOkWNtUASiiVZ2GGciHR5aJZa0gJQaPYeOtY=; c=relaxed/simple; d=groups.io; h=Message-ID:Date:MIME-Version:User-Agent:Subject:To:Cc:References:From:In-Reply-To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20240206; t=1712266012; v=1; b=gzC0Axn362KOZDqWuVTs3d25lUIWD6zGVyl3NJF2E+hjE+sGdMB7QotRfL68j+nRoeFhQ225 aMCPsvuzn3gwXzzf8ZRxq0uB8FDbHoV8MXEnvk8470aRENnbu39LGhx5KKsX+Fx3Dv+bhOJ38z/ l3/vgFtjhwy7ytpVuWAQAyuALp35NXHd1ajeaxsdNU4SPTy9iO6qfcDwEdEIAz/kUUuI76FptGV 2iAEEnONshqE/e0ycqgaLV0B5cj0iAt51IPyyD7Fce1b4S71uPYP73MS2wrhC0ROR+FTGvGEC9f esmHyXVtGO7G+bRBqm2RpyHCf1dip8IjsQJeyuSGoCBfg== X-Received: by 127.0.0.2 with SMTP id xjl9YY7687511xqlf8qtg7B9; Thu, 04 Apr 2024 14:26:52 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.4400.1712266012285356141 for ; Thu, 04 Apr 2024 14:26:52 -0700 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9A5A6FEC; Thu, 4 Apr 2024 14:27:22 -0700 (PDT) X-Received: from [10.118.105.166] (C02F85CGML7H.austin.arm.com [10.118.105.166]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CF46C3F7C5; Thu, 4 Apr 2024 14:26:51 -0700 (PDT) Message-ID: <8c9f415a-1e9b-4661-80d3-6ac468a52f66@arm.com> Date: Thu, 4 Apr 2024 16:26:51 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [edk2-devel] [PATCH v4 2/3] ShellPkg: UefiShellDebug1CommandsLib: Image Execution Table in Dmem.c To: devel@edk2.groups.io, sam.kaynor@arm.com Cc: Ray Ni , Zhichao Gao References: <20240403211933.1662236-1-Sam.Kaynor@arm.com> <20240403211933.1662236-3-Sam.Kaynor@arm.com> From: "Stuart Yoder" In-Reply-To: <20240403211933.1662236-3-Sam.Kaynor@arm.com> Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Resent-Date: Thu, 04 Apr 2024 14:26:52 -0700 Resent-From: stuart.yoder@arm.com Reply-To: devel@edk2.groups.io,stuart.yoder@arm.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: s8MKQfJFelIdPya3VEUnBURnx7686176AA= Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=gzC0Axn3; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=arm.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io Reviewed-by: Stuart Yoder On 4/3/24 4:19 PM, Sam Kaynor via groups.io wrote: > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4352 >=20 > Implemented dumping of the Image Execution Table using Dmem.c >=20 > Cc: Ray Ni > Cc: Zhichao Gao > Signed-off-by: Sam Kaynor > --- >=20 > Notes: > v4: > - changed Image Execution output to match spec > v3: > - fixed build erros > - added setwidth formatting to output > - properly using Address variable >=20 > ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c = | 134 ++++++++++++++++++++ > ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.= uni | 3 + > 2 files changed, 137 insertions(+) >=20 > diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c b/ShellPk= g/Library/UefiShellDebug1CommandsLib/Dmem.c > index 52a0630f1cdc..813759a9055d 100644 > --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c > +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c > @@ -139,6 +139,137 @@ DisplayRtProperties ( > return (ShellStatus); > } > =20 > +/** > + 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 =3D StrSize(FileName); > + > + for (StrTail =3D FileName + StrLen - 1; StrTail !=3D FileName && *StrT= ail !=3D L'\\'; StrTail--) { > + } > + > + if (StrTail =3D=3D FileName) { > + return EFI_NOT_FOUND; > + } > + *BaseName =3D 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_TABLE *ExecInfoTablePtr; > + EFI_IMAGE_EXECUTION_INFO *InfoPtr; > + VOID *ptr; > + CHAR16 *ImagePath; > + CHAR16 *ImageName; > + UINTN *NumberOfImages; > + CHAR16 *ActionType; > + > + ExecInfoTablePtr =3D (EFI_IMAGE_EXECUTION_INFO_TABLE *)Address; > + > + NumberOfImages =3D &ExecInfoTablePtr->NumberOfImages; > + > + ptr =3D (VOID *)(ExecInfoTablePtr + 1); > + > + for (int Image =3D 0; Image < *NumberOfImages; Image++, ptr +=3D InfoP= tr->InfoSize) { > + InfoPtr =3D ptr; > + ImagePath =3D (CHAR16*)(InfoPtr + 1); > + > + GetBaseName(ImagePath,&ImageName); > + > + switch(InfoPtr->Action) { > + case EFI_IMAGE_EXECUTION_AUTHENTICATION: > + ActionType =3D L"AUTHENTICATION"; > + break; > + case EFI_IMAGE_EXECUTION_AUTH_UNTESTED: > + ActionType =3D L"AUTH_UNTESTED"; > + break; > + case EFI_IMAGE_EXECUTION_AUTH_SIG_FAILED: > + ActionType =3D L"AUTH_SIG_FAILED"; > + break; > + case EFI_IMAGE_EXECUTION_AUTH_SIG_PASSED: > + ActionType =3D L"AUTH_SIG_PASSED"; > + break; > + case EFI_IMAGE_EXECUTION_AUTH_SIG_NOT_FOUND: > + ActionType =3D L"AUTH_SIG_NOT_FOUND"; > + break; > + case EFI_IMAGE_EXECUTION_AUTH_SIG_FOUND: > + ActionType =3D L"AUTH_SIG_FOUND"; > + break; > + case EFI_IMAGE_EXECUTION_POLICY_FAILED: > + ActionType =3D L"POLICY_FAILED"; > + break; > + case EFI_IMAGE_EXECUTION_INITIALIZED: > + ActionType =3D L"INITIALIZED"; > + break; > + default: > + ActionType =3D L"invalid action"; > + } > + > + Status =3D 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 =3D SHELL_SUCCESS; > + > + if (Address !=3D 0) { > + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMEM_IMG_EXE_TABLE)= , gShellDebug1HiiHandle); > + Status =3D GetImageExecutionInfo(Address); > + if (EFI_ERROR (Status)) { > + ShellStatus =3D 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[] =3D { > { L"-mmio", TypeFlag }, > { L"-verbose", TypeFlag }, > @@ -369,6 +500,9 @@ ShellCommandRunDmem ( > if (ShellStatus =3D=3D SHELL_SUCCESS) { > ShellStatus =3D DisplayRtProperties (RtPropertiesTableAddre= ss); > } > + if (ShellStatus =3D=3D SHELL_SUCCESS) { > + ShellStatus =3D DisplayImageExecutionEntries (ImageExecution= TableAddress); > + } > } > =20 > } else { > diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1C= ommandsLib.uni b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug= 1CommandsLib.uni > index a2241614f109..3b730164ddce 100644 > --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1Commands= Lib.uni > +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1Commands= Lib.uni > @@ -144,6 +144,9 @@ > " UPDATE_CAPSULE = %d\r\n" > " QUERY_CAPSULE_CAPA= BILITIES %d\r\n" > " QUERY_VARIABLE_INF= O %d\r\n" > +#string STR_DMEM_IMG_EXE_TABLE #language en-US "\r\nImage Execution T= able\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 ad= dress not found.\r\n" > #string STR_DMEM_ERR_GET_FAIL #language en-US "\r\n%H%s%N: Unable t= o get table information.\r\n" > =20 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#117445): https://edk2.groups.io/g/devel/message/117445 Mute This Topic: https://groups.io/mt/105318208/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-