From patchwork Thu Apr 27 14:06:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florent Revest X-Patchwork-Id: 88276 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp304566vqo; Thu, 27 Apr 2023 07:22:45 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5TPrQWiqH4L1IMy4NowXjScmCsePHyW/uVWPPDvD18zhLVmaAvJma6/F/i2NndEMT9CZY9 X-Received: by 2002:a17:902:ea08:b0:1a9:6604:2b1b with SMTP id s8-20020a170902ea0800b001a966042b1bmr2872512plg.20.1682605364834; Thu, 27 Apr 2023 07:22:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682605364; cv=none; d=google.com; s=arc-20160816; b=H6ud1VMbeHbT9blwsvDLRREXA40XwDIPCa9HAT0QRSQIMGGs6jYy8Pz1kxJhR+JkCO MCxAEOsv5iepUbTKwQH4LihhepWAonzI5ZWCxtC4bNq4i+a+q5wgVmNbRdBu0uo/jPUL KRaNtTM9Z5uqkeUFw6GmH+vzvjBSy9Np/P6YyaVr7T5dEXhATKkw4rn46f1nlYBc35Hd OYmlRQJEiftmuW5fAR3PSy9HP0OMckxr4f224BMZANtiZBxiAMxsZH1MARMEdKsOPBxp Shib4+VceWoU4edg+P7CYI4ogKrEKbRzdMV5hJtmiPWcbSjVRRYBE/mlJUl90AAtdo+8 V5FQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6ljaeRoUOTvHIOJot1r8A0oYKDFB5aJ471vIxa1FpUA=; b=TWzXGqPeiZEw5Vas4IEvPiIgf32n5pkWckrtrmifXgzBTJfsI/O4KylupAwKga30ac IvYrIZM8WkPqcGWgHICRwRhPKYSzu86QcuJu8motAJACbdGFDWecHHu/29a3AXnAC/Kv pH73T3MwIWvgw65AYJZAYSuipZTu/3AGrqAfiBzJeODvPfBoVgFKQWJArYb/Yh5w3Wgq P5wDAqJ22AS86m9byTUkhxixGfv9w8Bdum+OmwfWlFnI39T/bPXmBegRNhAoCLpuK42w 5CTeGswp9orkL5/JkNsI/k/maUUimZndgW/kQ7ckBWwVPxv9ZU1HjtZEoXx8JlwyxcYu blig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=n2vmdIIc; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l16-20020a170902f69000b001a1d78af685si20542095plg.466.2023.04.27.07.22.28; Thu, 27 Apr 2023 07:22:44 -0700 (PDT) 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; dkim=pass header.i=@chromium.org header.s=google header.b=n2vmdIIc; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243771AbjD0OH1 (ORCPT + 99 others); Thu, 27 Apr 2023 10:07:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243731AbjD0OHZ (ORCPT ); Thu, 27 Apr 2023 10:07:25 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E06BC4491 for ; Thu, 27 Apr 2023 07:07:16 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-3f1738d0d4cso56049135e9.1 for ; Thu, 27 Apr 2023 07:07:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1682604435; x=1685196435; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6ljaeRoUOTvHIOJot1r8A0oYKDFB5aJ471vIxa1FpUA=; b=n2vmdIIcATMu0p/U3Y9qlWt92NaIMfpiymvMTwLsveBJ6eMt1rIB+zLqcdVH3hDZ/M xGhPa6SClrcyLbDeaoPAFNn1+84tAUrDY1bYDCCON3INglGx9mdkH2IPSN+k2Dx9h1dG xwSyV2P5U9DY3WcxB2z6EnPeAhaWNWHKoQmQo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682604435; x=1685196435; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6ljaeRoUOTvHIOJot1r8A0oYKDFB5aJ471vIxa1FpUA=; b=klU1PdkLyQcGlVuXkP6YjR0bDrVaa5y+bKtf2wmO77Vcj304lpp0+byNIUIhCZJJeF 0S48b67F/NBYKgJrKezn5ag0xIsynZ39WL8HXJlSdVCh5PN6X5n3JZD7Sdys5M4KQ+YW BVDGpNN4oYQRWz3YFt26ELdTmNhuE+Wxim9EJURJrSqkzi6FUBUGdLvnK5L4kDef+3YX Yot0Fv+oMoCRrjg/5DGt/ntBTTMqSY6BVLFFYfirGacPUzyLnNHe/7D+oKtMoFWIni9Z y7NB68BndJB9udTMkSvyDi77NBYTNt0wrJJt02t9AphLgit5u1AuVT85G1ENk3znPah7 v4Rg== X-Gm-Message-State: AC+VfDy93Mpp9q2mW0Je36jRQgbe0SJrs75y07jJa1AjUDaFTKRohoQL XiMDKZY8iHzniIk3DCwStevZPg== X-Received: by 2002:a05:600c:2046:b0:3f1:9134:f28b with SMTP id p6-20020a05600c204600b003f19134f28bmr1665373wmg.19.1682604435148; Thu, 27 Apr 2023 07:07:15 -0700 (PDT) Received: from revest.zrh.corp.google.com ([2a00:79e0:9d:6:a66d:4f2c:7ce5:e8ea]) by smtp.gmail.com with ESMTPSA id c21-20020a7bc855000000b003f17300c7dcsm21285075wml.48.2023.04.27.07.07.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Apr 2023 07:07:14 -0700 (PDT) From: Florent Revest To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Cc: rostedt@goodmis.org, mhiramat@kernel.org, mark.rutland@arm.com, kpsingh@kernel.org, xukuohai@huaweicloud.com, Florent Revest , stable@vger.kernel.org Subject: [PATCH 1/2] samples: ftrace: Save required argument registers in sample trampolines Date: Thu, 27 Apr 2023 16:06:59 +0200 Message-ID: <20230427140700.625241-2-revest@chromium.org> X-Mailer: git-send-email 2.40.1.495.gc816e09b53d-goog In-Reply-To: <20230427140700.625241-1-revest@chromium.org> References: <20230427140700.625241-1-revest@chromium.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764339603426284541?= X-GMAIL-MSGID: =?utf-8?q?1764339603426284541?= The ftrace-direct-too sample traces the handle_mm_fault function whose signature changed since the introduction of the sample. Since: commit bce617edecad ("mm: do page fault accounting in handle_mm_fault") handle_mm_fault now has 4 arguments. Therefore, the sample trampoline should save 4 argument registers. s390 saves all argument registers already so it does not need a change but x86_64 needs an extra push and pop. This also evolves the signature of the tracing function to make it mirror the signature of the traced function. Cc: stable@vger.kernel.org Fixes: bce617edecad ("mm: do page fault accounting in handle_mm_fault") Reviewed-by: Steven Rostedt (Google) Reviewed-by: Mark Rutland Signed-off-by: Florent Revest --- samples/ftrace/ftrace-direct-too.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/samples/ftrace/ftrace-direct-too.c b/samples/ftrace/ftrace-direct-too.c index f28e7b99840f..71ed4ee8cb4a 100644 --- a/samples/ftrace/ftrace-direct-too.c +++ b/samples/ftrace/ftrace-direct-too.c @@ -5,14 +5,14 @@ #include #include -extern void my_direct_func(struct vm_area_struct *vma, - unsigned long address, unsigned int flags); +extern void my_direct_func(struct vm_area_struct *vma, unsigned long address, + unsigned int flags, struct pt_regs *regs); -void my_direct_func(struct vm_area_struct *vma, - unsigned long address, unsigned int flags) +void my_direct_func(struct vm_area_struct *vma, unsigned long address, + unsigned int flags, struct pt_regs *regs) { - trace_printk("handle mm fault vma=%p address=%lx flags=%x\n", - vma, address, flags); + trace_printk("handle mm fault vma=%p address=%lx flags=%x regs=%p\n", + vma, address, flags, regs); } extern void my_tramp(void *); @@ -34,7 +34,9 @@ asm ( " pushq %rdi\n" " pushq %rsi\n" " pushq %rdx\n" +" pushq %rcx\n" " call my_direct_func\n" +" popq %rcx\n" " popq %rdx\n" " popq %rsi\n" " popq %rdi\n" From patchwork Thu Apr 27 14:07:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florent Revest X-Patchwork-Id: 88274 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp296140vqo; Thu, 27 Apr 2023 07:10:47 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7yWPDmbgWZSkroAAAxT2lCqR2vejOQVbtq6g1k26q5eqm00fFBjIQDOwDH0TfTLqgg7oBA X-Received: by 2002:a17:90b:17c3:b0:247:bab1:d901 with SMTP id me3-20020a17090b17c300b00247bab1d901mr1895763pjb.17.1682604647351; Thu, 27 Apr 2023 07:10:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682604647; cv=none; d=google.com; s=arc-20160816; b=PUMwOkrXZ7ASherVq2DL1ZkuuqDCgkuMR5CRgzK/G3IYggjSnIROZIFtICQpwkYj++ 5kQxkqLiWk5SCnO1ymr9Y73vFj1vIw8ikDuGXdTLwSXnyKnOT/qidQ82kOsNJKvcUqlR 2ELRYVc7AUeW9ki3HJNQGgPpUyWXHcjH3HzaFOO0FGRiDbzgJ+Iz2znTn4Bz+6JIaCip PujO6wtwOmN82yKEtYdnwj8Ke2uLNduihmltC7RSO3TobKRbAtEUoQxbH/KzcN4hI5YA fTLdP1dUAPeoUmhEB5x7jYUdd2MMw0EAWuLNMVz+LA7s8mylUoyAp7YSVm8iedHOFEuP a96Q== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=EVGI/9TRxcLl2jjt/VjqKdsC9yR4uWTAAN6xoAYLhYc=; b=NXMyfLWuyEtRifkUIVBSuLj171QZSUxiEHSrk3O+hIMYlEe3l7O0jladV4oAml62J4 vRNFQsTsOYwvBM6hiGsj0TvX/DPGbd4+83ppfzq9TTNquwZHZDY5g5n487XRV/+2CssM NQoJuSJfDK1VlTOCqoYTbuWi0YYC3oi6a7Q1kf4MFhYurRfR0hdQBaBfB5UmXuecwwLh azVYiRlmQsSFw4vgs1eyv0AW5pa6bN4aO2/FIWsaPNXII6hW7QCz0yK5tck3nIESNzvQ VELmIz0fJlaNUi8SlSxpfvxyukNsP9OFQidqHikuN+v9wE1Z6E2ecgJWFx0LNQDHyiFq /laQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=mrmISWdR; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lw6-20020a17090b180600b002402e91b437si20339849pjb.147.2023.04.27.07.10.33; Thu, 27 Apr 2023 07:10:47 -0700 (PDT) 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; dkim=pass header.i=@chromium.org header.s=google header.b=mrmISWdR; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243777AbjD0OHj (ORCPT + 99 others); Thu, 27 Apr 2023 10:07:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243781AbjD0OH3 (ORCPT ); Thu, 27 Apr 2023 10:07:29 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BC05449D for ; Thu, 27 Apr 2023 07:07:18 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-3f18dacd392so53487025e9.0 for ; Thu, 27 Apr 2023 07:07:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1682604436; x=1685196436; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=EVGI/9TRxcLl2jjt/VjqKdsC9yR4uWTAAN6xoAYLhYc=; b=mrmISWdRcfSKZ/TELjixBZkldgX9bvmQALdjTOTRCke4xcU+66ukcYg7lUESr0xOJD D8VtVkHLr9erkJ0NQxaVc11J7IeMdSEisAcV4/FH6/EaiP8a1Cnp1P4sS+PQF9AsoNaB /lYJaiMPSreHA8HsU1+U0oGAw320zbOTs1BJU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682604436; x=1685196436; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EVGI/9TRxcLl2jjt/VjqKdsC9yR4uWTAAN6xoAYLhYc=; b=IOZ1pZAcAyixa1kZRgiQ4BVDyy2ZjA+vJLTUxJIt4QgqKOcTUZgXAFw4R5bnYi2eVN LQMZvTZj/5YFOtyfiP/dWaMWSVo5wsVXmnYQA2dhbKyc+EkcrSVRBP99BmdTEuYo7Ibn YcMfsmyhBGgpsXaPMMnH7ZCQkRGicwu8P2fySv6hJLNj4h1YzUVeLql0F9WrEZPo/oGY IVQhN6If+BVhoW6MHjdtmKg1XNYhE35cfXlsofb6XIBcY+iGXPTY1+lB+hquAdK6M2Ay As2C/N56NooOmAKItDzaRYzOqg1W+6cNFhmOnXvZLqXKhbGK81d5oiSV11uG3d1sm4zk IB7Q== X-Gm-Message-State: AC+VfDy9YvvQoynDBUy9+KFn0DZc8CXQXJ0yc5Hg+d3bAhi3bFzUoZ83 F7Y4g57UxDXz16M2nN2waOG6Tw== X-Received: by 2002:a05:600c:ac8:b0:3f1:819d:d050 with SMTP id c8-20020a05600c0ac800b003f1819dd050mr1405441wmr.37.1682604436589; Thu, 27 Apr 2023 07:07:16 -0700 (PDT) Received: from revest.zrh.corp.google.com ([2a00:79e0:9d:6:a66d:4f2c:7ce5:e8ea]) by smtp.gmail.com with ESMTPSA id c21-20020a7bc855000000b003f17300c7dcsm21285075wml.48.2023.04.27.07.07.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Apr 2023 07:07:16 -0700 (PDT) From: Florent Revest To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Cc: rostedt@goodmis.org, mhiramat@kernel.org, mark.rutland@arm.com, kpsingh@kernel.org, xukuohai@huaweicloud.com, Florent Revest Subject: [PATCH 2/2] arm64: ftrace: Add direct call trampoline samples support Date: Thu, 27 Apr 2023 16:07:00 +0200 Message-ID: <20230427140700.625241-3-revest@chromium.org> X-Mailer: git-send-email 2.40.1.495.gc816e09b53d-goog In-Reply-To: <20230427140700.625241-1-revest@chromium.org> References: <20230427140700.625241-1-revest@chromium.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764338850755996648?= X-GMAIL-MSGID: =?utf-8?q?1764338850755996648?= The ftrace samples need per-architecture trampoline implementations to save and restore argument registers around the calls to my_direct_func* and to restore polluted registers (eg: x30). These samples also include which, on arm64, is not necessary and redefines previously defined macros (resulting in warnings) so these includes are guarded by !CONFIG_ARM64. Reviewed-by: Mark Rutland Tested-by: Mark Rutland Signed-off-by: Florent Revest --- arch/arm64/Kconfig | 2 ++ samples/ftrace/ftrace-direct-modify.c | 34 ++++++++++++++++++ samples/ftrace/ftrace-direct-multi-modify.c | 40 +++++++++++++++++++++ samples/ftrace/ftrace-direct-multi.c | 24 +++++++++++++ samples/ftrace/ftrace-direct-too.c | 26 ++++++++++++++ samples/ftrace/ftrace-direct.c | 24 +++++++++++++ 6 files changed, 150 insertions(+) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 3f5bf55050e8..e98d6b7845c4 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -195,6 +195,8 @@ config ARM64 !CC_OPTIMIZE_FOR_SIZE) select FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY \ if DYNAMIC_FTRACE_WITH_ARGS + select HAVE_SAMPLE_FTRACE_DIRECT + select HAVE_SAMPLE_FTRACE_DIRECT_MULTI select HAVE_EFFICIENT_UNALIGNED_ACCESS select HAVE_FAST_GUP select HAVE_FTRACE_MCOUNT_RECORD diff --git a/samples/ftrace/ftrace-direct-modify.c b/samples/ftrace/ftrace-direct-modify.c index 25fba66f61c0..98d1b7385f08 100644 --- a/samples/ftrace/ftrace-direct-modify.c +++ b/samples/ftrace/ftrace-direct-modify.c @@ -2,7 +2,9 @@ #include #include #include +#ifndef CONFIG_ARM64 #include +#endif extern void my_direct_func1(void); extern void my_direct_func2(void); @@ -96,6 +98,38 @@ asm ( #endif /* CONFIG_S390 */ +#ifdef CONFIG_ARM64 + +asm ( +" .pushsection .text, \"ax\", @progbits\n" +" .type my_tramp1, @function\n" +" .globl my_tramp1\n" +" my_tramp1:" +" bti c\n" +" sub sp, sp, #16\n" +" stp x9, x30, [sp]\n" +" bl my_direct_func1\n" +" ldp x30, x9, [sp]\n" +" add sp, sp, #16\n" +" ret x9\n" +" .size my_tramp1, .-my_tramp1\n" + +" .type my_tramp2, @function\n" +" .globl my_tramp2\n" +" my_tramp2:" +" bti c\n" +" sub sp, sp, #16\n" +" stp x9, x30, [sp]\n" +" bl my_direct_func2\n" +" ldp x30, x9, [sp]\n" +" add sp, sp, #16\n" +" ret x9\n" +" .size my_tramp2, .-my_tramp2\n" +" .popsection\n" +); + +#endif /* CONFIG_ARM64 */ + static struct ftrace_ops direct; static unsigned long my_tramp = (unsigned long)my_tramp1; diff --git a/samples/ftrace/ftrace-direct-multi-modify.c b/samples/ftrace/ftrace-direct-multi-modify.c index f72623899602..26956c8fc513 100644 --- a/samples/ftrace/ftrace-direct-multi-modify.c +++ b/samples/ftrace/ftrace-direct-multi-modify.c @@ -2,7 +2,9 @@ #include #include #include +#ifndef CONFIG_ARM64 #include +#endif extern void my_direct_func1(unsigned long ip); extern void my_direct_func2(unsigned long ip); @@ -103,6 +105,44 @@ asm ( #endif /* CONFIG_S390 */ +#ifdef CONFIG_ARM64 + +asm ( +" .pushsection .text, \"ax\", @progbits\n" +" .type my_tramp1, @function\n" +" .globl my_tramp1\n" +" my_tramp1:" +" bti c\n" +" sub sp, sp, #32\n" +" stp x9, x30, [sp]\n" +" str x0, [sp, #16]\n" +" mov x0, x30\n" +" bl my_direct_func1\n" +" ldp x30, x9, [sp]\n" +" ldr x0, [sp, #16]\n" +" add sp, sp, #32\n" +" ret x9\n" +" .size my_tramp1, .-my_tramp1\n" + +" .type my_tramp2, @function\n" +" .globl my_tramp2\n" +" my_tramp2:" +" bti c\n" +" sub sp, sp, #32\n" +" stp x9, x30, [sp]\n" +" str x0, [sp, #16]\n" +" mov x0, x30\n" +" bl my_direct_func2\n" +" ldp x30, x9, [sp]\n" +" ldr x0, [sp, #16]\n" +" add sp, sp, #32\n" +" ret x9\n" +" .size my_tramp2, .-my_tramp2\n" +" .popsection\n" +); + +#endif /* CONFIG_ARM64 */ + static unsigned long my_tramp = (unsigned long)my_tramp1; static unsigned long tramps[2] = { (unsigned long)my_tramp1, diff --git a/samples/ftrace/ftrace-direct-multi.c b/samples/ftrace/ftrace-direct-multi.c index 1547c2c6be02..b2ac90e0c02e 100644 --- a/samples/ftrace/ftrace-direct-multi.c +++ b/samples/ftrace/ftrace-direct-multi.c @@ -4,7 +4,9 @@ #include /* for handle_mm_fault() */ #include #include +#ifndef CONFIG_ARM64 #include +#endif extern void my_direct_func(unsigned long ip); @@ -66,6 +68,28 @@ asm ( #endif /* CONFIG_S390 */ +#ifdef CONFIG_ARM64 + +asm ( +" .pushsection .text, \"ax\", @progbits\n" +" .type my_tramp, @function\n" +" .globl my_tramp\n" +" my_tramp:" +" bti c\n" +" sub sp, sp, #32\n" +" stp x9, x30, [sp]\n" +" str x0, [sp, #16]\n" +" mov x0, x30\n" +" bl my_direct_func\n" +" ldp x30, x9, [sp]\n" +" ldr x0, [sp, #16]\n" +" add sp, sp, #32\n" +" ret x9\n" +" .size my_tramp, .-my_tramp\n" +" .popsection\n" +); + +#endif /* CONFIG_ARM64 */ static struct ftrace_ops direct; static int __init ftrace_direct_multi_init(void) diff --git a/samples/ftrace/ftrace-direct-too.c b/samples/ftrace/ftrace-direct-too.c index 71ed4ee8cb4a..38f6f677f913 100644 --- a/samples/ftrace/ftrace-direct-too.c +++ b/samples/ftrace/ftrace-direct-too.c @@ -3,7 +3,9 @@ #include /* for handle_mm_fault() */ #include +#ifndef CONFIG_ARM64 #include +#endif extern void my_direct_func(struct vm_area_struct *vma, unsigned long address, unsigned int flags, struct pt_regs *regs); @@ -72,6 +74,30 @@ asm ( #endif /* CONFIG_S390 */ +#ifdef CONFIG_ARM64 + +asm ( +" .pushsection .text, \"ax\", @progbits\n" +" .type my_tramp, @function\n" +" .globl my_tramp\n" +" my_tramp:" +" bti c\n" +" sub sp, sp, #48\n" +" stp x9, x30, [sp]\n" +" stp x0, x1, [sp, #16]\n" +" stp x2, x3, [sp, #32]\n" +" bl my_direct_func\n" +" ldp x30, x9, [sp]\n" +" ldp x0, x1, [sp, #16]\n" +" ldp x2, x3, [sp, #32]\n" +" add sp, sp, #48\n" +" ret x9\n" +" .size my_tramp, .-my_tramp\n" +" .popsection\n" +); + +#endif /* CONFIG_ARM64 */ + static struct ftrace_ops direct; static int __init ftrace_direct_init(void) diff --git a/samples/ftrace/ftrace-direct.c b/samples/ftrace/ftrace-direct.c index d81a9473b585..e5312f9c15d3 100644 --- a/samples/ftrace/ftrace-direct.c +++ b/samples/ftrace/ftrace-direct.c @@ -3,7 +3,9 @@ #include /* for wake_up_process() */ #include +#ifndef CONFIG_ARM64 #include +#endif extern void my_direct_func(struct task_struct *p); @@ -63,6 +65,28 @@ asm ( #endif /* CONFIG_S390 */ +#ifdef CONFIG_ARM64 + +asm ( +" .pushsection .text, \"ax\", @progbits\n" +" .type my_tramp, @function\n" +" .globl my_tramp\n" +" my_tramp:" +" bti c\n" +" sub sp, sp, #32\n" +" stp x9, x30, [sp]\n" +" str x0, [sp, #16]\n" +" bl my_direct_func\n" +" ldp x30, x9, [sp]\n" +" ldr x0, [sp, #16]\n" +" add sp, sp, #32\n" +" ret x9\n" +" .size my_tramp, .-my_tramp\n" +" .popsection\n" +); + +#endif /* CONFIG_ARM64 */ + static struct ftrace_ops direct; static int __init ftrace_direct_init(void)