Re: [tip:x86/asm] x86/syscalls: Remove __SYSCALL_COMMON and __SYSCALL_X32

From: Andy Lutomirski
Date: Sat Jan 30 2016 - 12:36:23 EST


On Sat, Jan 30, 2016 at 1:31 AM, Ingo Molnar <mingo@xxxxxxxxxx> wrote:
>
> * Andy Lutomirski <luto@xxxxxxxxxxxxxx> wrote:
>
>> >>>+ if [ "$abi" == "COMMON" -o "$abi" == "64" ]; then
>> >>>+ # COMMON is the same as 64, except that we don't expect X32
>> >>>+ # programs to use it. Our expectation has nothing to do with
>> >>>+ # any generated code, so treat them the same.
>> >>>+ emit 64 "$nr" "$entry" "$compat"
>> >>>+ elif [ "$abi" == "X32" ]; then
>> >>>+ # X32 is equivalent to 64 on an X32-compatible kernel.
>> >>>+ echo "#ifdef CONFIG_X86_X32_ABI"
>> >>>+ emit 64 "$nr" "$entry" "$compat"
>> >>>+ echo "#endif"
>> >>>+ elif [ "$abi" == "I386" ]; then
>> >>>+ emit "$abi" "$nr" "$entry" "$compat"
>> >>>+ else
>> >>>+ echo "Unknown abi $abi" >&2
>> >>>+ exit 1
>> >>>+ fi
>
>> No combinatorial explosion, please. We could use __SYSCALL(nr, sym,
>> abi, qual), though.
>
> Mind fixing it, so that we get back the arch-neutral property?
>

I need some guidance as to the goal to do a good job.

In the version in -tip, I have this thing:

if [ "$abi" == "64" -a -n "$compat" ]; then
echo "a compat entry for a 64-bit syscall makes no sense" >&2
exit 1
fi

Moving that outside the script will either be impossible or an
exercise in really awful C preprocessor hacks. We could keep that
under the theory that it's arch-neutral.

It might be nice to add a similar warning that a compat entry for an
x32 syscall makes so sense. That's a little less arch-neutral,
although it wouldn't be actively harmful on any architecture, since
"x32" wouldn't occur in the first place.

Other than that, I could add a little header called
syscall_abi_mapping.h containing something like:

#ifndef __SYSCALL_ABI_MAPPING_H
#define __SYSCALL_ABI_MAPPING_H

#ifdef CONFIG_X86_32

/* Only I386 entries should ever be compiled into 32-bit kernels. */
#define __SYSCALL_ABI_I386(nr, entry, qual, compat, compat_qual)
__SYSCALL_I386(nr, entry, qual)

#else

/* I386 entries on 64-bit kernels use the compat entry point. */
#define __SYSCALL_ABI_I386(nr, entry, qual, compat, compat_qual)
__SYSCALL_I386(nr, compat, compat_qual)

#define __SYSCALL_ABI_common(nr, entry, compat, qual)
#define __SYSCALL_ABI_64(nr, entry, qual, compat, compat_qual)
__SYSCALL_64(nr, entry, qual)
#ifdef CONFIG_X86_X32
#define __SYSCALL_ABI_x32(nr, entry, qual, compat, compat_qual)
__SYSCALL_64(nr, entry, qual)
#else
#define __SYSCALL_ABI_x32(nr, entry, qual, compat, compat_qual)
__SYSCALL_64(nr, entry, qual)
#endif

#endif

#endif

and teach syscalltbl.sh to emit #include <asm/syscall_abi_mapping.h>
at the beginning of syscalls_32.h and syscalls_64.h and to reference
those macros.

hpa, would that meet your requirements?

IMO this is quite a bit messier than the code in -tip, and I'm
honestly not convinced it's an improvement.

--Andy