Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2512426imm; Mon, 24 Sep 2018 05:43:36 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbmJ9qY/IpsidtcqTWA9vr3hilE8j1EKcuTRoq5t/Cl4t9sqYgrIWw3l5aIcBI5TkiFCZ/O X-Received: by 2002:a62:c699:: with SMTP id x25-v6mr10376541pfk.16.1537793016148; Mon, 24 Sep 2018 05:43:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537793016; cv=none; d=google.com; s=arc-20160816; b=r2k48Xw5J/gyKI6Vb6E4p4t/SUA07aXPk6KBBrJLZjP4wFL/mzOJrXeTOXXi3weTpq 9yMC0YV8wMgguBcFGbB0HxTbaiFq60IWTPcBlqBQWuYshigXO1Z4bimuP5q3LomoyB8o 6fGwpcFbD93KNIUAbz0o8AwKM7giEoU3puWbIR1/41NwWE37o+re/x9PtaOwQ2b70OQv YXu0oqYidJPexzGOaIB/d4sfr619SfFpe4+xpqaBsgktS6a+EqP10+P/rbcJqOJrfXK2 TA7N+aBOfZsXqDnYGNmqAowTyqpO2SYbcqfr5n27ML+RbaSEaaApyIcmY4jB+llHSnMy y2MA== 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=oZu1vi6h7nYXi+cLJ5azQZxmhsCF/jolm7KT016QQxE=; b=XmLJ0Egt1vpYwPURfum2se0KdKWEjRaGajgh2r2AzcUfUHJsBatEIB9j7Vh5nNk5L3 qzESQMej+XRA3uzymc0g7VcyayZrnw6Jm2I6lB2IX56UJP8siXE6I5p3IVQceLbF3dCK FOd9uRDyFzdm/vL7HEHBY4OE4lVvGcWio3/B1KeaQ0mVnu4Nk/EusItRDXg0SisZrKYR Lmn2u8dZ4AVhyl/gDfyQDH4v8V4s1Yo4lpbF4seCmHuE94uCxB4l7lQm6H6Q8cU8Owt/ ji4ZlCx0GFGsxGzPqXvYncpBYc6qugBXTxrFHNEbTBmJr81e2h20xn2drnHmWGLC6yhg mFig== 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 98-v6si6976752pla.59.2018.09.24.05.43.21; Mon, 24 Sep 2018 05:43:36 -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 S2388941AbeIXSo3 (ORCPT + 99 others); Mon, 24 Sep 2018 14:44:29 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:59342 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731786AbeIXSo2 (ORCPT ); Mon, 24 Sep 2018 14:44:28 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 20779E1C; Mon, 24 Sep 2018 12:42:29 +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.18 191/235] coresight: tpiu: Fix disabling timeouts Date: Mon, 24 Sep 2018 13:52:57 +0200 Message-Id: <20180924113123.490672500@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180924113103.999624566@linuxfoundation.org> References: <20180924113103.999624566@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.18-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 @@ -40,8 +40,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) @@ -86,9 +87,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); }