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