From patchwork Thu Mar 16 17:38:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florent Revest X-Patchwork-Id: 70931 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp618759wrt; Thu, 16 Mar 2023 10:53:11 -0700 (PDT) X-Google-Smtp-Source: AK7set8iaWmRwCFZ/NZg+e+vMrudlpz4TubdzLwXTx3LVYzKdcNZZ7dNI0FaXt0qOx1v57TavBcz X-Received: by 2002:a17:903:228d:b0:19e:6cb9:4c8f with SMTP id b13-20020a170903228d00b0019e6cb94c8fmr5338364plh.41.1678989190808; Thu, 16 Mar 2023 10:53:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678989190; cv=none; d=google.com; s=arc-20160816; b=pWtEDdSKHlYn1YbvrO770tLNoFboCKl72G7XUbhweK+DgcgXGRsENW2qXMYE1O0v5B akI9F4CK/fUO+d3tdLME4PKdWWuqu8XWFNz0ayatjJww004GnOseecsqvJtN8ydS1G8j onZroY7YbKGn6SRWJFn4OBK36BJaKaDt8GDeCRLVgG4zquiHgU+8la/XaN6XvaDAOEK9 u8YH0xZtnIBALC/FTM84xU5moTZRDyT2HLv/RMXM6B2BD/2VJMzy7NPnQ/pOl+ZmVK/H JD5aGeSvvDOPxf70DUZxGliiLzIzNuofIGfSqIFt2int8boGEoU971ccE2GwCFoFkL01 RfSA== 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=RknWTQPZwhibubaws4VpF1wT1qJmtFEhJqVyQzYCbBk=; b=npbmZokosqlZWq+u+dAMU0fTb50D0yowbiIjkf70ieMUhvZzBp68ka07VRqrqC4nps 8ukDENofcKqFd//cBYKAqbwPu2U1ZC1URMb0UaKcHP0D/kanjvBOFzfuqQbBozXFGpOk nxPMpVitFyrZhUpVeSsdYZzl6oXGNaG9tXefX2yCO5yOdh4W+Jb4qn4fizvt27spclig tJx/1oWkIKuMdOrMkuphFdS0Yri6QF1ndxl5KsChs/hqbR99qwZMpiHsBr3GQrNdaffx kLvszK4MMUKk8B/ggcaMF8VaD3ChNPCbsAbosIuvYh1y8joUd342RtIBZIKEBqi4RuaV wBKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=f56BSsM5; 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 lb7-20020a170902fa4700b0019ab69570aasi8485535plb.417.2023.03.16.10.52.58; Thu, 16 Mar 2023 10:53:10 -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=f56BSsM5; 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 S229918AbjCPRjD (ORCPT + 99 others); Thu, 16 Mar 2023 13:39:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230018AbjCPRis (ORCPT ); Thu, 16 Mar 2023 13:38:48 -0400 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FD7FDCF74 for ; Thu, 16 Mar 2023 10:38:44 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id o11-20020a05600c4fcb00b003eb33ea29a8so1729108wmq.1 for ; Thu, 16 Mar 2023 10:38:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1678988322; 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=RknWTQPZwhibubaws4VpF1wT1qJmtFEhJqVyQzYCbBk=; b=f56BSsM5F/ldRHe5qOjUptpr+nccSsE5eRA+3mK+BgPce9DTV5LPUavBnVLW47eUr/ 6awV/JtevYfZanAmjonsIB5yDkuEWU+8Bh4+0wwFygu9rthmr6XVcRYgNPxpRsObPeen eXqYveVWhsHFhzLC7FwxE+eSuYdf1kpXMZ9V4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678988322; 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=RknWTQPZwhibubaws4VpF1wT1qJmtFEhJqVyQzYCbBk=; b=QaLvFaslwIfL1LG+2lA8vXH3058kvxotbvp+swta2BrfcF+R8U+vsloaEiAuHzkHQt qSONq0oBoDna1SJ5eIq5qR1A91xwe/t8m10u8p9ZrpQTBRYMoh6AzMojAcmZgELT3fij UXEf5A5XjNdPsezOcU1l6EUelCfvpZrKRw8rsyX1LGXmDC+E3QPTW5+5oaY0w9poQM3H mLL22MxUsJWrJI82+PrbCchpnB3m9Nvlawe//XuZ/xZ9KbqGut+zooEdOaGS/vo9/I5x f9ODikUuNToKgmutTKjGYZkjJivoagMxgqu6VAorFPBy24uQnZ29tRh7UX1AuH0XawAq MVQg== X-Gm-Message-State: AO0yUKWZ/EfRl+3O1w03EM/4ROCh2v/mrMUzU8vg5MZCgvkE+IK1xB5Y JAzuoOTWbSgeGc4AXWkfMcwTgRhguT4t3Qu/8mM= X-Received: by 2002:a05:600c:314c:b0:3ed:3d89:1b4b with SMTP id h12-20020a05600c314c00b003ed3d891b4bmr4819498wmo.8.1678988322663; Thu, 16 Mar 2023 10:38:42 -0700 (PDT) Received: from revest.zrh.corp.google.com ([2a00:79e0:9d:6:24ff:9ff7:736e:20a6]) by smtp.gmail.com with ESMTPSA id t14-20020a1c770e000000b003daf7721bb3sm5596436wmi.12.2023.03.16.10.38.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Mar 2023 10:38:42 -0700 (PDT) From: Florent Revest To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Cc: rostedt@goodmis.org, mhiramat@kernel.org, mark.rutland@arm.com, ast@kernel.org, daniel@iogearbox.net, kpsingh@kernel.org, revest@chromium.org, jolsa@kernel.org Subject: [PATCH 6/7] ftrace: Make DIRECT_CALLS work WITH_ARGS and !WITH_REGS Date: Thu, 16 Mar 2023 18:38:10 +0100 Message-Id: <20230316173811.1223508-7-revest@chromium.org> X-Mailer: git-send-email 2.40.0.rc2.332.ga46443480c-goog In-Reply-To: <20230316173811.1223508-1-revest@chromium.org> References: <20230316173811.1223508-1-revest@chromium.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 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 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?1760547769803538980?= X-GMAIL-MSGID: =?utf-8?q?1760547769803538980?= Direct called trampolines can be called in two ways: - either from the ftrace callsite. In this case, they do not access any struct ftrace_regs nor pt_regs - Or, if a ftrace ops is also attached, from the end of a ftrace trampoline. In this case, the call_direct_funcs ops is in charge of setting the direct call trampoline's address in a struct ftrace_regs Since: commit 9705bc709604 ("ftrace: pass fregs to arch_ftrace_set_direct_caller()") The later case no longer requires a full pt_regs. It only needs a struct ftrace_regs so DIRECT_CALLS can work with both WITH_ARGS or WITH_REGS. With architectures like arm64 already abandoning WITH_REGS in favor of WITH_ARGS, it's important to have DIRECT_CALLS work WITH_ARGS only. Signed-off-by: Florent Revest Co-developed-by: Mark Rutland Signed-off-by: Mark Rutland --- include/linux/ftrace.h | 6 ++++++ kernel/trace/Kconfig | 2 +- kernel/trace/ftrace.c | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h index 6a532dd6789e..31f1e1df2af3 100644 --- a/include/linux/ftrace.h +++ b/include/linux/ftrace.h @@ -241,6 +241,12 @@ enum { FTRACE_OPS_FL_DIRECT = BIT(17), }; +#ifndef CONFIG_DYNAMIC_FTRACE_WITH_ARGS +#define FTRACE_OPS_FL_SAVE_ARGS FTRACE_OPS_FL_SAVE_REGS +#else +#define FTRACE_OPS_FL_SAVE_ARGS 0 +#endif + /* * FTRACE_OPS_CMD_* commands allow the ftrace core logic to request changes * to a ftrace_ops. Note, the requests may fail. diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig index a856d4a34c67..5b1e7fa41ca8 100644 --- a/kernel/trace/Kconfig +++ b/kernel/trace/Kconfig @@ -257,7 +257,7 @@ config DYNAMIC_FTRACE_WITH_REGS config DYNAMIC_FTRACE_WITH_DIRECT_CALLS def_bool y - depends on DYNAMIC_FTRACE_WITH_REGS + depends on DYNAMIC_FTRACE_WITH_REGS || DYNAMIC_FTRACE_WITH_ARGS depends on HAVE_DYNAMIC_FTRACE_WITH_DIRECT_CALLS config DYNAMIC_FTRACE_WITH_CALL_OPS diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 66c91fa4b6ab..7a0c7eddf25b 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -5287,7 +5287,7 @@ static LIST_HEAD(ftrace_direct_funcs); static int register_ftrace_function_nolock(struct ftrace_ops *ops); -#define MULTI_FLAGS (FTRACE_OPS_FL_DIRECT | FTRACE_OPS_FL_SAVE_REGS) +#define MULTI_FLAGS (FTRACE_OPS_FL_DIRECT | FTRACE_OPS_FL_SAVE_ARGS) static int check_direct_multi(struct ftrace_ops *ops) {