From patchwork Sat Oct 22 07:26:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7572 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1106188wrr; Sat, 22 Oct 2022 01:37:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6lk7yqwQ/ofmlTBQzUOwXZUqglt1clghCqfw0Ffx0uauetpHeaHwmwjE3YSJ4rizh4PsOP X-Received: by 2002:a17:907:6e8b:b0:793:30e1:96c9 with SMTP id sh11-20020a1709076e8b00b0079330e196c9mr13834269ejc.97.1666427833487; Sat, 22 Oct 2022 01:37:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666427833; cv=none; d=google.com; s=arc-20160816; b=tOCkU9hBk3VXoZ38OrNpTWxpnabQee3VImkRsTsmdF0F/Vou9dUNTQtS613HhOAIcN NzFGehOKNi495eaMzL1w/LLyWvIy7/WtR6g2HC2R68tS4gK7PWTSE0VPNUGTQMs/jpxE VnMQlntqXaWjwaIJX1X+4lG2r1zzB8DPEvUOMZ6wp+cfPdFUQupI+ZGrp+0dQSratajx epQFqtK45M1MXdrPfXyk6OukulEGq982K+dt+jFtxrWiknGJ5QyR6CAx1hD7326iCgA1 d7XWYmQY70dHZ2JdCrzcfaRw5WSj402RPQ86l2HByAQdsixqt61a0kZLmgepUThLMwwM e4ww== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=svhPfyiBknFcdK9Jb03uX0IgjMsCSeIO5LuOUGYZPMQ=; b=H6xEvDejxzShK8YyWl3LL2+H+VsrM5WMD7Xc/XeJIj61Af+VhkU7brDjD14/g8p+S5 qRQgkMDP/czgvXgt92B5axxSS2oHodENvD1csvsAkSGDkvbQGbA3udQWdV8S6e1gYWYP zmMMhk/X00OIhslOrGkjc+RQuuLQanULvxOSX2joyeshw5tdecQcv3Cy5d3mb1tNGVo8 EYVBO+Xd/tDo9IigASno8zibT0vq44sLTH1vsEiFvhVB/tD7SOcvMY9MeO/N+Ex4MJmU Its1HaXNVKvafGtgA1oQiXsmDUY/kFkrUczL8CumN8ookrTKDHpTH9XiZlohmjZtFEAv Xf2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=H6rL+InR; 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=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l15-20020a170906794f00b0078d2a84f2f8si25249371ejo.645.2022.10.22.01.36.45; Sat, 22 Oct 2022 01:37:13 -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=@linuxfoundation.org header.s=korg header.b=H6rL+InR; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233995AbiJVIcQ (ORCPT + 99 others); Sat, 22 Oct 2022 04:32:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234013AbiJVI3M (ORCPT ); Sat, 22 Oct 2022 04:29:12 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 920C12E2BAD; Sat, 22 Oct 2022 01:01:44 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4531F60AFA; Sat, 22 Oct 2022 08:00:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 27020C433D7; Sat, 22 Oct 2022 08:00:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666425607; bh=Xz/JYnNX+bv4d5sNBNrD5dHf4bfzzM5L7MEjHHLxJTw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H6rL+InRTUElvIlZItognaPFHJRAN5sEq1ClqqFIvaWofsbyNObsG7vWoQNRNxvtb znRUHfZCWU5+m8gxTYNp0qCLsA6Yeg/sSs9/YD7fsZrxl8dw8l6/j/eXUY5fN09OHy qrrAg1n9rkLAqU+midzCPz5cj86VxZLsULn38WXs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, linux-riscv@lists.infradead.org, mingo@redhat.com, paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, zanussi@kernel.org, liaochang1@huawei.com, chris.zjh@huawei.com, Yipeng Zou , "Masami Hiramatsu (Google)" , "Steven Rostedt (Google)" , Sasha Levin Subject: [PATCH 5.19 526/717] tracing: kprobe: Make gen test module work in arm and riscv Date: Sat, 22 Oct 2022 09:26:45 +0200 Message-Id: <20221022072521.582016938@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham 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?1747376232311953431?= X-GMAIL-MSGID: =?utf-8?q?1747376232311953431?= From: Yipeng Zou [ Upstream commit d8ef45d66c01425ff748e13ef7dd1da7a91cc93c ] For now, this selftest module can only work in x86 because of the kprobe cmd was fixed use of x86 registers. This patch adapted to register names under arm and riscv, So that this module can be worked on those platform. Link: https://lkml.kernel.org/r/20220919125629.238242-3-zouyipeng@huawei.com Cc: Cc: Cc: Cc: Cc: Cc: Cc: Cc: Fixes: 64836248dda2 ("tracing: Add kprobe event command generation test module") Signed-off-by: Yipeng Zou Acked-by: Masami Hiramatsu (Google) Signed-off-by: Steven Rostedt (Google) Signed-off-by: Sasha Levin --- kernel/trace/kprobe_event_gen_test.c | 47 +++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/kernel/trace/kprobe_event_gen_test.c b/kernel/trace/kprobe_event_gen_test.c index e023154be0f8..80e04a1e1977 100644 --- a/kernel/trace/kprobe_event_gen_test.c +++ b/kernel/trace/kprobe_event_gen_test.c @@ -35,6 +35,45 @@ static struct trace_event_file *gen_kprobe_test; static struct trace_event_file *gen_kretprobe_test; +#define KPROBE_GEN_TEST_FUNC "do_sys_open" + +/* X86 */ +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_32) +#define KPROBE_GEN_TEST_ARG0 "dfd=%ax" +#define KPROBE_GEN_TEST_ARG1 "filename=%dx" +#define KPROBE_GEN_TEST_ARG2 "flags=%cx" +#define KPROBE_GEN_TEST_ARG3 "mode=+4($stack)" + +/* ARM64 */ +#elif defined(CONFIG_ARM64) +#define KPROBE_GEN_TEST_ARG0 "dfd=%x0" +#define KPROBE_GEN_TEST_ARG1 "filename=%x1" +#define KPROBE_GEN_TEST_ARG2 "flags=%x2" +#define KPROBE_GEN_TEST_ARG3 "mode=%x3" + +/* ARM */ +#elif defined(CONFIG_ARM) +#define KPROBE_GEN_TEST_ARG0 "dfd=%r0" +#define KPROBE_GEN_TEST_ARG1 "filename=%r1" +#define KPROBE_GEN_TEST_ARG2 "flags=%r2" +#define KPROBE_GEN_TEST_ARG3 "mode=%r3" + +/* RISCV */ +#elif defined(CONFIG_RISCV) +#define KPROBE_GEN_TEST_ARG0 "dfd=%a0" +#define KPROBE_GEN_TEST_ARG1 "filename=%a1" +#define KPROBE_GEN_TEST_ARG2 "flags=%a2" +#define KPROBE_GEN_TEST_ARG3 "mode=%a3" + +/* others */ +#else +#define KPROBE_GEN_TEST_ARG0 NULL +#define KPROBE_GEN_TEST_ARG1 NULL +#define KPROBE_GEN_TEST_ARG2 NULL +#define KPROBE_GEN_TEST_ARG3 NULL +#endif + + /* * Test to make sure we can create a kprobe event, then add more * fields. @@ -58,14 +97,14 @@ static int __init test_gen_kprobe_cmd(void) * fields. */ ret = kprobe_event_gen_cmd_start(&cmd, "gen_kprobe_test", - "do_sys_open", - "dfd=%ax", "filename=%dx"); + KPROBE_GEN_TEST_FUNC, + KPROBE_GEN_TEST_ARG0, KPROBE_GEN_TEST_ARG1); if (ret) goto free; /* Use kprobe_event_add_fields to add the rest of the fields */ - ret = kprobe_event_add_fields(&cmd, "flags=%cx", "mode=+4($stack)"); + ret = kprobe_event_add_fields(&cmd, KPROBE_GEN_TEST_ARG2, KPROBE_GEN_TEST_ARG3); if (ret) goto free; @@ -128,7 +167,7 @@ static int __init test_gen_kretprobe_cmd(void) * Define the kretprobe event. */ ret = kretprobe_event_gen_cmd_start(&cmd, "gen_kretprobe_test", - "do_sys_open", + KPROBE_GEN_TEST_FUNC, "$retval"); if (ret) goto free;