Skip to contentSkip to conversation

arm64: expose kernel page size in Image header flags

PATCH New Ard Biesheuvel 3 participants 4 messages Sep 17, 2015 – Sep 18, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm64: expose kernel page size in Image header flags

In order for a bootloader to be able to decide whether a certain arm64 kernel image is compatible with the hardware it is running on, it needs to be able to find out for which page size the kernel was built. This is necessary, since the architecture does not mandate support for all page sizes it defines, and the kernel cannot boot to a state where it can print a diagnostic if it was built for a page size that is not supported by the hardware.

So assign two bits in the flags field of the Image header, and set them according to the build time page size. For backward compatibility, retain the 0b00 value as 'unspecified'.

---
 Documentation/arm64/booting.txt | 3 ++-
 arch/arm64/kernel/image.h       | 4 +++-
 2 files changed, 5 insertions(+), 2 deletions(-)
Documentation/arm64/booting.txt +2 -1
index 1690350f16e7..46056e7d766e 100644
@@ -104,7 +104,8 @@ Header notes:
 - The flags field (introduced in v3.17) is a little-endian 64-bit field
   composed as follows:
   Bit 0: 	Kernel endianness.  1 if BE, 0 if LE.
-  Bits 1-63:	Reserved.
+  Bits 1-2:	Kernel page size.   0=unspecified, 1=4K, 2=16K, 3=64K
+  Bits 3-63:	Reserved.
 
 - When image_size is zero, a bootloader should attempt to keep as much
   memory as possible free for use by the kernel immediately after the
arch/arm64/kernel/image.h +3 -1
index 8fae0756e175..5def289bda84 100644
@@ -47,7 +47,9 @@
 #define __HEAD_FLAG_BE	0
 #endif
 
-#define __HEAD_FLAGS	(__HEAD_FLAG_BE << 0)
+#define __HEAD_FLAG_PAGE_SIZE ((PAGE_SHIFT - 10) / 2)
+
+#define __HEAD_FLAGS	(__HEAD_FLAG_BE << 0) | (__HEAD_FLAG_PAGE_SIZE << 1)
 
 /*
  * These will output as part of the Image header, which should be little-endian
Signature · 1 line
1.9.1
reviewer
#1 lore raw

PATCH 1/1 arm64: expose kernel page size in Image header flags

Quoted 8 lines · Ard Biesheuvel

In order for a bootloader to be able to decide whether a certain arm64 kernel image is compatible with the hardware it is running on, it needs to be able to find out for which page size the kernel was built. This is necessary, since the architecture does not mandate support for all page sizes it defines, and the kernel cannot boot to a state where it can print a diagnostic if it was built for a page size that is not supported by the hardware.

Quoted 6 lines

So assign two bits in the flags field of the Image header, and set them according to the build time page size. For backward compatibility, retain the 0b00 value as 'unspecified'.

This looks sane to me.

FWIW: Acked-by: Mark Rutland <[email protected]>

Thanks,
Mark.

Quoted 37 lines
---
 Documentation/arm64/booting.txt | 3 ++-
 arch/arm64/kernel/image.h       | 4 +++-
 2 files changed, 5 insertions(+), 2 deletions(-)
Documentation/arm64/booting.txt +2 -1
index 1690350f16e7..46056e7d766e 100644
@@ -104,7 +104,8 @@ Header notes:
 - The flags field (introduced in v3.17) is a little-endian 64-bit field
   composed as follows:
   Bit 0: 	Kernel endianness.  1 if BE, 0 if LE.
-  Bits 1-63:	Reserved.
+  Bits 1-2:	Kernel page size.   0=unspecified, 1=4K, 2=16K, 3=64K
+  Bits 3-63:	Reserved.
 
 - When image_size is zero, a bootloader should attempt to keep as much
   memory as possible free for use by the kernel immediately after the
arch/arm64/kernel/image.h +3 -1
index 8fae0756e175..5def289bda84 100644
@@ -47,7 +47,9 @@
 #define __HEAD_FLAG_BE	0
 #endif
 
-#define __HEAD_FLAGS	(__HEAD_FLAG_BE << 0)
+#define __HEAD_FLAG_PAGE_SIZE ((PAGE_SHIFT - 10) / 2)
+
+#define __HEAD_FLAGS	(__HEAD_FLAG_BE << 0) | (__HEAD_FLAG_PAGE_SIZE << 1)
 
 /*
  * These will output as part of the Image header, which should be little-endian
Signature · 1 line
1.9.1
#2 lore raw

PATCH 1/1 arm64: expose kernel page size in Image header flags

In reply to Ard Biesheuvel
Quoted 8 lines · Ard Biesheuvel

In order for a bootloader to be able to decide whether a certain arm64 kernel image is compatible with the hardware it is running on, it needs to be able to find out for which page size the kernel was built. This is necessary, since the architecture does not mandate support for all page sizes it defines, and the kernel cannot boot to a state where it can print a diagnostic if it was built for a page size that is not supported by the hardware.

Quoted 6 lines

So assign two bits in the flags field of the Image header, and set them according to the build time page size. For backward compatibility, retain the 0b00 value as 'unspecified'.

Ard,

I picked this patch based on the our initial discussion on 16K page size series, and added it to the V2 of the series.

	https://lkml.org/lkml/2015/9/15/716
Quoted 24 lines
---
  Documentation/arm64/booting.txt | 3 ++-
  arch/arm64/kernel/image.h       | 4 +++-
  2 files changed, 5 insertions(+), 2 deletions(-)
Documentation/arm64/booting.txt +2 -1
index 1690350f16e7..46056e7d766e 100644
@@ -104,7 +104,8 @@ Header notes:
  - The flags field (introduced in v3.17) is a little-endian 64-bit field
    composed as follows:
    Bit 0: 	Kernel endianness.  1 if BE, 0 if LE.
-  Bits 1-63:	Reserved.
+  Bits 1-2:	Kernel page size.   0=unspecified, 1=4K, 2=16K, 3=64K
+  Bits 3-63:	Reserved.
 
  - When image_size is zero, a bootloader should attempt to keep as much
    memory as possible free for use by the kernel immediately after the
arch/arm64/kernel/image.h +0 -0
index 8fae0756e175..5def289bda84 100644

arch/arm64/kernel/image.h line 53

Quoted 8 lines
arch/arm64/kernel/image.h +3 -1
@@ -47,7 +47,9 @@
  #define __HEAD_FLAG_BE	0
  #endif
 
-#define __HEAD_FLAGS	(__HEAD_FLAG_BE << 0)
+#define __HEAD_FLAG_PAGE_SIZE ((PAGE_SHIFT - 10) / 2)
+
+#define __HEAD_FLAGS	(__HEAD_FLAG_BE << 0) | (__HEAD_FLAG_PAGE_SIZE << 1)
 

FWIW,

Thanks
Suzuki

#3 lore raw

PATCH 1/1 arm64: expose kernel page size in Image header flags

Quoted 18 lines · Suzuki K. Poulose
Quoted 9 lines · Ard Biesheuvel

In order for a bootloader to be able to decide whether a certain arm64 kernel image is compatible with the hardware it is running on, it needs to be able to find out for which page size the kernel was built. This is necessary, since the architecture does not mandate support for all page sizes it defines, and the kernel cannot boot to a state where it can print a diagnostic if it was built for a page size that is not supported by the hardware.

Quoted 6 lines

So assign two bits in the flags field of the Image header, and set them according to the build time page size. For backward compatibility, retain the 0b00 value as 'unspecified'.

Quoted 7 lines

Ard,

I picked this patch based on the our initial discussion on 16K page size series, and added it to the V2 of the series.

        https://lkml.org/lkml/2015/9/15/716

Ah, I missed that, sorry.

I don't care which version makes it eventually,

Quoted 39 lines
Quoted 27 lines

---
  Documentation/arm64/booting.txt | 3 ++-
  arch/arm64/kernel/image.h       | 4 +++-
  2 files changed, 5 insertions(+), 2 deletions(-)
Documentation/arm64/booting.txt +2 -1
index 1690350f16e7..46056e7d766e 100644
@@ -104,7 +104,8 @@ Header notes:
  - The flags field (introduced in v3.17) is a little-endian 64-bit field
    composed as follows:
    Bit 0:      Kernel endianness.  1 if BE, 0 if LE.
-  Bits 1-63:   Reserved.
+  Bits 1-2:    Kernel page size.   0=unspecified, 1=4K, 2=16K, 3=64K
+  Bits 3-63:   Reserved.
 
  - When image_size is zero, a bootloader should attempt to keep as much
    memory as possible free for use by the kernel immediately after the
arch/arm64/kernel/image.h +0 -0
index 8fae0756e175..5def289bda84 100644

arch/arm64/kernel/image.h line 54

Quoted 9 lines
arch/arm64/kernel/image.h +3 -1
@@ -47,7 +47,9 @@
  #define __HEAD_FLAG_BE        0
  #endif
 
-#define __HEAD_FLAGS   (__HEAD_FLAG_BE << 0)
+#define __HEAD_FLAG_PAGE_SIZE ((PAGE_SHIFT - 10) / 2)
+
+#define __HEAD_FLAGS   (__HEAD_FLAG_BE << 0) | (__HEAD_FLAG_PAGE_SIZE <<
 1)
 

FWIW,

Quoted 2 lines

Thank you,
Ard.