1*da6a9125SWilliam Cohen/* 2*da6a9125SWilliam Cohen * trampoline entry and return code for kretprobes. 3*da6a9125SWilliam Cohen */ 4*da6a9125SWilliam Cohen 5*da6a9125SWilliam Cohen#include <linux/linkage.h> 6*da6a9125SWilliam Cohen#include <asm/asm-offsets.h> 7*da6a9125SWilliam Cohen#include <asm/assembler.h> 8*da6a9125SWilliam Cohen 9*da6a9125SWilliam Cohen .text 10*da6a9125SWilliam Cohen 11*da6a9125SWilliam Cohen .macro save_all_base_regs 12*da6a9125SWilliam Cohen stp x0, x1, [sp, #S_X0] 13*da6a9125SWilliam Cohen stp x2, x3, [sp, #S_X2] 14*da6a9125SWilliam Cohen stp x4, x5, [sp, #S_X4] 15*da6a9125SWilliam Cohen stp x6, x7, [sp, #S_X6] 16*da6a9125SWilliam Cohen stp x8, x9, [sp, #S_X8] 17*da6a9125SWilliam Cohen stp x10, x11, [sp, #S_X10] 18*da6a9125SWilliam Cohen stp x12, x13, [sp, #S_X12] 19*da6a9125SWilliam Cohen stp x14, x15, [sp, #S_X14] 20*da6a9125SWilliam Cohen stp x16, x17, [sp, #S_X16] 21*da6a9125SWilliam Cohen stp x18, x19, [sp, #S_X18] 22*da6a9125SWilliam Cohen stp x20, x21, [sp, #S_X20] 23*da6a9125SWilliam Cohen stp x22, x23, [sp, #S_X22] 24*da6a9125SWilliam Cohen stp x24, x25, [sp, #S_X24] 25*da6a9125SWilliam Cohen stp x26, x27, [sp, #S_X26] 26*da6a9125SWilliam Cohen stp x28, x29, [sp, #S_X28] 27*da6a9125SWilliam Cohen add x0, sp, #S_FRAME_SIZE 28*da6a9125SWilliam Cohen stp lr, x0, [sp, #S_LR] 29*da6a9125SWilliam Cohen /* 30*da6a9125SWilliam Cohen * Construct a useful saved PSTATE 31*da6a9125SWilliam Cohen */ 32*da6a9125SWilliam Cohen mrs x0, nzcv 33*da6a9125SWilliam Cohen mrs x1, daif 34*da6a9125SWilliam Cohen orr x0, x0, x1 35*da6a9125SWilliam Cohen mrs x1, CurrentEL 36*da6a9125SWilliam Cohen orr x0, x0, x1 37*da6a9125SWilliam Cohen mrs x1, SPSel 38*da6a9125SWilliam Cohen orr x0, x0, x1 39*da6a9125SWilliam Cohen stp xzr, x0, [sp, #S_PC] 40*da6a9125SWilliam Cohen .endm 41*da6a9125SWilliam Cohen 42*da6a9125SWilliam Cohen .macro restore_all_base_regs 43*da6a9125SWilliam Cohen ldr x0, [sp, #S_PSTATE] 44*da6a9125SWilliam Cohen and x0, x0, #(PSR_N_BIT | PSR_Z_BIT | PSR_C_BIT | PSR_V_BIT) 45*da6a9125SWilliam Cohen msr nzcv, x0 46*da6a9125SWilliam Cohen ldp x0, x1, [sp, #S_X0] 47*da6a9125SWilliam Cohen ldp x2, x3, [sp, #S_X2] 48*da6a9125SWilliam Cohen ldp x4, x5, [sp, #S_X4] 49*da6a9125SWilliam Cohen ldp x6, x7, [sp, #S_X6] 50*da6a9125SWilliam Cohen ldp x8, x9, [sp, #S_X8] 51*da6a9125SWilliam Cohen ldp x10, x11, [sp, #S_X10] 52*da6a9125SWilliam Cohen ldp x12, x13, [sp, #S_X12] 53*da6a9125SWilliam Cohen ldp x14, x15, [sp, #S_X14] 54*da6a9125SWilliam Cohen ldp x16, x17, [sp, #S_X16] 55*da6a9125SWilliam Cohen ldp x18, x19, [sp, #S_X18] 56*da6a9125SWilliam Cohen ldp x20, x21, [sp, #S_X20] 57*da6a9125SWilliam Cohen ldp x22, x23, [sp, #S_X22] 58*da6a9125SWilliam Cohen ldp x24, x25, [sp, #S_X24] 59*da6a9125SWilliam Cohen ldp x26, x27, [sp, #S_X26] 60*da6a9125SWilliam Cohen ldp x28, x29, [sp, #S_X28] 61*da6a9125SWilliam Cohen .endm 62*da6a9125SWilliam Cohen 63*da6a9125SWilliam CohenENTRY(kretprobe_trampoline) 64*da6a9125SWilliam Cohen sub sp, sp, #S_FRAME_SIZE 65*da6a9125SWilliam Cohen 66*da6a9125SWilliam Cohen save_all_base_regs 67*da6a9125SWilliam Cohen 68*da6a9125SWilliam Cohen mov x0, sp 69*da6a9125SWilliam Cohen bl trampoline_probe_handler 70*da6a9125SWilliam Cohen /* 71*da6a9125SWilliam Cohen * Replace trampoline address in lr with actual orig_ret_addr return 72*da6a9125SWilliam Cohen * address. 73*da6a9125SWilliam Cohen */ 74*da6a9125SWilliam Cohen mov lr, x0 75*da6a9125SWilliam Cohen 76*da6a9125SWilliam Cohen restore_all_base_regs 77*da6a9125SWilliam Cohen 78*da6a9125SWilliam Cohen add sp, sp, #S_FRAME_SIZE 79*da6a9125SWilliam Cohen ret 80*da6a9125SWilliam Cohen 81*da6a9125SWilliam CohenENDPROC(kretprobe_trampoline) 82