Skip to contentSkip to conversation

arm64: booting: Require placement within 48-bit addressable memory

PATCH Applied Ard Biesheuvel 4 participants 8 messages Nov 22, 2022 – Nov 30, 2022 Documentation

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm64: booting: Require placement within 48-bit addressable memory

Some configurations (i.e., 64k + LVA/LPA) can tolerate a physical placement of the kernel image outside of the 48-bit addressable region, but given that the loader has no way of knowing whether or not the image in question supports LVA/LPA, it currently has no choice but to place it below the 48-bit mark.

Once we add support for LPA2, which allows 52-bit physical and virtual addressing when using 4k or 16k pages, but in way that relies on increasing the number of paging levels, there will be more variety in the configurations that may or may not support this.

So redefine bit #3 in the Image header as 'must be placed within 48-bit addressable memory', as this is the current de facto meaning.

---
 Documentation/arm64/booting.rst | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
Documentation/arm64/booting.rst +3 -2
index 8c324ad638de2b27..5a764fabfea821f0 100644
@@ -121,8 +121,9 @@ Header notes:
 			  to the base of DRAM, since memory below it is not
 			  accessible via the linear mapping
 			1
-			  2MB aligned base may be anywhere in physical
-			  memory
+			  2MB aligned base such that all image_size bytes
+			  counted from the start of the image are within
+			  the 48-bit addressable range of physical memory
   Bits 4-63	Reserved.
   ============= ===============================================================
 
Signature · 7 lines
2.35.1


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#1 lore raw
Quoted 12 lines · Ard Biesheuvel

Some configurations (i.e., 64k + LVA/LPA) can tolerate a physical placement of the kernel image outside of the 48-bit addressable region, but given that the loader has no way of knowing whether or not the image in question supports LVA/LPA, it currently has no choice but to place it below the 48-bit mark.

Once we add support for LPA2, which allows 52-bit physical and virtual addressing when using 4k or 16k pages, but in way that relies on increasing the number of paging levels, there will be more variety in the configurations that may or may not support this.

Quoted 5 lines

So redefine bit #3 in the Image header as 'must be placed within 48-bit addressable memory', as this is the current de facto meaning.

---

Note that this is a v2 addressing prior feedback from Mark.

Quoted 20 lines
 Documentation/arm64/booting.rst | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
Documentation/arm64/booting.rst +3 -3
index 8c324ad638de2b27..5a764fabfea821f0 100644
@@ -121,8 +121,9 @@ Header notes:
                          to the base of DRAM, since memory below it is not
                          accessible via the linear mapping
                        1
-                         2MB aligned base may be anywhere in physical
-                         memory
+                         2MB aligned base such that all image_size bytes
+                         counted from the start of the image are within
+                         the 48-bit addressable range of physical memory
   Bits 4-63    Reserved.
   ============= ===============================================================
 
--
Quoted 2 lines

2.35.1

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

Acked-by on v1 1/1
#4 lore raw
In reply to Ard Biesheuvel
Quoted 11 lines · Ard Biesheuvel

Some configurations (i.e., 64k + LVA/LPA) can tolerate a physical placement of the kernel image outside of the 48-bit addressable region, but given that the loader has no way of knowing whether or not the image in question supports LVA/LPA, it currently has no choice but to place it below the 48-bit mark.

Once we add support for LPA2, which allows 52-bit physical and virtual addressing when using 4k or 16k pages, but in way that relies on increasing the number of paging levels, there will be more variety in the configurations that may or may not support this.

Quoted 4 lines

So redefine bit #3 in the Image header as 'must be placed within 48-bit addressable memory', as this is the current de facto meaning.

Thanks for the respin!

Mark.

Quoted 23 lines
---
 Documentation/arm64/booting.rst | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
Documentation/arm64/booting.rst +3 -2
index 8c324ad638de2b27..5a764fabfea821f0 100644
@@ -121,8 +121,9 @@ Header notes:
 			  to the base of DRAM, since memory below it is not
 			  accessible via the linear mapping
 			1
-			  2MB aligned base may be anywhere in physical
-			  memory
+			  2MB aligned base such that all image_size bytes
+			  counted from the start of the image are within
+			  the 48-bit addressable range of physical memory
   Bits 4-63	Reserved.
   ============= ===============================================================
 
Signature · 1 line
2.35.1

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

#2 lore raw
In reply to Ard Biesheuvel
Quoted 13 lines · Ard Biesheuvel
Quoted 12 lines · Ard Biesheuvel

Some configurations (i.e., 64k + LVA/LPA) can tolerate a physical placement of the kernel image outside of the 48-bit addressable region, but given that the loader has no way of knowing whether or not the image in question supports LVA/LPA, it currently has no choice but to place it below the 48-bit mark.

Once we add support for LPA2, which allows 52-bit physical and virtual addressing when using 4k or 16k pages, but in way that relies on increasing the number of paging levels, there will be more variety in the configurations that may or may not support this.

Quoted 7 lines
Quoted 5 lines

So redefine bit #3 in the Image header as 'must be placed within 48-bit addressable memory', as this is the current de facto meaning.

---

Note that this is a v2 addressing prior feedback from Mark.

As you had mentioned earlier, currently [64K|52VA|52PA] can boot the vmlinux loaded beyond 48 bits PA. Why should not the kernel header flags be extended right away to support mentioned FEAT_LPA config and also let the kernel write update these extended flags when applicable. Why wait for FEAT_LPA2 ?

Quoted 20 lines
Quoted 20 lines
 Documentation/arm64/booting.rst | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
Documentation/arm64/booting.rst +3 -2
index 8c324ad638de2b27..5a764fabfea821f0 100644
@@ -121,8 +121,9 @@ Header notes:
                          to the base of DRAM, since memory below it is not
                          accessible via the linear mapping
                        1
-                         2MB aligned base may be anywhere in physical
-                         memory
+                         2MB aligned base such that all image_size bytes
+                         counted from the start of the image are within
+                         the 48-bit addressable range of physical memory
   Bits 4-63    Reserved.
   ============= ===============================================================
 
Quoted 8 lines
Quoted 3 lines

--
2.35.1

_______________________________________________
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

#3 lore raw
Quoted 23 lines · Anshuman Khandual
Quoted 19 lines · Ard Biesheuvel
Quoted 17 lines · Ard Biesheuvel

Some configurations (i.e., 64k + LVA/LPA) can tolerate a physical placement of the kernel image outside of the 48-bit addressable region, but given that the loader has no way of knowing whether or not the image in question supports LVA/LPA, it currently has no choice but to place it below the 48-bit mark.

Once we add support for LPA2, which allows 52-bit physical and virtual addressing when using 4k or 16k pages, but in way that relies on increasing the number of paging levels, there will be more variety in the configurations that may or may not support this.

So redefine bit #3 in the Image header as 'must be placed within 48-bit addressable memory', as this is the current de facto meaning.

---

Quoted 7 lines
Quoted 1 line

Note that this is a v2 addressing prior feedback from Mark.

As you had mentioned earlier, currently [64K|52VA|52PA] can boot the vmlinux loaded beyond 48 bits PA. Why should not the kernel header flags be extended right away to support mentioned FEAT_LPA config and also let the kernel write update these extended flags when applicable. Why wait for FEAT_LPA2 ?

I am not suggesting to wait for FEAT_LPA2.

I am suggesting to only support kernels loaded into 48 bit addressable physical memory. There is simply no point, as no system is likely to ever exist that relies on this, so this will be dead code that only ever gets tested if someone bothers to run it on a doctored emulator that has all its memory outside of that region.

By the same reasoning, there is really no point in updating the ID map extension code to account for this: that feature was specifically intended for being able to boot AMD seattle with a 39-bit VA 4k pages kernel at a time when the only alternative we had was 42-bit 64k pages. Also, given that LPA2 is defined as a single feature that covers both virtual and physical addressing up to 52 bits, and that the virtual addressing part requires the physical addressing part, I don't see a point in supporting 52-bit physical addressing without 52-bit virtual addressing, which means the ID map extension case simply ceases to exist for LPA2.

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

Reviewed-by on v1 1/1
#5 lore raw
In reply to Ard Biesheuvel
Quoted 11 lines · Ard Biesheuvel

Some configurations (i.e., 64k + LVA/LPA) can tolerate a physical placement of the kernel image outside of the 48-bit addressable region, but given that the loader has no way of knowing whether or not the image in question supports LVA/LPA, it currently has no choice but to place it below the 48-bit mark.

Once we add support for LPA2, which allows 52-bit physical and virtual addressing when using 4k or 16k pages, but in way that relies on increasing the number of paging levels, there will be more variety in the configurations that may or may not support this.

Quoted 5 lines

So redefine bit #3 in the Image header as 'must be placed within 48-bit addressable memory', as this is the current de facto meaning.

---

Regardless of possible vmlinux beyond 48 bits physical address discussion, this patch looks good, and complete in itself.

Quoted 9 lines
 Documentation/arm64/booting.rst | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
Documentation/arm64/booting.rst +0 -0
index 8c324ad638de2b27..5a764fabfea821f0 100644
@@ -121,8 +121,9 @@ Header notes:
 			  to the base of DRAM, since memory below it is not

Documentation/arm64/booting.rst Header notes: · line 129

Quoted 10 lines
Documentation/arm64/booting.rst +3 -2
 			  accessible via the linear mapping
 			1
-			  2MB aligned base may be anywhere in physical
-			  memory
+			  2MB aligned base such that all image_size bytes
+			  counted from the start of the image are within
+			  the 48-bit addressable range of physical memory
   Bits 4-63	Reserved.
   ============= ===============================================================
 

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

Applied
#6 lore raw
In reply to Ard Biesheuvel
Quoted 6 lines · Ard Biesheuvel

Some configurations (i.e., 64k + LVA/LPA) can tolerate a physical placement of the kernel image outside of the 48-bit addressable region, but given that the loader has no way of knowing whether or not the image in question supports LVA/LPA, it currently has no choice but to place it below the 48-bit mark.

Quoted 6 lines

Once we add support for LPA2, which allows 52-bit physical and virtual addressing when using 4k or 16k pages, but in way that relies on increasing the number of paging levels, there will be more variety in the configurations that may or may not support this.

[...]

Applied to arm64 (for-next/mm), thanks!

[1/1] arm64: booting: Require placement within 48-bit addressable memory

      https://git.kernel.org/arm64/c/453dfcee70c5

Cheers,

Signature · 10 lines
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#7 lore raw
Quoted 13 lines · Will Deacon
Quoted 11 lines · Ard Biesheuvel

Some configurations (i.e., 64k + LVA/LPA) can tolerate a physical placement of the kernel image outside of the 48-bit addressable region, but given that the loader has no way of knowing whether or not the image in question supports LVA/LPA, it currently has no choice but to place it below the 48-bit mark.

Once we add support for LPA2, which allows 52-bit physical and virtual addressing when using 4k or 16k pages, but in way that relies on increasing the number of paging levels, there will be more variety in the configurations that may or may not support this.

Quoted 7 lines
Quoted 1 line

[...]

Applied to arm64 (for-next/mm), thanks!

[1/1] arm64: booting: Require placement within 48-bit addressable memory

      https://git.kernel.org/arm64/c/453dfcee70c5

In the discussion with Ryan Roberts regarding my LPA2 series, it became clear that this necessarily applies to the FDT and initrd as well, given that the bootloader must not assume that the kernel can access anything residing beyond the 48-bit PA limit.

Unless anyone disagrees with that, I'll prepare a follow up patch to clarify this too.

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