From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.120, mailfrom: shenglei.zhang@intel.com) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by groups.io with SMTP; Sun, 11 Aug 2019 23:24:47 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Aug 2019 23:24:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,376,1559545200"; d="scan'208";a="187327787" Received: from shenglei-dev.ccr.corp.intel.com ([10.239.158.52]) by orsmga002.jf.intel.com with ESMTP; 11 Aug 2019 23:24:45 -0700 From: "Zhang, Shenglei" To: devel@edk2.groups.io Cc: Dandan Bi , Liming Gao , Hao A Wu , Laszlo Ersek , Eric Dong Subject: [PATCH 1/1] MdeModulePkg/DxeIplPeim: Relocate the operation of PageMapLevel5Entry++ Date: Mon, 12 Aug 2019 14:24:44 +0800 Message-Id: <20190812062444.14572-1-shenglei.zhang@intel.com> X-Mailer: git-send-email 2.18.0.windows.1 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 -- 2.18.0.windows.1