All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86: prevent gcc from emitting SSE into boot code
@ 2016-06-22 17:37 Dmitry Vyukov
  2016-06-22 20:17 ` Dmitry Vyukov
  0 siblings, 1 reply; 4+ messages in thread
From: Dmitry Vyukov @ 2016-06-22 17:37 UTC (permalink / raw)
  To: hpa, tglx, mingo, x86
  Cc: linux-kernel, glider, ryabinin.a.a, kasan-dev, Dmitry Vyukov

Latest gcc manages to emit MOVDQA into boot code
which leads to crashes. Add more -mno-see flags.

Signed-off-by: Dmitry Vyukov <dvyukov@google.com>
---
 arch/x86/boot/compressed/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
index f135688..7eaafb8 100644
--- a/arch/x86/boot/compressed/Makefile
+++ b/arch/x86/boot/compressed/Makefile
@@ -31,7 +31,7 @@ KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
 cflags-$(CONFIG_X86_32) := -march=i386
 cflags-$(CONFIG_X86_64) := -mcmodel=small
 KBUILD_CFLAGS += $(cflags-y)
-KBUILD_CFLAGS += -mno-mmx -mno-sse
+KBUILD_CFLAGS += -mno-mmx -mno-sse -mno-sse2 -mno-sse3
 KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
 
-- 
2.8.0.rc3.226.g39d4020

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

* Re: [PATCH] x86: prevent gcc from emitting SSE into boot code
  2016-06-22 17:37 [PATCH] x86: prevent gcc from emitting SSE into boot code Dmitry Vyukov
@ 2016-06-22 20:17 ` Dmitry Vyukov
  2016-06-27 18:53   ` Ingo Molnar
  0 siblings, 1 reply; 4+ messages in thread
From: Dmitry Vyukov @ 2016-06-22 20:17 UTC (permalink / raw)
  To: H. Peter Anvin, Thomas Gleixner, Ingo Molnar, x86
  Cc: LKML, Alexander Potapenko, Andrey Ryabinin, kasan-dev, Dmitry Vyukov

On Wed, Jun 22, 2016 at 7:37 PM, Dmitry Vyukov <dvyukov@google.com> wrote:
> Latest gcc manages to emit MOVDQA into boot code
> which leads to crashes. Add more -mno-see flags.
>
> Signed-off-by: Dmitry Vyukov <dvyukov@google.com>
> ---
>  arch/x86/boot/compressed/Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
> index f135688..7eaafb8 100644
> --- a/arch/x86/boot/compressed/Makefile
> +++ b/arch/x86/boot/compressed/Makefile
> @@ -31,7 +31,7 @@ KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
>  cflags-$(CONFIG_X86_32) := -march=i386
>  cflags-$(CONFIG_X86_64) := -mcmodel=small
>  KBUILD_CFLAGS += $(cflags-y)
> -KBUILD_CFLAGS += -mno-mmx -mno-sse
> +KBUILD_CFLAGS += -mno-mmx -mno-sse -mno-sse2 -mno-sse3
>  KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
>  KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
>
> --
> 2.8.0.rc3.226.g39d4020


I withdraw this patch.

>From off-list discussion:

"-mno-sse alone should disable all SSE/AVX instructions. If not,
please file a GCC bug report".

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

* Re: [PATCH] x86: prevent gcc from emitting SSE into boot code
  2016-06-22 20:17 ` Dmitry Vyukov
@ 2016-06-27 18:53   ` Ingo Molnar
  2016-06-27 18:58     ` Dmitry Vyukov
  0 siblings, 1 reply; 4+ messages in thread
From: Ingo Molnar @ 2016-06-27 18:53 UTC (permalink / raw)
  To: Dmitry Vyukov
  Cc: H. Peter Anvin, Thomas Gleixner, Ingo Molnar, x86, LKML,
	Alexander Potapenko, Andrey Ryabinin, kasan-dev


* Dmitry Vyukov <dvyukov@google.com> wrote:

> On Wed, Jun 22, 2016 at 7:37 PM, Dmitry Vyukov <dvyukov@google.com> wrote:
> > Latest gcc manages to emit MOVDQA into boot code
> > which leads to crashes. Add more -mno-see flags.

Which GCC version is that?

> >
> > Signed-off-by: Dmitry Vyukov <dvyukov@google.com>
> > ---
> >  arch/x86/boot/compressed/Makefile | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
> > index f135688..7eaafb8 100644
> > --- a/arch/x86/boot/compressed/Makefile
> > +++ b/arch/x86/boot/compressed/Makefile
> > @@ -31,7 +31,7 @@ KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
> >  cflags-$(CONFIG_X86_32) := -march=i386
> >  cflags-$(CONFIG_X86_64) := -mcmodel=small
> >  KBUILD_CFLAGS += $(cflags-y)
> > -KBUILD_CFLAGS += -mno-mmx -mno-sse
> > +KBUILD_CFLAGS += -mno-mmx -mno-sse -mno-sse2 -mno-sse3
> >  KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
> >  KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
> >
> > --
> > 2.8.0.rc3.226.g39d4020
> 
> 
> I withdraw this patch.
> 
> From off-list discussion:
> 
> "-mno-sse alone should disable all SSE/AVX instructions. If not,
> please file a GCC bug report".

So the GCC documentation says:

 -mmmx
 -mno-mmx
 -msse
 -mno-sse
 -msse2
 -mno-sse2
 -msse3
 -mno-sse3
 -m3dnow
 -mno-3dnow
    These switches enable or disable the use of built-in functions that allow 
    direct access to the MMX, SSE, SSE2, SSE3 and 3Dnow extensions of the 
    instruction set.

Technically -mno-mmx won't turn off SSE instructions because they are independent. 
Do we really want to rely on an undocumented property of -mno-sse (clearly broken 
in at least one released GCC version), especially as the fix is so easy?

Thanks,

	Ingo

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

* Re: [PATCH] x86: prevent gcc from emitting SSE into boot code
  2016-06-27 18:53   ` Ingo Molnar
@ 2016-06-27 18:58     ` Dmitry Vyukov
  0 siblings, 0 replies; 4+ messages in thread
From: Dmitry Vyukov @ 2016-06-27 18:58 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: H. Peter Anvin, Thomas Gleixner, Ingo Molnar, x86, LKML,
	Alexander Potapenko, Andrey Ryabinin, kasan-dev, H.J. Lu

On Mon, Jun 27, 2016 at 8:53 PM, Ingo Molnar <mingo@kernel.org> wrote:
>
> * Dmitry Vyukov <dvyukov@google.com> wrote:
>
>> On Wed, Jun 22, 2016 at 7:37 PM, Dmitry Vyukov <dvyukov@google.com> wrote:
>> > Latest gcc manages to emit MOVDQA into boot code
>> > which leads to crashes. Add more -mno-see flags.
>
> Which GCC version is that?
>
>> >
>> > Signed-off-by: Dmitry Vyukov <dvyukov@google.com>
>> > ---
>> >  arch/x86/boot/compressed/Makefile | 2 +-
>> >  1 file changed, 1 insertion(+), 1 deletion(-)
>> >
>> > diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
>> > index f135688..7eaafb8 100644
>> > --- a/arch/x86/boot/compressed/Makefile
>> > +++ b/arch/x86/boot/compressed/Makefile
>> > @@ -31,7 +31,7 @@ KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
>> >  cflags-$(CONFIG_X86_32) := -march=i386
>> >  cflags-$(CONFIG_X86_64) := -mcmodel=small
>> >  KBUILD_CFLAGS += $(cflags-y)
>> > -KBUILD_CFLAGS += -mno-mmx -mno-sse
>> > +KBUILD_CFLAGS += -mno-mmx -mno-sse -mno-sse2 -mno-sse3
>> >  KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
>> >  KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
>> >
>> > --
>> > 2.8.0.rc3.226.g39d4020
>>
>>
>> I withdraw this patch.
>>
>> From off-list discussion:
>>
>> "-mno-sse alone should disable all SSE/AVX instructions. If not,
>> please file a GCC bug report".
>
> So the GCC documentation says:
>
>  -mmmx
>  -mno-mmx
>  -msse
>  -mno-sse
>  -msse2
>  -mno-sse2
>  -msse3
>  -mno-sse3
>  -m3dnow
>  -mno-3dnow
>     These switches enable or disable the use of built-in functions that allow
>     direct access to the MMX, SSE, SSE2, SSE3 and 3Dnow extensions of the
>     instruction set.
>
> Technically -mno-mmx won't turn off SSE instructions because they are independent.
> Do we really want to rely on an undocumented property of -mno-sse (clearly broken
> in at least one released GCC version), especially as the fix is so easy?
>
> Thanks,
>
>         Ingo


Unfortunately part of this discussion gone private. Bringing it public.
This was not necessary a release version of gcc.

=====
The full story is that I spent quite some time debugging it with some
non-release gcc5 version a while ago, and then I was just sitting on
this patch. Now I am using release gcc6. I've just checked and the
kernel boots without these new flags. I thought that -mno-see does not
have to prevent newer SSE instructions, so this patch will save
somebody debugging in future. If the existing -mno-see should prevent
all SSE instructions, then I guess we don't need this patch.
And if not, then, no, I don't have a test case right now.
=====

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

end of thread, other threads:[~2016-06-27 19:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-22 17:37 [PATCH] x86: prevent gcc from emitting SSE into boot code Dmitry Vyukov
2016-06-22 20:17 ` Dmitry Vyukov
2016-06-27 18:53   ` Ingo Molnar
2016-06-27 18:58     ` Dmitry Vyukov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.