Skip to content

Commit 38ba4a6

Browse files
makubackimergify[bot]
authored andcommitted
ArmPkg/Drivers/CpuDxe: Use lower and upper attributes
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 Signed-off-by: Michael Kubacki <[email protected]> Reviewed-by: Ard Biesheuvel <[email protected]>
1 parent e1627f7 commit 38ba4a6

File tree

1 file changed

+5
-5
lines changed
  • ArmPkg/Drivers/CpuDxe/AArch64

1 file changed

+5
-5
lines changed

ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
1313
#include <Library/MemoryAllocationLib.h>
1414
#include "CpuDxe.h"
1515

16-
#define INVALID_ENTRY ((UINT32)~0)
16+
#define INVALID_ENTRY ((UINT64)~0)
1717

1818
#define MIN_T0SZ 16
1919
#define BITS_PER_LEVEL 9
@@ -169,14 +169,14 @@ GetNextEntryAttribute (
169169
IN UINTN EntryCount,
170170
IN UINTN TableLevel,
171171
IN UINT64 BaseAddress,
172-
IN OUT UINT32 *PrevEntryAttribute,
172+
IN OUT UINT64 *PrevEntryAttribute,
173173
IN OUT UINT64 *StartGcdRegion
174174
)
175175
{
176176
UINTN Index;
177177
UINT64 Entry;
178-
UINT32 EntryAttribute;
179-
UINT32 EntryType;
178+
UINT64 EntryAttribute;
179+
UINT64 EntryType;
180180
EFI_STATUS Status;
181181
UINTN NumberOfDescriptors;
182182
EFI_GCD_MEMORY_SPACE_DESCRIPTOR *MemorySpaceMap;
@@ -271,7 +271,7 @@ SyncCacheConfig (
271271
)
272272
{
273273
EFI_STATUS Status;
274-
UINT32 PageAttribute;
274+
UINT64 PageAttribute;
275275
UINT64 *FirstLevelTableAddress;
276276
UINTN TableLevel;
277277
UINTN TableCount;

0 commit comments

Comments
 (0)