Greg Kroah-Hartman | 0b73214 | 2017-11-24 15:00:38 +0100 | [diff] [blame] | 1 | # SPDX-License-Identifier: GPL-2.0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | # |
| 3 | # s390/Makefile |
| 4 | # |
| 5 | # This file is included by the global makefile so that you can add your own |
Masahiro Yamada | 8212f89 | 2021-10-13 15:36:22 +0900 | [diff] [blame] | 6 | # architecture-specific flags and dependencies. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | # |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | # Copyright (C) 1994 by Linus Torvalds |
| 9 | # |
| 10 | |
Martin Schwidefsky | 1844c9b | 2010-02-26 22:37:53 +0100 | [diff] [blame] | 11 | LD_BFD := elf64-s390 |
Masahiro Yamada | d503ac5 | 2018-08-24 08:20:39 +0900 | [diff] [blame] | 12 | KBUILD_LDFLAGS := -m elf64_s390 |
Martin Schwidefsky | 7bdc229 | 2013-01-11 15:26:01 +0100 | [diff] [blame] | 13 | KBUILD_AFLAGS_MODULE += -fPIC |
| 14 | KBUILD_CFLAGS_MODULE += -fPIC |
Sam Ravnborg | 222d394 | 2007-10-15 21:59:31 +0200 | [diff] [blame] | 15 | KBUILD_AFLAGS += -m64 |
Vasily Gorbik | 76bf9d6 | 2018-06-15 12:28:05 +0200 | [diff] [blame] | 16 | KBUILD_CFLAGS += -m64 |
Gerald Schaefer | 805bc0b | 2019-02-03 21:35:45 +0100 | [diff] [blame] | 17 | KBUILD_CFLAGS += -fPIE |
| 18 | LDFLAGS_vmlinux := -pie |
Vasily Gorbik | ee6d777 | 2018-06-28 19:22:21 +0200 | [diff] [blame] | 19 | aflags_dwarf := -Wa,-gdwarf-2 |
Arnd Bergmann | 96fb54a | 2019-04-15 10:35:52 +0200 | [diff] [blame] | 20 | KBUILD_AFLAGS_DECOMPRESSOR := $(CLANG_FLAGS) -m64 -D__ASSEMBLY__ |
Heiko Carstens | bb31074 | 2022-05-11 14:05:31 +0200 | [diff] [blame] | 21 | ifndef CONFIG_AS_IS_LLVM |
Vasily Gorbik | ee6d777 | 2018-06-28 19:22:21 +0200 | [diff] [blame] | 22 | KBUILD_AFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO),$(aflags_dwarf)) |
Heiko Carstens | bb31074 | 2022-05-11 14:05:31 +0200 | [diff] [blame] | 23 | endif |
Vasily Gorbik | 42b01a5 | 2022-01-29 00:34:13 +0100 | [diff] [blame] | 24 | KBUILD_CFLAGS_DECOMPRESSOR := $(CLANG_FLAGS) -m64 -O2 -mpacked-stack |
Vasily Gorbik | 76bf9d6 | 2018-06-15 12:28:05 +0200 | [diff] [blame] | 25 | KBUILD_CFLAGS_DECOMPRESSOR += -DDISABLE_BRANCH_PROFILING -D__NO_FORTIFY |
Vasily Gorbik | 8977ab6 | 2020-11-10 17:05:35 +0100 | [diff] [blame] | 26 | KBUILD_CFLAGS_DECOMPRESSOR += -fno-delete-null-pointer-checks -msoft-float -mbackchain |
Vasily Gorbik | 76bf9d6 | 2018-06-15 12:28:05 +0200 | [diff] [blame] | 27 | KBUILD_CFLAGS_DECOMPRESSOR += -fno-asynchronous-unwind-tables |
Masahiro Yamada | 685969e | 2020-06-27 03:59:13 +0900 | [diff] [blame] | 28 | KBUILD_CFLAGS_DECOMPRESSOR += -ffreestanding |
Fabrice Fontaine | 42e8d65 | 2021-05-10 07:31:33 +0200 | [diff] [blame] | 29 | KBUILD_CFLAGS_DECOMPRESSOR += -fno-stack-protector |
Heiko Carstens | f9364df | 2019-06-04 13:10:51 +0200 | [diff] [blame] | 30 | KBUILD_CFLAGS_DECOMPRESSOR += $(call cc-disable-warning, address-of-packed-member) |
Vasily Gorbik | ee6d777 | 2018-06-28 19:22:21 +0200 | [diff] [blame] | 31 | KBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO),-g) |
| 32 | KBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO_DWARF4), $(call cc-option, -gdwarf-4,)) |
Linus Torvalds | f0be87c | 2022-06-09 10:11:12 -0700 | [diff] [blame] | 33 | KBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_CC_NO_ARRAY_BOUNDS),-Wno-array-bounds) |
Sven Schnelle | 8b202ee | 2022-04-25 14:17:42 +0200 | [diff] [blame] | 34 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | UTS_MACHINE := s390x |
Vasily Gorbik | 9fed920 | 2018-10-26 15:29:59 +0200 | [diff] [blame] | 36 | STACK_SIZE := $(if $(CONFIG_KASAN),65536,16384) |
Luc Van Oostenryck | 14516765 | 2018-05-28 20:27:35 +0200 | [diff] [blame] | 37 | CHECKFLAGS += -D__s390__ -D__s390x__ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | |
Martin Schwidefsky | 1844c9b | 2010-02-26 22:37:53 +0100 | [diff] [blame] | 39 | export LD_BFD |
| 40 | |
Heiko Carstens | 0f1b1ff | 2014-08-14 16:06:02 +0200 | [diff] [blame] | 41 | mflags-$(CONFIG_MARCH_Z10) := -march=z10 |
| 42 | mflags-$(CONFIG_MARCH_Z196) := -march=z196 |
| 43 | mflags-$(CONFIG_MARCH_ZEC12) := -march=zEC12 |
Martin Schwidefsky | 6997c32 | 2017-04-12 14:17:25 +0200 | [diff] [blame] | 44 | mflags-$(CONFIG_MARCH_Z13) := -march=z13 |
| 45 | mflags-$(CONFIG_MARCH_Z14) := -march=z14 |
Martin Schwidefsky | a0e2251 | 2019-02-06 08:22:11 +0100 | [diff] [blame] | 46 | mflags-$(CONFIG_MARCH_Z15) := -march=z15 |
Heiko Carstens | e69a7ff | 2021-07-20 14:28:08 +0200 | [diff] [blame] | 47 | mflags-$(CONFIG_MARCH_Z16) := -march=z16 |
Heiko Carstens | 0f1b1ff | 2014-08-14 16:06:02 +0200 | [diff] [blame] | 48 | |
Martin Schwidefsky | 22362a0 | 2015-07-08 10:20:04 +0200 | [diff] [blame] | 49 | export CC_FLAGS_MARCH := $(mflags-y) |
| 50 | |
Heiko Carstens | 0f1b1ff | 2014-08-14 16:06:02 +0200 | [diff] [blame] | 51 | aflags-y += $(mflags-y) |
| 52 | cflags-y += $(mflags-y) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | |
Heiko Carstens | 1db9e05 | 2013-10-30 12:12:50 +0100 | [diff] [blame] | 54 | cflags-$(CONFIG_MARCH_Z10_TUNE) += -mtune=z10 |
| 55 | cflags-$(CONFIG_MARCH_Z196_TUNE) += -mtune=z196 |
| 56 | cflags-$(CONFIG_MARCH_ZEC12_TUNE) += -mtune=zEC12 |
Martin Schwidefsky | 6997c32 | 2017-04-12 14:17:25 +0200 | [diff] [blame] | 57 | cflags-$(CONFIG_MARCH_Z13_TUNE) += -mtune=z13 |
| 58 | cflags-$(CONFIG_MARCH_Z14_TUNE) += -mtune=z14 |
Martin Schwidefsky | a0e2251 | 2019-02-06 08:22:11 +0100 | [diff] [blame] | 59 | cflags-$(CONFIG_MARCH_Z15_TUNE) += -mtune=z15 |
Heiko Carstens | e69a7ff | 2021-07-20 14:28:08 +0200 | [diff] [blame] | 60 | cflags-$(CONFIG_MARCH_Z16_TUNE) += -mtune=z16 |
Heiko Carstens | 1db9e05 | 2013-10-30 12:12:50 +0100 | [diff] [blame] | 61 | |
Martin Schwidefsky | c783b91e | 2016-09-06 10:46:36 +0200 | [diff] [blame] | 62 | cflags-y += -Wa,-I$(srctree)/arch/$(ARCH)/include |
| 63 | |
Heiko Carstens | cbbd1fa | 2006-07-03 00:24:38 -0700 | [diff] [blame] | 64 | # |
| 65 | # Prevent tail-call optimizations, to get clearer backtraces: |
| 66 | # |
| 67 | cflags-$(CONFIG_FRAME_POINTER) += -fno-optimize-sibling-calls |
| 68 | |
Vasily Gorbik | 76bf9d6 | 2018-06-15 12:28:05 +0200 | [diff] [blame] | 69 | KBUILD_AFLAGS_DECOMPRESSOR += $(aflags-y) |
| 70 | KBUILD_CFLAGS_DECOMPRESSOR += $(cflags-y) |
| 71 | |
Nick Desaulniers | ff00f64 | 2021-08-16 17:21:04 -0700 | [diff] [blame] | 72 | ifneq ($(call cc-option,-mstack-size=8192 -mstack-guard=128),) |
Sven Schnelle | 00b55ea | 2021-11-11 10:58:26 +0100 | [diff] [blame] | 73 | CC_FLAGS_CHECK_STACK := -mstack-size=$(STACK_SIZE) |
| 74 | ifeq ($(call cc-option,-mstack-size=8192),) |
| 75 | CC_FLAGS_CHECK_STACK += -mstack-guard=$(CONFIG_STACK_GUARD) |
| 76 | endif |
| 77 | export CC_FLAGS_CHECK_STACK |
| 78 | cflags-$(CONFIG_CHECK_STACK) += $(CC_FLAGS_CHECK_STACK) |
Martin Schwidefsky | be79628 | 2007-04-27 16:01:46 +0200 | [diff] [blame] | 79 | endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | |
Martin Schwidefsky | f19fbd5 | 2018-01-26 12:46:47 +0100 | [diff] [blame] | 81 | ifdef CONFIG_EXPOLINE |
Vasily Gorbik | 1d2ad08 | 2022-03-06 20:56:07 +0100 | [diff] [blame] | 82 | ifdef CONFIG_EXPOLINE_EXTERN |
Vasily Gorbik | c4e7895 | 2022-06-27 14:50:53 +0200 | [diff] [blame] | 83 | KBUILD_LDFLAGS_MODULE += arch/s390/lib/expoline/expoline.o |
Vasily Gorbik | 1d2ad08 | 2022-03-06 20:56:07 +0100 | [diff] [blame] | 84 | CC_FLAGS_EXPOLINE := -mindirect-branch=thunk-extern |
| 85 | CC_FLAGS_EXPOLINE += -mfunction-return=thunk-extern |
| 86 | else |
Martin Schwidefsky | f19fbd5 | 2018-01-26 12:46:47 +0100 | [diff] [blame] | 87 | CC_FLAGS_EXPOLINE := -mindirect-branch=thunk |
| 88 | CC_FLAGS_EXPOLINE += -mfunction-return=thunk |
Martin Schwidefsky | f19fbd5 | 2018-01-26 12:46:47 +0100 | [diff] [blame] | 89 | endif |
Vasily Gorbik | 1d2ad08 | 2022-03-06 20:56:07 +0100 | [diff] [blame] | 90 | CC_FLAGS_EXPOLINE += -mindirect-branch-table |
| 91 | export CC_FLAGS_EXPOLINE |
| 92 | cflags-y += $(CC_FLAGS_EXPOLINE) -DCC_USING_EXPOLINE |
| 93 | aflags-y += -DCC_USING_EXPOLINE |
Martin Schwidefsky | f19fbd5 | 2018-01-26 12:46:47 +0100 | [diff] [blame] | 94 | endif |
| 95 | |
Heiko Carstens | e6d60b3 | 2015-01-09 13:08:28 +0100 | [diff] [blame] | 96 | ifdef CONFIG_FUNCTION_TRACER |
Nick Desaulniers | ff00f64 | 2021-08-16 17:21:04 -0700 | [diff] [blame] | 97 | ifeq ($(call cc-option,-mfentry -mnop-mcount),) |
Vasily Gorbik | d983c89 | 2018-08-06 15:17:47 +0200 | [diff] [blame] | 98 | # make use of hotpatch feature if the compiler supports it |
| 99 | cc_hotpatch := -mhotpatch=0,3 |
Nick Desaulniers | ff00f64 | 2021-08-16 17:21:04 -0700 | [diff] [blame] | 100 | ifneq ($(call cc-option,$(cc_hotpatch)),) |
Vasily Gorbik | d983c89 | 2018-08-06 15:17:47 +0200 | [diff] [blame] | 101 | CC_FLAGS_FTRACE := $(cc_hotpatch) |
| 102 | KBUILD_AFLAGS += -DCC_USING_HOTPATCH |
| 103 | KBUILD_CFLAGS += -DCC_USING_HOTPATCH |
| 104 | endif |
| 105 | endif |
Heiko Carstens | e6d60b3 | 2015-01-09 13:08:28 +0100 | [diff] [blame] | 106 | endif |
| 107 | |
Hendrik Brueckner | 7bceec4 | 2017-11-20 11:46:13 +0100 | [diff] [blame] | 108 | # Test CFI features of binutils |
| 109 | cfi := $(call as-instr,.cfi_startproc\n.cfi_val_offset 15$(comma)-160\n.cfi_endproc,-DCONFIG_AS_CFI_VAL_OFFSET=1) |
| 110 | |
Vasily Gorbik | 42b01a5 | 2022-01-29 00:34:13 +0100 | [diff] [blame] | 111 | KBUILD_CFLAGS += -mpacked-stack -mbackchain -msoft-float $(cflags-y) |
Arnd Bergmann | c1afcae | 2019-04-08 23:26:14 +0200 | [diff] [blame] | 112 | KBUILD_CFLAGS += -pipe -Wno-sign-compare |
Hendrik Brueckner | 7bceec4 | 2017-11-20 11:46:13 +0100 | [diff] [blame] | 113 | KBUILD_CFLAGS += -fno-asynchronous-unwind-tables $(cfi) |
| 114 | KBUILD_AFLAGS += $(aflags-y) $(cfi) |
Vasily Gorbik | 76bf9d6 | 2018-06-15 12:28:05 +0200 | [diff] [blame] | 115 | export KBUILD_AFLAGS_DECOMPRESSOR |
| 116 | export KBUILD_CFLAGS_DECOMPRESSOR |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | |
| 118 | OBJCOPYFLAGS := -O binary |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | |
Michael Holzheu | 4562c9f | 2007-02-21 10:55:46 +0100 | [diff] [blame] | 120 | libs-y += arch/s390/lib/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 121 | drivers-y += drivers/s390/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 122 | |
Michael Holzheu | 4562c9f | 2007-02-21 10:55:46 +0100 | [diff] [blame] | 123 | boot := arch/s390/boot |
Hendrik Brueckner | 5c75824 | 2017-12-11 14:54:08 +0100 | [diff] [blame] | 124 | syscalls := arch/s390/kernel/syscalls |
Heiko Carstens | c30f682 | 2015-02-02 07:08:44 +0100 | [diff] [blame] | 125 | tools := arch/s390/tools |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | |
Vasily Gorbik | 00f2fb5 | 2018-06-11 14:35:01 +0200 | [diff] [blame] | 127 | all: bzImage |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | |
Vasily Gorbik | e0aa099 | 2018-02-20 11:31:34 +0100 | [diff] [blame] | 129 | #KBUILD_IMAGE is necessary for packaging targets like rpm-pkg, deb-pkg... |
| 130 | KBUILD_IMAGE := $(boot)/bzImage |
| 131 | |
Masahiro Yamada | 94e90f7 | 2020-02-16 23:48:29 +0900 | [diff] [blame] | 132 | install: |
Masahiro Yamada | f774f5b | 2022-05-03 11:47:16 +0900 | [diff] [blame] | 133 | $(call cmd,install) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | |
Vasily Gorbik | 00f2fb5 | 2018-06-11 14:35:01 +0200 | [diff] [blame] | 135 | bzImage: vmlinux |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@ |
| 137 | |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 138 | zfcpdump: |
| 139 | $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@ |
| 140 | |
Hendrik Brueckner | f3cb31e | 2010-05-17 10:00:09 +0200 | [diff] [blame] | 141 | vdso_install: |
Hendrik Brueckner | f3cb31e | 2010-05-17 10:00:09 +0200 | [diff] [blame] | 142 | $(Q)$(MAKE) $(build)=arch/$(ARCH)/kernel/vdso64 $@ |
Hendrik Brueckner | f3cb31e | 2010-05-17 10:00:09 +0200 | [diff] [blame] | 143 | |
Hendrik Brueckner | 5c75824 | 2017-12-11 14:54:08 +0100 | [diff] [blame] | 144 | archheaders: |
| 145 | $(Q)$(MAKE) $(build)=$(syscalls) uapi |
| 146 | |
Heiko Carstens | c30f682 | 2015-02-02 07:08:44 +0100 | [diff] [blame] | 147 | archprepare: |
Hendrik Brueckner | 5c75824 | 2017-12-11 14:54:08 +0100 | [diff] [blame] | 148 | $(Q)$(MAKE) $(build)=$(syscalls) kapi |
Hendrik Brueckner | 7fbf831 | 2018-01-11 12:13:18 +0100 | [diff] [blame] | 149 | $(Q)$(MAKE) $(build)=$(tools) kapi |
Sven Schnelle | 779df22 | 2021-06-25 14:50:08 +0200 | [diff] [blame] | 150 | ifeq ($(KBUILD_EXTMOD),) |
| 151 | # We need to generate vdso-offsets.h before compiling certain files in kernel/. |
| 152 | # In order to do that, we should use the archprepare target, but we can't since |
| 153 | # asm-offsets.h is included in some files used to generate vdso-offsets.h, and |
| 154 | # asm-offsets.h is built in prepare0, for which archprepare is a dependency. |
| 155 | # Therefore we need to generate the header after prepare0 has been made, hence |
| 156 | # this hack. |
| 157 | prepare: vdso_prepare |
| 158 | vdso_prepare: prepare0 |
| 159 | $(Q)$(MAKE) $(build)=arch/s390/kernel/vdso64 include/generated/vdso64-offsets.h |
| 160 | $(if $(CONFIG_COMPAT),$(Q)$(MAKE) \ |
| 161 | $(build)=arch/s390/kernel/vdso32 include/generated/vdso32-offsets.h) |
Vasily Gorbik | c4e7895 | 2022-06-27 14:50:53 +0200 | [diff] [blame] | 162 | |
| 163 | ifdef CONFIG_EXPOLINE_EXTERN |
| 164 | modules_prepare: expoline_prepare |
Jiri Slaby (SUSE) | 7bb2107 | 2023-03-16 12:28:09 +0100 | [diff] [blame] | 165 | expoline_prepare: scripts |
Vasily Gorbik | c4e7895 | 2022-06-27 14:50:53 +0200 | [diff] [blame] | 166 | $(Q)$(MAKE) $(build)=arch/s390/lib/expoline arch/s390/lib/expoline/expoline.o |
| 167 | endif |
Sven Schnelle | 779df22 | 2021-06-25 14:50:08 +0200 | [diff] [blame] | 168 | endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 169 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 170 | # Don't use tabs in echo arguments |
| 171 | define archhelp |
Vasily Gorbik | 00f2fb5 | 2018-06-11 14:35:01 +0200 | [diff] [blame] | 172 | echo '* bzImage - Kernel image for IPL ($(boot)/bzImage)' |
Michael Holzheu | b8eecf3 | 2015-11-25 11:54:36 +0100 | [diff] [blame] | 173 | echo ' install - Install kernel using' |
| 174 | echo ' (your) ~/bin/$(INSTALLKERNEL) or' |
| 175 | echo ' (distribution) /sbin/$(INSTALLKERNEL) or' |
| 176 | echo ' install to $$(INSTALL_PATH)' |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 177 | endef |