From patchwork Tue Feb 7 18:21:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florent Revest X-Patchwork-Id: 54033 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp3005222wrn; Tue, 7 Feb 2023 10:23:55 -0800 (PST) X-Google-Smtp-Source: AK7set8WYWy1sqxz5k18SiDRguEw0YFkDRvS56q6Gv+nczZBXZZBEWP1CrFSOsQ6LSu2b9LqN909 X-Received: by 2002:a50:d658:0:b0:4aa:b391:d2a5 with SMTP id c24-20020a50d658000000b004aab391d2a5mr4732312edj.11.1675794235691; Tue, 07 Feb 2023 10:23:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675794235; cv=none; d=google.com; s=arc-20160816; b=Q7rE0L29FsNRHFTS7kbcT4VdVlupD5KT4iVPZhTYuWx3RY6vFWbd+CA63+FwFOOJab OFwgodFW16qBNSdz8TQCOqhH1BRA7qh6PObf9iMDjSMMctaZiFsnsTiiv6WLg8Wn4wHT 9hbzh40DBDjb7Fltc7Y9I8pr33Pa57JXnPwVqEKnIcxszMDQK9WlMD3CY50Sj/rGS2rM PDr+QXhSpoWsXBhOe6reR/hocg6AsfRgFutMpGVOeqEFx5ZiwojOJqGEYQb8eyWSoEfL hMeWkEWM9v+fR6PbsAFwWqeuLYILaWM4JTahT+VPiaeegLhWPYNIsdTJUSDWQXTqSx9W nAdQ== 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=sVdLTLQft6enzmBPM6z7EP+DOR880oV54j7MQfksQV4=; b=lngC+Bz6NzotqIsJTsTgMj4UpTNML02CBMGTe0ZAgfJ9B58HZ3OSUDXJRdUxmrrAYW QzKDfMhBmZFEgfEukX/772gBcWDxrBFa98fkfh4ZyDup3hpMMi/JTRlOGB8kVNT3UnkF tnJ2sqqJbgwq9cUbSX+8112zVNA0qr3O2IU9c0ms7uxxBvZkiG6aizXnj8IJk0SL+Avz JbAeyBWTD9pX7Kjht1+wPxWSlmf1H048iYANzQrILMVFLwHpgqIW8dK+Zg9aBn1HYqRM BTSP9BtKbl6oBoWxArhG0xvha4Aa2ml9Y/trB5pwYAAIV3YRGl5RjuAIOZlFJugKVW1p vx4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="e6OSwVp/"; 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 ay24-20020a056402203800b004aaa4db50d9si11403760edb.440.2023.02.07.10.23.32; Tue, 07 Feb 2023 10:23:55 -0800 (PST) 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="e6OSwVp/"; 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 S232169AbjBGSXM (ORCPT + 99 others); Tue, 7 Feb 2023 13:23:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232214AbjBGSWj (ORCPT ); Tue, 7 Feb 2023 13:22:39 -0500 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7ACFB402F9 for ; Tue, 7 Feb 2023 10:22:09 -0800 (PST) Received: by mail-wm1-x32b.google.com with SMTP id k8-20020a05600c1c8800b003dc57ea0dfeso13848476wms.0 for ; Tue, 07 Feb 2023 10:22:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; 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=sVdLTLQft6enzmBPM6z7EP+DOR880oV54j7MQfksQV4=; b=e6OSwVp/NPzxEGu5b3/btFrO+8uOj89LTeWGJl9emjZZ4wnzZvkc/m2mUmYZXxRJtk q33u2WS9pSJ5U+MA0i8xz7x8gsJwapZaYKYsycL+Bms9N1UxsQnUX7zpgHuSZDEtcIYF 2469o9/Z5vKfR7MRnipxbuqUfDCQoz5TpL5Lw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=sVdLTLQft6enzmBPM6z7EP+DOR880oV54j7MQfksQV4=; b=LtJdxZ/OXByMxVheAMINBXAjlDz+aj3ME3SW7nZgPL3yl/GJ/lOJ10E6zEXBHAgwVA BTwLJGpgsPBMnBiOvUmoDK9a9YCTI+2Jia7lTWs4xUPvlBmqgQaG/PmqeGt7+pG+/PL9 4xWPN7sL1bzKV7pAQXV9OJ+AwylDVJyvLBR74DHe4/efsQsZpA69RJ6kPUh7qbDZiCIF saxiIflkZTmtqHxJxMr6YLn4UCKxnktAgQ8gOK4s0mU6MTnUy9/gVBMEigGEADTtbtqt 7Wl/FKicmdXmRL1rlvlA9K7eZBrT8RtyuasAbbp+Kax7UeNplhqFN7SGHkM7akgCT+hq Bagg== X-Gm-Message-State: AO0yUKXt+eaUG7j71MnOlIJu1u77AsCpJZtE0oCaYGxMY84PKGr2npB5 laepGJMuIpIzPOY+g298nPI5IA== X-Received: by 2002:a05:600c:1892:b0:3da:fa18:a535 with SMTP id x18-20020a05600c189200b003dafa18a535mr3844120wmp.29.1675794127977; Tue, 07 Feb 2023 10:22:07 -0800 (PST) Received: from revest.zrh.corp.google.com ([2a00:79e0:9d:6:5307:c0c0:ff97:80de]) by smtp.gmail.com with ESMTPSA id n6-20020a05600c4f8600b003daf672a616sm15578369wmq.22.2023.02.07.10.22.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Feb 2023 10:22:07 -0800 (PST) From: Florent Revest To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, bpf@vger.kernel.org Cc: catalin.marinas@arm.com, will@kernel.org, rostedt@goodmis.org, mhiramat@kernel.org, mark.rutland@arm.com, ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, kpsingh@kernel.org, jolsa@kernel.org, xukuohai@huaweicloud.com, lihuafei1@huawei.com, Florent Revest Subject: [PATCH v2 05/10] ftrace: Make DIRECT_CALLS work WITH_ARGS and !WITH_REGS Date: Tue, 7 Feb 2023 19:21:30 +0100 Message-Id: <20230207182135.2671106-6-revest@chromium.org> X-Mailer: git-send-email 2.39.1.519.gcb327c4b5f-goog In-Reply-To: <20230207182135.2671106-1-revest@chromium.org> References: <20230207182135.2671106-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?1757197616183551655?= X-GMAIL-MSGID: =?utf-8?q?1757197616183551655?= 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 84f717f8959e..cabb40146da9 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 5df427a2321d..4496a7c69810 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 dfa5f34ec320..58b6f4411ac7 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -5282,7 +5282,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) {