[PATCH v4 1/2] powerpc/uaccess: Implement unsafe_put_user() using 'asm goto'

Christophe Leroy christophe.leroy at csgroup.eu
Sat Jun 13 16:46:33 AEST 2020



On 06/12/2020 09:33 PM, Nick Desaulniers wrote:
> 
> IIUC the bug report correctly, it looks like LLVM is failing for the
> __put_user_asm2_goto case for -m32.  A simple reproducer:
> https://godbolt.org/z/jBBF9b
> 
> void foo(long long in, long long* out) {
> asm volatile(
>    "stw%X1 %0, %1\n\t"
>    "stw%X1 %L0, %L1"
>    ::"r"(in), "m"(*out));
> }
> prints (in GCC):
> foo:
>    stw 3, 0(5)
>    stw 4, 4(5)
>    blr
> (first time looking at ppc assembler, seems constants and registers
> are not as easy to distinguish,
> https://developer.ibm.com/technologies/linux/articles/l-ppc/ say "Get
> used to it." LOL, ok).

When I do ppc-linux-objdump -d vmlinux, registers and constants are 
easily distinguished, see below.

c0002284 <start_here>:
c0002284:	3c 40 c0 3c 	lis     r2,-16324
c0002288:	60 42 45 00 	ori     r2,r2,17664
c000228c:	3c 82 40 00 	addis   r4,r2,16384
c0002290:	38 84 04 30 	addi    r4,r4,1072
c0002294:	7c 93 43 a6 	mtsprg  3,r4
c0002298:	3c 20 c0 3e 	lis     r1,-16322
c000229c:	38 21 e0 00 	addi    r1,r1,-8192
c00022a0:	38 00 00 00 	li      r0,0
c00022a4:	94 01 1f f0 	stwu    r0,8176(r1)
c00022a8:	48 35 e7 41 	bl      c03609e8 <early_init>
c00022ac:	38 60 00 00 	li      r3,0
c00022b0:	7f e4 fb 78 	mr      r4,r31
c00022b4:	48 35 e7 8d 	bl      c0360a40 <machine_init>
c00022b8:	48 35 eb e1 	bl      c0360e98 <MMU_init>
c00022bc:	3c c0 c0 3c 	lis     r6,-16324
c00022c0:	3c c6 40 00 	addis   r6,r6,16384
c00022c4:	7c df c3 a6 	mtspr   799,r6
c00022c8:	3c 80 c0 00 	lis     r4,-16384
c00022cc:	60 84 22 e4 	ori     r4,r4,8932
c00022d0:	3c 84 40 00 	addis   r4,r4,16384
c00022d4:	38 60 10 02 	li      r3,4098
c00022d8:	7c 9a 03 a6 	mtsrr0  r4
c00022dc:	7c 7b 03 a6 	mtsrr1  r3
c00022e0:	4c 00 00 64 	rfi
c00022e4:	7c 00 02 e4 	tlbia
c00022e8:	7c 00 04 ac 	hwsync
c00022ec:	3c c6 c0 00 	addis   r6,r6,-16384
c00022f0:	3c a0 c0 3c 	lis     r5,-16324
c00022f4:	60 a5 40 00 	ori     r5,r5,16384
c00022f8:	90 a0 00 f0 	stw     r5,240(0)
c00022fc:	3c a5 40 00 	addis   r5,r5,16384
c0002300:	90 c5 00 00 	stw     r6,0(r5)
c0002304:	38 80 10 32 	li      r4,4146
c0002308:	3c 60 c0 35 	lis     r3,-16331
c000230c:	60 63 d6 a8 	ori     r3,r3,54952
c0002310:	7c 7a 03 a6 	mtsrr0  r3
c0002314:	7c 9b 03 a6 	mtsrr1  r4
c0002318:	4c 00 00 64 	rfi

For GCC, I think you call tell you want register names with -mregnames

Christophe


More information about the Linuxppc-dev mailing list