Re: [PATCH] compat: fixes to allow working with tile arch

From: Arnd Bergmann
Date: Thu May 05 2011 - 03:02:50 EST


On Wednesday 04 May 2011, Chris Metcalf wrote:
> <linux/compat.h> doesn't currently provide enough to allow the new
> <asm-generic/unistd.h> approach to work for the compat syscall vector.
> In principle you should be able to "#define __SYSCALL(nr, call)
> [nr] = (compat_##call)," and then #include <asm/unistd.h>. This change
> adds all the remaining compat_sys_xxx() prototypes, and also adds
> appropriate #defines for compat syscalls that can use the non-compat
> implementation. See arch/tile/kernel/compat.c for an example.

I didn't realize this was still missing, my impression was that this
already worked when you added the tile arch tree, but apparently
I was missing something there.

Thanks for bringing it up and doing the patch for it!

> +/* Standard Linux functions that don't have "compat" versions. */
> +#define compat_sys_accept sys_accept
> +#define compat_sys_accept4 sys_accept4
> +#define compat_sys_access sys_access
> +#define compat_sys_acct sys_acct
> +#define compat_sys_add_key sys_add_key
> ...

It seems kludgy to have to add all the "regular" system calls to yet
another list, I'd prefer the default to be using the same entry point
for the regular syscall and the compat_ version, so you only need to
list the exceptions in the asm-generic/unistd.h file.

Maybe something like

#if __BITS_PER_LONG == 32 || defined(__SYSCALL_COMPAT)
#define __SC_3264(_nr, _32, _64) __SYSCALL(_nr, _32)
#define __SC_COMP(_nr, _32, _64) __SYSCALL(_nr, _32)
#elif defined(__SYSCALL_COMPAT)
#define __SC_3264(_nr, _32, _64) __SYSCALL(_nr, _32)
#define __SC_COMP(_nr, _32, _64) __SYSCALL(_nr, compat ## _32)
#else
#define __SC_3264(_nr, _32, _64) __SYSCALL(_nr, _64)
#define __SC_COMP(_nr, _32, _64) __SYSCALL(_nr, _64)
#endif

Then you replace all __SC_3264 with __SC_COMP for the cases where
you call the compat version instead of the regular syscall in case
of 32-bit compat.

Alternatively, you could create a tristate version in addition
to the existing __SC_3264:

#ifdef __SYSCALL_COMPAT
#define __SC_COMP(_nr, _32, _64, _comp) __SC_3264(_comp, _64)
#else
#define __SC_COMP(_nr, _32, _64, _comp) __SC_3264(_32, _64)
#endif

This requires listing all entry points explicitly, but makes it easier
to grep for where the compat syscalls are actually used.

Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/