lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200930183413.17023-2-l.stelmach@samsung.com>
Date:   Wed, 30 Sep 2020 20:34:10 +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,
        AKASHI Takahiro <takahiro.akashi@...aro.org>,
        kexec@...ts.infradead.org, Dave Young <dyoung@...hat.com>
Cc:     Bartlomiej Zolnierkiewicz <b.zolnierkie@...sung.com>,
        Marek Szyprowski <m.szyprowski@...sung.com>,
        Łukasz Stelmach <l.stelmach@...sung.com>
Subject: [PATCH v3 1/4] 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           | 50 ++++++++++++++++++++++++++
 3 files changed, 55 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 2e04ec5b5446..3099002ad13a 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"
@@ -206,7 +207,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 1bcb68ac4b01..a6b151112ac5 100644
--- a/arch/arm/boot/compressed/vmlinux.lds.S
+++ b/arch/arm/boot/compressed/vmlinux.lds.S
@@ -4,14 +4,7 @@
  */
 #include <asm/vmlinux.lds.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
+#include <asm/image.h>
 
 OUTPUT_ARCH(arm)
 ENTRY(_start)
@@ -45,7 +38,7 @@ SECTIONS
   .table : ALIGN(4) {
     _table_start = .;
     LONG(ZIMAGE_MAGIC(6))
-    LONG(ZIMAGE_MAGIC(0x5a534c4b))
+    LONG(ARM_ZIMAGE_MAGIC3)
     LONG(ZIMAGE_MAGIC(__piggy_size_addr - _start))
     LONG(ZIMAGE_MAGIC(_kernel_bss_size))
     LONG(ZIMAGE_MAGIC(TEXT_OFFSET))
@@ -116,7 +109,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..8150b9490e86
--- /dev/null
+++ b/arch/arm/include/asm/image.h
@@ -0,0 +1,50 @@
+/* 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;
+			__le32 text_offset;
+			__le32 malloc_size;
+		} krnl_size;
+	} u;
+};
+
+#endif /* __ASSEMBLY__ */
+
+#endif /* __ASM_IMAGE_H */
-- 
2.26.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ