From: "Ni, Ray" <ray.ni@intel.com>
To: "Liu, Zhiguang" <zhiguang.liu@intel.com>,
"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: "Dong, Eric" <eric.dong@intel.com>,
"Kumar, Rahul R" <rahul.r.kumar@intel.com>,
Gerd Hoffmann <kraxel@redhat.com>,
"De, Debkumar" <debkumar.de@intel.com>,
"West, Catharine" <catharine.west@intel.com>
Subject: Re: [PATCH v2 2/2] UefiCpuPkg: Support 5 level page table in ResetVector
Date: Wed, 26 Apr 2023 09:07:27 +0000 [thread overview]
Message-ID: <MN6PR11MB82444C9DB980435BB5FB1A968C659@MN6PR11MB8244.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20230426081327.1425-2-zhiguang.liu@intel.com>
> -----Original Message-----
> From: Liu, Zhiguang <zhiguang.liu@intel.com>
> Sent: Wednesday, April 26, 2023 4:13 PM
> To: devel@edk2.groups.io
> Cc: Liu, Zhiguang <zhiguang.liu@intel.com>; Dong, Eric
> <eric.dong@intel.com>; Ni, Ray <ray.ni@intel.com>; Kumar, Rahul R
> <rahul.r.kumar@intel.com>; Gerd Hoffmann <kraxel@redhat.com>; De,
> Debkumar <debkumar.de@intel.com>; West, Catharine
> <catharine.west@intel.com>
> Subject: [PATCH v2 2/2] UefiCpuPkg: Support 5 level page table in
> ResetVector
>
> Add a macro USE_5_LEVEL_PAGE_TABLE to determine whether to create
> 5 level page table.
> If macro USE_5_LEVEL_PAGE_TABLE is defined, PML5Table is created
> at (4G-12K), while PML4Table is at (4G-16K). In runtime check, if
> 5level paging is supported, use PML5Table, otherwise, use PML4Table.
> If macro USE_5_LEVEL_PAGE_TABLE is not defined, to save space, 5level
> paging is not created, and 4level paging is at (4G-12K) and be used.
>
> Cc: Eric Dong <eric.dong@intel.com>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Rahul Kumar <rahul1.kumar@intel.com>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: Debkumar De <debkumar.de@intel.com>
> Cc: Catharine West <catharine.west@intel.com>
> Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
> ---
> .../ResetVector/Vtf0/Ia32/Flat32ToFlat64.asm | 24 ++++++++++++++++--
> .../ResetVector/Vtf0/Ia32/PageTables64.asm | 25 -------------------
> UefiCpuPkg/ResetVector/Vtf0/Vtf0.nasmb | 4 ++-
> .../ResetVector/Vtf0/X64/PageTables5L.asm | 20 +++++++++++++++
> 4 files changed, 45 insertions(+), 28 deletions(-)
> delete mode 100644 UefiCpuPkg/ResetVector/Vtf0/Ia32/PageTables64.asm
> create mode 100644 UefiCpuPkg/ResetVector/Vtf0/X64/PageTables5L.asm
>
> diff --git a/UefiCpuPkg/ResetVector/Vtf0/Ia32/Flat32ToFlat64.asm
> b/UefiCpuPkg/ResetVector/Vtf0/Ia32/Flat32ToFlat64.asm
> index 6891397c2a..0b4a21061b 100644
> --- a/UefiCpuPkg/ResetVector/Vtf0/Ia32/Flat32ToFlat64.asm
> +++ b/UefiCpuPkg/ResetVector/Vtf0/Ia32/Flat32ToFlat64.asm
> @@ -2,7 +2,7 @@
> ; @file
> ; Transition from 32 bit flat protected mode into 64 bit flat protected mode
> ;
> -; Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>
> +; Copyright (c) 2008 - 2023, Intel Corporation. All rights reserved.<BR>
> ; SPDX-License-Identifier: BSD-2-Clause-Patent
> ;
> ;------------------------------------------------------------------------------
> @@ -13,8 +13,28 @@ BITS 32
> ; Modified: EAX
> ;
> Transition32FlatTo64Flat:
> +%ifdef USE_5_LEVEL_PAGE_TABLE
> + mov eax, 0
> + cpuid
> + cmp eax, 07h ; check if basic CPUID leaf contains leaf 07
> + jb NotSupport5LevelPaging ; 5level paging not support, downgrade
> to 4level paging
> + mov eax, 07h ; check cpuid leaf 7, subleaf 0
> + mov ecx, 0
> + cpuid
> + bt ecx, 16 ; [Bits 16] Supports 5-level paging if 1.
> + jnc NotSupport5LevelPaging ; 5level paging not support, downgrade
> to 4level paging
> + mov eax, ADDR_OF(PML5Table)
1. Label can be "Pml5"
> + mov cr3, eax
> + mov eax, cr4
> + bts eax, 12 ; Set LA57=1.
> + mov cr4, eax
> + jmp CR3ProgramDone
> +NotSupport5LevelPaging:
> +%endif
>
> - OneTimeCall SetCr3ForPageTables64
> + mov eax, ADDR_OF(PML4Table)
> + mov cr3, eax
> +CR3ProgramDone:
2. Label can be "SetCr3Done"
> +
> +PML5Table:
3. "Pml5:"
> + ;
> + ; PML5 table Pointers
4. "PML5"
> + ; Assume page table is create from bottom to top, and only one PML4
> table there.
5. "Assume PML4 is in 4KB-lower address"
> + ;
> + DQ (ADDR_OF($) - 0x1000 + PAGE_PDP_ATTR)
> +
> + ;
> + ; Only first PML5 entry(first 8 bytes) pointting to a PML4 table. Others are
> zero
> + ;
> + TIMES (0x1000 - 0x8) DB 0
6. How about "TIMES 0x1000 - ($-Pml5) DB 0"?
> --
> 2.31.1.windows.1
next prev parent reply other threads:[~2023-04-26 9:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-26 8:13 [PATCH v2 1/2] UefiCpuPkg/ResetVector: Modify Page Table in ResetVector Zhiguang Liu
2023-04-26 8:13 ` [PATCH v2 2/2] UefiCpuPkg: Support 5 level page table " Zhiguang Liu
2023-04-26 9:07 ` Ni, Ray [this message]
2023-04-26 8:25 ` [PATCH v2 1/2] UefiCpuPkg/ResetVector: Modify Page Table " Zhiguang Liu
2023-04-26 8:58 ` Ni, Ray
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=MN6PR11MB82444C9DB980435BB5FB1A968C659@MN6PR11MB8244.namprd11.prod.outlook.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox