提交 1d621674 编写于 作者: D Daniel Borkmann 提交者: Alexei Starovoitov

bpf: xor of a/x in cbpf can be done in 32 bit alu

Very minor optimization; saves 1 byte per program in x86_64
JIT in cBPF prologue.
Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
Acked-by: NAlexei Starovoitov <ast@kernel.org>
Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
上级 c25ef6a5
...@@ -401,8 +401,8 @@ static int bpf_convert_filter(struct sock_filter *prog, int len, ...@@ -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 /* Classic BPF expects A and X to be reset first. These need
* to be guaranteed to be the first two instructions. * 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_ALU32_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_X, BPF_REG_X);
/* All programs must keep CTX in callee saved BPF_REG_CTX. /* All programs must keep CTX in callee saved BPF_REG_CTX.
* In eBPF case it's done by the compiler, here we need to * In eBPF case it's done by the compiler, here we need to
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册