Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2474201imm; Mon, 24 Sep 2018 05:07:40 -0700 (PDT) X-Google-Smtp-Source: ACcGV61QcHKKptNJEsUgozVggc5vGYo2E/5WT2qZrWFFyCBZr4wFo71+D0+PDdveFf8rmjmJHHkV X-Received: by 2002:a17:902:be06:: with SMTP id r6-v6mr2207166pls.32.1537790860506; Mon, 24 Sep 2018 05:07:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537790860; cv=none; d=google.com; s=arc-20160816; b=Z2YR1VPEnTjjqgHXP0vQTuavP0yGwV+4h0MugSTuGP4DKRTylebXjSipzQSGUuFisi D25SpfqM3OLrLSg75AjSqwk/DrQteypWL4swTut0hZm6JtybuyECCBtXcEh/JTGwfclp elhZKSqy3G2gpuuoTjtbl0WiT7V/FMGstGhN0qxKUNmyXo+bQJPjDz7DjeD+grVGtm8p 7QZ42IjiWeFlZi6/1TaJOTK0qxq9nf87KCHA8XbFYitVbdaIQqy2mCBBCBmLnZZPJ8mE kiIxOgcuv6lunz1Og+igVWs7cxyPeomF+u0oOLATLdbgtDMdN00Hk1u7re6LUQO+AaOH aT1w== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=3usEE0xnXrHPiaTGxQOsMpWHj7zOfo9ssgH11fH0Xho=; b=BUJc0xzdb7QKs523ANhSy4lQhFhCjrg606aJzQZOS8Yf7l1ItX72rwoT4oTlAeAQUo XIJRsf3VQpEr+Bae28olmTsR8XsTDbNv1UZEVnCdkigCxrblO7frSPX1iC59rhTVxrmL TmzCIj/C2bPjGrZCSVA442Mung5JvRFSkdW2tT9tDefOx7ztwQkCN0Zt7HWeG3kNe5fS L66bdjPsmxuoQdctltvOtIuP37kohtD93l0ZDV7ZN/qM5cy9+c+auo1g47Yqx+1CRZUi H27TW98QOlwuWh4cZ5kMYGooQD3uJiZB0dEmu4pkmGwwvzV+CXl8Npspob/dKgBBuBps xI/A== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y6-v6si34311230pgr.684.2018.09.24.05.07.25; Mon, 24 Sep 2018 05:07:40 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731124AbeIXSIK (ORCPT + 99 others); Mon, 24 Sep 2018 14:08:10 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:54080 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730438AbeIXSIJ (ORCPT ); Mon, 24 Sep 2018 14:08:09 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id B5A8C1080; Mon, 24 Sep 2018 12:06:21 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Robert Walker , Mike Leach , Mathieu Poirier , Robin Murphy , Sasha Levin Subject: [PATCH 4.9 089/111] coresight: tpiu: Fix disabling timeouts Date: Mon, 24 Sep 2018 13:52:56 +0200 Message-Id: <20180924113113.629916119@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180924113103.337261320@linuxfoundation.org> References: <20180924113103.337261320@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Robin Murphy [ Upstream commit ccff2dfaceaca4517432f5c149594215fe9098cc ] Probing the TPIU driver under UBSan triggers an out-of-bounds shift warning in coresight_timeout(): ... [ 5.677530] UBSAN: Undefined behaviour in drivers/hwtracing/coresight/coresight.c:929:16 [ 5.685542] shift exponent 64 is too large for 64-bit type 'long unsigned int' ... On closer inspection things are exponentially out of whack because we're passing a bitmask where a bit number should be. Amusingly, it seems that both calls will find their expected values by sheer luck and appear to succeed: 1 << FFCR_FON_MAN ends up at bit 64 which whilst undefined evaluates as zero in practice, while 1 << FFSR_FT_STOPPED finds bit 2 (TCPresent) which apparently is usually tied high. Following the examples of other drivers, define separate FOO and FOO_BIT macros for masks vs. indices, and put things right. CC: Robert Walker CC: Mike Leach CC: Mathieu Poirier Fixes: 11595db8e17f ("coresight: Fix disabling of CoreSight TPIU") Signed-off-by: Robin Murphy Signed-off-by: Mathieu Poirier Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/hwtracing/coresight/coresight-tpiu.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) --- a/drivers/hwtracing/coresight/coresight-tpiu.c +++ b/drivers/hwtracing/coresight/coresight-tpiu.c @@ -47,8 +47,9 @@ /** register definition **/ /* FFSR - 0x300 */ -#define FFSR_FT_STOPPED BIT(1) +#define FFSR_FT_STOPPED_BIT 1 /* FFCR - 0x304 */ +#define FFCR_FON_MAN_BIT 6 #define FFCR_FON_MAN BIT(6) #define FFCR_STOP_FI BIT(12) @@ -93,9 +94,9 @@ static void tpiu_disable_hw(struct tpiu_ /* Generate manual flush */ writel_relaxed(FFCR_STOP_FI | FFCR_FON_MAN, drvdata->base + TPIU_FFCR); /* Wait for flush to complete */ - coresight_timeout(drvdata->base, TPIU_FFCR, FFCR_FON_MAN, 0); + coresight_timeout(drvdata->base, TPIU_FFCR, FFCR_FON_MAN_BIT, 0); /* Wait for formatter to stop */ - coresight_timeout(drvdata->base, TPIU_FFSR, FFSR_FT_STOPPED, 1); + coresight_timeout(drvdata->base, TPIU_FFSR, FFSR_FT_STOPPED_BIT, 1); CS_LOCK(drvdata->base); }