From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: References: <1379748334-3313-1-git-send-email-murzin.v@gmail.com> <1379748334-3313-2-git-send-email-murzin.v@gmail.com> In-Reply-To: <1379748334-3313-2-git-send-email-murzin.v@gmail.com> Mime-Version: 1.0 (1.0) Content-Type: text/plain; charset=us-ascii Message-Id: From: Matt Evans Subject: Re: [RESEND PATCH 2/2] ppc: bpf_jit: support MOD operation Date: Mon, 23 Sep 2013 01:13:45 +1000 To: Vladimir Murzin Cc: "netdev@vger.kernel.org" , Vladimir Murzin , "dborkman@redhat.com" , "edumazet@google.com" , "paulus@samba.org" , "linuxppc-dev@lists.ozlabs.org" , "davem@davemloft.net" List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Hi Vladimir, On 21 Sep 2013, at 17:25, Vladimir Murzin wrote: > commit b6069a9570 (filter: add MOD operation) added generic > support for modulus operation in BPF. >=20 > This patch brings JIT support for PPC64 >=20 > Signed-off-by: Vladimir Murzin > Acked-by: Matt Evans Not this version, though; see below.=20 > --- > arch/powerpc/net/bpf_jit_comp.c | 22 ++++++++++++++++++++++ > 1 file changed, 22 insertions(+) >=20 > diff --git a/arch/powerpc/net/bpf_jit_comp.c b/arch/powerpc/net/bpf_jit_co= mp.c > index bf56e33..96f24dc 100644 > --- a/arch/powerpc/net/bpf_jit_comp.c > +++ b/arch/powerpc/net/bpf_jit_comp.c > @@ -193,6 +193,28 @@ static int bpf_jit_build_body(struct sk_filter *fp, u= 32 *image, > PPC_MUL(r_A, r_A, r_scratch1); > } > break; > + case BPF_S_ALU_MOD_X: /* A %=3D X; */ > + ctx->seen |=3D SEEN_XREG; > + PPC_CMPWI(r_X, 0); > + if (ctx->pc_ret0 !=3D -1) { > + PPC_BCC(COND_EQ, addrs[ctx->pc_ret0]); > + } else { > + PPC_BCC_SHORT(COND_NE, (ctx->idx*4)+12); > + PPC_LI(r_ret, 0); > + PPC_JMP(exit_addr); > + } > + PPC_DIVWU(r_scratch1, r_A, r_X); > + PPC_MUL(r_scratch1, r_X, r_scratch1); > + PPC_SUB(r_A, r_A, r_scratch1); > + break; > + case BPF_S_ALU_MOD_K: /* A %=3D K; */ > +#define r_scratch2 (r_scratch1 + 1) Old version of this patch, still? I had hoped that r_scratch2 would be defi= ned in the header. > + PPC_LI32(r_scratch2, K); > + PPC_DIVWU(r_scratch1, r_A, r_scratch2); > + PPC_MUL(r_scratch1, r_scratch2, r_scratch1); > + PPC_SUB(r_A, r_A, r_scratch1); > +#undef r_scratch2 And remember this guy too.. :) Matt > + break; > case BPF_S_ALU_DIV_X: /* A /=3D X; */ > ctx->seen |=3D SEEN_XREG; > PPC_CMPWI(r_X, 0); > --=20 > 1.8.1.5