From mboxrd@z Thu Jan 1 00:00:00 1970 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=-9.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 C4E2EC433DB for ; Sun, 10 Jan 2021 01:43:49 +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 7E8492389B for ; Sun, 10 Jan 2021 01:43:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7E8492389B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org 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:In-Reply-To:MIME-Version:References: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:List-Owner; bh=+N2oXmNp3Lxd9PwgHbcAhSAZ8TAoCGAPeQ6FPxp1qCc=; b=xzZFJasknnLo9zh41TQwrPt/9 98gXeR43y+tfk2SOJTEY8uaCT0QX3InNn5S6p86Vpfou7xcxdimhPmKYda+TZfrqpAmi7PQfxUKsg 1PLrEiNtzJzSTdXs87Pe3SGZf/8mcqgnVrHxCvrEV1ESOc+K3kiA3/Oe4iXaK35tJ0u8reAPibVMK YBo19CL5VvtgInAWno7aQVryd4n72MHNq/SIkmeZJO802KxC0gIle+0aYpyLsFxDyUs6g2JvUrMgH 31FuDVnwtA0LbGelCf3sIYxLH6Vfdvnt0e8ei/R08smO2VEijEb9pB+GO4hhYXR4Ye+Sb6PbDDBAf /zkQ/+ppA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kyPjp-0006wP-SB; Sun, 10 Jan 2021 01:41:49 +0000 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kyPjm-0006vD-1V for linux-arm-kernel@lists.infradead.org; Sun, 10 Jan 2021 01:41:48 +0000 Received: by mail-pf1-x436.google.com with SMTP id a188so8743823pfa.11 for ; Sat, 09 Jan 2021 17:41:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=kX5HkKe+fqKkNrQ53S/utmlgPxcfxCQK7L32nTJ5eSk=; b=mqvAe1rEMJCUwdYbOBkQNVCeXCPzHA52UC21TV/TwNNBLddnwRrz6QFDM8IUjfwusD WZWTw5NXqshKmqrHc0M0RAzzHl5CCMDlRLclwZcesNe0v7o2D4RK2GiVI0+Br8sFZ285 1j4ZcMmohXg5oxGh6HzPUswYOItddCmOPT5KfvvWFD3dlHNWmRc+BW2nLXITpEsaEGXY woxHXNJLPeBUDE5fohY7uKOytjMGITrlEtjfwq4Y2pNl7WK5lF5dW1e/G7kjkGbhhTw8 u81hbbfkZ7C/yMr0nM4HVBDiKH9cHIrOizwJP2wMWFd6sauHPHGcreAlXYiN8j/t88P5 4MPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=kX5HkKe+fqKkNrQ53S/utmlgPxcfxCQK7L32nTJ5eSk=; b=AymzSZIV/L/EDYlThPJqDO6rvYfvAiWr/qdDk2TFOwOCMaTUUiJuEBJSCczUQhkATJ QUfUR+ED4NIge2uVzL1o4naYJnCj/fPM7+2eGFIQeCVU2JAyMUgDi75DSWnQ4hutSbsi SL3uLx4mP3KXDUgA6FeZvGuYoC5wsEiugHtuqR8B4TWaJY0EupsWyYq9kH+upy8nZ9el a9JAonJWjpmKnSGf7r5x5r7skx4PwDliivMfkIkQl0mv4LkJTq5Qiol6BRfFBU7cVNWk h+kFpDYI3ZSZ7cUdEo5cnNQJ4AhKpDjQYCrp051e/9QyIs8EtRO+I7kkpb9z9t+j9DrY o7Wg== X-Gm-Message-State: AOAM532LfPMGhalB3/EtcNyuGMna6gYFV6F2brshHmomN4iTo5u2hdT/ EROmcEPPmjzPMLv6qI72ZN8kWw== X-Google-Smtp-Source: ABdhPJxICydKftJl1mt1C4rhPwqaNs5xpy5/VREYr4SZDE+V9RMZqJGQpPGLNoAd7cQa8urPTZhC7w== X-Received: by 2002:a63:d650:: with SMTP id d16mr13782482pgj.277.1610242903029; Sat, 09 Jan 2021 17:41:43 -0800 (PST) Received: from leoy-ThinkPad-X240s ([84.17.45.149]) by smtp.gmail.com with ESMTPSA id x10sm13216991pff.214.2021.01.09.17.41.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Jan 2021 17:41:42 -0800 (PST) Date: Sun, 10 Jan 2021 09:41:33 +0800 From: Leo Yan To: Suzuki K Poulose Subject: Re: [PATCH] coresight: etm-perf: Add support for PID tracing for kernel at EL2 Message-ID: <20210110014133.GA3776@leoy-ThinkPad-X240s> References: <202101091731.R1nMP6tg-lkp@intel.com> <20210110012430.1874799-1-suzuki.poulose@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210110012430.1874799-1-suzuki.poulose@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210109_204146_857614_927C9B9D X-CRM114-Status: GOOD ( 19.42 ) 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: mark.rutland@arm.com, Al Grant , lkp@intel.com, mathieu.poirier@linaro.org, alexander.shishkin@linux.intel.com, coresight@lists.linaro.org, john.garry@huawei.com, acme@kernel.org, peterz@infradead.org, mingo@redhat.com, will@kernel.org, linux-arm-kernel@lists.infradead.org, mike.leach@linaro.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Suzuki, On Sun, Jan 10, 2021 at 01:24:30AM +0000, Suzuki Kuruppassery Poulose wrote: [...] > +static ssize_t format_attr_pid_show(struct device *dev, > + struct device_attribute *attr, > + char *page) > +{ > + int pid_fmt = ETM_OPT_CTXTID; > + > +#ifdef CONFIG_CORESIGHT_SOURCE_ETM4X > + if (is_kernel_in_hyp_mode()) > + pid_fmt = ETM_OPT_CTXTID_IN_VMID; > +#endif I have a different idea for this. As Armv8 Arm describes: "The Virtualization Host Extensions only apply to an implementation that includes EL2 using AArch64.", seems to me it's more reasable to use the condition "#ifdef CONFIG_64BIT", like below: #ifdef CONFIG_64BIT if (is_kernel_in_hyp_mode()) pid_fmt = ETM_OPT_CTXTID_IN_VMID; #endif Please let me know if this is better or not. I will resend the patch series after agreement. Thanks, Leo > + return sprintf(page, "config:%d\n", pid_fmt); > +} > + > +struct device_attribute format_attr_pid = __ATTR(pid, 0444, format_attr_pid_show, NULL); > + > static struct attribute *etm_config_formats_attr[] = { > &format_attr_cycacc.attr, > &format_attr_contextid.attr, > + &format_attr_contextid_in_vmid.attr, > + &format_attr_pid.attr, > &format_attr_timestamp.attr, > &format_attr_retstack.attr, > &format_attr_sinkid.attr, > diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c > index b20b6ff17cf6..8b7c7a8b2874 100644 > --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c > +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c > @@ -477,6 +477,15 @@ static int etm4_parse_event_config(struct etmv4_drvdata *drvdata, > /* bit[6], Context ID tracing bit */ > config->cfg |= BIT(ETM4_CFG_BIT_CTXTID); > > + /* Do not enable VMID tracing if we are not running in EL2 */ > + if (attr->config & BIT(ETM_OPT_CTXTID_IN_VMID)) { > + if (!is_kernel_in_hyp_mode()) { > + ret = -EINVAL; > + goto out; > + } > + config->cfg |= BIT(ETM4_CFG_BIT_VMID) | BIT(ETM4_CFG_BIT_VMID_OPT); > + } > + > /* return stack - enable if selected and supported */ > if ((attr->config & BIT(ETM_OPT_RETSTK)) && drvdata->retstack) > /* bit[12], Return stack enable bit */ > diff --git a/include/linux/coresight-pmu.h b/include/linux/coresight-pmu.h > index b0e35eec6499..927c6285ce5d 100644 > --- a/include/linux/coresight-pmu.h > +++ b/include/linux/coresight-pmu.h > @@ -11,16 +11,19 @@ > #define CORESIGHT_ETM_PMU_SEED 0x10 > > /* ETMv3.5/PTM's ETMCR config bit */ > -#define ETM_OPT_CYCACC 12 > -#define ETM_OPT_CTXTID 14 > -#define ETM_OPT_TS 28 > -#define ETM_OPT_RETSTK 29 > +#define ETM_OPT_CYCACC 12 > +#define ETM_OPT_CTXTID 14 > +#define ETM_OPT_CTXTID_IN_VMID 15 > +#define ETM_OPT_TS 28 > +#define ETM_OPT_RETSTK 29 > > /* ETMv4 CONFIGR programming bits for the ETM OPTs */ > #define ETM4_CFG_BIT_CYCACC 4 > #define ETM4_CFG_BIT_CTXTID 6 > +#define ETM4_CFG_BIT_VMID 7 > #define ETM4_CFG_BIT_TS 11 > #define ETM4_CFG_BIT_RETSTK 12 > +#define ETM4_CFG_BIT_VMID_OPT 15 > > static inline int coresight_get_trace_id(int cpu) > { > -- > 2.24.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel