From patchwork Wed Feb 10 06:44:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 12079967 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1D86FC433DB for ; Wed, 10 Feb 2021 06:46:15 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B370264E56 for ; Wed, 10 Feb 2021 06:46:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B370264E56 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=synaptics.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-ID:Subject:To:From:Date: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=34ByRRr9gESMMb+ZlaHmVZizarP97zvPQz4aU9TRSgQ=; b=NhDNZXXV+TO/sAoATnrD8dwKIp vzMrLRtsUuBWMzbrsUhTw5rwn3ynrrlognoZbrz681aPWAXn3GHkO1D6iRVHLwiei3+X5gM/eH1nG aYSG+y2oQV0ANwXiJDmHKbSnZDhJmK94tvUUkB0HMbIVj+UTnSXrwwYcIhZeBSTK8LSKegifWXZdX GUPIkfGW2cwmAGTAjR4dwSefD5gZTnZvLBuXUXd3vaslYEGib5kxsJD5oeQ5tgZyq2J4zFFNLac1B +iY37L451tYxmDZXL6zc3nsh9sbM55hX6X/5uLs1yqIFGJ3ZwqoseFTIKrUmdRqt5BwBf/pIL0d8x TAfiT5hQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l9jEr-0003j6-Ec; Wed, 10 Feb 2021 06:44:37 +0000 Received: from mail-mw2nam10on2046.outbound.protection.outlook.com ([40.107.94.46] helo=NAM10-MW2-obe.outbound.protection.outlook.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l9jEm-0003ie-Vp for linux-arm-kernel@lists.infradead.org; Wed, 10 Feb 2021 06:44:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=astm26aniAQNyK1DMPe0quCd3o4TnGPJmqLS9Rs8PHKDlsVJVmepS7T6RgLmM69gBHcQU+ZmrkAR3wvBzAB++Nh7LqyQWK1UHZy0dJ6TSSGzAnjvOOfz7tyGHIciWZNgsO9W5eLaLyP1T+xVF1MjZBvYMlYE9A056pSOYSUNGCt1L7wooxoIIAbfpl85vxO4RAwOm1bWY3vk9souLU5LxFWv4WWCHoAV/hcW9wyobVgPUMYjCsn80urVY6yoL2gptQBLsGmvoWBTpGrYoBJrYxMSJtH7QDSgrPjon3Mra3g/HK4gPAnN1Sjt+VYX9/sMP4soq2mVQcRxJSIrkmTcyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BhjJWuvonJWPXqMBpL1P7EPAg07h3Y01XWCBIRYYnjc=; b=jj96/nBFShExFxnmoDxVhS/ZXX3wR/7rKPsl4LLjg61GVsSZorDr5snB0KHBjNyoAlAMMtDLDOrkMoajqOCWRwY4myWLJhHNEOZOhTdyzBQH6cIt/bP+1SORUBbe5EB1hsRCabO1XxgeQoBnDNpFfYenNHDVv75kkXOY4d8ZD1Br1D3YkdGdZYMjAeDUz9iCRR1JKKzmJQezF/+5SACgepFj5aaaxJEKgVb7Gq7pZmI+UqA3AvO2594x8APXUZfHgKPJBMMb517vZWGb4EH69kd0rjJ1KaSj0iy2I7RLrfgx4cO4lWKA6J0fzseCkKCnQjaWb9a3xGAfzlyuT3NgvQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=synaptics.com; dmarc=pass action=none header.from=synaptics.com; dkim=pass header.d=synaptics.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Synaptics.onmicrosoft.com; s=selector2-Synaptics-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BhjJWuvonJWPXqMBpL1P7EPAg07h3Y01XWCBIRYYnjc=; b=mH0j1816eO0pfSqFd5Fn8qn+IUJ2T0j3ABMvy/lDAyR43XlNBR/AqYwkBtP1+4C4Esvn22/lP/p0HwqNuXsURmt3AQzpdxIFE8wDgeURn2g1+ffjFpOFa/eFjkEtvek5znWViQq2zx0bBFy7KiIun7tSRZMu0JkONfphIQyJPUo= Authentication-Results: linaro.org; dkim=none (message not signed) header.d=none;linaro.org; dmarc=none action=none header.from=synaptics.com; Received: from BN8PR03MB4724.namprd03.prod.outlook.com (2603:10b6:408:96::21) by BN8PR03MB4723.namprd03.prod.outlook.com (2603:10b6:408:97::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.27; Wed, 10 Feb 2021 06:44:28 +0000 Received: from BN8PR03MB4724.namprd03.prod.outlook.com ([fe80::34cf:5dc3:971:82a7]) by BN8PR03MB4724.namprd03.prod.outlook.com ([fe80::34cf:5dc3:971:82a7%5]) with mapi id 15.20.3846.026; Wed, 10 Feb 2021 06:44:28 +0000 Date: Wed, 10 Feb 2021 14:44:09 +0800 From: Jisheng Zhang To: Jens Wiklander , "Steven Rostedt (VMware)" Subject: [PATCH] tee: optee: add invoke_fn tracepoints Message-ID: <20210210144409.36ecdaed@xhacker.debian> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) X-Originating-IP: [192.147.44.204] X-ClientProxiedBy: BYAPR07CA0037.namprd07.prod.outlook.com (2603:10b6:a03:60::14) To BN8PR03MB4724.namprd03.prod.outlook.com (2603:10b6:408:96::21) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from xhacker.debian (192.147.44.204) by BYAPR07CA0037.namprd07.prod.outlook.com (2603:10b6:a03:60::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.27 via Frontend Transport; Wed, 10 Feb 2021 06:44:25 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: dd9e7cca-84cc-4ba9-6db2-08d8cd8f4ff9 X-MS-TrafficTypeDiagnostic: BN8PR03MB4723: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4125; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IA4Bi1U4Lux4Z5ZQ6gVlVDQzNREOLA/8p/8C9tJ2MehSbGwhBpt/gglp0ZY9ImEvlNTWWakC6phTHCrfYnXvpefS473uM6chCgu22P1EUg4Ox5oxdYQ3oMGF0olIeey6J3YoNBivJaOS0BB0UBwDX/KOZ2BscwXCLAKelMUp1ruQ+PqfVQ5NTGgV+CzNculxcSzvHuk7ckrMnyHXGWQmNfw0A1/Qw2++Y2sah05bzI5u3yR1YAA2JDGH7h+4UXJenUXsEozcLl/JgrL9u/TEFXq1YZnyyWxXRbWuLRSNfhsY+YqYR2kLTVXqo90hWKXxAALeGSkzIoX5R6fGpPOyiWK809nWqbea70S0lmUZk2Y1x4s6QMDm5NEfwEhG539AIw3X+g8QzEg7jQ/5OC5p1xEwgOpRETxpt7Rp6dzK8ZMD0ysHPmnItV5x+pe+89A6wIt3zvXhKQmtTflq7V6Xr14wp/Of/7SxREk/Y7I3VcGbny92fhIeCzn312OBNbAB0WDwQd1/THr5KiPzZqBaWA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BN8PR03MB4724.namprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(396003)(39860400002)(346002)(376002)(136003)(366004)(7696005)(52116002)(956004)(6666004)(186003)(9686003)(8936002)(16526019)(1076003)(8676002)(110136005)(2906002)(86362001)(478600001)(83380400001)(26005)(66946007)(316002)(66556008)(66476007)(55016002)(5660300002)(4326008)(6506007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: ZiyBgu3F0L1nN2Sy3TDLNkgqcYe2TRxMJWIHCyySB5muay+w+NCf0KNo9BQgahN9ER43RhBXUtou0P3XE5qlgcc2pOOjIOkGmKJgMdopkXB1mr+WBv357Qd6ugV3hriOYm1AoGLfofFfa7oclvm2eGLqhLfR+Sqdq3DKC7SFBjvXkb7UgTb+tvs8JNAarafYKdeDepua769lsylZk4F9oo80z9nATy4GUqYyLHZI1mm1n3RDcfcfLQcsGBc+BsVDEWTYr3f+pqfwI0rIi72WGgGb9PVoW199lgAKjuC6c8P7VaBgAre6epdALKHvdgqe9g/PKD5ACBORvw7admDqym950owWSpaPyJHLxX/NxBurvjdztg7DV6L0KoWl/88K2QntE4dUwXD+lCjlnkeAkptpdku95MvucoRI2o/0pNJta3KZ+MveId4kyl/d4v/hTPA6T/OHFfDEaN/pycVIEDytLPdQ0cD8i5sJgs/TRDzitFXgFTIyRXwDX98/2nrsgjjcPOrznciJAoRMOQUtMBWEqBvpACznqt6gq8Q9/VMHhh4HZINOJaJy2u0Zr47+bd/nNn7CkLl46YKrAKG9bGAtMS2hRs8IgU1DEabXOxPMbvmD5IsAO6Hwg+QKZ98LPz44MP02Be7mLdikm76tLaRTU/aJvd5cs1NqCkJBQD32T61b2tQDv0bcWfMmG0p/j5WJa0PnH7nFSqcnfpWGGd+/4rafu666oa7hDF+vpTulQu/7+m2AdDCxgoCHynihSmtgrUgsfos31qbZBUqoLdSpexGjEF1UGOD97wyiPa/XkENgRduuM1OZ+ktwPEI9ZjgbcvCAa/AFqirZx11wVTDca0oM1+4AZxWEn6WQNzOxfdq1wKXjQqiSH+yWj87jL6fBgQbIFxhtKKzn80TXl6SKWWnU0DhKdlgV3vw9qXO2UL4ODbCSVEWO1vBoZ/w/NlXdx+XZb9/llfyTu3bLE0wzQ0H3yH94q+VBpCMnNSPPwI37EsYjPvtCmyoTySq3biU+IufBqCTiojTeQYoT14DNcM6OPVTizb/xrmj/0kzCXcJWApSHFnxBcoLdi82v29n6lHRXfUZ2zrzssBEmr9/qK1ifwho0SY+hHKN5uV7NxckvLFEpUeI8qEF4s+yGnvOCxYJFZIxRJTTyX13ieVvFVpxaiYDQ9cXUpb2ChQOYd7Om5VwU8cqel2BK84J5s1UbcypNI9G6f6AF9JbyTDnHFVdhKuDpcs8zqW18fzid7vD4Nmd2NTZGOcpD7G5KrNrV9b6NbiZS8JBmGul7YiMiZ07uan5Mx0RAgCkX+WYX6WRaPsHBA7zEzb2SthFf X-OriginatorOrg: synaptics.com X-MS-Exchange-CrossTenant-Network-Message-Id: dd9e7cca-84cc-4ba9-6db2-08d8cd8f4ff9 X-MS-Exchange-CrossTenant-AuthSource: BN8PR03MB4724.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Feb 2021 06:44:28.0518 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335d1fbc-2124-4173-9863-17e7051a2a0e X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: UD8wuVZaoLobaaq/Xh3CpSA6OcFQAplbZGNKS6YbessIWGd6rcl4mXcK97MOjt/OsS4ax77LfjXG2rKVc8lxyA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR03MB4723 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210210_014433_840036_50678037 X-CRM114-Status: GOOD ( 16.57 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: op-tee@lists.trustedfirmware.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add tracepoints to retrieve information about the invoke_fn. This would help to measure how many invoke_fn are triggered and how long it takes to complete one invoke_fn call. Signed-off-by: Jisheng Zhang Reviewed-by: Steven Rostedt (VMware) --- Since v1: - add BUILD_BUG_ON() macro usage to make sure that the size of what is being copied, is not smaller than the amount being copied. Thank Steve. - move optee_trace.h to keep include headers sorted drivers/tee/optee/call.c | 4 ++ drivers/tee/optee/optee_trace.h | 67 +++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 drivers/tee/optee/optee_trace.h diff --git a/drivers/tee/optee/call.c b/drivers/tee/optee/call.c index 780d7c4fd756..0da6fe50f1af 100644 --- a/drivers/tee/optee/call.c +++ b/drivers/tee/optee/call.c @@ -14,6 +14,8 @@ #include #include "optee_private.h" #include "optee_smc.h" +#define CREATE_TRACE_POINTS +#include "optee_trace.h" struct optee_call_waiter { struct list_head list_node; @@ -138,9 +140,11 @@ u32 optee_do_call_with_arg(struct tee_context *ctx, phys_addr_t parg) while (true) { struct arm_smccc_res res; + trace_optee_invoke_fn_begin(¶m); optee->invoke_fn(param.a0, param.a1, param.a2, param.a3, param.a4, param.a5, param.a6, param.a7, &res); + trace_optee_invoke_fn_end(¶m, &res); if (res.a0 == OPTEE_SMC_RETURN_ETHREAD_LIMIT) { /* diff --git a/drivers/tee/optee/optee_trace.h b/drivers/tee/optee/optee_trace.h new file mode 100644 index 000000000000..7c954eefa4bf --- /dev/null +++ b/drivers/tee/optee/optee_trace.h @@ -0,0 +1,67 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * optee trace points + * + * Copyright (C) 2021 Synaptics Incorporated + * Author: Jisheng Zhang + */ + +#undef TRACE_SYSTEM +#define TRACE_SYSTEM optee + +#if !defined(_TRACE_OPTEE_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_OPTEE_H + +#include +#include +#include "optee_private.h" + +TRACE_EVENT(optee_invoke_fn_begin, + TP_PROTO(struct optee_rpc_param *param), + TP_ARGS(param), + + TP_STRUCT__entry( + __field(void *, param) + __array(u32, args, 8) + ), + + TP_fast_assign( + __entry->param = param; + BUILD_BUG_ON(sizeof(*param) < sizeof(__entry->args)); + memcpy(__entry->args, param, sizeof(__entry->args)); + ), + + TP_printk("param=%p (%x, %x, %x, %x, %x, %x, %x, %x)", __entry->param, + __entry->args[0], __entry->args[1], __entry->args[2], + __entry->args[3], __entry->args[4], __entry->args[5], + __entry->args[6], __entry->args[7]) +); + +TRACE_EVENT(optee_invoke_fn_end, + TP_PROTO(struct optee_rpc_param *param, struct arm_smccc_res *res), + TP_ARGS(param, res), + + TP_STRUCT__entry( + __field(void *, param) + __array(unsigned long, rets, 4) + ), + + TP_fast_assign( + __entry->param = param; + BUILD_BUG_ON(sizeof(*res) < sizeof(__entry->rets)); + memcpy(__entry->rets, res, sizeof(__entry->rets)); + ), + + TP_printk("param=%p ret (%lx, %lx, %lx, %lx)", __entry->param, + __entry->rets[0], __entry->rets[1], __entry->rets[2], + __entry->rets[3]) +); +#endif /* _TRACE_OPTEE_H */ + +#undef TRACE_INCLUDE_PATH +#define TRACE_INCLUDE_PATH . +#undef TRACE_INCLUDE_FILE +#define TRACE_INCLUDE_FILE optee_trace + +/* This part must be outside protection */ +#include