From nobody Sun Dec 22 11:11:42 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+104834+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+104834+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1684115377; cv=none; d=zohomail.com; s=zohoarc; b=MA+FnVndlN2qZtWu49Ytlot8FeNQ0+E8UErwNXlOly+8uDSR5pzCM7QOVf1w2pgX4Ox1pGwwuB2uZhr8ujU0iaTmqXgu8daAI2nIxH4ttqEKyjsmR7APkYVYGsY19UUjSL8jkW8Y0NAfQx+XXyWaZorssUK5Y83urxpJU38yyTU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684115377; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=HqvRotv65ebM/cv+ke5pMUHn3IEv+kvZJKw+tffi1as=; b=BWB0Dt+UNvheUuE2YGY7JQz+UAiFiIUlrJhaQZDAzM3bQ+qViXQCif4dqlmgTA7GsqZES/WJm1JGrStt/MKJ5ZNvF3w1pvkTYOaApGRclQ0zKoBoBdDefrAl9XPhk62HNj4HglLgGMHjGhOKVdr+3lIEo+e8idiOEmLiOPqoGm0= 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+104834+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 1684115377516878.1749019105446; Sun, 14 May 2023 18:49:37 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id NFMKYY1788612xF6jN0EuTGA; Sun, 14 May 2023 18:49:35 -0700 X-Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mx.groups.io with SMTP id smtpd.web11.79068.1684114925302985385 for ; Sun, 14 May 2023 18:42:10 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10710"; a="331457228" X-IronPort-AV: E=Sophos;i="5.99,275,1677571200"; d="scan'208";a="331457228" X-Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 May 2023 18:42:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10710"; a="824987080" X-IronPort-AV: E=Sophos;i="5.99,275,1677571200"; d="scan'208";a="824987080" X-Received: from shwdesfp01.ccr.corp.intel.com ([10.239.158.151]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 May 2023 18:42:07 -0700 From: "Zhiguang Liu" To: devel@edk2.groups.io Cc: "Liu, Zhiguang" , Eric Dong , Ray Ni , Rahul Kumar , Gerd Hoffmann , Debkumar De , Catharine West , Zhiguang Liu Subject: [edk2-devel] [PATCH v6 3/5] UefiCpuPkg/ResetVector: Combine PageTables1G.asm and PageTables2M.asm Date: Mon, 15 May 2023 09:41:36 +0800 Message-Id: <20230515014138.1321-4-zhiguang.liu@intel.com> In-Reply-To: <20230515014138.1321-1-zhiguang.liu@intel.com> References: <20230515014138.1321-1-zhiguang.liu@intel.com> MIME-Version: 1.0 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,zhiguang.liu@intel.com X-Gm-Message-State: 4q4ICJAydPMpgX9H4Xznk3N5x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1684115375; bh=3pc0gcJ1JGvA51Hp/Wdv549Vlc2odoLPWrGxmc1RvhY=; h=Cc:Date:From:Reply-To:Subject:To; b=NkVv3I7oSM8XeQ1PR0of3ABiMKruxfsJJaCmW3Wls95TSpN7Wd+OYD8Xz925eQMQjAd m8dPDYf4j6ayhnR49N91REKmxr+nXi0a+IAtTl96S9BGmFKEiEMhRdXruJdhk3fpytsJP Tsx0l4rdICR4i2dvmai/O0J8qSG3faKDFf8= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1684115378250100005 Content-Type: text/plain; charset="utf-8" From: "Liu, Zhiguang" Combine PageTables1G.asm and PageTables2M.asm to reuse code. Cc: Eric Dong Reviewed-by: Ray Ni Cc: Rahul Kumar Tested-by: Gerd Hoffmann Acked-by: Gerd Hoffmann Cc: Debkumar De Cc: Catharine West Signed-off-by: Zhiguang Liu --- UefiCpuPkg/ResetVector/Vtf0/Vtf0.nasmb | 8 +-- .../X64/{PageTables1G.asm =3D> PageTables.asm} | 38 ++++++++--- .../ResetVector/Vtf0/X64/PageTables2M.asm | 63 ------------------- 3 files changed, 33 insertions(+), 76 deletions(-) rename UefiCpuPkg/ResetVector/Vtf0/X64/{PageTables1G.asm =3D> PageTables.a= sm} (57%) delete mode 100644 UefiCpuPkg/ResetVector/Vtf0/X64/PageTables2M.asm diff --git a/UefiCpuPkg/ResetVector/Vtf0/Vtf0.nasmb b/UefiCpuPkg/ResetVecto= r/Vtf0/Vtf0.nasmb index bdea1fb875..136361e62c 100644 --- a/UefiCpuPkg/ResetVector/Vtf0/Vtf0.nasmb +++ b/UefiCpuPkg/ResetVector/Vtf0/Vtf0.nasmb @@ -2,7 +2,7 @@ ; @file ; This file includes all other code files to assemble the reset vector code ; -; Copyright (c) 2008 - 2013, Intel Corporation. All rights reserved.
+; Copyright (c) 2008 - 2023, Intel Corporation. All rights reserved.
; SPDX-License-Identifier: BSD-2-Clause-Patent ; ;-------------------------------------------------------------------------= ----- @@ -38,11 +38,7 @@ %include "PageTables.inc" =20 %ifdef ARCH_X64 - %ifdef PAGE_TABLE_1G - %include "X64/PageTables1G.asm" - %else - %include "X64/PageTables2M.asm" - %endif + %include "X64/PageTables.asm" %endif =20 %ifdef DEBUG_PORT80 diff --git a/UefiCpuPkg/ResetVector/Vtf0/X64/PageTables1G.asm b/UefiCpuPkg/= ResetVector/Vtf0/X64/PageTables.asm similarity index 57% rename from UefiCpuPkg/ResetVector/Vtf0/X64/PageTables1G.asm rename to UefiCpuPkg/ResetVector/Vtf0/X64/PageTables.asm index f5b8da0015..9b492b063f 100644 --- a/UefiCpuPkg/ResetVector/Vtf0/X64/PageTables1G.asm +++ b/UefiCpuPkg/ResetVector/Vtf0/X64/PageTables.asm @@ -1,10 +1,11 @@ ;-------------------------------------------------------------------------= ----- ; @file -; Emits Page Tables for 1:1 mapping of the addresses 0 - 0x8000000000 (512= GB) +; Emits Page Tables for 1:1 mapping. +; If using 1G page table, map addresses 0 - 0x8000000000 (512GB), +; else, map addresses 0 - 0x100000000 (4GB) ; ; Copyright (c) 2021 - 2023, Intel Corporation. All rights reserved.
; SPDX-License-Identifier: BSD-2-Clause-Patent -; Linear-Address Translation to a 1-GByte Page ; ;-------------------------------------------------------------------------= ----- =20 @@ -36,6 +37,7 @@ BITS 64 PAGE_NLE_ATTR) =20 %define PAGE_PDPTE_1GB(x) ((x << 30) + PAGE_BLE_ATTR) +%define PAGE_PDE_2MB(x) ((x << 21) + PAGE_BLE_ATTR) =20 ALIGN 16 =20 @@ -46,14 +48,36 @@ Pml4: DQ PAGE_NLE(Pdp) TIMES 0x1000 - ($ - Pml4) DB 0 =20 +%ifdef PAGE_TABLE_1G Pdp: ; ; Page-directory pointer table (512 * 1GB entries =3D> 512GB) ; -%assign i 0 -%rep 512 - DQ PAGE_PDPTE_1GB(i) - %assign i i+1 -%endrep + %assign i 0 + %rep 512 + DQ PAGE_PDPTE_1GB(i) + %assign i i+1 + %endrep +%else +Pdp: + ; + ; Page-directory pointer table (4 * 1GB entries =3D> 4GB) + ; + DQ PAGE_NLE(Pd) + DQ PAGE_NLE(Pd + 0x1000) + DQ PAGE_NLE(Pd + 0x2000) + DQ PAGE_NLE(Pd + 0x3000) + TIMES 0x1000 - ($ - Pdp) DB 0 =20 +Pd: + ; + ; Page-Directory (2048 * 2MB entries =3D> 4GB) + ; Four pages below, each is pointed by one entry in Pdp. + ; + %assign i 0 + %rep 0x800 + DQ PAGE_PDE_2MB(i) + %assign i i+1 + %endrep +%endif EndOfPageTables: diff --git a/UefiCpuPkg/ResetVector/Vtf0/X64/PageTables2M.asm b/UefiCpuPkg/= ResetVector/Vtf0/X64/PageTables2M.asm deleted file mode 100644 index 731dabad4d..0000000000 --- a/UefiCpuPkg/ResetVector/Vtf0/X64/PageTables2M.asm +++ /dev/null @@ -1,63 +0,0 @@ -;-------------------------------------------------------------------------= ----- -; @file -; Emits Page Tables for 1:1 mapping of the addresses 0 - 0x100000000 (4GB) -; -; Copyright (c) 2008 - 2023, Intel Corporation. All rights reserved.
-; SPDX-License-Identifier: BSD-2-Clause-Patent -; -;-------------------------------------------------------------------------= ----- - -BITS 64 - -%define ALIGN_TOP_TO_4K_FOR_PAGING - -; -; Page table big leaf entry attribute: -; PDPTE 1GB entry or PDE 2MB entry -; -%define PAGE_BLE_ATTR (PAGE_SIZE + \ - PAGE_ACCESSED + \ - PAGE_DIRTY + \ - PAGE_READ_WRITE + \ - PAGE_PRESENT) - -; -; Page table non-leaf entry attribute -; -%define PAGE_NLE_ATTR (PAGE_ACCESSED + \ - PAGE_READ_WRITE + \ - PAGE_PRESENT) - -%define PAGE_NLE(address) (ADDR_OF(address) + \ - PAGE_NLE_ATTR) -%define PAGE_PDE_2MB(x) ((x << 21) + PAGE_BLE_ATTR) - -Pml4: - ; - ; PML4 (1 * 512GB entry) - ; - DQ PAGE_NLE(Pdp) - TIMES 0x1000 - ($ - Pml4) DB 0 - -Pdp: - ; - ; Page-directory pointer table (4 * 1GB entries =3D> 4GB) - ; - DQ PAGE_NLE(Pd) - DQ PAGE_NLE(Pd + 0x1000) - DQ PAGE_NLE(Pd + 0x2000) - DQ PAGE_NLE(Pd + 0x3000) - TIMES 0x1000 - ($ - Pdp) DB 0 - -Pd: - ; - ; Page-Directory (2048 * 2MB entries =3D> 4GB) - ; Four pages below, each is pointed by one entry in Pdp. - ; -%assign i 0 -%rep 0x800 - DQ PAGE_PDE_2MB(i) - %assign i i+1 -%endrep - -EndOfPageTables: --=20 2.31.1.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 (#104834): https://edk2.groups.io/g/devel/message/104834 Mute This Topic: https://groups.io/mt/98894734/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-