License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 17:07:57 +03:00
|
|
|
# SPDX-License-Identifier: GPL-2.0
|
2007-10-25 21:42:04 +04:00
|
|
|
# Unified Makefile for i386 and x86_64
|
|
|
|
|
2007-10-25 22:31:19 +04:00
|
|
|
# select defconfig based on actual architecture
|
2007-11-12 22:14:19 +03:00
|
|
|
ifeq ($(ARCH),x86)
|
2023-02-15 12:16:56 +03:00
|
|
|
ifeq ($(shell uname -m | sed -e 's/i.86/i386/'),i386)
|
2007-11-12 22:14:19 +03:00
|
|
|
KBUILD_DEFCONFIG := i386_defconfig
|
2023-02-15 12:16:56 +03:00
|
|
|
else
|
|
|
|
KBUILD_DEFCONFIG := x86_64_defconfig
|
2012-12-21 01:51:55 +04:00
|
|
|
endif
|
2007-11-12 22:14:19 +03:00
|
|
|
else
|
|
|
|
KBUILD_DEFCONFIG := $(ARCH)_defconfig
|
|
|
|
endif
|
2007-10-25 22:31:19 +04:00
|
|
|
|
2021-11-19 19:50:24 +03:00
|
|
|
ifdef CONFIG_CC_IS_GCC
|
|
|
|
RETPOLINE_CFLAGS := $(call cc-option,-mindirect-branch=thunk-extern -mindirect-branch-register)
|
|
|
|
RETPOLINE_VDSO_CFLAGS := $(call cc-option,-mindirect-branch=thunk-inline -mindirect-branch-register)
|
|
|
|
endif
|
|
|
|
ifdef CONFIG_CC_IS_CLANG
|
|
|
|
RETPOLINE_CFLAGS := -mretpoline-external-thunk
|
|
|
|
RETPOLINE_VDSO_CFLAGS := -mretpoline
|
|
|
|
endif
|
2023-01-20 19:58:27 +03:00
|
|
|
RETPOLINE_CFLAGS += $(call cc-option,-mindirect-branch-cs-prefix)
|
2022-06-28 01:21:17 +03:00
|
|
|
|
|
|
|
ifdef CONFIG_RETHUNK
|
|
|
|
RETHUNK_CFLAGS := -mfunction-return=thunk-extern
|
|
|
|
RETPOLINE_CFLAGS += $(RETHUNK_CFLAGS)
|
|
|
|
endif
|
|
|
|
|
2022-07-18 17:50:25 +03:00
|
|
|
export RETHUNK_CFLAGS
|
2021-11-19 19:50:24 +03:00
|
|
|
export RETPOLINE_CFLAGS
|
|
|
|
export RETPOLINE_VDSO_CFLAGS
|
|
|
|
|
2017-06-22 02:28:05 +03:00
|
|
|
# For gcc stack alignment is specified with -mpreferred-stack-boundary,
|
|
|
|
# clang has the option -mstack-alignment for that purpose.
|
|
|
|
ifneq ($(call cc-option, -mpreferred-stack-boundary=4),)
|
2017-08-17 03:47:40 +03:00
|
|
|
cc_stack_align4 := -mpreferred-stack-boundary=2
|
|
|
|
cc_stack_align8 := -mpreferred-stack-boundary=3
|
|
|
|
else ifneq ($(call cc-option, -mstack-alignment=16),)
|
|
|
|
cc_stack_align4 := -mstack-alignment=4
|
|
|
|
cc_stack_align8 := -mstack-alignment=8
|
2017-06-22 02:28:05 +03:00
|
|
|
endif
|
|
|
|
|
2014-01-08 15:21:20 +04:00
|
|
|
# How to compile the 16-bit code. Note we always compile for -march=i386;
|
|
|
|
# that way we can complain to the user if the CPU is insufficient.
|
2022-03-08 18:30:17 +03:00
|
|
|
REALMODE_CFLAGS := -m16 -g -Os -DDISABLE_BRANCH_PROFILING -D__DISABLE_EXPORTS \
|
2014-01-08 15:21:20 +04:00
|
|
|
-Wall -Wstrict-prototypes -march=i386 -mregparm=3 \
|
|
|
|
-fno-strict-aliasing -fomit-frame-pointer -fno-pic \
|
2021-03-23 15:48:36 +03:00
|
|
|
-mno-mmx -mno-sse $(call cc-option,-fcf-protection=none)
|
2017-06-22 02:28:04 +03:00
|
|
|
|
2020-06-26 21:59:13 +03:00
|
|
|
REALMODE_CFLAGS += -ffreestanding
|
2020-06-26 21:59:12 +03:00
|
|
|
REALMODE_CFLAGS += -fno-stack-protector
|
2021-08-12 21:38:48 +03:00
|
|
|
REALMODE_CFLAGS += -Wno-address-of-packed-member
|
|
|
|
REALMODE_CFLAGS += $(cc_stack_align4)
|
2021-03-26 03:04:33 +03:00
|
|
|
REALMODE_CFLAGS += $(CLANG_FLAGS)
|
2014-01-08 15:21:20 +04:00
|
|
|
export REALMODE_CFLAGS
|
|
|
|
|
2008-01-30 15:32:20 +03:00
|
|
|
# BITS is used as extension for files which are available in a 32 bit
|
|
|
|
# and a 64 bit version to simplify shared Makefiles.
|
|
|
|
# e.g.: obj-y += foo_$(BITS).o
|
|
|
|
export BITS
|
2007-10-25 21:42:04 +04:00
|
|
|
|
2015-07-21 19:27:18 +03:00
|
|
|
#
|
|
|
|
# Prevent GCC from generating any FP code by mistake.
|
|
|
|
#
|
|
|
|
# This must happen before we try the -mpreferred-stack-boundary, see:
|
|
|
|
#
|
|
|
|
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53383
|
|
|
|
#
|
2021-08-12 21:38:48 +03:00
|
|
|
KBUILD_CFLAGS += -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx
|
2022-08-04 13:16:44 +03:00
|
|
|
KBUILD_RUSTFLAGS += -Ctarget-feature=-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-avx,-avx2
|
2015-07-21 19:27:18 +03:00
|
|
|
|
2022-03-08 18:30:17 +03:00
|
|
|
ifeq ($(CONFIG_X86_KERNEL_IBT),y)
|
|
|
|
#
|
|
|
|
# Kernel IBT has S_CET.NOTRACK_EN=0, as such the compilers must not generate
|
|
|
|
# NOTRACK prefixes. Current generation compilers unconditionally employ NOTRACK
|
|
|
|
# for jump-tables, as such, disable jump-tables for now.
|
|
|
|
#
|
|
|
|
# (jump-tables are implicitly disabled by RETPOLINE)
|
|
|
|
#
|
|
|
|
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104816
|
|
|
|
#
|
|
|
|
KBUILD_CFLAGS += $(call cc-option,-fcf-protection=branch -fno-jump-tables)
|
|
|
|
else
|
2021-02-08 18:43:30 +03:00
|
|
|
KBUILD_CFLAGS += $(call cc-option,-fcf-protection=none)
|
2022-03-08 18:30:17 +03:00
|
|
|
endif
|
2021-02-08 18:43:30 +03:00
|
|
|
|
2007-11-12 22:14:19 +03:00
|
|
|
ifeq ($(CONFIG_X86_32),y)
|
2008-01-30 15:32:20 +03:00
|
|
|
BITS := 32
|
2007-11-20 01:58:57 +03:00
|
|
|
UTS_MACHINE := i386
|
2008-01-30 15:32:23 +03:00
|
|
|
CHECKFLAGS += -D__i386__
|
2008-01-30 15:32:20 +03:00
|
|
|
|
2021-08-12 21:38:48 +03:00
|
|
|
KBUILD_AFLAGS += -m32
|
|
|
|
KBUILD_CFLAGS += -m32
|
2008-01-30 15:32:20 +03:00
|
|
|
|
|
|
|
KBUILD_CFLAGS += -msoft-float -mregparm=3 -freg-struct-return
|
|
|
|
|
2012-08-10 22:49:06 +04:00
|
|
|
# Never want PIC in a 32-bit kernel, prevent breakage with GCC built
|
|
|
|
# with nonstandard options
|
|
|
|
KBUILD_CFLAGS += -fno-pic
|
|
|
|
|
2017-06-22 02:28:05 +03:00
|
|
|
# Align the stack to the register width instead of using the default
|
|
|
|
# alignment of 16 bytes. This reduces stack usage and the number of
|
|
|
|
# alignment instructions.
|
2021-08-12 21:38:48 +03:00
|
|
|
KBUILD_CFLAGS += $(cc_stack_align4)
|
2008-01-30 15:32:20 +03:00
|
|
|
|
|
|
|
# CPU-specific tuning. Anything which can be shared with UML should go here.
|
2021-07-24 21:35:56 +03:00
|
|
|
include $(srctree)/arch/x86/Makefile_32.cpu
|
2008-01-30 15:32:20 +03:00
|
|
|
KBUILD_CFLAGS += $(cflags-y)
|
|
|
|
|
|
|
|
# temporary until string.h is fixed
|
|
|
|
KBUILD_CFLAGS += -ffreestanding
|
x86/stackprotector/32: Make the canary into a regular percpu variable
On 32-bit kernels, the stackprotector canary is quite nasty -- it is
stored at %gs:(20), which is nasty because 32-bit kernels use %fs for
percpu storage. It's even nastier because it means that whether %gs
contains userspace state or kernel state while running kernel code
depends on whether stackprotector is enabled (this is
CONFIG_X86_32_LAZY_GS), and this setting radically changes the way
that segment selectors work. Supporting both variants is a
maintenance and testing mess.
Merely rearranging so that percpu and the stack canary
share the same segment would be messy as the 32-bit percpu address
layout isn't currently compatible with putting a variable at a fixed
offset.
Fortunately, GCC 8.1 added options that allow the stack canary to be
accessed as %fs:__stack_chk_guard, effectively turning it into an ordinary
percpu variable. This lets us get rid of all of the code to manage the
stack canary GDT descriptor and the CONFIG_X86_32_LAZY_GS mess.
(That name is special. We could use any symbol we want for the
%fs-relative mode, but for CONFIG_SMP=n, gcc refuses to let us use any
name other than __stack_chk_guard.)
Forcibly disable stackprotector on older compilers that don't support
the new options and turn the stack canary into a percpu variable. The
"lazy GS" approach is now used for all 32-bit configurations.
Also makes load_gs_index() work on 32-bit kernels. On 64-bit kernels,
it loads the GS selector and updates the user GSBASE accordingly. (This
is unchanged.) On 32-bit kernels, it loads the GS selector and updates
GSBASE, which is now always the user base. This means that the overall
effect is the same on 32-bit and 64-bit, which avoids some ifdeffery.
[ bp: Massage commit message. ]
Signed-off-by: Andy Lutomirski <luto@kernel.org>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/c0ff7dba14041c7e5d1cae5d4df052f03759bef3.1613243844.git.luto@kernel.org
2021-02-13 22:19:44 +03:00
|
|
|
|
|
|
|
ifeq ($(CONFIG_STACKPROTECTOR),y)
|
|
|
|
ifeq ($(CONFIG_SMP),y)
|
|
|
|
KBUILD_CFLAGS += -mstack-protector-guard-reg=fs -mstack-protector-guard-symbol=__stack_chk_guard
|
|
|
|
else
|
|
|
|
KBUILD_CFLAGS += -mstack-protector-guard=global
|
|
|
|
endif
|
|
|
|
endif
|
2007-10-25 21:42:04 +04:00
|
|
|
else
|
2008-01-30 15:32:20 +03:00
|
|
|
BITS := 64
|
2007-11-20 01:58:57 +03:00
|
|
|
UTS_MACHINE := x86_64
|
2018-05-30 23:48:38 +03:00
|
|
|
CHECKFLAGS += -D__x86_64__
|
2008-01-30 15:32:20 +03:00
|
|
|
|
|
|
|
KBUILD_AFLAGS += -m64
|
|
|
|
KBUILD_CFLAGS += -m64
|
|
|
|
|
x86: Align jump targets to 1-byte boundaries
The following NOP in a hot function caught my attention:
> 5a: 66 0f 1f 44 00 00 nopw 0x0(%rax,%rax,1)
That's a dead NOP that bloats the function a bit, added for the
default 16-byte alignment that GCC applies for jump targets.
I realize that x86 CPU manufacturers recommend 16-byte jump
target alignments (it's in the Intel optimization manual),
to help their relatively narrow decoder prefetch alignment
and uop cache constraints, but the cost of that is very
significant:
text data bss dec filename
12566391 1617840 1089536 15273767 vmlinux.align.16-byte
12224951 1617840 1089536 14932327 vmlinux.align.1-byte
By using 1-byte jump target alignment (i.e. no alignment at all)
we get an almost 3% reduction in kernel size (!) - and a
probably similar reduction in I$ footprint.
Now, the usual justification for jump target alignment is the
following:
- modern decoders tend to have 16-byte (effective) decoder
prefetch windows. (AMD documents it higher but measurements
suggest the effective prefetch window on curretn uarchs is
still around 16 bytes)
- on Intel there's also the uop-cache with cachelines that have
16-byte granularity and limited associativity.
- older x86 uarchs had a penalty for decoder fetches that crossed
16-byte boundaries. These limits are mostly gone from recent
uarchs.
So if a forward jump target is aligned to cacheline boundary then
prefetches will start from a new prefetch-cacheline and there's
higher chance for decoding in fewer steps and packing tightly.
But I think that argument is flawed for typical optimized kernel
code flows: forward jumps often go to 'cold' (uncommon) pieces
of code, and aligning cold code to cache lines does not bring a
lot of advantages (they are uncommon), while it causes
collateral damage:
- their alignment 'spreads out' the cache footprint, it shifts
followup hot code further out
- plus it slows down even 'cold' code that immediately follows 'hot'
code (like in the above case), which could have benefited from the
partial cacheline that comes off the end of hot code.
But even in the cache-hot case the 16 byte alignment brings
disadvantages:
- it spreads out the cache footprint, possibly making the code
fall out of the L1 I$.
- On Intel CPUs, recent microarchitectures have plenty of
uop cache (typically doubling every 3 years) - while the
size of the L1 cache grows much less aggressively. So
workloads are rarely uop cache limited.
The only situation where alignment might matter are tight
loops that could fit into a single 16 byte chunk - but those
are pretty rare in the kernel: if they exist they tend
to be pointer chasing or generic memory ops, which both tend
to be cache miss (or cache allocation) intensive and are not
decoder bandwidth limited.
So the balance of arguments strongly favors packing kernel
instructions tightly versus maximizing for decoder bandwidth:
this patch changes the jump target alignment from 16 bytes
to 1 byte (tightly packed, unaligned).
Acked-by: Denys Vlasenko <dvlasenk@redhat.com>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Aswin Chandramouleeswaran <aswin@hp.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Davidlohr Bueso <dave@stgolabs.net>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Jason Low <jason.low2@hp.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tim Chen <tim.c.chen@linux.intel.com>
Link: http://lkml.kernel.org/r/20150410120846.GA17101@gmail.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2015-04-10 15:08:46 +03:00
|
|
|
# Align jump targets to 1 byte, not the default 16 bytes:
|
2017-04-13 20:26:09 +03:00
|
|
|
KBUILD_CFLAGS += $(call cc-option,-falign-jumps=1)
|
x86: Align jump targets to 1-byte boundaries
The following NOP in a hot function caught my attention:
> 5a: 66 0f 1f 44 00 00 nopw 0x0(%rax,%rax,1)
That's a dead NOP that bloats the function a bit, added for the
default 16-byte alignment that GCC applies for jump targets.
I realize that x86 CPU manufacturers recommend 16-byte jump
target alignments (it's in the Intel optimization manual),
to help their relatively narrow decoder prefetch alignment
and uop cache constraints, but the cost of that is very
significant:
text data bss dec filename
12566391 1617840 1089536 15273767 vmlinux.align.16-byte
12224951 1617840 1089536 14932327 vmlinux.align.1-byte
By using 1-byte jump target alignment (i.e. no alignment at all)
we get an almost 3% reduction in kernel size (!) - and a
probably similar reduction in I$ footprint.
Now, the usual justification for jump target alignment is the
following:
- modern decoders tend to have 16-byte (effective) decoder
prefetch windows. (AMD documents it higher but measurements
suggest the effective prefetch window on curretn uarchs is
still around 16 bytes)
- on Intel there's also the uop-cache with cachelines that have
16-byte granularity and limited associativity.
- older x86 uarchs had a penalty for decoder fetches that crossed
16-byte boundaries. These limits are mostly gone from recent
uarchs.
So if a forward jump target is aligned to cacheline boundary then
prefetches will start from a new prefetch-cacheline and there's
higher chance for decoding in fewer steps and packing tightly.
But I think that argument is flawed for typical optimized kernel
code flows: forward jumps often go to 'cold' (uncommon) pieces
of code, and aligning cold code to cache lines does not bring a
lot of advantages (they are uncommon), while it causes
collateral damage:
- their alignment 'spreads out' the cache footprint, it shifts
followup hot code further out
- plus it slows down even 'cold' code that immediately follows 'hot'
code (like in the above case), which could have benefited from the
partial cacheline that comes off the end of hot code.
But even in the cache-hot case the 16 byte alignment brings
disadvantages:
- it spreads out the cache footprint, possibly making the code
fall out of the L1 I$.
- On Intel CPUs, recent microarchitectures have plenty of
uop cache (typically doubling every 3 years) - while the
size of the L1 cache grows much less aggressively. So
workloads are rarely uop cache limited.
The only situation where alignment might matter are tight
loops that could fit into a single 16 byte chunk - but those
are pretty rare in the kernel: if they exist they tend
to be pointer chasing or generic memory ops, which both tend
to be cache miss (or cache allocation) intensive and are not
decoder bandwidth limited.
So the balance of arguments strongly favors packing kernel
instructions tightly versus maximizing for decoder bandwidth:
this patch changes the jump target alignment from 16 bytes
to 1 byte (tightly packed, unaligned).
Acked-by: Denys Vlasenko <dvlasenk@redhat.com>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Aswin Chandramouleeswaran <aswin@hp.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Davidlohr Bueso <dave@stgolabs.net>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Jason Low <jason.low2@hp.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tim Chen <tim.c.chen@linux.intel.com>
Link: http://lkml.kernel.org/r/20150410120846.GA17101@gmail.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2015-04-10 15:08:46 +03:00
|
|
|
|
2015-05-17 08:56:54 +03:00
|
|
|
# Pack loops tightly as well:
|
2017-04-13 20:26:09 +03:00
|
|
|
KBUILD_CFLAGS += $(call cc-option,-falign-loops=1)
|
2015-05-17 08:56:54 +03:00
|
|
|
|
2014-09-10 20:05:39 +04:00
|
|
|
# Don't autogenerate traditional x87 instructions
|
2021-08-12 21:38:48 +03:00
|
|
|
KBUILD_CFLAGS += -mno-80387
|
2014-04-22 09:40:27 +04:00
|
|
|
KBUILD_CFLAGS += $(call cc-option,-mno-fp-ret-in-387)
|
2013-11-21 01:31:49 +04:00
|
|
|
|
2017-06-22 02:28:05 +03:00
|
|
|
# By default gcc and clang use a stack alignment of 16 bytes for x86.
|
|
|
|
# However the standard kernel entry on x86-64 leaves the stack on an
|
|
|
|
# 8-byte boundary. If the compiler isn't informed about the actual
|
|
|
|
# alignment it will generate extra alignment instructions for the
|
|
|
|
# default alignment which keep the stack *mis*aligned.
|
|
|
|
# Furthermore an alignment to the register width reduces stack usage
|
|
|
|
# and the number of alignment instructions.
|
2021-08-12 21:38:48 +03:00
|
|
|
KBUILD_CFLAGS += $(cc_stack_align8)
|
2012-05-30 01:31:23 +04:00
|
|
|
|
2014-12-18 05:05:29 +03:00
|
|
|
# Use -mskip-rax-setup if supported.
|
|
|
|
KBUILD_CFLAGS += $(call cc-option,-mskip-rax-setup)
|
|
|
|
|
2008-01-30 15:32:20 +03:00
|
|
|
# FIXME - should be integrated in Makefile.cpu (Makefile_32.cpu)
|
2021-08-12 21:38:48 +03:00
|
|
|
cflags-$(CONFIG_MK8) += -march=k8
|
|
|
|
cflags-$(CONFIG_MPSC) += -march=nocona
|
|
|
|
cflags-$(CONFIG_MCORE2) += -march=core2
|
|
|
|
cflags-$(CONFIG_MATOM) += -march=atom
|
|
|
|
cflags-$(CONFIG_GENERIC_CPU) += -mtune=generic
|
2008-01-30 15:32:20 +03:00
|
|
|
KBUILD_CFLAGS += $(cflags-y)
|
|
|
|
|
2022-08-04 13:16:44 +03:00
|
|
|
rustflags-$(CONFIG_MK8) += -Ctarget-cpu=k8
|
|
|
|
rustflags-$(CONFIG_MPSC) += -Ctarget-cpu=nocona
|
|
|
|
rustflags-$(CONFIG_MCORE2) += -Ctarget-cpu=core2
|
|
|
|
rustflags-$(CONFIG_MATOM) += -Ctarget-cpu=atom
|
|
|
|
rustflags-$(CONFIG_GENERIC_CPU) += -Ztune-cpu=generic
|
|
|
|
KBUILD_RUSTFLAGS += $(rustflags-y)
|
|
|
|
|
2008-01-30 15:32:20 +03:00
|
|
|
KBUILD_CFLAGS += -mno-red-zone
|
|
|
|
KBUILD_CFLAGS += -mcmodel=kernel
|
2022-08-04 13:16:44 +03:00
|
|
|
KBUILD_RUSTFLAGS += -Cno-redzone=y
|
|
|
|
KBUILD_RUSTFLAGS += -Ccode-model=kernel
|
2009-02-09 16:17:39 +03:00
|
|
|
endif
|
2008-01-30 15:32:20 +03:00
|
|
|
|
2017-03-16 22:31:33 +03:00
|
|
|
#
|
|
|
|
# If the function graph tracer is used with mcount instead of fentry,
|
|
|
|
# '-maccumulate-outgoing-args' is needed to prevent a GCC bug
|
|
|
|
# (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=42109)
|
|
|
|
#
|
|
|
|
ifdef CONFIG_FUNCTION_GRAPH_TRACER
|
|
|
|
ifndef CONFIG_HAVE_FENTRY
|
|
|
|
ACCUMULATE_OUTGOING_ARGS := 1
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(ACCUMULATE_OUTGOING_ARGS), 1)
|
2017-05-09 06:29:46 +03:00
|
|
|
# This compiler flag is not supported by Clang:
|
|
|
|
KBUILD_CFLAGS += $(call cc-option,-maccumulate-outgoing-args,)
|
2017-03-16 22:31:33 +03:00
|
|
|
endif
|
|
|
|
|
2008-01-30 15:32:21 +03:00
|
|
|
# Workaround for a gcc prelease that unfortunately was shipped in a suse release
|
|
|
|
KBUILD_CFLAGS += -Wno-sign-compare
|
|
|
|
#
|
|
|
|
KBUILD_CFLAGS += -fno-asynchronous-unwind-tables
|
2008-01-30 15:32:20 +03:00
|
|
|
|
x86/retpoline: Add initial retpoline support
Enable the use of -mindirect-branch=thunk-extern in newer GCC, and provide
the corresponding thunks. Provide assembler macros for invoking the thunks
in the same way that GCC does, from native and inline assembler.
This adds X86_FEATURE_RETPOLINE and sets it by default on all CPUs. In
some circumstances, IBRS microcode features may be used instead, and the
retpoline can be disabled.
On AMD CPUs if lfence is serialising, the retpoline can be dramatically
simplified to a simple "lfence; jmp *\reg". A future patch, after it has
been verified that lfence really is serialising in all circumstances, can
enable this by setting the X86_FEATURE_RETPOLINE_AMD feature bit in addition
to X86_FEATURE_RETPOLINE.
Do not align the retpoline in the altinstr section, because there is no
guarantee that it stays aligned when it's copied over the oldinstr during
alternative patching.
[ Andi Kleen: Rename the macros, add CONFIG_RETPOLINE option, export thunks]
[ tglx: Put actual function CALL/JMP in front of the macros, convert to
symbolic labels ]
[ dwmw2: Convert back to numeric labels, merge objtool fixes ]
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Arjan van de Ven <arjan@linux.intel.com>
Acked-by: Ingo Molnar <mingo@kernel.org>
Cc: gnomes@lxorguk.ukuu.org.uk
Cc: Rik van Riel <riel@redhat.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: thomas.lendacky@amd.com
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Jiri Kosina <jikos@kernel.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Dave Hansen <dave.hansen@intel.com>
Cc: Kees Cook <keescook@google.com>
Cc: Tim Chen <tim.c.chen@linux.intel.com>
Cc: Greg Kroah-Hartman <gregkh@linux-foundation.org>
Cc: Paul Turner <pjt@google.com>
Link: https://lkml.kernel.org/r/1515707194-20531-4-git-send-email-dwmw@amazon.co.uk
2018-01-12 00:46:25 +03:00
|
|
|
# Avoid indirect branches in kernel to deal with Spectre
|
|
|
|
ifdef CONFIG_RETPOLINE
|
2018-11-02 11:45:41 +03:00
|
|
|
KBUILD_CFLAGS += $(RETPOLINE_CFLAGS)
|
x86, retpolines: Raise limit for generating indirect calls from switch-case
From networking side, there are numerous attempts to get rid of indirect
calls in fast-path wherever feasible in order to avoid the cost of
retpolines, for example, just to name a few:
* 283c16a2dfd3 ("indirect call wrappers: helpers to speed-up indirect calls of builtin")
* aaa5d90b395a ("net: use indirect call wrappers at GRO network layer")
* 028e0a476684 ("net: use indirect call wrappers at GRO transport layer")
* 356da6d0cde3 ("dma-mapping: bypass indirect calls for dma-direct")
* 09772d92cd5a ("bpf: avoid retpoline for lookup/update/delete calls on maps")
* 10870dd89e95 ("netfilter: nf_tables: add direct calls for all builtin expressions")
[...]
Recent work on XDP from Björn and Magnus additionally found that manually
transforming the XDP return code switch statement with more than 5 cases
into if-else combination would result in a considerable speedup in XDP
layer due to avoidance of indirect calls in CONFIG_RETPOLINE enabled
builds. On i40e driver with XDP prog attached, a 20-26% speedup has been
observed [0]. Aside from XDP, there are many other places later in the
networking stack's critical path with similar switch-case
processing. Rather than fixing every XDP-enabled driver and locations in
stack by hand, it would be good to instead raise the limit where gcc would
emit expensive indirect calls from the switch under retpolines and stick
with the default as-is in case of !retpoline configured kernels. This would
also have the advantage that for archs where this is not necessary, we let
compiler select the underlying target optimization for these constructs and
avoid potential slow-downs by if-else hand-rewrite.
In case of gcc, this setting is controlled by case-values-threshold which
has an architecture global default that selects 4 or 5 (latter if target
does not have a case insn that compares the bounds) where some arch back
ends like arm64 or s390 override it with their own target hooks, for
example, in gcc commit db7a90aa0de5 ("S/390: Disable prediction of indirect
branches") the threshold pretty much disables jump tables by limit of 20
under retpoline builds. Comparing gcc's and clang's default code
generation on x86-64 under O2 level with retpoline build results in the
following outcome for 5 switch cases:
* gcc with -mindirect-branch=thunk-inline -mindirect-branch-register:
# gdb -batch -ex 'disassemble dispatch' ./c-switch
Dump of assembler code for function dispatch:
0x0000000000400be0 <+0>: cmp $0x4,%edi
0x0000000000400be3 <+3>: ja 0x400c35 <dispatch+85>
0x0000000000400be5 <+5>: lea 0x915f8(%rip),%rdx # 0x4921e4
0x0000000000400bec <+12>: mov %edi,%edi
0x0000000000400bee <+14>: movslq (%rdx,%rdi,4),%rax
0x0000000000400bf2 <+18>: add %rdx,%rax
0x0000000000400bf5 <+21>: callq 0x400c01 <dispatch+33>
0x0000000000400bfa <+26>: pause
0x0000000000400bfc <+28>: lfence
0x0000000000400bff <+31>: jmp 0x400bfa <dispatch+26>
0x0000000000400c01 <+33>: mov %rax,(%rsp)
0x0000000000400c05 <+37>: retq
0x0000000000400c06 <+38>: nopw %cs:0x0(%rax,%rax,1)
0x0000000000400c10 <+48>: jmpq 0x400c90 <fn_3>
0x0000000000400c15 <+53>: nopl (%rax)
0x0000000000400c18 <+56>: jmpq 0x400c70 <fn_2>
0x0000000000400c1d <+61>: nopl (%rax)
0x0000000000400c20 <+64>: jmpq 0x400c50 <fn_1>
0x0000000000400c25 <+69>: nopl (%rax)
0x0000000000400c28 <+72>: jmpq 0x400c40 <fn_0>
0x0000000000400c2d <+77>: nopl (%rax)
0x0000000000400c30 <+80>: jmpq 0x400cb0 <fn_4>
0x0000000000400c35 <+85>: push %rax
0x0000000000400c36 <+86>: callq 0x40dd80 <abort>
End of assembler dump.
* clang with -mretpoline emitting search tree:
# gdb -batch -ex 'disassemble dispatch' ./c-switch
Dump of assembler code for function dispatch:
0x0000000000400b30 <+0>: cmp $0x1,%edi
0x0000000000400b33 <+3>: jle 0x400b44 <dispatch+20>
0x0000000000400b35 <+5>: cmp $0x2,%edi
0x0000000000400b38 <+8>: je 0x400b4d <dispatch+29>
0x0000000000400b3a <+10>: cmp $0x3,%edi
0x0000000000400b3d <+13>: jne 0x400b52 <dispatch+34>
0x0000000000400b3f <+15>: jmpq 0x400c50 <fn_3>
0x0000000000400b44 <+20>: test %edi,%edi
0x0000000000400b46 <+22>: jne 0x400b5c <dispatch+44>
0x0000000000400b48 <+24>: jmpq 0x400c20 <fn_0>
0x0000000000400b4d <+29>: jmpq 0x400c40 <fn_2>
0x0000000000400b52 <+34>: cmp $0x4,%edi
0x0000000000400b55 <+37>: jne 0x400b66 <dispatch+54>
0x0000000000400b57 <+39>: jmpq 0x400c60 <fn_4>
0x0000000000400b5c <+44>: cmp $0x1,%edi
0x0000000000400b5f <+47>: jne 0x400b66 <dispatch+54>
0x0000000000400b61 <+49>: jmpq 0x400c30 <fn_1>
0x0000000000400b66 <+54>: push %rax
0x0000000000400b67 <+55>: callq 0x40dd20 <abort>
End of assembler dump.
For sake of comparison, clang without -mretpoline:
# gdb -batch -ex 'disassemble dispatch' ./c-switch
Dump of assembler code for function dispatch:
0x0000000000400b30 <+0>: cmp $0x4,%edi
0x0000000000400b33 <+3>: ja 0x400b57 <dispatch+39>
0x0000000000400b35 <+5>: mov %edi,%eax
0x0000000000400b37 <+7>: jmpq *0x492148(,%rax,8)
0x0000000000400b3e <+14>: jmpq 0x400bf0 <fn_0>
0x0000000000400b43 <+19>: jmpq 0x400c30 <fn_4>
0x0000000000400b48 <+24>: jmpq 0x400c10 <fn_2>
0x0000000000400b4d <+29>: jmpq 0x400c20 <fn_3>
0x0000000000400b52 <+34>: jmpq 0x400c00 <fn_1>
0x0000000000400b57 <+39>: push %rax
0x0000000000400b58 <+40>: callq 0x40dcf0 <abort>
End of assembler dump.
Raising the cases to a high number (e.g. 100) will still result in similar
code generation pattern with clang and gcc as above, in other words clang
generally turns off jump table emission by having an extra expansion pass
under retpoline build to turn indirectbr instructions from their IR into
switch instructions as a built-in -mno-jump-table lowering of a switch (in
this case, even if IR input already contained an indirect branch).
For gcc, adding --param=case-values-threshold=20 as in similar fashion as
s390 in order to raise the limit for x86 retpoline enabled builds results
in a small vmlinux size increase of only 0.13% (before=18,027,528
after=18,051,192). For clang this option is ignored due to i) not being
needed as mentioned and ii) not having above cmdline
parameter. Non-retpoline-enabled builds with gcc continue to use the
default case-values-threshold setting, so nothing changes here.
[0] https://lore.kernel.org/netdev/20190129095754.9390-1-bjorn.topel@gmail.com/
and "The Path to DPDK Speeds for AF_XDP", LPC 2018, networking track:
- http://vger.kernel.org/lpc_net2018_talks/lpc18_pres_af_xdp_perf-v3.pdf
- http://vger.kernel.org/lpc_net2018_talks/lpc18_paper_af_xdp_perf-v2.pdf
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Jesper Dangaard Brouer <brouer@redhat.com>
Acked-by: Björn Töpel <bjorn.topel@intel.com>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: netdev@vger.kernel.org
Cc: David S. Miller <davem@davemloft.net>
Cc: Magnus Karlsson <magnus.karlsson@intel.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Link: https://lkml.kernel.org/r/20190221221941.29358-1-daniel@iogearbox.net
2019-02-22 01:19:41 +03:00
|
|
|
# Additionally, avoid generating expensive indirect jumps which
|
|
|
|
# are subject to retpolines for small number of switch cases.
|
|
|
|
# clang turns off jump table generation by default when under
|
2019-03-25 16:56:20 +03:00
|
|
|
# retpoline builds, however, gcc does not for x86. This has
|
|
|
|
# only been fixed starting from gcc stable version 8.4.0 and
|
|
|
|
# onwards, but not for older ones. See gcc bug #86952.
|
|
|
|
ifndef CONFIG_CC_IS_CLANG
|
2021-08-12 21:38:48 +03:00
|
|
|
KBUILD_CFLAGS += -fno-jump-tables
|
2019-03-25 16:56:20 +03:00
|
|
|
endif
|
x86/retpoline: Add initial retpoline support
Enable the use of -mindirect-branch=thunk-extern in newer GCC, and provide
the corresponding thunks. Provide assembler macros for invoking the thunks
in the same way that GCC does, from native and inline assembler.
This adds X86_FEATURE_RETPOLINE and sets it by default on all CPUs. In
some circumstances, IBRS microcode features may be used instead, and the
retpoline can be disabled.
On AMD CPUs if lfence is serialising, the retpoline can be dramatically
simplified to a simple "lfence; jmp *\reg". A future patch, after it has
been verified that lfence really is serialising in all circumstances, can
enable this by setting the X86_FEATURE_RETPOLINE_AMD feature bit in addition
to X86_FEATURE_RETPOLINE.
Do not align the retpoline in the altinstr section, because there is no
guarantee that it stays aligned when it's copied over the oldinstr during
alternative patching.
[ Andi Kleen: Rename the macros, add CONFIG_RETPOLINE option, export thunks]
[ tglx: Put actual function CALL/JMP in front of the macros, convert to
symbolic labels ]
[ dwmw2: Convert back to numeric labels, merge objtool fixes ]
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Arjan van de Ven <arjan@linux.intel.com>
Acked-by: Ingo Molnar <mingo@kernel.org>
Cc: gnomes@lxorguk.ukuu.org.uk
Cc: Rik van Riel <riel@redhat.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: thomas.lendacky@amd.com
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Jiri Kosina <jikos@kernel.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Dave Hansen <dave.hansen@intel.com>
Cc: Kees Cook <keescook@google.com>
Cc: Tim Chen <tim.c.chen@linux.intel.com>
Cc: Greg Kroah-Hartman <gregkh@linux-foundation.org>
Cc: Paul Turner <pjt@google.com>
Link: https://lkml.kernel.org/r/1515707194-20531-4-git-send-email-dwmw@amazon.co.uk
2018-01-12 00:46:25 +03:00
|
|
|
endif
|
|
|
|
|
2021-12-04 16:43:44 +03:00
|
|
|
ifdef CONFIG_SLS
|
|
|
|
KBUILD_CFLAGS += -mharden-sls=all
|
|
|
|
endif
|
|
|
|
|
2022-10-27 12:28:14 +03:00
|
|
|
ifdef CONFIG_CALL_PADDING
|
2022-09-15 14:11:18 +03:00
|
|
|
PADDING_CFLAGS := -fpatchable-function-entry=$(CONFIG_FUNCTION_PADDING_BYTES),$(CONFIG_FUNCTION_PADDING_BYTES)
|
|
|
|
KBUILD_CFLAGS += $(PADDING_CFLAGS)
|
|
|
|
export PADDING_CFLAGS
|
|
|
|
endif
|
|
|
|
|
2021-05-18 22:01:06 +03:00
|
|
|
KBUILD_LDFLAGS += -m elf_$(UTS_MACHINE)
|
|
|
|
|
|
|
|
ifdef CONFIG_LTO_CLANG
|
kbuild: add test-{ge,gt,le,lt} macros
GNU Make 4.4 introduced $(intcmp ...), which is useful to compare two
integers without forking a new process.
Add test-{ge,gt,le,lt} macros, which work more efficiently with GNU
Make >= 4.4. For older Make versions, they fall back to the 'test'
shell command.
The first two parameters to $(intcmp ...) must not be empty. To avoid
the syntax error, I appended '0' to them. Fortunately, '00' is treated
as '0'. This is needed because CONFIG options may expand to an empty
string when the kernel configuration is not included.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Acked-by: Palmer Dabbelt <palmer@rivosinc.com> # RISC-V
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
2022-12-11 05:46:47 +03:00
|
|
|
ifeq ($(call test-lt, $(CONFIG_LLD_VERSION), 130000),y)
|
2021-06-10 23:58:06 +03:00
|
|
|
KBUILD_LDFLAGS += -plugin-opt=-stack-alignment=$(if $(CONFIG_X86_32),4,8)
|
|
|
|
endif
|
2021-05-18 22:01:06 +03:00
|
|
|
endif
|
2020-07-22 21:43:34 +03:00
|
|
|
|
|
|
|
ifdef CONFIG_X86_NEED_RELOCS
|
|
|
|
LDFLAGS_vmlinux := --emit-relocs --discard-none
|
|
|
|
else
|
|
|
|
LDFLAGS_vmlinux :=
|
|
|
|
endif
|
|
|
|
|
|
|
|
#
|
|
|
|
# The 64-bit kernel must be aligned to 2MB. Pass -z max-page-size=0x200000 to
|
|
|
|
# the linker to force 2MB page size regardless of the default page size used
|
|
|
|
# by the linker.
|
|
|
|
#
|
|
|
|
ifdef CONFIG_X86_64
|
|
|
|
LDFLAGS_vmlinux += -z max-page-size=0x200000
|
|
|
|
endif
|
|
|
|
|
2020-09-02 05:53:46 +03:00
|
|
|
|
2012-10-15 23:16:56 +04:00
|
|
|
archscripts: scripts_basic
|
2012-05-08 22:22:24 +04:00
|
|
|
$(Q)$(MAKE) $(build)=arch/x86/tools relocs
|
|
|
|
|
2011-11-12 04:07:41 +04:00
|
|
|
###
|
|
|
|
# Syscall table generation
|
|
|
|
|
|
|
|
archheaders:
|
2015-06-03 19:36:41 +03:00
|
|
|
$(Q)$(MAKE) $(build)=arch/x86/entry/syscalls all
|
2011-11-12 04:07:41 +04:00
|
|
|
|
2008-01-30 15:32:20 +03:00
|
|
|
###
|
|
|
|
# Kernel objects
|
|
|
|
|
|
|
|
libs-y += arch/x86/lib/
|
|
|
|
|
|
|
|
# drivers-y are linked after core-y
|
|
|
|
drivers-$(CONFIG_MATH_EMULATION) += arch/x86/math-emu/
|
|
|
|
drivers-$(CONFIG_PCI) += arch/x86/pci/
|
|
|
|
|
2008-02-10 01:24:09 +03:00
|
|
|
# suspend and hibernation support
|
2008-01-30 15:32:20 +03:00
|
|
|
drivers-$(CONFIG_PM) += arch/x86/power/
|
2008-02-10 01:24:09 +03:00
|
|
|
|
2008-01-30 15:32:20 +03:00
|
|
|
drivers-$(CONFIG_FB) += arch/x86/video/
|
|
|
|
|
|
|
|
####
|
|
|
|
# boot loader support. Several targets are kept for legacy purposes
|
|
|
|
|
|
|
|
boot := arch/x86/boot
|
|
|
|
|
x86/boot: Modernize genimage script; hdimage+EFI support
The image generation scripts in arch/x86/boot are pretty out of date,
except for the isoimage target. Update and clean up the
genimage.sh script, and make it support an arbitrary number of
initramfs files in the image.
Add a "hdimage" target, which can be booted by either BIOS or
EFI (if the kernel is compiled with the EFI stub.) For EFI to be able
to pass the command line to the kernel, we need the EFI shell, but the
firmware builtin EFI shell, if it even exists, is pretty much always
the last resort boot option, so search for OVMF or EDK2 and explicitly
include a copy of the EFI shell.
To make this all work, use bash features in the script. Furthermore,
this version of the script makes use of some mtools features,
especially mpartition, that might not exist in very old version of
mtools, but given all the other dependencies on this script this
doesn't seem such a big deal.
Finally, put a volume label ("LINUX_BOOT") on all generated images.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20210510082840.628372-1-hpa@zytor.com
2021-05-10 11:28:40 +03:00
|
|
|
BOOT_TARGETS = bzdisk fdimage fdimage144 fdimage288 hdimage isoimage
|
2009-03-12 22:50:33 +03:00
|
|
|
|
|
|
|
PHONY += bzImage $(BOOT_TARGETS)
|
2008-01-30 15:32:20 +03:00
|
|
|
|
|
|
|
# Default kernel to build
|
|
|
|
all: bzImage
|
|
|
|
|
|
|
|
# KBUILD_IMAGE specify target image being built
|
2009-03-12 22:50:33 +03:00
|
|
|
KBUILD_IMAGE := $(boot)/bzImage
|
2008-01-30 15:32:20 +03:00
|
|
|
|
2009-03-12 22:50:33 +03:00
|
|
|
bzImage: vmlinux
|
2009-08-14 00:34:21 +04:00
|
|
|
ifeq ($(CONFIG_X86_DECODER_SELFTEST),y)
|
|
|
|
$(Q)$(MAKE) $(build)=arch/x86/tools posttest
|
|
|
|
endif
|
2008-01-30 15:32:20 +03:00
|
|
|
$(Q)$(MAKE) $(build)=$(boot) $(KBUILD_IMAGE)
|
|
|
|
$(Q)mkdir -p $(objtree)/arch/$(UTS_MACHINE)/boot
|
2008-04-22 19:29:26 +04:00
|
|
|
$(Q)ln -fsn ../../x86/boot/bzImage $(objtree)/arch/$(UTS_MACHINE)/boot/$@
|
2008-01-30 15:32:20 +03:00
|
|
|
|
2009-03-12 22:50:33 +03:00
|
|
|
$(BOOT_TARGETS): vmlinux
|
|
|
|
$(Q)$(MAKE) $(build)=$(boot) $@
|
2008-01-30 15:32:20 +03:00
|
|
|
|
2021-07-29 17:00:22 +03:00
|
|
|
PHONY += install
|
|
|
|
install:
|
2022-05-03 05:47:16 +03:00
|
|
|
$(call cmd,install)
|
2009-04-17 21:46:37 +04:00
|
|
|
|
2008-01-30 15:32:20 +03:00
|
|
|
PHONY += vdso_install
|
|
|
|
vdso_install:
|
2015-06-03 19:05:44 +03:00
|
|
|
$(Q)$(MAKE) $(build)=arch/x86/entry/vdso $@
|
2008-01-30 15:32:20 +03:00
|
|
|
|
2018-08-29 22:43:17 +03:00
|
|
|
archprepare: checkbin
|
|
|
|
checkbin:
|
2018-12-05 09:27:19 +03:00
|
|
|
ifdef CONFIG_RETPOLINE
|
|
|
|
ifeq ($(RETPOLINE_CFLAGS),)
|
|
|
|
@echo "You are building kernel with non-retpoline compiler." >&2
|
|
|
|
@echo "Please update your compiler." >&2
|
|
|
|
@false
|
|
|
|
endif
|
|
|
|
endif
|
2018-08-29 22:43:17 +03:00
|
|
|
|
2008-01-30 15:32:20 +03:00
|
|
|
archclean:
|
|
|
|
$(Q)rm -rf $(objtree)/arch/i386
|
|
|
|
$(Q)rm -rf $(objtree)/arch/x86_64
|
|
|
|
|
|
|
|
define archhelp
|
2020-12-17 16:42:00 +03:00
|
|
|
echo '* bzImage - Compressed kernel image (arch/x86/boot/bzImage)'
|
|
|
|
echo ' install - Install kernel using (your) ~/bin/$(INSTALLKERNEL) or'
|
|
|
|
echo ' (distribution) /sbin/$(INSTALLKERNEL) or install to '
|
|
|
|
echo ' $$(INSTALL_PATH) and run lilo'
|
|
|
|
echo ''
|
|
|
|
echo ' fdimage - Create 1.4MB boot floppy image (arch/x86/boot/fdimage)'
|
|
|
|
echo ' fdimage144 - Create 1.4MB boot floppy image (arch/x86/boot/fdimage)'
|
|
|
|
echo ' fdimage288 - Create 2.8MB boot floppy image (arch/x86/boot/fdimage)'
|
x86/boot: Modernize genimage script; hdimage+EFI support
The image generation scripts in arch/x86/boot are pretty out of date,
except for the isoimage target. Update and clean up the
genimage.sh script, and make it support an arbitrary number of
initramfs files in the image.
Add a "hdimage" target, which can be booted by either BIOS or
EFI (if the kernel is compiled with the EFI stub.) For EFI to be able
to pass the command line to the kernel, we need the EFI shell, but the
firmware builtin EFI shell, if it even exists, is pretty much always
the last resort boot option, so search for OVMF or EDK2 and explicitly
include a copy of the EFI shell.
To make this all work, use bash features in the script. Furthermore,
this version of the script makes use of some mtools features,
especially mpartition, that might not exist in very old version of
mtools, but given all the other dependencies on this script this
doesn't seem such a big deal.
Finally, put a volume label ("LINUX_BOOT") on all generated images.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20210510082840.628372-1-hpa@zytor.com
2021-05-10 11:28:40 +03:00
|
|
|
echo ' hdimage - Create a BIOS/EFI hard disk image (arch/x86/boot/hdimage)'
|
2020-12-17 16:42:00 +03:00
|
|
|
echo ' isoimage - Create a boot CD-ROM image (arch/x86/boot/image.iso)'
|
x86/boot: Modernize genimage script; hdimage+EFI support
The image generation scripts in arch/x86/boot are pretty out of date,
except for the isoimage target. Update and clean up the
genimage.sh script, and make it support an arbitrary number of
initramfs files in the image.
Add a "hdimage" target, which can be booted by either BIOS or
EFI (if the kernel is compiled with the EFI stub.) For EFI to be able
to pass the command line to the kernel, we need the EFI shell, but the
firmware builtin EFI shell, if it even exists, is pretty much always
the last resort boot option, so search for OVMF or EDK2 and explicitly
include a copy of the EFI shell.
To make this all work, use bash features in the script. Furthermore,
this version of the script makes use of some mtools features,
especially mpartition, that might not exist in very old version of
mtools, but given all the other dependencies on this script this
doesn't seem such a big deal.
Finally, put a volume label ("LINUX_BOOT") on all generated images.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20210510082840.628372-1-hpa@zytor.com
2021-05-10 11:28:40 +03:00
|
|
|
echo ' bzdisk/fdimage*/hdimage/isoimage also accept:'
|
2020-12-17 16:42:00 +03:00
|
|
|
echo ' FDARGS="..." arguments for the booted kernel'
|
2021-10-28 15:10:21 +03:00
|
|
|
echo ' FDINITRD=file initrd for the booted kernel'
|
2020-12-17 16:42:00 +03:00
|
|
|
echo ''
|
|
|
|
echo ' kvm_guest.config - Enable Kconfig items for running this kernel as a KVM guest'
|
|
|
|
echo ' xen.config - Enable Kconfig items for running this kernel as a Xen guest'
|
2022-03-31 20:57:28 +03:00
|
|
|
echo ' x86_debug.config - Enable tip tree debugging options for testing'
|
2020-12-17 15:13:34 +03:00
|
|
|
|
2008-01-30 15:32:20 +03:00
|
|
|
endef
|