Skip to content

Commit 1844c9b

Browse files
Martin SchwidefskyMartin Schwidefsky
authored andcommitted
[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: Martin Schwidefsky <schwidefsky@de.ibm.com>
1 parent 73bfa5f commit 1844c9b

15 files changed

Lines changed: 488 additions & 43 deletions

File tree

‎arch/s390/Kconfig‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ config S390
9898
select HAVE_ARCH_TRACEHOOK
9999
select INIT_ALL_POSSIBLE
100100
select HAVE_PERF_EVENTS
101+
select HAVE_KERNEL_GZIP
102+
select HAVE_KERNEL_BZIP2
103+
select HAVE_KERNEL_LZMA
101104
select ARCH_INLINE_SPIN_TRYLOCK
102105
select ARCH_INLINE_SPIN_TRYLOCK_BH
103106
select ARCH_INLINE_SPIN_LOCK

‎arch/s390/Makefile‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@
1414
#
1515

1616
ifndef CONFIG_64BIT
17+
LD_BFD := elf32-s390
1718
LDFLAGS := -m elf_s390
1819
KBUILD_CFLAGS += -m31
1920
KBUILD_AFLAGS += -m31
2021
UTS_MACHINE := s390
2122
STACK_SIZE := 8192
2223
CHECKFLAGS += -D__s390__ -msize-long
2324
else
25+
LD_BFD := elf64-s390
2426
LDFLAGS := -m elf64_s390
2527
MODFLAGS += -fpic -D__PIC__
2628
KBUILD_CFLAGS += -m64
@@ -30,6 +32,8 @@ STACK_SIZE := 16384
3032
CHECKFLAGS += -D__s390__ -D__s390x__
3133
endif
3234

35+
export LD_BFD
36+
3337
cflags-$(CONFIG_MARCH_G5) += $(call cc-option,-march=g5)
3438
cflags-$(CONFIG_MARCH_Z900) += $(call cc-option,-march=z900)
3539
cflags-$(CONFIG_MARCH_Z990) += $(call cc-option,-march=z990)
@@ -85,7 +89,9 @@ KBUILD_AFLAGS += $(aflags-y)
8589
OBJCOPYFLAGS := -O binary
8690
LDFLAGS_vmlinux := -e start
8791

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

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

100106
boot := arch/s390/boot
101107

102-
all: image
108+
all: image bzImage
103109

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

107-
image: vmlinux
113+
image bzImage: vmlinux
108114
$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
109115

110116
zfcpdump:
@@ -116,4 +122,5 @@ archclean:
116122
# Don't use tabs in echo arguments
117123
define archhelp
118124
echo '* image - Kernel image for IPL ($(boot)/image)'
125+
echo '* bzImage - Compressed kernel image for IPL ($(boot)/bzImage)'
119126
endef

‎arch/s390/boot/Makefile‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,18 @@ COMPILE_VERSION := __linux_compile_version_id__`hostname | \
99
EXTRA_CFLAGS := -DCOMPILE_VERSION=$(COMPILE_VERSION) -gstabs -I.
1010

1111
targets := image
12+
targets += bzImage
13+
subdir- := compressed
1214

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

18+
$(obj)/bzImage: $(obj)/compressed/vmlinux FORCE
19+
$(call if_changed,objcopy)
20+
21+
$(obj)/compressed/vmlinux: FORCE
22+
$(Q)$(MAKE) $(build)=$(obj)/compressed $@
23+
1624
install: $(CONFIGURE) $(obj)/image
1725
sh -x $(srctree)/$(obj)/install.sh $(KERNELRELEASE) $(obj)/image \
1826
System.map Kerntypes "$(INSTALL_PATH)"

‎arch/s390/boot/compressed/Makefile‎

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#
2+
# linux/arch/s390/boot/compressed/Makefile
3+
#
4+
# create a compressed vmlinux image from the original vmlinux
5+
#
6+
7+
BITS := $(if $(CONFIG_64BIT),64,31)
8+
9+
targets := vmlinux.lds vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 \
10+
vmlinux.bin.lzma misc.o piggy.o sizes.h head$(BITS).o
11+
12+
KBUILD_CFLAGS := -m$(BITS) -D__KERNEL__ $(LINUX_INCLUDE) -O2
13+
KBUILD_CFLAGS += $(cflags-y)
14+
KBUILD_CFLAGS += $(call cc-option,-mpacked-stack)
15+
KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
16+
17+
GCOV_PROFILE := n
18+
19+
OBJECTS := $(addprefix $(objtree)/arch/s390/kernel/, head.o sclp.o ebcdic.o)
20+
OBJECTS += $(obj)/head$(BITS).o $(obj)/misc.o $(obj)/piggy.o
21+
22+
LDFLAGS_vmlinux := --oformat $(LD_BFD) -e startup -T
23+
$(obj)/vmlinux: $(obj)/vmlinux.lds $(OBJECTS)
24+
$(call if_changed,ld)
25+
@:
26+
27+
sed-sizes := -e 's/^\([0-9a-fA-F]*\) . \(__bss_start\|_end\)$$/\#define SZ\2 0x\1/p'
28+
29+
quiet_cmd_sizes = GEN $@
30+
cmd_sizes = $(NM) $< | sed -n $(sed-sizes) > $@
31+
32+
$(obj)/sizes.h: vmlinux
33+
$(call if_changed,sizes)
34+
35+
AFLAGS_head$(BITS).o += -I$(obj)
36+
$(obj)/head$(BITS).o: $(obj)/sizes.h
37+
38+
CFLAGS_misc.o += -I$(obj)
39+
$(obj)/misc.o: $(obj)/sizes.h
40+
41+
OBJCOPYFLAGS_vmlinux.bin := -R .comment -S
42+
$(obj)/vmlinux.bin: vmlinux
43+
$(call if_changed,objcopy)
44+
45+
vmlinux.bin.all-y := $(obj)/vmlinux.bin
46+
47+
suffix-$(CONFIG_KERNEL_GZIP) := gz
48+
suffix-$(CONFIG_KERNEL_BZIP2) := bz2
49+
suffix-$(CONFIG_KERNEL_LZMA) := lzma
50+
51+
$(obj)/vmlinux.bin.gz: $(vmlinux.bin.all-y)
52+
$(call if_changed,gzip)
53+
$(obj)/vmlinux.bin.bz2: $(vmlinux.bin.all-y)
54+
$(call if_changed,bzip2)
55+
$(obj)/vmlinux.bin.lzma: $(vmlinux.bin.all-y)
56+
$(call if_changed,lzma)
57+
58+
LDFLAGS_piggy.o := -r --format binary --oformat $(LD_BFD) -T
59+
$(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.$(suffix-y)
60+
$(call if_changed,ld)

‎arch/s390/boot/compressed/head31.S‎

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Startup glue code to uncompress the kernel
3+
*
4+
* Copyright IBM Corp. 2010
5+
*
6+
* Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
7+
*/
8+
9+
#include <linux/init.h>
10+
#include <asm/asm-offsets.h>
11+
#include <asm/thread_info.h>
12+
#include <asm/page.h>
13+
#include "sizes.h"
14+
15+
__HEAD
16+
.globl startup_continue
17+
startup_continue:
18+
basr %r13,0 # get base
19+
.LPG1:
20+
# setup stack
21+
l %r15,.Lstack-.LPG1(%r13)
22+
ahi %r15,-96
23+
l %r1,.Ldecompress-.LPG1(%r13)
24+
basr %r14,%r1
25+
# setup registers for memory mover & branch to target
26+
lr %r4,%r2
27+
l %r2,.Loffset-.LPG1(%r13)
28+
la %r4,0(%r2,%r4)
29+
l %r3,.Lmvsize-.LPG1(%r13)
30+
lr %r5,%r3
31+
# move the memory mover someplace safe
32+
la %r1,0x200
33+
mvc 0(mover_end-mover,%r1),mover-.LPG1(%r13)
34+
# decompress image is started at 0x11000
35+
lr %r6,%r2
36+
br %r1
37+
mover:
38+
mvcle %r2,%r4,0
39+
jo mover
40+
br %r6
41+
mover_end:
42+
43+
.align 8
44+
.Lstack:
45+
.long 0x8000 + (1<<(PAGE_SHIFT+THREAD_ORDER))
46+
.Ldecompress:
47+
.long decompress_kernel
48+
.Loffset:
49+
.long 0x11000
50+
.Lmvsize:
51+
.long SZ__bss_start

‎arch/s390/boot/compressed/head64.S‎

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Startup glue code to uncompress the kernel
3+
*
4+
* Copyright IBM Corp. 2010
5+
*
6+
* Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
7+
*/
8+
9+
#include <linux/init.h>
10+
#include <asm/asm-offsets.h>
11+
#include <asm/thread_info.h>
12+
#include <asm/page.h>
13+
#include "sizes.h"
14+
15+
__HEAD
16+
.globl startup_continue
17+
startup_continue:
18+
basr %r13,0 # get base
19+
.LPG1:
20+
# setup stack
21+
lg %r15,.Lstack-.LPG1(%r13)
22+
aghi %r15,-160
23+
brasl %r14,decompress_kernel
24+
# setup registers for memory mover & branch to target
25+
lgr %r4,%r2
26+
lg %r2,.Loffset-.LPG1(%r13)
27+
la %r4,0(%r2,%r4)
28+
lg %r3,.Lmvsize-.LPG1(%r13)
29+
lgr %r5,%r3
30+
# move the memory mover someplace safe
31+
la %r1,0x200
32+
mvc 0(mover_end-mover,%r1),mover-.LPG1(%r13)
33+
# decompress image is started at 0x11000
34+
lgr %r6,%r2
35+
br %r1
36+
mover:
37+
mvcle %r2,%r4,0
38+
jo mover
39+
br %r6
40+
mover_end:
41+
42+
.align 8
43+
.Lstack:
44+
.quad 0x8000 + (1<<(PAGE_SHIFT+THREAD_ORDER))
45+
.Loffset:
46+
.quad 0x11000
47+
.Lmvsize:
48+
.quad SZ__bss_start

0 commit comments

Comments
 (0)