[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200601142754.26139-3-l.stelmach@samsung.com>
Date: Mon, 1 Jun 2020 16:27:51 +0200
From: Łukasz Stelmach <l.stelmach@...sung.com>
To: Russell King <linux@...linux.org.uk>,
Masahiro Yamada <masahiroy@...nel.org>,
Nick Desaulniers <ndesaulniers@...gle.com>,
Thomas Gleixner <tglx@...utronix.de>,
Enrico Weigelt <info@...ux.net>,
Kees Cook <keescook@...omium.org>,
Ingo Molnar <mingo@...nel.org>,
Ben Dooks <ben-linux@...ff.org>,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org
Cc: AKASHI Takahiro <takahiro.akashi@...aro.org>,
Bartlomiej Zolnierkiewicz <b.zolnierkie@...sung.com>,
Marek Szyprowski <m.szyprowski@...sung.com>,
Łukasz Stelmach <l.stelmach@...sung.com>
Subject: [PATCH 2/5] arm: add image header definitions
This structure will be used later by kexec_file loader.
Signed-off-by: Łukasz Stelmach <l.stelmach@...sung.com>
---
arch/arm/boot/compressed/head.S | 3 +-
arch/arm/boot/compressed/vmlinux.lds.S | 13 ++-----
arch/arm/include/asm/image.h | 48 ++++++++++++++++++++++++++
3 files changed, 53 insertions(+), 11 deletions(-)
create mode 100644 arch/arm/include/asm/image.h
diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
index dcc1afa60fb9..97e4cfcfc197 100644
--- a/arch/arm/boot/compressed/head.S
+++ b/arch/arm/boot/compressed/head.S
@@ -7,6 +7,7 @@
*/
#include <linux/linkage.h>
#include <asm/assembler.h>
+#include <asm/image.h>
#include <asm/v7m.h>
#include "efi-header.S"
@@ -211,7 +212,7 @@ start:
.word _magic_start @ absolute load/run zImage address
.word _magic_end @ zImage end address
.word 0x04030201 @ endianness flag
- .word 0x45454545 @ another magic number to indicate
+ .word ARM_ZIMAGE_MAGIC2 @ another magic number to indicate
.word _magic_table @ additional data table
__EFI_HEADER
diff --git a/arch/arm/boot/compressed/vmlinux.lds.S b/arch/arm/boot/compressed/vmlinux.lds.S
index f82b5962d97e..308e9cd6a897 100644
--- a/arch/arm/boot/compressed/vmlinux.lds.S
+++ b/arch/arm/boot/compressed/vmlinux.lds.S
@@ -3,14 +3,7 @@
* Copyright (C) 2000 Russell King
*/
-#ifdef CONFIG_CPU_ENDIAN_BE8
-#define ZIMAGE_MAGIC(x) ( (((x) >> 24) & 0x000000ff) | \
- (((x) >> 8) & 0x0000ff00) | \
- (((x) << 8) & 0x00ff0000) | \
- (((x) << 24) & 0xff000000) )
-#else
-#define ZIMAGE_MAGIC(x) (x)
-#endif
+#include <asm/image.h>
OUTPUT_ARCH(arm)
ENTRY(_start)
@@ -43,7 +36,7 @@ SECTIONS
.table : ALIGN(4) {
_table_start = .;
LONG(ZIMAGE_MAGIC(4))
- LONG(ZIMAGE_MAGIC(0x5a534c4b))
+ LONG(ARM_ZIMAGE_MAGIC3)
LONG(ZIMAGE_MAGIC(__piggy_size_addr - _start))
LONG(ZIMAGE_MAGIC(_kernel_bss_size))
LONG(0)
@@ -107,7 +100,7 @@ SECTIONS
_edata_real = .;
}
- _magic_sig = ZIMAGE_MAGIC(0x016f2818);
+ _magic_sig = ARM_ZIMAGE_MAGIC1;
_magic_start = ZIMAGE_MAGIC(_start);
_magic_end = ZIMAGE_MAGIC(_edata);
_magic_table = ZIMAGE_MAGIC(_table_start - _start);
diff --git a/arch/arm/include/asm/image.h b/arch/arm/include/asm/image.h
new file mode 100644
index 000000000000..d5c18a0f6a34
--- /dev/null
+++ b/arch/arm/include/asm/image.h
@@ -0,0 +1,48 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef __ASM_IMAGE_H
+#define __ASM_IMAGE_H
+
+#ifdef CONFIG_CPU_ENDIAN_BE8
+#define ZIMAGE_MAGIC(x) ((((x) >> 24) & 0x000000ff) | \
+ (((x) >> 8) & 0x0000ff00) | \
+ (((x) << 8) & 0x00ff0000) | \
+ (((x) << 24) & 0xff000000))
+#else
+#define ZIMAGE_MAGIC(x) (x)
+#endif
+
+#define ARM_ZIMAGE_MAGIC1 ZIMAGE_MAGIC(0x016f2818)
+#define ARM_ZIMAGE_MAGIC2 (0x45454545)
+#define ARM_ZIMAGE_MAGIC3 ZIMAGE_MAGIC(0x5a534c4b)
+
+#ifndef __ASSEMBLY__
+
+#include <linux/types.h>
+#include <asm/setup.h>
+
+/* ARM zImage header format */
+struct arm_zimage_header {
+ __le32 code[9];
+ __le32 magic;
+ __le32 start;
+ __le32 end;
+ __le32 endian;
+ __le32 magic2;
+ __le32 extension_tag_offset;
+};
+
+struct arm_zimage_tag {
+ struct tag_header hdr;
+ union {
+#define ZIMAGE_TAG_KRNL_SIZE ARM_ZIMAGE_MAGIC3
+ struct zimage_krnl_size {
+ __le32 size_ptr;
+ __le32 bss_size;
+ } krnl_size;
+ } u;
+};
+
+#endif /* __ASSEMBLY__ */
+
+#endif /* __ASM_IMAGE_H */
--
2.26.2
Powered by blists - more mailing lists