Commit b03c036e authored by Linus Torvalds's avatar Linus Torvalds

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 commit 0f327f2a ("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
parents 36024fcf 474efecb
...@@ -18,7 +18,7 @@ The following 64-byte header is present in decompressed Linux kernel image. ...@@ -18,7 +18,7 @@ The following 64-byte header is present in decompressed Linux kernel image.
u32 res1 = 0; /* Reserved */ u32 res1 = 0; /* Reserved */
u64 res2 = 0; /* Reserved */ u64 res2 = 0; /* Reserved */
u64 magic = 0x5643534952; /* Magic number, little endian, "RISCV" */ 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 */ u32 res4; /* Reserved for PE COFF offset */
This header format is compliant with PE/COFF header and largely inspired from This header format is compliant with PE/COFF header and largely inspired from
...@@ -37,13 +37,14 @@ Notes: ...@@ -37,13 +37,14 @@ Notes:
Bits 16:31 - Major version Bits 16:31 - Major version
This preserves compatibility across newer and older version of the header. 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 - The "magic" field is deprecated as of version 0.2. In a future
header extendible in future. One example would be to accommodate ISA release, it may be removed. This originally should have matched up
extension for RISC-V in future. For current version, it is set to be zero. 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. Bit 0: Kernel endianness. 1 if BE, 0 if LE.
- Image size is mandatory for boot loader to load kernel image. Booting will - Image size is mandatory for boot loader to load kernel image. Booting will
......
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
#ifndef __ASM_IMAGE_H #ifndef __ASM_IMAGE_H
#define __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_SHIFT 0
#define RISCV_IMAGE_FLAG_BE_MASK 0x1 #define RISCV_IMAGE_FLAG_BE_MASK 0x1
...@@ -23,7 +24,7 @@ ...@@ -23,7 +24,7 @@
#define __HEAD_FLAGS (__HEAD_FLAG(BE)) #define __HEAD_FLAGS (__HEAD_FLAG(BE))
#define RISCV_HEADER_VERSION_MAJOR 0 #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 | \ #define RISCV_HEADER_VERSION (RISCV_HEADER_VERSION_MAJOR << 16 | \
RISCV_HEADER_VERSION_MINOR) RISCV_HEADER_VERSION_MINOR)
...@@ -39,9 +40,8 @@ ...@@ -39,9 +40,8 @@
* @version: version * @version: version
* @res1: reserved * @res1: reserved
* @res2: reserved * @res2: reserved
* @magic: Magic number * @magic: Magic number (RISC-V specific; deprecated)
* @res3: reserved (will be used for additional RISC-V specific * @magic2: Magic number 2 (to match the ARM64 'magic' field pos)
* header)
* @res4: reserved (will be used for PE COFF offset) * @res4: reserved (will be used for PE COFF offset)
* *
* The intention is for this header format to be shared between multiple * The intention is for this header format to be shared between multiple
...@@ -58,7 +58,7 @@ struct riscv_image_header { ...@@ -58,7 +58,7 @@ struct riscv_image_header {
u32 res1; u32 res1;
u64 res2; u64 res2;
u64 magic; u64 magic;
u32 res3; u32 magic2;
u32 res4; u32 res4;
}; };
#endif /* __ASSEMBLY__ */ #endif /* __ASSEMBLY__ */
......
...@@ -39,9 +39,9 @@ ENTRY(_start) ...@@ -39,9 +39,9 @@ ENTRY(_start)
.word RISCV_HEADER_VERSION .word RISCV_HEADER_VERSION
.word 0 .word 0
.dword 0 .dword 0
.asciz RISCV_IMAGE_MAGIC .ascii RISCV_IMAGE_MAGIC
.word 0
.balign 4 .balign 4
.ascii RISCV_IMAGE_MAGIC2
.word 0 .word 0
.global _start_kernel .global _start_kernel
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment