[libc-dev] New powerpc vdso calling convention

Christophe Leroy via libc-dev libc-dev at lists.llvm.org
Sat Apr 25 00:47:08 PDT 2020

Le 25/04/2020 à 07:22, Nicholas Piggin a écrit :
> As noted in the 'scv' thread, powerpc's vdso calling convention does not
> match the C ELF ABI calling convention (or the proposed scv convention).
> I think we could implement a new ABI by basically duplicating function
> entry points with different names.

I think doing this is a real good idea.

I've been working at porting powerpc VDSO to the GENERIC C VDSO, and the 
main pitfall has been that our vdso calling convention is not compatible 
with C calling convention, so we have go through an ASM entry/exit.

See https://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=171469

We should kill this error flag return through CR[SO] and get it the 
"modern" way like other architectectures implementing the C VDSO: return 
0 when successfull, return -err when failed.

> The ELF v2 ABI convention would suit it well, because the caller already
> requires the function address for ctr, so having it in r12 will
> eliminate the need for address calculation, which suits the vdso data
> page access.
> Is there a need for ELF v1 specific calls as well, or could those just be
> deprecated and remain on existing functions or required to use the ELF
> v2 calls using asm wrappers?

What's ELF v1 and ELF v2 ? Is ELF v1 what PPC32 uses ? If so, I'd say 
yes, it would be good to have it to avoid going through ASM in the middle.

> Is there a good reason for the system call fallback to go in the vdso
> function rather than have the caller handle it?

I've seen at least one while porting powerpc to the C VDSO: arguments 
toward VDSO functions are in volatile registers. If the caller has to 
call the fallback by itself, it has to save them before calling the 
VDSO, allthought in 99% of cases it won't use them again. With the 
fallback called by the VDSO itself, the arguments are still hot in 
volatile registers and ready for calling the fallback. That make it very 
easy to call them, see patch 5 in the series 

> Thanks,
> Nick


More information about the libc-dev mailing list