]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
s390: remove decompressor's head.S
authorVasily Gorbik <gor@linux.ibm.com>
Thu, 19 Jul 2018 11:11:28 +0000 (13:11 +0200)
committerMartin Schwidefsky <schwidefsky@de.ibm.com>
Tue, 9 Oct 2018 09:21:02 +0000 (11:21 +0200)
Decompressor's head.S provided "data mover" sole purpose of which has
been to safely move uncompressed kernel at 0x100000 and jump to it.

With current bzImage layout entire decompressor's code guaranteed to be
in a safe location under 0x100000, and hence could not be overwritten
during kernel move. For that reason head.S could be replaced with simple
memmove function. To do so introduce early boot code phase which is
executed from arch/s390/boot/head.S after "verify_facilities" and takes
care of optional kernel image decompression and transition to it.

Reviewed-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
arch/s390/boot/Makefile
arch/s390/boot/boot.h [new file with mode: 0644]
arch/s390/boot/compressed/Makefile
arch/s390/boot/compressed/decompressor.h [new file with mode: 0644]
arch/s390/boot/compressed/head.S [deleted file]
arch/s390/boot/compressed/misc.c
arch/s390/boot/head.S
arch/s390/boot/startup.c [new file with mode: 0644]

index 9e6668ee93de83122fbfc1c3ade9ab9b0519d87c..1b5a95b1ab09b8994dab055871490c2044cabed1 100644 (file)
@@ -27,7 +27,7 @@ endif
 
 CFLAGS_sclp_early_core.o += -I$(srctree)/drivers/s390/char
 
-obj-y  := head.o als.o ebcdic.o sclp_early_core.o mem.o
+obj-y  := head.o als.o startup.o ebcdic.o sclp_early_core.o mem.o
 targets        := bzImage startup.a $(obj-y)
 subdir-        := compressed
 
diff --git a/arch/s390/boot/boot.h b/arch/s390/boot/boot.h
new file mode 100644 (file)
index 0000000..36c93e6
--- /dev/null
@@ -0,0 +1,7 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef BOOT_BOOT_H
+#define BOOT_BOOT_H
+
+void startup_kernel(void);
+
+#endif /* BOOT_BOOT_H */
index 04609478d18b99303909a01d7b313df8c799873b..c16ded8a35bef04cb40d35e01d0efa9ae50798b0 100644 (file)
@@ -9,7 +9,7 @@ KCOV_INSTRUMENT := n
 GCOV_PROFILE := n
 UBSAN_SANITIZE := n
 
-obj-y  := $(if $(CONFIG_KERNEL_UNCOMPRESSED),,head.o misc.o) piggy.o
+obj-y  := $(if $(CONFIG_KERNEL_UNCOMPRESSED),,misc.o) piggy.o
 targets        := vmlinux.lds vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2
 targets += vmlinux.bin.xz vmlinux.bin.lzma vmlinux.bin.lzo vmlinux.bin.lz4
 targets += vmlinux.scr.lds $(obj-y) $(if $(CONFIG_KERNEL_UNCOMPRESSED),,sizes.h)
@@ -32,9 +32,6 @@ quiet_cmd_sizes = GEN     $@
 $(obj)/sizes.h: vmlinux
        $(call if_changed,sizes)
 
-AFLAGS_head.o += -I$(objtree)/$(obj)
-$(obj)/head.o: $(obj)/sizes.h
-
 CFLAGS_misc.o += -I$(objtree)/$(obj)
 $(obj)/misc.o: $(obj)/sizes.h
 
diff --git a/arch/s390/boot/compressed/decompressor.h b/arch/s390/boot/compressed/decompressor.h
new file mode 100644 (file)
index 0000000..0dd0b84
--- /dev/null
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef BOOT_COMPRESSED_DECOMPRESSOR_H
+#define BOOT_COMPRESSED_DECOMPRESSOR_H
+
+#ifdef CONFIG_KERNEL_UNCOMPRESSED
+static inline void *decompress_kernel(unsigned long *uncompressed_size) {}
+#else
+void *decompress_kernel(unsigned long *uncompressed_size);
+#endif
+
+#endif /* BOOT_COMPRESSED_DECOMPRESSOR_H */
diff --git a/arch/s390/boot/compressed/head.S b/arch/s390/boot/compressed/head.S
deleted file mode 100644 (file)
index 4041fcf..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * Startup glue code to uncompress the kernel
- *
- * Copyright IBM Corp. 2010
- *
- *   Author(s):        Martin Schwidefsky <schwidefsky@de.ibm.com>
- */
-
-#include <linux/init.h>
-#include <linux/linkage.h>
-#include <asm/asm-offsets.h>
-#include <asm/thread_info.h>
-#include <asm/page.h>
-#include <asm/ptrace.h>
-#include "sizes.h"
-
-__HEAD
-ENTRY(startup_decompressor)
-       basr    %r13,0                  # get base
-.LPG1:
-       # setup stack
-       lg      %r15,.Lstack-.LPG1(%r13)
-       brasl   %r14,decompress_kernel
-       # Set up registers for memory mover. We move the decompressed image to
-       # 0x100000, where startup_continue of the decompressed image is supposed
-       # to be.
-       lgr     %r4,%r2
-       lg      %r2,.Loffset-.LPG1(%r13)
-       lg      %r3,.Lmvsize-.LPG1(%r13)
-       lgr     %r5,%r3
-       # Move the memory mover someplace safe so it doesn't overwrite itself.
-       la      %r1,0x200
-       mvc     0(mover_end-mover,%r1),mover-.LPG1(%r13)
-       # When the memory mover is done we pass control to
-       # arch/s390/kernel/head64.S:startup_continue which lives at 0x100000 in
-       # the decompressed image.
-       lgr     %r6,%r2
-       br      %r1
-mover:
-       mvcle   %r2,%r4,0
-       jo      mover
-       br      %r6
-mover_end:
-
-       .align  8
-.Lstack:
-       .quad   0x8000 + THREAD_SIZE - STACK_FRAME_OVERHEAD
-.Loffset:
-       .quad   0x100000
-.Lmvsize:
-       .quad   SZ__bss_start
index f66ad73c205b79889554f3ccae735e102df617df..321f6151ded95795ba02fc5027c018b5b4c168af 100644 (file)
@@ -12,6 +12,7 @@
 #include <asm/sclp.h>
 #include <asm/ipl.h>
 #include "sizes.h"
+#include "decompressor.h"
 
 /*
  * gzip declarations
@@ -82,7 +83,7 @@ static void error(char *x)
        asm volatile("lpsw %0" : : "Q" (psw));
 }
 
-unsigned long decompress_kernel(void)
+void *decompress_kernel(unsigned long *uncompressed_size)
 {
        void *output, *kernel_end;
 
@@ -111,6 +112,8 @@ unsigned long decompress_kernel(void)
        free_mem_end_ptr = free_mem_ptr + HEAP_SIZE;
 
        __decompress(input_data, input_len, NULL, NULL, output, 0, NULL, error);
-       return (unsigned long) output;
+       if (uncompressed_size)
+               *uncompressed_size = SZ__bss_start;
+       return output;
 }
 
index d0736a05bc7f496e1dc9136ad3d8d77f21017361..e209cfe69bb9bb775e3fcefc5af6afd2377b4d2a 100644 (file)
@@ -312,11 +312,7 @@ ENTRY(startup_kdump)
        mvc     __LC_LAST_UPDATE_TIMER(8),6f-.LPG0(%r13)
        l       %r15,.Lstack-.LPG0(%r13)
        brasl   %r14,verify_facilities
-#ifdef CONFIG_KERNEL_UNCOMPRESSED
-       jg      startup_continue
-#else
-       jg      startup_decompressor
-#endif
+       brasl   %r14,startup_kernel
 
 .Lstack:
        .long   0x8000 + THREAD_SIZE - STACK_FRAME_OVERHEAD
diff --git a/arch/s390/boot/startup.c b/arch/s390/boot/startup.c
new file mode 100644 (file)
index 0000000..2a9ce35
--- /dev/null
@@ -0,0 +1,17 @@
+// SPDX-License-Identifier: GPL-2.0
+#include <linux/string.h>
+#include "compressed/decompressor.h"
+#include "boot.h"
+
+void startup_kernel(void)
+{
+       void (*startup_continue)(void) = (void *)0x100000;
+       unsigned long uncompressed_size;
+       void *uncompressed_img;
+
+       if (!IS_ENABLED(CONFIG_KERNEL_UNCOMPRESSED)) {
+               uncompressed_img = decompress_kernel(&uncompressed_size);
+               memmove(startup_continue, uncompressed_img, uncompressed_size);
+       }
+       startup_continue();
+}