hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/arch/powerpc/Makefile
....@@ -17,31 +17,15 @@
1717 # Set default 32 bits cross compilers for vdso and boot wrapper
1818 CROSS32_COMPILE ?=
1919
20
-ifeq ($(HAS_BIARCH),y)
21
-ifeq ($(CROSS32_COMPILE),)
22
-ifdef CONFIG_PPC32
23
-# These options will be overridden by any -mcpu option that the CPU
24
-# or platform code sets later on the command line, but they are needed
25
-# to set a sane 32-bit cpu target for the 64-bit cross compiler which
26
-# may default to the wrong ISA.
27
-KBUILD_CFLAGS += -mcpu=powerpc
28
-KBUILD_AFLAGS += -mcpu=powerpc
29
-endif
30
-endif
31
-endif
20
+# If we're on a ppc/ppc64/ppc64le machine use that defconfig, otherwise just use
21
+# ppc64_defconfig because we have nothing better to go on.
22
+uname := $(shell uname -m)
23
+KBUILD_DEFCONFIG := $(if $(filter ppc%,$(uname)),$(uname),ppc64)_defconfig
3224
33
-ifeq ($(CROSS_COMPILE),)
34
-KBUILD_DEFCONFIG := $(shell uname -m)_defconfig
35
-else
36
-KBUILD_DEFCONFIG := ppc64_defconfig
37
-endif
38
-
39
-ifdef CONFIG_PPC64
4025 new_nm := $(shell if $(NM) --help 2>&1 | grep -- '--synthetic' > /dev/null; then echo y; else echo n; fi)
4126
4227 ifeq ($(new_nm),y)
4328 NM := $(NM) --synthetic
44
-endif
4529 endif
4630
4731 # BITS is used as extension for files which are available in a 32 bit
....@@ -64,7 +48,6 @@
6448 ifdef CONFIG_PPC32
6549 KBUILD_LDFLAGS_MODULE += arch/powerpc/lib/crtsavres.o
6650 else
67
-KBUILD_LDFLAGS_MODULE += -T $(srctree)/arch/powerpc/kernel/module.lds
6851 ifeq ($(call ld-ifversion, -ge, 225000000, y),y)
6952 # Have the linker provide sfpr if possible.
7053 # There is a corresponding test in arch/powerpc/lib/Makefile
....@@ -98,7 +81,7 @@
9881 endif
9982 endif
10083
101
-ifneq ($(cc-name),clang)
84
+ifndef CONFIG_CC_IS_CLANG
10285 cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mno-strict-align
10386 endif
10487
....@@ -111,13 +94,18 @@
11194 KBUILD_CFLAGS += -m$(BITS)
11295 KBUILD_AFLAGS += -m$(BITS) -Wl,-a$(BITS)
11396 KBUILD_LDFLAGS += -m elf$(BITS)$(LDEMULATION)
114
-KBUILD_ARFLAGS += --target=elf$(BITS)-$(GNUTARGET)
97
+endif
98
+
99
+cflags-$(CONFIG_STACKPROTECTOR) += -mstack-protector-guard=tls
100
+ifdef CONFIG_PPC64
101
+cflags-$(CONFIG_STACKPROTECTOR) += -mstack-protector-guard-reg=r13
102
+else
103
+cflags-$(CONFIG_STACKPROTECTOR) += -mstack-protector-guard-reg=r2
115104 endif
116105
117106 LDFLAGS_vmlinux-y := -Bstatic
118107 LDFLAGS_vmlinux-$(CONFIG_RELOCATABLE) := -pie
119108 LDFLAGS_vmlinux := $(LDFLAGS_vmlinux-y)
120
-LDFLAGS_vmlinux += $(call ld-option,--orphan-handling=warn)
121109
122110 ifdef CONFIG_PPC64
123111 ifeq ($(call cc-option-yn,-mcmodel=medium),y)
....@@ -165,9 +153,9 @@
165153 CFLAGS-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mtune=power9,-mtune=power8)
166154 else
167155 CFLAGS-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mtune=power7,$(call cc-option,-mtune=power5))
168
-CFLAGS-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mcpu=power5,-mcpu=power4)
156
+CFLAGS-$(CONFIG_GENERIC_CPU) += -mcpu=power4
169157 endif
170
-else
158
+else ifdef CONFIG_PPC_BOOK3E_64
171159 CFLAGS-$(CONFIG_GENERIC_CPU) += -mcpu=powerpc64
172160 endif
173161
....@@ -179,12 +167,13 @@
179167 # Work around gcc code-gen bugs with -pg / -fno-omit-frame-pointer in gcc <= 4.8
180168 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=44199
181169 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52828
182
-ifneq ($(cc-name),clang)
170
+ifndef CONFIG_CC_IS_CLANG
183171 CC_FLAGS_FTRACE += $(call cc-ifversion, -lt, 0409, -mno-sched-epilog)
184172 endif
185173 endif
186174
187175 CFLAGS-$(CONFIG_TARGET_CPU_BOOL) += $(call cc-option,-mcpu=$(CONFIG_TARGET_CPU))
176
+AFLAGS-$(CONFIG_TARGET_CPU_BOOL) += $(call cc-option,-mcpu=$(CONFIG_TARGET_CPU))
188177
189178 # Altivec option not allowed with e500mc64 in GCC.
190179 ifdef CONFIG_ALTIVEC
....@@ -195,20 +184,12 @@
195184 CFLAGS-$(CONFIG_E5500_CPU) += $(E5500_CPU)
196185 CFLAGS-$(CONFIG_E6500_CPU) += $(call cc-option,-mcpu=e6500,$(E5500_CPU))
197186
198
-ifdef CONFIG_PPC32
199
-ifdef CONFIG_PPC_E500MC
200
-CFLAGS-y += $(call cc-option,-mcpu=e500mc,-mcpu=powerpc)
201
-else
202
-CFLAGS-$(CONFIG_E500) += $(call cc-option,-mcpu=8540 -msoft-float,-mcpu=powerpc)
203
-endif
204
-endif
205
-
206187 asinstr := $(call as-instr,lis 9$(comma)foo@high,-DHAVE_AS_ATHIGH=1)
207188
208
-KBUILD_CPPFLAGS += -Iarch/$(ARCH) $(asinstr)
209
-KBUILD_AFLAGS += -Iarch/$(ARCH) $(AFLAGS-y)
189
+KBUILD_CPPFLAGS += -I $(srctree)/arch/$(ARCH) $(asinstr)
190
+KBUILD_AFLAGS += $(AFLAGS-y)
210191 KBUILD_CFLAGS += $(call cc-option,-msoft-float)
211
-KBUILD_CFLAGS += -pipe -Iarch/$(ARCH) $(CFLAGS-y)
192
+KBUILD_CFLAGS += -pipe $(CFLAGS-y)
212193 CPP = $(CC) -E $(KBUILD_CFLAGS)
213194
214195 CHECKFLAGS += -m$(BITS) -D__powerpc__ -D__powerpc$(BITS)__
....@@ -232,24 +213,15 @@
232213 KBUILD_CFLAGS += $(call cc-option,-mno-spe)
233214 KBUILD_CFLAGS += $(call cc-option,-mspe=no)
234215
235
-# Enable unit-at-a-time mode when possible. It shrinks the
236
-# kernel considerably.
237
-KBUILD_CFLAGS += $(call cc-option,-funit-at-a-time)
238
-
239
-# FIXME: the module load should be taught about the additional relocs
240
-# generated by this.
241
-# revert to pre-gcc-4.4 behaviour of .eh_frame
242
-KBUILD_CFLAGS += $(call cc-option,-fno-dwarf2-cfi-asm)
216
+# Don't emit .eh_frame since we have no use for it
217
+KBUILD_CFLAGS += -fno-asynchronous-unwind-tables
243218
244219 # Never use string load/store instructions as they are
245220 # often slow when they are implemented at all
246221 KBUILD_CFLAGS += $(call cc-option,-mno-string)
247222
248
-ifdef CONFIG_6xx
249
-KBUILD_CFLAGS += -mcpu=powerpc
250
-endif
251
-
252
-cpu-as-$(CONFIG_4xx) += -Wa,-m405
223
+cpu-as-$(CONFIG_40x) += -Wa,-m405
224
+cpu-as-$(CONFIG_44x) += -Wa,-m440
253225 cpu-as-$(CONFIG_ALTIVEC) += $(call as-option,-Wa$(comma)-maltivec)
254226 cpu-as-$(CONFIG_E500) += -Wa,-me500
255227
....@@ -265,7 +237,8 @@
265237 KBUILD_AFLAGS += $(aflags-y)
266238 KBUILD_CFLAGS += $(cflags-y)
267239
268
-head-y := arch/powerpc/kernel/head_$(BITS).o
240
+head-$(CONFIG_PPC64) := arch/powerpc/kernel/head_64.o
241
+head-$(CONFIG_PPC_BOOK3S_32) := arch/powerpc/kernel/head_book3s_32.o
269242 head-$(CONFIG_PPC_8xx) := arch/powerpc/kernel/head_8xx.o
270243 head-$(CONFIG_40x) := arch/powerpc/kernel/head_40x.o
271244 head-$(CONFIG_44x) := arch/powerpc/kernel/head_44x.o
....@@ -276,18 +249,8 @@
276249 head-$(CONFIG_ALTIVEC) += arch/powerpc/kernel/vector.o
277250 head-$(CONFIG_PPC_OF_BOOT_TRAMPOLINE) += arch/powerpc/kernel/prom_init.o
278251
279
-core-y += arch/powerpc/kernel/ \
280
- arch/powerpc/mm/ \
281
- arch/powerpc/lib/ \
282
- arch/powerpc/sysdev/ \
283
- arch/powerpc/platforms/ \
284
- arch/powerpc/math-emu/ \
285
- arch/powerpc/crypto/ \
286
- arch/powerpc/net/
287
-core-$(CONFIG_XMON) += arch/powerpc/xmon/
288
-core-$(CONFIG_KVM) += arch/powerpc/kvm/
289
-core-$(CONFIG_PERF_EVENTS) += arch/powerpc/perf/
290
-core-$(CONFIG_KEXEC_FILE) += arch/powerpc/purgatory/
252
+# See arch/powerpc/Kbuild for content of core part of the kernel
253
+core-y += arch/powerpc/
291254
292255 drivers-$(CONFIG_OPROFILE) += arch/powerpc/oprofile/
293256
....@@ -308,10 +271,8 @@
308271 $(Q)$(MAKE) $(build)=$(boot) $(patsubst %,$(boot)/%,$@)
309272
310273
274
+PHONY += bootwrapper_install
311275 bootwrapper_install:
312
- $(Q)$(MAKE) $(build)=$(boot) $(patsubst %,$(boot)/%,$@)
313
-
314
-%.dtb: scripts
315276 $(Q)$(MAKE) $(build)=$(boot) $(patsubst %,$(boot)/%,$@)
316277
317278 # Used to create 'merged defconfigs'
....@@ -333,44 +294,56 @@
333294 ppc64le_defconfig:
334295 $(call merge_into_defconfig,ppc64_defconfig,le)
335296
297
+PHONY += ppc64le_guest_defconfig
298
+ppc64le_guest_defconfig:
299
+ $(call merge_into_defconfig,ppc64_defconfig,le guest)
300
+
301
+PHONY += ppc64_guest_defconfig
302
+ppc64_guest_defconfig:
303
+ $(call merge_into_defconfig,ppc64_defconfig,be guest)
304
+
336305 PHONY += powernv_be_defconfig
337306 powernv_be_defconfig:
338307 $(call merge_into_defconfig,powernv_defconfig,be)
339308
340309 PHONY += mpc85xx_defconfig
341310 mpc85xx_defconfig:
342
- $(call merge_into_defconfig,mpc85xx_basic_defconfig,\
311
+ $(call merge_into_defconfig,mpc85xx_base.config,\
343312 85xx-32bit 85xx-hw fsl-emb-nonhw)
344313
345314 PHONY += mpc85xx_smp_defconfig
346315 mpc85xx_smp_defconfig:
347
- $(call merge_into_defconfig,mpc85xx_basic_defconfig,\
316
+ $(call merge_into_defconfig,mpc85xx_base.config,\
348317 85xx-32bit 85xx-smp 85xx-hw fsl-emb-nonhw)
349318
350319 PHONY += corenet32_smp_defconfig
351320 corenet32_smp_defconfig:
352
- $(call merge_into_defconfig,corenet_basic_defconfig,\
321
+ $(call merge_into_defconfig,corenet_base.config,\
353322 85xx-32bit 85xx-smp 85xx-hw fsl-emb-nonhw dpaa)
354323
355324 PHONY += corenet64_smp_defconfig
356325 corenet64_smp_defconfig:
357
- $(call merge_into_defconfig,corenet_basic_defconfig,\
326
+ $(call merge_into_defconfig,corenet_base.config,\
358327 85xx-64bit 85xx-smp altivec 85xx-hw fsl-emb-nonhw dpaa)
359328
360329 PHONY += mpc86xx_defconfig
361330 mpc86xx_defconfig:
362
- $(call merge_into_defconfig,mpc86xx_basic_defconfig,\
331
+ $(call merge_into_defconfig,mpc86xx_base.config,\
363332 86xx-hw fsl-emb-nonhw)
364333
365334 PHONY += mpc86xx_smp_defconfig
366335 mpc86xx_smp_defconfig:
367
- $(call merge_into_defconfig,mpc86xx_basic_defconfig,\
336
+ $(call merge_into_defconfig,mpc86xx_base.config,\
368337 86xx-smp 86xx-hw fsl-emb-nonhw)
369338
370339 PHONY += ppc32_allmodconfig
371340 ppc32_allmodconfig:
372341 $(Q)$(MAKE) KCONFIG_ALLCONFIG=$(srctree)/arch/powerpc/configs/book3s_32.config \
373342 -f $(srctree)/Makefile allmodconfig
343
+
344
+PHONY += ppc_defconfig
345
+ppc_defconfig:
346
+ $(call merge_into_defconfig,book3s_32.config,)
374347
375348 PHONY += ppc64le_allmodconfig
376349 ppc64le_allmodconfig:
....@@ -404,9 +377,11 @@
404377 @echo ' (minus the .dts extension).'
405378 endef
406379
380
+PHONY += install
407381 install:
408382 $(Q)$(MAKE) $(build)=$(boot) install
409383
384
+PHONY += vdso_install
410385 vdso_install:
411386 ifdef CONFIG_PPC64
412387 $(Q)$(MAKE) $(build)=arch/$(ARCH)/kernel/vdso64 $@
....@@ -420,10 +395,30 @@
420395
421396 archprepare: checkbin
422397
423
-# Use the file '.tmp_gas_check' for binutils tests, as gas won't output
424
-# to stdout and these checks are run even on install targets.
425
-TOUT := .tmp_gas_check
398
+archheaders:
399
+ $(Q)$(MAKE) $(build)=arch/powerpc/kernel/syscalls all
426400
401
+ifdef CONFIG_STACKPROTECTOR
402
+prepare: stack_protector_prepare
403
+
404
+PHONY += stack_protector_prepare
405
+stack_protector_prepare: prepare0
406
+ifdef CONFIG_PPC64
407
+ $(eval KBUILD_CFLAGS += -mstack-protector-guard-offset=$(shell awk '{if ($$2 == "PACA_CANARY") print $$3;}' include/generated/asm-offsets.h))
408
+else
409
+ $(eval KBUILD_CFLAGS += -mstack-protector-guard-offset=$(shell awk '{if ($$2 == "TASK_CANARY") print $$3;}' include/generated/asm-offsets.h))
410
+endif
411
+endif
412
+
413
+ifdef CONFIG_SMP
414
+prepare: task_cpu_prepare
415
+
416
+PHONY += task_cpu_prepare
417
+task_cpu_prepare: prepare0
418
+ $(eval KBUILD_CFLAGS += -D_TASK_CPU=$(shell awk '{if ($$2 == "TASK_CPU") print $$3;}' include/generated/asm-offsets.h))
419
+endif
420
+
421
+PHONY += checkbin
427422 # Check toolchain versions:
428423 # - gcc-4.6 is the minimum kernel-wide version so nothing required.
429424 checkbin:
....@@ -434,7 +429,3 @@
434429 echo -n '*** Please use a different binutils version.' ; \
435430 false ; \
436431 fi
437
-
438
-
439
-CLEAN_FILES += $(TOUT)
440
-