Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp625367imu; Thu, 22 Nov 2018 02:59:51 -0800 (PST) X-Google-Smtp-Source: AFSGD/VOnFA5I6xkLZ3H9RjhPqKvdgmSMbosd0NlnEtqC8Y6mvehWRmiFKUbbbe+68AD3ZXYJImM X-Received: by 2002:a63:df13:: with SMTP id u19mr9650677pgg.294.1542884391627; Thu, 22 Nov 2018 02:59:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542884391; cv=none; d=google.com; s=arc-20160816; b=EL3ZbOpMCMf07D2iZ9Q9l0xt24bh3m0QkTPqcMdsJup/O/q30TnHHv3jkjCUEQOVKn fbLtKsIXbRdZx26fQs1AuJ74bvZsv+/4KMpoyI1Df2hCKgp8MOM8cRaipPgLNy5Wo3wO fddqiGn+JE36bWVBEHsC2y+MUd09N0qxCSw3aCV976gzycCzqSAZpnU9UqDSvkr7HJDX QlZfBHW7/x4QDRAL6daEzbau+Ok08AxJSWl/SJentmxe7x1DIMF1/GiWW/FQ67iqFy9C NWv0VeTqwfL4516e3xTCJ76qIVKR+WT+sOxu8+oSR1V5X/Fu2N5EiEaqqbCGo4y1dDwy gE6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=/43PIzZKAIIs6exrSGpoxRl9fTrXlbXEzUORdCLjAEs=; b=VB1TE3aYLq6VSV65v4VH9xwepWhQH4lcyYF/xODQz6s/O5KjUWaiwMnu4SNlqVPUC+ yCsv0tyuWty1Q2qTNeN534rj493eay+Ex2o1ukMLnpc/wOMDJuWlMr8LgZw8zF80iYMu add0+Sm/bdu97Luh9+6umcTa9lInb/Q9xEqlG3egMzdkKTRW1qi7fyYexuWLtZYd+Ykh S13RPtv+7D9BWz+6R+ZsSKxLor7Qjw36bBHWAbGikiQF7eQWjj8mrfj718DFYr4xN7tJ 4ipiR9UlRFJJhSg+r1EmzyCzTtVlrlGZnpM+TVApSE8k8N5IUTZ/vfMw327nj5jufClT OCmw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d2-v6si49745527plo.210.2018.11.22.02.59.36; Thu, 22 Nov 2018 02:59:51 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388104AbeKVJ4w (ORCPT + 99 others); Thu, 22 Nov 2018 04:56:52 -0500 Received: from www62.your-server.de ([213.133.104.62]:51836 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731891AbeKVJ4w (ORCPT ); Thu, 22 Nov 2018 04:56:52 -0500 Received: from [88.198.220.130] (helo=sslproxy01.your-server.de) by www62.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89_1) (envelope-from ) id 1gPbmu-0005Zw-61; Thu, 22 Nov 2018 00:20:04 +0100 Received: from [178.197.249.20] (helo=linux.home) by sslproxy01.your-server.de with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1gPbmt-0007pZ-Sa; Thu, 22 Nov 2018 00:20:03 +0100 Subject: Re: [PATCH v2 2/2] arm64/bpf: don't allocate BPF JIT programs in module memory To: Ard Biesheuvel , linux-arm-kernel@lists.infradead.org Cc: Alexei Starovoitov , Rick Edgecombe , Eric Dumazet , Jann Horn , Kees Cook , Jessica Yu , Arnd Bergmann , Catalin Marinas , Will Deacon , Mark Rutland , "David S. Miller" , linux-kernel@vger.kernel.org, netdev@vger.kernel.org References: <20181121131733.14910-1-ard.biesheuvel@linaro.org> <20181121131733.14910-3-ard.biesheuvel@linaro.org> From: Daniel Borkmann Message-ID: <945415e1-0ff8-65ce-15fa-33cea0a7d1c9@iogearbox.net> Date: Thu, 22 Nov 2018 00:20:02 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <20181121131733.14910-3-ard.biesheuvel@linaro.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Authenticated-Sender: daniel@iogearbox.net X-Virus-Scanned: Clear (ClamAV 0.100.2/25141/Wed Nov 21 23:16:24 2018) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/21/2018 02:17 PM, Ard Biesheuvel wrote: > The arm64 module region is a 128 MB region that is kept close to > the core kernel, in order to ensure that relative branches are > always in range. So using the same region for programs that do > not have this restriction is wasteful, and preferably avoided. > > Now that the core BPF JIT code permits the alloc/free routines to > be overridden, implement them by simple vmalloc_exec()/vfree() > calls, which can be served from anywere. This also solves an > issue under KASAN, where shadow memory is needlessly allocated for > all BPF programs (which don't require KASAN shadow pages since > they are not KASAN instrumented) > > Signed-off-by: Ard Biesheuvel > --- > arch/arm64/net/bpf_jit_comp.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c > index a6fdaea07c63..f91b7c157841 100644 > --- a/arch/arm64/net/bpf_jit_comp.c > +++ b/arch/arm64/net/bpf_jit_comp.c > @@ -940,3 +940,13 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog) > tmp : orig_prog); > return prog; > } > + > +void *bpf_jit_alloc_exec(unsigned long size) > +{ > + return vmalloc_exec(size); > +} > + > +void bpf_jit_free_exec(const void *addr) > +{ > + return vfree(size); > +} Hmm, could you elaborate in the commit log on the potential performance regression for JITed progs on arm64 after this change? I think this change would also break JITing of BPF to BPF calls. You might have the same issue as ppc64 folks where the offset might not fit into imm anymore and would have to transfer it via fp->aux->func[off]->bpf_func instead.