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  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20250616-loongarch-fix-warn-cond-llvm-ias-v1-1-6c6d90bb4466@kernel.org>
Date: Mon, 16 Jun 2025 16:23:40 -0700
From: Nathan Chancellor <nathan@...nel.org>
To: Ingo Molnar <mingo@...nel.org>, Huacai Chen <chenhuacai@...nel.org>, 
 WANG Xuerui <kernel@...0n.name>
Cc: Nick Desaulniers <nick.desaulniers+lkml@...il.com>, 
 Bill Wendling <morbo@...gle.com>, Justin Stitt <justinstitt@...gle.com>, 
 loongarch@...ts.linux.dev, linux-kernel@...r.kernel.org, 
 llvm@...ts.linux.dev, Nathan Chancellor <nathan@...nel.org>
Subject: [PATCH] loongarch: Use '.ascii' instead of '.string' in
 __BUGVERBOSE_LOCATION

After commit 5d476f66e6ad ("bugs/LoongArch: Concatenate 'cond_str' with
'__FILE__' in __BUG_ENTRY(), to extend WARN_ON/BUG_ON output"), building
loongarch with clang's integrated assembler fails with:

  block/blk-throttle.c:205:2: error: unexpected token
    205 |         WARN_ON_ONCE(!bio);
        |         ^
  include/asm-generic/bug.h:119:3: note: expanded from macro 'WARN_ON_ONCE'
    119 |                 __WARN_FLAGS("["#condition"] ",                 \
        |                 ^
  arch/loongarch/include/asm/bug.h:47:2: note: expanded from macro '__WARN_FLAGS'
     47 |         __BUG_FLAGS(cond_str, BUGFLAG_WARNING|(flags), ANNOTATE_REACHABLE(10001b));\
        |         ^
  arch/loongarch/include/asm/bug.h:42:23: note: expanded from macro '__BUG_FLAGS'
     42 |         asm_inline volatile (__stringify(ASM_BUG_FLAGS(cond_str, flags)) extra);
        |                              ^
  ...
  <inline asm>:1:134: note: instantiated into assembly here
      1 |         .pushsection __bug_table, "aw"; .align 2; 10000: .long 10001f - .; .pushsection .rodata.str, "aMS", @progbits, 1; 10002: .string "[""!bio""] " "block/blk-throttle.c"; .popsection; .long 10002b - .; .short 205; .short (1 << 0)|((1 << 1) | ((9) << 8)); .popsection; 10001: break 1;.pushsection .discard.annotate_insn,"M",@progbits,8
        |                                                                                                                                             ^

clang's integrated assembler only supports concatenating strings with
'.ascii'. There was discussion of allowing '.string' / '.asciz' but it
was decided against [1] because it was undesirable to match the behavior
of released binutils at the time, where

  .asciz "foo" "bar"

was treated like

  "foo\0bar\0"

instead of the more intuitive to C programmers

  "foobar\0"

and diverging from that behavior was seen as risky and unnecessary. GNU
binutils updated its handling of '.asciz' and '.string' to the more
intuitive option in 2.36 [2] after this was brought up to them in
passing.

Convert LoongArch's __BUGVERBOSE_LOCATION from '.string' to '.ascii'
with a manually added NUL, similar to commit 707f853d7fa3 ("module:
Provide EXPORT_SYMBOL_GPL_FOR_MODULES() helper") for the same reason,
which clears up the build error and results in no changes in output for
builds with GNU binutils.

Fixes: 5d476f66e6ad ("bugs/LoongArch: Concatenate 'cond_str' with '__FILE__' in __BUG_ENTRY(), to extend WARN_ON/BUG_ON output")
Link: https://reviews.llvm.org/D91460#2398228 [1]
Link: https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=3d955acb36f483c05724181da5ffba46b1303c43 [2]
Signed-off-by: Nathan Chancellor <nathan@...nel.org>
---
 arch/loongarch/include/asm/bug.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/loongarch/include/asm/bug.h b/arch/loongarch/include/asm/bug.h
index cad807b100ad..d090a5bec5eb 100644
--- a/arch/loongarch/include/asm/bug.h
+++ b/arch/loongarch/include/asm/bug.h
@@ -11,7 +11,7 @@
 #else
 #define __BUGVERBOSE_LOCATION(file, line)			\
 		.pushsection .rodata.str, "aMS", @progbits, 1;	\
-	10002:	.string file;					\
+	10002:	.ascii file "\0";				\
 		.popsection;					\
 								\
 		.long 10002b - .;				\

---
base-commit: d298bb98d65f964288bb87feef014da1baafedda
change-id: 20250616-loongarch-fix-warn-cond-llvm-ias-b954f02c446c

Best regards,
--  
Nathan Chancellor <nathan@...nel.org>


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ