Re: csum_partial_copy_fromuser patch, #2

Jakub Jelinek (jj@sunsite.ms.mff.cuni.cz)
Mon, 3 Feb 1997 10:40:48 +0100 (MET)


>
> From: alan@lxorguk.ukuu.org.uk (Alan Cox)
> Date: Sun, 2 Feb 1997 17:10:33 +0000 (GMT)
>
> Why not pass the address of a dummy long word. Thats even faster than
> doing the check (assuming we only write on an error and errors are
> rare anyway).
>
> Jakub wants to have a single routine do it all, that is why. The
> techniques we could do for long routines such as memset, and now the
> checksum stuff especially, is to have just one routine which has all
> the exception detection crap in it, but somehow to have the fault
> exception fixup code know that "ahh, this was a non-foo_user
> invocation, die_if_kernel()"

Ok, just a silly idea which could save up something and let us use just one
code for everything, no matter whether doing exception stuff or not (well,
only if the return value is the same).
I guess we can use the same technique used for exception handling, ie. have
one more exception section (or put it into the same??) and mark in there
routines which want to do exception handling. The fixup would then look down
callee's pc, look in there to see if exception handling wanted. If yes, it
would do the same as it does now, if not, it would die_if_kernel and kill
the process with some signal otherwise.
Like this, we could do e.g. with the csum_partial_from_user:

inline csum_partial_from_user_check (int *err, const char *src, ....)
{
__asm__ __volatile__ (".section __ex_table2
.word 1f
.previous
.......
put err as the last arg to csum_partial, ie. csum_partial_generic has arguments
( const char *src, char *dst, int len, int sum, ...), where ... may or may
not be int *err.
1:
call csum_partial_generic
.......
");
}

and

inline csum_partial_from_user_check (const char *src, ....)
{
return csum_partial_generic (src, ....); /* Note: just with 4 arguments */
}

The problem with clear_user and copy_user is that they return different
thing than normal bzero/memset/memcpy, if I remember well...
The question is if someone is using their arguments in a different way other
than just testing whether it failed or not. If not, we can have them return
the same thing or do other tricks, but generally what we cannot do is to
have a branch at the end deciding what to return...
And it would be really nice for icache to have those routines just in one
instance.

.u$e.
Cheers .$$$$$:S
Jakub $"*$/"*$$
$.`$ . ^F
4k+#+T.$F
-------------------------------------------------------------- 4P+++"$"$ ---
Jakub Jelinek, jj@sunsite.mff.cuni.cz :R"+ t$$B
Administrator of SunSITE Czech Republic ___# $$$
MFF, Charles University, Prague | | R$$k
---------------------------------------------------------- dd. | Linux $!$
Give your Sparc a new beginning - SparcLinux ddd | Sparc $9$F
-------------------------------------------------------- '!!!!!$ !!#!`
!!!!!* .!!!!!`
'!!!!!!!W..e$$!!!!!!`
"~^^~ ^~~^