1 From 81806f18c95d35e1d8a8f1c069d32c2c6a703b82 Mon Sep 17 00:00:00 2001
2 From: Sasha Levin <sashal@kernel.org>
3 Date: Thu, 29 Feb 2024 23:25:19 +1100
4 Subject: powerpc/fsl: Fix mfpmr build errors with newer binutils
6 From: Michael Ellerman <mpe@ellerman.id.au>
8 [ Upstream commit 5f491356b7149564ab22323ccce79c8d595bfd0c ]
10 Binutils 2.38 complains about the use of mfpmr when building
13 CC arch/powerpc/kernel/pmc.o
14 {standard input}: Assembler messages:
15 {standard input}:45: Error: unrecognized opcode: `mfpmr'
16 {standard input}:56: Error: unrecognized opcode: `mtpmr'
18 This is because by default the kernel is built with -mcpu=powerpc, and
19 the mt/mfpmr instructions are not defined.
21 It can be avoided by enabling CONFIG_E300C3_CPU, but just adding that to
22 the defconfig will leave open the possibility of randconfig failures.
24 So add machine directives around the mt/mfpmr instructions to tell
25 binutils how to assemble them.
27 Cc: stable@vger.kernel.org
28 Reported-by: Jan-Benedict Glaw <jbglaw@lug-owl.de>
29 Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
30 Link: https://msgid.link/20240229122521.762431-3-mpe@ellerman.id.au
31 Signed-off-by: Sasha Levin <sashal@kernel.org>
33 arch/powerpc/include/asm/reg_fsl_emb.h | 11 +++++++++--
34 1 file changed, 9 insertions(+), 2 deletions(-)
36 diff --git a/arch/powerpc/include/asm/reg_fsl_emb.h b/arch/powerpc/include/asm/reg_fsl_emb.h
37 index a21f529c43d96..8359c06d92d9f 100644
38 --- a/arch/powerpc/include/asm/reg_fsl_emb.h
39 +++ b/arch/powerpc/include/asm/reg_fsl_emb.h
42 /* Performance Monitor Registers */
43 #define mfpmr(rn) ({unsigned int rval; \
44 - asm volatile("mfpmr %0," __stringify(rn) \
45 + asm volatile(".machine push; " \
47 + "mfpmr %0," __stringify(rn) ";" \
49 : "=r" (rval)); rval;})
50 -#define mtpmr(rn, v) asm volatile("mtpmr " __stringify(rn) ",%0" : : "r" (v))
51 +#define mtpmr(rn, v) asm volatile(".machine push; " \
53 + "mtpmr " __stringify(rn) ",%0; " \
56 #endif /* __ASSEMBLY__ */
58 /* Freescale Book E Performance Monitor APU Registers */