From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel Borkmann Subject: Re: [RFC][PATCH bpf v2 1/2] bpf: allow 64-bit offsets for bpf function calls Date: Thu, 15 Feb 2018 17:25:17 +0100 Message-ID: References: <20180213040600.5821-1-sandipan@linux.vnet.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: netdev@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, mpe@ellerman.id.au, naveen.n.rao@linux.vnet.ibm.com To: Sandipan Das , ast@fb.com Return-path: Received: from www62.your-server.de ([213.133.104.62]:53494 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1033257AbeBOQZa (ORCPT ); Thu, 15 Feb 2018 11:25:30 -0500 In-Reply-To: <20180213040600.5821-1-sandipan@linux.vnet.ibm.com> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: On 02/13/2018 05:05 AM, Sandipan Das wrote: > The imm field of a bpf_insn is a signed 32-bit integer. For > JIT-ed bpf-to-bpf function calls, it stores the offset from > __bpf_call_base to the start of the callee function. > > For some architectures, such as powerpc64, it was found that > this offset may be as large as 64 bits because of which this > cannot be accomodated in the imm field without truncation. > > To resolve this, we additionally make aux->func within each > bpf_prog associated with the functions to point to the list > of all function addresses determined by the verifier. > > We keep the value assigned to the off field of the bpf_insn > as a way to index into aux->func and also set aux->func_cnt > so that this can be used for performing basic upper bound > checks for the off field. > > Signed-off-by: Sandipan Das > --- > v2: Make aux->func point to the list of functions determined > by the verifier rather than allocating a separate callee > list for each function. Approach looks good to me; do you know whether s390x JIT would have similar requirement? I think one limitation that would still need to be addressed later with such approach would be regarding the xlated prog dump in bpftool, see 'BPF calls via JIT' in 7105e828c087 ("bpf: allow for correlation of maps and helpers in dump"). Any ideas for this (potentially if we could use off + imm for calls, we'd get to 48 bits, but that seems still not be enough as you say)? Thanks, Daniel