2022-02-23 14:56:55

by Anders Roxell

[permalink] [raw]
Subject: [PATCH 3/3] powerpc: lib: sstep: fix build errors

Building tinyconfig with gcc (Debian 11.2.0-16) and assembler (Debian
2.37.90.20220207) the following build error shows up:

{standard input}: Assembler messages:
{standard input}:10576: Error: unrecognized opcode: `stbcx.'
{standard input}:10680: Error: unrecognized opcode: `lharx'
{standard input}:10694: Error: unrecognized opcode: `lbarx'

Rework to add assembler directives [1] around the instruction. The
problem with this might be that we can trick a power6 into
single-stepping through an stbcx. for instance, and it will execute that
in kernel mode.

[1] https://sourceware.org/binutils/docs/as/PowerPC_002dPseudo.html#PowerPC_002dPseudo

Cc: <[email protected]>
Co-developed-by: Arnd Bergmann <[email protected]>
Signed-off-by: Arnd Bergmann <[email protected]>
Signed-off-by: Anders Roxell <[email protected]>
---
arch/powerpc/lib/sstep.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c
index d2d29243fa6d..b9f43bbdd55a 100644
--- a/arch/powerpc/lib/sstep.c
+++ b/arch/powerpc/lib/sstep.c
@@ -1097,7 +1097,10 @@ NOKPROBE_SYMBOL(emulate_dcbz);

#define __put_user_asmx(x, addr, err, op, cr) \
__asm__ __volatile__( \
+ ".machine \"push\"\n" \
+ ".machine \"power8\"\n" \
"1: " op " %2,0,%3\n" \
+ ".machine \"pop\"\n" \
" mfcr %1\n" \
"2:\n" \
".section .fixup,\"ax\"\n" \
@@ -1110,7 +1113,10 @@ NOKPROBE_SYMBOL(emulate_dcbz);

#define __get_user_asmx(x, addr, err, op) \
__asm__ __volatile__( \
+ ".machine \"push\"\n" \
+ ".machine \"power8\"\n" \
"1: "op" %1,0,%2\n" \
+ ".machine \"pop\"\n" \
"2:\n" \
".section .fixup,\"ax\"\n" \
"3: li %0,%3\n" \
--
2.34.1


2022-02-23 15:36:41

by Segher Boessenkool

[permalink] [raw]
Subject: Re: [PATCH 3/3] powerpc: lib: sstep: fix build errors

On Wed, Feb 23, 2022 at 02:58:20PM +0100, Anders Roxell wrote:
> Building tinyconfig with gcc (Debian 11.2.0-16) and assembler (Debian
> 2.37.90.20220207) the following build error shows up:
>
> {standard input}: Assembler messages:
> {standard input}:10576: Error: unrecognized opcode: `stbcx.'
> {standard input}:10680: Error: unrecognized opcode: `lharx'
> {standard input}:10694: Error: unrecognized opcode: `lbarx'
>
> Rework to add assembler directives [1] around the instruction. The
> problem with this might be that we can trick a power6 into
> single-stepping through an stbcx. for instance, and it will execute that
> in kernel mode.
>
> [1] https://sourceware.org/binutils/docs/as/PowerPC_002dPseudo.html#PowerPC_002dPseudo

Wow, no wonder you think you need quotes after reading that. I'll try
to get that fixed.

Reviewed-by: Segher Boessenkool <[email protected]>


Segher