From nobody Wed May 8 19:27:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+92266+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+92266+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1660094703; cv=none; d=zohomail.com; s=zohoarc; b=oEjdBQ7VQL70Y8c7LUSsv1SNrncHza3Lhg7tkuyUEOHyB/ps0haELIFh7zbNfbpGlg3spM46BAEDXjyjybjwKrlCWRGrhrHkqvtNUJGDubbMpGBoVFsDIUlXbYlPYwOm6Gf7B+FwN435yY0ns9MV7avYYBWUeWQ1Y6G5IUtVFOk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660094703; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=FwpOR5zR6XEth2tb4M3UMa/MaEthn1/WSTfysRgFD4U=; b=n3YA9Eju8rX4BmQDFTCLZtvoD1B0TcfJLK1pme5GoFVWUMTOjJQ4LtYMv1Ycpgne8EsIOX9eATxf01y7awYhA4A5ecll4lNEdvWvUqiMDvI8d7Kb6hA/5PROiPQhMxyC7tn6d/gmXT1WmqDK2Kp/eZPwAh5i6Nu61WhQtWlkm7A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+92266+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1660094703280719.929744661048; Tue, 9 Aug 2022 18:25:03 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id q6caYY1788612xHiwXdQJJcj; Tue, 09 Aug 2022 18:25:02 -0700 X-Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mx.groups.io with SMTP id smtpd.web10.827.1660094701706544740 for ; Tue, 09 Aug 2022 18:25:02 -0700 X-IronPort-AV: E=McAfee;i="6400,9594,10434"; a="271356121" X-IronPort-AV: E=Sophos;i="5.93,225,1654585200"; d="scan'208";a="271356121" X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Aug 2022 18:25:01 -0700 X-IronPort-AV: E=Sophos;i="5.93,225,1654585200"; d="scan'208";a="664673427" X-Received: from duntan-mobl.ccr.corp.intel.com ([10.239.157.47]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Aug 2022 18:25:00 -0700 From: "duntan" To: devel@edk2.groups.io Cc: Dandan Bi , Liming Gao , Ray Ni Subject: [edk2-devel] [PATCH] MdeModulePkg/DxeIpl: Remove clearing CR0.WP when protecting pagetable Date: Wed, 10 Aug 2022 09:24:47 +0800 Message-Id: <20220810012447.1425-1-dun.tan@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,dun.tan@intel.com X-Gm-Message-State: xWymcTfa6cvZZSJHe1peh7qix1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1660094702; bh=b+p/E9EQPs1z5HMHJyh7HGRBNaGfTTc8KH7YNStFkuo=; h=Cc:Date:From:Reply-To:Subject:To; b=vi932G1VO2oBOLIVLvqus0VJCs4YI/b0Vr0JS7SQmYSqyJOP90MTSE8IpQZhFxBFZsM uwcNHt62RWfw9xns2DTLpIzcW13Iy4nkY0dzO0Fw5xdpTdiYIyDHlzQ4HaSTtk2P5pOu0 ND/mEUKYRLeLPAHpLCAy2Cl0ype6y8o1Afk= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1660094703588100001 Content-Type: text/plain; charset="utf-8" Remove clearing CR0.WP when marking the memory used for page table to be read-only in the page table itself created by DxeIpl or UefiPayloadEntry/UniversalPayloadEntry. This page table address is written to Cr3 after these protection steps. Till this, the page table is always RW. Change-Id: Ibd65fb68ddfa3ea2931004d2d27b6023f457ab46 Signed-off-by: Dun Tan Cc: Dandan Bi Cc: Liming Gao Cc: Ray Ni --- MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c | 7 +------ UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c | 7 +------ 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c b/MdeModulePk= g/Core/DxeIplPeim/X64/VirtualMemory.c index a451ca1604..18b121d768 100644 --- a/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c +++ b/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c @@ -626,12 +626,7 @@ EnablePageTableProtection ( } =20 // - // Disable write protection, because we need to mark page table to be wr= ite - // protected. - // - AsmWriteCr0 (AsmReadCr0 () & ~CR0_WP); - - // + // No need to clear CR0.WP since PageTableBase has't been written to CR3= yet. // SetPageTablePoolReadOnly might update mPageTablePool. It's safer to // remember original one in advance. // diff --git a/UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c b/UefiPayl= oadPkg/UefiPayloadEntry/X64/VirtualMemory.c index 74b667a62a..a586941352 100644 --- a/UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c +++ b/UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c @@ -622,12 +622,7 @@ EnablePageTableProtection ( } =20 // - // Disable write protection, because we need to mark page table to be wr= ite - // protected. - // - AsmWriteCr0 (AsmReadCr0 () & ~CR0_WP); - - // + // No need to clear CR0.WP since PageTableBase has't been written to CR3= yet. // SetPageTablePoolReadOnly might update mPageTablePool. It's safer to // remember original one in advance. // --=20 2.31.1.windows.1 -=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 (#92266): https://edk2.groups.io/g/devel/message/92266 Mute This Topic: https://groups.io/mt/92928669/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-