From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.43; helo=mga05.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id EBCF621164899 for ; Tue, 16 Oct 2018 02:15:30 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Oct 2018 02:15:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,388,1534834800"; d="scan'208";a="97834862" Received: from ray-dev.ccr.corp.intel.com (HELO [10.239.9.11]) ([10.239.9.11]) by fmsmga004.fm.intel.com with ESMTP; 16 Oct 2018 02:15:29 -0700 To: Jim.Dailey@dell.com Cc: jaben.carsey@intel.com, edk2-devel@lists.01.org References: <20181011075249.240844-1-ruiyu.ni@intel.com> <96c3fa7383b94fa0852822e25341777a@ausx13mps335.AMER.DELL.COM> From: "Ni, Ruiyu" Message-ID: <5220f931-d22d-e8b3-f465-58e97242a8f6@Intel.com> Date: Tue, 16 Oct 2018 17:16:41 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <96c3fa7383b94fa0852822e25341777a@ausx13mps335.AMER.DELL.COM> Subject: Re: [PATCH] ShellPkg/dmem: Only dump sizeof (EFI_SYSTEM_TABLE) bytes for gST X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Oct 2018 09:15:31 -0000 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit On 10/11/2018 9:05 PM, Jim.Dailey@dell.com wrote: > Is the line: > > Size = gST->Hdr.HeaderSize; > > possibly a better way of handling this? Either way: > > Reviewed-by: Jim Dailey Thanks! I will stick to use sizeof(). > > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Ruiyu Ni > Sent: Thursday, October 11, 2018 2:53 AM > To: edk2-devel@lists.01.org > Cc: Jaben Carsey > Subject: [edk2] [PATCH] ShellPkg/dmem: Only dump sizeof (EFI_SYSTEM_TABLE) bytes for gST > > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1236 > > When "dmem" runs without additional arguments, it dumps the memory > content of EFI_SYSTEM_TABLE. But today's implementation dumps 512 > bytes. It's not correct because sizeof (EFI_SYSTEM_TABLE) is less > than 512, the 512-read causes page fault exception in a heap-guard > enabled environment. > > The patch changes the implementation to only dump > sizeof (EFI_SYSTEM_TABLE) bytes for gST. > > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Ruiyu Ni > Cc: Jaben Carsey > --- > ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c > index f38593a9e9..a4c18c9b68 100644 > --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c > +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c > @@ -149,7 +149,7 @@ ShellCommandRunDmem ( > Temp1 = ShellCommandLineGetRawValue(Package, 1); > if (Temp1 == NULL) { > Address = gST; > - Size = 512; > + Size = sizeof (*gST); > } else { > if (!ShellIsHexOrDecimalNumber(Temp1, TRUE, FALSE) || EFI_ERROR(ShellConvertStringToUint64(Temp1, (UINT64*)&Address, TRUE, FALSE))) { > ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"dmem", Temp1); > -- Thanks, Ray