powerpc/fsl: Fix mfpmr build errors with newer binutils
authorMichael Ellerman <mpe@ellerman.id.au>
Thu, 29 Feb 2024 12:25:19 +0000 (23:25 +1100)
committerMichael Ellerman <mpe@ellerman.id.au>
Sun, 3 Mar 2024 12:05:21 +0000 (23:05 +1100)
Binutils 2.38 complains about the use of mfpmr when building
ppc6xx_defconfig:

    CC      arch/powerpc/kernel/pmc.o
  {standard input}: Assembler messages:
  {standard input}:45: Error: unrecognized opcode: `mfpmr'
  {standard input}:56: Error: unrecognized opcode: `mtpmr'

This is because by default the kernel is built with -mcpu=powerpc, and
the mt/mfpmr instructions are not defined.

It can be avoided by enabling CONFIG_E300C3_CPU, but just adding that to
the defconfig will leave open the possibility of randconfig failures.

So add machine directives around the mt/mfpmr instructions to tell
binutils how to assemble them.

Cc: stable@vger.kernel.org
Reported-by: Jan-Benedict Glaw <jbglaw@lug-owl.de>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20240229122521.762431-3-mpe@ellerman.id.au
arch/powerpc/include/asm/reg_fsl_emb.h

index a21f529c43d96b548690aeff283820ce07a6e4a1..8359c06d92d9f8a486c027aad3b76dea1234a226 100644 (file)
 #ifndef __ASSEMBLY__
 /* Performance Monitor Registers */
 #define mfpmr(rn)      ({unsigned int rval; \
-                       asm volatile("mfpmr %0," __stringify(rn) \
+                       asm volatile(".machine push; " \
+                                    ".machine e300; " \
+                                    "mfpmr %0," __stringify(rn) ";" \
+                                    ".machine pop; " \
                                     : "=r" (rval)); rval;})
-#define mtpmr(rn, v)   asm volatile("mtpmr " __stringify(rn) ",%0" : : "r" (v))
+#define mtpmr(rn, v)   asm volatile(".machine push; " \
+                                    ".machine e300; " \
+                                    "mtpmr " __stringify(rn) ",%0; " \
+                                    ".machine pop; " \
+                                    : : "r" (v))
 #endif /* __ASSEMBLY__ */
 
 /* Freescale Book E Performance Monitor APU Registers */