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