lkml.org 
[lkml]   [2012]   [Jun]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 03/19] perf, x86: Add copy_from_user_nmi_nochk for best effort copy
Date
Adding copy_from_user_nmi_nochk that provides the best effort
copy regardless the size crossing the task boundary at the moment.

This is going to be useful for stack dump we need in post
DWARF CFI based unwind.

Signed-off-by: Jiri Olsa <jolsa@redhat.com>
---
arch/x86/include/asm/uaccess.h | 2 ++
arch/x86/lib/usercopy.c | 15 +++++++++++----
2 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
index e1f3a17..d8d6bcd 100644
--- a/arch/x86/include/asm/uaccess.h
+++ b/arch/x86/include/asm/uaccess.h
@@ -562,6 +562,8 @@ struct __large_struct { unsigned long buf[100]; };
#endif /* CONFIG_X86_WP_WORKS_OK */

extern unsigned long
+copy_from_user_nmi_nochk(void *to, const void __user *from, unsigned long n);
+extern unsigned long
copy_from_user_nmi(void *to, const void __user *from, unsigned long n);
extern __must_check long
strncpy_from_user(char *dst, const char __user *src, long count);
diff --git a/arch/x86/lib/usercopy.c b/arch/x86/lib/usercopy.c
index 677b1ed..29ca1c7 100644
--- a/arch/x86/lib/usercopy.c
+++ b/arch/x86/lib/usercopy.c
@@ -14,7 +14,7 @@
* 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)
+copy_from_user_nmi_nochk(void *to, const void __user *from, unsigned long n)
{
unsigned long offset, addr = (unsigned long)from;
unsigned long size, len = 0;
@@ -22,9 +22,6 @@ copy_from_user_nmi(void *to, const void __user *from, unsigned long n)
void *map;
int ret;

- if (__range_not_ok(from, n, TASK_SIZE) == 0)
- return len;
-
do {
ret = __get_user_pages_fast(addr, 1, 0, &page);
if (!ret)
@@ -46,4 +43,14 @@ copy_from_user_nmi(void *to, const void __user *from, unsigned long n)

return len;
}
+EXPORT_SYMBOL_GPL(copy_from_user_nmi_nochk);
+
+unsigned long
+copy_from_user_nmi(void *to, const void __user *from, unsigned long n)
+{
+ if (__range_not_ok(from, n, TASK_SIZE) == 0)
+ return 0;
+
+ return copy_from_user_nmi_nochk(to, from, n);
+}
EXPORT_SYMBOL_GPL(copy_from_user_nmi);
--
1.7.7.6


\
 
 \ /
  Last update: 2012-06-11 16:24    [W:0.290 / U:0.364 seconds]
©2003-2014 Jasper Spaans. Advertise on this site