1 #include <asm/ptrace.h>
7 #define SCRATCH_OFF STACK_BIAS + 128
8 #define BE_PTR(label) be,pn %xcc, label
9 #define SIGN_EXTEND(reg) sra reg, 0, reg
12 #define SCRATCH_OFF 72
13 #define BE_PTR(label) be label
14 #define SIGN_EXTEND(reg)
17 #define SKF_MAX_NEG_OFF (-0x200000) /* SKF_LL_OFF from filter.h */
20 .globl bpf_jit_load_word
23 bl bpf_slow_path_word_neg
25 .globl bpf_jit_load_word_positive_offset
26 bpf_jit_load_word_positive_offset:
27 sub r_HEADLEN, r_OFF, r_TMP
29 ble bpf_slow_path_word
30 add r_SKB_DATA, r_OFF, r_TMP
32 bne load_word_unaligned
37 ldub [r_TMP + 0x0], r_OFF
38 ldub [r_TMP + 0x1], r_TMP2
40 or r_OFF, r_TMP2, r_OFF
41 ldub [r_TMP + 0x2], r_TMP2
43 or r_OFF, r_TMP2, r_OFF
44 ldub [r_TMP + 0x3], r_TMP2
49 .globl bpf_jit_load_half
52 bl bpf_slow_path_half_neg
54 .globl bpf_jit_load_half_positive_offset
55 bpf_jit_load_half_positive_offset:
56 sub r_HEADLEN, r_OFF, r_TMP
58 ble bpf_slow_path_half
59 add r_SKB_DATA, r_OFF, r_TMP
61 bne load_half_unaligned
66 ldub [r_TMP + 0x0], r_OFF
67 ldub [r_TMP + 0x1], r_TMP2
72 .globl bpf_jit_load_byte
75 bl bpf_slow_path_byte_neg
77 .globl bpf_jit_load_byte_positive_offset
78 bpf_jit_load_byte_positive_offset:
80 bge bpf_slow_path_byte
83 ldub [r_SKB_DATA + r_OFF], r_A
85 .globl bpf_jit_load_byte_msh
86 bpf_jit_load_byte_msh:
88 bl bpf_slow_path_byte_msh_neg
90 .globl bpf_jit_load_byte_msh_positive_offset
91 bpf_jit_load_byte_msh_positive_offset:
93 bge bpf_slow_path_byte_msh
95 ldub [r_SKB_DATA + r_OFF], r_OFF
100 #define bpf_slow_path_common(LEN) \
101 save %sp, -SAVE_SZ, %sp; \
104 add %fp, SCRATCH_OFF, %o2; \
105 call skb_copy_bits; \
111 bpf_slow_path_common(4)
113 ld [%sp + SCRATCH_OFF], r_A
117 bpf_slow_path_common(2)
119 lduh [%sp + SCRATCH_OFF], r_A
123 bpf_slow_path_common(1)
125 ldub [%sp + SCRATCH_OFF], r_A
128 bpf_slow_path_byte_msh:
129 bpf_slow_path_common(1)
131 ldub [%sp + SCRATCH_OFF], r_A
132 and r_OFF, 0xf, r_OFF
136 #define bpf_negative_common(LEN) \
137 save %sp, -SAVE_SZ, %sp; \
141 call bpf_internal_load_pointer_neg_helper; \
148 bpf_slow_path_word_neg:
149 sethi %hi(SKF_MAX_NEG_OFF), r_TMP
153 .globl bpf_jit_load_word_negative_offset
154 bpf_jit_load_word_negative_offset:
155 bpf_negative_common(4)
157 bne load_word_unaligned
162 bpf_slow_path_half_neg:
163 sethi %hi(SKF_MAX_NEG_OFF), r_TMP
167 .globl bpf_jit_load_half_negative_offset
168 bpf_jit_load_half_negative_offset:
169 bpf_negative_common(2)
171 bne load_half_unaligned
176 bpf_slow_path_byte_neg:
177 sethi %hi(SKF_MAX_NEG_OFF), r_TMP
181 .globl bpf_jit_load_byte_negative_offset
182 bpf_jit_load_byte_negative_offset:
183 bpf_negative_common(1)
187 bpf_slow_path_byte_msh_neg:
188 sethi %hi(SKF_MAX_NEG_OFF), r_TMP
192 .globl bpf_jit_load_byte_msh_negative_offset
193 bpf_jit_load_byte_msh_negative_offset:
194 bpf_negative_common(1)
196 and r_OFF, 0xf, r_OFF
201 /* Make the JIT program return zero. The JIT epilogue
202 * stores away the original %o7 into r_saved_O7. The
203 * normal leaf function return is to use "retl" which
204 * would evalute to "jmpl %o7 + 8, %g0" but we want to
205 * use the saved value thus the sequence you see here.
207 jmpl r_saved_O7 + 8, %g0