From: "Ard Biesheuvel" <ardb@kernel.org>
To: mikuback@linux.microsoft.com
Cc: devel@edk2.groups.io, Ard Biesheuvel <ardb+tianocore@kernel.org>,
Leif Lindholm <quic_llindhol@quicinc.com>,
Sami Mujawar <sami.mujawar@arm.com>
Subject: Re: [edk2-devel] [PATCH v2 1/1] ArmPkg/Drivers/CpuDxe: Use lower and upper attributes
Date: Tue, 28 Nov 2023 18:44:59 +0100 [thread overview]
Message-ID: <CAMj1kXFAbtMB=dhUCpkzpDoszwC-_2H_cga6gkHknW=X3irb+A@mail.gmail.com> (raw)
In-Reply-To: <20231128171154.1349-2-mikuback@linux.microsoft.com>
On Tue, 28 Nov 2023 at 18:12, <mikuback@linux.microsoft.com> wrote:
>
> From: Michael Kubacki <michael.kubacki@microsoft.com>
>
> GetNextEntryAttribute() is currently applying a 64-bit mask
> (TT_ATTRIBUTES_MASK) to a 32-bit descriptor value (EntryType).
> The original descriptor was 64 bits containing the upper and
> lower attributes which are included in TT_ATTRIBUTES_MASK.
>
> The PrevEntryAttribute parameter is also a UINT32, but passed to
> PageAttributeToGcdAttribute() for a UINT64 parameter where the
> function checks masks in the upper 32 bits of the integer value:
>
> PageAttributeToGcdAttribute (*PrevEntryAttribute)
> ...
> STATIC
> UINT64
> PageAttributeToGcdAttribute (
> IN UINT64 PageAttributes
> )
> ...
> if ((PageAttributes & (TT_PXN_MASK | TT_UXN_MASK)) != 0) {
> GcdAttributes |= EFI_MEMORY_XP;
> }
> ...
> #define TT_PXN_MASK BIT53
> #define TT_UXN_MASK BIT54 // EL1&0
>
> This change removes UINT32 intermediary values. For EntryType,
> eliminating an unncessary cast. For EntryAttribute, preserving the
> upper and lower attributes for evaluation in
> PageAttributeToGcdAttribute().
>
> This also resolves the following compiler warning previously present
> on Visual Studio for the assignment to the previously 32-bit local
> variables.
>
> '=': conversion from 'UINT64' to 'UINT32', possible loss of data
>
> Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
> Cc: Leif Lindholm <quic_llindhol@quicinc.com>
> Cc: Sami Mujawar <sami.mujawar@arm.com>
> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Queued up now - thanks.
> ---
> ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c b/ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c
> index e14eb47ce4c6..ff14c2f814b2 100644
> --- a/ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c
> +++ b/ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c
> @@ -13,7 +13,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
> #include <Library/MemoryAllocationLib.h>
> #include "CpuDxe.h"
>
> -#define INVALID_ENTRY ((UINT32)~0)
> +#define INVALID_ENTRY ((UINT64)~0)
>
> #define MIN_T0SZ 16
> #define BITS_PER_LEVEL 9
> @@ -169,14 +169,14 @@ GetNextEntryAttribute (
> IN UINTN EntryCount,
> IN UINTN TableLevel,
> IN UINT64 BaseAddress,
> - IN OUT UINT32 *PrevEntryAttribute,
> + IN OUT UINT64 *PrevEntryAttribute,
> IN OUT UINT64 *StartGcdRegion
> )
> {
> UINTN Index;
> UINT64 Entry;
> - UINT32 EntryAttribute;
> - UINT32 EntryType;
> + UINT64 EntryAttribute;
> + UINT64 EntryType;
> EFI_STATUS Status;
> UINTN NumberOfDescriptors;
> EFI_GCD_MEMORY_SPACE_DESCRIPTOR *MemorySpaceMap;
> @@ -271,7 +271,7 @@ SyncCacheConfig (
> )
> {
> EFI_STATUS Status;
> - UINT32 PageAttribute;
> + UINT64 PageAttribute;
> UINT64 *FirstLevelTableAddress;
> UINTN TableLevel;
> UINTN TableCount;
> --
> 2.42.0.windows.2
>
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111819): https://edk2.groups.io/g/devel/message/111819
Mute This Topic: https://groups.io/mt/102854549/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
prev parent reply other threads:[~2023-11-28 17:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-28 17:11 [edk2-devel] [PATCH v2 0/1] ArmPkg/CpuDxe: Use upper and lower attributes Michael Kubacki
2023-11-28 17:11 ` [edk2-devel] [PATCH v2 1/1] ArmPkg/Drivers/CpuDxe: Use lower and upper attributes Michael Kubacki
2023-11-28 17:44 ` Ard Biesheuvel [this message]
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='CAMj1kXFAbtMB=dhUCpkzpDoszwC-_2H_cga6gkHknW=X3irb+A@mail.gmail.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