From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mx.groups.io with SMTP id smtpd.web12.2539.1660109672243652742 for ; Tue, 09 Aug 2022 22:34:38 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=Ui+GuG1G; spf=pass (domain: intel.com, ip: 192.55.52.115, mailfrom: dun.tan@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1660109678; x=1691645678; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qQXKwfM/9cqzptiZbrGlD+u2NHgaVgAsm0N4zh00xOg=; b=Ui+GuG1GVacfRrEkgB3xVbcDmbsPsTlXB04OGU65G3Sd0s7UI9dmmRpf VaP2YSQ0sM1HMcdvCXVKDNNwmQWLcp1/6cbsv0l2fHd8/2i//tBFEnGZ0 jTh+1aZsVIog7iGY/na4NVJn5KK01jN1nvBp3Xq/JGLPFT1bxI+t3yCPc czX1vPRF/NqNRd+Sxr+MvCqUQxhl4fgXodYLeTPJFuZYnL9nt9ZQT4d/Z QOPmX6it3rzIdH3vmtaMbAXqe7WirveLaD0x/L3W/rsi56yHEU6lPPODd nQzup+aY2CDcQCDGDoHUPXpspX0gs4/L2nHm1evmP+p0bbkLRvmbtV2Ua A==; X-IronPort-AV: E=McAfee;i="6400,9594,10434"; a="291002920" X-IronPort-AV: E=Sophos;i="5.93,226,1654585200"; d="scan'208";a="291002920" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Aug 2022 22:34:38 -0700 X-IronPort-AV: E=Sophos;i="5.93,226,1654585200"; d="scan'208";a="581093874" Received: from duntan-mobl.ccr.corp.intel.com ([10.239.157.47]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Aug 2022 22:34:36 -0700 From: "duntan" To: devel@edk2.groups.io Cc: Guo Dong , Ray Ni , Maurice Ma , Benjamin You , Sean Rhodes Subject: [Patch V2 2/2] UefiPayloadPkg: Remove clearing CR0.WP when protecting pagetable Date: Wed, 10 Aug 2022 13:34:00 +0800 Message-Id: <20220810053400.317-3-dun.tan@intel.com> X-Mailer: git-send-email 2.31.1.windows.1 In-Reply-To: <20220810053400.317-1-dun.tan@intel.com> References: <20220810053400.317-1-dun.tan@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Remove clearing CR0.WP when marking the memory used for page table as read-only in the page table itself created by UefiPayloadEntry. This page table address is written to Cr3 after these protection steps. Till this, the memory used for page table is always RW. Signed-off-by: Dun Tan Cc: Guo Dong Cc: Ray Ni Cc: Maurice Ma Cc: Benjamin You Cc: Sean Rhodes --- UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c b/UefiPayloadPkg/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 ( } // - // Disable write protection, because we need to mark page table to be write - // 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. // -- 2.31.1.windows.1