@@ -22,6 +22,11 @@ config CC_HAS_PCREL
# do pcrel yet.
def_bool PPC64 && CC_IS_GCC && $(cc-option, -mcpu=power10 -mpcrel)
+config AS_HAS_MISSING_PLA_INSN
+ # llvm-as is missing some extended mnemonics including pla
+ # (https://github.com/llvm/llvm-project/issues/62373).
+ def_bool AS_IS_LLVM
+
config 32BIT
bool
default y if PPC32
@@ -380,8 +380,13 @@ GLUE(.,name):
rldimi reg, tmp, 32, 0
#ifdef CONFIG_PPC_KERNEL_PCREL
+#ifdef CONFIG_AS_HAS_MISSING_PLA_INSN
+#define LOAD_REG_ADDR(reg,name) \
+ paddi reg,0,name@pcrel,1
+#else
#define LOAD_REG_ADDR(reg,name) \
pla reg,name@pcrel
+#endif
#else
#define LOAD_REG_ADDR(reg,name) \
@@ -178,9 +178,15 @@ fphalf:
.quad 0x3fe0000000000000 /* 0.5 */
#ifdef CONFIG_PPC_KERNEL_PCREL
+#ifdef CONFIG_AS_HAS_MISSING_PLA_INSN
+#define LDCONST(fr, name) \
+ paddi r11,0,name@pcrel,1; \
+ lfd fr,0(r11)
+#else
#define LDCONST(fr, name) \
pla r11,name@pcrel; \
lfd fr,0(r11)
+#endif
#else
#define LDCONST(fr, name) \
addis r11,r2,name@toc@ha; \
llvm-as does not recognise the pla mnemonic, which is used for pcrel address generation. Use the equivalent paddi opcode instead. Clang can not build working pcrel kernels yet, but this patch does allow it to build a non-working pcrel kernel with llvm-as. This could be unconditional or use a raw encoding, but this gives a placeholder to track the issue. Signed-off-by: Nicholas Piggin <npiggin@gmail.com> --- arch/powerpc/Kconfig | 5 +++++ arch/powerpc/include/asm/ppc_asm.h | 5 +++++ arch/powerpc/kernel/vector.S | 6 ++++++ 3 files changed, 16 insertions(+)