mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: linux-kernel@vger.kernel.org
Cc: uclinux-dist-devel@blackfin.uclinux.org
Subject: [PATCH 17/17] Blackfin: convert uaccess to asm-generic
Date: Sun, 14 Jun 2009 08:01:18 -0400	[thread overview]
Message-ID: <1244980878-2124-18-git-send-email-vapier@gentoo.org> (raw)
In-Reply-To: <1244980878-2124-1-git-send-email-vapier@gentoo.org>

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
 arch/blackfin/include/asm/segment.h |    8 +-
 arch/blackfin/include/asm/uaccess.h |  265 ++---------------------------------
 2 files changed, 10 insertions(+), 263 deletions(-)

diff --git a/arch/blackfin/include/asm/segment.h b/arch/blackfin/include/asm/segment.h
index 02cfd09..f1b81e5 100644
--- a/arch/blackfin/include/asm/segment.h
+++ b/arch/blackfin/include/asm/segment.h
@@ -1,7 +1 @@
-#ifndef _BFIN_SEGMENT_H
-#define _BFIN_SEGMENT_H
-
-#define KERNEL_DS   (0x5)
-#define USER_DS     (0x1)
-
-#endif				/* _BFIN_SEGMENT_H */
+#include <asm-generic/segment.h>
diff --git a/arch/blackfin/include/asm/uaccess.h b/arch/blackfin/include/asm/uaccess.h
index 8894e9f..6f235e2 100644
--- a/arch/blackfin/include/asm/uaccess.h
+++ b/arch/blackfin/include/asm/uaccess.h
@@ -1,268 +1,21 @@
-/* Changes made by Lineo Inc.    May 2001
- *
- * Based on: include/asm-m68knommu/uaccess.h
+/*
+ * User space memory access functions
  */
 
 #ifndef __BLACKFIN_UACCESS_H
 #define __BLACKFIN_UACCESS_H
 
-/*
- * User space memory access functions
- */
-#include <linux/sched.h>
-#include <linux/mm.h>
-#include <linux/string.h>
+#define KERNEL_DS   (0x5)
+#define USER_DS     (0x1)
 
-#include <asm/segment.h>
 #ifdef CONFIG_ACCESS_CHECK
-# include <asm/bfin-global.h>
+# define __access_ok(ptr, size) _access_ok((unsigned long)(ptr), size)
+extern int _access_ok(unsigned long ptr, unsigned long size);
 #endif
 
-#define get_ds()        (KERNEL_DS)
-#define get_fs()        (current_thread_info()->addr_limit)
-
-static inline void set_fs(mm_segment_t fs)
-{
-	current_thread_info()->addr_limit = fs;
-}
-
-#define segment_eq(a,b) ((a) == (b))
+#include <asm-generic/uaccess.h>
 
-#define VERIFY_READ	0
-#define VERIFY_WRITE	1
-
-#define access_ok(type, addr, size) _access_ok((unsigned long)(addr), (size))
-
-static inline int is_in_rom(unsigned long addr)
-{
-	/*
-	 * What we are really trying to do is determine if addr is
-	 * in an allocated kernel memory region. If not then assume
-	 * we cannot free it or otherwise de-allocate it. Ideally
-	 * we could restrict this to really being in a ROM or flash,
-	 * but that would need to be done on a board by board basis,
-	 * not globally.
-	 */
-	if ((addr < _ramstart) || (addr >= _ramend))
-		return (1);
-
-	/* Default case, not in ROM */
-	return (0);
-}
-
-/*
- * The fs value determines whether argument validity checking should be
- * performed or not.  If get_fs() == USER_DS, checking is performed, with
- * get_fs() == KERNEL_DS, checking is bypassed.
- */
+#undef segment_eq
+#define segment_eq(a, b) ((a) == (b))
 
-#ifndef CONFIG_ACCESS_CHECK
-static inline int _access_ok(unsigned long addr, unsigned long size) { return 1; }
-#else
-extern int _access_ok(unsigned long addr, unsigned long size);
 #endif
-
-/*
- * The exception table consists of pairs of addresses: the first is the
- * address of an instruction that is allowed to fault, and the second is
- * the address at which the program should continue.  No registers are
- * modified, so it is entirely up to the continuation code to figure out
- * what to do.
- *
- * All the routines below use bits of fixup code that are out of line
- * with the main instruction path.  This means when everything is well,
- * we don't even have to jump over them.  Further, they do not intrude
- * on our cache or tlb entries.
- */
-
-struct exception_table_entry {
-	unsigned long insn, fixup;
-};
-
-/*
- * These are the main single-value transfer routines.  They automatically
- * use the right size if we just have the right pointer type.
- */
-
-#define put_user(x,p)						\
-	({							\
-		int _err = 0;					\
-		typeof(*(p)) _x = (x);				\
-		typeof(*(p)) *_p = (p);				\
-		if (!access_ok(VERIFY_WRITE, _p, sizeof(*(_p)))) {\
-			_err = -EFAULT;				\
-		}						\
-		else {						\
-		switch (sizeof (*(_p))) {			\
-		case 1:						\
-			__put_user_asm(_x, _p, B);		\
-			break;					\
-		case 2:						\
-			__put_user_asm(_x, _p, W);		\
-			break;					\
-		case 4:						\
-			__put_user_asm(_x, _p,  );		\
-			break;					\
-		case 8: {					\
-			long _xl, _xh;				\
-			_xl = ((long *)&_x)[0];			\
-			_xh = ((long *)&_x)[1];			\
-			__put_user_asm(_xl, ((long *)_p)+0, );	\
-			__put_user_asm(_xh, ((long *)_p)+1, );	\
-		} break;					\
-		default:					\
-			_err = __put_user_bad();		\
-			break;					\
-		}						\
-		}						\
-		_err;						\
-	})
-
-#define __put_user(x,p) put_user(x,p)
-static inline int bad_user_access_length(void)
-{
-	panic("bad_user_access_length");
-	return -1;
-}
-
-#define __put_user_bad() (printk(KERN_INFO "put_user_bad %s:%d %s\n",\
-                           __FILE__, __LINE__, __func__),\
-                           bad_user_access_length(), (-EFAULT))
-
-/*
- * Tell gcc we read from memory instead of writing: this is because
- * we do not write to any memory gcc knows about, so there are no
- * aliasing issues.
- */
-
-#define __ptr(x) ((unsigned long *)(x))
-
-#define __put_user_asm(x,p,bhw)				\
-	__asm__ (#bhw"[%1] = %0;\n\t"			\
-		 : /* no outputs */			\
-		 :"d" (x),"a" (__ptr(p)) : "memory")
-
-#define get_user(x, ptr)					\
-({								\
-	int _err = 0;						\
-	unsigned long _val = 0;					\
-	const typeof(*(ptr)) __user *_p = (ptr);		\
-	const size_t ptr_size = sizeof(*(_p));			\
-	if (likely(access_ok(VERIFY_READ, _p, ptr_size))) {	\
-		BUILD_BUG_ON(ptr_size >= 8);			\
-		switch (ptr_size) {				\
-		case 1:						\
-			__get_user_asm(_val, _p, B,(Z));	\
-			break;					\
-		case 2:						\
-			__get_user_asm(_val, _p, W,(Z));	\
-			break;					\
-		case 4:						\
-			__get_user_asm(_val, _p,  , );		\
-			break;					\
-		}						\
-	} else							\
-		_err = -EFAULT;					\
-	x = (typeof(*(ptr)))_val;				\
-	_err;							\
-})
-
-#define __get_user(x,p) get_user(x,p)
-
-#define __get_user_bad() (bad_user_access_length(), (-EFAULT))
-
-#define __get_user_asm(x, ptr, bhw, option)	\
-({						\
-	__asm__ __volatile__ (			\
-		"%0 =" #bhw "[%1]" #option ";"	\
-		: "=d" (x)			\
-		: "a" (__ptr(ptr)));		\
-})
-
-#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)
-#define __copy_to_user_inatomic __copy_to_user
-#define __copy_from_user_inatomic __copy_from_user
-
-#define copy_to_user_ret(to,from,n,retval) ({ if (copy_to_user(to,from,n))\
-				                 return retval; })
-
-#define copy_from_user_ret(to,from,n,retval) ({ if (copy_from_user(to,from,n))\
-                                                   return retval; })
-
-static inline unsigned long __must_check
-copy_from_user(void *to, const void __user *from, unsigned long n)
-{
-	if (access_ok(VERIFY_READ, from, n))
-		memcpy(to, from, n);
-	else
-		return n;
-	return 0;
-}
-
-static inline unsigned long __must_check
-copy_to_user(void *to, const void __user *from, unsigned long n)
-{
-	if (access_ok(VERIFY_WRITE, to, n))
-		memcpy(to, from, n);
-	else
-		return n;
-	return 0;
-}
-
-/*
- * Copy a null terminated string from userspace.
- */
-
-static inline long __must_check
-strncpy_from_user(char *dst, const char *src, long count)
-{
-	char *tmp;
-	if (!access_ok(VERIFY_READ, src, 1))
-		return -EFAULT;
-	strncpy(dst, src, count);
-	for (tmp = dst; *tmp && count > 0; tmp++, count--) ;
-	return (tmp - dst);
-}
-
-/*
- * Get the size of a string in user space.
- *   src: The string to measure
- *     n: The maximum valid length
- *
- * Get the size of a NUL-terminated string in user space.
- *
- * Returns the size of the string INCLUDING the terminating NUL.
- * On exception, returns 0.
- * If the string is too long, returns a value greater than n.
- */
-static inline long __must_check strnlen_user(const char *src, long n)
-{
-	if (!access_ok(VERIFY_READ, src, 1))
-		return 0;
-	return strnlen(src, n) + 1;
-}
-
-static inline long __must_check strlen_user(const char *src)
-{
-	if (!access_ok(VERIFY_READ, src, 1))
-		return 0;
-	return strlen(src) + 1;
-}
-
-/*
- * Zero Userspace
- */
-
-static inline unsigned long __must_check
-__clear_user(void *to, unsigned long n)
-{
-	if (!access_ok(VERIFY_WRITE, to, n))
-		return n;
-	memset(to, 0, n);
-	return 0;
-}
-
-#define clear_user(to, n) __clear_user(to, n)
-
-#endif				/* _BLACKFIN_UACCESS_H */
-- 
1.6.3.1


  parent reply	other threads:[~2009-06-14 12:05 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-14 12:01 [PATCH 00/17] Blackfin arch conversion " Mike Frysinger
2009-06-14 12:01 ` [PATCH 01/17] Blackfin: use common test_bit() rather than __test_bit() Mike Frysinger
2009-06-14 12:01 ` [PATCH 02/17] Blackfin: pull in asm/io.h in ksyms for prototypes Mike Frysinger
2009-06-14 12:01 ` [PATCH 03/17] Blackfin: only build irqpanic.c when needed Mike Frysinger
2009-06-14 12:01 ` [PATCH 04/17] Blackfin: convert asm/ioctls.h to asm-generic/ioctls.h Mike Frysinger
2009-06-14 12:01 ` [PATCH 05/17] Blackfin: convert to generic checksum code Mike Frysinger
2009-06-15 11:04   ` Arnd Bergmann
2009-06-16 10:03     ` Mike Frysinger
2009-06-19  1:19     ` Mike Frysinger
2009-06-19  9:05       ` Arnd Bergmann
2009-06-19 10:42         ` Mike Frysinger
2009-06-19 12:33           ` Arnd Bergmann
2009-06-19 13:12             ` Mike Frysinger
2009-06-23 21:14               ` Arnd Bergmann
2009-06-23 21:53                 ` Mike Frysinger
2009-06-23 22:06                   ` Arnd Bergmann
2009-06-23 22:11                     ` Mike Frysinger
2009-09-19 19:08                 ` Mike Frysinger
2009-06-14 12:01 ` [PATCH 06/17] Blackfin: convert shm/sysv/ipc to asm-generic Mike Frysinger
2009-06-14 12:01 ` [PATCH 07/17] Blackfin: convert user/elf " Mike Frysinger
2009-06-14 12:01 ` [PATCH 08/17] Blackfin: convert socket/poll " Mike Frysinger
2009-06-14 12:01 ` [PATCH 09/17] Blackfin: convert simple headers " Mike Frysinger
2009-06-14 12:01 ` [PATCH 10/17] Blackfin: convert dma/pci " Mike Frysinger
2009-06-15 11:37   ` Arnd Bergmann
2009-06-16 10:00     ` Mike Frysinger
2009-06-14 12:01 ` [PATCH 11/17] Blackfin: convert termios " Mike Frysinger
2009-06-14 12:01 ` [PATCH 12/17] Blackfin: convert locking primitives " Mike Frysinger
2009-06-14 12:01 ` [PATCH 13/17] Blackfin: convert signal/mmap " Mike Frysinger
2009-06-14 12:01 ` [PATCH 14/17] Blackfin: convert irq/process " Mike Frysinger
2009-06-14 12:01 ` [PATCH 15/17] Blackfin: convert types " Mike Frysinger
2009-06-14 12:01 ` [PATCH 16/17] Blackfin: convert page/tlb " Mike Frysinger
2009-06-14 12:01 ` Mike Frysinger [this message]
2009-06-15 11:42 ` [PATCH 00/17] Blackfin arch conversion " Arnd Bergmann

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=1244980878-2124-18-git-send-email-vapier@gentoo.org \
    --to=vapier@gentoo.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=uclinux-dist-devel@blackfin.uclinux.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®