@@ -79,7 +79,8 @@ The decompressed kernel image contains a 64-byte header as follows::
u64 text_offset; /* Image load offset, little endian */
u64 image_size; /* Effective Image size, little endian */
u64 flags; /* kernel flags, little endian */
- u64 res2 = 0; /* reserved */
+ u32 code_size; /* Image code size, little endian */
+ u32 res2 = 0; /* reserved */
u64 res3 = 0; /* reserved */
u64 res4 = 0; /* reserved */
u32 magic = 0x644d5241; /* Magic number, little endian, "ARM\x64" */
@@ -47,7 +47,8 @@ struct arm64_image_header {
__le64 text_offset;
__le64 image_size;
__le64 flags;
- __le64 res2;
+ __le32 code_size;
+ __le32 res2;
__le64 res3;
__le64 res4;
__le32 magic;
@@ -62,7 +62,8 @@
.quad 0 // Image load offset from start of RAM, little-endian
le64sym _kernel_size_le // Effective size of kernel image, little-endian
le64sym _kernel_flags_le // Informative flags, little-endian
- .quad 0 // reserved
+ .long _kernel_codesize_le // Size of leading text/rodata/inittext region, LE
+ .long 0 // reserved
.quad 0 // reserved
.quad 0 // reserved
.ascii ARM64_IMAGE_MAGIC // Magic number
@@ -34,6 +34,9 @@
#define DATA_LE32(data) ((data) & 0xffffffff)
#endif
+#define DEFINE_IMAGE_LE32(sym, data) \
+ sym = DATA_LE32((data) & 0xffffffff)
+
#define DEFINE_IMAGE_LE64(sym, data) \
sym##_lo32 = DATA_LE32((data) & 0xffffffff); \
sym##_hi32 = DATA_LE32((data) >> 32)
@@ -60,8 +63,9 @@
* regardless of the endianness of the kernel. While constant values could be
* endian swapped in head.S, all are done here for consistency.
*/
-#define HEAD_SYMBOLS \
- DEFINE_IMAGE_LE64(_kernel_size_le, _end - _text); \
- DEFINE_IMAGE_LE64(_kernel_flags_le, __HEAD_FLAGS);
+#define HEAD_SYMBOLS \
+ DEFINE_IMAGE_LE64(_kernel_size_le, _end - _text); \
+ DEFINE_IMAGE_LE64(_kernel_flags_le, __HEAD_FLAGS); \
+ DEFINE_IMAGE_LE32(_kernel_codesize_le, __initdata_begin - _text);
#endif /* __ARM64_KERNEL_IMAGE_H */
In order for loaders to be able to create a preliminary mapping of the image without having to rely on mappings that have both write and execute permissions, it is necessary to expose the size of the leading part of the image consisting of .text, .rodata and .inittext. So add this information to the arm64 bare metal boot header. Signed-off-by: Ard Biesheuvel <ardb@kernel.org> --- Documentation/arm64/booting.rst | 3 ++- arch/arm64/include/asm/image.h | 3 ++- arch/arm64/kernel/head.S | 3 ++- arch/arm64/kernel/image.h | 10 +++++++--- 4 files changed, 13 insertions(+), 6 deletions(-)