Skip to contentSkip to conversation

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

PATCH In review Ard Biesheuvel 2 participants 4 messages Nov 14, 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 repaint bit #3 in the Image header as 'must be placed within 48-bit addressable memory', as this is the current de facto meaning, and add bits that we may set later to allow placement outside of that.

---
 Documentation/arm64/booting.rst | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
Documentation/arm64/booting.rst +7 -2
index 8c324ad638de2b27..9919e1a107add655 100644
@@ -114,16 +114,21 @@ Header notes:
 			* 1 - 4K
 			* 2 - 16K
 			* 3 - 64K
-  Bit 3		Kernel physical placement
+  Bit 3-4	Kernel physical placement
 
 			0
 			  2MB aligned base should be as close as possible
 			  to the base of DRAM, since memory below it is not
 			  accessible via the linear mapping
 			1
+			  2MB aligned base such that base plus image_size is
+			  entirely within the 48-bit addressable range
+			2
+			  Reserved
+			3
 			  2MB aligned base may be anywhere in physical
 			  memory
-  Bits 4-63	Reserved.
+  Bits 5-63	Reserved.
   ============= ===============================================================
 
 - When image_size is zero, a bootloader should attempt to keep as much
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 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 8 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.

So repaint bit #3 in the Image header as 'must be placed within 48-bit addressable memory', as this is the current de facto meaning, and add bits that we may set later to allow placement outside of that.

Could we just clean up the definition of bit 3 for now, then add the other bits when we actually set them?

Quoted 14 lines
---
 Documentation/arm64/booting.rst | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
Documentation/arm64/booting.rst +0 -0
index 8c324ad638de2b27..9919e1a107add655 100644
@@ -114,16 +114,21 @@ Header notes:
 			* 1 - 4K
 			* 2 - 16K
 			* 3 - 64K

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

Quoted 10 lines
Documentation/arm64/booting.rst +3 -1
-  Bit 3		Kernel physical placement
+  Bit 3-4	Kernel physical placement
 
 			0
 			  2MB aligned base should be as close as possible
 			  to the base of DRAM, since memory below it is not
 			  accessible via the linear mapping
 			1
+			  2MB aligned base such that base plus image_size is
+			  entirely within the 48-bit addressable range

This seems to assume text_offset is zero (which is the case today, but this is the first part of booting.txt that assumes that); as a matter of policy are we sure that we'll never use a non-zero offset again? If so, we probably want to mention that in the "header notes" section, or come up with some wording to include it here.

Otherwise, this looks good; I'm certainly in favour of explicitly mentioning the 48-bit restriction.

Thanks,
Mark.

Quoted 13 lines
Documentation/arm64/booting.rst +4 -1
+			2
+			  Reserved
+			3
 			  2MB aligned base may be anywhere in physical
 			  memory
-  Bits 4-63	Reserved.
+  Bits 5-63	Reserved.
   ============= ===============================================================
 
 - When image_size is zero, a bootloader should attempt to keep as much
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
Quoted 13 lines · Mark Rutland
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 3 lines

So repaint bit #3 in the Image header as 'must be placed within 48-bit addressable memory', as this is the current de facto meaning, and add bits that we may set later to allow placement outside of that.

Could we just clean up the definition of bit 3 for now, then add the other bits when we actually set them?

Sure

Quoted 17 lines
Quoted 17 lines
---
 Documentation/arm64/booting.rst | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
Documentation/arm64/booting.rst +1 -1
index 8c324ad638de2b27..9919e1a107add655 100644
@@ -114,16 +114,21 @@ Header notes:
                      * 1 - 4K
                      * 2 - 16K
                      * 3 - 64K
-  Bit 3              Kernel physical placement
+  Bit 3-4    Kernel physical placement
 
Quoted 14 lines

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

Quoted 7 lines
Documentation/arm64/booting.rst +2 -0
                      0
                        2MB aligned base should be as close as possible
                        to the base of DRAM, since memory below it is not
                        accessible via the linear mapping
                      1
+                       2MB aligned base such that base plus image_size is
+                       entirely within the 48-bit addressable range

This seems to assume text_offset is zero (which is the case today, but this is the first part of booting.txt that assumes that); as a matter of policy are we sure that we'll never use a non-zero offset again? If so, we probably want to mention that in the "header notes" section, or come up with some wording to include it here.

How about:

2MB aligned base such that all image_size bytes
counted from the start of the image are within
the 48-bit addressable range

?

Quoted 6 lines

Otherwise, this looks good; I'm certainly in favour of explicitly mentioning the 48-bit restriction.

Thanks,
Mark.

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

#3 lore raw
Quoted 20 lines · Ard Biesheuvel
Quoted 12 lines · Mark Rutland

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

Quoted 9 lines · Ard Biesheuvel
Documentation/arm64/booting.rst +3 -0
+  Bit 3-4    Kernel physical placement
 
                      0
                        2MB aligned base should be as close as possible
                        to the base of DRAM, since memory below it is not
                        accessible via the linear mapping
                      1
+                       2MB aligned base such that base plus image_size is
+                       entirely within the 48-bit addressable range
Quoted 6 lines

This seems to assume text_offset is zero (which is the case today, but this is the first part of booting.txt that assumes that); as a matter of policy are we sure that we'll never use a non-zero offset again? If so, we probably want to mention that in the "header notes" section, or come up with some wording to include it here.

Quoted 7 lines

How about:

2MB aligned base such that all image_size bytes
counted from the start of the image are within
the 48-bit addressable range

?

Sounds good to me, thanks!

Mark.

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