From patchwork Tue Sep 13 06:31:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xu Kuohai X-Patchwork-Id: 12974459 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 DB00BC54EE9 for ; Tue, 13 Sep 2022 06:28:25 +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=c8ScXbXrQJHLFudIvdDt0w9tSuUUd4CVO9SggbiFcx8=; b=SY7LHnENJh9ifE 3SQTr0tqt97tr+1GOGSeffChFs5iHXPqMCGWEOkeotzDtRVoJEYeGV+NiPR48lKpoFaTUNzyMRIF9 iQ2t3kdfbgSd30Hd38VvOHaQtzGgOmlKsNhIzkeMKnqtIRzb/iihoJVZOgUa+Brx4/4+h6E8NWwb5 W3RYWx3xS3sSRr9CBlahFoPJaDOgFBEsIvkCUZsly3HlulArvhlNYkgSsx8dxRTPzh2gSbOUsJ4xu kBw0mFV14gljFk/FZM7IbE/Va2eRQrmjBgeAZYjMAuSL4RexkB2AJyVEGfhY3DgUyfEbj0NIx2ws6 +Yx1TRK0IiGNv/Wm6aZQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oXzNr-002zO2-Im; Tue, 13 Sep 2022 06:27:00 +0000 Received: from dggsgout12.his.huawei.com ([45.249.212.56]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oXzLO-002wN2-Ky for linux-arm-kernel@lists.infradead.org; Tue, 13 Sep 2022 06:24:29 +0000 Received: from mail02.huawei.com (unknown [172.30.67.169]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4MRYKM4BkYz6S2cZ for ; Tue, 13 Sep 2022 14:22:15 +0800 (CST) Received: from k01.huawei.com (unknown [10.67.174.197]) by APP4 (Coremail) with SMTP id gCh0CgCHSYkDIiBjT3sKAw--.4735S2; Tue, 13 Sep 2022 14:24:04 +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 0/4] Add ftrace direct call for arm64 Date: Tue, 13 Sep 2022 02:31:42 -0400 Message-Id: <20220913063146.74750-1-xukuohai@huaweicloud.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-CM-TRANSID: gCh0CgCHSYkDIiBjT3sKAw--.4735S2 X-Coremail-Antispam: 1UD129KBjvJXoW7uFyDGF1fXrW8uw4fWrykKrg_yoW8GrWfpa 9rurnxGr4UCFsakFyfu3Z3ury3Jw4kJry5Ja47A34Fkrn09FyUWrnayrnrCw4UJr9rJ3y2 qFyYvrWrKF4UXa7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUk2b4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4 vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7Cj xVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x 0267AKxVW0oVCq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG 6I80ewAv7VC0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFV Cjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JM4IIrI8v6xkF7I0E8cxan2IY04v7MxAIw28I cxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2 IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVW8ZVWrXwCIc40Y0x0EwIxGrwCI 42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwCI42 IY6xAIw20EY4v20xvaj40_WFyUJVCq3wCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E 87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjxUFYFCUUUUU X-CM-SenderInfo: 50xn30hkdlqx5xdzvxpfor3voofrz/ X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220912_232427_417950_2D955EDF X-CRM114-Status: GOOD ( 10.17 ) 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 From: Xu Kuohai 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/ 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 + kernel/trace/Kconfig | 7 +- kernel/trace/ftrace.c | 10 +- kernel/trace/trace_selftest.c | 2 + 13 files changed, 295 insertions(+), 29 deletions(-)