Skip to content

Commit c9a4ef6

Browse files
MaskRayctmarinas
authored andcommitted
arm64: Delete the space separator in __emit_inst
In assembly, many instances of __emit_inst(x) expand to a directive. In a few places __emit_inst(x) is used as an assembler macro argument. For example, in arch/arm64/kvm/hyp/entry.S ALTERNATIVE(nop, SET_PSTATE_PAN(1), ARM64_HAS_PAN, CONFIG_ARM64_PAN) expands to the following by the C preprocessor: alternative_insn nop, .inst (0xd500401f | ((0) << 16 | (4) << 5) | ((!!1) << 8)), 4, 1 Both comma and space are separators, with an exception that content inside a pair of parentheses/quotes is not split, so the clang integrated assembler splits the arguments to: nop, .inst, (0xd500401f | ((0) << 16 | (4) << 5) | ((!!1) << 8)), 4, 1 GNU as preprocesses the input with do_scrub_chars(). Its arm64 backend (along with many other non-x86 backends) sees: alternative_insn nop,.inst(0xd500401f|((0)<<16|(4)<<5)|((!!1)<<8)),4,1 # .inst(...) is parsed as one argument while its x86 backend sees: alternative_insn nop,.inst (0xd500401f|((0)<<16|(4)<<5)|((!!1)<<8)),4,1 # The extra space before '(' makes the whole .inst (...) parsed as two arguments The non-x86 backend's behavior is considered unintentional (https://sourceware.org/bugzilla/show_bug.cgi?id=25750). So drop the space separator inside `.inst (...)` to make the clang integrated assembler work. Suggested-by: Ilie Halip <[email protected]> Signed-off-by: Fangrui Song <[email protected]> Reviewed-by: Mark Rutland <[email protected]> Link: ClangBuiltLinux#939 Signed-off-by: Catalin Marinas <[email protected]>
1 parent 9cc3d0c commit c9a4ef6

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

arch/arm64/include/asm/sysreg.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@
4949
#ifndef CONFIG_BROKEN_GAS_INST
5050

5151
#ifdef __ASSEMBLY__
52-
#define __emit_inst(x) .inst (x)
52+
// The space separator is omitted so that __emit_inst(x) can be parsed as
53+
// either an assembler directive or an assembler macro argument.
54+
#define __emit_inst(x) .inst(x)
5355
#else
5456
#define __emit_inst(x) ".inst " __stringify((x)) "\n\t"
5557
#endif

0 commit comments

Comments
 (0)