1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * BPF Jit compiler defines 4 * 5 * Copyright IBM Corp. 2012,2015 6 * 7 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com> 8 * Michael Holzheu <holzheu@linux.vnet.ibm.com> 9 */ 10 11 #ifndef __ARCH_S390_NET_BPF_JIT_H 12 #define __ARCH_S390_NET_BPF_JIT_H 13 14 #ifndef __ASSEMBLY__ 15 16 #include <linux/filter.h> 17 #include <linux/types.h> 18 19 extern u8 sk_load_word_pos[], sk_load_half_pos[], sk_load_byte_pos[]; 20 extern u8 sk_load_word[], sk_load_half[], sk_load_byte[]; 21 22 #endif /* __ASSEMBLY__ */ 23 24 /* 25 * Stackframe layout (packed stack): 26 * 27 * ^ high 28 * +---------------+ | 29 * | old backchain | | 30 * +---------------+ | 31 * | r15 - r6 | | 32 * +---------------+ | 33 * | 4 byte align | | 34 * | tail_call_cnt | | 35 * BFP -> +===============+ | 36 * | | | 37 * | BPF stack | | 38 * | | | 39 * +---------------+ | 40 * | 8 byte skbp | | 41 * R15+176 -> +---------------+ | 42 * | 8 byte hlen | | 43 * R15+168 -> +---------------+ | 44 * | 4 byte align | | 45 * +---------------+ | 46 * | 4 byte temp | | 47 * | for bpf_jit.S | | 48 * R15+160 -> +---------------+ | 49 * | new backchain | | 50 * R15+152 -> +---------------+ | 51 * | + 152 byte SA | | 52 * R15 -> +---------------+ + low 53 * 54 * We get 160 bytes stack space from calling function, but only use 55 * 12 * 8 byte for old backchain, r15..r6, and tail_call_cnt. 56 * 57 * The stack size used by the BPF program ("BPF stack" above) is passed 58 * via "aux->stack_depth". 59 */ 60 #define STK_SPACE_ADD (8 + 8 + 4 + 4 + 160) 61 #define STK_160_UNUSED (160 - 12 * 8) 62 #define STK_OFF (STK_SPACE_ADD - STK_160_UNUSED) 63 #define STK_OFF_TMP 160 /* Offset of tmp buffer on stack */ 64 #define STK_OFF_HLEN 168 /* Offset of SKB header length on stack */ 65 #define STK_OFF_SKBP 176 /* Offset of SKB pointer on stack */ 66 67 #define STK_OFF_R6 (160 - 11 * 8) /* Offset of r6 on stack */ 68 #define STK_OFF_TCCNT (160 - 12 * 8) /* Offset of tail_call_cnt on stack */ 69 70 /* Offset to skip condition code check */ 71 #define OFF_OK 4 72 73 #endif /* __ARCH_S390_NET_BPF_JIT_H */ 74