]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
bpf: xor of a/x in cbpf can be done in 32 bit alu
authorDaniel Borkmann <daniel@iogearbox.net>
Fri, 26 Jan 2018 22:33:36 +0000 (23:33 +0100)
committerAlexei Starovoitov <ast@kernel.org>
Sat, 27 Jan 2018 00:42:05 +0000 (16:42 -0800)
Very minor optimization; saves 1 byte per program in x86_64
JIT in cBPF prologue.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
net/core/filter.c

index fe2c7937351f5ae5bfdd3e4b2a288cd5c2c4bc37..60d8c8712652be5263249dd43f8ec57d62975dd3 100644 (file)
@@ -401,8 +401,8 @@ static int bpf_convert_filter(struct sock_filter *prog, int len,
                /* Classic BPF expects A and X to be reset first. These need
                 * to be guaranteed to be the first two instructions.
                 */
-               *new_insn++ = BPF_ALU64_REG(BPF_XOR, BPF_REG_A, BPF_REG_A);
-               *new_insn++ = BPF_ALU64_REG(BPF_XOR, BPF_REG_X, BPF_REG_X);
+               *new_insn++ = BPF_ALU32_REG(BPF_XOR, BPF_REG_A, BPF_REG_A);
+               *new_insn++ = BPF_ALU32_REG(BPF_XOR, BPF_REG_X, BPF_REG_X);
 
                /* All programs must keep CTX in callee saved BPF_REG_CTX.
                 * In eBPF case it's done by the compiler, here we need to