regs_load.S 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #include <linux/linkage.h>
  3. #define R0 0x00
  4. #define R1 0x08
  5. #define R2 0x10
  6. #define R3 0x18
  7. #define R4 0x20
  8. #define R5 0x28
  9. #define R6 0x30
  10. #define R7 0x38
  11. #define R8 0x40
  12. #define R9 0x48
  13. #define SL 0x50
  14. #define FP 0x58
  15. #define IP 0x60
  16. #define SP 0x68
  17. #define LR 0x70
  18. #define PC 0x78
  19. /*
  20. * Implementation of void perf_regs_load(u64 *regs);
  21. *
  22. * This functions fills in the 'regs' buffer from the actual registers values,
  23. * in the way the perf built-in unwinding test expects them:
  24. * - the PC at the time at the call to this function. Since this function
  25. * is called using a bl instruction, the PC value is taken from LR.
  26. * The built-in unwinding test then unwinds the call stack from the dwarf
  27. * information in unwind__get_entries.
  28. *
  29. * Notes:
  30. * - the 8 bytes stride in the registers offsets comes from the fact
  31. * that the registers are stored in an u64 array (u64 *regs),
  32. * - the regs buffer needs to be zeroed before the call to this function,
  33. * in this case using a calloc in dwarf-unwind.c.
  34. */
  35. .text
  36. .type perf_regs_load,%function
  37. ENTRY(perf_regs_load)
  38. str r0, [r0, #R0]
  39. str r1, [r0, #R1]
  40. str r2, [r0, #R2]
  41. str r3, [r0, #R3]
  42. str r4, [r0, #R4]
  43. str r5, [r0, #R5]
  44. str r6, [r0, #R6]
  45. str r7, [r0, #R7]
  46. str r8, [r0, #R8]
  47. str r9, [r0, #R9]
  48. str sl, [r0, #SL]
  49. str fp, [r0, #FP]
  50. str ip, [r0, #IP]
  51. str sp, [r0, #SP]
  52. str lr, [r0, #LR]
  53. str lr, [r0, #PC] // store pc as lr in order to skip the call
  54. // to this function
  55. mov pc, lr
  56. ENDPROC(perf_regs_load)