Re: [PATCH] bpf,x64: pad NOPs to make images converge more easily

2020-12-14 Thread Gary Lin
On Mon, Dec 14, 2020 at 04:31:44PM +0100, Daniel Borkmann wrote: > On 12/14/20 9:15 AM, Gary Lin wrote: > > On Mon, Dec 14, 2020 at 11:56:22AM +0800, Gary Lin wrote: > > > On Fri, Dec 11, 2020 at 09:05:05PM +0100, Daniel Borkmann wrote: > > > > On 12/11/20 9:19 AM, Gary Lin wrote: > > > > > The x64

Re: [PATCH] bpf,x64: pad NOPs to make images converge more easily

2020-12-14 Thread Daniel Borkmann
On 12/14/20 9:15 AM, Gary Lin wrote: On Mon, Dec 14, 2020 at 11:56:22AM +0800, Gary Lin wrote: On Fri, Dec 11, 2020 at 09:05:05PM +0100, Daniel Borkmann wrote: On 12/11/20 9:19 AM, Gary Lin wrote: The x64 bpf jit expects bpf images converge within the given passes, but it could fail to do so w

Re: [PATCH] bpf,x64: pad NOPs to make images converge more easily

2020-12-14 Thread Gary Lin
On Mon, Dec 14, 2020 at 11:56:22AM +0800, Gary Lin wrote: > On Fri, Dec 11, 2020 at 09:05:05PM +0100, Daniel Borkmann wrote: > > On 12/11/20 9:19 AM, Gary Lin wrote: > > > The x64 bpf jit expects bpf images converge within the given passes, but > > > it could fail to do so with some corner cases. F

Re: [PATCH] bpf,x64: pad NOPs to make images converge more easily

2020-12-13 Thread Gary Lin
On Fri, Dec 11, 2020 at 06:24:47PM -0800, Alexei Starovoitov wrote: > On Fri, Dec 11, 2020 at 1:13 PM Daniel Borkmann wrote: > > >> + } > > >> emit_jmp: > > >> if (is_imm8(jmp_offset)) { > > >> + if (jmp_padding) > > >>

Re: [PATCH] bpf,x64: pad NOPs to make images converge more easily

2020-12-13 Thread Gary Lin
On Fri, Dec 11, 2020 at 09:05:05PM +0100, Daniel Borkmann wrote: > On 12/11/20 9:19 AM, Gary Lin wrote: > > The x64 bpf jit expects bpf images converge within the given passes, but > > it could fail to do so with some corner cases. For example: > > > >l0: ldh [4] > >l1: jeq

Re: [PATCH] bpf,x64: pad NOPs to make images converge more easily

2020-12-13 Thread Gary Lin
On Fri, Dec 11, 2020 at 12:58:17PM -0800, Andrii Nakryiko wrote: > On Fri, Dec 11, 2020 at 8:51 AM Gary Lin wrote: > > > > The x64 bpf jit expects bpf images converge within the given passes, but > > it could fail to do so with some corner cases. For example: > > > > l0: ldh [4] > >

Re: [PATCH] bpf,x64: pad NOPs to make images converge more easily

2020-12-11 Thread Alexei Starovoitov
On Fri, Dec 11, 2020 at 1:13 PM Daniel Borkmann wrote: > >> + } > >> emit_jmp: > >> if (is_imm8(jmp_offset)) { > >> + if (jmp_padding) > >> + cnt += emit_nops(&prog, > >> INSN_SZ_D

Re: [PATCH] bpf,x64: pad NOPs to make images converge more easily

2020-12-11 Thread Daniel Borkmann
On 12/11/20 9:58 PM, Andrii Nakryiko wrote: On Fri, Dec 11, 2020 at 8:51 AM Gary Lin wrote: [...] +static int emit_nops(u8 **pprog, int len) +{ + u8 *prog = *pprog; + int i, noplen, cnt = 0; + + while (len > 0) { + noplen = len; + + if (noplen >

Re: [PATCH] bpf,x64: pad NOPs to make images converge more easily

2020-12-11 Thread Andrii Nakryiko
On Fri, Dec 11, 2020 at 8:51 AM Gary Lin wrote: > > The x64 bpf jit expects bpf images converge within the given passes, but > it could fail to do so with some corner cases. For example: > > l0: ldh [4] > l1: jeq #0x537d, l2, l40 > l2: ld [0] > l3: jeq #0xfa

Re: [PATCH] bpf,x64: pad NOPs to make images converge more easily

2020-12-11 Thread Daniel Borkmann
On 12/11/20 9:19 AM, Gary Lin wrote: The x64 bpf jit expects bpf images converge within the given passes, but it could fail to do so with some corner cases. For example: l0: ldh [4] l1: jeq #0x537d, l2, l40 l2: ld [0] l3: jeq #0xfa163e0d, l4, l40

[PATCH] bpf,x64: pad NOPs to make images converge more easily

2020-12-11 Thread Gary Lin
The x64 bpf jit expects bpf images converge within the given passes, but it could fail to do so with some corner cases. For example: l0: ldh [4] l1: jeq #0x537d, l2, l40 l2: ld [0] l3: jeq #0xfa163e0d, l4, l40 l4: ldh [12] l5: ldx #0xe