xref: /linux-6.15/arch/x86/Makefile (revision 1e7857b2)
1b2441318SGreg Kroah-Hartman# SPDX-License-Identifier: GPL-2.0
274b469f2SSam Ravnborg# Unified Makefile for i386 and x86_64
374b469f2SSam Ravnborg
42266cfd5SSam Ravnborg# select defconfig based on actual architecture
5d746d647SSam Ravnborgifeq ($(ARCH),x86)
6f9bb7f6aSArnd Bergmann  ifeq ($(shell uname -m | sed -e 's/i.86/i386/'),i386)
7d746d647SSam Ravnborg        KBUILD_DEFCONFIG := i386_defconfig
8f9bb7f6aSArnd Bergmann  else
9f9bb7f6aSArnd Bergmann        KBUILD_DEFCONFIG := x86_64_defconfig
10ffee0de4SDavid Woodhouse  endif
11d746d647SSam Ravnborgelse
122266cfd5SSam Ravnborg        KBUILD_DEFCONFIG := $(ARCH)_defconfig
13d746d647SSam Ravnborgendif
142266cfd5SSam Ravnborg
15b2f825bfSPeter Zijlstraifdef CONFIG_CC_IS_GCC
16b2f825bfSPeter ZijlstraRETPOLINE_CFLAGS	:= $(call cc-option,-mindirect-branch=thunk-extern -mindirect-branch-register)
17b2f825bfSPeter ZijlstraRETPOLINE_VDSO_CFLAGS	:= $(call cc-option,-mindirect-branch=thunk-inline -mindirect-branch-register)
18b2f825bfSPeter Zijlstraendif
19b2f825bfSPeter Zijlstraifdef CONFIG_CC_IS_CLANG
20b2f825bfSPeter ZijlstraRETPOLINE_CFLAGS	:= -mretpoline-external-thunk
21b2f825bfSPeter ZijlstraRETPOLINE_VDSO_CFLAGS	:= -mretpoline
22b2f825bfSPeter Zijlstraendif
2327b5de62SNathan ChancellorRETPOLINE_CFLAGS	+= $(call cc-option,-mindirect-branch-cs-prefix)
24f43b9876SPeter Zijlstra
250911b8c5SBreno Leitaoifdef CONFIG_MITIGATION_RETHUNK
26f43b9876SPeter ZijlstraRETHUNK_CFLAGS		:= -mfunction-return=thunk-extern
27d7868550SMiguel OjedaRETHUNK_RUSTFLAGS	:= -Zfunction-return=thunk-extern
28f43b9876SPeter ZijlstraRETPOLINE_CFLAGS	+= $(RETHUNK_CFLAGS)
29d7868550SMiguel OjedaRETPOLINE_RUSTFLAGS	+= $(RETHUNK_RUSTFLAGS)
30f43b9876SPeter Zijlstraendif
31f43b9876SPeter Zijlstra
32efc72a66SJosh Poimboeufexport RETHUNK_CFLAGS
33d7868550SMiguel Ojedaexport RETHUNK_RUSTFLAGS
34b2f825bfSPeter Zijlstraexport RETPOLINE_CFLAGS
35d7868550SMiguel Ojedaexport RETPOLINE_RUSTFLAGS
36b2f825bfSPeter Zijlstraexport RETPOLINE_VDSO_CFLAGS
37b2f825bfSPeter Zijlstra
38d77698dfSMatthias Kaehlcke# For gcc stack alignment is specified with -mpreferred-stack-boundary,
39d77698dfSMatthias Kaehlcke# clang has the option -mstack-alignment for that purpose.
40d77698dfSMatthias Kaehlckeifneq ($(call cc-option, -mpreferred-stack-boundary=4),)
418f918697SMatthias Kaehlcke      cc_stack_align4 := -mpreferred-stack-boundary=2
428f918697SMatthias Kaehlcke      cc_stack_align8 := -mpreferred-stack-boundary=3
438f918697SMatthias Kaehlckeelse ifneq ($(call cc-option, -mstack-alignment=16),)
448f918697SMatthias Kaehlcke      cc_stack_align4 := -mstack-alignment=4
458f918697SMatthias Kaehlcke      cc_stack_align8 := -mstack-alignment=8
46d77698dfSMatthias Kaehlckeendif
47d77698dfSMatthias Kaehlcke
481c678da3SDavid Woodhouse# How to compile the 16-bit code.  Note we always compile for -march=i386;
491c678da3SDavid Woodhouse# that way we can complain to the user if the CPU is insufficient.
50b3bee1e7SAlexey DobriyanREALMODE_CFLAGS	:= -std=gnu11 -m16 -g -Os -DDISABLE_BRANCH_PROFILING -D__DISABLE_EXPORTS \
511c678da3SDavid Woodhouse		   -Wall -Wstrict-prototypes -march=i386 -mregparm=3 \
521c678da3SDavid Woodhouse		   -fno-strict-aliasing -fomit-frame-pointer -fno-pic \
539fcb51c1SArnd Bergmann		   -mno-mmx -mno-sse $(call cc-option,-fcf-protection=none)
54032a2c4fSMatthias Kaehlcke
55685969e0SMasahiro YamadaREALMODE_CFLAGS += -ffreestanding
56893ab004SMasahiro YamadaREALMODE_CFLAGS += -fno-stack-protector
57989ceac7SNick DesaulniersREALMODE_CFLAGS += -Wno-address-of-packed-member
58989ceac7SNick DesaulniersREALMODE_CFLAGS += $(cc_stack_align4)
598abe7fc2SJohn MillikinREALMODE_CFLAGS += $(CLANG_FLAGS)
602afa7994SThomas Zimmermannifdef CONFIG_CC_IS_CLANG
612afa7994SThomas ZimmermannREALMODE_CFLAGS += -Wno-gnu
622afa7994SThomas Zimmermannendif
631c678da3SDavid Woodhouseexport REALMODE_CFLAGS
641c678da3SDavid Woodhouse
650a6ef376SSam Ravnborg# BITS is used as extension for files which are available in a 32 bit
660a6ef376SSam Ravnborg# and a 64 bit version to simplify shared Makefiles.
670a6ef376SSam Ravnborg# e.g.: obj-y += foo_$(BITS).o
680a6ef376SSam Ravnborgexport BITS
6974b469f2SSam Ravnborg
70b2c51106SAndy Lutomirski#
71b2c51106SAndy Lutomirski# Prevent GCC from generating any FP code by mistake.
72b2c51106SAndy Lutomirski#
73b2c51106SAndy Lutomirski# This must happen before we try the -mpreferred-stack-boundary, see:
74b2c51106SAndy Lutomirski#
75b2c51106SAndy Lutomirski#    https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53383
76b2c51106SAndy Lutomirski#
77989ceac7SNick DesaulniersKBUILD_CFLAGS += -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx
78f82811e2SJamie CunliffeKBUILD_RUSTFLAGS += --target=$(objtree)/scripts/target.json
7909498135SMiguel OjedaKBUILD_RUSTFLAGS += -Ctarget-feature=-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-avx,-avx2
80b2c51106SAndy Lutomirski
81b0b8a15bSSamuel Holland#
82b0b8a15bSSamuel Holland# CFLAGS for compiling floating point code inside the kernel.
83b0b8a15bSSamuel Holland#
84b0b8a15bSSamuel HollandCC_FLAGS_FPU := -msse -msse2
85b0b8a15bSSamuel Hollandifdef CONFIG_CC_IS_GCC
86b0b8a15bSSamuel Holland# Stack alignment mismatch, proceed with caution.
87b0b8a15bSSamuel Holland# GCC < 7.1 cannot compile code using `double` and -mpreferred-stack-boundary=3
88b0b8a15bSSamuel Holland# (8B stack alignment).
89b0b8a15bSSamuel Holland# See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53383
90b0b8a15bSSamuel Holland#
91b0b8a15bSSamuel Holland# The "-msse" in the first argument is there so that the
92b0b8a15bSSamuel Holland# -mpreferred-stack-boundary=3 build error:
93b0b8a15bSSamuel Holland#
94b0b8a15bSSamuel Holland#  -mpreferred-stack-boundary=3 is not between 4 and 12
95b0b8a15bSSamuel Holland#
96b0b8a15bSSamuel Holland# can be triggered. Otherwise gcc doesn't complain.
97b0b8a15bSSamuel HollandCC_FLAGS_FPU += -mhard-float
98b0b8a15bSSamuel HollandCC_FLAGS_FPU += $(call cc-option,-msse -mpreferred-stack-boundary=3,-mpreferred-stack-boundary=4)
99b0b8a15bSSamuel Hollandendif
100b0b8a15bSSamuel Holland
101156ff4a5SPeter Zijlstraifeq ($(CONFIG_X86_KERNEL_IBT),y)
102156ff4a5SPeter Zijlstra#
103156ff4a5SPeter Zijlstra# Kernel IBT has S_CET.NOTRACK_EN=0, as such the compilers must not generate
104156ff4a5SPeter Zijlstra# NOTRACK prefixes. Current generation compilers unconditionally employ NOTRACK
105156ff4a5SPeter Zijlstra# for jump-tables, as such, disable jump-tables for now.
106156ff4a5SPeter Zijlstra#
107156ff4a5SPeter Zijlstra# (jump-tables are implicitly disabled by RETPOLINE)
108156ff4a5SPeter Zijlstra#
109156ff4a5SPeter Zijlstra#   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104816
110156ff4a5SPeter Zijlstra#
111156ff4a5SPeter ZijlstraKBUILD_CFLAGS += $(call cc-option,-fcf-protection=branch -fno-jump-tables)
1126a5c032cSMatthew MaurerKBUILD_RUSTFLAGS += -Zcf-protection=branch -Zno-jump-tables
113156ff4a5SPeter Zijlstraelse
114256b92afSBorislav PetkovKBUILD_CFLAGS += $(call cc-option,-fcf-protection=none)
115156ff4a5SPeter Zijlstraendif
116256b92afSBorislav Petkov
117d746d647SSam Ravnborgifeq ($(CONFIG_X86_32),y)
1180a6ef376SSam Ravnborg        BITS := 32
1198c6531f7SAndreas Herrmann        UTS_MACHINE := i386
1204ba7e5cdSSam Ravnborg        CHECKFLAGS += -D__i386__
1210a6ef376SSam Ravnborg
122989ceac7SNick Desaulniers        KBUILD_AFLAGS += -m32
123989ceac7SNick Desaulniers        KBUILD_CFLAGS += -m32
1240a6ef376SSam Ravnborg
1250a6ef376SSam Ravnborg        KBUILD_CFLAGS += -msoft-float -mregparm=3 -freg-struct-return
1260a6ef376SSam Ravnborg
127484d90eeSAndrew Boie        # Never want PIC in a 32-bit kernel, prevent breakage with GCC built
128484d90eeSAndrew Boie        # with nonstandard options
129484d90eeSAndrew Boie        KBUILD_CFLAGS += -fno-pic
130484d90eeSAndrew Boie
131d77698dfSMatthias Kaehlcke        # Align the stack to the register width instead of using the default
132d77698dfSMatthias Kaehlcke        # alignment of 16 bytes. This reduces stack usage and the number of
133d77698dfSMatthias Kaehlcke        # alignment instructions.
134989ceac7SNick Desaulniers        KBUILD_CFLAGS += $(cc_stack_align4)
1350a6ef376SSam Ravnborg
1360a6ef376SSam Ravnborg        # CPU-specific tuning. Anything which can be shared with UML should go here.
137d8285639SMasahiro Yamada        include $(srctree)/arch/x86/Makefile_32.cpu
1380a6ef376SSam Ravnborg        KBUILD_CFLAGS += $(cflags-y)
1390a6ef376SSam Ravnborg
140d70da124SKees Cook    ifneq ($(call clang-min-version, 160000),y)
14116cb16e0SKees Cook        # https://github.com/llvm/llvm-project/issues/53645
1420a6ef376SSam Ravnborg        KBUILD_CFLAGS += -ffreestanding
14316cb16e0SKees Cook    endif
1443fb0fdb3SAndy Lutomirski
14580d47defSBrian Gerst        percpu_seg := fs
1460a6ef376SSam Ravnborgelse
1470a6ef376SSam Ravnborg        BITS := 64
1480a6ef376SSam Ravnborg        UTS_MACHINE := x86_64
1491f2f01b1SLuc Van Oostenryck        CHECKFLAGS += -D__x86_64__
1500a6ef376SSam Ravnborg
1510a6ef376SSam Ravnborg        KBUILD_AFLAGS += -m64
1520a6ef376SSam Ravnborg        KBUILD_CFLAGS += -m64
1530a6ef376SSam Ravnborg
154be6cb027SIngo Molnar        # Align jump targets to 1 byte, not the default 16 bytes:
1552c4fd1acSMatthias Kaehlcke        KBUILD_CFLAGS += $(call cc-option,-falign-jumps=1)
156be6cb027SIngo Molnar
15752648e83SIngo Molnar        # Pack loops tightly as well:
1582c4fd1acSMatthias Kaehlcke        KBUILD_CFLAGS += $(call cc-option,-falign-loops=1)
15952648e83SIngo Molnar
1605c630089SRasmus Villemoes        # Don't autogenerate traditional x87 instructions
161989ceac7SNick Desaulniers        KBUILD_CFLAGS += -mno-80387
1628f2dd677SBehan Webster        KBUILD_CFLAGS += $(call cc-option,-mno-fp-ret-in-387)
1635551a34eSH. Peter Anvin
164d77698dfSMatthias Kaehlcke        # By default gcc and clang use a stack alignment of 16 bytes for x86.
165d77698dfSMatthias Kaehlcke        # However the standard kernel entry on x86-64 leaves the stack on an
166d77698dfSMatthias Kaehlcke        # 8-byte boundary. If the compiler isn't informed about the actual
167d77698dfSMatthias Kaehlcke        # alignment it will generate extra alignment instructions for the
168d77698dfSMatthias Kaehlcke        # default alignment which keep the stack *mis*aligned.
169d77698dfSMatthias Kaehlcke        # Furthermore an alignment to the register width reduces stack usage
170d77698dfSMatthias Kaehlcke        # and the number of alignment instructions.
171989ceac7SNick Desaulniers        KBUILD_CFLAGS += $(cc_stack_align8)
172d9b0cde9SH.J. Lu
173d9ee948dSH.J. Lu	# Use -mskip-rax-setup if supported.
174d9ee948dSH.J. Lu	KBUILD_CFLAGS += $(call cc-option,-mskip-rax-setup)
175d9ee948dSH.J. Lu
176f388f60cSArnd Bergmann        KBUILD_CFLAGS += -march=x86-64 -mtune=generic
177f388f60cSArnd Bergmann        KBUILD_RUSTFLAGS += -Ctarget-cpu=x86-64 -Ztune-cpu=generic
17809498135SMiguel Ojeda
1790a6ef376SSam Ravnborg        KBUILD_CFLAGS += -mno-red-zone
1800a6ef376SSam Ravnborg        KBUILD_CFLAGS += -mcmodel=kernel
18109498135SMiguel Ojeda        KBUILD_RUSTFLAGS += -Cno-redzone=y
18209498135SMiguel Ojeda        KBUILD_RUSTFLAGS += -Ccode-model=kernel
18380d47defSBrian Gerst
18480d47defSBrian Gerst        percpu_seg := gs
18580d47defSBrian Gerstendif
18680d47defSBrian Gerst
18780d47defSBrian Gerstifeq ($(CONFIG_STACKPROTECTOR),y)
18880d47defSBrian Gerst    ifeq ($(CONFIG_SMP),y)
18980d47defSBrian Gerst	KBUILD_CFLAGS += -mstack-protector-guard-reg=$(percpu_seg)
19080d47defSBrian Gerst	KBUILD_CFLAGS += -mstack-protector-guard-symbol=__ref_stack_chk_guard
19180d47defSBrian Gerst    else
19280d47defSBrian Gerst	KBUILD_CFLAGS += -mstack-protector-guard=global
19380d47defSBrian Gerst    endif
1945d707e9cSTejun Heoendif
1950a6ef376SSam Ravnborg
1963f135e57SJosh Poimboeuf#
1973f135e57SJosh Poimboeuf# If the function graph tracer is used with mcount instead of fentry,
1983f135e57SJosh Poimboeuf# '-maccumulate-outgoing-args' is needed to prevent a GCC bug
1993f135e57SJosh Poimboeuf# (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=42109)
2003f135e57SJosh Poimboeuf#
2013f135e57SJosh Poimboeufifdef CONFIG_FUNCTION_GRAPH_TRACER
2023f135e57SJosh Poimboeuf  ifndef CONFIG_HAVE_FENTRY
2033f135e57SJosh Poimboeuf	ACCUMULATE_OUTGOING_ARGS := 1
2043f135e57SJosh Poimboeuf  endif
2053f135e57SJosh Poimboeufendif
2063f135e57SJosh Poimboeuf
2073f135e57SJosh Poimboeufifeq ($(ACCUMULATE_OUTGOING_ARGS), 1)
2084a1bec46SNick Desaulniers	# This compiler flag is not supported by Clang:
2094a1bec46SNick Desaulniers	KBUILD_CFLAGS += $(call cc-option,-maccumulate-outgoing-args,)
2103f135e57SJosh Poimboeufendif
2113f135e57SJosh Poimboeuf
21225dfeeb7SSam Ravnborg# Workaround for a gcc prelease that unfortunately was shipped in a suse release
21325dfeeb7SSam RavnborgKBUILD_CFLAGS += -Wno-sign-compare
21425dfeeb7SSam Ravnborg#
21525dfeeb7SSam RavnborgKBUILD_CFLAGS += -fno-asynchronous-unwind-tables
2160a6ef376SSam Ravnborg
21776b04384SDavid Woodhouse# Avoid indirect branches in kernel to deal with Spectre
218aefb2f2eSBreno Leitaoifdef CONFIG_MITIGATION_RETPOLINE
2194cd24de3SZhenzhong Duan  KBUILD_CFLAGS += $(RETPOLINE_CFLAGS)
220d7868550SMiguel Ojeda  KBUILD_RUSTFLAGS += $(RETPOLINE_RUSTFLAGS)
221ce02ef06SDaniel Borkmann  # Additionally, avoid generating expensive indirect jumps which
222ce02ef06SDaniel Borkmann  # are subject to retpolines for small number of switch cases.
223284a3ac4SMiguel Ojeda  # LLVM turns off jump table generation by default when under
224a9d57ef1SDaniel Borkmann  # retpoline builds, however, gcc does not for x86. This has
225a9d57ef1SDaniel Borkmann  # only been fixed starting from gcc stable version 8.4.0 and
226a9d57ef1SDaniel Borkmann  # onwards, but not for older ones. See gcc bug #86952.
227a9d57ef1SDaniel Borkmann  ifndef CONFIG_CC_IS_CLANG
228989ceac7SNick Desaulniers    KBUILD_CFLAGS += -fno-jump-tables
229a9d57ef1SDaniel Borkmann  endif
23076b04384SDavid Woodhouseendif
23176b04384SDavid Woodhouse
2327b75782fSBreno Leitaoifdef CONFIG_MITIGATION_SLS
233e463a09aSPeter Zijlstra  KBUILD_CFLAGS += -mharden-sls=all
234e463a09aSPeter Zijlstraendif
235e463a09aSPeter Zijlstra
236931ab636SPeter Zijlstraifdef CONFIG_CALL_PADDING
237bea75b33SThomas GleixnerPADDING_CFLAGS := -fpatchable-function-entry=$(CONFIG_FUNCTION_PADDING_BYTES),$(CONFIG_FUNCTION_PADDING_BYTES)
238bea75b33SThomas GleixnerKBUILD_CFLAGS += $(PADDING_CFLAGS)
239bea75b33SThomas Gleixnerexport PADDING_CFLAGS
240ca627e63SMatthew Maurer
241ca627e63SMatthew MaurerPADDING_RUSTFLAGS := -Zpatchable-function-entry=$(CONFIG_FUNCTION_PADDING_BYTES),$(CONFIG_FUNCTION_PADDING_BYTES)
242ca627e63SMatthew MaurerKBUILD_RUSTFLAGS += $(PADDING_RUSTFLAGS)
243ca627e63SMatthew Maurerexport PADDING_RUSTFLAGS
244bea75b33SThomas Gleixnerendif
245bea75b33SThomas Gleixner
2460024430eSNathan ChancellorKBUILD_LDFLAGS += -m elf_$(UTS_MACHINE)
2470024430eSNathan Chancellor
248587af649SArvind Sankar#
249587af649SArvind Sankar# The 64-bit kernel must be aligned to 2MB.  Pass -z max-page-size=0x200000 to
250587af649SArvind Sankar# the linker to force 2MB page size regardless of the default page size used
251587af649SArvind Sankar# by the linker.
252587af649SArvind Sankar#
253587af649SArvind Sankarifdef CONFIG_X86_64
254587af649SArvind SankarLDFLAGS_vmlinux += -z max-page-size=0x200000
255587af649SArvind Sankarendif
256587af649SArvind Sankar
257587af649SArvind Sankar
258587af649SArvind Sankararchscripts: scripts_basic
259587af649SArvind Sankar	$(Q)$(MAKE) $(build)=arch/x86/tools relocs
260587af649SArvind Sankar
261587af649SArvind Sankar###
262587af649SArvind Sankar# Syscall table generation
26383109d5dSKees Cook
2643ce9e53eSMichal Marekarchheaders:
2656520fe55SH. Peter Anvin	$(Q)$(MAKE) $(build)=arch/x86/entry/syscalls all
2666520fe55SH. Peter Anvin
2670a6ef376SSam Ravnborg###
268303395acSH. Peter Anvin# <asm/cpufeaturemasks.h> header generation
269303395acSH. Peter Anvin
270303395acSH. Peter Anvincpufeaturemasks.hdr := arch/x86/include/generated/asm/cpufeaturemasks.h
2711f57d5d8SIngo Molnarcpufeaturemasks.awk := $(srctree)/arch/x86/tools/cpufeaturemasks.awk
272303395acSH. Peter Anvincpufeatures_hdr := $(srctree)/arch/x86/include/asm/cpufeatures.h
273303395acSH. Peter Anvintargets += $(cpufeaturemasks.hdr)
27484132633SH. Peter Anvin (Intel)      filechk_gen_featuremasks = $(AWK) -f $(cpufeaturemasks.awk) $(cpufeatures_hdr) $(KCONFIG_CONFIG)
27584132633SH. Peter Anvin (Intel)
27684132633SH. Peter Anvin (Intel)$(cpufeaturemasks.hdr): $(cpufeaturemasks.awk) $(cpufeatures_hdr) $(KCONFIG_CONFIG) FORCE
27784132633SH. Peter Anvin (Intel)	$(shell mkdir -p $(dir $@))
27884132633SH. Peter Anvin (Intel)	$(call filechk,gen_featuremasks)
27984132633SH. Peter Anvin (Intel)archprepare: $(cpufeaturemasks.hdr)
280*1e7857b2SLinus Torvalds
28184132633SH. Peter Anvin (Intel)###
28284132633SH. Peter Anvin (Intel)# Kernel objects
28384132633SH. Peter Anvin (Intel)
284*1e7857b2SLinus Torvaldslibs-y  += arch/x86/lib/
28584132633SH. Peter Anvin (Intel)
28684132633SH. Peter Anvin (Intel)# drivers-y are linked after core-y
28784132633SH. Peter Anvin (Intel)drivers-$(CONFIG_MATH_EMULATION) += arch/x86/math-emu/
2880a6ef376SSam Ravnborgdrivers-$(CONFIG_PCI)            += arch/x86/pci/
2890a6ef376SSam Ravnborg
2900a6ef376SSam Ravnborg# suspend and hibernation support
2910a6ef376SSam Ravnborgdrivers-$(CONFIG_PM) += arch/x86/power/
2920a6ef376SSam Ravnborg
2930a6ef376SSam Ravnborgdrivers-$(CONFIG_VIDEO) += arch/x86/video/
2940a6ef376SSam Ravnborg
2950a6ef376SSam Ravnborg####
296cf7700feSRafael J. Wysocki# boot loader support. Several targets are kept for legacy purposes
2970a6ef376SSam Ravnborg
298cf7700feSRafael J. Wysockiboot := arch/x86/boot
299f25eae2cSThomas Zimmermann
3000a6ef376SSam RavnborgBOOT_TARGETS = bzdisk fdimage fdimage144 fdimage288 hdimage isoimage
3010a6ef376SSam Ravnborg
3020a6ef376SSam RavnborgPHONY += bzImage $(BOOT_TARGETS)
3030a6ef376SSam Ravnborg
3040a6ef376SSam Ravnborg# Default kernel to build
3050a6ef376SSam Ravnborgall: bzImage
306f279b49fSH. Peter Anvin (Intel)
307f9c5107cSH. Peter Anvin# KBUILD_IMAGE specify target image being built
308f9c5107cSH. Peter AnvinKBUILD_IMAGE := $(boot)/bzImage
3090a6ef376SSam Ravnborg
3100a6ef376SSam RavnborgbzImage: vmlinux
3110a6ef376SSam Ravnborgifeq ($(CONFIG_X86_DECODER_SELFTEST),y)
3120a6ef376SSam Ravnborg	$(Q)$(MAKE) $(build)=arch/x86/tools posttest
3130a6ef376SSam Ravnborgendif
3140a6ef376SSam Ravnborg	$(Q)$(MAKE) $(build)=$(boot) $(KBUILD_IMAGE)
3150a6ef376SSam Ravnborg	$(Q)mkdir -p $(objtree)/arch/$(UTS_MACHINE)/boot
316f9c5107cSH. Peter Anvin	$(Q)ln -fsn ../../x86/boot/bzImage $(objtree)/arch/$(UTS_MACHINE)/boot/$@
317ca0e9badSMasami Hiramatsu
318ca0e9badSMasami Hiramatsu$(BOOT_TARGETS): vmlinux
319ca0e9badSMasami Hiramatsu	$(Q)$(MAKE) $(build)=$(boot) $@
3200a6ef376SSam Ravnborg
3210a6ef376SSam RavnborgPHONY += install
32241b3eae6SJan Beulichinstall:
3230a6ef376SSam Ravnborg	$(call cmd,install)
324f9c5107cSH. Peter Anvin
325f9c5107cSH. Peter Anvinvdso-install-$(CONFIG_X86_64)		+= arch/x86/entry/vdso/vdso64.so.dbg
3260a6ef376SSam Ravnborgvdso-install-$(CONFIG_X86_X32_ABI)	+= arch/x86/entry/vdso/vdsox32.so.dbg
3276d61b8e6SMasahiro Yamadavdso-install-$(CONFIG_COMPAT_32)	+= arch/x86/entry/vdso/vdso32.so.dbg
3286d61b8e6SMasahiro Yamada
329f774f5bbSMasahiro Yamadaarchprepare: checkbin
3301648e4f8SH. Peter Anvincheckbin:
33156769ba4SMasahiro Yamadaifdef CONFIG_MITIGATION_RETPOLINE
33256769ba4SMasahiro Yamadaifeq ($(RETPOLINE_CFLAGS),)
333289d0a47SMasahiro Yamada	@echo "You are building kernel with non-retpoline compiler." >&2
3340a6ef376SSam Ravnborg	@echo "Please update your compiler." >&2
335829fe4aaSBen Hutchings	@false
336829fe4aaSBen Hutchingsendif
337aefb2f2eSBreno Leitaoendif
33825896d07SMasahiro Yamada
33925896d07SMasahiro Yamadaifdef CONFIG_UNWINDER_ORC
34025896d07SMasahiro Yamadaorc_hash_h := arch/$(SRCARCH)/include/generated/asm/orc_hash.h
34125896d07SMasahiro Yamadaorc_hash_sh := $(srctree)/scripts/orc_hash.sh
34225896d07SMasahiro Yamadatargets += $(orc_hash_h)
34325896d07SMasahiro Yamadaquiet_cmd_orc_hash = GEN     $@
344829fe4aaSBen Hutchings      cmd_orc_hash = mkdir -p $(dir $@); \
345b9f174c8SOmar Sandoval		     $(CONFIG_SHELL) $(orc_hash_sh) < $< > $@
346b9f174c8SOmar Sandoval$(orc_hash_h): $(srctree)/arch/x86/include/asm/orc_types.h $(orc_hash_sh) FORCE
347b9f174c8SOmar Sandoval	$(call if_changed,orc_hash)
348b9f174c8SOmar Sandovalarchprepare: $(orc_hash_h)
349b9f174c8SOmar Sandovalendif
350b9f174c8SOmar Sandoval
351b9f174c8SOmar Sandovalarchclean:
352b9f174c8SOmar Sandoval	$(Q)rm -rf $(objtree)/arch/i386
353b9f174c8SOmar Sandoval	$(Q)rm -rf $(objtree)/arch/x86_64
354b9f174c8SOmar Sandoval
355b9f174c8SOmar Sandovaldefine archhelp
356b9f174c8SOmar Sandoval  echo  '* bzImage		- Compressed kernel image (arch/x86/boot/bzImage)'
3570a6ef376SSam Ravnborg  echo  '  install		- Install kernel using (your) ~/bin/$(INSTALLKERNEL) or'
3580a6ef376SSam Ravnborg  echo  '			  (distribution) /sbin/$(INSTALLKERNEL) or install to '
3590a6ef376SSam Ravnborg  echo  '			  $$(INSTALL_PATH) and run lilo'
3600a6ef376SSam Ravnborg  echo  ''
3610a6ef376SSam Ravnborg  echo  '  fdimage		- Create 1.4MB boot floppy image (arch/x86/boot/fdimage)'
3620a6ef376SSam Ravnborg  echo  '  fdimage144		- Create 1.4MB boot floppy image (arch/x86/boot/fdimage)'
363ac5d0887SBorislav Petkov  echo  '  fdimage288		- Create 2.8MB boot floppy image (arch/x86/boot/fdimage)'
364ac5d0887SBorislav Petkov  echo  '  hdimage		- Create a BIOS/EFI hard disk image (arch/x86/boot/hdimage)'
365ac5d0887SBorislav Petkov  echo  '  isoimage		- Create a boot CD-ROM image (arch/x86/boot/image.iso)'
366ac5d0887SBorislav Petkov  echo  '			  bzdisk/fdimage*/hdimage/isoimage also accept:'
36737f30e21SAndi Kleen  echo  '			  FDARGS="..."  arguments for the booted kernel'
36837f30e21SAndi Kleen  echo  '			  FDINITRD=file initrd for the booted kernel'
36937f30e21SAndi Kleen
370f279b49fSH. Peter Anvin (Intel)endef
37137f30e21SAndi Kleen