Message ID | 20230220083203.2988238-1-pulehui@huaweicloud.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1193784wrn; Mon, 20 Feb 2023 00:35:06 -0800 (PST) X-Google-Smtp-Source: AK7set/5cZRwnZ3IpHnapjrKhtnsH4VkhjdNPkgbOsEA0e0YLoDSQpRZcqrJVZa1Uc/OcZzl6k/4 X-Received: by 2002:a17:906:acb:b0:862:11f6:a082 with SMTP id z11-20020a1709060acb00b0086211f6a082mr7598652ejf.17.1676882105951; Mon, 20 Feb 2023 00:35:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676882105; cv=none; d=google.com; s=arc-20160816; b=e4y1xq/KbH4LVXbabq3/3X2hpgel/hQ2uHbqi2HWoy2cjacvNz5+ZQqjOAcfYYvxtT pvJml47KScQjp2vn04orVT/SCfv3QcpXB8fR9POTdk9we1kzyZ4nSK09+3O+HOoPKSxt TK9KobuY4etZRmpy4HpPoxLOCUaQghqnFRyOfbbiLSSNS50DE6+IHja/QeFvkvV56b58 hplcqVykVsbyZYgXJDDRrS6VTF0rO3+/5jLlCSm7JER/Nwe8rCDmGPiNaq8BDspYIu8f gNvczOn4WieRuQO5IXRae+Y6entQj8uXclKWm553v06+kcnyf9U1daIZCOvArTnUjAvw sKlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=Hrxm/cl4iX542n6CsRoZM5CM5XeaRNUPpR36jdEwGGE=; b=IzqRxugTccNhsNjkzezzddKHADYKTvsGZVQWR/eTq9mqnFyFxcg3rEOdU4lr+SM3aD SLJ3NM/dEf3SjifW1PaYrq0IJX/heMyiACBlypOfLG/qfVFnDYzI6BWwY1G9cnsxzSMD zdqS8mCD6mu3mOKJ9LRmsGPMr53L7VeNKyz8Cc/a2GIftMwJpO3ZviZx6ZUcWw7dt/YG c/txvJAkDLkUMKsDuCkg4S7yMwm50ZouRrhaI26SuQ4PjwOpkCcsxd5QxOwQ0PaNKjdy SsZSOa090Wa6gfn72GD0E9pkuwDzR6zv3trQF4BbUR/B1W8nPe2Bd/6h4fSrbZkg6J06 Th8A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fe17-20020a1709072a5100b008b14da8ab72si12346324ejc.193.2023.02.20.00.34.41; Mon, 20 Feb 2023 00:35:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231137AbjBTI3p (ORCPT <rfc822;kautuk.consul.80@gmail.com> + 99 others); Mon, 20 Feb 2023 03:29:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230223AbjBTI3o (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 20 Feb 2023 03:29:44 -0500 Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4EF7BBBB3; Mon, 20 Feb 2023 00:29:42 -0800 (PST) Received: from mail02.huawei.com (unknown [172.30.67.153]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4PKwZT1nwjz4f41V5; Mon, 20 Feb 2023 16:29:37 +0800 (CST) Received: from localhost.localdomain (unknown [10.67.175.61]) by APP1 (Coremail) with SMTP id cCh0CgD3YSxyL_NjSWbkDg--.11659S2; Mon, 20 Feb 2023 16:29:39 +0800 (CST) From: Pu Lehui <pulehui@huaweicloud.com> To: bpf@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Cc: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= <bjorn@kernel.org>, Alexei Starovoitov <ast@kernel.org>, Daniel Borkmann <daniel@iogearbox.net>, Andrii Nakryiko <andrii@kernel.org>, Martin KaFai Lau <martin.lau@linux.dev>, Song Liu <song@kernel.org>, Yonghong Song <yhs@fb.com>, John Fastabend <john.fastabend@gmail.com>, KP Singh <kpsingh@kernel.org>, Stanislav Fomichev <sdf@google.com>, Hao Luo <haoluo@google.com>, Jiri Olsa <jolsa@kernel.org>, Pu Lehui <pulehui@huawei.com>, Pu Lehui <pulehui@huaweicloud.com> Subject: [PATCH bpf-next v2] riscv, bpf: Add kfunc support for RV64 Date: Mon, 20 Feb 2023 16:32:03 +0800 Message-Id: <20230220083203.2988238-1-pulehui@huaweicloud.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-CM-TRANSID: cCh0CgD3YSxyL_NjSWbkDg--.11659S2 X-Coremail-Antispam: 1UD129KBjvdXoWrury3GFyxXrW7try3GFWUtwb_yoW3uFg_ur 1xJa4Iq3y5Ja18JF4DuF4fArykCws3GFykXw1xZryjy3ZxWFn8ta4kKryjqry7Zr1YyrW7 Xrn5Ja9aqw42qjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbxkFF20E14v26ryj6rWUM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8w A2z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j 6F4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oV Cq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0 I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r 4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628v n2kIc2xKxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F4 0E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_GFv_Wryl IxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxV AFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6rW3Jr0E3s1lIxAIcVC2z280aVAFwI0_ Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7VUb QVy7UUUUU== X-CM-SenderInfo: psxovxtxl6x35dzhxuhorxvhhfrp/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758333436464237401?= X-GMAIL-MSGID: =?utf-8?q?1758338331039593055?= |
Series |
[bpf-next,v2] riscv, bpf: Add kfunc support for RV64
|
|
Commit Message
Pu Lehui
Feb. 20, 2023, 8:32 a.m. UTC
From: Pu Lehui <pulehui@huawei.com> As another important missing piece of RV64 JIT, kfunc allow bpf programs call kernel functions. For now, RV64 is sufficient to enable it. Suggested-by: Björn Töpel <bjorn@rivosinc.com> Signed-off-by: Pu Lehui <pulehui@huawei.com> --- v2: - Fix email address mismatch. arch/riscv/net/bpf_jit_comp64.c | 5 +++++ 1 file changed, 5 insertions(+)
Comments
Pu Lehui <pulehui@huaweicloud.com> writes: > From: Pu Lehui <pulehui@huawei.com> > > As another important missing piece of RV64 JIT, kfunc allow bpf programs > call kernel functions. For now, RV64 is sufficient to enable it. Thanks Lehui! Maybe we can reword/massage the commit message a bit? What do you think about something like: "Now that the BPF trampoline is supported by RISC-V, it is possible to use BPF programs with kfunc calls. Note that the trampoline functionality is only supported by RV64. Add bpf_jit_supports_kfunc_call() to the 64-bit JIT." Björn
On 2023/2/20 22:34, Björn Töpel wrote: > Pu Lehui <pulehui@huaweicloud.com> writes: > >> From: Pu Lehui <pulehui@huawei.com> >> >> As another important missing piece of RV64 JIT, kfunc allow bpf programs >> call kernel functions. For now, RV64 is sufficient to enable it. > > Thanks Lehui! > > Maybe we can reword/massage the commit message a bit? What do you think > about something like: > > "Now that the BPF trampoline is supported by RISC-V, it is possible to > use BPF programs with kfunc calls. > kfunc and bpf trampoline are functionally independent. kfunc [1], like bpf helper functions, allows bpf programs to call exported kernel functions, while bpf trampoline provides a more efficient way than kprobe to act as a mediator between kernel functions and bpf programs, and between bpf programs. In fact, it was already supported before the bpf trampoline implementation, I just turned it on. As for RV32 kfunc, it needs to do some registers parsing. [1] https://lore.kernel.org/bpf/20210325015124.1543397-1-kafai@fb.com/ > Note that the trampoline functionality is only supported by RV64. > > Add bpf_jit_supports_kfunc_call() to the 64-bit JIT." > > > Björn
Pu Lehui <pulehui@huaweicloud.com> writes: > On 2023/2/20 22:34, Björn Töpel wrote: >> Pu Lehui <pulehui@huaweicloud.com> writes: >> >>> From: Pu Lehui <pulehui@huawei.com> >>> >>> As another important missing piece of RV64 JIT, kfunc allow bpf programs >>> call kernel functions. For now, RV64 is sufficient to enable it. >> >> Thanks Lehui! >> >> Maybe we can reword/massage the commit message a bit? What do you think >> about something like: >> >> "Now that the BPF trampoline is supported by RISC-V, it is possible to >> use BPF programs with kfunc calls. >> > > kfunc and bpf trampoline are functionally independent. kfunc [1], like > bpf helper functions, allows bpf programs to call exported kernel > functions, while bpf trampoline provides a more efficient way than > kprobe to act as a mediator between kernel functions and bpf programs, > and between bpf programs. > > In fact, it was already supported before the bpf trampoline > implementation, I just turned it on. Good point. I guess my (incorrect) kfunc mental model was that struct_ops and kfunc were tightly coupled. (Then again, w/o struct_ops working kfunc is a bit half-working in my view.) Fair enough. I'm still a bit confused about the commit message, but happy with the patch. Acked-by: Björn Töpel <bjorn@rivosinc.com>
diff --git a/arch/riscv/net/bpf_jit_comp64.c b/arch/riscv/net/bpf_jit_comp64.c index f5a668736c79..a9270366dc57 100644 --- a/arch/riscv/net/bpf_jit_comp64.c +++ b/arch/riscv/net/bpf_jit_comp64.c @@ -1751,3 +1751,8 @@ void bpf_jit_build_epilogue(struct rv_jit_context *ctx) { __build_epilogue(false, ctx); } + +bool bpf_jit_supports_kfunc_call(void) +{ + return true; +}