162306a36Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0
262306a36Sopenharmony_ci#
362306a36Sopenharmony_ci# Makefile for the linux s390-specific parts of the memory manager.
462306a36Sopenharmony_ci#
562306a36Sopenharmony_ci
662306a36Sopenharmony_ciKCOV_INSTRUMENT := n
762306a36Sopenharmony_ciGCOV_PROFILE := n
862306a36Sopenharmony_ciUBSAN_SANITIZE := n
962306a36Sopenharmony_ciKASAN_SANITIZE := n
1062306a36Sopenharmony_ciKCSAN_SANITIZE := n
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_ciKBUILD_AFLAGS := $(KBUILD_AFLAGS_DECOMPRESSOR)
1362306a36Sopenharmony_ciKBUILD_CFLAGS := $(KBUILD_CFLAGS_DECOMPRESSOR)
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ci#
1662306a36Sopenharmony_ci# Use minimum architecture for als.c to be able to print an error
1762306a36Sopenharmony_ci# message if the kernel is started on a machine which is too old
1862306a36Sopenharmony_ci#
1962306a36Sopenharmony_ciifndef CONFIG_CC_IS_CLANG
2062306a36Sopenharmony_ciCC_FLAGS_MARCH_MINIMUM := -march=z900
2162306a36Sopenharmony_cielse
2262306a36Sopenharmony_ciCC_FLAGS_MARCH_MINIMUM := -march=z10
2362306a36Sopenharmony_ciendif
2462306a36Sopenharmony_ci
2562306a36Sopenharmony_ciifneq ($(CC_FLAGS_MARCH),$(CC_FLAGS_MARCH_MINIMUM))
2662306a36Sopenharmony_ciAFLAGS_REMOVE_head.o		+= $(CC_FLAGS_MARCH)
2762306a36Sopenharmony_ciAFLAGS_head.o			+= $(CC_FLAGS_MARCH_MINIMUM)
2862306a36Sopenharmony_ciAFLAGS_REMOVE_mem.o		+= $(CC_FLAGS_MARCH)
2962306a36Sopenharmony_ciAFLAGS_mem.o			+= $(CC_FLAGS_MARCH_MINIMUM)
3062306a36Sopenharmony_ciCFLAGS_REMOVE_als.o		+= $(CC_FLAGS_MARCH)
3162306a36Sopenharmony_ciCFLAGS_als.o			+= $(CC_FLAGS_MARCH_MINIMUM)
3262306a36Sopenharmony_ciCFLAGS_REMOVE_sclp_early_core.o	+= $(CC_FLAGS_MARCH)
3362306a36Sopenharmony_ciCFLAGS_sclp_early_core.o	+= $(CC_FLAGS_MARCH_MINIMUM)
3462306a36Sopenharmony_ciendif
3562306a36Sopenharmony_ci
3662306a36Sopenharmony_ciCFLAGS_sclp_early_core.o += -I$(srctree)/drivers/s390/char
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_ciobj-y	:= head.o als.o startup.o physmem_info.o ipl_parm.o ipl_report.o vmem.o
3962306a36Sopenharmony_ciobj-y	+= string.o ebcdic.o sclp_early_core.o mem.o ipl_vmparm.o cmdline.o
4062306a36Sopenharmony_ciobj-y	+= version.o pgm_check_info.o ctype.o ipl_data.o machine_kexec_reloc.o
4162306a36Sopenharmony_ciobj-$(findstring y, $(CONFIG_PROTECTED_VIRTUALIZATION_GUEST) $(CONFIG_PGSTE))	+= uv.o
4262306a36Sopenharmony_ciobj-$(CONFIG_RANDOMIZE_BASE)	+= kaslr.o
4362306a36Sopenharmony_ciobj-y	+= $(if $(CONFIG_KERNEL_UNCOMPRESSED),,decompressor.o) info.o
4462306a36Sopenharmony_ciobj-$(CONFIG_KERNEL_ZSTD) += clz_ctz.o
4562306a36Sopenharmony_ciobj-all := $(obj-y) piggy.o syms.o
4662306a36Sopenharmony_ci
4762306a36Sopenharmony_citargets	:= bzImage section_cmp.boot.data section_cmp.boot.preserved.data $(obj-y)
4862306a36Sopenharmony_citargets	+= vmlinux.lds vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2
4962306a36Sopenharmony_citargets += vmlinux.bin.xz vmlinux.bin.lzma vmlinux.bin.lzo vmlinux.bin.lz4
5062306a36Sopenharmony_citargets += vmlinux.bin.zst info.bin syms.bin vmlinux.syms $(obj-all)
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_ciOBJECTS := $(addprefix $(obj)/,$(obj-y))
5362306a36Sopenharmony_ciOBJECTS_ALL := $(addprefix $(obj)/,$(obj-all))
5462306a36Sopenharmony_ci
5562306a36Sopenharmony_ciclean-files += vmlinux.map
5662306a36Sopenharmony_ci
5762306a36Sopenharmony_ciquiet_cmd_section_cmp = SECTCMP $*
5862306a36Sopenharmony_cidefine cmd_section_cmp
5962306a36Sopenharmony_ci	s1=`$(OBJDUMP) -t -j "$*" "$<" | sort | \
6062306a36Sopenharmony_ci		sed -n "/0000000000000000/! s/.*\s$*\s\+//p" | sha256sum`; \
6162306a36Sopenharmony_ci	s2=`$(OBJDUMP) -t -j "$*" "$(word 2,$^)" | sort | \
6262306a36Sopenharmony_ci		sed -n "/0000000000000000/! s/.*\s$*\s\+//p" | sha256sum`; \
6362306a36Sopenharmony_ci	if [ "$$s1" != "$$s2" ]; then \
6462306a36Sopenharmony_ci		echo "error: section $* differs between $< and $(word 2,$^)" >&2; \
6562306a36Sopenharmony_ci		exit 1; \
6662306a36Sopenharmony_ci	fi; \
6762306a36Sopenharmony_ci	touch $@
6862306a36Sopenharmony_ciendef
6962306a36Sopenharmony_ci
7062306a36Sopenharmony_ci$(obj)/bzImage: $(obj)/vmlinux $(obj)/section_cmp.boot.data $(obj)/section_cmp.boot.preserved.data FORCE
7162306a36Sopenharmony_ci	$(call if_changed,objcopy)
7262306a36Sopenharmony_ci
7362306a36Sopenharmony_ci$(obj)/section_cmp%: vmlinux $(obj)/vmlinux FORCE
7462306a36Sopenharmony_ci	$(call if_changed,section_cmp)
7562306a36Sopenharmony_ci
7662306a36Sopenharmony_ciLDFLAGS_vmlinux := --oformat $(LD_BFD) -e startup $(if $(CONFIG_VMLINUX_MAP),-Map=$(obj)/vmlinux.map) --build-id=sha1 -T
7762306a36Sopenharmony_ci$(obj)/vmlinux: $(obj)/vmlinux.lds $(OBJECTS_ALL) FORCE
7862306a36Sopenharmony_ci	$(call if_changed,ld)
7962306a36Sopenharmony_ci
8062306a36Sopenharmony_ciLDFLAGS_vmlinux.syms := --oformat $(LD_BFD) -e startup -T
8162306a36Sopenharmony_ci$(obj)/vmlinux.syms: $(obj)/vmlinux.lds $(OBJECTS) FORCE
8262306a36Sopenharmony_ci	$(call if_changed,ld)
8362306a36Sopenharmony_ci
8462306a36Sopenharmony_ciquiet_cmd_dumpsyms = DUMPSYMS $<
8562306a36Sopenharmony_cidefine cmd_dumpsyms
8662306a36Sopenharmony_ci	$(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' > "$@"
8762306a36Sopenharmony_ciendef
8862306a36Sopenharmony_ci
8962306a36Sopenharmony_ci$(obj)/syms.bin: $(obj)/vmlinux.syms FORCE
9062306a36Sopenharmony_ci	$(call if_changed,dumpsyms)
9162306a36Sopenharmony_ci
9262306a36Sopenharmony_ciOBJCOPYFLAGS_syms.o := -I binary -O elf64-s390 -B s390:64-bit --rename-section .data=.decompressor.syms
9362306a36Sopenharmony_ci$(obj)/syms.o: $(obj)/syms.bin FORCE
9462306a36Sopenharmony_ci	$(call if_changed,objcopy)
9562306a36Sopenharmony_ci
9662306a36Sopenharmony_ciOBJCOPYFLAGS_info.bin := -O binary --only-section=.vmlinux.info --set-section-flags .vmlinux.info=load
9762306a36Sopenharmony_ci$(obj)/info.bin: vmlinux FORCE
9862306a36Sopenharmony_ci	$(call if_changed,objcopy)
9962306a36Sopenharmony_ci
10062306a36Sopenharmony_ciOBJCOPYFLAGS_info.o := -I binary -O elf64-s390 -B s390:64-bit --rename-section .data=.vmlinux.info
10162306a36Sopenharmony_ci$(obj)/info.o: $(obj)/info.bin FORCE
10262306a36Sopenharmony_ci	$(call if_changed,objcopy)
10362306a36Sopenharmony_ci
10462306a36Sopenharmony_ciOBJCOPYFLAGS_vmlinux.bin := -O binary --remove-section=.comment --remove-section=.vmlinux.info -S
10562306a36Sopenharmony_ci$(obj)/vmlinux.bin: vmlinux FORCE
10662306a36Sopenharmony_ci	$(call if_changed,objcopy)
10762306a36Sopenharmony_ci
10862306a36Sopenharmony_cisuffix-$(CONFIG_KERNEL_GZIP)  := .gz
10962306a36Sopenharmony_cisuffix-$(CONFIG_KERNEL_BZIP2) := .bz2
11062306a36Sopenharmony_cisuffix-$(CONFIG_KERNEL_LZ4)  := .lz4
11162306a36Sopenharmony_cisuffix-$(CONFIG_KERNEL_LZMA)  := .lzma
11262306a36Sopenharmony_cisuffix-$(CONFIG_KERNEL_LZO)  := .lzo
11362306a36Sopenharmony_cisuffix-$(CONFIG_KERNEL_XZ)  := .xz
11462306a36Sopenharmony_cisuffix-$(CONFIG_KERNEL_ZSTD)  := .zst
11562306a36Sopenharmony_ci
11662306a36Sopenharmony_ci$(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE
11762306a36Sopenharmony_ci	$(call if_changed,gzip)
11862306a36Sopenharmony_ci$(obj)/vmlinux.bin.bz2: $(obj)/vmlinux.bin FORCE
11962306a36Sopenharmony_ci	$(call if_changed,bzip2_with_size)
12062306a36Sopenharmony_ci$(obj)/vmlinux.bin.lz4: $(obj)/vmlinux.bin FORCE
12162306a36Sopenharmony_ci	$(call if_changed,lz4_with_size)
12262306a36Sopenharmony_ci$(obj)/vmlinux.bin.lzma: $(obj)/vmlinux.bin FORCE
12362306a36Sopenharmony_ci	$(call if_changed,lzma_with_size)
12462306a36Sopenharmony_ci$(obj)/vmlinux.bin.lzo: $(obj)/vmlinux.bin FORCE
12562306a36Sopenharmony_ci	$(call if_changed,lzo_with_size)
12662306a36Sopenharmony_ci$(obj)/vmlinux.bin.xz: $(obj)/vmlinux.bin FORCE
12762306a36Sopenharmony_ci	$(call if_changed,xzkern_with_size)
12862306a36Sopenharmony_ci$(obj)/vmlinux.bin.zst: $(obj)/vmlinux.bin FORCE
12962306a36Sopenharmony_ci	$(call if_changed,zstd22_with_size)
13062306a36Sopenharmony_ci
13162306a36Sopenharmony_ciOBJCOPYFLAGS_piggy.o := -I binary -O elf64-s390 -B s390:64-bit --rename-section .data=.vmlinux.bin.compressed
13262306a36Sopenharmony_ci$(obj)/piggy.o: $(obj)/vmlinux.bin$(suffix-y) FORCE
13362306a36Sopenharmony_ci	$(call if_changed,objcopy)
134