diff options
author | Michal Suchanek <msuchanek@suse.de> | 2020-04-06 23:00:22 +0200 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2020-07-30 22:53:49 +1000 |
commit | d3a133aa0e029e0bbb67170f5f18c8fcd4701370 (patch) | |
tree | bed697e7bd70061e09d75c9ec86e7bf5961dfd27 /arch/powerpc/perf/callchain_64.c | |
parent | a0ff72f9f5a780341e7ff5e9ba50a0dad5fa1980 (diff) | |
download | lwn-d3a133aa0e029e0bbb67170f5f18c8fcd4701370.tar.gz lwn-d3a133aa0e029e0bbb67170f5f18c8fcd4701370.zip |
powerpc/perf: Consolidate perf_callchain_user_[64|32]()
perf_callchain_user_64() and perf_callchain_user_32() are nearly
identical. Consolidate into one function with thin wrappers.
Suggested-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Michal Suchanek <msuchanek@suse.de>
[mpe: Adapt to copy_from_user_nofault(), minor formatting]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20200406210022.32265-1-msuchanek@suse.de
Diffstat (limited to 'arch/powerpc/perf/callchain_64.c')
-rw-r--r-- | arch/powerpc/perf/callchain_64.c | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/arch/powerpc/perf/callchain_64.c b/arch/powerpc/perf/callchain_64.c index fa2a1b83b9b0..fed90e827f3a 100644 --- a/arch/powerpc/perf/callchain_64.c +++ b/arch/powerpc/perf/callchain_64.c @@ -23,7 +23,7 @@ * interrupt context, so if the access faults, we read the page tables * to find which page (if any) is mapped and access it directly. */ -int read_user_stack_slow(void __user *ptr, void *buf, int nb) +int read_user_stack_slow(const void __user *ptr, void *buf, int nb) { unsigned long addr = (unsigned long) ptr; @@ -44,16 +44,9 @@ int read_user_stack_slow(void __user *ptr, void *buf, int nb) return -EFAULT; } -static int read_user_stack_64(unsigned long __user *ptr, unsigned long *ret) +static int read_user_stack_64(const unsigned long __user *ptr, unsigned long *ret) { - if ((unsigned long)ptr > TASK_SIZE - sizeof(unsigned long) || - ((unsigned long)ptr & 7)) - return -EFAULT; - - if (!copy_from_user_nofault(ret, ptr, sizeof(*ret))) - return 0; - - return read_user_stack_slow(ptr, ret, 8); + return __read_user_stack(ptr, ret, sizeof(*ret)); } /* |