callchain.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. #ifndef _POWERPC_PERF_CALLCHAIN_H
  3. #define _POWERPC_PERF_CALLCHAIN_H
  4. void perf_callchain_user_64(struct perf_callchain_entry_ctx *entry,
  5. struct pt_regs *regs);
  6. void perf_callchain_user_32(struct perf_callchain_entry_ctx *entry,
  7. struct pt_regs *regs);
  8. static inline bool invalid_user_sp(unsigned long sp)
  9. {
  10. unsigned long mask = is_32bit_task() ? 3 : 7;
  11. unsigned long top = STACK_TOP - (is_32bit_task() ? 16 : 32);
  12. return (!sp || (sp & mask) || (sp > top));
  13. }
  14. /*
  15. * On 32-bit we just access the address and let hash_page create a
  16. * HPTE if necessary, so there is no need to fall back to reading
  17. * the page tables. Since this is called at interrupt level,
  18. * do_page_fault() won't treat a DSI as a page fault.
  19. */
  20. static inline int __read_user_stack(const void __user *ptr, void *ret,
  21. size_t size)
  22. {
  23. unsigned long addr = (unsigned long)ptr;
  24. if (addr > TASK_SIZE - size || (addr & (size - 1)))
  25. return -EFAULT;
  26. return copy_from_user_nofault(ret, ptr, size);
  27. }
  28. #endif /* _POWERPC_PERF_CALLCHAIN_H */