public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Laszlo Ersek <lersek@redhat.com>
To: Ard Biesheuvel <ard.biesheuvel@linaro.org>, edk2-devel@lists.01.org
Cc: Andrew Jones <drjones@redhat.com>, Eric Auger <eric.auger@redhat.com>
Subject: Re: [PATCH 2/5] ArmPkg/ArmMmuLib: take the CPU supported maximum PA space into account
Date: Mon, 26 Nov 2018 11:06:25 +0100	[thread overview]
Message-ID: <3fb36d63-7cb1-53a1-f1c6-6dff1910e978@redhat.com> (raw)
In-Reply-To: <8dbc755f-1e89-3c59-f3e3-731d16ea8ab2@redhat.com>

On 11/26/18 10:42, Laszlo Ersek wrote:
> On 11/23/18 13:14, Ard Biesheuvel wrote:
>> In preparation of permitting the virt code to define a larger PA space
>> size via gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize than what the
>> CPU actually supports, take the CPU's capabilities into account when
>> setting up the page tables. This is necessary because KVM will shortly
>> support variable PA space sizes, and to support running the same UEFI
>> binaries regardless of that limit, PcdPrePiCpuMemorySize needs to be
>> treated as an upper bound rather than a fixed size.
>>
>> Contributed-under: TianoCore Contribution Agreement 1.1
>> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
>> ---
>>  ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c | 5 ++++-
>>  1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c
>> index 4b62ecb6a476..a4fde9b59383 100644
>> --- a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c
>> +++ b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c
>> @@ -593,6 +593,7 @@ ArmConfigureMmu (
>>  {
>>    VOID*                         TranslationTable;
>>    UINT32                        TranslationTableAttribute;
>> +  UINTN                         MaxAddressBits;
>>    UINT64                        MaxAddress;
>>    UINTN                         T0SZ;
>>    UINTN                         RootTableEntryCount;
>> @@ -605,7 +606,9 @@ ArmConfigureMmu (
>>    }
>>  
>>    // Cover the entire GCD memory space
>> -  MaxAddress = (1UL << PcdGet8 (PcdPrePiCpuMemorySize)) - 1;
>> +  MaxAddressBits = MIN (ArmGetPhysicalAddressBits (),
>> +                        PcdGet8 (PcdPrePiCpuMemorySize));
> 
> (1) Superficial comment: sticking to the letter of MIN() in
> "MdePkg/Include/Base.h", the arguments should be of the exact same type.
> Currently they aren't. (It's a different question whether that
> requirement makes any sense for MIN().)
> 
> (2) Why does it make sense to use MIN() here? Why not just disregard
> PcdPrePiCpuMemorySize and map what the CPU is capable of? (This ties in
> with my lack of understanding of PcdPrePiCpuMemorySize.)
> 
> I mean, not going above ArmGetPhysicalAddressBits() makes total sense.
> What's the point of staying below it though? And if so, how much exactly
> do we want to stay below it? (I.e., how is a platform supposed to set
> PcdPrePiCpuMemorySize, in order to clamp down ArmGetPhysicalAddressBits()?)

Ugh, okay. (Maybe you've responded already, I'm still in write-only
mode, sorry.) I think I'm getting the idea here. This is just being done
to keep the series bisectable / regression-free in the middle too. Right?

Thanks
Laszlo

> 
>> +  MaxAddress = (1UL << MaxAddressBits) - 1;
> 
> (3) I understand this just reworks the original code, but the original
> code isn't stellar. If we are left-shifting a UINT32 or UINTN value,
> then the result is the same, and the << operator is OK. However:
> 
> - Here we intend to accommodate a UINT64 result, judged from the type of
> MaxAddress (UINT64).
> 
> - For that, we should likely left-shift 1ULL, not 1 U;, which in turn
> requires LShiftU64() from BaseLib.
> 
> (If we indeed want to use UINTN, then I think we should change the type
> of MaxAddress, plus write "(UINTN)1", not 1UL.)
> 
>>  
>>    // Lookup the Table Level to get the information
>>    LookupAddresstoRootTable (MaxAddress, &T0SZ, &RootTableEntryCount);
>>
> 
> Thanks,
> Laszlo
> 



  parent reply	other threads:[~2018-11-26 10:06 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-23 12:14 [PATCH 0/5] ArmPkg, ArmVirtPkg: lift 40-bit IPA space limit Ard Biesheuvel
2018-11-23 12:14 ` [PATCH 1/5] ArmPkg/ArmLib: add support for reading the max physical address space size Ard Biesheuvel
     [not found]   ` <20181123131631.ionb53xqzlyepaue@hawk.localdomain>
2018-11-23 13:20     ` Ard Biesheuvel
2018-11-23 13:23       ` Ard Biesheuvel
2018-11-25 17:21       ` Laszlo Ersek
2018-11-26 11:46   ` Ard Biesheuvel
2018-11-26 18:17     ` Philippe Mathieu-Daudé
2018-11-23 12:14 ` [PATCH 2/5] ArmPkg/ArmMmuLib: take the CPU supported maximum PA space into account Ard Biesheuvel
2018-11-26  9:42   ` Laszlo Ersek
2018-11-26  9:46     ` Laszlo Ersek
2018-11-26 10:06     ` Laszlo Ersek [this message]
2018-11-26 11:43     ` Ard Biesheuvel
2018-11-26 17:45   ` Leif Lindholm
2018-11-26 17:50     ` Ard Biesheuvel
2018-11-26 17:57       ` Leif Lindholm
2018-11-23 12:14 ` [PATCH 3/5] ArmVirtPkg: refactor reading of the physical address space size Ard Biesheuvel
2018-11-26 10:00   ` Laszlo Ersek
2018-11-26 11:44     ` Ard Biesheuvel
2018-11-23 12:14 ` [PATCH 4/5] ArmVirtPkg: disregard PcdPrePiCpuMemorySize PCD when sizing the GCD space Ard Biesheuvel
2018-11-26 10:47   ` Laszlo Ersek
2018-11-26 11:59     ` Ard Biesheuvel
2018-11-23 12:14 ` [PATCH 5/5] ArmVirtPkg: revert PcdPrePiCpuMemorySize to is default value of 48 Ard Biesheuvel
     [not found]   ` <20181123133553.4o6rcbmebggn2ne7@hawk.localdomain>
2018-11-23 13:45     ` Ard Biesheuvel
2018-11-26 10:58   ` Laszlo Ersek
2018-11-25 17:23 ` [PATCH 0/5] ArmPkg, ArmVirtPkg: lift 40-bit IPA space limit Laszlo Ersek
2018-11-26  9:35 ` Laszlo Ersek
2018-11-26 10:22 ` Laszlo Ersek
2018-11-26 11:31   ` 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=3fb36d63-7cb1-53a1-f1c6-6dff1910e978@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