From patchwork Thu Dec 6 21:25:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaldo Carvalho de Melo X-Patchwork-Id: 153063 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp11045237ljp; Thu, 6 Dec 2018 13:28:59 -0800 (PST) X-Google-Smtp-Source: AFSGD/V6NEaMBTVv9Uy72+p7GYvJ+jLZwPfpLeNZmUBFJ+oJvxHGuYhtJJ/+ZzPa5q8HGZaZhSmp X-Received: by 2002:a62:c3:: with SMTP id 186mr29807586pfa.24.1544131739167; Thu, 06 Dec 2018 13:28:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544131739; cv=none; d=google.com; s=arc-20160816; b=n7dKplndg49QrfDnpsEJ2/zElDMTC9/GpI3OPNpdKj8iqOTANTWoSczLJPh2c298EZ nQfBo/dxX/uxAf3SGIdC8UPaCwII+lypS9RSZ2USibrQ1evbVjGQi7DQFB6LHAdqds+l ILWE0Y5v4mWvo5CUk53UAaOv+fyisKRwK/Ix/7M6umSdtcxVNaNpTLtePJFWGbWw9dMP VSvE+adsX/Ormsbn6uHOy6ryF2ziGZ5t9fWjTD01bUzy26bSI5d6H35vyI4N/Wa4adI+ IhJdyJtzb6FM4Ii/+Mucf5eG+31VW5vYnbrIdg0Mfhp63n8CmN59xwQxRLz54qLguz2h L1ZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Wj5N702c2dWYiG+q6tReZUA3mStx7nSHNi9cnaNpXck=; b=tjbnXUU27+CZQ1Q+lqeEErFq0rILE2ibtUYbImk+5pN4ryToFnx6YmSm/SZcsDZZjT jg0kAICjVEpumGcArSOqrm39ZsK2MNVwvEqyoMpaYOMpJkt+gnRWBow5OaUgBSlSAvUX HiPGO/RSdQ0A01Ao6UJ4Ps/svjSCThTSY6S3w2LRLzs4aOCgY0SCKKyMdf5vMECaNfW0 57hAsjAIMHZgl/2K3PU6ROFiEer8/R9Yg3LV1dvMIMKdNDHwil40lL6v3umc3dp9D/+g n2XCWswXhimBuAi/QXtvZkwO/2g1q1loV8Yyy9G4kl4DeNY10UTVWPVeGRNCHd9C/rbI lZ7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sBwRWmVK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 189si1182423pfd.142.2018.12.06.13.28.58; Thu, 06 Dec 2018 13:28:59 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sBwRWmVK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726481AbeLFV25 (ORCPT + 31 others); Thu, 6 Dec 2018 16:28:57 -0500 Received: from mail.kernel.org ([198.145.29.99]:47516 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726018AbeLFV24 (ORCPT ); Thu, 6 Dec 2018 16:28:56 -0500 Received: from quaco.ghostprotocols.net (179.187.13.223.dynamic.adsl.gvt.net.br [179.187.13.223]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C44552082B; Thu, 6 Dec 2018 21:28:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544131734; bh=fNHwI70wlQSpnCNa5b879ofSiU9IH+t1JxBu8054x0g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sBwRWmVKEVvj3qfSkDVaEz8/AvLE8ECdzgoh4/htCijuc7Zm7SJL7UY7Bj7E1y32L V+nazKXkQVwPWn0fNAO3brl2Md5Pel4DL/8VatA8By40G+bxhAzsEgz2eh76y/pRsU hvDU4zCldqFuWVUSt+XU831usEVYl38fjuwephJw= From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Robert Walker , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Peter Zijlstra , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, Arnaldo Carvalho de Melo Subject: [PATCH 35/75] perf cs-etm: Support for ARM A32/T32 instruction sets in CoreSight trace Date: Thu, 6 Dec 2018 18:25:22 -0300 Message-Id: <20181206212602.20474-36-acme@kernel.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181206212602.20474-1-acme@kernel.org> References: <20181206212602.20474-1-acme@kernel.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Robert Walker This patch adds support for generating instruction samples from trace of AArch32 programs using the A32 and T32 instruction sets. T32 has variable 2 or 4 byte instruction size, so the conversion between addresses and instruction counts requires extra information from the trace decoder, requiring version 0.10.0 of OpenCSD. A check for the OpenCSD library version has been added to the feature check for OpenCSD. Signed-off-by: Robert Walker Reviewed-by: Mathieu Poirier Tested-by: Leo Yan Cc: Alexander Shishkin Cc: Jiri Olsa Cc: Namhyung Kim Cc: Peter Zijlstra Cc: coresight@lists.linaro.org Cc: linux-arm-kernel@lists.infradead.org Link: http://lkml.kernel.org/r/1543839526-30348-1-git-send-email-robert.walker@arm.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/build/feature/test-libopencsd.c | 8 +++ .../perf/util/cs-etm-decoder/cs-etm-decoder.c | 29 ++++++++ .../perf/util/cs-etm-decoder/cs-etm-decoder.h | 10 +++ tools/perf/util/cs-etm.c | 70 ++++++++----------- 4 files changed, 78 insertions(+), 39 deletions(-) -- 2.19.2 diff --git a/tools/build/feature/test-libopencsd.c b/tools/build/feature/test-libopencsd.c index 5ff1246e6194..d68eb4fb40cc 100644 --- a/tools/build/feature/test-libopencsd.c +++ b/tools/build/feature/test-libopencsd.c @@ -1,6 +1,14 @@ // SPDX-License-Identifier: GPL-2.0 #include +/* + * Check OpenCSD library version is sufficient to provide required features + */ +#define OCSD_MIN_VER ((0 << 16) | (10 << 8) | (0)) +#if !defined(OCSD_VER_NUM) || (OCSD_VER_NUM < OCSD_MIN_VER) +#error "OpenCSD >= 0.10.0 is required" +#endif + int main(void) { (void)ocsd_get_version(); diff --git a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c index 938def6d0bb9..5efb616bd609 100644 --- a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c +++ b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c @@ -263,9 +263,12 @@ static void cs_etm_decoder__clear_buffer(struct cs_etm_decoder *decoder) decoder->tail = 0; decoder->packet_count = 0; for (i = 0; i < MAX_BUFFER; i++) { + decoder->packet_buffer[i].isa = CS_ETM_ISA_UNKNOWN; decoder->packet_buffer[i].start_addr = CS_ETM_INVAL_ADDR; decoder->packet_buffer[i].end_addr = CS_ETM_INVAL_ADDR; + decoder->packet_buffer[i].instr_count = 0; decoder->packet_buffer[i].last_instr_taken_branch = false; + decoder->packet_buffer[i].last_instr_size = 0; decoder->packet_buffer[i].exc = false; decoder->packet_buffer[i].exc_ret = false; decoder->packet_buffer[i].cpu = INT_MIN; @@ -294,11 +297,15 @@ cs_etm_decoder__buffer_packet(struct cs_etm_decoder *decoder, decoder->packet_count++; decoder->packet_buffer[et].sample_type = sample_type; + decoder->packet_buffer[et].isa = CS_ETM_ISA_UNKNOWN; decoder->packet_buffer[et].exc = false; decoder->packet_buffer[et].exc_ret = false; decoder->packet_buffer[et].cpu = *((int *)inode->priv); decoder->packet_buffer[et].start_addr = CS_ETM_INVAL_ADDR; decoder->packet_buffer[et].end_addr = CS_ETM_INVAL_ADDR; + decoder->packet_buffer[et].instr_count = 0; + decoder->packet_buffer[et].last_instr_taken_branch = false; + decoder->packet_buffer[et].last_instr_size = 0; if (decoder->packet_count == MAX_BUFFER - 1) return OCSD_RESP_WAIT; @@ -321,8 +328,28 @@ cs_etm_decoder__buffer_range(struct cs_etm_decoder *decoder, packet = &decoder->packet_buffer[decoder->tail]; + switch (elem->isa) { + case ocsd_isa_aarch64: + packet->isa = CS_ETM_ISA_A64; + break; + case ocsd_isa_arm: + packet->isa = CS_ETM_ISA_A32; + break; + case ocsd_isa_thumb2: + packet->isa = CS_ETM_ISA_T32; + break; + case ocsd_isa_tee: + case ocsd_isa_jazelle: + case ocsd_isa_custom: + case ocsd_isa_unknown: + default: + packet->isa = CS_ETM_ISA_UNKNOWN; + } + packet->start_addr = elem->st_addr; packet->end_addr = elem->en_addr; + packet->instr_count = elem->num_instr_range; + switch (elem->last_i_type) { case OCSD_INSTR_BR: case OCSD_INSTR_BR_INDIRECT: @@ -336,6 +363,8 @@ cs_etm_decoder__buffer_range(struct cs_etm_decoder *decoder, break; } + packet->last_instr_size = elem->last_instr_sz; + return ret; } diff --git a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h index 612b5755f742..9351bd10d864 100644 --- a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h +++ b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h @@ -28,11 +28,21 @@ enum cs_etm_sample_type { CS_ETM_TRACE_ON = 1 << 1, }; +enum cs_etm_isa { + CS_ETM_ISA_UNKNOWN, + CS_ETM_ISA_A64, + CS_ETM_ISA_A32, + CS_ETM_ISA_T32, +}; + struct cs_etm_packet { enum cs_etm_sample_type sample_type; + enum cs_etm_isa isa; u64 start_addr; u64 end_addr; + u32 instr_count; u8 last_instr_taken_branch; + u8 last_instr_size; u8 exc; u8 exc_ret; int cpu; diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index 73430b73570d..48ad217bf0df 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -31,14 +31,6 @@ #define MAX_TIMESTAMP (~0ULL) -/* - * A64 instructions are always 4 bytes - * - * Only A64 is supported, so can use this constant for converting between - * addresses and instruction counts, calculting offsets etc - */ -#define A64_INSTR_SIZE 4 - struct cs_etm_auxtrace { struct auxtrace auxtrace; struct auxtrace_queues queues; @@ -510,21 +502,17 @@ static inline void cs_etm__reset_last_branch_rb(struct cs_etm_queue *etmq) etmq->last_branch_rb->nr = 0; } -static inline u64 cs_etm__last_executed_instr(struct cs_etm_packet *packet) -{ - /* Returns 0 for the CS_ETM_TRACE_ON packet */ - if (packet->sample_type == CS_ETM_TRACE_ON) - return 0; +static inline int cs_etm__t32_instr_size(struct cs_etm_queue *etmq, + u64 addr) { + u8 instrBytes[2]; + cs_etm__mem_access(etmq, addr, ARRAY_SIZE(instrBytes), instrBytes); /* - * The packet records the execution range with an exclusive end address - * - * A64 instructions are constant size, so the last executed - * instruction is A64_INSTR_SIZE before the end address - * Will need to do instruction level decode for T32 instructions as - * they can be variable size (not yet supported). + * T32 instruction size is indicated by bits[15:11] of the first + * 16-bit word of the instruction: 0b11101, 0b11110 and 0b11111 + * denote a 32-bit instruction. */ - return packet->end_addr - A64_INSTR_SIZE; + return ((instrBytes[1] & 0xF8) >= 0xE8) ? 4 : 2; } static inline u64 cs_etm__first_executed_instr(struct cs_etm_packet *packet) @@ -536,27 +524,32 @@ static inline u64 cs_etm__first_executed_instr(struct cs_etm_packet *packet) return packet->start_addr; } -static inline u64 cs_etm__instr_count(const struct cs_etm_packet *packet) +static inline +u64 cs_etm__last_executed_instr(const struct cs_etm_packet *packet) { - /* - * Only A64 instructions are currently supported, so can get - * instruction count by dividing. - * Will need to do instruction level decode for T32 instructions as - * they can be variable size (not yet supported). - */ - return (packet->end_addr - packet->start_addr) / A64_INSTR_SIZE; + /* Returns 0 for the CS_ETM_TRACE_ON packet */ + if (packet->sample_type == CS_ETM_TRACE_ON) + return 0; + + return packet->end_addr - packet->last_instr_size; } -static inline u64 cs_etm__instr_addr(const struct cs_etm_packet *packet, +static inline u64 cs_etm__instr_addr(struct cs_etm_queue *etmq, + const struct cs_etm_packet *packet, u64 offset) { - /* - * Only A64 instructions are currently supported, so can get - * instruction address by muliplying. - * Will need to do instruction level decode for T32 instructions as - * they can be variable size (not yet supported). - */ - return packet->start_addr + offset * A64_INSTR_SIZE; + if (packet->isa == CS_ETM_ISA_T32) { + u64 addr = packet->start_addr; + + while (offset > 0) { + addr += cs_etm__t32_instr_size(etmq, addr); + offset--; + } + return addr; + } + + /* Assume a 4 byte instruction size (A32/A64) */ + return packet->start_addr + offset * 4; } static void cs_etm__update_last_branch_rb(struct cs_etm_queue *etmq) @@ -888,9 +881,8 @@ static int cs_etm__sample(struct cs_etm_queue *etmq) struct cs_etm_auxtrace *etm = etmq->etm; struct cs_etm_packet *tmp; int ret; - u64 instrs_executed; + u64 instrs_executed = etmq->packet->instr_count; - instrs_executed = cs_etm__instr_count(etmq->packet); etmq->period_instructions += instrs_executed; /* @@ -920,7 +912,7 @@ static int cs_etm__sample(struct cs_etm_queue *etmq) * executed, but PC has not advanced to next instruction) */ u64 offset = (instrs_executed - instrs_over - 1); - u64 addr = cs_etm__instr_addr(etmq->packet, offset); + u64 addr = cs_etm__instr_addr(etmq, etmq->packet, offset); ret = cs_etm__synth_instruction_sample( etmq, addr, etm->instructions_sample_period); From patchwork Thu Dec 6 21:25:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaldo Carvalho de Melo X-Patchwork-Id: 153064 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp11046503ljp; Thu, 6 Dec 2018 13:30:21 -0800 (PST) X-Google-Smtp-Source: AFSGD/X1de9p07wP/bZ3rsZzS6dmpuh4R7/5n/QGtFAqqCztOHkmqXP/Sdtqj+/ilqPY/c1RzYRP X-Received: by 2002:a63:310:: with SMTP id 16mr24906746pgd.79.1544131821305; Thu, 06 Dec 2018 13:30:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544131821; cv=none; d=google.com; s=arc-20160816; b=dz2XUgof/hQdwe3waDtXhPRrknNi7icEO1sFZX/+QWh9q63B5MmR4vPtomboXDrePO +3CbHF5MxcSZZ2ml6eftdHxomgj8zNvWbB+DsX7M3irRF8biRpu3Qzs7Ps3irA5dx4E9 eCAqk/AhIenNsQAsM9NYztw2Q7Z4BKY44p83f935dptD91Bms3NZNlZQC/mHxClUquQY YOlRUosDlJBkUmzYnqeualUv5AP1OfPjwjTJiBtZS+KypoYu4v/URkgefkcDvjuXFr7c whpsNSHJIxZaNsRi5eX9oj8b/DblqTiKjrLvVB1WVowCT9jXnG5G+NuSZ4EDM73WrhWu 7kNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=m1c4UG73+RmO07PL/TTUcyCKlXnWUB5NwtculP7RLTk=; b=u34fOEzQ6tQyvriXwDn8QrQr7pB+Boh5LIZ0VffRglz8kx/Y+CCQwr22cFeLV/Cf0+ iEyD/8VOviLZL7fJ11gp44Gi/LPVzF40StdE5NBo7JH0nzfdcIz2uFhdllvg2C62LBHz Vf9DVBa3RPOzFrddmqaC96liXTAXVw9iXUWh2HXmUp3qfvYEqLv0vfrprjvYNX7gdxRZ evx9sFzvAJ3O7NO8hC7I0HyUg/TcvUWpiEZsiCKKbQTmAIBfw1tqAf3BGZmg/Oani7de nHamwlKAEDBthcOH4NCRe1w04yBVeRtFPS/frsOCWPVeXC02zbjqH8XPa3cfFlgGlihn K/gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=m70DW2pC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s35si1092177pgk.392.2018.12.06.13.30.20; Thu, 06 Dec 2018 13:30:21 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=m70DW2pC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726714AbeLFVaT (ORCPT + 31 others); Thu, 6 Dec 2018 16:30:19 -0500 Received: from mail.kernel.org ([198.145.29.99]:48654 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726710AbeLFVaP (ORCPT ); Thu, 6 Dec 2018 16:30:15 -0500 Received: from quaco.ghostprotocols.net (179.187.13.223.dynamic.adsl.gvt.net.br [179.187.13.223]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DC12D2146F; Thu, 6 Dec 2018 21:30:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544131814; bh=kalhg6BjUEjBPqLkTfeR+KzRWOd6nI7iVDMjU7Q3CVY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m70DW2pC6bPZ592di+g/wcojEcCo/kprhHr6LR5Y4Q2N17h18V9kfAxSsesxFE9G8 IQcVoaCBq7hSJ0txUeYjMa4UZlmQ1fwRM5rFThuc0t5+kcA3RmckMOqV4hq5RkNUc/ /v/cBJqznzYXJnC/pnp/a7g1BmguezcpBDL215Qk= From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Mathieu Poirier , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Peter Zijlstra , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, Arnaldo Carvalho de Melo Subject: [PATCH 57/75] perf cs-etm: Add configuration for ETMv3 trace protocol Date: Thu, 6 Dec 2018 18:25:44 -0300 Message-Id: <20181206212602.20474-58-acme@kernel.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181206212602.20474-1-acme@kernel.org> References: <20181206212602.20474-1-acme@kernel.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mathieu Poirier This patch deals with the proper initialisation of configuration parameters for the ETMv3 trace protocol in order to properly handle packets generated by tracers following this specification. Signed-off-by: Mathieu Poirier Cc: Alexander Shishkin Cc: Jiri Olsa Cc: Namhyung Kim Cc: Peter Zijlstra Cc: coresight@lists.linaro.org Cc: linux-arm-kernel@lists.infradead.org Link: http://lkml.kernel.org/r/1543955944-10042-2-git-send-email-mathieu.poirier@linaro.org Signed-off-by: Arnaldo Carvalho de Melo --- .../perf/util/cs-etm-decoder/cs-etm-decoder.h | 8 +++ tools/perf/util/cs-etm.c | 54 ++++++++++++++----- 2 files changed, 48 insertions(+), 14 deletions(-) -- 2.19.2 diff --git a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h index 9351bd10d864..6b5525410a43 100644 --- a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h +++ b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h @@ -53,6 +53,13 @@ struct cs_etm_queue; typedef u32 (*cs_etm_mem_cb_type)(struct cs_etm_queue *, u64, size_t, u8 *); +struct cs_etmv3_trace_params { + u32 reg_ctrl; + u32 reg_trc_id; + u32 reg_ccer; + u32 reg_idr; +}; + struct cs_etmv4_trace_params { u32 reg_idr0; u32 reg_idr1; @@ -65,6 +72,7 @@ struct cs_etmv4_trace_params { struct cs_etm_trace_params { int protocol; union { + struct cs_etmv3_trace_params etmv3; struct cs_etmv4_trace_params etmv4; }; }; diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index 48ad217bf0df..76e509c32a28 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -114,15 +114,28 @@ static void cs_etm__dump_event(struct cs_etm_auxtrace *etm, /* Use metadata to fill in trace parameters for trace decoder */ t_params = zalloc(sizeof(*t_params) * etm->num_cpu); for (i = 0; i < etm->num_cpu; i++) { - t_params[i].protocol = CS_ETM_PROTO_ETMV4i; - t_params[i].etmv4.reg_idr0 = etm->metadata[i][CS_ETMV4_TRCIDR0]; - t_params[i].etmv4.reg_idr1 = etm->metadata[i][CS_ETMV4_TRCIDR1]; - t_params[i].etmv4.reg_idr2 = etm->metadata[i][CS_ETMV4_TRCIDR2]; - t_params[i].etmv4.reg_idr8 = etm->metadata[i][CS_ETMV4_TRCIDR8]; - t_params[i].etmv4.reg_configr = + if (etm->metadata[i][CS_ETM_MAGIC] == __perf_cs_etmv3_magic) { + t_params[i].protocol = CS_ETM_PROTO_ETMV3; + t_params[i].etmv3.reg_ctrl = + etm->metadata[i][CS_ETM_ETMCR]; + t_params[i].etmv3.reg_trc_id = + etm->metadata[i][CS_ETM_ETMTRACEIDR]; + } else if (etm->metadata[i][CS_ETM_MAGIC] == + __perf_cs_etmv4_magic) { + t_params[i].protocol = CS_ETM_PROTO_ETMV4i; + t_params[i].etmv4.reg_idr0 = + etm->metadata[i][CS_ETMV4_TRCIDR0]; + t_params[i].etmv4.reg_idr1 = + etm->metadata[i][CS_ETMV4_TRCIDR1]; + t_params[i].etmv4.reg_idr2 = + etm->metadata[i][CS_ETMV4_TRCIDR2]; + t_params[i].etmv4.reg_idr8 = + etm->metadata[i][CS_ETMV4_TRCIDR8]; + t_params[i].etmv4.reg_configr = etm->metadata[i][CS_ETMV4_TRCCONFIGR]; - t_params[i].etmv4.reg_traceidr = + t_params[i].etmv4.reg_traceidr = etm->metadata[i][CS_ETMV4_TRCTRACEIDR]; + } } /* Set decoder parameters to simply print the trace packets */ @@ -352,15 +365,28 @@ static struct cs_etm_queue *cs_etm__alloc_queue(struct cs_etm_auxtrace *etm, goto out_free; for (i = 0; i < etm->num_cpu; i++) { - t_params[i].protocol = CS_ETM_PROTO_ETMV4i; - t_params[i].etmv4.reg_idr0 = etm->metadata[i][CS_ETMV4_TRCIDR0]; - t_params[i].etmv4.reg_idr1 = etm->metadata[i][CS_ETMV4_TRCIDR1]; - t_params[i].etmv4.reg_idr2 = etm->metadata[i][CS_ETMV4_TRCIDR2]; - t_params[i].etmv4.reg_idr8 = etm->metadata[i][CS_ETMV4_TRCIDR8]; - t_params[i].etmv4.reg_configr = + if (etm->metadata[i][CS_ETM_MAGIC] == __perf_cs_etmv3_magic) { + t_params[i].protocol = CS_ETM_PROTO_ETMV3; + t_params[i].etmv3.reg_ctrl = + etm->metadata[i][CS_ETM_ETMCR]; + t_params[i].etmv3.reg_trc_id = + etm->metadata[i][CS_ETM_ETMTRACEIDR]; + } else if (etm->metadata[i][CS_ETM_MAGIC] == + __perf_cs_etmv4_magic) { + t_params[i].protocol = CS_ETM_PROTO_ETMV4i; + t_params[i].etmv4.reg_idr0 = + etm->metadata[i][CS_ETMV4_TRCIDR0]; + t_params[i].etmv4.reg_idr1 = + etm->metadata[i][CS_ETMV4_TRCIDR1]; + t_params[i].etmv4.reg_idr2 = + etm->metadata[i][CS_ETMV4_TRCIDR2]; + t_params[i].etmv4.reg_idr8 = + etm->metadata[i][CS_ETMV4_TRCIDR8]; + t_params[i].etmv4.reg_configr = etm->metadata[i][CS_ETMV4_TRCCONFIGR]; - t_params[i].etmv4.reg_traceidr = + t_params[i].etmv4.reg_traceidr = etm->metadata[i][CS_ETMV4_TRCTRACEIDR]; + } } /* Set decoder parameters to simply print the trace packets */ From patchwork Thu Dec 6 21:25:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaldo Carvalho de Melo X-Patchwork-Id: 153065 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp11046558ljp; Thu, 6 Dec 2018 13:30:24 -0800 (PST) X-Google-Smtp-Source: AFSGD/UiWDlBG2XEwuXRrS9sQC9mXv3YRhnaQtwaPlpy0VXUielrEeZG8DFCNTbkAuUm+rsJJ471 X-Received: by 2002:a63:a84a:: with SMTP id i10mr25918460pgp.263.1544131824176; Thu, 06 Dec 2018 13:30:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544131824; cv=none; d=google.com; s=arc-20160816; b=yvF92NULPBXmfS8wrTNa55WL1c6PixjuKkUHmJ1URWjD2zi/FLRdiHFoN+vbkd0hGo ef8g3PQIPlkB4qVlk6kByyVnk46Fk3aeg76QA6NchP/puC6XjRrXkjlCdba3A3/1YyAT 7wBwEhc3c151S1gx6+sJTs2kQ1NVkt8j1aOHQUdyR8ywVHMrbMmvHRntiIZlWxmrvrMo b5DqxuSVRaUb0WFvSzQh9K/OPKgrn1+WZJnZIqH5vYmsCQnw2nl3UyhlTZ8AyCa3cDt+ kAN+fivpQr35agzLJmZp+VwE+l7c+1DRPUsHmZQCYwR/+NKSpzWltdsgDiSBbNkiHlaL wjVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=rzdEyahUnp1vw8KttHml6c5zxLeLoKgIioNfhfFl09k=; b=O68ujJ2pSxtjImzwnKmCkiJXF+Oha6sZ5VMO4J72QfqPPdY4QSzyu+abM5/JNJUn8+ IHYYmbCARzd5LFzSipZaeTZGn33db611GUTqglLirurnK1PLUI0kdOnIhERxNO/p9deC tfA7x5TKf46YnhkW3PYh4BFENtE8YzuAnJra0AwKc3sc19e2qLZdWDQvbbukWZ275QC3 XnC8rkQ4ypKtANZ6N+8NpuOjXMUCnTJBZ9tlhoGGlVUbkKYWYS2peqDdQm9IDaJ6fVuG tNyjFb6We2Au5BqNMkh81/aYexv8I9ZXyuqPDLU5Z9KEXMGT5IJunfWd0BdtluwtVtRr itWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Q6Hg8r6V; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s35si1092177pgk.392.2018.12.06.13.30.23; Thu, 06 Dec 2018 13:30:24 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Q6Hg8r6V; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726723AbeLFVaW (ORCPT + 31 others); Thu, 6 Dec 2018 16:30:22 -0500 Received: from mail.kernel.org ([198.145.29.99]:48712 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726461AbeLFVaU (ORCPT ); Thu, 6 Dec 2018 16:30:20 -0500 Received: from quaco.ghostprotocols.net (179.187.13.223.dynamic.adsl.gvt.net.br [179.187.13.223]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7BC342082B; Thu, 6 Dec 2018 21:30:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544131819; bh=AIgtURRIhEtOHGMPeP9Ir9TKedr2M3hpVEkium/Fg/c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q6Hg8r6VTSfoLnBybixm90UGNO4cVzUJ7BVfM4ph3qucuwDpmQzuHDr7ARfgdF0wc mNpslVs/nHanGa3vC5s1qUm4Hcs4ua+RZo9eXE8OjN4J9yqZMRC4/xSdVX3nFmL9E3 9RcmUqN2Y4SnfEUTKpXWyJ6cNRN8tA/+xENFlLmg= From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Mathieu Poirier , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Peter Zijlstra , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, Arnaldo Carvalho de Melo Subject: [PATCH 58/75] perf cs-etm: Add support for ETMv3 trace decoding Date: Thu, 6 Dec 2018 18:25:45 -0300 Message-Id: <20181206212602.20474-59-acme@kernel.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181206212602.20474-1-acme@kernel.org> References: <20181206212602.20474-1-acme@kernel.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mathieu Poirier Add support for the creation of packet printer and decoder for the ETMv3 trace architecture. That way traces generated by tracers adhering to that trace protocol can be handled properly by the perf infrastructure. Signed-off-by: Mathieu Poirier Cc: Alexander Shishkin Cc: Jiri Olsa Cc: Namhyung Kim Cc: Peter Zijlstra Cc: coresight@lists.linaro.org Cc: linux-arm-kernel@lists.infradead.org Link: http://lkml.kernel.org/r/1543955944-10042-3-git-send-email-mathieu.poirier@linaro.org Signed-off-by: Arnaldo Carvalho de Melo --- .../perf/util/cs-etm-decoder/cs-etm-decoder.c | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) -- 2.19.2 diff --git a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c index 5efb616bd609..952d1f43f3fa 100644 --- a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c +++ b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c @@ -116,6 +116,19 @@ int cs_etm_decoder__get_packet(struct cs_etm_decoder *decoder, return 1; } +static int cs_etm_decoder__gen_etmv3_config(struct cs_etm_trace_params *params, + ocsd_etmv3_cfg *config) +{ + config->reg_idr = params->etmv3.reg_idr; + config->reg_ctrl = params->etmv3.reg_ctrl; + config->reg_ccer = params->etmv3.reg_ccer; + config->reg_trc_id = params->etmv3.reg_trc_id; + config->arch_ver = ARCH_V7; + config->core_prof = profile_CortexA; + + return 0; +} + static void cs_etm_decoder__gen_etmv4_config(struct cs_etm_trace_params *params, ocsd_etmv4_cfg *config) { @@ -237,10 +250,16 @@ cs_etm_decoder__create_etm_packet_printer(struct cs_etm_trace_params *t_params, struct cs_etm_decoder *decoder) { const char *decoder_name; + ocsd_etmv3_cfg config_etmv3; ocsd_etmv4_cfg trace_config_etmv4; void *trace_config; switch (t_params->protocol) { + case CS_ETM_PROTO_ETMV3: + cs_etm_decoder__gen_etmv3_config(t_params, &config_etmv3); + decoder_name = OCSD_BUILTIN_DCD_ETMV3; + trace_config = &config_etmv3; + break; case CS_ETM_PROTO_ETMV4i: cs_etm_decoder__gen_etmv4_config(t_params, &trace_config_etmv4); decoder_name = OCSD_BUILTIN_DCD_ETMV4I; @@ -427,11 +446,17 @@ static int cs_etm_decoder__create_etm_packet_decoder( struct cs_etm_decoder *decoder) { const char *decoder_name; + ocsd_etmv3_cfg config_etmv3; ocsd_etmv4_cfg trace_config_etmv4; void *trace_config; u8 csid; switch (t_params->protocol) { + case CS_ETM_PROTO_ETMV3: + cs_etm_decoder__gen_etmv3_config(t_params, &config_etmv3); + decoder_name = OCSD_BUILTIN_DCD_ETMV3; + trace_config = &config_etmv3; + break; case CS_ETM_PROTO_ETMV4i: cs_etm_decoder__gen_etmv4_config(t_params, &trace_config_etmv4); decoder_name = OCSD_BUILTIN_DCD_ETMV4I; From patchwork Thu Dec 6 21:25:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaldo Carvalho de Melo X-Patchwork-Id: 153066 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp11046633ljp; Thu, 6 Dec 2018 13:30:29 -0800 (PST) X-Google-Smtp-Source: AFSGD/XlNcvFpmwD8xs5qjXKiWJBaaIThll9K16SLsT7jfdILgW6GJBgpJMXmx03+u9rZLDcytQe X-Received: by 2002:a63:c10f:: with SMTP id w15mr25190156pgf.199.1544131829336; Thu, 06 Dec 2018 13:30:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544131829; cv=none; d=google.com; s=arc-20160816; b=Lq3UDh74nhwUUiBOWcWiiEie3gMtND38Vj44CURaaxafywYi9kPIpCX/w4Ae4IBGYD EMzlm7BGurC8b/YgyWB0pBBC95tddxr+t0fVLZUJeEFaVkNW1JOTvG7nDo3oU48LFSpF eiYoewS0qsOKMkVNEXed0NrpVP8EmRTjvQ2It+SOoObtkp55+UdV4iT4cDdUR+tv0Ajq fDsBTWQNbRyJ2RnQnAmtNYBv3wtItD9RKljyuTBFbXVQbyk83HWMrduqgXUxqPw+2nQC W5WszEow94IQEzINhMmEUAQsHWwtDhgqo7lfC+9AgKnRYtD6LMnru223Gb2SVnTI5eV3 E3FQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=3yw3T3X+I8KSwfRwMbWWrwn8+hgMrdcQkRf00135gjw=; b=uPkVveIkkLnnv3twcAhMfPiVqmc3ADDZEGZ/xOlpvwpzcgucTEk+ZbsByQHptwJuuw k3/AmADkDQQm1gGyOuI/r+Sp81S6ColS53Iw+7cXdnCrQY6FlKxrS6q8m1NGEqxBcQGl ZyhnWA6h4X6jaWRvSadsiS7ndtu0SAib2W7Z/NA5dl5r0NaXZTcMeKO7GArfLXClnoTy kzUPsx+hIDXJhwQ+N9fye66J8nGkbNV9Kp4Nu5OWTnKRF2YnPoo6H4TYdSSCO0VyNUTy ttm4A7L6bmjJU/aLvUYN3fKxPC8vWluCDTO/o8jyT7RV8x0ZV1iXR9uh/TSTgu0/hBsh DNfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kUKaAUv5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e7si1020061pgv.499.2018.12.06.13.30.29; Thu, 06 Dec 2018 13:30:29 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kUKaAUv5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726733AbeLFVa1 (ORCPT + 31 others); Thu, 6 Dec 2018 16:30:27 -0500 Received: from mail.kernel.org ([198.145.29.99]:48766 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726125AbeLFVaY (ORCPT ); Thu, 6 Dec 2018 16:30:24 -0500 Received: from quaco.ghostprotocols.net (179.187.13.223.dynamic.adsl.gvt.net.br [179.187.13.223]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C50D1208E7; Thu, 6 Dec 2018 21:30:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544131823; bh=Pp1BSJqGnr8Zlu4LoVIpB9sL2Ft59alVyavz5fTV3dI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kUKaAUv5n2GHvd3fDyF1AtZ70d0ITdFyp49lne2ILHuAyX+6ysq7+44cCz+yLmPOI NTMdfkLIMtIz+EZe+DQTQyBlsZhvrXwpk3IA9HRIwS00icgBgSL2rXSBdUgfIShmEm W34bWijZHTI8nWgfDHaKKXFAU6IHgrHX2GUGYl7A= From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Mathieu Poirier , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Peter Zijlstra , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, Arnaldo Carvalho de Melo Subject: [PATCH 59/75] perf cs-etm: Add support for PTMv1.1 decoding Date: Thu, 6 Dec 2018 18:25:46 -0300 Message-Id: <20181206212602.20474-60-acme@kernel.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181206212602.20474-1-acme@kernel.org> References: <20181206212602.20474-1-acme@kernel.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mathieu Poirier This patch is re-using the mechanic set forth by ETMv3 to add support for PTM decoding. Configuration for both encoding protocol is similar but the generated stream itself is very different, hence requiring special handling. Signed-off-by: Mathieu Poirier Cc: Alexander Shishkin Cc: Jiri Olsa Cc: Namhyung Kim Cc: Peter Zijlstra Cc: coresight@lists.linaro.org Cc: linux-arm-kernel@lists.infradead.org Link: http://lkml.kernel.org/r/1543955944-10042-4-git-send-email-mathieu.poirier@linaro.org Signed-off-by: Arnaldo Carvalho de Melo --- .../perf/util/cs-etm-decoder/cs-etm-decoder.c | 10 ++++++-- .../perf/util/cs-etm-decoder/cs-etm-decoder.h | 1 + tools/perf/util/cs-etm.c | 23 +++++++++++++++++-- 3 files changed, 30 insertions(+), 4 deletions(-) -- 2.19.2 diff --git a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c index 952d1f43f3fa..0b4c8629f578 100644 --- a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c +++ b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c @@ -256,8 +256,11 @@ cs_etm_decoder__create_etm_packet_printer(struct cs_etm_trace_params *t_params, switch (t_params->protocol) { case CS_ETM_PROTO_ETMV3: + case CS_ETM_PROTO_PTM: cs_etm_decoder__gen_etmv3_config(t_params, &config_etmv3); - decoder_name = OCSD_BUILTIN_DCD_ETMV3; + decoder_name = (t_params->protocol == CS_ETM_PROTO_ETMV3) ? + OCSD_BUILTIN_DCD_ETMV3 : + OCSD_BUILTIN_DCD_PTM; trace_config = &config_etmv3; break; case CS_ETM_PROTO_ETMV4i: @@ -453,8 +456,11 @@ static int cs_etm_decoder__create_etm_packet_decoder( switch (t_params->protocol) { case CS_ETM_PROTO_ETMV3: + case CS_ETM_PROTO_PTM: cs_etm_decoder__gen_etmv3_config(t_params, &config_etmv3); - decoder_name = OCSD_BUILTIN_DCD_ETMV3; + decoder_name = (t_params->protocol == CS_ETM_PROTO_ETMV3) ? + OCSD_BUILTIN_DCD_ETMV3 : + OCSD_BUILTIN_DCD_PTM; trace_config = &config_etmv3; break; case CS_ETM_PROTO_ETMV4i: diff --git a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h index 6b5525410a43..b295dd2b8292 100644 --- a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h +++ b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h @@ -96,6 +96,7 @@ enum { CS_ETM_PROTO_ETMV3 = 1, CS_ETM_PROTO_ETMV4i, CS_ETM_PROTO_ETMV4d, + CS_ETM_PROTO_PTM, }; enum { diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index 76e509c32a28..23159c33db2a 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -83,6 +83,19 @@ static int cs_etm__update_queues(struct cs_etm_auxtrace *etm); static int cs_etm__process_timeless_queues(struct cs_etm_auxtrace *etm, pid_t tid, u64 time_); +/* PTMs ETMIDR [11:8] set to b0011 */ +#define ETMIDR_PTM_VERSION 0x00000300 + +static u32 cs_etm__get_v7_protocol_version(u32 etmidr) +{ + etmidr &= ETMIDR_PTM_VERSION; + + if (etmidr == ETMIDR_PTM_VERSION) + return CS_ETM_PROTO_PTM; + + return CS_ETM_PROTO_ETMV3; +} + static void cs_etm__packet_dump(const char *pkt_string) { const char *color = PERF_COLOR_BLUE; @@ -115,7 +128,10 @@ static void cs_etm__dump_event(struct cs_etm_auxtrace *etm, t_params = zalloc(sizeof(*t_params) * etm->num_cpu); for (i = 0; i < etm->num_cpu; i++) { if (etm->metadata[i][CS_ETM_MAGIC] == __perf_cs_etmv3_magic) { - t_params[i].protocol = CS_ETM_PROTO_ETMV3; + u32 etmidr = etm->metadata[i][CS_ETM_ETMIDR]; + + t_params[i].protocol = + cs_etm__get_v7_protocol_version(etmidr); t_params[i].etmv3.reg_ctrl = etm->metadata[i][CS_ETM_ETMCR]; t_params[i].etmv3.reg_trc_id = @@ -366,7 +382,10 @@ static struct cs_etm_queue *cs_etm__alloc_queue(struct cs_etm_auxtrace *etm, for (i = 0; i < etm->num_cpu; i++) { if (etm->metadata[i][CS_ETM_MAGIC] == __perf_cs_etmv3_magic) { - t_params[i].protocol = CS_ETM_PROTO_ETMV3; + u32 etmidr = etm->metadata[i][CS_ETM_ETMIDR]; + + t_params[i].protocol = + cs_etm__get_v7_protocol_version(etmidr); t_params[i].etmv3.reg_ctrl = etm->metadata[i][CS_ETM_ETMCR]; t_params[i].etmv3.reg_trc_id =