forked from Minki/linux
Urgent RISC-V fix for v5.3
Last week, Palmer and I learned that there was an error in the RISC-V kernel image header format that could make it less compatible with the ARM64 kernel image header format. I had missed this error during my original reviews of the patch. The kernel image header format is an interface that impacts bootloaders, QEMU, and other user tools. Those packages must be updated to align with whatever is merged in the kernel. We would like to avoid proliferating these image formats by keeping the RISC-V header as close as possible to the existing ARM64 header. Since the arch/riscv patch that adds support for the image header was merged with our v5.3-rc1 pull request as commit0f327f2aaa
("RISC-V: Add an Image header that boot loader can parse."), we think it wise to try to fix this error before v5.3 is released. The fix itself should be backwards-compatible with any project that has already merged support for premature versions of this interface. It primarily involves ensuring that the RISC-V image header has something useful in the same field as the ARM64 image header. -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEElRDoIDdEz9/svf2Kx4+xDQu9KksFAl1870sACgkQx4+xDQu9 Kkt33A//SG4fTIyz0rIGTZpJPKV3nXacBq6XvOFxFsHRHlEvD2f/JkSK1Ab+hV5R vmTkVGCSCVz1C/OEA+KWsjuiJEglII6eOLIRqST1Wm6KumwAwLc78xdgEb1Sm/SC E7OTYtSqbUjCqzzD1BFcXfbP4mGF/9IBjWI3OcCnb1UcLuL29Mt35gvxI9fF1FB6 +EU96MBQbk4gVUYjKXObTvaAZwWIYrMkOFQmdRgb4jqk42i0hLmKx//WkI1Ajlp8 FDjE2nIo2NAt0N7pImJ/QtqxkOsQjMtOyOscoTyhB4eGJW0+fTyVrt6FpUdYQDQq vZI/WS2RFYUi2wfj+JNQ959MgsWZZ8z21KbFWwR0HC4k2xRZaxCO48g/VweJA/QW 3f6+CMxYgwF5KzToHvUjlo0wNMW2Xo/FX9bky3gb8rJPWnSx9uu9lfoh17FUD4Ty cEknaLtmMALA8Lgr8hwTKbZLg7J1ih5r1SPj0UvjpjEmwDUl2doA0EONuuBroEHM KDerGitg6D0g4B4VlGsHuLMd6Gj/5r2teno97tPoaf5J9mCZ1v2/Q5OL0QwBYd84 5cp+Ox1aQTY6SJq8gftBOD3MmW2lKCC5tT6H0bJvKBAE7tJaLPv5YIj6dp1jfXKB klzJUdGRsL60EwlL/cbFOurDfhBeQlq8akdzG5Cg5e8q+mISSTE= =Jt6U -----END PGP SIGNATURE----- Merge tag 'riscv/for-v5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux Pull RISC-V fix from Paul Walmsley: "Last week, Palmer and I learned that there was an error in the RISC-V kernel image header format that could make it less compatible with the ARM64 kernel image header format. I had missed this error during my original reviews of the patch. The kernel image header format is an interface that impacts bootloaders, QEMU, and other user tools. Those packages must be updated to align with whatever is merged in the kernel. We would like to avoid proliferating these image formats by keeping the RISC-V header as close as possible to the existing ARM64 header. Since the arch/riscv patch that adds support for the image header was merged with our v5.3-rc1 pull request as commit0f327f2aaa
("RISC-V: Add an Image header that boot loader can parse."), we think it wise to try to fix this error before v5.3 is released. The fix itself should be backwards-compatible with any project that has already merged support for premature versions of this interface. It primarily involves ensuring that the RISC-V image header has something useful in the same field as the ARM64 image header" * tag 'riscv/for-v5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux: riscv: modify the Image header to improve compatibility with the ARM64 header
This commit is contained in:
commit
b03c036e6f
@ -18,7 +18,7 @@ The following 64-byte header is present in decompressed Linux kernel image.
|
||||
u32 res1 = 0; /* Reserved */
|
||||
u64 res2 = 0; /* Reserved */
|
||||
u64 magic = 0x5643534952; /* Magic number, little endian, "RISCV" */
|
||||
u32 res3; /* Reserved for additional RISC-V specific header */
|
||||
u32 magic2 = 0x56534905; /* Magic number 2, little endian, "RSC\x05" */
|
||||
u32 res4; /* Reserved for PE COFF offset */
|
||||
|
||||
This header format is compliant with PE/COFF header and largely inspired from
|
||||
@ -37,13 +37,14 @@ Notes:
|
||||
Bits 16:31 - Major version
|
||||
|
||||
This preserves compatibility across newer and older version of the header.
|
||||
The current version is defined as 0.1.
|
||||
The current version is defined as 0.2.
|
||||
|
||||
- res3 is reserved for offset to any other additional fields. This makes the
|
||||
header extendible in future. One example would be to accommodate ISA
|
||||
extension for RISC-V in future. For current version, it is set to be zero.
|
||||
- The "magic" field is deprecated as of version 0.2. In a future
|
||||
release, it may be removed. This originally should have matched up
|
||||
with the ARM64 header "magic" field, but unfortunately does not.
|
||||
The "magic2" field replaces it, matching up with the ARM64 header.
|
||||
|
||||
- In current header, the flag field has only one field.
|
||||
- In current header, the flags field has only one field.
|
||||
Bit 0: Kernel endianness. 1 if BE, 0 if LE.
|
||||
|
||||
- Image size is mandatory for boot loader to load kernel image. Booting will
|
||||
|
@ -3,7 +3,8 @@
|
||||
#ifndef __ASM_IMAGE_H
|
||||
#define __ASM_IMAGE_H
|
||||
|
||||
#define RISCV_IMAGE_MAGIC "RISCV"
|
||||
#define RISCV_IMAGE_MAGIC "RISCV\0\0\0"
|
||||
#define RISCV_IMAGE_MAGIC2 "RSC\x05"
|
||||
|
||||
#define RISCV_IMAGE_FLAG_BE_SHIFT 0
|
||||
#define RISCV_IMAGE_FLAG_BE_MASK 0x1
|
||||
@ -23,7 +24,7 @@
|
||||
#define __HEAD_FLAGS (__HEAD_FLAG(BE))
|
||||
|
||||
#define RISCV_HEADER_VERSION_MAJOR 0
|
||||
#define RISCV_HEADER_VERSION_MINOR 1
|
||||
#define RISCV_HEADER_VERSION_MINOR 2
|
||||
|
||||
#define RISCV_HEADER_VERSION (RISCV_HEADER_VERSION_MAJOR << 16 | \
|
||||
RISCV_HEADER_VERSION_MINOR)
|
||||
@ -39,9 +40,8 @@
|
||||
* @version: version
|
||||
* @res1: reserved
|
||||
* @res2: reserved
|
||||
* @magic: Magic number
|
||||
* @res3: reserved (will be used for additional RISC-V specific
|
||||
* header)
|
||||
* @magic: Magic number (RISC-V specific; deprecated)
|
||||
* @magic2: Magic number 2 (to match the ARM64 'magic' field pos)
|
||||
* @res4: reserved (will be used for PE COFF offset)
|
||||
*
|
||||
* The intention is for this header format to be shared between multiple
|
||||
@ -58,7 +58,7 @@ struct riscv_image_header {
|
||||
u32 res1;
|
||||
u64 res2;
|
||||
u64 magic;
|
||||
u32 res3;
|
||||
u32 magic2;
|
||||
u32 res4;
|
||||
};
|
||||
#endif /* __ASSEMBLY__ */
|
||||
|
@ -39,9 +39,9 @@ ENTRY(_start)
|
||||
.word RISCV_HEADER_VERSION
|
||||
.word 0
|
||||
.dword 0
|
||||
.asciz RISCV_IMAGE_MAGIC
|
||||
.word 0
|
||||
.ascii RISCV_IMAGE_MAGIC
|
||||
.balign 4
|
||||
.ascii RISCV_IMAGE_MAGIC2
|
||||
.word 0
|
||||
|
||||
.global _start_kernel
|
||||
|
Loading…
Reference in New Issue
Block a user