Commit 81796a3c authored by Vasily Gorbik's avatar Vasily Gorbik Committed by Martin Schwidefsky

s390/decompressor: trim uncompressed image head during the build

It seems to be suboptimal to compress the entire image, so that we
could decompress and throw away the first 68k (0x11000) during the boot
process. This patch trims 0x11000 bytes during the build process and
adjusts symbols in size.h accordingly.

Besides making bzImage smaller, this change would also be a benefit
for kaslr. It allows to decompress the kernel right to desired offset,
without worrying about dead weight in front of the decompressed image.
Signed-off-by: default avatarVasily Gorbik <gor@linux.vnet.ibm.com>
Acked-by: default avatarHeiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
parent c7260ca3
...@@ -29,11 +29,16 @@ LDFLAGS_vmlinux := --oformat $(LD_BFD) -e startup -T ...@@ -29,11 +29,16 @@ LDFLAGS_vmlinux := --oformat $(LD_BFD) -e startup -T
$(obj)/vmlinux: $(obj)/vmlinux.lds $(OBJECTS) $(obj)/vmlinux: $(obj)/vmlinux.lds $(OBJECTS)
$(call if_changed,ld) $(call if_changed,ld)
sed-sizes := -e 's/^\([0-9a-fA-F]*\) . \(__bss_start\|_end\)$$/\#define SZ\2 0x\1/p' TRIM_HEAD_SIZE := 0x11000
sed-sizes := -e 's/^\([0-9a-fA-F]*\) . \(__bss_start\|_end\)$$/\#define SZ\2 (0x\1 - $(TRIM_HEAD_SIZE))/p'
quiet_cmd_sizes = GEN $@ quiet_cmd_sizes = GEN $@
cmd_sizes = $(NM) $< | sed -n $(sed-sizes) > $@ cmd_sizes = $(NM) $< | sed -n $(sed-sizes) > $@
quiet_cmd_trim_head = TRIM $@
cmd_trim_head = tail -c +$$(($(TRIM_HEAD_SIZE) + 1)) $< > $@
$(obj)/sizes.h: vmlinux $(obj)/sizes.h: vmlinux
$(call if_changed,sizes) $(call if_changed,sizes)
...@@ -43,10 +48,13 @@ $(obj)/head.o: $(obj)/sizes.h ...@@ -43,10 +48,13 @@ $(obj)/head.o: $(obj)/sizes.h
CFLAGS_misc.o += -I$(objtree)/$(obj) CFLAGS_misc.o += -I$(objtree)/$(obj)
$(obj)/misc.o: $(obj)/sizes.h $(obj)/misc.o: $(obj)/sizes.h
OBJCOPYFLAGS_vmlinux.bin := -R .comment -S OBJCOPYFLAGS_vmlinux.bin.full := -R .comment -S
$(obj)/vmlinux.bin: vmlinux $(obj)/vmlinux.bin.full: vmlinux
$(call if_changed,objcopy) $(call if_changed,objcopy)
$(obj)/vmlinux.bin: $(obj)/vmlinux.bin.full
$(call if_changed,trim_head)
vmlinux.bin.all-y := $(obj)/vmlinux.bin vmlinux.bin.all-y := $(obj)/vmlinux.bin
suffix-$(CONFIG_KERNEL_GZIP) := gz suffix-$(CONFIG_KERNEL_GZIP) := gz
......
...@@ -23,12 +23,10 @@ ENTRY(startup_continue) ...@@ -23,12 +23,10 @@ ENTRY(startup_continue)
aghi %r15,-160 aghi %r15,-160
brasl %r14,decompress_kernel brasl %r14,decompress_kernel
# Set up registers for memory mover. We move the decompressed image to # Set up registers for memory mover. We move the decompressed image to
# 0x11000, starting at offset 0x11000 in the decompressed image so # 0x11000, where startup_continue of the decompressed image is supposed
# that code living at 0x11000 in the image will end up at 0x11000 in # to be.
# memory.
lgr %r4,%r2 lgr %r4,%r2
lg %r2,.Loffset-.LPG1(%r13) lg %r2,.Loffset-.LPG1(%r13)
la %r4,0(%r2,%r4)
lg %r3,.Lmvsize-.LPG1(%r13) lg %r3,.Lmvsize-.LPG1(%r13)
lgr %r5,%r3 lgr %r5,%r3
# Move the memory mover someplace safe so it doesn't overwrite itself. # Move the memory mover someplace safe so it doesn't overwrite itself.
......
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