1 # SPDX-License-Identifier: GPL-2.0
3 # Makefile for the linux s390-specific parts of the memory manager.
12 KBUILD_AFLAGS := $(KBUILD_AFLAGS_DECOMPRESSOR)
13 KBUILD_CFLAGS := $(KBUILD_CFLAGS_DECOMPRESSOR)
16 # Use minimum architecture for als.c to be able to print an error
17 # message if the kernel is started on a machine which is too old
19 ifndef CONFIG_CC_IS_CLANG
20 CC_FLAGS_MARCH_MINIMUM := -march=z900
22 CC_FLAGS_MARCH_MINIMUM := -march=z10
25 ifneq ($(CC_FLAGS_MARCH),$(CC_FLAGS_MARCH_MINIMUM))
26 AFLAGS_REMOVE_head.o += $(CC_FLAGS_MARCH)
27 AFLAGS_head.o += $(CC_FLAGS_MARCH_MINIMUM)
28 AFLAGS_REMOVE_mem.o += $(CC_FLAGS_MARCH)
29 AFLAGS_mem.o += $(CC_FLAGS_MARCH_MINIMUM)
30 CFLAGS_REMOVE_als.o += $(CC_FLAGS_MARCH)
31 CFLAGS_als.o += $(CC_FLAGS_MARCH_MINIMUM)
32 CFLAGS_REMOVE_sclp_early_core.o += $(CC_FLAGS_MARCH)
33 CFLAGS_sclp_early_core.o += $(CC_FLAGS_MARCH_MINIMUM)
36 CFLAGS_sclp_early_core.o += -I$(srctree)/drivers/s390/char
38 obj-y := head.o als.o startup.o physmem_info.o ipl_parm.o ipl_report.o vmem.o
39 obj-y += string.o ebcdic.o sclp_early_core.o mem.o ipl_vmparm.o cmdline.o
40 obj-y += version.o pgm_check_info.o ctype.o ipl_data.o machine_kexec_reloc.o
41 obj-$(findstring y, $(CONFIG_PROTECTED_VIRTUALIZATION_GUEST) $(CONFIG_PGSTE)) += uv.o
42 obj-$(CONFIG_RANDOMIZE_BASE) += kaslr.o
43 obj-y += $(if $(CONFIG_KERNEL_UNCOMPRESSED),,decompressor.o) info.o
44 obj-$(CONFIG_KERNEL_ZSTD) += clz_ctz.o
45 obj-all := $(obj-y) piggy.o syms.o
47 targets := bzImage section_cmp.boot.data section_cmp.boot.preserved.data $(obj-y)
48 targets += vmlinux.lds vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2
49 targets += vmlinux.bin.xz vmlinux.bin.lzma vmlinux.bin.lzo vmlinux.bin.lz4
50 targets += vmlinux.bin.zst info.bin syms.bin vmlinux.syms $(obj-all)
52 OBJECTS := $(addprefix $(obj)/,$(obj-y))
53 OBJECTS_ALL := $(addprefix $(obj)/,$(obj-all))
55 clean-files += vmlinux.map
57 quiet_cmd_section_cmp = SECTCMP $*
58 define cmd_section_cmp
59 s1=`$(OBJDUMP) -t -j "$*" "$<" | sort | \
60 sed -n "/0000000000000000/! s/.*\s$*\s\+//p" | sha256sum`; \
61 s2=`$(OBJDUMP) -t -j "$*" "$(word 2,$^)" | sort | \
62 sed -n "/0000000000000000/! s/.*\s$*\s\+//p" | sha256sum`; \
63 if [ "$$s1" != "$$s2" ]; then \
64 echo "error: section $* differs between $< and $(word 2,$^)" >&2; \
70 $(obj)/bzImage: $(obj)/vmlinux $(obj)/section_cmp.boot.data $(obj)/section_cmp.boot.preserved.data FORCE
71 $(call if_changed,objcopy)
73 $(obj)/section_cmp%: vmlinux $(obj)/vmlinux FORCE
74 $(call if_changed,section_cmp)
76 LDFLAGS_vmlinux-$(CONFIG_LD_ORPHAN_WARN) := --orphan-handling=$(CONFIG_LD_ORPHAN_WARN_LEVEL)
77 LDFLAGS_vmlinux := $(LDFLAGS_vmlinux-y) --oformat $(LD_BFD) -e startup $(if $(CONFIG_VMLINUX_MAP),-Map=$(obj)/vmlinux.map) --build-id=sha1 -T
78 $(obj)/vmlinux: $(obj)/vmlinux.lds $(OBJECTS_ALL) FORCE
81 LDFLAGS_vmlinux.syms := $(LDFLAGS_vmlinux-y) --oformat $(LD_BFD) -e startup -T
82 $(obj)/vmlinux.syms: $(obj)/vmlinux.lds $(OBJECTS) FORCE
85 quiet_cmd_dumpsyms = DUMPSYMS $<
87 $(NM) -n -S --format=bsd "$<" | sed -nE 's/^0*([0-9a-fA-F]+) 0*([0-9a-fA-F]+) [tT] ([^ ]*)$$/\1 \2 \3/p' | tr '\n' '\0' > "$@"
90 $(obj)/syms.bin: $(obj)/vmlinux.syms FORCE
91 $(call if_changed,dumpsyms)
93 OBJCOPYFLAGS_syms.o := -I binary -O elf64-s390 -B s390:64-bit --rename-section .data=.decompressor.syms
94 $(obj)/syms.o: $(obj)/syms.bin FORCE
95 $(call if_changed,objcopy)
97 OBJCOPYFLAGS_info.bin := -O binary --only-section=.vmlinux.info --set-section-flags .vmlinux.info=load
98 $(obj)/info.bin: vmlinux FORCE
99 $(call if_changed,objcopy)
101 OBJCOPYFLAGS_info.o := -I binary -O elf64-s390 -B s390:64-bit --rename-section .data=.vmlinux.info
102 $(obj)/info.o: $(obj)/info.bin FORCE
103 $(call if_changed,objcopy)
105 OBJCOPYFLAGS_vmlinux.bin := -O binary --remove-section=.comment --remove-section=.vmlinux.info -S
106 $(obj)/vmlinux.bin: vmlinux FORCE
107 $(call if_changed,objcopy)
109 suffix-$(CONFIG_KERNEL_GZIP) := .gz
110 suffix-$(CONFIG_KERNEL_BZIP2) := .bz2
111 suffix-$(CONFIG_KERNEL_LZ4) := .lz4
112 suffix-$(CONFIG_KERNEL_LZMA) := .lzma
113 suffix-$(CONFIG_KERNEL_LZO) := .lzo
114 suffix-$(CONFIG_KERNEL_XZ) := .xz
115 suffix-$(CONFIG_KERNEL_ZSTD) := .zst
117 $(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE
118 $(call if_changed,gzip)
119 $(obj)/vmlinux.bin.bz2: $(obj)/vmlinux.bin FORCE
120 $(call if_changed,bzip2_with_size)
121 $(obj)/vmlinux.bin.lz4: $(obj)/vmlinux.bin FORCE
122 $(call if_changed,lz4_with_size)
123 $(obj)/vmlinux.bin.lzma: $(obj)/vmlinux.bin FORCE
124 $(call if_changed,lzma_with_size)
125 $(obj)/vmlinux.bin.lzo: $(obj)/vmlinux.bin FORCE
126 $(call if_changed,lzo_with_size)
127 $(obj)/vmlinux.bin.xz: $(obj)/vmlinux.bin FORCE
128 $(call if_changed,xzkern_with_size)
129 $(obj)/vmlinux.bin.zst: $(obj)/vmlinux.bin FORCE
130 $(call if_changed,zstd22_with_size)
132 OBJCOPYFLAGS_piggy.o := -I binary -O elf64-s390 -B s390:64-bit --rename-section .data=.vmlinux.bin.compressed
133 $(obj)/piggy.o: $(obj)/vmlinux.bin$(suffix-y) FORCE
134 $(call if_changed,objcopy)