regs_load.S 1.5 KB

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