scs.h 1003 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _ASM_SCS_H
  3. #define _ASM_SCS_H
  4. #ifdef __ASSEMBLY__
  5. #include <asm/asm-offsets.h>
  6. #include <asm/sysreg.h>
  7. #ifdef CONFIG_SHADOW_CALL_STACK
  8. scs_sp .req x18
  9. .macro scs_load_current
  10. get_current_task scs_sp
  11. ldr scs_sp, [scs_sp, #TSK_TI_SCS_SP]
  12. .endm
  13. .macro scs_save tsk
  14. str scs_sp, [\tsk, #TSK_TI_SCS_SP]
  15. .endm
  16. #else
  17. .macro scs_load_current
  18. .endm
  19. .macro scs_save tsk
  20. .endm
  21. #endif /* CONFIG_SHADOW_CALL_STACK */
  22. #else
  23. #include <linux/scs.h>
  24. #include <asm/cpufeature.h>
  25. #ifdef CONFIG_UNWIND_PATCH_PAC_INTO_SCS
  26. static inline void dynamic_scs_init(void)
  27. {
  28. extern bool __pi_dynamic_scs_is_enabled;
  29. if (__pi_dynamic_scs_is_enabled) {
  30. pr_info("Enabling dynamic shadow call stack\n");
  31. static_branch_enable(&dynamic_scs_enabled);
  32. }
  33. }
  34. #else
  35. static inline void dynamic_scs_init(void) {}
  36. #endif
  37. int __pi_scs_patch(const u8 eh_frame[], int size);
  38. asmlinkage void __pi_scs_patch_vmlinux(void);
  39. #endif /* __ASSEMBLY __ */
  40. #endif /* _ASM_SCS_H */