xref: /openbmc/linux/arch/s390/net/bpf_jit.h (revision bbac1c94)
105462310SMichael Holzheu /*
205462310SMichael Holzheu  * BPF Jit compiler defines
305462310SMichael Holzheu  *
405462310SMichael Holzheu  * Copyright IBM Corp. 2012,2015
505462310SMichael Holzheu  *
605462310SMichael Holzheu  * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
705462310SMichael Holzheu  *	      Michael Holzheu <holzheu@linux.vnet.ibm.com>
805462310SMichael Holzheu  */
905462310SMichael Holzheu 
1005462310SMichael Holzheu #ifndef __ARCH_S390_NET_BPF_JIT_H
1105462310SMichael Holzheu #define __ARCH_S390_NET_BPF_JIT_H
1205462310SMichael Holzheu 
1305462310SMichael Holzheu #ifndef __ASSEMBLY__
1405462310SMichael Holzheu 
1505462310SMichael Holzheu #include <linux/filter.h>
1605462310SMichael Holzheu #include <linux/types.h>
1705462310SMichael Holzheu 
1805462310SMichael Holzheu extern u8 sk_load_word_pos[], sk_load_half_pos[], sk_load_byte_pos[];
1905462310SMichael Holzheu extern u8 sk_load_word[], sk_load_half[], sk_load_byte[];
2005462310SMichael Holzheu 
2105462310SMichael Holzheu #endif /* __ASSEMBLY__ */
2205462310SMichael Holzheu 
2305462310SMichael Holzheu /*
2405462310SMichael Holzheu  * Stackframe layout (packed stack):
2505462310SMichael Holzheu  *
2605462310SMichael Holzheu  *				    ^ high
2705462310SMichael Holzheu  *	      +---------------+     |
2805462310SMichael Holzheu  *	      | old backchain |     |
2905462310SMichael Holzheu  *	      +---------------+     |
3005462310SMichael Holzheu  *	      |   r15 - r6    |     |
3105462310SMichael Holzheu  * BFP	   -> +===============+     |
3205462310SMichael Holzheu  *	      |		      |     |
3305462310SMichael Holzheu  *	      |   BPF stack   |     |
3405462310SMichael Holzheu  *	      |		      |     |
3505462310SMichael Holzheu  *	      +---------------+     |
3605462310SMichael Holzheu  *	      | 8 byte hlen   |     |
3705462310SMichael Holzheu  * R15+168 -> +---------------+     |
3805462310SMichael Holzheu  *	      | 4 byte align  |     |
3905462310SMichael Holzheu  *	      +---------------+     |
4005462310SMichael Holzheu  *	      | 4 byte temp   |     |
4105462310SMichael Holzheu  *	      | for bpf_jit.S |     |
4205462310SMichael Holzheu  * R15+160 -> +---------------+     |
4305462310SMichael Holzheu  *	      | new backchain |     |
4405462310SMichael Holzheu  * R15+152 -> +---------------+     |
4505462310SMichael Holzheu  *	      | + 152 byte SA |     |
4605462310SMichael Holzheu  * R15	   -> +---------------+     + low
4705462310SMichael Holzheu  *
4805462310SMichael Holzheu  * We get 160 bytes stack space from calling function, but only use
4905462310SMichael Holzheu  * 11 * 8 byte (old backchain + r15 - r6) for storing registers.
5005462310SMichael Holzheu  */
51bbac1c94SMichael Holzheu #define STK_SPACE	(MAX_BPF_STACK + 8 + 4 + 4 + 160)
52bbac1c94SMichael Holzheu #define STK_160_UNUSED	(160 - 11 * 8)
53bbac1c94SMichael Holzheu #define STK_OFF		(STK_SPACE - STK_160_UNUSED)
5405462310SMichael Holzheu #define STK_OFF_TMP	160	/* Offset of tmp buffer on stack */
5505462310SMichael Holzheu #define STK_OFF_HLEN	168	/* Offset of SKB header length on stack */
5605462310SMichael Holzheu 
5705462310SMichael Holzheu /* Offset to skip condition code check */
5805462310SMichael Holzheu #define OFF_OK		4
5905462310SMichael Holzheu 
6005462310SMichael Holzheu #endif /* __ARCH_S390_NET_BPF_JIT_H */
61