bpf_timed_may_goto.S 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* Copyright (c) 2025 Puranjay Mohan <puranjay@kernel.org> */
  3. #include <linux/linkage.h>
  4. SYM_FUNC_START(arch_bpf_timed_may_goto)
  5. /* Allocate stack space and emit frame record */
  6. stp x29, x30, [sp, #-64]!
  7. mov x29, sp
  8. /* Save BPF registers R0 - R5 (x7, x0-x4)*/
  9. stp x7, x0, [sp, #16]
  10. stp x1, x2, [sp, #32]
  11. stp x3, x4, [sp, #48]
  12. /*
  13. * Stack depth was passed in BPF_REG_AX (x9), add it to the BPF_FP
  14. * (x25) to get the pointer to count and timestamp and pass it as the
  15. * first argument in x0.
  16. *
  17. * Before generating the call to arch_bpf_timed_may_goto, the verifier
  18. * generates a load instruction using FP, i.e. REG_AX = *(u64 *)(FP -
  19. * stack_off_cnt), so BPF_REG_FP (x25) is always set up by the arm64
  20. * jit in this case.
  21. */
  22. add x0, x9, x25
  23. bl bpf_check_timed_may_goto
  24. /* BPF_REG_AX(x9) will be stored into count, so move return value to it. */
  25. mov x9, x0
  26. /* Restore BPF registers R0 - R5 (x7, x0-x4) */
  27. ldp x7, x0, [sp, #16]
  28. ldp x1, x2, [sp, #32]
  29. ldp x3, x4, [sp, #48]
  30. /* Restore FP and LR */
  31. ldp x29, x30, [sp], #64
  32. ret
  33. SYM_FUNC_END(arch_bpf_timed_may_goto)