Skip to content

Commit 607f865

Browse files
Matthias Kaehlckepundiramit
authored andcommitted
UPSTREAM: x86/build: Use cc-option to validate stack alignment parameter
With the following commit: 8f91869766c0 ("x86/build: Fix stack alignment for CLang") cc-option is only used to determine the name of the stack alignment option supported by the compiler, but not to verify that the actual parameter <option>=N is valid in combination with the other CFLAGS. This causes problems (as reported by the kbuild robot) with older GCC versions which only support stack alignment on a boundary of 16 bytes or higher. Also use (__)cc_option to add the stack alignment option to CFLAGS to make sure only valid options are added. Reported-by: kbuild test robot <fengguang.wu@intel.com> Signed-off-by: Matthias Kaehlcke <mka@chromium.org> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Bernhard.Rosenkranzer@linaro.org Cc: Greg Hackmann <ghackmann@google.com> Cc: Kees Cook <keescook@chromium.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Masahiro Yamada <yamada.masahiro@socionext.com> Cc: Michael Davidson <md@google.com> Cc: Nick Desaulniers <ndesaulniers@google.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephen Hines <srhines@google.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: dianders@chromium.org Fixes: 8f91869766c0 ("x86/build: Fix stack alignment for CLang") Link: http://lkml.kernel.org/r/20170817182047.176752-1-mka@chromium.org Signed-off-by: Ingo Molnar <mingo@kernel.org> (cherry picked from commit 9e8730b178a2472fca3123e909d6e69cc8127778) Signed-off-by: Greg Hackmann <ghackmann@google.com> Change-Id: Ia2c932ede0096fe399131e958e0aaf4835039294
1 parent f2b2d0a commit 607f865

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

arch/x86/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ REALMODE_CFLAGS := $(M16_CFLAGS) -g -Os -D__KERNEL__ \
3838

3939
REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), -ffreestanding)
4040
REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), -fno-stack-protector)
41-
REALMODE_CFLAGS += $(cc_stack_align4)
41+
REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), $(cc_stack_align4))
4242
export REALMODE_CFLAGS
4343

4444
# BITS is used as extension for files which are available in a 32 bit
@@ -78,7 +78,7 @@ ifeq ($(CONFIG_X86_32),y)
7878
# Align the stack to the register width instead of using the default
7979
# alignment of 16 bytes. This reduces stack usage and the number of
8080
# alignment instructions.
81-
KBUILD_CFLAGS += $(cc_stack_align4)
81+
KBUILD_CFLAGS += $(call cc-option,$(cc_stack_align4))
8282

8383
# Disable unit-at-a-time mode on pre-gcc-4.0 compilers, it makes gcc use
8484
# a lot more stack due to the lack of sharing of stacklots:
@@ -119,7 +119,7 @@ else
119119
# default alignment which keep the stack *mis*aligned.
120120
# Furthermore an alignment to the register width reduces stack usage
121121
# and the number of alignment instructions.
122-
KBUILD_CFLAGS += $(cc_stack_align8)
122+
KBUILD_CFLAGS += $(call cc-option,$(cc_stack_align8))
123123

124124
# Use -mskip-rax-setup if supported.
125125
KBUILD_CFLAGS += $(call cc-option,-mskip-rax-setup)

0 commit comments

Comments
 (0)