mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Frederic Weisbecker <fweisbec@gmail.com>
To: LKML <linux-kernel@vger.kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Ingo Molnar <mingo@elte.hu>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Paul Mackerras <paulus@samba.org>,
	Stephane Eranian <eranian@google.com>,
	Cyrill Gorcunov <gorcunov@openvz.org>,
	Tom Zanussi <tzanussi@gmail.com>,
	Masami Hiramatsu <mhiramat@redhat.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Robert Richter <robert.richter@amd.com>
Subject: [RFC PATCH 1/9] uaccess: Make copy_from_user_nmi() globally available
Date: Wed, 13 Oct 2010 07:06:53 +0200	[thread overview]
Message-ID: <1286946421-32202-2-git-send-regression-fweisbec@gmail.com> (raw)
In-Reply-To: <1286946421-32202-1-git-send-regression-fweisbec@gmail.com>

In order to support user stack dump safely in perf samples from
generic code, export copy_from_user_nmi() from x86 and make it
generally available. For most archs it will map to
copy_from_user_inatomic, but for x86 we need to take care of
not faulting from NMIs.

Since perf is the first user for now, let the overriden x86
implementation in the perf source file.

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Cc: Tom Zanussi <tzanussi@gmail.com>
Cc: Masami Hiramatsu <mhiramat@redhat.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Robert Richter <robert.richter@amd.com>
---
 arch/x86/include/asm/uaccess.h   |    5 +++++
 arch/x86/kernel/cpu/perf_event.c |    4 ++--
 include/asm-generic/uaccess.h    |    4 ++++
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
index abd3e0e..901daf3 100644
--- a/arch/x86/include/asm/uaccess.h
+++ b/arch/x86/include/asm/uaccess.h
@@ -229,6 +229,11 @@ extern void __put_user_2(void);
 extern void __put_user_4(void);
 extern void __put_user_8(void);
 
+extern unsigned long
+__copy_from_user_nmi(void *to, const void __user *from, unsigned long n);
+
+#define copy_from_user_nmi(to, from, n)	__copy_from_user_nmi(to, from, n)
+
 #ifdef CONFIG_X86_WP_WORKS_OK
 
 /**
diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
index e2513f2..d3278da 100644
--- a/arch/x86/kernel/cpu/perf_event.c
+++ b/arch/x86/kernel/cpu/perf_event.c
@@ -45,8 +45,8 @@ do {								\
 /*
  * 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
+__copy_from_user_nmi(void *to, const void __user *from, unsigned long n)
 {
 	unsigned long offset, addr = (unsigned long)from;
 	int type = in_nmi() ? KM_NMI : KM_IRQ0;
diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h
index b218b85..a8d5525 100644
--- a/include/asm-generic/uaccess.h
+++ b/include/asm-generic/uaccess.h
@@ -240,6 +240,10 @@ extern int __get_user_bad(void) __attribute__((noreturn));
 #define __copy_to_user_inatomic __copy_to_user
 #endif
 
+#ifndef copy_from_user_nmi
+#define copy_from_user_nmi __copy_from_user_inatomic
+#endif
+
 static inline long copy_from_user(void *to,
 		const void __user * from, unsigned long n)
 {
-- 
1.6.2.3


  reply	other threads:[~2010-10-13  5:08 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-13  5:06 [RFC] perf: Dwarf cfi based user callchains Frederic Weisbecker
2010-10-13  5:06 ` Frederic Weisbecker [this message]
2010-10-13  7:15   ` [RFC PATCH 1/9] uaccess: Make copy_from_user_nmi() globally available Peter Zijlstra
2010-10-13 14:47     ` Frederic Weisbecker
2010-10-13 20:43       ` Peter Zijlstra
2010-10-13  5:06 ` [RFC PATCH 2/9] perf: Add ability to dump user regs Frederic Weisbecker
2010-10-13  7:20   ` Peter Zijlstra
2010-10-13 14:56     ` Frederic Weisbecker
2010-10-13 14:58     ` Frederic Weisbecker
2010-10-14 11:06     ` Stephane Eranian
2010-10-14 11:20       ` Frederic Weisbecker
2010-10-15  8:39         ` Stephane Eranian
2010-10-15 22:58           ` Frederic Weisbecker
2010-10-17 10:07             ` Peter Zijlstra
2010-10-18 10:01               ` Stephane Eranian
2010-10-18 22:35                 ` Frederic Weisbecker
2010-10-20  9:24                   ` Stephane Eranian
2010-10-20 16:13                     ` Frederic Weisbecker
2010-10-20 16:19                     ` Peter Zijlstra
2010-10-13  5:06 ` [RFC PATCH 3/9] perf: Add ability to dump part of the user stack Frederic Weisbecker
2010-10-13  7:22   ` Peter Zijlstra
2010-10-13 15:01     ` Frederic Weisbecker
2010-10-13  5:06 ` [RFC PATCH 4/9] perf: Don't record frame pointer based user stacktraces if we dump stack and regs Frederic Weisbecker
2010-10-13  7:23   ` Peter Zijlstra
2010-10-13 15:02     ` Frederic Weisbecker
2010-10-16  0:19     ` Frederic Weisbecker
2010-10-13  5:06 ` [RFC PATCH 5/9] perf: Support for dwarf mode callchain on perf record Frederic Weisbecker
2010-10-13  5:06 ` [RFC PATCH 6/9] perf: Build with dwarf cfi Frederic Weisbecker
2010-10-13  5:06 ` [RFC PATCH 7/9] perf: Support for error passed over pointers Frederic Weisbecker
2010-10-13  5:07 ` [RFC PATCH 8/9] perf: Add libunwind dependency for dwarf cfi unwinding Frederic Weisbecker
2010-10-13  5:07 ` [RFC PATCH 9/9] perf: Support for dwarf cfi unwinding on post processing Frederic Weisbecker
2010-10-13 15:13 ` [RFC] perf: Dwarf cfi based user callchains Frank Ch. Eigler
2010-10-20 15:35   ` Frederic Weisbecker

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=1286946421-32202-2-git-send-regression-fweisbec@gmail.com \
    --to=fweisbec@gmail.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@redhat.com \
    --cc=eranian@google.com \
    --cc=gorcunov@openvz.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhiramat@redhat.com \
    --cc=mingo@elte.hu \
    --cc=paulus@samba.org \
    --cc=robert.richter@amd.com \
    --cc=rostedt@goodmis.org \
    --cc=tzanussi@gmail.com \
    /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

Powered by JetHome