From patchwork Wed Aug 19 21:10:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Leach X-Patchwork-Id: 11725053 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 11F45618 for ; Wed, 19 Aug 2020 21:11: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 DA38C207DE for ; Wed, 19 Aug 2020 21:11:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="jmaWE8uX"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="MQKiWuZ6" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DA38C207DE 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+patchwork-linux-arm=patchwork.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:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=KM0ttL1dmkuLq/9kVgXCcEqtftz3WNTos/pymR0cpe8=; b=jmaWE8uXKi07MaaplvUYs9HWZR 59YfjDjfTMxmXid2sU/dds5M6lF2a46Yn1lBlAtRZ6tceliFwcYoUHboEMhHXKmD0SAgjbI335NrI krjmAXQ2vChZJ9TNoXLsvesPdFsCIAuayGDwFk/+hT09Q0V3LbERuH9mE0VepiANZS5HBSAsmBo4p 95rNm6UjFucg0YHMvBB8eJC365bYWtnmMYmDeO5FRjhsH8VyMMf4bL3N3/0KLtsOZkgsVOhlE2x5E Rr1K8fAHO8Lg3pviJfCBQ6fjaOw+DRGzvlVYrif+AtjdEG4TfP+NTdN/VlcF2SOY/Y6iIUUnMt4fe xRBaAMvQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k8VLk-00066A-7x; Wed, 19 Aug 2020 21:10:24 +0000 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k8VLf-00061q-N4 for linux-arm-kernel@lists.infradead.org; Wed, 19 Aug 2020 21:10:20 +0000 Received: by mail-wm1-x341.google.com with SMTP id 9so3395070wmj.5 for ; Wed, 19 Aug 2020 14:10:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=G7Mg0DKR8Y9o8OGWneFqNN2tq4b7ccK2Vw39luxO/dA=; b=MQKiWuZ6vNFi1O6AQv0tAjYIuroxTGDnWP9bkxA642eB0UXSuV2hEgrMcBXcgoreOq E58APHzF+jmNZFSluVya9Otymc2IXDTnbg00hVPnB7CMWbkXlLpG4wI8LjkWPFN1RXmm nQ8VmyIglLp4y+/1YVddbcs+jbOx9YLNsKUnxgVlz3IzbheenZJvidI9FGPzSTJ/N0/Q sqMb8TeZ1Ayjj309/vRJTDFcA+nZAY4RtfHlz5Ce8KluOa/eBM2hHo7QWGeibuscAzVN Mdd3mAQ8JvJTQ6nUQ4b5uZ22hkH4t38dP9dGKYaWxsEK21ApevusJJz+gOUT+r8QVx31 YPIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=G7Mg0DKR8Y9o8OGWneFqNN2tq4b7ccK2Vw39luxO/dA=; b=T8p/ES8o4+I4HKYjAYleXbdIEaw5/lr6ivX2KzRdjaCc979UjJg833mfuEa/GT/qBY 3YhP+5yvnqJU/b7aW/3jbYZzuS0gsRUDfC+GIKF7ZkgJiKfgZE3WZzQC422O1Nx3024T YPVzQYLQEevmwIR5+zQn15+qPWEwAH+2zO+lkxq0wXcagkkkllYKQxB5AMJHkgCHTCvg TLwbTTJNThU0IhSOtROWhQ/fWbg4qqGUelHLJdoOeZZsaG31A7Cp19PWo+GC0INN7I0e I8kGE/EDhOsZ2Q78pCqzcroIa9imjGCvZvRhq4AsYjsl6E579Xsg4oq6pv8Tiw5oqc72 x93Q== X-Gm-Message-State: AOAM5311InQoWC/+Abr3Pwv8h2dNqQZCMTOcUPKjW5i6gyL0GEyXyDmw NWu2k0bwadKVI5+4s3lyMs81nJwMNLOoqQ== X-Google-Smtp-Source: ABdhPJxjh1g4x9M3lcHeWiS3Kl1WLTVxdGH8I7li2qJ0/YoIdZ5tldLmLqCRNxgC5U9I3WCfBkYLZA== X-Received: by 2002:a7b:c35a:: with SMTP id l26mr189598wmj.42.1597871418365; Wed, 19 Aug 2020 14:10:18 -0700 (PDT) Received: from linaro.org ([2a00:23c5:6801:1801:cd32:959f:4432:132a]) by smtp.gmail.com with ESMTPSA id x11sm135646wrl.28.2020.08.19.14.10.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Aug 2020 14:10:17 -0700 (PDT) From: Mike Leach To: linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org, mathieu.poirier@linaro.org, leo.yan@linaro.org Subject: [PATCH v2 1/1] coresight: etm4x: Ensure default perf settings filter user/kernel Date: Wed, 19 Aug 2020 22:10:15 +0100 Message-Id: <20200819211015.28448-2-mike.leach@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200819211015.28448-1-mike.leach@linaro.org> References: <20200819211015.28448-1-mike.leach@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200819_171019_777759_06B0AA4A X-CRM114-Status: GOOD ( 17.46 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:341 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 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: Mike Leach , suzuki.poulose@arm.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Moving from using an address filter to trace the default "all addresses" range to no filtering to acheive the same result, has caused the perf filtering of kernel/user address spaces from not working unless an explicit address filter was used. This is due to the original code using a side-effect of the address filtering rather than setting the global TRCVICTLR exception level filtering. The use of the mode sysfs file is also similarly affected. A helper function is added to fix both instances. Fixes: ae2041510d5d5 ("coresight: etmv4: Update default filter and initialisation") Reported-by: Leo Yan Signed-off-by: Mike Leach Reviewed-by: Leo Yan Tested-by: Leo Yan --- drivers/hwtracing/coresight/coresight-etm4x.c | 32 +++++++++++++------ drivers/hwtracing/coresight/coresight-etm4x.h | 3 ++ 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etm4x.c b/drivers/hwtracing/coresight/coresight-etm4x.c index 8b0634ebef77..522ff5418a35 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x.c +++ b/drivers/hwtracing/coresight/coresight-etm4x.c @@ -52,6 +52,7 @@ static struct etmv4_drvdata *etmdrvdata[NR_CPUS]; static void etm4_set_default_config(struct etmv4_config *config); static int etm4_set_event_filters(struct etmv4_drvdata *drvdata, struct perf_event *event); +static u64 etm4_get_access_type(struct etmv4_config *config); static enum cpuhp_state hp_online; @@ -783,6 +784,22 @@ static void etm4_init_arch_data(void *info) CS_LOCK(drvdata->base); } +/* Set ELx trace filter access in the TRCVICTLR register */ +static void etm4_set_victlr_access(struct etmv4_config *config) +{ + u64 access_type; + + config->vinst_ctrl &= ~(ETM_EXLEVEL_S_VICTLR_MASK | ETM_EXLEVEL_NS_VICTLR_MASK); + + /* + * TRCVICTLR::EXLEVEL_NS:EXLEVELS: Set kernel / user filtering + * bits in vinst_ctrl, same bit pattern as TRCACATRn values returned by + * etm4_get_access_type() but with a relative shift in this register. + */ + access_type = etm4_get_access_type(config) << ETM_EXLEVEL_LSHIFT_TRCVICTLR; + config->vinst_ctrl |= (u32)access_type; +} + static void etm4_set_default_config(struct etmv4_config *config) { /* disable all events tracing */ @@ -800,6 +817,9 @@ static void etm4_set_default_config(struct etmv4_config *config) /* TRCVICTLR::EVENT = 0x01, select the always on logic */ config->vinst_ctrl = BIT(0); + + /* TRCVICTLR::EXLEVEL_NS:EXLEVELS: Set kernel / user filtering */ + etm4_set_victlr_access(config); } static u64 etm4_get_ns_access_type(struct etmv4_config *config) @@ -1064,7 +1084,7 @@ static int etm4_set_event_filters(struct etmv4_drvdata *drvdata, void etm4_config_trace_mode(struct etmv4_config *config) { - u32 addr_acc, mode; + u32 mode; mode = config->mode; mode &= (ETM_MODE_EXCL_KERN | ETM_MODE_EXCL_USER); @@ -1076,15 +1096,7 @@ void etm4_config_trace_mode(struct etmv4_config *config) if (!(mode & ETM_MODE_EXCL_KERN) && !(mode & ETM_MODE_EXCL_USER)) return; - addr_acc = config->addr_acc[ETM_DEFAULT_ADDR_COMP]; - /* clear default config */ - addr_acc &= ~(ETM_EXLEVEL_NS_APP | ETM_EXLEVEL_NS_OS | - ETM_EXLEVEL_NS_HYP); - - addr_acc |= etm4_get_ns_access_type(config); - - config->addr_acc[ETM_DEFAULT_ADDR_COMP] = addr_acc; - config->addr_acc[ETM_DEFAULT_ADDR_COMP + 1] = addr_acc; + etm4_set_victlr_access(config); } static int etm4_online_cpu(unsigned int cpu) diff --git a/drivers/hwtracing/coresight/coresight-etm4x.h b/drivers/hwtracing/coresight/coresight-etm4x.h index b8283e1d6d88..5259f96fd28a 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x.h +++ b/drivers/hwtracing/coresight/coresight-etm4x.h @@ -192,6 +192,9 @@ #define ETM_EXLEVEL_NS_HYP BIT(14) #define ETM_EXLEVEL_NS_NA BIT(15) +/* access level control in TRCVICTLR - same bits as TRCACATRn but shifted */ +#define ETM_EXLEVEL_LSHIFT_TRCVICTLR 8 + /* secure / non secure masks - TRCVICTLR, IDR3 */ #define ETM_EXLEVEL_S_VICTLR_MASK GENMASK(19, 16) /* NS MON (EL3) mode never implemented */