Skip to contentSkip to conversation

x86: prevent gcc from emitting SSE into boot code

PATCH In review Dmitry Vyukov 2 participants 4 messages Jun 22, 2016 – Jun 27, 2016 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: prevent gcc from emitting SSE into boot code

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

---
 arch/x86/boot/compressed/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/boot/compressed/Makefile +1 -1
index f135688..7eaafb8 100644
@@ -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)
 
Signature · 1 line
2.8.0.rc3.226.g39d4020
#1 lore raw
Quoted 22 lines · Dmitry Vyukov

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

---
 arch/x86/boot/compressed/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/boot/compressed/Makefile +1 -2
index f135688..7eaafb8 100644
@@ -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)
 
--
Quoted 1 line

2.8.0.rc3.226.g39d4020

I withdraw this patch.

Quoted 1 line

From off-list discussion:

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

#2 lore raw
Quoted 3 lines · Dmitry Vyukov
Quoted 2 lines · Dmitry Vyukov

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

Which GCC version is that?

Quoted 25 lines
Quoted 20 lines
---
 arch/x86/boot/compressed/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/boot/compressed/Makefile +1 -2
index f135688..7eaafb8 100644
@@ -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)
 
--
Quoted 1 line

2.8.0.rc3.226.g39d4020

I withdraw this patch.

Quoted 4 lines

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

#3 lore raw
Quoted 55 lines · Ingo Molnar
Quoted 3 lines · Dmitry Vyukov
Quoted 2 lines · Dmitry Vyukov

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

Which GCC version is that?

Quoted 25 lines
Quoted 20 lines
---
 arch/x86/boot/compressed/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/boot/compressed/Makefile +1 -2
index f135688..7eaafb8 100644
@@ -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)
 
--
Quoted 1 line

2.8.0.rc3.226.g39d4020

I withdraw this patch.

Quoted 4 lines

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.

Quoted 7 lines

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.
=====