1577 Commits

Author SHA1 Message Date
Greg Kroah-Hartman
574a61d201 Linux 4.9.200 2019-11-10 11:23:33 +01:00
Seth Forshee
0446b0300c kbuild: add -fcf-protection=none when using retpoline flags
[ Upstream commit 29be86d7f9cb18df4123f309ac7857570513e8bc ]

The gcc -fcf-protection=branch option is not compatible with
-mindirect-branch=thunk-extern. The latter is used when
CONFIG_RETPOLINE is selected, and this will fail to build with
a gcc which has -fcf-protection=branch enabled by default. Adding
-fcf-protection=none when building with retpoline enabled
prevents such build failures.

Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-11-10 11:23:30 +01:00
Masahiro Yamada
2e1dff7b0d kbuild: use -fmacro-prefix-map to make __FILE__ a relative path
[ Upstream commit a73619a845d5625079cc1b3b820f44c899618388 ]

The __FILE__ macro is used everywhere in the kernel to locate the file
printing the log message, such as WARN_ON(), etc.  If the kernel is
built out of tree, this can be a long absolute path, like this:

  WARNING: CPU: 1 PID: 1 at /path/to/build/directory/arch/arm64/kernel/foo.c:...

This is because Kbuild runs in the objtree instead of the srctree,
then __FILE__ is expanded to a file path prefixed with $(srctree)/.

Commit 9da0763bdd82 ("kbuild: Use relative path when building in a
subdir of the source tree") improved this to some extent; $(srctree)
becomes ".." if the objtree is a child of the srctree.

For other cases of out-of-tree build, __FILE__ is still the absolute
path.  It also means the kernel image depends on where it was built.

A brand-new option from GCC, -fmacro-prefix-map, solves this problem.
If your compiler supports it, __FILE__ is the relative path from the
srctree regardless of O= option.  This provides more readable log and
more reproducible builds.

Please note __FILE__ is always an absolute path for external modules.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-11-10 11:23:30 +01:00
Kees Cook
a250cab009 Kbuild: make designated_init attribute fatal
[ Upstream commit c834f0e8a8bb3025aac38e802fca2e686720f544 ]

If a structure is marked with __attribute__((designated_init)) from
GCC or Sparse, it needs to have all static initializers using designated
initialization. Fail the build for any missing cases. This attribute will
be used by the randstruct plugin to make sure randomized structures are
being correctly initialized.

Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-11-10 11:23:29 +01:00
Greg Kroah-Hartman
352b498db8 Linux 4.9.199 2019-11-06 12:18:29 +01:00
Greg Kroah-Hartman
9e48f0c28d Linux 4.9.198 2019-10-29 09:15:27 +01:00
Greg Kroah-Hartman
364ef83db0 Linux 4.9.197 2019-10-17 13:42:47 -07:00
Greg Kroah-Hartman
140fcbee3e Linux 4.9.196 2019-10-07 18:53:25 +02:00
Greg Kroah-Hartman
6eea609ac3 Linux 4.9.195 2019-10-05 12:30:37 +02:00
Greg Kroah-Hartman
1b2be6d75a Linux 4.9.194 2019-09-21 07:14:23 +02:00
Greg Kroah-Hartman
779cde69dc Linux 4.9.193 2019-09-16 08:19:34 +02:00
Greg Kroah-Hartman
5ce2e06002 Linux 4.9.192 2019-09-10 10:31:05 +01:00
Greg Kroah-Hartman
bf489db05e Linux 4.9.191 2019-09-06 10:19:54 +02:00
Greg Kroah-Hartman
228e87c35b Linux 4.9.190 2019-08-25 10:51:53 +02:00
Greg Kroah-Hartman
4bd718dba6 Linux 4.9.189 2019-08-11 12:22:20 +02:00
Greg Kroah-Hartman
fa897d1731 Linux 4.9.188 2019-08-06 18:29:42 +02:00
Masahiro Yamada
757ee02703 kbuild: initialize CLANG_FLAGS correctly in the top Makefile
commit 5241ab4cf42d3a93b933b55d3d53f43049081fa1 upstream.

CLANG_FLAGS is initialized by the following line:

  CLANG_FLAGS     := --target=$(notdir $(CROSS_COMPILE:%-=%))

..., which is run only when CROSS_COMPILE is set.

Some build targets (bindeb-pkg etc.) recurse to the top Makefile.

When you build the kernel with Clang but without CROSS_COMPILE,
the same compiler flags such as -no-integrated-as are accumulated
into CLANG_FLAGS.

If you run 'make CC=clang' and then 'make CC=clang bindeb-pkg',
Kbuild will recompile everything needlessly due to the build command
change.

Fix this by correctly initializing CLANG_FLAGS.

Fixes: 238bcbc4e07f ("kbuild: consolidate Clang compiler flags")
Cc: <stable@vger.kernel.org> # v5.0+
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>
Acked-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-08-06 18:29:40 +02:00
Greg Kroah-Hartman
97d7530b83 Linux 4.9.187 2019-08-04 09:33:45 +02:00
Nathan Chancellor
7caebf6db7 kbuild: Add -Werror=unknown-warning-option to CLANG_FLAGS
[ Upstream commit 589834b3a0097a4908f4112eac0ca2feb486fa32 ]

In commit ebcc5928c5d9 ("arm64: Silence gcc warnings about arch ABI
drift"), the arm64 Makefile added -Wno-psabi to KBUILD_CFLAGS, which is
a GCC only option so clang rightfully complains:

warning: unknown warning option '-Wno-psabi' [-Wunknown-warning-option]

https://clang.llvm.org/docs/DiagnosticsReference.html#wunknown-warning-option

However, by default, this is merely a warning so the build happily goes
on with a slew of these warnings in the process.

Commit c3f0d0bc5b01 ("kbuild, LLVMLinux: Add -Werror to cc-option to
support clang") worked around this behavior in cc-option by adding
-Werror so that unknown flags cause an error. However, this all happens
silently and when an unknown flag is added to the build unconditionally
like -Wno-psabi, cc-option will always fail because there is always an
unknown flag in the list of flags. This manifested as link time failures
in the arm64 libstub because -fno-stack-protector didn't get added to
KBUILD_CFLAGS.

To avoid these weird cryptic failures in the future, make clang behave
like gcc and immediately error when it encounters an unknown flag by
adding -Werror=unknown-warning-option to CLANG_FLAGS. This can be added
unconditionally for clang because it is supported by at least 3.0.0,
according to godbolt [1] and 4.0.0, according to its documentation [2],
which is far earlier than we typically support.

[1]: https://godbolt.org/z/7F7rm3
[2]: https://releases.llvm.org/4.0.0/tools/clang/docs/DiagnosticsReference.html#wunknown-warning-option

Link: https://github.com/ClangBuiltLinux/linux/issues/511
Link: https://github.com/ClangBuiltLinux/linux/issues/517
Suggested-by: Peter Smith <peter.smith@linaro.org>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Tested-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-08-04 09:33:38 +02:00
Greg Kroah-Hartman
35c308d782 Linux 4.9.186 2019-07-21 09:06:09 +02:00
Greg Kroah-Hartman
9c51e1102c Linux 4.9.185 2019-07-10 09:55:47 +02:00
Linus Torvalds
7601d81506 gcc-9: silence 'address-of-packed-member' warning
commit 6f303d60534c46aa1a239f29c321f95c83dda748 upstream.

We already did this for clang, but now gcc has that warning too.  Yes,
yes, the address may be unaligned.  And that's kind of the point.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-07-10 09:55:28 +02:00
Greg Kroah-Hartman
09a7068360 Linux 4.9.184 2019-06-27 08:14:21 +08:00
Greg Kroah-Hartman
72f67fd749 Linux 4.9.183 2019-06-22 08:17:25 +02:00
Greg Kroah-Hartman
f4e2dd989e Linux 4.9.182 2019-06-17 19:53:33 +02:00
Greg Kroah-Hartman
3ffb2407c5 Linux 4.9.181 2019-06-11 12:22:50 +02:00
Greg Kroah-Hartman
b16a5334ed Linux 4.9.180 2019-05-31 06:48:32 -07:00
Greg Kroah-Hartman
2584e66ffb Linux 4.9.179 2019-05-25 18:26:58 +02:00
Greg Kroah-Hartman
a5f56b52c8 Linux 4.9.178 2019-05-21 18:49:01 +02:00
Greg Kroah-Hartman
8baec4ebdf Linux 4.9.177 2019-05-16 19:43:47 +02:00
Greg Kroah-Hartman
ffe8cffc8b Linux 4.9.176 2019-05-14 19:19:42 +02:00
Greg Kroah-Hartman
bb4f008d1e Linux 4.9.175 2019-05-10 17:52:11 +02:00
Greg Kroah-Hartman
d79b8577df Linux 4.9.174 2019-05-08 07:19:12 +02:00
Greg Kroah-Hartman
4b333b9c99 Linux 4.9.173 2019-05-04 08:49:10 +02:00
Greg Kroah-Hartman
5383785aaa Linux 4.9.172 2019-05-02 09:32:07 +02:00
Greg Kroah-Hartman
6bff0bba46 Linux 4.9.171 2019-04-27 09:34:48 +02:00
Matthias Kaehlcke
6950577c4f Revert "kbuild: use -Oz instead of -Os when using clang"
commit a75bb4eb9e565b9f5115e2e8c07377ce32cbe69a upstream.

The clang option -Oz enables *aggressive* optimization for size,
which doesn't necessarily result in smaller images, but can have
negative impact on performance. Switch back to the less aggressive
-Os.

This reverts commit 6748cb3c299de1ffbe56733647b01dbcc398c419.

Suggested-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-04-27 09:34:46 +02:00
Greg Kroah-Hartman
ad387ec4bc Linux 4.9.170 2019-04-20 09:07:54 +02:00
Greg Kroah-Hartman
df62169c33 Linux 4.9.169 2019-04-17 08:36:48 +02:00
Nick Desaulniers
1347aa2a4d kbuild: clang: choose GCC_TOOLCHAIN_DIR not on LD
commit ad15006cc78459d059af56729c4d9bed7c7fd860 upstream.

This causes an issue when trying to build with `make LD=ld.lld` if
ld.lld and the rest of your cross tools aren't in the same directory
(ex. /usr/local/bin) (as is the case for Android's build system), as the
GCC_TOOLCHAIN_DIR then gets set based on `which $(LD)` which will point
where LLVM tools are, not GCC/binutils tools are located.

Instead, select the GCC_TOOLCHAIN_DIR based on another tool provided by
binutils for which LLVM does not provide a substitute for, such as
elfedit.

Fixes: 785f11aa595b ("kbuild: Add better clang cross build support")
Link: https://github.com/ClangBuiltLinux/linux/issues/341
Suggested-by: Nathan Chancellor <natechancellor@gmail.com>
Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>
Tested-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-04-17 08:36:38 +02:00
Greg Kroah-Hartman
e93d474911 Linux 4.9.168 2019-04-05 22:29:15 +02:00
Greg Kroah-Hartman
21834d3e53 Linux 4.9.167 2019-04-03 06:24:20 +02:00
Greg Kroah-Hartman
60771fc402 Linux 4.9.166 2019-03-27 14:13:05 +09:00
Greg Kroah-Hartman
1c453afcda Linux 4.9.165 2019-03-23 13:19:54 +01:00
Greg Kroah-Hartman
f5fd34f057 Linux 4.9.164 2019-03-19 13:14:12 +01:00
Greg Kroah-Hartman
b834331609 Linux 4.9.163 2019-03-13 14:05:02 -07:00
Greg Kroah-Hartman
f422a02f86 Linux 4.9.162 2019-03-05 17:57:07 +01:00
Greg Kroah-Hartman
5507839a72 Linux 4.9.161 2019-02-27 10:07:03 +01:00
Masahiro Yamada
8ff3c2ecc1 kbuild: consolidate Clang compiler flags
commit 238bcbc4e07fad2fff99c5b157d0c37ccd4d093c upstream.

Collect basic Clang options such as --target, --prefix, --gcc-toolchain,
-no-integrated-as into a single variable CLANG_FLAGS so that it can be
easily reused in other parts of Makefile.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Tested-by: Nick Desaulniers <ndesaulniers@google.com>
Acked-by: Greg Hackmann <ghackmann@google.com>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-02-27 10:07:03 +01:00
Masahiro Yamada
c95a870d1c kbuild: add -no-integrated-as Clang option unconditionally
commit dbe27a002ef8573168cb64e181458ea23a74e2b6 upstream.

We are still a way off the Clang's integrated assembler support for
the kernel. Hence, -no-integrated-as is mandatory to build the kernel
with Clang. If you had an ancient version of Clang that does not
recognize this option, you would not be able to compile the kernel
anyway.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Tested-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-02-27 10:07:02 +01:00