From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web10.13349.1682664197208531778 for ; Thu, 27 Apr 2023 23:43:18 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=HDBbFAUl; spf=pass (domain: intel.com, ip: 192.55.52.43, mailfrom: zhiguang.liu@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1682664197; x=1714200197; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0o82SKbalkT/tncUMRdyINki0zaKLDUjSV1J420mEcg=; b=HDBbFAUlYBO/nead5w5SJXWB77NDrsIVvQ5qFUfke9G4kRFaULFiQpa9 VScYzJF5nDQjPHZA9x+a/2FkvomEns29iiJnpjTX+sT8DatUVeleCHL10 RYt86jLiq7t1rEMT3SwpN/OTypOgYrr7UtiqZWiDy4W2HAbzO/uVnjceH NWqg7b2CeGRZk25DDMEyHuIuFize+XNqBTCJNbMkmAcckXF6ywko6T9cW cQGzVteItFr/NkFmufG52xOujdXy+GDABVDOJLPwS0PTUZSsKcPgSXndI SwJDtujIKFTI/NcQ+lz55hsJTKRu051drgQmyVranLh88cqA8pNJqx6bB w==; X-IronPort-AV: E=McAfee;i="6600,9927,10693"; a="433956821" X-IronPort-AV: E=Sophos;i="5.99,233,1677571200"; d="scan'208";a="433956821" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Apr 2023 23:43:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10693"; a="806262934" X-IronPort-AV: E=Sophos;i="5.99,233,1677571200"; d="scan'208";a="806262934" Received: from shwdesfp01.ccr.corp.intel.com ([10.239.158.151]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Apr 2023 23:43:06 -0700 From: "Zhiguang Liu" To: devel@edk2.groups.io Cc: Zhiguang Liu , Eric Dong , Ray Ni , Rahul Kumar , Gerd Hoffmann , Debkumar De , Catharine West Subject: [PATCH v3 3/5] UefiCpuPkg/ResetVector: Combine PageTables1G.asm and PageTables2M.asm Date: Fri, 28 Apr 2023 14:42:21 +0800 Message-Id: <20230428064223.2048-3-zhiguang.liu@intel.com> X-Mailer: git-send-email 2.31.1.windows.1 In-Reply-To: <20230428064223.2048-1-zhiguang.liu@intel.com> References: <20230428064223.2048-1-zhiguang.liu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Combine PageTables1G.asm and PageTables2M.asm to reuse code. Cc: Eric Dong Cc: Ray Ni Cc: Rahul Kumar Cc: Gerd Hoffmann Cc: Debkumar De Cc: Catharine West Signed-off-by: Zhiguang Liu --- UefiCpuPkg/ResetVector/Vtf0/Vtf0.nasmb | 8 +-- .../X64/{PageTables1G.asm => PageTables.asm} | 38 ++++++++--- .../ResetVector/Vtf0/X64/PageTables2M.asm | 63 ------------------- 3 files changed, 33 insertions(+), 76 deletions(-) rename UefiCpuPkg/ResetVector/Vtf0/X64/{PageTables1G.asm => PageTables.asm} (58%) delete mode 100644 UefiCpuPkg/ResetVector/Vtf0/X64/PageTables2M.asm diff --git a/UefiCpuPkg/ResetVector/Vtf0/Vtf0.nasmb b/UefiCpuPkg/ResetVector/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" %ifdef ARCH_X64 - %ifdef PAGE_TABLE_1G - %include "X64/PageTables1G.asm" - %else - %include "X64/PageTables2M.asm" - %endif + %include "X64/PageTables.asm" %endif %ifdef DEBUG_PORT80 diff --git a/UefiCpuPkg/ResetVector/Vtf0/X64/PageTables1G.asm b/UefiCpuPkg/ResetVector/Vtf0/X64/PageTables.asm similarity index 58% rename from UefiCpuPkg/ResetVector/Vtf0/X64/PageTables1G.asm rename to UefiCpuPkg/ResetVector/Vtf0/X64/PageTables.asm index 2b0de6020c..469fed0006 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 (512GB) +; 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 ; ;------------------------------------------------------------------------------ @@ -36,6 +37,7 @@ BITS 64 PAGE_NLE_ATTR) %define PDP_1G(x) ((x << 30) + PAGE_BLP_ATTR) +%define PTE_2MB(x) ((x << 21) + PAGE_BLP_ATTR) ALIGN 16 @@ -46,14 +48,36 @@ Pml4: DQ PG_NLE(Pdp) TIMES 0x1000 - ($ - Pml4) DB 0 +%ifdef PAGE_TABLE_1G Pdp: ; ; Page-directory pointer table (512 * 1GB entries => 512GB) ; -%assign i 0 -%rep 512 - DQ PDP_1G(i) - %assign i i+1 -%endrep + %assign i 0 + %rep 512 + DQ PDP_1G(i) + %assign i i+1 + %endrep +%else +Pdp: + ; + ; Page-directory pointer table (4 * 1GB entries => 4GB) + ; + DQ PG_NLE(Pd) + DQ PG_NLE(Pd + 0x1000) + DQ PG_NLE(Pd + 0x2000) + DQ PG_NLE(Pd + 0x3000) + TIMES 0x1000 - ($ - Pdp) DB 0 +Pd: + ; + ; Page-Directory (2048 * 2MB entries => 4GB) + ; Four pages below, each is pointed by one entry in Pdp. + ; + %assign i 0 + %rep 0x800 + DQ PTE_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 cdf0fb41b7..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 page attribute -; Big leaf page contains PDPTE 1GB page and PDE 2MB page -; -%define PAGE_BLP_ATTR (PAGE_SIZE + \ - PAGE_ACCESSED + \ - PAGE_DIRTY + \ - PAGE_READ_WRITE + \ - PAGE_PRESENT) - -; -; Page table no-leaf entry attribute -; -%define PAGE_NLE_ATTR (PAGE_ACCESSED + \ - PAGE_READ_WRITE + \ - PAGE_PRESENT) - -%define PG_NLE(address) (ADDR_OF(address) + \ - PAGE_NLE_ATTR) -%define PTE_2MB(x) ((x << 21) + PAGE_BLP_ATTR) - -Pml4: - ; - ; PML4 (1 * 512GB entry) - ; - DQ PG_NLE(Pdp) - TIMES 0x1000 - ($ - Pml4) DB 0 - -Pdp: - ; - ; Page-directory pointer table (4 * 1GB entries => 4GB) - ; - DQ PG_NLE(Pd) - DQ PG_NLE(Pd + 0x1000) - DQ PG_NLE(Pd + 0x2000) - DQ PG_NLE(Pd + 0x3000) - TIMES 0x1000 - ($ - Pdp) DB 0 - -Pd: - ; - ; Page-Directory (2048 * 2MB entries => 4GB) - ; Four pages below, each is pointed by one entry in Pdp. - ; -%assign i 0 -%rep 0x800 - DQ PTE_2MB(i) - %assign i i+1 -%endrep - -EndOfPageTables: -- 2.31.1.windows.1