[PATCH] ppc64: fix semtimedop compat syscall

Arnd Bergmann arnd at arndb.de
Wed Mar 23 08:21:48 EST 2005


On Dinsdag 22 März 2005 18:26, David S. Miller wrote:
> Ok.  The scheme used on sparc64 (and I was under the impression
> that a discussion last year left us with the decision that zero
> extending all args by default, then fixing up the differences was
> the way to go) is to zero extend all the registers at 32-bit syscall
> dispatch, then we have fixups for the sign-extension cases.
> 
> Regardless, we can genericize this even with the differences.

Yes, I remember that discussion now. 

> > 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.
> 
> That's a great idea.  This thing could spit out a set of macros
> that an arch-specific ASM stub could end up using.

Unfortunately, it turned out that the actual script got lost in some
when I clean up my disk, so I have now reimplemented it. The upside
is that it now is architecture independent.
 
> Just an idea, maybe you can come up with something
> cleaner. :-)

This is what I have now. AFAICS, this should work for all architectures,
even without having to zero-extend all arguments. The output currently
looks like

compat_s(sys32_exit, sys_exit)
compat_u_p_u(sys32_read, sys32_read)
compat_u_p_u(sys32_write, sys32_write)
compat_p_s_s(sys32_open, sys_open)
compat_u(sys32_close, sys_close)
compat_p_s(sys32_creat, sys_creat)
compat_p_p(sys32_link, sys_link)
compat_p(sys32_unlink, sys_unlink)
compat_p(sys32_chdir, sys_chdir)
compat_p(sys32_time, sys_time)
compat_p_s_u(sys32_mknod, sys_mknod)
compat_p_u(sys32_chmod, sys_chmod)
compat_p_u_u(sys32_lchown16, sys32_lchown16)
compat_u_s_u(sys32_lseek, sys_lseek)
compat_p_p_p_u_p(sys32_mount, sys32_mount)

This means that every architecture needs to define macros for
all combinations of signed, unsigned, pointer and u64 arguments
that are used by any system call. There is a total of 58
different calling conventions, half of which can be eliminated
for !s390 by providing a generic way to map pointers to unsigned,
e.g.

#define compat_p compat_u
#define compat_s_p compat_s_u

only compat_u, compat_u_u ... compat_u_u_u_u_u can be eliminated
by always doing zero extension at system call entry and that might
not be worth it.

 Arnd <><
-------------- next part --------------
A non-text attachment was scrubbed...
Name: compat_decl.h
Type: text/x-chdr
Size: 13593 bytes
Desc: not available
Url : http://ozlabs.org/pipermail/linuxppc64-dev/attachments/20050322/e770b4d3/attachment.h 
-------------- next part --------------
# remove all lines except prototypes
/^\s*asmlinkage/!d

# ignore return type
s/^ *asmlinkage \+\(void\)\?\(unsigned \+\)\?\(long\)\? \+//

# ignore any const
s/const *//g

# pointer become _p
s/[a-zA-Z0-9_ ]\+ *\*/_p/g
s/\b__sighandler_t/_p/g
s/\bcaddr_t/_p/g

# unsigned long long becomes _U
s/unsigned \+long \+long/_U/g

# unsigned becomes _u
s/\baio_context_t/_u/g
s/\bcompat_gid_t/_u/g
s/\bcompat_size_t/_u/g
s/\bcompat_uid_t/_u/g
s/\bdev_t/_u/g
s/\bgid_t/_u/g
s/\bmode_t/_u/g
s/\bqid_t/_u/g
s/\bsize_t/_u/g
s/\bu32/_u/g
s/\buid_t/_u/g
s/\bulong_ptr/_u/g
s/\bunsigned \+int/_u/g
s/\bunsigned \+long/_u/g
s/\bunsigned/_u/g

# signed becomes _s
s/\bclockid_t/_s/g
s/\bint/_s/g
s/\blong/_s/g
s/\boff_t/_s/g
s/\bpid_t/_s/g
s/\btimer_t/_u/g

# remove commas and spaces between arguments
s/[, ]//g

# output real line
s/\(^[a-z0-9_]*\)(\(.*\));/compat\2(\1, \1)/

# rename output function name in case of sys_*
s/(sys_/(sys32_/


More information about the Linuxppc64-dev mailing list