Skip to content

Commit

Permalink
FROMLIST: arm64: fix alternatives with LLVM's integrated assembler
Browse files Browse the repository at this point in the history
LLVM's integrated assembler fails with the following error when
building KVM:

  <inline asm>:12:6: error: expected absolute expression
   .if kvm_update_va_mask == 0
       ^
  <inline asm>:21:6: error: expected absolute expression
   .if kvm_update_va_mask == 0
       ^
  <inline asm>:24:2: error: unrecognized instruction mnemonic
          NOT_AN_INSTRUCTION
          ^
  LLVM ERROR: Error parsing inline asm

These errors come from ALTERNATIVE_CB and __ALTERNATIVE_CFG,
which test for the existence of the callback parameter in inline
assembly using the following expression:

  " .if " __stringify(cb) " == 0\n"

This works with GNU as, but isn't supported by LLVM. This change
splits __ALTERNATIVE_CFG and ALTINSTR_ENTRY into separate macros
to fix the LLVM build.

Bug: 145210207
Change-Id: I62dd786277bcaf3c730a7489c4b5a2b437f722ce
(am from https://lore.kernel.org/patchwork/patch/1136803/)
Link: ClangBuiltLinux/linux#472
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
Signed-off-by: Dakkshesh <dakkshesh5@gmail.com>
  • Loading branch information
samitolvanen authored and KanonifyX committed Dec 5, 2024
1 parent 383875f commit f41afca
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions arch/arm64/include/asm/alternative.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void apply_alternatives(void *start, size_t length);
" .byte 662b-661b\n" /* source len */ \
" .byte 664f-663f\n" /* replacement len */

#define ALTINSTR_ENTRY_CB(feature, cb) \
#define ALTINSTR_ENTRY_CB(feature,cb) \
" .word 661b - .\n" /* label */ \
" .word " __stringify(cb) "- .\n" /* callback */ \
" .hword " __stringify(feature) "\n" /* feature bit */ \
Expand Down Expand Up @@ -82,7 +82,7 @@ void apply_alternatives(void *start, size_t length);
oldinstr "\n" \
"662:\n" \
".pushsection .altinstructions,\"a\"\n" \
ALTINSTR_ENTRY_CB(feature, cb) \
ALTINSTR_ENTRY_CB(feature,cb) \
".popsection\n" \
"663:\n\t" \
"664:\n\t" \
Expand Down

0 comments on commit f41afca

Please sign in to comment.