Skip to content

Commit

Permalink
s390: remove decompressor's head.S
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Vasily Gorbik authored and Martin Schwidefsky committed Oct 9, 2018
1 parent 32ce55a commit 8f75582
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 64 deletions.
2 changes: 1 addition & 1 deletion arch/s390/boot/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 7 additions & 0 deletions arch/s390/boot/boot.h
Original file line number Diff line number Diff line change
@@ -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 */
5 changes: 1 addition & 4 deletions arch/s390/boot/compressed/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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

Expand Down
11 changes: 11 additions & 0 deletions arch/s390/boot/compressed/decompressor.h
Original file line number Diff line number Diff line change
@@ -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 */
52 changes: 0 additions & 52 deletions arch/s390/boot/compressed/head.S

This file was deleted.

7 changes: 5 additions & 2 deletions arch/s390/boot/compressed/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <asm/sclp.h>
#include <asm/ipl.h>
#include "sizes.h"
#include "decompressor.h"

/*
* gzip declarations
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}

6 changes: 1 addition & 5 deletions arch/s390/boot/head.S
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions arch/s390/boot/startup.c
Original file line number Diff line number Diff line change
@@ -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();
}

0 comments on commit 8f75582

Please sign in to comment.