WIP FPC-III support
[linux/fpc-iii.git] / arch / powerpc / perf / callchain.h
blobd6fa6e25234f4f79d6da51f5166c5c78f5b3be9e
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 #ifndef _POWERPC_PERF_CALLCHAIN_H
3 #define _POWERPC_PERF_CALLCHAIN_H
5 int read_user_stack_slow(const void __user *ptr, void *buf, int nb);
6 void perf_callchain_user_64(struct perf_callchain_entry_ctx *entry,
7 struct pt_regs *regs);
8 void perf_callchain_user_32(struct perf_callchain_entry_ctx *entry,
9 struct pt_regs *regs);
11 static inline bool invalid_user_sp(unsigned long sp)
13 unsigned long mask = is_32bit_task() ? 3 : 7;
14 unsigned long top = STACK_TOP - (is_32bit_task() ? 16 : 32);
16 return (!sp || (sp & mask) || (sp > top));
20 * On 32-bit we just access the address and let hash_page create a
21 * HPTE if necessary, so there is no need to fall back to reading
22 * the page tables. Since this is called at interrupt level,
23 * do_page_fault() won't treat a DSI as a page fault.
25 static inline int __read_user_stack(const void __user *ptr, void *ret,
26 size_t size)
28 unsigned long addr = (unsigned long)ptr;
29 int rc;
31 if (addr > TASK_SIZE - size || (addr & (size - 1)))
32 return -EFAULT;
34 rc = copy_from_user_nofault(ret, ptr, size);
36 if (IS_ENABLED(CONFIG_PPC64) && !radix_enabled() && rc)
37 return read_user_stack_slow(ptr, ret, size);
39 return rc;
42 #endif /* _POWERPC_PERF_CALLCHAIN_H */