Skip to contentSkip to conversation

Free up a couple of MAIRs

PATCH Superseded Will Deacon 4 participants 13 messages May 6, 2021 arm64

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Will Deacon

author maintainer
#0 lore raw

cover Free up a couple of MAIRs

Hi folks,

Catalin pointed out that the Device-GRE memory type is unused, despite having a MAIR allocation. In removing that, I noticed that we also allocate Normal-WT despite it only being used for EFI_MEMORY_WT mappings, which can use Normal-NC instead.

With these changes, we free up a couple of MAIR entries for more interesting things (e.g. outer cacheability attributes if we need them in future for the SLC).

Patches taken against the arm64 for-next/core branch.

Cheers,

Will

Cc Christoph Hellwig <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Ard Biesheuvel <[email protected]>
Cc Lorenzo Pieralisi <[email protected]>

--->8

Will Deacon (3):
arm64: mm: Remove unused support for Device-GRE memory type
arm64: acpi: Map EFI_MEMORY_WT memory as Normal-NC
arm64: mm: Remove unused support for Normal-WT memory type

 arch/arm64/include/asm/memory.h       |  6 ++----
 arch/arm64/include/asm/pgtable-prot.h |  1 -
 arch/arm64/include/asm/sysreg.h       |  2 --
 arch/arm64/kernel/acpi.c              | 10 +++-------
 arch/arm64/mm/proc.S                  |  2 --
 arch/arm64/mm/ptdump.c                |  4 ----
 6 files changed, 5 insertions(+), 20 deletions(-)
Signature · 7 lines
2.31.1.607.g51e8a6a459-goog


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
author maintainer
#1 lore raw

PATCH 1/3 arm64: mm: Remove unused support for Device-GRE memory type

The Device-GRE memory type is unused, so remove it and reclaim a MAIR.

---
 arch/arm64/include/asm/memory.h | 1 -
 arch/arm64/include/asm/sysreg.h | 1 -
 arch/arm64/mm/proc.S            | 1 -
 arch/arm64/mm/ptdump.c          | 4 ----
 4 files changed, 7 deletions(-)
arch/arm64/include/asm/memory.h +0 -1
index 15018dc59554..ea268be37ea2 100644
@@ -138,7 +138,6 @@
 #define MT_NORMAL_WT		3
 #define MT_DEVICE_nGnRnE	4
 #define MT_DEVICE_nGnRE		5
-#define MT_DEVICE_GRE		6
 
 /*
  * Memory types for Stage-2 translation
arch/arm64/include/asm/sysreg.h +0 -1
index b31ac5ccc8ab..aa8e53dd8686 100644
@@ -651,7 +651,6 @@
 /* MAIR_ELx memory attributes (used by Linux) */
 #define MAIR_ATTR_DEVICE_nGnRnE		UL(0x00)
 #define MAIR_ATTR_DEVICE_nGnRE		UL(0x04)
-#define MAIR_ATTR_DEVICE_GRE		UL(0x0c)
 #define MAIR_ATTR_NORMAL_NC		UL(0x44)
 #define MAIR_ATTR_NORMAL_WT		UL(0xbb)
 #define MAIR_ATTR_NORMAL_TAGGED		UL(0xf0)
arch/arm64/mm/proc.S +0 -1
index 0a48191534ff..be6e5d1e3673 100644
@@ -58,7 +58,6 @@
 #define MAIR_EL1_SET							\
 	(MAIR_ATTRIDX(MAIR_ATTR_DEVICE_nGnRnE, MT_DEVICE_nGnRnE) |	\
 	 MAIR_ATTRIDX(MAIR_ATTR_DEVICE_nGnRE, MT_DEVICE_nGnRE) |	\
-	 MAIR_ATTRIDX(MAIR_ATTR_DEVICE_GRE, MT_DEVICE_GRE) |		\
 	 MAIR_ATTRIDX(MAIR_ATTR_NORMAL_NC, MT_NORMAL_NC) |		\
 	 MAIR_ATTRIDX(MAIR_ATTR_NORMAL, MT_NORMAL) |			\
 	 MAIR_ATTRIDX(MAIR_ATTR_NORMAL_WT, MT_NORMAL_WT) |		\
arch/arm64/mm/ptdump.c +0 -4
index a1937dfff31c..1c403536c9bb 100644
@@ -157,10 +157,6 @@ static const struct prot_bits pte_bits[] = {
 		.mask	= PTE_ATTRINDX_MASK,
 		.val	= PTE_ATTRINDX(MT_DEVICE_nGnRE),
 		.set	= "DEVICE/nGnRE",
-	}, {
-		.mask	= PTE_ATTRINDX_MASK,
-		.val	= PTE_ATTRINDX(MT_DEVICE_GRE),
-		.set	= "DEVICE/GRE",
 	}, {
 		.mask	= PTE_ATTRINDX_MASK,
 		.val	= PTE_ATTRINDX(MT_NORMAL_NC),
Signature · 7 lines
2.31.1.607.g51e8a6a459-goog


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
maintainer Acked-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] arm64: mm: Remove unused support for Device-GRE memory type

Quoted 6 lines · Will Deacon

The Device-GRE memory type is unused, so remove it and reclaim a MAIR.

(unless you want me to queue them as clean-ups for 5.13)

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

author maintainer
#3 lore raw

PATCH 2/3 arm64: acpi: Map EFI_MEMORY_WT memory as Normal-NC

In reply to Will Deacon

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.

Cc Ard Biesheuvel <[email protected]>
Cc Lorenzo Pieralisi <[email protected]>
Cc Christoph Hellwig <[email protected]>
---
 arch/arm64/kernel/acpi.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
arch/arm64/kernel/acpi.c +3 -7
index cada0b816c8a..aca5ee2a9e64 100644
@@ -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);
 		}
 	}
Signature · 7 lines
2.31.1.607.g51e8a6a459-goog


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Acked-by on v1 2/3
#4 lore raw

Re: [PATCH 2/3] arm64: acpi: Map EFI_MEMORY_WT memory as Normal-NC

Quoted 11 lines · Will Deacon

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.

Cc Ard Biesheuvel <[email protected]>
Cc Lorenzo Pieralisi <[email protected]>
Cc Christoph Hellwig <[email protected]>

I don't have any objections to this change per se, but I will point out that the UEFI spec describes the MAIR encodings, paragraph 2.3.6.1 (in revision 2.8B). However, the paragraph in question provides no context whatsoever, and so it is not clear whether it is normative, and whether it applies to the boot time firmware only or to the OS as well.

So in summary, given that EFI_MEMORY_WT (which I have never seen being used on ARM) should behave as expected when using the same MAIR attributes as EFI_MEMORY_WC, with only a theoretical performance impact, the change looks reasonable to me.

Quoted 40 lines
---
 arch/arm64/kernel/acpi.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
arch/arm64/kernel/acpi.c +3 -8
index cada0b816c8a..aca5ee2a9e64 100644
@@ -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);
                }
        }
--
Quoted 2 lines

2.31.1.607.g51e8a6a459-goog

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

maintainer Acked-by
#5 lore raw

Re: [PATCH 2/3] arm64: acpi: Map EFI_MEMORY_WT memory as Normal-NC

Quoted 20 lines · Ard Biesheuvel
Quoted 11 lines · Will Deacon

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.

Cc Ard Biesheuvel <[email protected]>
Cc Lorenzo Pieralisi <[email protected]>
Cc Christoph Hellwig <[email protected]>

I don't have any objections to this change per se, but I will point out that the UEFI spec describes the MAIR encodings, paragraph 2.3.6.1 (in revision 2.8B). However, the paragraph in question provides no context whatsoever, and so it is not clear whether it is normative, and whether it applies to the boot time firmware only or to the OS as well.

Quoted 4 lines

So in summary, given that EFI_MEMORY_WT (which I have never seen being used on ARM) should behave as expected when using the same MAIR attributes as EFI_MEMORY_WC, with only a theoretical performance impact, the change looks reasonable to me.

In theory there's a slight difference between WT and WC/Normal-NC as reads are allowed to hit into the cache while for WC/Normal-NC they aren't (somehow implied on page B2-168 in the ARMv8 ARM G.a). Whether they must hit in the cache is not entirely clear, I don't think they have to. The mismatched aliases section doesn't guarantee coherency between accesses using different WC and WB attributes (point 1, attributes must be the same for both reads and writes). Appendix K4.1.1 also suggest that WT could be implemented as Normal-NC.

So I don't think EFI can rely on any specific WT behaviour other than maybe slightly better performance.

So:

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#6 lore raw

Re: [PATCH 2/3] arm64: acpi: Map EFI_MEMORY_WT memory as Normal-NC

Quoted 36 lines · Catalin Marinas
Quoted 20 lines · Ard Biesheuvel
Quoted 11 lines · Will Deacon

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.

Cc Ard Biesheuvel <[email protected]>
Cc Lorenzo Pieralisi <[email protected]>
Cc Christoph Hellwig <[email protected]>

I don't have any objections to this change per se, but I will point out that the UEFI spec describes the MAIR encodings, paragraph 2.3.6.1 (in revision 2.8B). However, the paragraph in question provides no context whatsoever, and so it is not clear whether it is normative, and whether it applies to the boot time firmware only or to the OS as well.

Quoted 4 lines

So in summary, given that EFI_MEMORY_WT (which I have never seen being used on ARM) should behave as expected when using the same MAIR attributes as EFI_MEMORY_WC, with only a theoretical performance impact, the change looks reasonable to me.

In theory there's a slight difference between WT and WC/Normal-NC as reads are allowed to hit into the cache while for WC/Normal-NC they aren't (somehow implied on page B2-168 in the ARMv8 ARM G.a). Whether they must hit in the cache is not entirely clear, I don't think they have to. The mismatched aliases section doesn't guarantee coherency between accesses using different WC and WB attributes (point 1, attributes must be the same for both reads and writes). Appendix K4.1.1 also suggest that WT could be implemented as Normal-NC.

Quoted 3 lines

So I don't think EFI can rely on any specific WT behaviour other than maybe slightly better performance.

For the record, this mostly affects mappings created by the ACPI core, for things like RAS handling in firmware. EFI itself is not really a part of this, but given that ACPI lacks any way to annotate memory types for OpRegions (as x86 does not need this), we cross reference ACPI memory map requests with the EFI memory map to infer the right type.

For RAS in particular, I can see how firmware might rely on non-cacheable behavior for correctness (e.g., for publishing error records in a way that ensures they are visible to other agents, such as a BMC), but I still don't think treating WT as WC will make a material difference here.

Quoted 3 lines

So:

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

reviewer
#7 lore raw

Re: [PATCH 2/3] arm64: acpi: Map EFI_MEMORY_WT memory as Normal-NC

In reply to Will Deacon
Quoted 5 lines · Will Deacon

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.

Quoted 52 lines
Cc Ard Biesheuvel <[email protected]>
Cc Lorenzo Pieralisi <[email protected]>
Cc Christoph Hellwig <[email protected]>
---
 arch/arm64/kernel/acpi.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
arch/arm64/kernel/acpi.c +3 -7
index cada0b816c8a..aca5ee2a9e64 100644
@@ -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);
 		}
 	}
Signature · 7 lines
2.31.1.607.g51e8a6a459-goog


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

author maintainer
#8 lore raw

Re: [PATCH 2/3] arm64: acpi: Map EFI_MEMORY_WT memory as Normal-NC

Quoted 9 lines · Mark Rutland
Quoted 5 lines · Will Deacon

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).

I wonder if they just did that because the names match :(

Quoted 11 lines

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.

At the same time, allocating a MAIR for this memory type just because the UEFI spec permits some theoretical future firmware to use it on some theoretical CPU design is pretty farcical in my opinion. Looking through current TRMs I've not been able to find a CPU that doesn't just emit Normal-NC for this memory type.

How about I add a pr_warn() in this case, so that we can revisit it in the unlikely event that it ever comes up as an issue?

Will

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

reviewer
#9 lore raw

Re: [PATCH 2/3] arm64: acpi: Map EFI_MEMORY_WT memory as Normal-NC

Quoted 25 lines · Will Deacon
Quoted 9 lines · Mark Rutland
Quoted 5 lines · Will Deacon

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).

I wonder if they just did that because the names match :(

Quoted 11 lines

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.

Quoted 8 lines

At the same time, allocating a MAIR for this memory type just because the UEFI spec permits some theoretical future firmware to use it on some theoretical CPU design is pretty farcical in my opinion. Looking through current TRMs I've not been able to find a CPU that doesn't just emit Normal-NC for this memory type.

How about I add a pr_warn() in this case, so that we can revisit it in the unlikely event that it ever comes up as an issue?

If we also could avoid mapping EFI_MEMORY_WT to anything, that'd be nicer, but just the warning is probably good enough, yes.

Thanks,
Mark.

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#10 lore raw

Re: [PATCH 2/3] arm64: acpi: Map EFI_MEMORY_WT memory as Normal-NC

Quoted 33 lines · Mark Rutland
Quoted 31 lines · Will Deacon
Quoted 9 lines · Mark Rutland
Quoted 5 lines · Will Deacon

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).

I wonder if they just did that because the names match :(

Quoted 11 lines

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.

At the same time, allocating a MAIR for this memory type just because the UEFI spec permits some theoretical future firmware to use it on some theoretical CPU design is pretty farcical in my opinion. Looking through current TRMs I've not been able to find a CPU that doesn't just emit Normal-NC for this memory type.

Quoted 6 lines
Quoted 2 lines

How about I add a pr_warn() in this case, so that we can revisit it in the unlikely event that it ever comes up as an issue?

If we also could avoid mapping EFI_MEMORY_WT to anything, that'd be nicer, but just the warning is probably good enough, yes.

EFI memory types are not exclusive. Most implementations use WB|WT|WC for all memory, and some even use WB|WT|WC|UC, which means that the OS can use whichever attributes it wants.

So we should only warn in cases where WT is specified but WC is not, and I've never seen firmware that does this.

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

author maintainer
#11 lore raw

PATCH 3/3 arm64: mm: Remove unused support for Normal-WT memory type

In reply to Will Deacon

The Normal-WT memory type is unused, so remove it and reclaim a MAIR.

Cc Christoph Hellwig <[email protected]>
---
 arch/arm64/include/asm/memory.h       | 5 ++---
 arch/arm64/include/asm/pgtable-prot.h | 1 -
 arch/arm64/include/asm/sysreg.h       | 1 -
 arch/arm64/mm/proc.S                  | 1 -
 4 files changed, 2 insertions(+), 6 deletions(-)
arch/arm64/include/asm/memory.h +2 -3
index ea268be37ea2..865fa2ab51b2 100644
@@ -135,9 +135,8 @@
 #define MT_NORMAL		0
 #define MT_NORMAL_TAGGED	1
 #define MT_NORMAL_NC		2
-#define MT_NORMAL_WT		3
-#define MT_DEVICE_nGnRnE	4
-#define MT_DEVICE_nGnRE		5
+#define MT_DEVICE_nGnRnE	3
+#define MT_DEVICE_nGnRE		4
 
 /*
  * Memory types for Stage-2 translation
arch/arm64/include/asm/pgtable-prot.h +0 -1
index fab2f573f7a4..8923c9b119ae 100644
@@ -55,7 +55,6 @@ extern bool arm64_use_ng_mappings;
 #define PROT_DEVICE_nGnRnE	(PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_WRITE | PTE_ATTRINDX(MT_DEVICE_nGnRnE))
 #define PROT_DEVICE_nGnRE	(PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_WRITE | PTE_ATTRINDX(MT_DEVICE_nGnRE))
 #define PROT_NORMAL_NC		(PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_WRITE | PTE_ATTRINDX(MT_NORMAL_NC))
-#define PROT_NORMAL_WT		(PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_WRITE | PTE_ATTRINDX(MT_NORMAL_WT))
 #define PROT_NORMAL		(PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_WRITE | PTE_ATTRINDX(MT_NORMAL))
 #define PROT_NORMAL_TAGGED	(PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_WRITE | PTE_ATTRINDX(MT_NORMAL_TAGGED))
 
arch/arm64/include/asm/sysreg.h +0 -1
index aa8e53dd8686..ec27455d2a44 100644
@@ -652,7 +652,6 @@
 #define MAIR_ATTR_DEVICE_nGnRnE		UL(0x00)
 #define MAIR_ATTR_DEVICE_nGnRE		UL(0x04)
 #define MAIR_ATTR_NORMAL_NC		UL(0x44)
-#define MAIR_ATTR_NORMAL_WT		UL(0xbb)
 #define MAIR_ATTR_NORMAL_TAGGED		UL(0xf0)
 #define MAIR_ATTR_NORMAL		UL(0xff)
 #define MAIR_ATTR_MASK			UL(0xff)
arch/arm64/mm/proc.S +0 -1
index be6e5d1e3673..c2d57eb0e671 100644
@@ -60,7 +60,6 @@
 	 MAIR_ATTRIDX(MAIR_ATTR_DEVICE_nGnRE, MT_DEVICE_nGnRE) |	\
 	 MAIR_ATTRIDX(MAIR_ATTR_NORMAL_NC, MT_NORMAL_NC) |		\
 	 MAIR_ATTRIDX(MAIR_ATTR_NORMAL, MT_NORMAL) |			\
-	 MAIR_ATTRIDX(MAIR_ATTR_NORMAL_WT, MT_NORMAL_WT) |		\
 	 MAIR_ATTRIDX(MAIR_ATTR_NORMAL, MT_NORMAL_TAGGED))
 
 #ifdef CONFIG_CPU_PM
Signature · 7 lines
2.31.1.607.g51e8a6a459-goog


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
maintainer Acked-by on v1 3/3
#12 lore raw

Re: [PATCH 3/3] arm64: mm: Remove unused support for Normal-WT memory type

Quoted 4 lines · Will Deacon

The Normal-WT memory type is unused, so remove it and reclaim a MAIR.

Cc Christoph Hellwig <[email protected]>

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel