linux-um.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] arch:um: Only disable SSE on clang to work around old GCC bugs
@ 2023-03-18  4:15 David Gow
  2023-03-20 17:22 ` Vincenzo Palazzo
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: David Gow @ 2023-03-18  4:15 UTC (permalink / raw)
  To: Richard Weinberger, Anton Ivanov, Johannes Berg, Thomas Gleixner,
	Ingo Molnar, Nick Desaulniers, Nathan Chancellor, Miguel Ojeda,
	Roberto Sassu, SeongJae Park
  Cc: David Gow, linux-um, x86, llvm, rust-for-linux, kunit-dev, linux-kernel

As part of the Rust support for UML, we disable SSE (and similar flags)
to match the normal x86 builds. This both makes sense (we ideally want a
similar configuration to x86), and works around a crash bug with SSE
generation under Rust with LLVM.

However, this breaks compiling stdlib.h under gcc < 11, as the x86_64
ABI requires floating-point return values be stored in an SSE register.
gcc 11 fixes this by only doing register allocation when a function is
actually used, and since we never use atof(), it shouldn't be a problem:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99652

Nevertheless, only disable SSE on clang setups, as that's a simple way
of working around everyone's bugs.

Fixes: 884981867947 ("rust: arch/um: Disable FP/SIMD instruction to match x86")
Reported-by: Roberto Sassu <roberto.sassu@huaweicloud.com>
Link: https://lore.kernel.org/linux-um/6df2ecef9011d85654a82acd607fdcbc93ad593c.camel@huaweicloud.com/
Tested-by: Roberto Sassu <roberto.sassu@huaweicloud.com>
Tested-by: SeongJae Park <sj@kernel.org>
Signed-off-by: David Gow <davidgow@google.com>
---
 arch/x86/Makefile.um | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/x86/Makefile.um b/arch/x86/Makefile.um
index b70559b821df..2106a2bd152b 100644
--- a/arch/x86/Makefile.um
+++ b/arch/x86/Makefile.um
@@ -3,9 +3,14 @@ core-y += arch/x86/crypto/
 
 #
 # Disable SSE and other FP/SIMD instructions to match normal x86
+# This is required to work around issues in older LLVM versions, but breaks
+# GCC versions < 11. See:
+# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99652
 #
+ifeq ($(CONFIG_CC_IS_CLANG),y)
 KBUILD_CFLAGS += -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx
 KBUILD_RUSTFLAGS += -Ctarget-feature=-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-avx,-avx2
+endif
 
 ifeq ($(CONFIG_X86_32),y)
 START := 0x8048000
-- 
2.40.0.rc1.284.g88254d51c5-goog


_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um

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

* Re: [PATCH] arch:um: Only disable SSE on clang to work around old GCC bugs
  2023-03-18  4:15 [PATCH] arch:um: Only disable SSE on clang to work around old GCC bugs David Gow
@ 2023-03-20 17:22 ` Vincenzo Palazzo
  2023-03-21 20:11 ` Arthur Grillo Queiroz Cabral
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Vincenzo Palazzo @ 2023-03-20 17:22 UTC (permalink / raw)
  To: David Gow, Richard Weinberger, Anton Ivanov, Johannes Berg,
	Thomas Gleixner, Ingo Molnar, Nick Desaulniers,
	Nathan Chancellor, Miguel Ojeda, Roberto Sassu, SeongJae Park
  Cc: linux-um, x86, llvm, rust-for-linux, kunit-dev, linux-kernel

> As part of the Rust support for UML, we disable SSE (and similar flags)
> to match the normal x86 builds. This both makes sense (we ideally want a
> similar configuration to x86), and works around a crash bug with SSE
> generation under Rust with LLVM.
>
> However, this breaks compiling stdlib.h under gcc < 11, as the x86_64
> ABI requires floating-point return values be stored in an SSE register.
> gcc 11 fixes this by only doing register allocation when a function is
> actually used, and since we never use atof(), it shouldn't be a problem:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99652
>
> Nevertheless, only disable SSE on clang setups, as that's a simple way
> of working around everyone's bugs.
>
> Fixes: 884981867947 ("rust: arch/um: Disable FP/SIMD instruction to match x86")
> Reported-by: Roberto Sassu <roberto.sassu@huaweicloud.com>
> Link: https://lore.kernel.org/linux-um/6df2ecef9011d85654a82acd607fdcbc93ad593c.camel@huaweicloud.com/
> Tested-by: Roberto Sassu <roberto.sassu@huaweicloud.com>
> Tested-by: SeongJae Park <sj@kernel.org>
> Signed-off-by: David Gow <davidgow@google.com>
> ---
>  arch/x86/Makefile.um | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/arch/x86/Makefile.um b/arch/x86/Makefile.um
> index b70559b821df..2106a2bd152b 100644
> --- a/arch/x86/Makefile.um
> +++ b/arch/x86/Makefile.um
> @@ -3,9 +3,14 @@ core-y += arch/x86/crypto/
>  
>  #
>  # Disable SSE and other FP/SIMD instructions to match normal x86
> +# This is required to work around issues in older LLVM versions, but breaks
> +# GCC versions < 11. See:
> +# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99652
>  #
> +ifeq ($(CONFIG_CC_IS_CLANG),y)
>  KBUILD_CFLAGS += -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx
>  KBUILD_RUSTFLAGS += -Ctarget-feature=-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-avx,-avx2
> +endif
>  
>  ifeq ($(CONFIG_X86_32),y)
>  START := 0x8048000
> -- 
> 2.40.0.rc1.284.g88254d51c5-goog


Reviewed-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>

_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um

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

* Re: [PATCH] arch:um: Only disable SSE on clang to work around old GCC bugs
  2023-03-18  4:15 [PATCH] arch:um: Only disable SSE on clang to work around old GCC bugs David Gow
  2023-03-20 17:22 ` Vincenzo Palazzo
@ 2023-03-21 20:11 ` Arthur Grillo Queiroz Cabral
  2023-03-31  8:25 ` David Gow
  2023-03-31 13:39 ` Miguel Ojeda
  3 siblings, 0 replies; 7+ messages in thread
From: Arthur Grillo Queiroz Cabral @ 2023-03-21 20:11 UTC (permalink / raw)
  To: David Gow, Richard Weinberger, Anton Ivanov, Johannes Berg,
	Thomas Gleixner, Ingo Molnar, Nick Desaulniers,
	Nathan Chancellor, Miguel Ojeda, Roberto Sassu, SeongJae Park
  Cc: linux-um, x86, llvm, rust-for-linux, kunit-dev, linux-kernel



On 18/03/23 01:15, 'David Gow' via KUnit Development wrote:
> As part of the Rust support for UML, we disable SSE (and similar flags)
> to match the normal x86 builds. This both makes sense (we ideally want a
> similar configuration to x86), and works around a crash bug with SSE
> generation under Rust with LLVM.
> 
> However, this breaks compiling stdlib.h under gcc < 11, as the x86_64
> ABI requires floating-point return values be stored in an SSE register.
> gcc 11 fixes this by only doing register allocation when a function is
> actually used, and since we never use atof(), it shouldn't be a problem:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99652
> 
> Nevertheless, only disable SSE on clang setups, as that's a simple way
> of working around everyone's bugs.
> 
> Fixes: 884981867947 ("rust: arch/um: Disable FP/SIMD instruction to match x86")
> Reported-by: Roberto Sassu <roberto.sassu@huaweicloud.com>
> Link: https://lore.kernel.org/linux-um/6df2ecef9011d85654a82acd607fdcbc93ad593c.camel@huaweicloud.com/
> Tested-by: Roberto Sassu <roberto.sassu@huaweicloud.com>
> Tested-by: SeongJae Park <sj@kernel.org>
> Signed-off-by: David Gow <davidgow@google.com>
> ---
>  arch/x86/Makefile.um | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/arch/x86/Makefile.um b/arch/x86/Makefile.um
> index b70559b821df..2106a2bd152b 100644
> --- a/arch/x86/Makefile.um
> +++ b/arch/x86/Makefile.um
> @@ -3,9 +3,14 @@ core-y += arch/x86/crypto/
>  
>  #
>  # Disable SSE and other FP/SIMD instructions to match normal x86
> +# This is required to work around issues in older LLVM versions, but breaks
> +# GCC versions < 11. See:
> +# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99652
>  #
> +ifeq ($(CONFIG_CC_IS_CLANG),y)
>  KBUILD_CFLAGS += -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx
>  KBUILD_RUSTFLAGS += -Ctarget-feature=-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-avx,-avx2
> +endif
>  
>  ifeq ($(CONFIG_X86_32),y)
>  START := 0x8048000

Tested-by: Arthur Grillo <arthurgrillo@riseup.net>

_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um

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

* Re: [PATCH] arch:um: Only disable SSE on clang to work around old GCC bugs
  2023-03-18  4:15 [PATCH] arch:um: Only disable SSE on clang to work around old GCC bugs David Gow
  2023-03-20 17:22 ` Vincenzo Palazzo
  2023-03-21 20:11 ` Arthur Grillo Queiroz Cabral
@ 2023-03-31  8:25 ` David Gow
  2023-03-31  8:37   ` Richard Weinberger
  2023-03-31 13:39 ` Miguel Ojeda
  3 siblings, 1 reply; 7+ messages in thread
From: David Gow @ 2023-03-31  8:25 UTC (permalink / raw)
  To: Richard Weinberger, Anton Ivanov, Johannes Berg
  Cc: linux-um, x86, llvm, rust-for-linux, kunit-dev, linux-kernel,
	SeongJae Park, Roberto Sassu, Miguel Ojeda, Nathan Chancellor,
	Ingo Molnar, Thomas Gleixner, Nick Desaulniers


[-- Attachment #1.1: Type: text/plain, Size: 1325 bytes --]

On Sat, 18 Mar 2023 at 12:16, David Gow <davidgow@google.com> wrote:
>
> As part of the Rust support for UML, we disable SSE (and similar flags)
> to match the normal x86 builds. This both makes sense (we ideally want a
> similar configuration to x86), and works around a crash bug with SSE
> generation under Rust with LLVM.
>
> However, this breaks compiling stdlib.h under gcc < 11, as the x86_64
> ABI requires floating-point return values be stored in an SSE register.
> gcc 11 fixes this by only doing register allocation when a function is
> actually used, and since we never use atof(), it shouldn't be a problem:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99652
>
> Nevertheless, only disable SSE on clang setups, as that's a simple way
> of working around everyone's bugs.
>
> Fixes: 884981867947 ("rust: arch/um: Disable FP/SIMD instruction to match x86")
> Reported-by: Roberto Sassu <roberto.sassu@huaweicloud.com>
> Link: https://lore.kernel.org/linux-um/6df2ecef9011d85654a82acd607fdcbc93ad593c.camel@huaweicloud.com/
> Tested-by: Roberto Sassu <roberto.sassu@huaweicloud.com>
> Tested-by: SeongJae Park <sj@kernel.org>
> Signed-off-by: David Gow <davidgow@google.com>
> ---

Any chance we could get this picked up as a fix for 6.3? The UML build
is still broken with older gcc versions.

Cheers,
-- David

[-- Attachment #1.2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4003 bytes --]

[-- Attachment #2: Type: text/plain, Size: 152 bytes --]

_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um

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

* Re: [PATCH] arch:um: Only disable SSE on clang to work around old GCC bugs
  2023-03-31  8:25 ` David Gow
@ 2023-03-31  8:37   ` Richard Weinberger
  2023-04-04  7:59     ` Richard Weinberger
  0 siblings, 1 reply; 7+ messages in thread
From: Richard Weinberger @ 2023-03-31  8:37 UTC (permalink / raw)
  To: davidgow
  Cc: anton ivanov, Johannes Berg, linux-um, x86, llvm,
	Rust for Linux Kernel, kunit-dev, linux-kernel, SeongJae Park,
	Roberto Sassu, Miguel Ojeda, Nathan Chancellor, mingo, tglx,
	Nick Desaulniers

----- Ursprüngliche Mail -----
> Von: "davidgow" <davidgow@google.com>
> An: "richard" <richard@nod.at>, "anton ivanov" <anton.ivanov@cambridgegreys.com>, "Johannes Berg"
> Any chance we could get this picked up as a fix for 6.3? The UML build
> is still broken with older gcc versions.

Sure. Just got flooded with other stuff. :-S

Thanks,
//richard

_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um

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

* Re: [PATCH] arch:um: Only disable SSE on clang to work around old GCC bugs
  2023-03-18  4:15 [PATCH] arch:um: Only disable SSE on clang to work around old GCC bugs David Gow
                   ` (2 preceding siblings ...)
  2023-03-31  8:25 ` David Gow
@ 2023-03-31 13:39 ` Miguel Ojeda
  3 siblings, 0 replies; 7+ messages in thread
From: Miguel Ojeda @ 2023-03-31 13:39 UTC (permalink / raw)
  To: David Gow
  Cc: Richard Weinberger, Anton Ivanov, Johannes Berg, Thomas Gleixner,
	Ingo Molnar, Nick Desaulniers, Nathan Chancellor, Miguel Ojeda,
	Roberto Sassu, SeongJae Park, linux-um, x86, llvm,
	rust-for-linux, kunit-dev, linux-kernel

On Sat, Mar 18, 2023 at 5:16 AM David Gow <davidgow@google.com> wrote:
>
> Nevertheless, only disable SSE on clang setups, as that's a simple way
> of working around everyone's bugs.

Sounds good to me. If GCC >= 11 has fixed it, should we instead test
for GCC < 11, i.e. it could help catching future new regressions like
the linked GCC bug, if I understand correctly, right? Of course, that
could be done for the next cycle, since this one minimizes the
original change w.r.t. v6.2.

By the way, missing space on the title (`arch:um`).

Cheers,
Miguel

_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um

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

* Re: [PATCH] arch:um: Only disable SSE on clang to work around old GCC bugs
  2023-03-31  8:37   ` Richard Weinberger
@ 2023-04-04  7:59     ` Richard Weinberger
  0 siblings, 0 replies; 7+ messages in thread
From: Richard Weinberger @ 2023-04-04  7:59 UTC (permalink / raw)
  To: davidgow
  Cc: anton ivanov, Johannes Berg, linux-um, x86, llvm,
	Rust for Linux Kernel, kunit-dev, linux-kernel, SeongJae Park,
	Roberto Sassu, Miguel Ojeda, Nathan Chancellor, mingo, tglx,
	Nick Desaulniers

----- Ursprüngliche Mail -----
>> Von: "davidgow" <davidgow@google.com>
>> An: "richard" <richard@nod.at>, "anton ivanov"
>> <anton.ivanov@cambridgegreys.com>, "Johannes Berg"
>> Any chance we could get this picked up as a fix for 6.3? The UML build
>> is still broken with older gcc versions.
> 
> Sure. Just got flooded with other stuff. :-S

Patch applied to fixes branch. PR will happen soon.

Thanks everyone and sorry for the delay on my side!

--
Thanks,
//richard

_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um

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

end of thread, other threads:[~2023-04-04  8:00 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-18  4:15 [PATCH] arch:um: Only disable SSE on clang to work around old GCC bugs David Gow
2023-03-20 17:22 ` Vincenzo Palazzo
2023-03-21 20:11 ` Arthur Grillo Queiroz Cabral
2023-03-31  8:25 ` David Gow
2023-03-31  8:37   ` Richard Weinberger
2023-04-04  7:59     ` Richard Weinberger
2023-03-31 13:39 ` Miguel Ojeda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).