audk/ArmPkg/Drivers/CpuDxe
Oliver Smith-Denny 647cd40cf6 ArmPkg/CpuDxe AARCH64: Report Memory Protection Attributes To GCD
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4463

When the AARCH64 CpuDxe attempts to SyncCacheConfig() with the GCD, it
collects the page attributes as:

  EntryAttribute = Entry & TT_ATTR_INDX_MASK

However, TT_ATTR_INDX_MASK only masks the cacheability attributes and
drops the memory protections attributes. Importantly, it also drops the
TT_AF (access flag) which is now wired up in EDK2 to represent
EFI_MEMORY_RP, so by default all SystemMem pages will report as
EFI_MEMORY_RP to the GCD. The GCD currently drops that silently, because
the Capabilities field in the GCD does not support EFI_MEMORY_RP by
default.

However, some ranges may support EFI_MEMORY_RP and incorrectly mark
those ranges as read protected. In conjunction with another change on
the mailing list (see: https://edk2.groups.io/g/devel/topic/98505340),
this causes an access flag fault incorrectly. See the linked BZ below
for full details.

This patch exposes all memory protections attributes to the GCD layer so
it can correctly set pages as EFI_MEMORY[RP|XP|RO] when it initially
syncs.

Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Taylor Beebe <t@taylorbeebe.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Michael Kubacki <michael.kubacki@microsoft.com>
2023-05-29 15:14:00 +00:00
..
AArch64 ArmPkg/CpuDxe AARCH64: Report Memory Protection Attributes To GCD 2023-05-29 15:14:00 +00:00
Arm ArmPkg/CpuDxe: Expose unified region-to-EFI attribute conversion 2023-03-16 21:14:49 +00:00
CpuDxe.c ArmPkg/CpuDxe: Implement EFI memory attributes protocol 2023-03-16 21:14:49 +00:00
CpuDxe.h ArmPkg/CpuDxe: Implement EFI memory attributes protocol 2023-03-16 21:14:49 +00:00
CpuDxe.inf ArmPkg/CpuDxe: Implement EFI memory attributes protocol 2023-03-16 21:14:49 +00:00
CpuMmuCommon.c ArmPkg: Apply uncrustify changes 2021-12-07 17:24:28 +00:00
Exception.c ArmPkg: Apply uncrustify changes 2021-12-07 17:24:28 +00:00
MemoryAttribute.c ArmPkg: Update code to be more C11 compliant by using __func__ 2023-04-10 14:19:57 +00:00