1
2
3
4
5
6
7
8
9
10
11
12#ifndef _BPF_JIT64_H
13#define _BPF_JIT64_H
14
15#include "bpf_jit.h"
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32#define BPF_PPC_STACK_SAVE (8*8)
33
34#define BPF_PPC_STACK_LOCALS 16
35
36#define BPF_PPC_STACKFRAME (STACK_FRAME_MIN_SIZE + MAX_BPF_STACK + \
37 BPF_PPC_STACK_LOCALS + BPF_PPC_STACK_SAVE)
38
39#ifndef __ASSEMBLY__
40
41
42#define SKB_HLEN_REG (MAX_BPF_JIT_REG + 0)
43#define SKB_DATA_REG (MAX_BPF_JIT_REG + 1)
44#define TMP_REG_1 (MAX_BPF_JIT_REG + 2)
45#define TMP_REG_2 (MAX_BPF_JIT_REG + 3)
46
47
48static const int b2p[] = {
49
50 [BPF_REG_0] = 8,
51
52 [BPF_REG_1] = 3,
53 [BPF_REG_2] = 4,
54 [BPF_REG_3] = 5,
55 [BPF_REG_4] = 6,
56 [BPF_REG_5] = 7,
57
58 [BPF_REG_6] = 27,
59 [BPF_REG_7] = 28,
60 [BPF_REG_8] = 29,
61 [BPF_REG_9] = 30,
62
63 [BPF_REG_FP] = 31,
64
65 [BPF_REG_AX] = 2,
66 [SKB_HLEN_REG] = 25,
67 [SKB_DATA_REG] = 26,
68 [TMP_REG_1] = 9,
69 [TMP_REG_2] = 10
70};
71
72
73#define BPF_PPC_NVR_MIN 24
74
75
76#define DECLARE_LOAD_FUNC(func) u64 func(u64 r3, u64 r4); \
77 u64 func##_negative_offset(u64 r3, u64 r4); \
78 u64 func##_positive_offset(u64 r3, u64 r4);
79
80DECLARE_LOAD_FUNC(sk_load_word);
81DECLARE_LOAD_FUNC(sk_load_half);
82DECLARE_LOAD_FUNC(sk_load_byte);
83
84#define CHOOSE_LOAD_FUNC(imm, func) \
85 (imm < 0 ? \
86 (imm >= SKF_LL_OFF ? func##_negative_offset : func) : \
87 func##_positive_offset)
88
89#define SEEN_FUNC 0x1000
90#define SEEN_STACK 0x2000
91#define SEEN_SKB 0x4000
92#define SEEN_TAILCALL 0x8000
93
94struct codegen_context {
95
96
97
98
99
100
101
102
103
104 unsigned int seen;
105 unsigned int idx;
106};
107
108#endif
109
110#endif
111