From nobody Mon Feb 9 09:22:30 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+44306+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+44306+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1563962471; cv=none; d=zoho.com; s=zohoarc; b=XLhFIehBlICHJhuRlv0OiovKE83kYFmwkxOCYVN+b+EGxnRed3wigkhWE7cdo5e1KnPkw3pEfSS6xUMFtRi6CuhZi3p2zpVItkNFjckYdUKHbkrMjqFv8Qf69wg0Wjest3NpsLf9ffNuNut7VoD1uSdn/9OYqheW6bliOL+vO1c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563962471; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=wOLnYG93erLzqVJ0GsHzeKH+glp7as8O33W47BeSzbM=; b=HmqECZjcZeXmWNYadwZ2Ut8vQMay/FhZwQo+SIuRE1H28/RT0ksSxrWLSBaKIYALy4S+jUPaaJT3JypPpFjFSxnsBNzQDJZFTrqCwTc4CnDuok6APAKiuwZ1vKqZBuDOqzIOJoWtpmLjGVbZ4YC/OgkfApSP+/B5A4cgTcyKv88= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+44306+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1563962471004378.92894426486384; Wed, 24 Jul 2019 03:01:11 -0700 (PDT) Return-Path: X-Received: from mga03.intel.com (mga03.intel.com []) by groups.io with SMTP; Wed, 24 Jul 2019 03:01:10 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Jul 2019 03:01:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,302,1559545200"; d="scan'208";a="369239979" X-Received: from ray-dev.ccr.corp.intel.com ([10.239.9.16]) by fmsmga006.fm.intel.com with ESMTP; 24 Jul 2019 03:01:09 -0700 From: "Ni, Ray" To: devel@edk2.groups.io Cc: Eric Dong , Laszlo Ersek Subject: [edk2-devel] [PATCH V2 3/6] UefiCpuPkg/CpuDxe: Support parsing 5-level page table Date: Wed, 24 Jul 2019 18:00:26 +0800 Message-Id: <20190724100029.252404-4-ray.ni@intel.com> In-Reply-To: <20190724100029.252404-1-ray.ni@intel.com> References: <20190724100029.252404-1-ray.ni@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,ray.ni@intel.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1563962470; bh=zLm+fhAiYPLc/roQuMB8SgGtqp+r9wvgZEwjl00vPQ8=; h=Cc:Date:From:Reply-To:Subject:To; b=CJv4D0a0+FK0sL2Hwft6aban1qr2r0ngTi5kiAwtDSZeaYb8nO5ZkOYlZFh8SCogSuv 2XF4YYjqk1af9ogv/FumUsAilGLfsa2ZbO6MjANDpvcgOk58aRoT4zF3f4sLfQZ+wXU1X y111OT659vF6t/DCPA+4cwb8QEvizpXEu6Y= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2008 Signed-off-by: Ray Ni Cc: Eric Dong Cc: Laszlo Ersek --- UefiCpuPkg/CpuDxe/CpuPageTable.c | 18 +++++++++++++++++- UefiCpuPkg/CpuDxe/CpuPageTable.h | 3 ++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/UefiCpuPkg/CpuDxe/CpuPageTable.c b/UefiCpuPkg/CpuDxe/CpuPageTa= ble.c index 16a2528b55..36ce90d66c 100644 --- a/UefiCpuPkg/CpuDxe/CpuPageTable.c +++ b/UefiCpuPkg/CpuDxe/CpuPageTable.c @@ -184,6 +184,9 @@ GetCurrentPagingContext ( if (Cr4.Bits.PAE !=3D 0) { mPagingContext.ContextData.Ia32.Attributes |=3D PAGE_TABLE_LIB_PAGIN= G_CONTEXT_IA32_X64_ATTRIBUTES_PAE; } + if (Cr4.Bits.LA57 !=3D 0) { + mPagingContext.ContextData.Ia32.Attributes |=3D PAGE_TABLE_LIB_PAGIN= G_CONTEXT_IA32_X64_ATTRIBUTES_5_LEVEL; + } =20 AsmCpuid (CPUID_EXTENDED_FUNCTION, &RegEax, NULL, NULL, NULL); if (RegEax >=3D CPUID_EXTENDED_CPU_SIG) { @@ -273,14 +276,17 @@ GetPageTableEntry ( UINTN Index2; UINTN Index3; UINTN Index4; + UINTN Index5; UINT64 *L1PageTable; UINT64 *L2PageTable; UINT64 *L3PageTable; UINT64 *L4PageTable; + UINT64 *L5PageTable; UINT64 AddressEncMask; =20 ASSERT (PagingContext !=3D NULL); =20 + Index5 =3D ((UINTN)RShiftU64 (Address, 48)) & PAGING_PAE_INDEX_MASK; Index4 =3D ((UINTN)RShiftU64 (Address, 39)) & PAGING_PAE_INDEX_MASK; Index3 =3D ((UINTN)Address >> 30) & PAGING_PAE_INDEX_MASK; Index2 =3D ((UINTN)Address >> 21) & PAGING_PAE_INDEX_MASK; @@ -291,7 +297,17 @@ GetPageTableEntry ( AddressEncMask =3D PcdGet64 (PcdPteMemoryEncryptionAddressOrMask) & PAGI= NG_1G_ADDRESS_MASK_64; =20 if (PagingContext->MachineType =3D=3D IMAGE_FILE_MACHINE_X64) { - L4PageTable =3D (UINT64 *)(UINTN)PagingContext->ContextData.X64.PageTa= bleBase; + if ((PagingContext->ContextData.X64.Attributes & PAGE_TABLE_LIB_PAGING= _CONTEXT_IA32_X64_ATTRIBUTES_5_LEVEL) !=3D 0) { + L5PageTable =3D (UINT64 *)(UINTN)PagingContext->ContextData.X64.Page= TableBase; + if (L5PageTable[Index5] =3D=3D 0) { + *PageAttribute =3D PageNone; + return NULL; + } + + L4PageTable =3D (UINT64 *)(UINTN)(L5PageTable[Index5] & ~AddressEncM= ask & PAGING_4K_ADDRESS_MASK_64); + } else { + L4PageTable =3D (UINT64 *)(UINTN)PagingContext->ContextData.X64.Page= TableBase; + } if (L4PageTable[Index4] =3D=3D 0) { *PageAttribute =3D PageNone; return NULL; diff --git a/UefiCpuPkg/CpuDxe/CpuPageTable.h b/UefiCpuPkg/CpuDxe/CpuPageTa= ble.h index 02d62f2b14..f845956f73 100644 --- a/UefiCpuPkg/CpuDxe/CpuPageTable.h +++ b/UefiCpuPkg/CpuDxe/CpuPageTable.h @@ -1,7 +1,7 @@ /** @file Page table management header file. =20 - Copyright (c) 2017, Intel Corporation. All rights reserved.
+ Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -14,6 +14,7 @@ #define PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_PSE = BIT0 #define PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_PAE = BIT1 #define PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_PAGE_1G_SUPPORT = BIT2 +#define PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_5_LEVEL = BIT3 #define PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_WP_ENABLE = BIT30 #define PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_XD_ACTIVATED = BIT31 // Other bits are reserved for future use --=20 2.21.0.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 (#44306): https://edk2.groups.io/g/devel/message/44306 Mute This Topic: https://groups.io/mt/32582437/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-