From patchwork Wed Feb 15 13:52:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pu Lehui X-Patchwork-Id: 13141700 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1D2ECC6379F for ; Wed, 15 Feb 2023 13:50:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=DhkOO77Gw9NGvYqa5CfKdjp0eZYnC9IRQgjLxYCkkLY=; b=1IvYi2FM/KkXtc kl2rQWZ4ACsoCct20CIS2AbcHY+X0VAEImG2T98ehKb/9o4T+EL/rrCoZpwY24UShnQgv5MxjXuWU 5eNM6DF155PI99jxmlvtBPlOQBrYILYssh2HrDEvuQ+Mf7VggtzwFmreOE1bRWxShGVaws5sbUvph o0kEHbEHzdcIl8/0g/aQR4k/JyQpCAEeojcfNGgvKPaLpYBZVJu5AdadENSLhMBLWIzfNg2tO37IV RcwIMd0x+7INEcOe8e1KkbNuJo8Mpc9zBeq3MS34bhZ+1tyJzyEf475rBkQ/HPwwEuRyrl4NBgjPc OkYPlliTjI1CHJIRWk8w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pSIAp-0066jb-CJ; Wed, 15 Feb 2023 13:50:15 +0000 Received: from [45.249.212.51] (helo=dggsgout11.his.huawei.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pSIAi-0066ZM-5l for linux-riscv@lists.infradead.org; Wed, 15 Feb 2023 13:50:09 +0000 Received: from mail02.huawei.com (unknown [172.30.67.153]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4PGzwC0ZVZz4f3jqq for ; Wed, 15 Feb 2023 21:49:47 +0800 (CST) Received: from localhost.localdomain (unknown [10.67.175.61]) by APP1 (Coremail) with SMTP id cCh0CgDnUSz64uxjC3LEDQ--.36740S2; Wed, 15 Feb 2023 21:49:47 +0800 (CST) From: Pu Lehui To: bpf@vger.kernel.org, linux-riscv@lists.infradead.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Palmer Dabbelt , Conor Dooley , Guo Ren , Luke Nelson , Xi Wang , Pu Lehui , Pu Lehui Subject: [PATCH bpf-next v1 0/4] Support bpf trampoline for RV64 Date: Wed, 15 Feb 2023 21:52:01 +0800 Message-Id: <20230215135205.1411105-1-pulehui@huaweicloud.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CM-TRANSID: cCh0CgDnUSz64uxjC3LEDQ--.36740S2 X-Coremail-Antispam: 1UD129KBjvJXoW7tw17GrWfJw4xAr4fGF13twb_yoW8Wryfpa yjkry3AryDu3W3JwnIya18ZryrKayvgw13Gw13t3yfJa1Yqry7ZrnYgayYyw15AF9xur1j yrn0qryj9FyDAa7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvY14x267AKxVW5JVWrJwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26w1j6s0DM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4U JVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Gc CE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E 2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJV W8JwACjcxG0xvY0x0EwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I1lFIxGxcIEc7CjxVA2 Y2ka0xkIwI1l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4 xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r4a6rW5 MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I 0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWrZr1j6s0DMIIF0xvEx4A2jsIE14v2 6r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0J UQvtAUUUUU= X-CM-SenderInfo: psxovxtxl6x35dzhxuhorxvhhfrp/ X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230215_055008_590751_83163B99 X-CRM114-Status: UNSURE ( 7.46 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org BPF trampoline is the critical infrastructure of the bpf subsystem, acting as a mediator between kernel functions and BPF programs. Numerous important features, such as using ebpf program for zero overhead kernel introspection, rely on this key component. We can't wait to support bpf trampoline on RV64. Since RV64 does not support ftrace direct call yet, the current RV64 bpf trampoline is only used in bpf context. As most of riscv cpu support unaligned memory accesses, we temporarily use patch [1] to facilitate testing. The test results are as follow, and test_verifier with no new failure ceses. - fexit_bpf2bpf:OK - dummy_st_ops:OK - xdp_bpf2bpf:OK [1] https://lore.kernel.org/linux-riscv/20210916130855.4054926-2-chenhuang5@huawei.com/ v1: - Remove the logic of bpf_arch_text_poke supported for kernel functions. (Kuohai and Björn) - Extend patch_text for multiple instructions. (Björn) - Fix OOB issue when image too big. (Björn) RFC: https://lore.kernel.org/bpf/20230103090756.1993820-1-pulehui@huaweicloud.com/ Pu Lehui (4): riscv: Extend patch_text for multiple instructions riscv, bpf: Factor out emit_call for kernel and bpf context riscv, bpf: Add bpf_arch_text_poke support for RV64 riscv, bpf: Add bpf trampoline support for RV64 arch/riscv/include/asm/patch.h | 2 +- arch/riscv/kernel/patch.c | 19 +- arch/riscv/kernel/probes/kprobes.c | 15 +- arch/riscv/net/bpf_jit.h | 5 + arch/riscv/net/bpf_jit_comp64.c | 437 +++++++++++++++++++++++++++-- 5 files changed, 444 insertions(+), 34 deletions(-) Tested-by: Björn Töpel Acked-by: Björn Töpel