Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ArmPkg/Drivers/CpuDxe: Use lower and upper attributes
`GetNextEntryAttribute()` is currently applying the 64-bit mask to a 32-bit descriptor value (the lower attributes). `EntryType` (and `EntryTypeAttribute`) are 32-bit and `TT_ATTRIBUTES_MASK` is 64-bit: #define TT_ATTRIBUTES_MASK ((0xFFFULL << 52) | (0x3FFULL << 2)) In the 64-bit descriptor, there are 10 bits of lower attributes and 12 bits of upper attributes. The descriptor is converted to a 32-bit value and assigned to `EntryAttribute`. This is assigned to `PrevEntryAttribute`: *PrevEntryAttribute = EntryAttribute; Where `PrevEntryAttribute` is also a `UINT32`: IN OUT UINT32 *PrevEntryAttribute, Which is passed to `PageAttributeToGcdAttribute()`: SetGcdMemorySpaceAttributes ( MemorySpaceMap, NumberOfDescriptors, *StartGcdRegion, (BaseAddress + (Index * TT_ADDRESS_AT_LEVEL (TableLevel))) - *StartGcdRegion, PageAttributeToGcdAttribute (*PrevEntryAttribute) ); Which accepts a `UINT64`: STATIC UINT64 PageAttributeToGcdAttribute ( IN UINT64 PageAttributes ); Which sets `EFI_MEMORY_XP` based on `TT_PXN_MASK | TT_UXN_MASK`: // Process eXecute Never attribute if ((PageAttributes & (TT_PXN_MASK | TT_UXN_MASK)) != 0) { GcdAttributes |= EFI_MEMORY_XP; } Where those bits are in the upper attributes: This change uses a 64-bit integer to hold the attributes to set `EFI_MEMORY_XP`. Signed-off-by: Michael Kubacki <[email protected]>
- Loading branch information