1/* SPDX-License-Identifier: GPL-2.0 */ 2/* Copyright (c) 2025 IBM Corporation, Saket Kumar Bhaskar <skb99@linux.ibm.com> */ 3 4#include <linux/linkage.h> 5#include <asm/ppc_asm.h> 6 7/* 8 * arch_bpf_timed_may_goto() trampoline for powerpc64 9 * 10 * Custom BPF convention (verifier/JIT): 11 * - input: stack offset in BPF_REG_AX (r12) 12 * - output: updated count in BPF_REG_AX (r12) 13 * 14 * Call bpf_check_timed_may_goto(ptr) with normal powerpc64 ABI: 15 * - r3 = ptr, return in r3 16 * 17 * Preserve BPF regs R0-R5 (mapping: r8, r3-r7). 18 */ 19 20SYM_FUNC_START(arch_bpf_timed_may_goto) 21 /* Prologue: save LR, allocate frame */ 22 mflr r0 23 std r0, 16(r1) 24 stdu r1, -112(r1) 25 26 /* Save BPF registers R0 - R5 (r8, r3-r7) */ 27 std r3, 32(r1) 28 std r4, 40(r1) 29 std r5, 48(r1) 30 std r6, 56(r1) 31 std r7, 64(r1) 32 std r8, 72(r1) 33 34 /* 35 * r3 = BPF_REG_FP + BPF_REG_AX 36 * BPF_REG_FP is r31; BPF_REG_AX is r12 (stack offset in bytes). 37 */ 38 add r3, r31, r12 39 bl bpf_check_timed_may_goto 40 41 /* Put return value back into AX */ 42 mr r12, r3 43 44 /* Restore BPF registers R0 - R5 (r8, r3-r7) */ 45 ld r3, 32(r1) 46 ld r4, 40(r1) 47 ld r5, 48(r1) 48 ld r6, 56(r1) 49 ld r7, 64(r1) 50 ld r8, 72(r1) 51 52 /* Epilogue: pop frame, restore LR, return */ 53 addi r1, r1, 112 54 ld r0, 16(r1) 55 mtlr r0 56 blr 57SYM_FUNC_END(arch_bpf_timed_may_goto) 58