diff options
Diffstat (limited to 'arch/x86/net/bpf_jit_comp.c')
-rw-r--r-- | arch/x86/net/bpf_jit_comp.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c index 4923d92f918d..45e4eb5bcbb2 100644 --- a/arch/x86/net/bpf_jit_comp.c +++ b/arch/x86/net/bpf_jit_comp.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <linux/if_vlan.h> | 13 | #include <linux/if_vlan.h> |
14 | #include <asm/cacheflush.h> | 14 | #include <asm/cacheflush.h> |
15 | #include <asm/set_memory.h> | 15 | #include <asm/set_memory.h> |
16 | #include <asm/nospec-branch.h> | ||
16 | #include <linux/bpf.h> | 17 | #include <linux/bpf.h> |
17 | 18 | ||
18 | /* | 19 | /* |
@@ -290,7 +291,7 @@ static void emit_bpf_tail_call(u8 **pprog) | |||
290 | EMIT2(0x89, 0xD2); /* mov edx, edx */ | 291 | EMIT2(0x89, 0xD2); /* mov edx, edx */ |
291 | EMIT3(0x39, 0x56, /* cmp dword ptr [rsi + 16], edx */ | 292 | EMIT3(0x39, 0x56, /* cmp dword ptr [rsi + 16], edx */ |
292 | offsetof(struct bpf_array, map.max_entries)); | 293 | offsetof(struct bpf_array, map.max_entries)); |
293 | #define OFFSET1 43 /* number of bytes to jump */ | 294 | #define OFFSET1 (41 + RETPOLINE_RAX_BPF_JIT_SIZE) /* number of bytes to jump */ |
294 | EMIT2(X86_JBE, OFFSET1); /* jbe out */ | 295 | EMIT2(X86_JBE, OFFSET1); /* jbe out */ |
295 | label1 = cnt; | 296 | label1 = cnt; |
296 | 297 | ||
@@ -299,7 +300,7 @@ static void emit_bpf_tail_call(u8 **pprog) | |||
299 | */ | 300 | */ |
300 | EMIT2_off32(0x8B, 0x85, 36); /* mov eax, dword ptr [rbp + 36] */ | 301 | EMIT2_off32(0x8B, 0x85, 36); /* mov eax, dword ptr [rbp + 36] */ |
301 | EMIT3(0x83, 0xF8, MAX_TAIL_CALL_CNT); /* cmp eax, MAX_TAIL_CALL_CNT */ | 302 | EMIT3(0x83, 0xF8, MAX_TAIL_CALL_CNT); /* cmp eax, MAX_TAIL_CALL_CNT */ |
302 | #define OFFSET2 32 | 303 | #define OFFSET2 (30 + RETPOLINE_RAX_BPF_JIT_SIZE) |
303 | EMIT2(X86_JA, OFFSET2); /* ja out */ | 304 | EMIT2(X86_JA, OFFSET2); /* ja out */ |
304 | label2 = cnt; | 305 | label2 = cnt; |
305 | EMIT3(0x83, 0xC0, 0x01); /* add eax, 1 */ | 306 | EMIT3(0x83, 0xC0, 0x01); /* add eax, 1 */ |
@@ -313,7 +314,7 @@ static void emit_bpf_tail_call(u8 **pprog) | |||
313 | * goto out; | 314 | * goto out; |
314 | */ | 315 | */ |
315 | EMIT3(0x48, 0x85, 0xC0); /* test rax,rax */ | 316 | EMIT3(0x48, 0x85, 0xC0); /* test rax,rax */ |
316 | #define OFFSET3 10 | 317 | #define OFFSET3 (8 + RETPOLINE_RAX_BPF_JIT_SIZE) |
317 | EMIT2(X86_JE, OFFSET3); /* je out */ | 318 | EMIT2(X86_JE, OFFSET3); /* je out */ |
318 | label3 = cnt; | 319 | label3 = cnt; |
319 | 320 | ||
@@ -326,7 +327,7 @@ static void emit_bpf_tail_call(u8 **pprog) | |||
326 | * rdi == ctx (1st arg) | 327 | * rdi == ctx (1st arg) |
327 | * rax == prog->bpf_func + prologue_size | 328 | * rax == prog->bpf_func + prologue_size |
328 | */ | 329 | */ |
329 | EMIT2(0xFF, 0xE0); /* jmp rax */ | 330 | RETPOLINE_RAX_BPF_JIT(); |
330 | 331 | ||
331 | /* out: */ | 332 | /* out: */ |
332 | BUILD_BUG_ON(cnt - label1 != OFFSET1); | 333 | BUILD_BUG_ON(cnt - label1 != OFFSET1); |