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:35 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=Rp0biyhv; 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=1660109675; x=1691645675; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OZkTLDuWd+nFinWhk5YRwFJhvWoZn3TpiXEyTn3bbVQ=; b=Rp0biyhvLF0kjX4ajyfk/nfO/GOxAnV84vOSSsaI7huGlPmLc1qQ7hy0 wsdF4t3jFopAL/KYxXKvSURZ+EL2piVANJXB0Mfw/ogkiBM7sVnSrNyWD EUMGTJaJkfzkWn9oBuR+EK+uctUumyeBJzNBsRx4DK0/qiHOpVgSbmzuS zJw8/cZO+tqP7DXzHhAw4RAl+ABnsbl/IEy6lhn6slyzbgwKPBmsuYQSZ boy1ESxExIQm4xImLY202iByvFZ+YemdQLffTINsUgiALIjcRuoopugta s/jz4Sc6SjwPOZZFpj9Rlw0XEfGB32ZPq8ovrm+hmrFkMJPAZV3oxItJR A==; X-IronPort-AV: E=McAfee;i="6400,9594,10434"; a="291002902" X-IronPort-AV: E=Sophos;i="5.93,226,1654585200"; d="scan'208";a="291002902" 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:34 -0700 X-IronPort-AV: E=Sophos;i="5.93,226,1654585200"; d="scan'208";a="581093829" 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:33 -0700 From: "duntan" To: devel@edk2.groups.io Cc: Dandan Bi , Liming Gao , Ray Ni Subject: [Patch V2 1/2] MdeModulePkg/DxeIpl: Remove clearing CR0.WP when protecting pagetable Date: Wed, 10 Aug 2022 13:33:59 +0800 Message-Id: <20220810053400.317-2-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 DxeIpl. 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: Dandan Bi Cc: Liming Gao Cc: Ray Ni --- MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c b/MdeModulePkg/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 ( } // - // 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