Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 257149
b: refs/heads/master
c: 1ac2e6c
h: refs/heads/master
i:
  257147: daf7045
v: v3
  • Loading branch information
Robert Richter authored and Ingo Molnar committed Jul 21, 2011
1 parent 432e01a commit 644f660
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 75 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 9985c20f9e4aee6857c08246b273a3695a52b929
refs/heads/master: 1ac2e6ca44e13a087eb7438d284f887097ee7e84
3 changes: 3 additions & 0 deletions trunk/arch/x86/include/asm/uaccess.h
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,9 @@ struct __large_struct { unsigned long buf[100]; };

#endif /* CONFIG_X86_WP_WORKS_OK */

extern unsigned long
copy_from_user_nmi(void *to, const void __user *from, unsigned long n);

/*
* movsl can be slow when source and dest are not both 8-byte aligned
*/
Expand Down
35 changes: 0 additions & 35 deletions trunk/arch/x86/kernel/cpu/perf_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include <linux/sched.h>
#include <linux/uaccess.h>
#include <linux/slab.h>
#include <linux/highmem.h>
#include <linux/cpu.h>
#include <linux/bitops.h>

Expand Down Expand Up @@ -67,40 +66,6 @@ enum extra_reg_type {
EXTRA_REG_MAX /* number of entries needed */
};

/*
* best effort, GUP based copy_from_user() that assumes IRQ or NMI context
*/
static unsigned long
copy_from_user_nmi(void *to, const void __user *from, unsigned long n)
{
unsigned long offset, addr = (unsigned long)from;
unsigned long size, len = 0;
struct page *page;
void *map;
int ret;

do {
ret = __get_user_pages_fast(addr, 1, 0, &page);
if (!ret)
break;

offset = addr & (PAGE_SIZE - 1);
size = min(PAGE_SIZE - offset, n - len);

map = kmap_atomic(page);
memcpy(to, map+offset, size);
kunmap_atomic(map);
put_page(page);

len += size;
to += size;
addr += size;

} while (len < n);

return len;
}

struct event_constraint {
union {
unsigned long idxmsk[BITS_TO_LONGS(X86_PMC_IDX_MAX)];
Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/x86/lib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ obj-$(CONFIG_SMP) += msr-smp.o cache-smp.o

lib-y := delay.o
lib-y += thunk_$(BITS).o
lib-y += usercopy_$(BITS).o getuser.o putuser.o
lib-y += usercopy_$(BITS).o usercopy.o getuser.o putuser.o
lib-y += memcpy_$(BITS).o
lib-$(CONFIG_INSTRUCTION_DECODER) += insn.o inat.o

Expand Down
43 changes: 43 additions & 0 deletions trunk/arch/x86/lib/usercopy.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* User address space access functions.
*
* For licencing details see kernel-base/COPYING
*/

#include <linux/highmem.h>
#include <linux/module.h>

/*
* best effort, GUP based copy_from_user() that is NMI-safe
*/
unsigned long
copy_from_user_nmi(void *to, const void __user *from, unsigned long n)
{
unsigned long offset, addr = (unsigned long)from;
unsigned long size, len = 0;
struct page *page;
void *map;
int ret;

do {
ret = __get_user_pages_fast(addr, 1, 0, &page);
if (!ret)
break;

offset = addr & (PAGE_SIZE - 1);
size = min(PAGE_SIZE - offset, n - len);

map = kmap_atomic(page);
memcpy(to, map+offset, size);
kunmap_atomic(map);
put_page(page);

len += size;
to += size;
addr += size;

} while (len < n);

return len;
}
EXPORT_SYMBOL_GPL(copy_from_user_nmi);
39 changes: 1 addition & 38 deletions trunk/arch/x86/oprofile/backtrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@
#include <linux/sched.h>
#include <linux/mm.h>
#include <linux/compat.h>
#include <linux/highmem.h>
#include <linux/uaccess.h>

#include <asm/ptrace.h>
#include <asm/uaccess.h>
#include <asm/stacktrace.h>

static int backtrace_stack(void *data, char *name)
Expand All @@ -38,42 +37,6 @@ static struct stacktrace_ops backtrace_ops = {
.walk_stack = print_context_stack,
};

/* from arch/x86/kernel/cpu/perf_event.c: */

/*
* best effort, GUP based copy_from_user() that assumes IRQ or NMI context
*/
static unsigned long
copy_from_user_nmi(void *to, const void __user *from, unsigned long n)
{
unsigned long offset, addr = (unsigned long)from;
unsigned long size, len = 0;
struct page *page;
void *map;
int ret;

do {
ret = __get_user_pages_fast(addr, 1, 0, &page);
if (!ret)
break;

offset = addr & (PAGE_SIZE - 1);
size = min(PAGE_SIZE - offset, n - len);

map = kmap_atomic(page);
memcpy(to, map+offset, size);
kunmap_atomic(map);
put_page(page);

len += size;
to += size;
addr += size;

} while (len < n);

return len;
}

#ifdef CONFIG_COMPAT
static struct stack_frame_ia32 *
dump_user_backtrace_32(struct stack_frame_ia32 *head)
Expand Down

0 comments on commit 644f660

Please sign in to comment.