Re: [PATCH] add likely around access_ok for uaccess

From: Andi Kleen
Date: Sun Sep 14 2003 - 11:50:36 EST


Manfred Spraul <manfred@xxxxxxxxxxxxxxxx> writes:

> The attached patch adds likely to the tests - any objections? What
> about the archs except i386?

I fixed x86-64 get/put_user, although it doesn't matter much there because
it compiles with -fno-reorder-blocks by default.

(generates smaller code and makes the assembly output much more readable)

But:

>
> --
> Manfred
> --- 2.6/include/asm-i386/uaccess.h 2003-09-12 21:53:58.000000000 +0200
> +++ build-2.6/include/asm-i386/uaccess.h 2003-09-14 12:56:19.000000000 +0200
> @@ -300,7 +300,7 @@
> long __pu_err = -EFAULT; \
> __typeof__(*(ptr)) *__pu_addr = (ptr); \
> might_sleep(); \
> - if (access_ok(VERIFY_WRITE,__pu_addr,size)) \
> + if (likely(access_ok(VERIFY_WRITE,__pu_addr,size))) \
> __put_user_size((x),__pu_addr,(size),__pu_err,-EFAULT); \
> __pu_err; \
> })
> @@ -510,7 +510,7 @@
> direct_copy_to_user(void __user *to, const void *from, unsigned long n)

My copy of 2.6.0test5 doesn't have a "direct_copy_to_user", so I'm wondering
at what tree you're looking.

And more importantly I think the i386 uaccess.h copy_{from/to}_user should
be fixed to not do the access_ok()/memset check inline. It can be as well done
out of line. This would likely save some code size. Doing it inline
just doesn't make any sense.

[x86-64 does it this way]

-Andi
-
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/