Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1844c9bc authored by Martin Schwidefsky's avatar Martin Schwidefsky Committed by Martin Schwidefsky
Browse files

[S390] add support for compressed kernels



Add the "bzImage" compile target and the necessary code  to generate
compressed kernel images. The old style uncompressed "image" target
is preserved, a simple make will build them both.

Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
parent 73bfa5f2
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -98,6 +98,9 @@ config S390
	select HAVE_ARCH_TRACEHOOK
	select INIT_ALL_POSSIBLE
	select HAVE_PERF_EVENTS
	select HAVE_KERNEL_GZIP
	select HAVE_KERNEL_BZIP2
	select HAVE_KERNEL_LZMA
	select ARCH_INLINE_SPIN_TRYLOCK
	select ARCH_INLINE_SPIN_TRYLOCK_BH
	select ARCH_INLINE_SPIN_LOCK
+10 −3
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@
#

ifndef CONFIG_64BIT
LD_BFD		:= elf32-s390
LDFLAGS		:= -m elf_s390
KBUILD_CFLAGS	+= -m31
KBUILD_AFLAGS	+= -m31
@@ -21,6 +22,7 @@ UTS_MACHINE := s390
STACK_SIZE	:= 8192
CHECKFLAGS	+= -D__s390__ -msize-long
else
LD_BFD		:= elf64-s390
LDFLAGS		:= -m elf64_s390
MODFLAGS	+= -fpic -D__PIC__
KBUILD_CFLAGS	+= -m64
@@ -30,6 +32,8 @@ STACK_SIZE := 16384
CHECKFLAGS	+= -D__s390__ -D__s390x__
endif

export LD_BFD

cflags-$(CONFIG_MARCH_G5)   += $(call cc-option,-march=g5)
cflags-$(CONFIG_MARCH_Z900) += $(call cc-option,-march=z900)
cflags-$(CONFIG_MARCH_Z990) += $(call cc-option,-march=z990)
@@ -85,7 +89,9 @@ KBUILD_AFLAGS += $(aflags-y)
OBJCOPYFLAGS	:= -O binary
LDFLAGS_vmlinux := -e start

head-y		:= arch/s390/kernel/head.o arch/s390/kernel/init_task.o
head-y		:= arch/s390/kernel/head.o
head-y		+= arch/s390/kernel/$(if $(CONFIG_64BIT),head64.o,head31.o)
head-y		+= arch/s390/kernel/init_task.o

core-y		+= arch/s390/mm/ arch/s390/kernel/ arch/s390/crypto/ \
		   arch/s390/appldata/ arch/s390/hypfs/ arch/s390/kvm/
@@ -99,12 +105,12 @@ drivers-$(CONFIG_OPROFILE) += arch/s390/oprofile/

boot		:= arch/s390/boot

all: image
all: image bzImage

install: vmlinux
	$(Q)$(MAKE) $(build)=$(boot) $@

image: vmlinux
image bzImage: vmlinux
	$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@

zfcpdump:
@@ -116,4 +122,5 @@ archclean:
# Don't use tabs in echo arguments
define archhelp
  echo  '* image           - Kernel image for IPL ($(boot)/image)'
  echo	'* bzImage         - Compressed kernel image for IPL ($(boot)/bzImage)'
endef
+8 −0
Original line number Diff line number Diff line
@@ -9,10 +9,18 @@ COMPILE_VERSION := __linux_compile_version_id__`hostname | \
EXTRA_CFLAGS  := -DCOMPILE_VERSION=$(COMPILE_VERSION) -gstabs -I.

targets := image
targets += bzImage
subdir- := compressed

$(obj)/image: vmlinux FORCE
	$(call if_changed,objcopy)

$(obj)/bzImage: $(obj)/compressed/vmlinux FORCE
	$(call if_changed,objcopy)

$(obj)/compressed/vmlinux: FORCE
	$(Q)$(MAKE) $(build)=$(obj)/compressed $@

install: $(CONFIGURE) $(obj)/image
	sh -x  $(srctree)/$(obj)/install.sh $(KERNELRELEASE) $(obj)/image \
	      System.map Kerntypes "$(INSTALL_PATH)"
+60 −0
Original line number Diff line number Diff line
#
# linux/arch/s390/boot/compressed/Makefile
#
# create a compressed vmlinux image from the original vmlinux
#

BITS := $(if $(CONFIG_64BIT),64,31)

targets	:= vmlinux.lds vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 \
	   vmlinux.bin.lzma misc.o piggy.o sizes.h head$(BITS).o

KBUILD_CFLAGS := -m$(BITS) -D__KERNEL__ $(LINUX_INCLUDE) -O2
KBUILD_CFLAGS += $(cflags-y)
KBUILD_CFLAGS += $(call cc-option,-mpacked-stack)
KBUILD_CFLAGS += $(call cc-option,-ffreestanding)

GCOV_PROFILE := n

OBJECTS := $(addprefix $(objtree)/arch/s390/kernel/, head.o sclp.o ebcdic.o)
OBJECTS += $(obj)/head$(BITS).o $(obj)/misc.o $(obj)/piggy.o

LDFLAGS_vmlinux := --oformat $(LD_BFD) -e startup -T
$(obj)/vmlinux: $(obj)/vmlinux.lds $(OBJECTS)
	$(call if_changed,ld)
	@:

sed-sizes := -e 's/^\([0-9a-fA-F]*\) . \(__bss_start\|_end\)$$/\#define SZ\2 0x\1/p'

quiet_cmd_sizes = GEN $@
      cmd_sizes = $(NM) $< | sed -n $(sed-sizes) > $@

$(obj)/sizes.h: vmlinux
	$(call if_changed,sizes)

AFLAGS_head$(BITS).o += -I$(obj)
$(obj)/head$(BITS).o: $(obj)/sizes.h

CFLAGS_misc.o += -I$(obj)
$(obj)/misc.o: $(obj)/sizes.h

OBJCOPYFLAGS_vmlinux.bin :=  -R .comment -S
$(obj)/vmlinux.bin: vmlinux
	$(call if_changed,objcopy)

vmlinux.bin.all-y := $(obj)/vmlinux.bin

suffix-$(CONFIG_KERNEL_GZIP)  := gz
suffix-$(CONFIG_KERNEL_BZIP2) := bz2
suffix-$(CONFIG_KERNEL_LZMA)  := lzma

$(obj)/vmlinux.bin.gz: $(vmlinux.bin.all-y)
	$(call if_changed,gzip)
$(obj)/vmlinux.bin.bz2: $(vmlinux.bin.all-y)
	$(call if_changed,bzip2)
$(obj)/vmlinux.bin.lzma: $(vmlinux.bin.all-y)
	$(call if_changed,lzma)

LDFLAGS_piggy.o := -r --format binary --oformat $(LD_BFD) -T
$(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.$(suffix-y)
	$(call if_changed,ld)
+51 −0
Original line number Diff line number Diff line
/*
 * Startup glue code to uncompress the kernel
 *
 * Copyright IBM Corp. 2010
 *
 *   Author(s):	Martin Schwidefsky <schwidefsky@de.ibm.com>
 */

#include <linux/init.h>
#include <asm/asm-offsets.h>
#include <asm/thread_info.h>
#include <asm/page.h>
#include "sizes.h"

__HEAD
	.globl	startup_continue
startup_continue:
	basr	%r13,0			# get base
.LPG1:
	# setup stack
	l	%r15,.Lstack-.LPG1(%r13)
	ahi	%r15,-96
	l	%r1,.Ldecompress-.LPG1(%r13)
	basr	%r14,%r1
	# setup registers for memory mover & branch to target
	lr	%r4,%r2
	l	%r2,.Loffset-.LPG1(%r13)
	la	%r4,0(%r2,%r4)
	l	%r3,.Lmvsize-.LPG1(%r13)
	lr	%r5,%r3
	# move the memory mover someplace safe
	la	%r1,0x200
	mvc	0(mover_end-mover,%r1),mover-.LPG1(%r13)
	# decompress image is started at 0x11000
	lr	%r6,%r2
	br	%r1
mover:
	mvcle	%r2,%r4,0
	jo	mover
	br	%r6
mover_end:

	.align	8
.Lstack:
	.long	0x8000 + (1<<(PAGE_SHIFT+THREAD_ORDER))
.Ldecompress:
	.long	decompress_kernel
.Loffset:
	.long	0x11000
.Lmvsize:
	.long	SZ__bss_start
Loading