All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thiemo Seufer <ths@networkno.de>
To: Franck Bui-Huu <fbuihuu@gmail.com>
Cc: Ralf Baechle <ralf@linux-mips.org>,
	linux-mips <linux-mips@linux-mips.org>
Subject: Re: [PATCH] Introduce __fill_user() and kill __bzero()
Date: Sun, 11 Nov 2007 13:01:31 +0000	[thread overview]
Message-ID: <20071111130130.GB8363@networkno.de> (raw)
In-Reply-To: <4736C1EA.2050009@gmail.com>

Franck Bui-Huu wrote:
> Currently memset() is used to fill a user space area (clear_user) or
> kernel one (memset). These two functions don't have the same
> prototype, the former returning the number of bytes not copied and the
> latter returning the start address of the area to clear. This forces
> memset() to actually returns two values in an unconventional way ie
> the number of bytes not copied is given by $a2. Therefore clear_user()
> needs to call memset() using inline assembly.
> 
> Instead this patch creates __fill_user() which is the same as memset()
> except it always returns the number of bytes not copied. This simplify
> clear_user() and makes its definition saner.
> 
> Also an out of line version of memset is given because gcc generates
> some calls to it since builtin functions have been disabled. It allows
> assembly code to call it too.
> 
> Eventually __bzero() has been removed because it's not part of the
> Linux uaccess API. And the nano-optimization it brings is not
> worthing.
> 
> Signed-off-by: Franck Bui-Huu <fbuihuu@gmail.com>
> ---
>  arch/mips/kernel/mips_ksyms.c |    3 +-
>  arch/mips/lib/csum_partial.S  |    2 +-
>  arch/mips/lib/memcpy.S        |    2 +-
>  arch/mips/lib/memset.S        |   49 ++++++++++++++++++++++++++--------------
>  include/asm-mips/string.h     |    7 +++++-
>  include/asm-mips/uaccess.h    |   17 ++-----------
>  6 files changed, 44 insertions(+), 36 deletions(-)
> 
> diff --git a/arch/mips/kernel/mips_ksyms.c b/arch/mips/kernel/mips_ksyms.c
> index 225755d..a801e09 100644
> --- a/arch/mips/kernel/mips_ksyms.c
> +++ b/arch/mips/kernel/mips_ksyms.c
> @@ -14,7 +14,6 @@
>  #include <asm/pgtable.h>
>  #include <asm/uaccess.h>
>  
> -extern void *__bzero(void *__s, size_t __count);
>  extern long __strncpy_from_user_nocheck_asm(char *__to,
>                                              const char *__from, long __len);
>  extern long __strncpy_from_user_asm(char *__to, const char *__from,
> @@ -36,9 +35,9 @@ EXPORT_SYMBOL(kernel_thread);
>  /*
>   * Userspace access stuff.
>   */
> +EXPORT_SYMBOL(__fill_user);
>  EXPORT_SYMBOL(__copy_user);
>  EXPORT_SYMBOL(__copy_user_inatomic);
> -EXPORT_SYMBOL(__bzero);
>  EXPORT_SYMBOL(__strncpy_from_user_nocheck_asm);
>  EXPORT_SYMBOL(__strncpy_from_user_asm);
>  EXPORT_SYMBOL(__strlen_user_nocheck_asm);
> diff --git a/arch/mips/lib/csum_partial.S b/arch/mips/lib/csum_partial.S
> index c0a77fe..8d3fa1e 100644
> --- a/arch/mips/lib/csum_partial.S
> +++ b/arch/mips/lib/csum_partial.S
> @@ -694,7 +694,7 @@ l_exc:
>  	ADD	dst, t0			# compute start address in a1
>  	SUB	dst, src
>  	/*
> -	 * Clear len bytes starting at dst.  Can't call __bzero because it
> +	 * Clear len bytes starting at dst.  Can't call memset because it
>  	 * might modify len.  An inefficient loop for these rare times...
>  	 */
>  	beqz	len, done
> diff --git a/arch/mips/lib/memcpy.S b/arch/mips/lib/memcpy.S
> index a526c62..425f2c3 100644
> --- a/arch/mips/lib/memcpy.S
> +++ b/arch/mips/lib/memcpy.S
> @@ -443,7 +443,7 @@ l_exc:
>  	ADD	dst, t0			# compute start address in a1
>  	SUB	dst, src
>  	/*
> -	 * Clear len bytes starting at dst.  Can't call __bzero because it
> +	 * Clear len bytes starting at dst.  Can't call memset because it
>  	 * might modify len.  An inefficient loop for these rare times...
>  	 */
>  	beqz	len, done
> diff --git a/arch/mips/lib/memset.S b/arch/mips/lib/memset.S
> index 3f8b8b3..cb6b83d 100644
> --- a/arch/mips/lib/memset.S
> +++ b/arch/mips/lib/memset.S
> @@ -46,17 +46,34 @@
>  	.endm
>  
>  /*
> - * memset(void *s, int c, size_t n)
> + * An outline version of memset, which should be used either by gcc or
> + * by assembly code.
> + */
> +NESTED(memset, 24, ra)
> +	PTR_ADDU	sp, sp, -24
> +	LONG_S		a0, 16(sp)
> +	LONG_S		ra, 20(sp)
> +	jal		__fill_user
> +	LONG_L		v0, 16(sp)
> +	LONG_L		ra, 20(sp)
> +	PTR_ADDU	sp, sp, 24
> +	jr		ra
> +END(memset)

This will break on 64bit kernels.


Thiemo

  reply	other threads:[~2007-11-11 13:01 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-11  8:48 [PATCH] Introduce __fill_user() and kill __bzero() Franck Bui-Huu
2007-11-11 13:01 ` Thiemo Seufer [this message]
2007-11-11 13:57   ` Franck Bui-Huu
2007-11-14  8:24   ` Franck Bui-Huu
2007-11-14 11:58     ` Thiemo Seufer
2007-11-14 12:34       ` Franck Bui-Huu
2007-11-14 13:48         ` Thiemo Seufer
2007-11-14 15:13           ` Franck Bui-Huu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20071111130130.GB8363@networkno.de \
    --to=ths@networkno.de \
    --cc=fbuihuu@gmail.com \
    --cc=linux-mips@linux-mips.org \
    --cc=ralf@linux-mips.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.