Commit 8bb227ac authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Richard Weinberger

um: remove set_fs

Remove address space overrides using set_fs() for User Mode Linux.
Note that just like the existing kernel access case of the uaccess
routines the new nofault kernel handlers do not actually have any
exception handling.  This is probably broken, but not change to the
status quo.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
parent ce72750f
...@@ -21,7 +21,6 @@ config UML ...@@ -21,7 +21,6 @@ config UML
select GENERIC_IRQ_SHOW select GENERIC_IRQ_SHOW
select GENERIC_CPU_DEVICES select GENERIC_CPU_DEVICES
select HAVE_GCC_PLUGINS select HAVE_GCC_PLUGINS
select SET_FS
select TRACE_IRQFLAGS_SUPPORT select TRACE_IRQFLAGS_SUPPORT
select TTY # Needed for line.c select TTY # Needed for line.c
select HAVE_ARCH_VMAP_STACK select HAVE_ARCH_VMAP_STACK
......
...@@ -22,9 +22,6 @@ struct thread_info { ...@@ -22,9 +22,6 @@ struct thread_info {
__u32 cpu; /* current CPU */ __u32 cpu; /* current CPU */
int preempt_count; /* 0 => preemptable, int preempt_count; /* 0 => preemptable,
<0 => BUG */ <0 => BUG */
mm_segment_t addr_limit; /* thread address space:
0-0xBFFFFFFF for user
0-0xFFFFFFFF for kernel */
struct thread_info *real_thread; /* Points to non-IRQ stack */ struct thread_info *real_thread; /* Points to non-IRQ stack */
unsigned long aux_fp_regs[FP_SIZE]; /* auxiliary fp_regs to save/restore unsigned long aux_fp_regs[FP_SIZE]; /* auxiliary fp_regs to save/restore
them out-of-band */ them out-of-band */
...@@ -36,7 +33,6 @@ struct thread_info { ...@@ -36,7 +33,6 @@ struct thread_info {
.flags = 0, \ .flags = 0, \
.cpu = 0, \ .cpu = 0, \
.preempt_count = INIT_PREEMPT_COUNT, \ .preempt_count = INIT_PREEMPT_COUNT, \
.addr_limit = KERNEL_DS, \
.real_thread = NULL, \ .real_thread = NULL, \
} }
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#define __UM_UACCESS_H #define __UM_UACCESS_H
#include <asm/elf.h> #include <asm/elf.h>
#include <asm/unaligned.h>
#define __under_task_size(addr, size) \ #define __under_task_size(addr, size) \
(((unsigned long) (addr) < TASK_SIZE) && \ (((unsigned long) (addr) < TASK_SIZE) && \
...@@ -39,8 +40,24 @@ static inline int __access_ok(unsigned long addr, unsigned long size) ...@@ -39,8 +40,24 @@ static inline int __access_ok(unsigned long addr, unsigned long size)
{ {
return __addr_range_nowrap(addr, size) && return __addr_range_nowrap(addr, size) &&
(__under_task_size(addr, size) || (__under_task_size(addr, size) ||
__access_ok_vsyscall(addr, size) || __access_ok_vsyscall(addr, size));
uaccess_kernel());
} }
/* no pagefaults for kernel addresses in um */
#define HAVE_GET_KERNEL_NOFAULT 1
#define __get_kernel_nofault(dst, src, type, err_label) \
do { \
*((type *)dst) = get_unaligned((type *)(src)); \
if (0) /* make sure the label looks used to the compiler */ \
goto err_label; \
} while (0)
#define __put_kernel_nofault(dst, src, type, err_label) \
do { \
put_unaligned(*((type *)src), (type *)(dst)); \
if (0) /* make sure the label looks used to the compiler */ \
goto err_label; \
} while (0)
#endif #endif
...@@ -146,11 +146,6 @@ static int copy_chunk_from_user(unsigned long from, int len, void *arg) ...@@ -146,11 +146,6 @@ static int copy_chunk_from_user(unsigned long from, int len, void *arg)
unsigned long raw_copy_from_user(void *to, const void __user *from, unsigned long n) unsigned long raw_copy_from_user(void *to, const void __user *from, unsigned long n)
{ {
if (uaccess_kernel()) {
memcpy(to, (__force void*)from, n);
return 0;
}
return buffer_op((unsigned long) from, n, 0, copy_chunk_from_user, &to); return buffer_op((unsigned long) from, n, 0, copy_chunk_from_user, &to);
} }
EXPORT_SYMBOL(raw_copy_from_user); EXPORT_SYMBOL(raw_copy_from_user);
...@@ -166,11 +161,6 @@ static int copy_chunk_to_user(unsigned long to, int len, void *arg) ...@@ -166,11 +161,6 @@ static int copy_chunk_to_user(unsigned long to, int len, void *arg)
unsigned long raw_copy_to_user(void __user *to, const void *from, unsigned long n) unsigned long raw_copy_to_user(void __user *to, const void *from, unsigned long n)
{ {
if (uaccess_kernel()) {
memcpy((__force void *) to, from, n);
return 0;
}
return buffer_op((unsigned long) to, n, 1, copy_chunk_to_user, &from); return buffer_op((unsigned long) to, n, 1, copy_chunk_to_user, &from);
} }
EXPORT_SYMBOL(raw_copy_to_user); EXPORT_SYMBOL(raw_copy_to_user);
...@@ -196,12 +186,6 @@ long strncpy_from_user(char *dst, const char __user *src, long count) ...@@ -196,12 +186,6 @@ long strncpy_from_user(char *dst, const char __user *src, long count)
if (!access_ok(src, 1)) if (!access_ok(src, 1))
return -EFAULT; return -EFAULT;
if (uaccess_kernel()) {
strncpy(dst, (__force void *) src, count);
return strnlen(dst, count);
}
n = buffer_op((unsigned long) src, count, 0, strncpy_chunk_from_user, n = buffer_op((unsigned long) src, count, 0, strncpy_chunk_from_user,
&ptr); &ptr);
if (n != 0) if (n != 0)
...@@ -218,11 +202,6 @@ static int clear_chunk(unsigned long addr, int len, void *unused) ...@@ -218,11 +202,6 @@ static int clear_chunk(unsigned long addr, int len, void *unused)
unsigned long __clear_user(void __user *mem, unsigned long len) unsigned long __clear_user(void __user *mem, unsigned long len)
{ {
if (uaccess_kernel()) {
memset((__force void*)mem, 0, len);
return 0;
}
return buffer_op((unsigned long) mem, len, 1, clear_chunk, NULL); return buffer_op((unsigned long) mem, len, 1, clear_chunk, NULL);
} }
EXPORT_SYMBOL(__clear_user); EXPORT_SYMBOL(__clear_user);
...@@ -245,10 +224,6 @@ long strnlen_user(const char __user *str, long len) ...@@ -245,10 +224,6 @@ long strnlen_user(const char __user *str, long len)
if (!access_ok(str, 1)) if (!access_ok(str, 1))
return -EFAULT; return -EFAULT;
if (uaccess_kernel())
return strnlen((__force char*)str, len) + 1;
n = buffer_op((unsigned long) str, len, 0, strnlen_chunk, &count); n = buffer_op((unsigned long) str, len, 0, strnlen_chunk, &count);
if (n == 0) if (n == 0)
return count + 1; return count + 1;
......
...@@ -8,12 +8,4 @@ extern int host_gdt_entry_tls_min; ...@@ -8,12 +8,4 @@ extern int host_gdt_entry_tls_min;
#define GDT_ENTRY_TLS_MIN host_gdt_entry_tls_min #define GDT_ENTRY_TLS_MIN host_gdt_entry_tls_min
#define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1) #define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
typedef struct {
unsigned long seg;
} mm_segment_t;
#define MAKE_MM_SEG(s) ((mm_segment_t) { (s) })
#define KERNEL_DS MAKE_MM_SEG(~0UL)
#define USER_DS MAKE_MM_SEG(TASK_SIZE)
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment