OSDN Git Service

x86, mm: Redesign get_user with a __builtin_choose_expr hack
authorH. Peter Anvin <hpa@linux.intel.com>
Tue, 12 Feb 2013 19:47:31 +0000 (11:47 -0800)
committerH. Peter Anvin <hpa@linux.intel.com>
Tue, 12 Feb 2013 20:46:40 +0000 (12:46 -0800)
commit3578baaed4613a9fc09bab9f79f6ce2ac682e8a3
tree2f58dbf5dcc6325fd87f17ccafd00f08bed741d8
parent16640165c9079e2cf36fdcfca093f29663a716f7
x86, mm: Redesign get_user with a __builtin_choose_expr hack

Instead of using a bitfield, use an odd little trick using typeof,
__builtin_choose_expr, and sizeof.  __builtin_choose_expr is
explicitly defined to not convert its type (its argument is required
to be a constant expression) so this should be well-defined.

The code is still not 100% preturbation-free versus the baseline
before 64-bit get_user(), but the differences seem to be very small,
mostly related to padding and to gcc deciding when to spill registers.

Cc: Jamie Lokier <jamie@shareable.org>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: H. J. Lu <hjl.tools@gmail.com>
Link: http://lkml.kernel.org/r/511A8922.6050908@zytor.com
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
arch/x86/include/asm/uaccess.h