From: Laszlo Ersek <lersek@redhat.com>
To: Ard Biesheuvel <ard.biesheuvel@linaro.org>, edk2-devel@lists.01.org
Cc: Leif Lindholm <leif.lindholm@linaro.org>,
Eric Auger <eric.auger@redhat.com>,
Andrew Jones <drjones@redhat.com>,
Philippe Mathieu-Daude <philmd@redhat.com>,
Julien Grall <julien.grall@linaro.org>
Subject: Re: [PATCH v3 08/16] ArmPkg/ArmMmuLib: take the CPU supported maximum PA space into account
Date: Wed, 28 Nov 2018 20:26:05 +0100 [thread overview]
Message-ID: <d6400892-2eb7-722d-5757-6f800eaa62b2@redhat.com> (raw)
In-Reply-To: <20181128143357.991-9-ard.biesheuvel@linaro.org>
On 11/28/18 15:33, Ard Biesheuvel wrote:
> In preparation of dropping PcdPrePiCpuMemorySize entirely, base the
> maximum size of the identity map on the capabilities of the CPU.
> Since that may exceed what is architecturally permitted when using
> 4 KB pages, take MAX_ADDRESS into account as well.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
> ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf | 3 ---
> ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf | 3 ---
> ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c | 11 +++++++++--
> 3 files changed, 9 insertions(+), 8 deletions(-)
>
> diff --git a/ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf b/ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf
> index b9f264de8d26..246963361e45 100644
> --- a/ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf
> +++ b/ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf
> @@ -40,8 +40,5 @@ [LibraryClasses]
> CacheMaintenanceLib
> MemoryAllocationLib
>
> -[Pcd.AARCH64]
> - gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize
> -
> [Pcd.ARM]
> gArmTokenSpaceGuid.PcdNormalMemoryNonshareableOverride
> diff --git a/ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf b/ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf
> index ecf13f790734..f689c193b862 100644
> --- a/ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf
> +++ b/ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf
> @@ -35,6 +35,3 @@ [LibraryClasses]
> ArmLib
> CacheMaintenanceLib
> MemoryAllocationLib
> -
> -[Pcd.AARCH64]
> - gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize
OK
> diff --git a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c
> index 4b62ecb6a476..5403b8d4070e 100644
> --- a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c
> +++ b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c
> @@ -604,8 +604,15 @@ ArmConfigureMmu (
> return EFI_INVALID_PARAMETER;
> }
>
> - // Cover the entire GCD memory space
> - MaxAddress = (1UL << PcdGet8 (PcdPrePiCpuMemorySize)) - 1;
> + //
> + // Limit the virtual address space to what we can actually use: UEFI
> + // mandates a 1:1 mapping, so no point in making the virtual address
> + // space larger than the physical address space. We also have to take
> + // into account the architectural limitations that result from UEFI's
> + // use of 4 KB pages.
> + //
> + MaxAddress = MIN (LShiftU64 (1ULL, ArmGetPhysicalAddressBits ()) - 1,
> + MAX_ADDRESS);
>
> // Lookup the Table Level to get the information
> LookupAddresstoRootTable (MaxAddress, &T0SZ, &RootTableEntryCount);
>
This part of edk2 (or ArmVirtQemu) is where I *always* get lost. So let
me check the call tree.
ArmPlatformPkg/MemoryInitPei/MemoryInitPeim.inf [ArmVirtPkg/ArmVirtQemu.dsc]
InitializeMemory() [ArmPlatformPkg/MemoryInitPei/MemoryInitPeim.c]
PeiServicesInstallPeiMemory() [...]
// now we've got permanent PEI RAM
MemoryPeim() [ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c]
InitMmu() [ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c]
ArmVirtGetMemoryMap() [ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.c]
ArmConfigureMmu() [ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c]
In patch v3 04/16, we modify ArmVirtGetMemoryMap() so that the mapping
not cover the "Peripheral space after DRAM" (which is practically
"limitless"). Good.
In this patch, we have to modify ArmConfigureMmu() as well, because the
descriptor array that we pass it from ArmVirtGetMemoryMap() does not
contain all the information that is necessary for setting up "paging" in
general. Also considering mappings that could be added later during DXE,
such as MMIO ranges of platform drivers / devices, discontiguous RAM
ranges, and so on.
So we need a "maximum" here. The maximum that we choose doesn't
"seriously" translate to an increased memory footprint of paging
artifacts, *unlike* the size of the address space that we actually map
for access. Hence in patch v3 04/16, we are conservative, but in this
patch, when selecting the maximum, we go as high as we can -- either the
architecturally permitted limit (with 4KB page size), or, if the latter
is lower, the limit supported by the current CPU.
The GCD *could* go higher (even though we'd never attempt to map that in
UEFI), assuming the CPU is capable enough (using 64KB pages at OS
runtime).
This bends my brain. :) I'm now slowly comprehending your blurb. Indeed,
the rest of the series pertains to the GCD memory space map.
Nit: the second argument of the MIN() macro is not indented
idiomatically. With that fixed (no need to repost the series just
because of it):
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Thanks
Laszlo
next prev parent reply other threads:[~2018-11-28 19:26 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-28 14:33 [PATCH v3 00/16] [Arm|ArmVirt|MdePkg|Embedded]Pkg: lift 40-bit IPA space limit Ard Biesheuvel
2018-11-28 14:33 ` [PATCH v3 01/16] EmbeddedPkg/TemplateSec: remove unused module Ard Biesheuvel
2018-11-28 17:55 ` Laszlo Ersek
2018-11-29 15:39 ` Leif Lindholm
2018-11-28 14:33 ` [PATCH v3 02/16] EmbeddedPkg/PrePiHobLib: drop CreateHobList() from library Ard Biesheuvel
2018-11-28 17:58 ` Laszlo Ersek
2018-11-29 15:40 ` Leif Lindholm
2018-11-28 14:33 ` [PATCH v3 03/16] ArmVirtPkg/FdtPciHostBridgeLib: map ECAM and I/O spaces in GCD memory map Ard Biesheuvel
2018-11-28 18:00 ` Laszlo Ersek
2018-11-28 14:33 ` [PATCH v3 04/16] ArmVirtPkg/QemuVirtMemInfoLib: remove 1:1 mapping of top of PA range Ard Biesheuvel
2018-11-28 15:06 ` Philippe Mathieu-Daudé
2018-11-28 18:05 ` Laszlo Ersek
2018-11-28 14:33 ` [PATCH v3 05/16] MdePkg/ProcessorBind.h AARCH64: limit MAX_ADDRESS to 48 bits Ard Biesheuvel
2018-11-28 18:41 ` Laszlo Ersek
2018-11-29 10:40 ` Ard Biesheuvel
2018-11-29 11:34 ` Laszlo Ersek
2018-11-29 15:19 ` Gao, Liming
2018-11-28 14:33 ` [PATCH v3 06/16] ArmPkg/ArmLib: add support for reading the max physical address space size Ard Biesheuvel
2018-11-28 14:41 ` Philippe Mathieu-Daudé
2018-11-28 18:44 ` Laszlo Ersek
2018-11-29 15:42 ` Leif Lindholm
2018-11-28 14:33 ` [PATCH v3 07/16] ArmVirtPkg/XenVirtMemInfoLib: refactor reading of the PA " Ard Biesheuvel
2018-11-28 14:44 ` Philippe Mathieu-Daudé
2018-11-28 18:47 ` Laszlo Ersek
2018-11-28 14:33 ` [PATCH v3 08/16] ArmPkg/ArmMmuLib: take the CPU supported maximum PA space into account Ard Biesheuvel
2018-11-28 14:46 ` Philippe Mathieu-Daudé
2018-11-28 19:26 ` Laszlo Ersek [this message]
2018-11-29 15:43 ` Leif Lindholm
2018-11-28 14:33 ` [PATCH v3 09/16] ArmPkg/CpuPei: base GCD memory space size on CPU's PA range Ard Biesheuvel
2018-11-28 15:01 ` Philippe Mathieu-Daudé
2018-11-28 19:51 ` Laszlo Ersek
2018-11-29 15:43 ` Leif Lindholm
2018-11-28 14:33 ` [PATCH v3 10/16] ArmPlatformPkg/PrePi: " Ard Biesheuvel
2018-11-28 15:01 ` Philippe Mathieu-Daudé
2018-11-28 19:53 ` Laszlo Ersek
2018-11-29 15:44 ` Leif Lindholm
2018-11-28 14:33 ` [PATCH v3 11/16] ArmVirtPkg/PrePi: " Ard Biesheuvel
2018-11-28 15:02 ` Philippe Mathieu-Daudé
2018-11-28 19:52 ` Laszlo Ersek
2018-11-28 14:33 ` [PATCH v3 12/16] BeagleBoardPkg/PrePi: " Ard Biesheuvel
2018-11-28 15:02 ` Philippe Mathieu-Daudé
2018-11-28 19:53 ` Laszlo Ersek
2018-11-29 15:44 ` Leif Lindholm
2018-11-28 14:33 ` [PATCH v3 13/16] ArmPlatformPkg/PlatformPei: drop unused PCD references Ard Biesheuvel
2018-11-28 19:54 ` Laszlo Ersek
2018-11-29 15:45 ` Leif Lindholm
2018-11-28 14:33 ` [PATCH v3 14/16] EmbeddedPkg/PrePiLib: drop unused PCD reference Ard Biesheuvel
2018-11-28 19:55 ` Laszlo Ersek
2018-11-29 15:46 ` Leif Lindholm
2018-11-28 14:33 ` [PATCH v3 15/16] ArmVirtPkg: drop PcdPrePiCpuMemorySize assignments from all platforms Ard Biesheuvel
2018-11-28 19:56 ` Laszlo Ersek
2018-11-28 14:33 ` [PATCH v3 16/16] EmbeddedPkg/EmbeddedPkg.dec: drop PcdPrePiCpuMemorySize declarations Ard Biesheuvel
2018-11-28 19:57 ` Laszlo Ersek
2018-11-29 15:46 ` Leif Lindholm
2018-11-29 17:59 ` [PATCH v3 00/16] [Arm|ArmVirt|MdePkg|Embedded]Pkg: lift 40-bit IPA space limit Ard Biesheuvel
2018-11-30 21:45 ` Ard Biesheuvel
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=d6400892-2eb7-722d-5757-6f800eaa62b2@redhat.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