Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933131AbdHVP0J (ORCPT ); Tue, 22 Aug 2017 11:26:09 -0400 Received: from www62.your-server.de ([213.133.104.62]:49876 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932946AbdHVP0I (ORCPT ); Tue, 22 Aug 2017 11:26:08 -0400 Message-ID: <599C4D02.7090901@iogearbox.net> Date: Tue, 22 Aug 2017 17:25:54 +0200 From: Daniel Borkmann User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Shubham Bansal , linux@armlinux.org.uk, davem@davemloft.net CC: netdev@vger.kernel.org, ast@fb.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, keescook@chromium.org Subject: Re: [PATCH v4 net-next] arm: eBPF JIT compiler References: <1503383772-5788-1-git-send-email-illusionist.neo@gmail.com> <599C48E7.3000409@iogearbox.net> In-Reply-To: <599C48E7.3000409@iogearbox.net> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Authenticated-Sender: daniel@iogearbox.net Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1223 Lines: 38 On 08/22/2017 05:08 PM, Daniel Borkmann wrote: > On 08/22/2017 08:36 AM, Shubham Bansal wrote: > [...] >> + >> +static int out_offset = -1; /* initialized on the first pass of build_body() */ > > Hm, why is this a global var actually? There can be > multiple parallel calls to bpf_int_jit_compile(), we > don't take a global lock on this. Unless I'm missing > something this should really reside in jit_ctx, no? Hm, okay, it's for generating the out jmp offsets in tail call emission which are supposed to always be the same relative offsets; should be fine then. > Given this is on emit_bpf_tail_call(), did you get > tail calls working the way I suggested to test? > >> +static int emit_bpf_tail_call(struct jit_ctx *ctx) >> { > [...] >> + const int idx0 = ctx->idx; >> +#define cur_offset (ctx->idx - idx0) >> +#define jmp_offset (out_offset - (cur_offset)) > [...] >> + >> + /* out: */ >> + if (out_offset == -1) >> + out_offset = cur_offset; >> + if (cur_offset != out_offset) { >> + pr_err_once("tail_call out_offset = %d, expected %d!\n", >> + cur_offset, out_offset); >> + return -1; >> + } >> + return 0; >> +#undef cur_offset >> +#undef jmp_offset >> }