Re: [PATCH] Add 64-bit get_user and __get_user for i386

From: Linus Torvalds
Date: Mon Apr 19 2004 - 09:58:57 EST




On Mon, 19 Apr 2004, Jamie Lokier wrote:
>
> Subject: [PATCH] Add 64-bit get_user and __get_user for i386
> Patch: uaccess64-2.6.5
>
> Add 64-bit get_user and __get_user for i386.
> Don't ask me how, but this shrinks the kernel too.

There must be some bug somewhere if the kernel shrinks from this. Although
possibly the bug is in gcc ;)

Anyway, please don't do it like this (ie making one case be just a
memcpy). If we do this, let's do it right - ie 'd much rather see
something like

#define get_user(x, ptr) \
({ __typeof__(*(ptr)) __val_gu; \
int __ret_gu; \
switch (sizeof(__val_gu)) { \
case 1: __get_user_x(1,__ret_gu,__val_gu,ptr); break; \
case 2: __get_user_x(2,__ret_gu,__val_gu,ptr); break; \
case 4: __get_user_x(4,__ret_gu,__val_gu,ptr); break; \
case 8: __get_user_8(__ret_gu,__val_gu,ptr); break; \
default: __get_user_bad(); break; \
} \
(x) = __val_gu; \
__ret_gu; \
})

and then you just make "__get_user_8()" look something like

#define __get_user_8(ret,x,ptr) \
__asm__ __volatile__("call __get_user_8" \
:"=A" (ret), "=c" (x) \
:"1" (ptr))

Which is _different_ from the other "get_user" cases: it passes the
address in %ecx, and it returns the error in %ecx too - the return value
comes in %edx:%eax. Make the __get_user_8 in getuser.S match those
different rules.

What do you think?

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