blob: cfd6a8be0eb4c5642ae907607abe0bb4d212261f [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
David S. Miller2809a202012-04-15 20:06:27 -07002#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. Miller7b56f762012-04-17 16:08:29 -04008 * %g3 : packet offset passed into SKB data helper stubs.
David S. Miller2809a202012-04-15 20:06:27 -07009 * %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. Miller7b56f762012-04-17 16:08:29 -040014 * %o4 : skb->len - skb->data_len
15 * %o5 : skb->data
David S. Miller2809a202012-04-15 20:06:27 -070016 */
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. Miller584c5e22012-04-17 16:38:16 -040042
David S. Miller7a12b502017-04-17 18:44:36 -070043/* assembly code in arch/sparc/net/bpf_jit_asm_32.S */
David S. Miller584c5e22012-04-17 16:38:16 -040044extern u32 bpf_jit_load_word[];
45extern u32 bpf_jit_load_half[];
46extern u32 bpf_jit_load_byte[];
47extern u32 bpf_jit_load_byte_msh[];
48extern u32 bpf_jit_load_word_positive_offset[];
49extern u32 bpf_jit_load_half_positive_offset[];
50extern u32 bpf_jit_load_byte_positive_offset[];
51extern u32 bpf_jit_load_byte_msh_positive_offset[];
52extern u32 bpf_jit_load_word_negative_offset[];
53extern u32 bpf_jit_load_half_negative_offset[];
54extern u32 bpf_jit_load_byte_negative_offset[];
55extern u32 bpf_jit_load_byte_msh_negative_offset[];
56
David S. Miller2809a202012-04-15 20:06:27 -070057#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 */