Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2550797rwb; Mon, 19 Sep 2022 06:46:53 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4/LLSv4QO58nH+WKdzQi3wbhyLOU1JQ89g6onGRwR6AL5B4rP3j03Xse9LRwN0UYibKnw9 X-Received: by 2002:a17:90b:1a8d:b0:202:971f:2a37 with SMTP id ng13-20020a17090b1a8d00b00202971f2a37mr30199330pjb.206.1663595213665; Mon, 19 Sep 2022 06:46:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663595213; cv=none; d=google.com; s=arc-20160816; b=b9ImCQgeNdeKyBCykf1wzm6/FuS6dbk+SwVKFB0LIQ3iHAOIuM0Wy6pwAv8PI7i3+j +FGxDt/BXW+aV3EklOEMKryqV6LQTh0l5xk6/TCsktTgur4S19P2mi0o2GLJn0uEsMgT dx0l0W0fTyWZfO+aEYxE9WvEZ8v5qt2BbdhX/PwGL+l3Dr+Tvk1n8VP5DFwSpI3WIAEI a8PQ4bSKdkM7pgOHOR9dqP7nApf+GJXTr3zNEQ6xuGDXKIdb7fR5cE+U6OXBonnpHuc4 xqIna9pZI3Ngo25jYLA+tKQ8h3ztQJnFmDy9lyiFMTfHfCsf2PO8LrK0UvpYNRnZqCUC XFnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=Tsk1/ZAK1Esm3F1J2ITrKgEcJO6HQAZt40KJ1MIbgNI=; b=IxYlDQdJI+w7nODB0WZ0bRt17fMntlGlOo9DvBbFfQOy026/PtNESM+o8K9ldtPF5u +7CR3K8ra+/hgfl2FytxGIi8wQsLUX8m5HZLOk7xxqBoZKe3l6Y2d7O1fnz/kwU55ZDz hp+ki8llzl2JmHJXc4qkMkdPXlOyCfoukEGfjtiOQ/0oJOaS9UeBmJYMMfFe9s7s4mCH 4VrldbrTGv/ZIBQOkfOpXhmQEsKvT7AAgK8mWUXPP+g312dW95sZS/xGSvSbGWkxaJJh PGWuAnrC2UPlqGB25lzzGslFhIHdmjyU2Z9HPXEpbdLh4QX9dT1/NQjBW6ZPGoBszW6X qWpA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t8-20020a170902e84800b00176939b5cd9si16762493plg.578.2022.09.19.06.46.41; Mon, 19 Sep 2022 06:46:53 -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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230346AbiISNBh (ORCPT + 99 others); Mon, 19 Sep 2022 09:01:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230333AbiISNBS (ORCPT ); Mon, 19 Sep 2022 09:01:18 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D2412F3A5 for ; Mon, 19 Sep 2022 06:01:11 -0700 (PDT) Received: from dggpemm500020.china.huawei.com (unknown [172.30.72.53]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4MWPp90GWdz14QRj; Mon, 19 Sep 2022 20:57:05 +0800 (CST) Received: from dggpemm500016.china.huawei.com (7.185.36.25) by dggpemm500020.china.huawei.com (7.185.36.49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 19 Sep 2022 21:01:09 +0800 Received: from huawei.com (10.67.175.41) by dggpemm500016.china.huawei.com (7.185.36.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 19 Sep 2022 21:01:09 +0800 From: Yipeng Zou To: , , , , , , , , , , CC: Subject: [PATCH 2/2] tracing: kprobe: make gen test module work in arm and riscv Date: Mon, 19 Sep 2022 20:56:29 +0800 Message-ID: <20220919125629.238242-3-zouyipeng@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220919125629.238242-1-zouyipeng@huawei.com> References: <20220919125629.238242-1-zouyipeng@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.175.41] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm500016.china.huawei.com (7.185.36.25) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, 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 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. Fixes: 64836248dda2 ("tracing: Add kprobe event command generation test module") Signed-off-by: Yipeng Zou --- 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; -- 2.17.1