From nobody Tue May 7 23:14:13 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1513305539581645.6503014878253; Thu, 14 Dec 2017 18:38:59 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 8E54A2216D8D4; Thu, 14 Dec 2017 18:34:16 -0800 (PST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (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 183AE2216D8CF for ; Thu, 14 Dec 2017 18:34:15 -0800 (PST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Dec 2017 18:38:56 -0800 Received: from jwang36-mobl2.ccr.corp.intel.com ([10.239.192.42]) by fmsmga002.fm.intel.com with ESMTP; 14 Dec 2017 18:38:55 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Permerror (SPF Permanent Error: More than 10 MX records returned) identity=mailfrom; client-ip=134.134.136.24; helo=mga09.intel.com; envelope-from=jian.j.wang@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,402,1508828400"; d="scan'208";a="1792609" From: Jian J Wang To: edk2-devel@lists.01.org Date: Fri, 15 Dec 2017 10:38:38 +0800 Message-Id: <20171215023838.9400-1-jian.j.wang@intel.com> X-Mailer: git-send-email 2.15.1.windows.2 Subject: [edk2] [PATCH] MdeModulePkg/DxeIplPeim: fix incorrect page table split during protecting X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ruiyu Ni , Eric Dong , Star Zeng MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The root cause of this issue is that, during splitting page table, the page size should be the value of next level (smaller one) instead of current lev= el. The wrong page size will then cause wrong page table introduced, which will break the normal boot. Validation works include booting to Windows 10 and Fedora 26 on real Intel platform and OVMF emulated platform in addition to manual checks on page table with JTAG tool. Cc: Ruiyu Ni Cc: Star Zeng Cc: Eric Dong Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jian J Wang Reviewed-by: Star Zeng --- MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c b/MdeModulePk= g/Core/DxeIplPeim/X64/VirtualMemory.c index 26116e420c..bbdfa2bb8e 100644 --- a/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c +++ b/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c @@ -472,6 +472,8 @@ SetPageTablePoolReadOnly ( // // The smaller granularity of page must be needed. // + ASSERT (Level > 1); + NewPageTable =3D AllocatePageTableMemory (1); ASSERT (NewPageTable !=3D NULL); =20 @@ -481,10 +483,10 @@ SetPageTablePoolReadOnly ( ++EntryIndex) { NewPageTable[EntryIndex] =3D PhysicalAddress | AddressEncMask | IA32_PG_P | IA32_PG_RW; - if (Level > 1) { + if (Level > 2) { NewPageTable[EntryIndex] |=3D IA32_PG_PS; } - PhysicalAddress +=3D LevelSize[Level]; + PhysicalAddress +=3D LevelSize[Level - 1]; } =20 PageTable[Index] =3D (UINT64)(UINTN)NewPageTable | AddressEncMask | --=20 2.14.1.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel