From nobody Sun Feb 8 22:49:55 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+44116+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+44116+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1563783388; cv=none; d=zoho.com; s=zohoarc; b=aNqgfhCNIrChVvJJCc6BSk97Y4u7XrSyKgYeB8DdStpSVr267WONyWAsURBwjPYijxN2Be7gHq7uUp6o/y/iXQ3EzqMd7axZLBgW/rT+4py9Rqer4mdZu14GeFEekP6JMxd7fofk9vunrgw6nTCH3WGv+4aCvsEjwOHX5FImQvg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563783388; 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=xuPlTLPlCWlObA4BlBLviIm9XyqoD0IvS0++XGplIGg=; b=ckHaJ1CXIsLjcJea/k93Zkkfqns2NGKlcRxPGdo9dTYnPrWiQQEpIFvBz3HcfhKSU3QT6pmU/JFnrGfH3wVTPQym4ovmsuGW2sxlyqK0VzpIIXFRMx8t62bubKdxsW+KCEuc1GHk5hG+j7FLDfZjoNs0ZyttGey5OSQ/dOO9Z2g= 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+44116+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 156378338837045.185238910724024; Mon, 22 Jul 2019 01:16:28 -0700 (PDT) Return-Path: X-Received: from mga12.intel.com (mga12.intel.com []) by groups.io with SMTP; Mon, 22 Jul 2019 01:16:27 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Jul 2019 01:16:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,294,1559545200"; d="scan'208";a="252831297" X-Received: from ray-dev.ccr.corp.intel.com ([10.239.9.16]) by orsmga001.jf.intel.com with ESMTP; 22 Jul 2019 01:16:26 -0700 From: "Ni, Ray" To: devel@edk2.groups.io Cc: Eric Dong , Laszlo Ersek Subject: [edk2-devel] [PATCH 2/4] UefiCpuPkg/CpuDxe: Support parsing 5-level page table Date: Mon, 22 Jul 2019 16:15:45 +0800 Message-Id: <20190722081547.56100-3-ray.ni@intel.com> In-Reply-To: <20190722081547.56100-1-ray.ni@intel.com> References: <20190722081547.56100-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=1563783387; bh=jnJwQoAhIJCqwX2iHP0uHopxfeX5WZT9bpCwVhjH1zo=; h=Cc:Date:From:Reply-To:Subject:To; b=FnJtW1ePuNOMw3go9Lp/dWRFczkCkpnd1A4JDBw/0QwzevnxeC2C+fHsHpYQqhyFSoh uNLxfQ4JGTpEVZKXLDdpjqpMOQiwuZtbvSJmfuHN2t46u5QFFFGAhPPI5jbyb8+A2H1eh k2Qn9oEbxYKHUIEV9nn9FrrpMaHWBn7Xofg= 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 | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/UefiCpuPkg/CpuDxe/CpuPageTable.c b/UefiCpuPkg/CpuDxe/CpuPageTa= ble.c index c369b44f12..8e959eb2b7 100644 --- a/UefiCpuPkg/CpuDxe/CpuPageTable.c +++ b/UefiCpuPkg/CpuDxe/CpuPageTable.c @@ -1,7 +1,7 @@ /** @file Page table management support. =20 - Copyright (c) 2017, Intel Corporation. All rights reserved.
+ Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.
Copyright (c) 2017, AMD Incorporated. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent @@ -276,25 +276,43 @@ GetPageTableEntry ( UINTN Index2; UINTN Index3; UINTN Index4; + UINTN Index5; UINT64 *L1PageTable; UINT64 *L2PageTable; UINT64 *L3PageTable; UINT64 *L4PageTable; + UINT64 *L5PageTable; UINT64 AddressEncMask; + IA32_CR4 Cr4; + BOOLEAN Enable5LevelPaging; =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; Index1 =3D ((UINTN)Address >> 12) & PAGING_PAE_INDEX_MASK; =20 + Cr4.UintN =3D AsmReadCr4 (); + Enable5LevelPaging =3D (BOOLEAN) (Cr4.Bits.LA57 =3D=3D 1); + // Make sure AddressEncMask is contained to smallest supported address f= ield. // 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 (Enable5LevelPaging) { + 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; --=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 (#44116): https://edk2.groups.io/g/devel/message/44116 Mute This Topic: https://groups.io/mt/32556533/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-