1*b57c2f12SBinglei Wang/* SPDX-License-Identifier: GPL-2.0+ */ 2*b57c2f12SBinglei Wang/* 3*b57c2f12SBinglei Wang * Author: Patrick Stählin <me@packi.ch> 4*b57c2f12SBinglei Wang */ 5*b57c2f12SBinglei Wang#include <linux/linkage.h> 6*b57c2f12SBinglei Wang 7*b57c2f12SBinglei Wang#include <asm/asm.h> 8*b57c2f12SBinglei Wang#include <asm/asm-offsets.h> 9*b57c2f12SBinglei Wang 10*b57c2f12SBinglei Wang .text 11*b57c2f12SBinglei Wang .altmacro 12*b57c2f12SBinglei Wang 13*b57c2f12SBinglei Wang .macro save_all_base_regs 14*b57c2f12SBinglei Wang REG_S x1, PT_RA(sp) 15*b57c2f12SBinglei Wang REG_S x3, PT_GP(sp) 16*b57c2f12SBinglei Wang REG_S x4, PT_TP(sp) 17*b57c2f12SBinglei Wang REG_S x5, PT_T0(sp) 18*b57c2f12SBinglei Wang REG_S x6, PT_T1(sp) 19*b57c2f12SBinglei Wang REG_S x7, PT_T2(sp) 20*b57c2f12SBinglei Wang REG_S x8, PT_S0(sp) 21*b57c2f12SBinglei Wang REG_S x9, PT_S1(sp) 22*b57c2f12SBinglei Wang REG_S x10, PT_A0(sp) 23*b57c2f12SBinglei Wang REG_S x11, PT_A1(sp) 24*b57c2f12SBinglei Wang REG_S x12, PT_A2(sp) 25*b57c2f12SBinglei Wang REG_S x13, PT_A3(sp) 26*b57c2f12SBinglei Wang REG_S x14, PT_A4(sp) 27*b57c2f12SBinglei Wang REG_S x15, PT_A5(sp) 28*b57c2f12SBinglei Wang REG_S x16, PT_A6(sp) 29*b57c2f12SBinglei Wang REG_S x17, PT_A7(sp) 30*b57c2f12SBinglei Wang REG_S x18, PT_S2(sp) 31*b57c2f12SBinglei Wang REG_S x19, PT_S3(sp) 32*b57c2f12SBinglei Wang REG_S x20, PT_S4(sp) 33*b57c2f12SBinglei Wang REG_S x21, PT_S5(sp) 34*b57c2f12SBinglei Wang REG_S x22, PT_S6(sp) 35*b57c2f12SBinglei Wang REG_S x23, PT_S7(sp) 36*b57c2f12SBinglei Wang REG_S x24, PT_S8(sp) 37*b57c2f12SBinglei Wang REG_S x25, PT_S9(sp) 38*b57c2f12SBinglei Wang REG_S x26, PT_S10(sp) 39*b57c2f12SBinglei Wang REG_S x27, PT_S11(sp) 40*b57c2f12SBinglei Wang REG_S x28, PT_T3(sp) 41*b57c2f12SBinglei Wang REG_S x29, PT_T4(sp) 42*b57c2f12SBinglei Wang REG_S x30, PT_T5(sp) 43*b57c2f12SBinglei Wang REG_S x31, PT_T6(sp) 44*b57c2f12SBinglei Wang .endm 45*b57c2f12SBinglei Wang 46*b57c2f12SBinglei Wang .macro restore_all_base_regs 47*b57c2f12SBinglei Wang REG_L x3, PT_GP(sp) 48*b57c2f12SBinglei Wang REG_L x4, PT_TP(sp) 49*b57c2f12SBinglei Wang REG_L x5, PT_T0(sp) 50*b57c2f12SBinglei Wang REG_L x6, PT_T1(sp) 51*b57c2f12SBinglei Wang REG_L x7, PT_T2(sp) 52*b57c2f12SBinglei Wang REG_L x8, PT_S0(sp) 53*b57c2f12SBinglei Wang REG_L x9, PT_S1(sp) 54*b57c2f12SBinglei Wang REG_L x10, PT_A0(sp) 55*b57c2f12SBinglei Wang REG_L x11, PT_A1(sp) 56*b57c2f12SBinglei Wang REG_L x12, PT_A2(sp) 57*b57c2f12SBinglei Wang REG_L x13, PT_A3(sp) 58*b57c2f12SBinglei Wang REG_L x14, PT_A4(sp) 59*b57c2f12SBinglei Wang REG_L x15, PT_A5(sp) 60*b57c2f12SBinglei Wang REG_L x16, PT_A6(sp) 61*b57c2f12SBinglei Wang REG_L x17, PT_A7(sp) 62*b57c2f12SBinglei Wang REG_L x18, PT_S2(sp) 63*b57c2f12SBinglei Wang REG_L x19, PT_S3(sp) 64*b57c2f12SBinglei Wang REG_L x20, PT_S4(sp) 65*b57c2f12SBinglei Wang REG_L x21, PT_S5(sp) 66*b57c2f12SBinglei Wang REG_L x22, PT_S6(sp) 67*b57c2f12SBinglei Wang REG_L x23, PT_S7(sp) 68*b57c2f12SBinglei Wang REG_L x24, PT_S8(sp) 69*b57c2f12SBinglei Wang REG_L x25, PT_S9(sp) 70*b57c2f12SBinglei Wang REG_L x26, PT_S10(sp) 71*b57c2f12SBinglei Wang REG_L x27, PT_S11(sp) 72*b57c2f12SBinglei Wang REG_L x28, PT_T3(sp) 73*b57c2f12SBinglei Wang REG_L x29, PT_T4(sp) 74*b57c2f12SBinglei Wang REG_L x30, PT_T5(sp) 75*b57c2f12SBinglei Wang REG_L x31, PT_T6(sp) 76*b57c2f12SBinglei Wang .endm 77*b57c2f12SBinglei Wang 78*b57c2f12SBinglei WangENTRY(arch_rethook_trampoline) 79*b57c2f12SBinglei Wang addi sp, sp, -(PT_SIZE_ON_STACK) 80*b57c2f12SBinglei Wang save_all_base_regs 81*b57c2f12SBinglei Wang 82*b57c2f12SBinglei Wang move a0, sp /* pt_regs */ 83*b57c2f12SBinglei Wang 84*b57c2f12SBinglei Wang call arch_rethook_trampoline_callback 85*b57c2f12SBinglei Wang 86*b57c2f12SBinglei Wang /* use the result as the return-address */ 87*b57c2f12SBinglei Wang move ra, a0 88*b57c2f12SBinglei Wang 89*b57c2f12SBinglei Wang restore_all_base_regs 90*b57c2f12SBinglei Wang addi sp, sp, PT_SIZE_ON_STACK 91*b57c2f12SBinglei Wang 92*b57c2f12SBinglei Wang ret 93*b57c2f12SBinglei WangENDPROC(arch_rethook_trampoline) 94