[PATCH] ppc64: fix semtimedop compat syscall

Arnd Bergmann arnd at arndb.de
Tue Mar 22 23:42:44 EST 2005

On Dinsdag 22 März 2005 04:22, Stephen Rothwell wrote:
> On Mon, 21 Mar 2005 13:50:31 -0800 "David S. Miller" <davem at redhat.com> wrote:
> > Anton Blanchard <anton at samba.org> wrote:
> > > I was also wondering if we could make the compat layer sign extension 
> > > code common, the ppc64 ones are written in c and most probably
> > > incomplete at the moment.

One problem is that sign extension can not be expressed in architecture
independent C code. On ppc64, we make the argument an unsigned int
and then cast it to signed int, e.g.

asmlinkage long sys_ssetmask(int newmask);
asmlinkage long sys32_ssetmask(u32 newmask)
        return sys_ssetmask((int) newmask);

On s390, the code would instead need to clear the upper 32 bits,
the existing assembly code could be expressed in C as:

asmlinkage long sys_ssetmask(int newmask);
asmlinkage long sys32_ssetmask(long newmask)
        return sys_ssetmask((int) newmask);

> > I do them in assembler on sparc64 to save a stack frame.
> > See arch/sparc64/kernel/sys32.S
> > 
> > That file is interesting because I am %99.999 certain that
> > it is an exhaustive list of the system calls that require
> > sign extension.

Right, except for the s390 31-bit pointer extension problem.
arch/s390/kernel/compat_wrapper.S does very similar stuff, but
has to do it also for syscalls that have only unsigned or pointer
The s390 file also handles clearing the upper 32 bits for all
arguments, because the CPU does not do that automatically, unlike
ppc64 or x86_64 (don't know about the others).

I have an old script that generates the s390 compat_wrapper.S file
from a header file holding all C prototypes for the compat_sys_*
functions. Maybe we can find a way to make that generic enough
for all seven compat architectures.

> I will take the hint and have a look at compat_sys_ipc (unless someone
> beats me to it).

When I introduced ipc/compat.c, I left over sys32_ipc because
I could not figure out how to do it in a generic way.
It should probably work with a prototype like

asmlinkage long compat_sys_ipc(u32 call, u32 first, u32 second,
                               u32 third, void __user *ptr);

The s390 wrapper would only do a zero-extend the first four arguments,
while compat_sys_ipc would need to do proper compat_ptr() and
sign-extension itself.

       Arnd <><

More information about the Linuxppc64-dev mailing list