lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 19 Oct 2021 19:11:08 +0200
From:   Arnd Bergmann <arnd@...nel.org>
To:     Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
        x86@...nel.org, Nathan Chancellor <nathan@...nel.org>,
        Nick Desaulniers <ndesaulniers@...gle.com>
Cc:     Arnd Bergmann <arnd@...db.de>, "H. Peter Anvin" <hpa@...or.com>,
        Masahiro Yamada <masahiroy@...nel.org>,
        Andy Lutomirski <luto@...nel.org>,
        Miguel Ojeda <ojeda@...nel.org>, linux-kernel@...r.kernel.org,
        llvm@...ts.linux.dev
Subject: [PATCH] [RFC] x86: avoid -mtune=atom with clang

From: Arnd Bergmann <arnd@...db.de>

The clang optimization for atom results in a large number of objtool
warnings like

  drivers/video/hdmi.o: warning: objtool: hdmi_infoframe_check()+0x74: unreachable instruction
  lib/crypto/curve25519.o: warning: objtool: init_module()+0x12: unreachable instruction
  drivers/clk/bcm/clk-iproc-armpll.o: warning: objtool: iproc_armpll_setup()+0x10c: unreachable instruction
  drivers/video/fbdev/core/cfbfillrect.o: warning: objtool: cfb_fillrect()+0xa2: unreachable instruction
  drivers/clk/bcm/clk-iproc-pll.o: warning: objtool: iproc_pll_clk_setup()+0x36d: unreachable instruction
  drivers/clk/bcm/clk-iproc-asiu.o: warning: objtool: iproc_asiu_setup()+0x2cf: unreachable instruction

and in rare cases problems with the register allocator:

  arch/x86/crypto/curve25519-x86_64.c:610:3: error: inline assembly requires more registers than available

  error: ran out of registers during register allocation

All of those can be avoided by changing the -mtune= option for
clang, leaving the -march= option unchanged. It's really a bug
that should be fxied in llvm, but it's fairly clear that the
atom optimizations are not well exercised in llvm, so not
using them is probably the safe choice regardless.

Link: https://github.com/ClangBuiltLinux/linux/issues/1483
Signed-off-by: Arnd Bergmann <arnd@...db.de>
---
 arch/x86/Makefile        | 4 ++++
 arch/x86/Makefile_32.cpu | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 7488cfbbd2f6..4c6f92b32385 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -120,7 +120,11 @@ else
         cflags-$(CONFIG_MK8)		+= -march=k8
         cflags-$(CONFIG_MPSC)		+= -march=nocona
         cflags-$(CONFIG_MCORE2)		+= -march=core2
+ifdef CONFIG_CC_IS_CLANG
+        cflags-$(CONFIG_MATOM)		+= -march=atom -mtune=generic
+else
         cflags-$(CONFIG_MATOM)		+= -march=atom
+endif
         cflags-$(CONFIG_GENERIC_CPU)	+= -mtune=generic
         KBUILD_CFLAGS += $(cflags-y)
 
diff --git a/arch/x86/Makefile_32.cpu b/arch/x86/Makefile_32.cpu
index 94834c4b5e5e..a17b089f367c 100644
--- a/arch/x86/Makefile_32.cpu
+++ b/arch/x86/Makefile_32.cpu
@@ -33,8 +33,12 @@ cflags-$(CONFIG_MCYRIXIII)	+= $(call cc-option,-march=c3,-march=i486) $(align)
 cflags-$(CONFIG_MVIAC3_2)	+= $(call cc-option,-march=c3-2,-march=i686)
 cflags-$(CONFIG_MVIAC7)		+= -march=i686
 cflags-$(CONFIG_MCORE2)		+= -march=i686 $(call tune,core2)
+ifdef CONFIG_CC_IS_CLANG
+cflags-$(CONFIG_MATOM)		+= -march=atom -mtune=generic
+else
 cflags-$(CONFIG_MATOM)		+= $(call cc-option,-march=atom,$(call cc-option,-march=core2,-march=i686)) \
 	$(call cc-option,-mtune=atom,$(call cc-option,-mtune=generic))
+endif
 
 # AMD Elan support
 cflags-$(CONFIG_MELAN)		+= -march=i486
-- 
2.29.2

Powered by blists - more mailing lists