1
2
3
4
5
6
7
8 #ifndef _BPF_JIT64_H
9 #define _BPF_JIT64_H
10
11 #include "bpf_jit.h"
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 #define BPF_PPC_STACK_SAVE (6*8)
29
30 #define BPF_PPC_STACK_LOCALS 16
31
32 #define BPF_PPC_STACKFRAME (STACK_FRAME_MIN_SIZE + \
33 BPF_PPC_STACK_LOCALS + BPF_PPC_STACK_SAVE)
34
35 #ifndef __ASSEMBLY__
36
37
38 #define TMP_REG_1 (MAX_BPF_JIT_REG + 0)
39 #define TMP_REG_2 (MAX_BPF_JIT_REG + 1)
40
41
42 static const int b2p[] = {
43
44 [BPF_REG_0] = 8,
45
46 [BPF_REG_1] = 3,
47 [BPF_REG_2] = 4,
48 [BPF_REG_3] = 5,
49 [BPF_REG_4] = 6,
50 [BPF_REG_5] = 7,
51
52 [BPF_REG_6] = 27,
53 [BPF_REG_7] = 28,
54 [BPF_REG_8] = 29,
55 [BPF_REG_9] = 30,
56
57 [BPF_REG_FP] = 31,
58
59 [BPF_REG_AX] = 2,
60 [TMP_REG_1] = 9,
61 [TMP_REG_2] = 10
62 };
63
64
65 #define BPF_PPC_NVR_MIN 27
66
67
68
69
70
71 #define PPC_BPF_LL(r, base, i) do { \
72 if ((i) % 4) { \
73 PPC_LI(b2p[TMP_REG_2], (i)); \
74 PPC_LDX(r, base, b2p[TMP_REG_2]); \
75 } else \
76 PPC_LD(r, base, i); \
77 } while(0)
78 #define PPC_BPF_STL(r, base, i) do { \
79 if ((i) % 4) { \
80 PPC_LI(b2p[TMP_REG_2], (i)); \
81 PPC_STDX(r, base, b2p[TMP_REG_2]); \
82 } else \
83 PPC_STD(r, base, i); \
84 } while(0)
85 #define PPC_BPF_STLU(r, base, i) do { PPC_STDU(r, base, i); } while(0)
86
87 #define SEEN_FUNC 0x1000
88 #define SEEN_STACK 0x2000
89 #define SEEN_TAILCALL 0x4000
90
91 struct codegen_context {
92
93
94
95
96
97
98
99
100
101 unsigned int seen;
102 unsigned int idx;
103 unsigned int stack_size;
104 };
105
106 #endif
107
108 #endif