From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: redhat.com, ip: 209.132.183.28, mailfrom: lersek@redhat.com) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by groups.io with SMTP; Tue, 13 Aug 2019 05:26:23 -0700 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1C6BE30832DC; Tue, 13 Aug 2019 12:26:23 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-117-193.ams2.redhat.com [10.36.117.193]) by smtp.corp.redhat.com (Postfix) with ESMTP id AC6D31C7; Tue, 13 Aug 2019 12:26:21 +0000 (UTC) Subject: Re: [edk2-devel] [PATCH 1/1] MdeModulePkg/DxeIplPeim: Relocate the operation of PageMapLevel5Entry++ To: devel@edk2.groups.io, shenglei.zhang@intel.com Cc: Dandan Bi , Liming Gao , Hao A Wu , Eric Dong References: <20190812062444.14572-1-shenglei.zhang@intel.com> From: "Laszlo Ersek" Message-ID: <088ace1c-568d-ccd5-fd74-1a7e93ba92d2@redhat.com> Date: Tue, 13 Aug 2019 14:26:20 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20190812062444.14572-1-shenglei.zhang@intel.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Tue, 13 Aug 2019 12:26:23 +0000 (UTC) Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 08/12/19 08:24, Zhang, Shenglei wrote: > PageMapLevel5Entry may be uninitialized in original code, which means > uninitialized pointer will be modified at some circumstance. > So relocate the operation of PageMapLevel5Entry++ in order to make sure > the pointer could be modified only when it is uninitialized. > > Cc: Dandan Bi > Cc: Liming Gao > Cc: Hao A Wu > Cc: Laszlo Ersek > Cc: Eric Dong > Signed-off-by: Shenglei Zhang > --- > MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c b/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c > index b40b7e0c9813..2389f3eb485b 100644 > --- a/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c > +++ b/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c > @@ -764,7 +764,7 @@ CreateIdentityMappingPageTables ( > > for ( IndexOfPml5Entries = 0 > ; IndexOfPml5Entries < NumberOfPml5EntriesNeeded > - ; IndexOfPml5Entries++, PageMapLevel5Entry++) { > + ; IndexOfPml5Entries++) { > // > // Each PML5 entry points to a page of PML4 entires. > // So lets allocate space for them and fill them in in the IndexOfPml4Entries loop. > @@ -780,6 +780,7 @@ CreateIdentityMappingPageTables ( > PageMapLevel5Entry->Uint64 = (UINT64) (UINTN) PageMapLevel4Entry | AddressEncMask; > PageMapLevel5Entry->Bits.ReadWrite = 1; > PageMapLevel5Entry->Bits.Present = 1; > + PageMapLevel5Entry++; > } > > for ( IndexOfPml4Entries = 0 > I'm commenting for a second time here because the underlying bug seems to break the building of OVMF: [edk2-devel] ovmf build fail with gcc 4.8.5 When you commit the patch, please add the following to the commit message: Fixes: b3527dedc3951f061c5a73cb4fb2b0f95f47e08b (Because the invalid access was apparently introduced in that commit. I did regression-test b3527dedc395, but I didn't get the warning.) Thanks Laszlo