From patchwork Thu Aug 27 04:06:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunyan Zhang X-Patchwork-Id: 7080991 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B38F4BEEC1 for ; Thu, 27 Aug 2015 04:16:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9E0AD20985 for ; Thu, 27 Aug 2015 04:16:29 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B590C208D2 for ; Thu, 27 Aug 2015 04:16:28 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZUoVF-00081K-Uh; Thu, 27 Aug 2015 04:09:29 +0000 Received: from mail-pa0-f49.google.com ([209.85.220.49]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZUoVD-0007zm-3I for linux-arm-kernel@lists.infradead.org; Thu, 27 Aug 2015 04:09:28 +0000 Received: by pacti10 with SMTP id ti10so10720411pac.0 for ; Wed, 26 Aug 2015 21:09:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Q98sX3dIV+xQpOyYbG80f5i2j4Dl5mu9KLb6lrybMFc=; b=FXzDqAZCxR526jMB6HJZE+d2u4GT47y1/ZYiZwi596SS+HADsfPPC8howU97KONis1 +EvXrqZt59TRjOglIG98L5SRpR9Q3l1A5irAXBuzDGZnEea0tn6JgCFx9LI5rPf3PHpy jKz+PpqArzl71OV5ByeAEKDH63qjZflt3kxy+3A3M2w96FdZkOm4woyJmO7pKKOnAQpx qXj2sZtCLfGyB2cMIvZBHU46DSzU6a5BfWrEk2xPM7LCD1ubeTJv8k7ojTRsByLQ7LoK mHtkqmF10FwDHJgR1e42V6LIESSSzkFRioOFW6hBRTegG4cuujnqfFos43DltLpSF1fD /KbA== X-Gm-Message-State: ALoCoQlMfOp6fRzSIWljmqcq1zmWM7mKDx2lBZhFSL1h5MMjtuIWaZ69a1hdEjdGgB8HJWTTuFFw X-Received: by 10.69.11.196 with SMTP id ek4mr3357070pbd.148.1440648543596; Wed, 26 Aug 2015 21:09:03 -0700 (PDT) Received: from zcy-ubuntu.spreadtrum.com ([175.111.195.49]) by smtp.gmail.com with ESMTPSA id kw3sm649498pbc.30.2015.08.26.21.08.59 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 26 Aug 2015 21:09:02 -0700 (PDT) From: Chunyan Zhang To: gregkh@linuxfoundation.org, mathieu.poirier@linaro.org Subject: [PATCH] Coresight: ETMv4: Prevent TRCRSCTLR0&1 from being accessed Date: Thu, 27 Aug 2015 12:06:09 +0800 Message-Id: <1440648369-4614-1-git-send-email-zhang.chunyan@linaro.org> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150826_210927_258219_0566FD00 X-CRM114-Status: GOOD ( 13.77 ) X-Spam-Score: -2.6 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: broonie@kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 1. TRCRSCTLRn - Resource Selection Control Registers n=0~1 are reserved, we shouldn't access them. 2. The max number of 'n' here is defined in TRCIDR4.NUMRSPAIR whoes value indicates the number of resource selection *pairs*, and 0 indicates one resource selection pair, 1 indicates two pairs, and so on ... So, the total number of resource selection control registers which we can access is (TRCIDR4.NUMRSPAIR * 2) Signed-off-by: Chunyan Zhang --- drivers/hwtracing/coresight/coresight-etm4x.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etm4x.c b/drivers/hwtracing/coresight/coresight-etm4x.c index 1312e99..9425249 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x.c +++ b/drivers/hwtracing/coresight/coresight-etm4x.c @@ -136,7 +136,9 @@ static void etm4_enable_hw(void *info) writel_relaxed(drvdata->cntr_val[i], drvdata->base + TRCCNTVRn(i)); } - for (i = 0; i < drvdata->nr_resource; i++) + + /* Resource selector pair 0 is always implemented and reserved */ + for (i = 2; i < (drvdata->nr_resource + 1) * 2; i++) writel_relaxed(drvdata->res_ctrl[i], drvdata->base + TRCRSCTLRn(i)); @@ -489,8 +491,9 @@ static ssize_t reset_store(struct device *dev, drvdata->cntr_val[i] = 0x0; } - drvdata->res_idx = 0x0; - for (i = 0; i < drvdata->nr_resource; i++) + /* Resource selector pair 0 is always implemented and reserved */ + drvdata->res_idx = 0x2; + for (i = 2; i < (drvdata->nr_resource + 1) * 2; i++) drvdata->res_ctrl[i] = 0x0; for (i = 0; i < drvdata->nr_ss_cmp; i++) { @@ -1729,7 +1732,7 @@ static ssize_t res_idx_store(struct device *dev, if (kstrtoul(buf, 16, &val)) return -EINVAL; /* Resource selector pair 0 is always implemented and reserved */ - if ((val == 0) || (val >= drvdata->nr_resource)) + if (val < 2 || val > (drvdata->nr_resource + 1) * 2) return -EINVAL; /* @@ -2498,7 +2501,9 @@ static void etm4_init_default_data(struct etmv4_drvdata *drvdata) drvdata->cntr_val[i] = 0x0; } - for (i = 2; i < drvdata->nr_resource * 2; i++) + /* Resource selector pair 0 is always implemented and reserved */ + drvdata->res_idx = 0x2; + for (i = 2; i < (drvdata->nr_resource + 1) * 2; i++) drvdata->res_ctrl[i] = 0x0; for (i = 0; i < drvdata->nr_ss_cmp; i++) {