From nobody Wed Oct 30 22:12:23 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+104842+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+104842+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1684117134; cv=none; d=zohomail.com; s=zohoarc; b=ETOX95cAQyGDOjRVauayMDDE7PCuOPH/nirMciXXJxHEm0gvBt3wdv5X3vkPnb9IRGif0I2hFCFNVancFWD4TyWckHEtuKn6lYlFkVm8BAO1KfaE1EaJ7p9PJhnHkQac2iWsz5+LBSty+z2GBV242rsZArAJPOYwx/RZuX4c5dM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684117134; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=v+VhotGGLneW00TBxTqPfgnNT+Y+1BLDzTLRIhQAflk=; b=kV6v4/IHBV2jhokIqNOnGUlI+fxHr+8IGeYOeoQ9de1PjUqv/C2fqpNkz+kAH844PR/GnhuYwk7E8HufPe52C/GJ57hOQxtSxLgtq7DjRL753ef+VajVeOnWuAIaXXjJyk4peBl5DXKdfeaNeic7ZLmuHa+RV+tqLfYhQVAvmF4= 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+104842+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 1684117133916717.6550106289259; Sun, 14 May 2023 19:18:53 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id IBnNYY1788612x48Sjk8WurA; Sun, 14 May 2023 19:18:49 -0700 X-Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mx.groups.io with SMTP id smtpd.web10.79852.1684116965727635794 for ; Sun, 14 May 2023 19:16:11 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10710"; a="416739593" X-IronPort-AV: E=Sophos;i="5.99,275,1677571200"; d="scan'208";a="416739593" X-Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 May 2023 19:16:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10710"; a="947260467" X-IronPort-AV: E=Sophos;i="5.99,275,1677571200"; d="scan'208";a="947260467" X-Received: from sh1gapp1009.ccr.corp.intel.com ([10.239.189.219]) by fmsmga006.fm.intel.com with ESMTP; 14 May 2023 19:16:09 -0700 From: "Wu, Jiaxin" To: devel@edk2.groups.io Cc: Dandan Bi , Liming Gao , Eric Dong , Ray Ni , Zeng Star , Gerd Hoffmann , Rahul Kumar Subject: [edk2-devel] [PATCH v3 3/5] MdeModulePkg/DxeIpl: Align Page table Level setting with previous level. Date: Mon, 15 May 2023 10:15:59 +0800 Message-Id: <20230515021601.6244-4-jiaxin.wu@intel.com> In-Reply-To: <20230515021601.6244-1-jiaxin.wu@intel.com> References: <20230515021601.6244-1-jiaxin.wu@intel.com> 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,jiaxin.wu@intel.com X-Gm-Message-State: dt90xYkuPt0YkxgFqgtd48c2x1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1684117129; bh=HSj7IkTwlFEyIO1Wa0o7UntnnGjOoJwmyGVernjqy4M=; h=Cc:Date:From:Reply-To:Subject:To; b=PiMsHXkkAx9rEDeTZUTC2KdES0mFXg8y4VyPZgpBtA1UN1rhI7FB8clnv7ckk5td8CJ iEJgBodXMC7f5x/l/ZaYWqrGz5DQBfPdD8QJ6A+CLVvYPbzTfu9IpQQ1Q8o5GWhm/+kva pPrX7CNyaaeb4oQHVH7cBmTmwOVZuCF7tGI= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1684117136044100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" System paging 5 level enabled or not can be checked via CR4.LA57, system preferred Page table Level (PcdUse5LevelPageTable) must align with previous level for 64bit long mode. This patch is to do the wise check: If cpu has already run in 64bit long mode PEI, Page table Level in DXE must align with previous level. If cpu runs in 32bit protected mode PEI, Page table Level in DXE is decided by PCD and feature capability. Cc: Dandan Bi Cc: Liming Gao Cc: Eric Dong Cc: Ray Ni Cc: Zeng Star Cc: Gerd Hoffmann Cc: Rahul Kumar Signed-off-by: Jiaxin Wu --- MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c | 36 ++++++++++++++++----= ---- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c b/MdeModulePk= g/Core/DxeIplPeim/X64/VirtualMemory.c index 18b121d768..980c2002d4 100644 --- a/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c +++ b/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c @@ -737,22 +737,34 @@ CreateIdentityMappingPageTables ( } else { PhysicalAddressBits =3D 36; } } =20 - Page5LevelSupport =3D FALSE; - if (PcdGetBool (PcdUse5LevelPageTable)) { - AsmCpuidEx ( - CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS, - CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_SUB_LEAF_INFO, - NULL, - NULL, - &EcxFlags.Uint32, - NULL - ); - if (EcxFlags.Bits.FiveLevelPage !=3D 0) { - Page5LevelSupport =3D TRUE; + if (sizeof (UINTN) =3D=3D sizeof (UINT64)) { + // + // If cpu has already run in 64bit long mode PEI, Page table Level in = DXE must align with previous level. + // + Cr4.UintN =3D AsmReadCr4 (); + Page5LevelSupport =3D (Cr4.Bits.LA57 !=3D 0); + ASSERT (PcdGetBool (PcdUse5LevelPageTable) =3D=3D Page5LevelSupport); + } else { + // + // If cpu runs in 32bit protected mode PEI, Page table Level in DXE is= decided by PCD and feature capability. + // + Page5LevelSupport =3D FALSE; + if (PcdGetBool (PcdUse5LevelPageTable)) { + AsmCpuidEx ( + CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS, + CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_SUB_LEAF_INFO, + NULL, + NULL, + &EcxFlags.Uint32, + NULL + ); + if (EcxFlags.Bits.FiveLevelPage !=3D 0) { + Page5LevelSupport =3D TRUE; + } } } =20 DEBUG ((DEBUG_INFO, "AddressBits=3D%u 5LevelPaging=3D%u 1GPage=3D%u\n", = PhysicalAddressBits, Page5LevelSupport, Page1GSupport)); =20 --=20 2.16.2.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 (#104842): https://edk2.groups.io/g/devel/message/104842 Mute This Topic: https://groups.io/mt/98895183/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-