entry-common.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef ARCH_S390_ENTRY_COMMON_H
  3. #define ARCH_S390_ENTRY_COMMON_H
  4. #include <linux/sched.h>
  5. #include <linux/audit.h>
  6. #include <linux/randomize_kstack.h>
  7. #include <linux/processor.h>
  8. #include <linux/uaccess.h>
  9. #include <asm/timex.h>
  10. #include <asm/fpu/api.h>
  11. #include <asm/pai.h>
  12. #define ARCH_EXIT_TO_USER_MODE_WORK (_TIF_GUARDED_STORAGE | _TIF_PER_TRAP)
  13. void do_per_trap(struct pt_regs *regs);
  14. static __always_inline void arch_enter_from_user_mode(struct pt_regs *regs)
  15. {
  16. if (IS_ENABLED(CONFIG_DEBUG_ENTRY))
  17. debug_user_asce(0);
  18. pai_kernel_enter(regs);
  19. }
  20. #define arch_enter_from_user_mode arch_enter_from_user_mode
  21. static __always_inline void arch_exit_to_user_mode_work(struct pt_regs *regs,
  22. unsigned long ti_work)
  23. {
  24. if (ti_work & _TIF_PER_TRAP) {
  25. clear_thread_flag(TIF_PER_TRAP);
  26. do_per_trap(regs);
  27. }
  28. if (ti_work & _TIF_GUARDED_STORAGE)
  29. gs_load_bc_cb(regs);
  30. }
  31. #define arch_exit_to_user_mode_work arch_exit_to_user_mode_work
  32. static __always_inline void arch_exit_to_user_mode(void)
  33. {
  34. if (test_cpu_flag(CIF_FPU))
  35. __load_fpu_regs();
  36. if (IS_ENABLED(CONFIG_DEBUG_ENTRY))
  37. debug_user_asce(1);
  38. pai_kernel_exit(current_pt_regs());
  39. }
  40. #define arch_exit_to_user_mode arch_exit_to_user_mode
  41. static inline void arch_exit_to_user_mode_prepare(struct pt_regs *regs,
  42. unsigned long ti_work)
  43. {
  44. choose_random_kstack_offset(get_tod_clock_fast() & 0xff);
  45. }
  46. #define arch_exit_to_user_mode_prepare arch_exit_to_user_mode_prepare
  47. static inline bool on_thread_stack(void)
  48. {
  49. return !(((unsigned long)(current->stack) ^ current_stack_pointer) & ~(THREAD_SIZE - 1));
  50. }
  51. #endif