From: Greg Ungerer <gerg@snapgear.com>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: linux-m68k@lists.linux-m68k.org, Greg Ungerer <gerg@uclinux.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] m68k: Use generic strncpy_from_user(), strlen_user(), and strnlen_user()
Date: Wed, 30 May 2012 13:07:08 +1000 [thread overview]
Message-ID: <4FC58EDC.6060800@snapgear.com> (raw)
In-Reply-To: <1338327216-15309-1-git-send-email-geert@linux-m68k.org>
Hi Geert,
On 30/05/12 07:33, Geert Uytterhoeven wrote:
> Signed-off-by: Geert Uytterhoeven<geert@linux-m68k.org>
Looks good:
Acked-by: Greg Ungerer <gerg@uclinux.org>
> ---
> Do we also want
>
> select HAVE_EFFICIENT_UNALIGNED_ACCESS if (!COLDFIRE&& !M68000)
Maybe yes.
Regards
Greg
> arch/m68k/Kconfig | 2 +
> arch/m68k/include/asm/Kbuild | 2 +
> arch/m68k/include/asm/uaccess_mm.h | 11 +++--
> arch/m68k/lib/uaccess.c | 74 ------------------------------------
> 4 files changed, 11 insertions(+), 78 deletions(-)
>
> diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
> index cac5b6b..1471201 100644
> --- a/arch/m68k/Kconfig
> +++ b/arch/m68k/Kconfig
> @@ -7,6 +7,8 @@ config M68K
> select GENERIC_IRQ_SHOW
> select ARCH_HAVE_NMI_SAFE_CMPXCHG if RMW_INSNS
> select GENERIC_CPU_DEVICES
> + select GENERIC_STRNCPY_FROM_USER if MMU
> + select GENERIC_STRNLEN_USER if MMU
> select FPU if MMU
> select ARCH_USES_GETTIMEOFFSET if MMU&& !COLDFIRE
>
> diff --git a/arch/m68k/include/asm/Kbuild b/arch/m68k/include/asm/Kbuild
> index 1a922fa..eafa253 100644
> --- a/arch/m68k/include/asm/Kbuild
> +++ b/arch/m68k/include/asm/Kbuild
> @@ -1,2 +1,4 @@
> include include/asm-generic/Kbuild.asm
> header-y += cachectl.h
> +
> +generic-y += word-at-a-time.h
> diff --git a/arch/m68k/include/asm/uaccess_mm.h b/arch/m68k/include/asm/uaccess_mm.h
> index 9c80cd5..472c891 100644
> --- a/arch/m68k/include/asm/uaccess_mm.h
> +++ b/arch/m68k/include/asm/uaccess_mm.h
> @@ -379,12 +379,15 @@ __constant_copy_to_user(void __user *to, const void *from, unsigned long n)
> #define copy_from_user(to, from, n) __copy_from_user(to, from, n)
> #define copy_to_user(to, from, n) __copy_to_user(to, from, n)
>
> -long strncpy_from_user(char *dst, const char __user *src, long count);
> -long strnlen_user(const char __user *src, long n);
> +#define user_addr_max() \
> + (segment_eq(get_fs(), USER_DS) ? TASK_SIZE : ~0UL)
> +
> +extern long strncpy_from_user(char *dst, const char __user *src, long count);
> +extern __must_check long strlen_user(const char __user *str);
> +extern __must_check long strnlen_user(const char __user *str, long n);
> +
> unsigned long __clear_user(void __user *to, unsigned long n);
>
> #define clear_user __clear_user
>
> -#define strlen_user(str) strnlen_user(str, 32767)
> -
> #endif /* _M68K_UACCESS_H */
> diff --git a/arch/m68k/lib/uaccess.c b/arch/m68k/lib/uaccess.c
> index 5664386..5e97f2e 100644
> --- a/arch/m68k/lib/uaccess.c
> +++ b/arch/m68k/lib/uaccess.c
> @@ -104,80 +104,6 @@ unsigned long __generic_copy_to_user(void __user *to, const void *from,
> EXPORT_SYMBOL(__generic_copy_to_user);
>
> /*
> - * Copy a null terminated string from userspace.
> - */
> -long strncpy_from_user(char *dst, const char __user *src, long count)
> -{
> - long res;
> - char c;
> -
> - if (count<= 0)
> - return count;
> -
> - asm volatile ("\n"
> - "1: "MOVES".b (%2)+,%4\n"
> - " move.b %4,(%1)+\n"
> - " jeq 2f\n"
> - " subq.l #1,%3\n"
> - " jne 1b\n"
> - "2: sub.l %3,%0\n"
> - "3:\n"
> - " .section .fixup,\"ax\"\n"
> - " .even\n"
> - "10: move.l %5,%0\n"
> - " jra 3b\n"
> - " .previous\n"
> - "\n"
> - " .section __ex_table,\"a\"\n"
> - " .align 4\n"
> - " .long 1b,10b\n"
> - " .previous"
> - : "=d" (res), "+a" (dst), "+a" (src), "+r" (count), "=&d" (c)
> - : "i" (-EFAULT), "0" (count));
> -
> - return res;
> -}
> -EXPORT_SYMBOL(strncpy_from_user);
> -
> -/*
> - * Return the size of a string (including the ending 0)
> - *
> - * Return 0 on exception, a value greater than N if too long
> - */
> -long strnlen_user(const char __user *src, long n)
> -{
> - char c;
> - long res;
> -
> - asm volatile ("\n"
> - "1: subq.l #1,%1\n"
> - " jmi 3f\n"
> - "2: "MOVES".b (%0)+,%2\n"
> - " tst.b %2\n"
> - " jne 1b\n"
> - " jra 4f\n"
> - "\n"
> - "3: addq.l #1,%0\n"
> - "4: sub.l %4,%0\n"
> - "5:\n"
> - " .section .fixup,\"ax\"\n"
> - " .even\n"
> - "20: sub.l %0,%0\n"
> - " jra 5b\n"
> - " .previous\n"
> - "\n"
> - " .section __ex_table,\"a\"\n"
> - " .align 4\n"
> - " .long 2b,20b\n"
> - " .previous\n"
> - : "=&a" (res), "+d" (n), "=&d" (c)
> - : "0" (src), "r" (src));
> -
> - return res;
> -}
> -EXPORT_SYMBOL(strnlen_user);
> -
> -/*
> * Zero Userspace
> */
>
--
------------------------------------------------------------------------
Greg Ungerer -- Principal Engineer EMAIL: gerg@snapgear.com
SnapGear Group, McAfee PHONE: +61 7 3435 2888
8 Gardner Close FAX: +61 7 3217 5323
Milton, QLD, 4064, Australia WEB: http://www.SnapGear.com
WARNING: multiple messages have this Message-ID (diff)
From: Greg Ungerer <gerg@snapgear.com>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: <linux-m68k@vger.kernel.org>, Greg Ungerer <gerg@uclinux.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] m68k: Use generic strncpy_from_user(), strlen_user(), and strnlen_user()
Date: Wed, 30 May 2012 13:07:08 +1000 [thread overview]
Message-ID: <4FC58EDC.6060800@snapgear.com> (raw)
In-Reply-To: <1338327216-15309-1-git-send-email-geert@linux-m68k.org>
Hi Geert,
On 30/05/12 07:33, Geert Uytterhoeven wrote:
> Signed-off-by: Geert Uytterhoeven<geert@linux-m68k.org>
Looks good:
Acked-by: Greg Ungerer <gerg@uclinux.org>
> ---
> Do we also want
>
> select HAVE_EFFICIENT_UNALIGNED_ACCESS if (!COLDFIRE&& !M68000)
Maybe yes.
Regards
Greg
> arch/m68k/Kconfig | 2 +
> arch/m68k/include/asm/Kbuild | 2 +
> arch/m68k/include/asm/uaccess_mm.h | 11 +++--
> arch/m68k/lib/uaccess.c | 74 ------------------------------------
> 4 files changed, 11 insertions(+), 78 deletions(-)
>
> diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
> index cac5b6b..1471201 100644
> --- a/arch/m68k/Kconfig
> +++ b/arch/m68k/Kconfig
> @@ -7,6 +7,8 @@ config M68K
> select GENERIC_IRQ_SHOW
> select ARCH_HAVE_NMI_SAFE_CMPXCHG if RMW_INSNS
> select GENERIC_CPU_DEVICES
> + select GENERIC_STRNCPY_FROM_USER if MMU
> + select GENERIC_STRNLEN_USER if MMU
> select FPU if MMU
> select ARCH_USES_GETTIMEOFFSET if MMU&& !COLDFIRE
>
> diff --git a/arch/m68k/include/asm/Kbuild b/arch/m68k/include/asm/Kbuild
> index 1a922fa..eafa253 100644
> --- a/arch/m68k/include/asm/Kbuild
> +++ b/arch/m68k/include/asm/Kbuild
> @@ -1,2 +1,4 @@
> include include/asm-generic/Kbuild.asm
> header-y += cachectl.h
> +
> +generic-y += word-at-a-time.h
> diff --git a/arch/m68k/include/asm/uaccess_mm.h b/arch/m68k/include/asm/uaccess_mm.h
> index 9c80cd5..472c891 100644
> --- a/arch/m68k/include/asm/uaccess_mm.h
> +++ b/arch/m68k/include/asm/uaccess_mm.h
> @@ -379,12 +379,15 @@ __constant_copy_to_user(void __user *to, const void *from, unsigned long n)
> #define copy_from_user(to, from, n) __copy_from_user(to, from, n)
> #define copy_to_user(to, from, n) __copy_to_user(to, from, n)
>
> -long strncpy_from_user(char *dst, const char __user *src, long count);
> -long strnlen_user(const char __user *src, long n);
> +#define user_addr_max() \
> + (segment_eq(get_fs(), USER_DS) ? TASK_SIZE : ~0UL)
> +
> +extern long strncpy_from_user(char *dst, const char __user *src, long count);
> +extern __must_check long strlen_user(const char __user *str);
> +extern __must_check long strnlen_user(const char __user *str, long n);
> +
> unsigned long __clear_user(void __user *to, unsigned long n);
>
> #define clear_user __clear_user
>
> -#define strlen_user(str) strnlen_user(str, 32767)
> -
> #endif /* _M68K_UACCESS_H */
> diff --git a/arch/m68k/lib/uaccess.c b/arch/m68k/lib/uaccess.c
> index 5664386..5e97f2e 100644
> --- a/arch/m68k/lib/uaccess.c
> +++ b/arch/m68k/lib/uaccess.c
> @@ -104,80 +104,6 @@ unsigned long __generic_copy_to_user(void __user *to, const void *from,
> EXPORT_SYMBOL(__generic_copy_to_user);
>
> /*
> - * Copy a null terminated string from userspace.
> - */
> -long strncpy_from_user(char *dst, const char __user *src, long count)
> -{
> - long res;
> - char c;
> -
> - if (count<= 0)
> - return count;
> -
> - asm volatile ("\n"
> - "1: "MOVES".b (%2)+,%4\n"
> - " move.b %4,(%1)+\n"
> - " jeq 2f\n"
> - " subq.l #1,%3\n"
> - " jne 1b\n"
> - "2: sub.l %3,%0\n"
> - "3:\n"
> - " .section .fixup,\"ax\"\n"
> - " .even\n"
> - "10: move.l %5,%0\n"
> - " jra 3b\n"
> - " .previous\n"
> - "\n"
> - " .section __ex_table,\"a\"\n"
> - " .align 4\n"
> - " .long 1b,10b\n"
> - " .previous"
> - : "=d" (res), "+a" (dst), "+a" (src), "+r" (count), "=&d" (c)
> - : "i" (-EFAULT), "0" (count));
> -
> - return res;
> -}
> -EXPORT_SYMBOL(strncpy_from_user);
> -
> -/*
> - * Return the size of a string (including the ending 0)
> - *
> - * Return 0 on exception, a value greater than N if too long
> - */
> -long strnlen_user(const char __user *src, long n)
> -{
> - char c;
> - long res;
> -
> - asm volatile ("\n"
> - "1: subq.l #1,%1\n"
> - " jmi 3f\n"
> - "2: "MOVES".b (%0)+,%2\n"
> - " tst.b %2\n"
> - " jne 1b\n"
> - " jra 4f\n"
> - "\n"
> - "3: addq.l #1,%0\n"
> - "4: sub.l %4,%0\n"
> - "5:\n"
> - " .section .fixup,\"ax\"\n"
> - " .even\n"
> - "20: sub.l %0,%0\n"
> - " jra 5b\n"
> - " .previous\n"
> - "\n"
> - " .section __ex_table,\"a\"\n"
> - " .align 4\n"
> - " .long 2b,20b\n"
> - " .previous\n"
> - : "=&a" (res), "+d" (n), "=&d" (c)
> - : "0" (src), "r" (src));
> -
> - return res;
> -}
> -EXPORT_SYMBOL(strnlen_user);
> -
> -/*
> * Zero Userspace
> */
>
--
------------------------------------------------------------------------
Greg Ungerer -- Principal Engineer EMAIL: gerg@snapgear.com
SnapGear Group, McAfee PHONE: +61 7 3435 2888
8 Gardner Close FAX: +61 7 3217 5323
Milton, QLD, 4064, Australia WEB: http://www.SnapGear.com
next prev parent reply other threads:[~2012-05-30 3:07 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-29 21:33 [PATCH] m68k: Use generic strncpy_from_user(), strlen_user(), and strnlen_user() Geert Uytterhoeven
2012-05-29 21:33 ` Geert Uytterhoeven
2012-05-30 3:07 ` Greg Ungerer [this message]
2012-05-30 3:07 ` Greg Ungerer
2012-05-30 10:22 ` Philippe De Muyter
2012-05-30 10:22 ` Philippe De Muyter
2012-05-30 11:20 ` Geert Uytterhoeven
2012-05-30 14:04 ` Philippe De Muyter
2012-05-30 14:04 ` Philippe De Muyter
2012-06-05 20:57 ` Geert Uytterhoeven
2012-06-05 20:57 ` Geert Uytterhoeven
2012-06-06 6:31 ` Greg Ungerer
2012-06-06 6:31 ` Greg Ungerer
2012-06-06 17:46 ` Geert Uytterhoeven
2012-06-06 17:46 ` Geert Uytterhoeven
2012-06-07 11:10 ` Greg Ungerer
2012-06-07 11:10 ` Greg Ungerer
2012-06-07 13:14 ` Andreas Schwab
2012-06-08 4:14 ` Greg Ungerer
2012-06-08 4:14 ` Greg Ungerer
2012-06-07 13:14 ` Andreas Schwab
2012-06-06 13:44 ` Geert Uytterhoeven
2012-06-06 13:44 ` Geert Uytterhoeven
2012-06-06 15:20 ` Philippe De Muyter
2012-06-06 15:20 ` Philippe De Muyter
2012-05-30 14:42 ` Andreas Schwab
2012-05-30 14:42 ` Andreas Schwab
2012-05-30 11:20 ` Geert Uytterhoeven
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=4FC58EDC.6060800@snapgear.com \
--to=gerg@snapgear.com \
--cc=geert@linux-m68k.org \
--cc=gerg@uclinux.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-m68k@lists.linux-m68k.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.