[PATCH 2/3] arm64: acpi: Map EFI_MEMORY_WT memory as Normal-NC
Mark Rutland
mark.rutland at arm.com
Thu May 6 03:20:45 PDT 2021
On Thu, May 06, 2021 at 10:50:33AM +0100, Will Deacon wrote:
> The only user we have of Normal Write-Through memory is in the ACPI code
> when mapping memory regions advertised as EFI_MEMORY_WT. Since most (all?)
> CPUs treat write-through as non-cacheable under the hood, don't bother
> with the extra memory type here and just treat EFI_MEMORY_WT the same way
> as EFI_MEMORY_WC by mapping it to the Normal-NC memory type instead.
The UEFI spec explicitly defines EFI_MEMORY_WT as Normal Outer-WT
Inner-WT (and even explicitly specifies the MAIR.Attr<n> value).
In the UEFI 2.9 spec, see section 2.3.6.1 "Memory types", Table 2-5
"Map: EFI Cacheability Attributes to AArch64 Memory Types".
The UEFI 2.9 spec can be found at:
https://uefi.org/sites/default/files/resources/UEFI_Spec_2_9_2021_03_18.pdf
Given that is specified explicitly, and given that we don't know how
future CPUs will treat this equivalently, I don't think this change is
architecturally sound and I don't think there's wiggle-room to read the
spec as permitting this.
Thanks,
Mark.
>
> Cc: Ard Biesheuvel <ardb at kernel.org>
> Cc: Lorenzo Pieralisi <lorenzo.pieralisi at arm.com>
> Cc: Christoph Hellwig <hch at lst.de>
> Signed-off-by: Will Deacon <will at kernel.org>
> ---
> arch/arm64/kernel/acpi.c | 10 +++-------
> 1 file changed, 3 insertions(+), 7 deletions(-)
>
> diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
> index cada0b816c8a..aca5ee2a9e64 100644
> --- a/arch/arm64/kernel/acpi.c
> +++ b/arch/arm64/kernel/acpi.c
> @@ -246,7 +246,7 @@ pgprot_t __acpi_get_mem_attribute(phys_addr_t addr)
> * types" of UEFI 2.5 section 2.3.6.1, each EFI memory type is
> * mapped to a corresponding MAIR attribute encoding.
> * The EFI memory attribute advises all possible capabilities
> - * of a memory region. We use the most efficient capability.
> + * of a memory region.
> */
>
> u64 attr;
> @@ -254,9 +254,7 @@ pgprot_t __acpi_get_mem_attribute(phys_addr_t addr)
> attr = efi_mem_attributes(addr);
> if (attr & EFI_MEMORY_WB)
> return PAGE_KERNEL;
> - if (attr & EFI_MEMORY_WT)
> - return __pgprot(PROT_NORMAL_WT);
> - if (attr & EFI_MEMORY_WC)
> + if (attr & (EFI_MEMORY_WC | EFI_MEMORY_WT))
> return __pgprot(PROT_NORMAL_NC);
> return __pgprot(PROT_DEVICE_nGnRnE);
> }
> @@ -340,9 +338,7 @@ void __iomem *acpi_os_ioremap(acpi_physical_address phys, acpi_size size)
> default:
> if (region->attribute & EFI_MEMORY_WB)
> prot = PAGE_KERNEL;
> - else if (region->attribute & EFI_MEMORY_WT)
> - prot = __pgprot(PROT_NORMAL_WT);
> - else if (region->attribute & EFI_MEMORY_WC)
> + else if (region->attribute & (EFI_MEMORY_WC | EFI_MEMORY_WT))
> prot = __pgprot(PROT_NORMAL_NC);
> }
> }
> --
> 2.31.1.607.g51e8a6a459-goog
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
More information about the linux-arm-kernel
mailing list