Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
David S. Miller | 2809a20 | 2012-04-15 20:06:27 -0700 | [diff] [blame] | 2 | #ifndef _BPF_JIT_H |
| 3 | #define _BPF_JIT_H |
| 4 | |
| 5 | /* Conventions: |
| 6 | * %g1 : temporary |
| 7 | * %g2 : Secondary temporary used by SKB data helper stubs. |
David S. Miller | 7b56f76 | 2012-04-17 16:08:29 -0400 | [diff] [blame] | 8 | * %g3 : packet offset passed into SKB data helper stubs. |
David S. Miller | 2809a20 | 2012-04-15 20:06:27 -0700 | [diff] [blame] | 9 | * %o0 : pointer to skb (first argument given to JIT function) |
| 10 | * %o1 : BPF A accumulator |
| 11 | * %o2 : BPF X accumulator |
| 12 | * %o3 : Holds saved %o7 so we can call helper functions without needing |
| 13 | * to allocate a register window. |
David S. Miller | 7b56f76 | 2012-04-17 16:08:29 -0400 | [diff] [blame] | 14 | * %o4 : skb->len - skb->data_len |
| 15 | * %o5 : skb->data |
David S. Miller | 2809a20 | 2012-04-15 20:06:27 -0700 | [diff] [blame] | 16 | */ |
| 17 | |
| 18 | #ifndef __ASSEMBLER__ |
| 19 | #define G0 0x00 |
| 20 | #define G1 0x01 |
| 21 | #define G3 0x03 |
| 22 | #define G6 0x06 |
| 23 | #define O0 0x08 |
| 24 | #define O1 0x09 |
| 25 | #define O2 0x0a |
| 26 | #define O3 0x0b |
| 27 | #define O4 0x0c |
| 28 | #define O5 0x0d |
| 29 | #define SP 0x0e |
| 30 | #define O7 0x0f |
| 31 | #define FP 0x1e |
| 32 | |
| 33 | #define r_SKB O0 |
| 34 | #define r_A O1 |
| 35 | #define r_X O2 |
| 36 | #define r_saved_O7 O3 |
| 37 | #define r_HEADLEN O4 |
| 38 | #define r_SKB_DATA O5 |
| 39 | #define r_TMP G1 |
| 40 | #define r_TMP2 G2 |
| 41 | #define r_OFF G3 |
David S. Miller | 584c5e2 | 2012-04-17 16:38:16 -0400 | [diff] [blame] | 42 | |
David S. Miller | 7a12b50 | 2017-04-17 18:44:36 -0700 | [diff] [blame] | 43 | /* assembly code in arch/sparc/net/bpf_jit_asm_32.S */ |
David S. Miller | 584c5e2 | 2012-04-17 16:38:16 -0400 | [diff] [blame] | 44 | extern u32 bpf_jit_load_word[]; |
| 45 | extern u32 bpf_jit_load_half[]; |
| 46 | extern u32 bpf_jit_load_byte[]; |
| 47 | extern u32 bpf_jit_load_byte_msh[]; |
| 48 | extern u32 bpf_jit_load_word_positive_offset[]; |
| 49 | extern u32 bpf_jit_load_half_positive_offset[]; |
| 50 | extern u32 bpf_jit_load_byte_positive_offset[]; |
| 51 | extern u32 bpf_jit_load_byte_msh_positive_offset[]; |
| 52 | extern u32 bpf_jit_load_word_negative_offset[]; |
| 53 | extern u32 bpf_jit_load_half_negative_offset[]; |
| 54 | extern u32 bpf_jit_load_byte_negative_offset[]; |
| 55 | extern u32 bpf_jit_load_byte_msh_negative_offset[]; |
| 56 | |
David S. Miller | 2809a20 | 2012-04-15 20:06:27 -0700 | [diff] [blame] | 57 | #else |
| 58 | #define r_SKB %o0 |
| 59 | #define r_A %o1 |
| 60 | #define r_X %o2 |
| 61 | #define r_saved_O7 %o3 |
| 62 | #define r_HEADLEN %o4 |
| 63 | #define r_SKB_DATA %o5 |
| 64 | #define r_TMP %g1 |
| 65 | #define r_TMP2 %g2 |
| 66 | #define r_OFF %g3 |
| 67 | #endif |
| 68 | |
| 69 | #endif /* _BPF_JIT_H */ |