From patchwork Tue Sep 13 16:27:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xu Kuohai X-Patchwork-Id: 12974963 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 9F370C54EE9 for ; Tue, 13 Sep 2022 16:12:26 +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=ojZ/lmIClY8otTH6W0VdzaPPFHIzH80J3oWu1ktQ3XY=; b=VodmgDGUZCJaTG 861LU4UH/mT1K6niezVpH4X/N869CaMZYo3POO9BlVgXdWkPXREkRfkByMH3yJfbrGcvaG9TGRI24 n38dcGdUuLO/OOzrt/3Nyv5JEn2G5jUrXcAPWJhikbcOI1yeEZI5JwwGMxiKA6sT3qlKRqbORLos+ catLjm2Xr34UXUVcwjT6ao52sH79NOKLK62A799gaX0L5JCjy66gWYFWQzNxRJdH423YYRYWZoEmu B8sECcPXOOC8Dud6Jk6wiEqiXHJOZQ9aIQt8Gz52rXY74dOjFfyh8KD+Juh2yrY5DmhI1SXDuFr1V N+Ce2O0mPgeRPpyYcLuA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oY8VH-00D4vS-Fa; Tue, 13 Sep 2022 16:11:15 +0000 Received: from dggsgout11.his.huawei.com ([45.249.212.51]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oY8Ue-00D4MD-6b for linux-arm-kernel@lists.infradead.org; Tue, 13 Sep 2022 16:10:41 +0000 Received: from mail02.huawei.com (unknown [172.30.67.153]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4MRpKv2QVxzKFt0 for ; Wed, 14 Sep 2022 00:08:35 +0800 (CST) Received: from k01.huawei.com (unknown [10.67.174.197]) by APP4 (Coremail) with SMTP id gCh0CgBHB4dxqyBjcEAeAw--.28569S2; Wed, 14 Sep 2022 00:10:26 +0800 (CST) From: Xu Kuohai To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org Cc: Mark Rutland , Florent Revest , Catalin Marinas , Will Deacon , Jean-Philippe Brucker , Steven Rostedt , Ingo Molnar , Oleg Nesterov , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Zi Shen Lim , Pasha Tatashin , Ard Biesheuvel , Marc Zyngier , Guo Ren , Masami Hiramatsu Subject: [PATCH bpf-next v2 0/4] Add ftrace direct call for arm64 Date: Tue, 13 Sep 2022 12:27:28 -0400 Message-Id: <20220913162732.163631-1-xukuohai@huaweicloud.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-CM-TRANSID: gCh0CgBHB4dxqyBjcEAeAw--.28569S2 X-Coremail-Antispam: 1UD129KBjvJXoWxJrW7JFWkKryUGFW8tryfXrb_yoW8XFy7pa 9rurn8Gr4UCFsakFyfu3Z7ury3Jw4kJry5Xa47A34Fkrn09FyUGr1SvrnxGw47JrZrJ3y2 gFyY9rWYgF1UXa7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUkSb4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4 vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7Cj xVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIE14v26F4j6r4UJwA2z4x0Y4vEx4A2jsIEc7 CjxVAFwI0_Gr1j6F4UJwAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAq x4xG6I80ewAv7VC0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6x CaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JM4IIrI8v6xkF7I0E8cxan2IY04v7MxAI w28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr 4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVW8ZVWrXwCIc40Y0x0EwIxG rwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8JVWxJw CI42IY6xAIw20EY4v20xvaj40_WFyUJVCq3wCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY 6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjxUFYFCUUUUU X-CM-SenderInfo: 50xn30hkdlqx5xdzvxpfor3voofrz/ X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220913_091037_269098_DE500447 X-CRM114-Status: GOOD ( 10.16 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This series adds ftrace direct call for arm64, which is required to attach bpf trampoline to fentry. Although there is no agreement on how to support ftrace direct call on arm64, no patch has been posted except the one I posted in [1], so this series continues the work of [1] with the addition of long jump support. Now ftrace direct call works regardless of the distance between the callsite and custom trampoline. [1] https://lore.kernel.org/bpf/20220518131638.3401509-2-xukuohai@huawei.com/ v2: - Fix compile and runtime errors caused by ftrace_rec_arch_init v1: https://lore.kernel.org/bpf/20220913063146.74750-1-xukuohai@huaweicloud.com/ Xu Kuohai (4): ftrace: Allow users to disable ftrace direct call arm64: ftrace: Support long jump for ftrace direct call arm64: ftrace: Add ftrace direct call support ftrace: Fix dead loop caused by direct call in ftrace selftest arch/arm64/Kconfig | 2 + arch/arm64/Makefile | 4 + arch/arm64/include/asm/ftrace.h | 35 ++++-- arch/arm64/include/asm/patching.h | 2 + arch/arm64/include/asm/ptrace.h | 6 +- arch/arm64/kernel/asm-offsets.c | 1 + arch/arm64/kernel/entry-ftrace.S | 39 ++++-- arch/arm64/kernel/ftrace.c | 198 ++++++++++++++++++++++++++++-- arch/arm64/kernel/patching.c | 14 +++ arch/arm64/net/bpf_jit_comp.c | 4 + include/linux/ftrace.h | 2 + kernel/trace/Kconfig | 7 +- kernel/trace/ftrace.c | 9 +- kernel/trace/trace_selftest.c | 2 + 14 files changed, 296 insertions(+), 29 deletions(-)