mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH resend] x86: Fix detection of GCC -mpreferred-stack-boundary support
@ 2015-07-21 16:27 Andy Lutomirski
  2015-07-22  8:04 ` Borislav Petkov
  2015-07-27 15:51 ` [tip:x86/asm] x86/build: " tip-bot for Andy Lutomirski
  0 siblings, 2 replies; 3+ messages in thread
From: Andy Lutomirski @ 2015-07-21 16:27 UTC (permalink / raw)
  To: x86, linux-kernel
  Cc: Denys Vlasenko, Andy Lutomirski, Linus Torvalds, Jan Kara,
	Ingo Molnar, Borislav Petkov

As per https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53383, GCC only
allows -mpreferred-stack-boundary=3 on x86_64 if -mno-sse is set.
That means that cc-option will not detect
-mpreferred-stack-boundary=3 support, because we test for it before
setting -mno-sse.

Fix it by reordering the Makefile bits.

Compile-tested only.  This should help avoid code generation issues
such as the one that was worked around in b96fecbfa8c8 ("x86/fpu:
Fix boot crash in the early FPU code").

I'm a bit concerned that we could still have problems on older GCC
versions given that our asm code does not respect GCC's idea of the
ABI-required stack alignment.

Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Jan Kara <jack@suse.cz>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Signed-off-by: Andy Lutomirski <luto@kernel.org>
---
 arch/x86/Makefile | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 118e6debc483..344dd2110b2a 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -39,6 +39,12 @@ ifdef CONFIG_X86_NEED_RELOCS
         LDFLAGS_vmlinux := --emit-relocs
 endif
 
+# prevent gcc from generating any FP code by mistake
+# This must be before we try -mpreferred-stack-boundary -- see
+# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53383
+KBUILD_CFLAGS += -mno-sse -mno-mmx -mno-sse2 -mno-3dnow
+KBUILD_CFLAGS += $(call cc-option,-mno-avx,)
+
 ifeq ($(CONFIG_X86_32),y)
         BITS := 32
         UTS_MACHINE := i386
@@ -167,9 +173,6 @@ KBUILD_CFLAGS += -pipe
 KBUILD_CFLAGS += -Wno-sign-compare
 #
 KBUILD_CFLAGS += -fno-asynchronous-unwind-tables
-# prevent gcc from generating any FP code by mistake
-KBUILD_CFLAGS += -mno-sse -mno-mmx -mno-sse2 -mno-3dnow
-KBUILD_CFLAGS += $(call cc-option,-mno-avx,)
 
 KBUILD_CFLAGS += $(mflags-y)
 KBUILD_AFLAGS += $(mflags-y)
-- 
2.4.3


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH resend] x86: Fix detection of GCC -mpreferred-stack-boundary support
  2015-07-21 16:27 [PATCH resend] x86: Fix detection of GCC -mpreferred-stack-boundary support Andy Lutomirski
@ 2015-07-22  8:04 ` Borislav Petkov
  2015-07-27 15:51 ` [tip:x86/asm] x86/build: " tip-bot for Andy Lutomirski
  1 sibling, 0 replies; 3+ messages in thread
From: Borislav Petkov @ 2015-07-22  8:04 UTC (permalink / raw)
  To: Andy Lutomirski
  Cc: x86, linux-kernel, Denys Vlasenko, Linus Torvalds, Jan Kara, Ingo Molnar

On Tue, Jul 21, 2015 at 09:27:18AM -0700, Andy Lutomirski wrote:
> +# prevent gcc from generating any FP code by mistake
> +# This must be before we try -mpreferred-stack-boundary -- see
> +# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53383
> +KBUILD_CFLAGS += -mno-sse -mno-mmx -mno-sse2 -mno-3dnow
> +KBUILD_CFLAGS += $(call cc-option,-mno-avx,)

Should we unify all FPU-generating switches to one place? I've added
this

        # Don't autogenerate traditional x87 instructions
        KBUILD_CFLAGS += $(call cc-option,-mno-80387)
        KBUILD_CFLAGS += $(call cc-option,-mno-fp-ret-in-387)

to the 64-bit build a while back but I don't see why it shouldn't be in
the generic part of the Makefile...

Also, 32-bit has -msoft-float which, according to the gcc manpage is
ignored but I guess should be kept for older gccs...

-- 
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.
--

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [tip:x86/asm] x86/build: Fix detection of GCC -mpreferred-stack-boundary support
  2015-07-21 16:27 [PATCH resend] x86: Fix detection of GCC -mpreferred-stack-boundary support Andy Lutomirski
  2015-07-22  8:04 ` Borislav Petkov
@ 2015-07-27 15:51 ` tip-bot for Andy Lutomirski
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Andy Lutomirski @ 2015-07-27 15:51 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: luto, torvalds, luto, hpa, brgerst, bp, jack, dvlasenk, peterz,
	linux-kernel, mingo, tglx

Commit-ID:  b2c51106c7581866c37ffc77c5d739f3d4b7cbc9
Gitweb:     http://git.kernel.org/tip/b2c51106c7581866c37ffc77c5d739f3d4b7cbc9
Author:     Andy Lutomirski <luto@kernel.org>
AuthorDate: Tue, 21 Jul 2015 09:27:18 -0700
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Wed, 22 Jul 2015 08:20:29 +0200

x86/build: Fix detection of GCC -mpreferred-stack-boundary support

As per:

  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53383

GCC only allows -mpreferred-stack-boundary=3 on x86_64 if -mno-sse is set.
That means that cc-option will not detect -mpreferred-stack-boundary=3
support, because we test for it before setting -mno-sse.

Fix it by reordering the Makefile bits.

Compile-tested only.  This should help avoid code generation
issues such as the one that was worked around in:

  b96fecbfa8c8 ("x86/fpu: Fix boot crash in the early FPU code")

I'm a bit concerned that we could still have problems on older
GCC versions given that our asm code does not respect GCC's idea
of the ABI-required stack alignment.

Signed-off-by: Andy Lutomirski <luto@kernel.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Jan Kara <jack@suse.cz>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/f5297c192969adfa0d28b84cf8a22d59573db26d.1436126872.git.luto@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/Makefile | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 118e6de..054ff96 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -39,6 +39,16 @@ ifdef CONFIG_X86_NEED_RELOCS
         LDFLAGS_vmlinux := --emit-relocs
 endif
 
+#
+# 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
+#
+KBUILD_CFLAGS += -mno-sse -mno-mmx -mno-sse2 -mno-3dnow
+KBUILD_CFLAGS += $(call cc-option,-mno-avx,)
+
 ifeq ($(CONFIG_X86_32),y)
         BITS := 32
         UTS_MACHINE := i386
@@ -167,9 +177,6 @@ KBUILD_CFLAGS += -pipe
 KBUILD_CFLAGS += -Wno-sign-compare
 #
 KBUILD_CFLAGS += -fno-asynchronous-unwind-tables
-# prevent gcc from generating any FP code by mistake
-KBUILD_CFLAGS += -mno-sse -mno-mmx -mno-sse2 -mno-3dnow
-KBUILD_CFLAGS += $(call cc-option,-mno-avx,)
 
 KBUILD_CFLAGS += $(mflags-y)
 KBUILD_AFLAGS += $(mflags-y)

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-07-27 15:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-21 16:27 [PATCH resend] x86: Fix detection of GCC -mpreferred-stack-boundary support Andy Lutomirski
2015-07-22  8:04 ` Borislav Petkov
2015-07-27 15:51 ` [tip:x86/asm] x86/build: " tip-bot for Andy Lutomirski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®