Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp250859pxx; Wed, 28 Oct 2020 04:07:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzkHBZse6jlD1ssQIX3kO6Qv1jQ/9uqUmEAhswe3wz6Mwf9AxX8zFO6x/EdzvE3Us88FIkd X-Received: by 2002:aa7:db07:: with SMTP id t7mr7283522eds.161.1603883225008; Wed, 28 Oct 2020 04:07:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603883225; cv=none; d=google.com; s=arc-20160816; b=L6anJrILxXEGCYKRbX59cuoYdUiS2JHRrb8DL0pdY2k1oSvXUC7Xg9jHK7QMz7/x+x mHRLsM/dZoyfBvjfXXWZ08BMgcjC4gTnDLXFCWK8yMLJ7tJLtWXpVnSbFH0xtTRkHzk4 YW2GNw+0xTsybmME2MHOtjCFezQEMbaNFOGIhMLL8TPSdJ5hZCLC9C22Mh6G2t8CKQHy rex+BvKZZnBUqZFTfqBQ0icyxPhDoHTk/4egWW7u1xCdyQMtIF1usYUrmMJZ6yZg8UUp AoRdK61UksqbGe27GB0/rZEQvkxi+ULS0+EXsRgURLP2T4MhcguamGxuhPoDgIaGz8XK XQzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=zMiTAaJxgBbeN9ARhcGeUIaAWdDNDsh+aitc5K5SAUM=; b=SKO8ZfWzobFZVOrQWTFt9MD+YJniBONuXEfazpB+d/1Xo0gNX2phJDiz7HODYYsLI/ TdxuVnWnZwdPtR5L+VMdAfioWOb4FiVER9uWlY/GCMOWFjcXzckmQVO4kAIxIIoUNV/C PyjKE/xlITKxQOHDTo/gPvVbC6wgd0gzjK2lHvauC1Ty1R9kGxNo797sWSlmM+HsK/d1 BzISYPbwIF5QplVT2rAXNnlM4vwahnn8hjgptmjgaWnlQiTDF0h2W5WNYzXPYsueRKWl aYFuXDhbNZiRyRVnIlW7frdMKrQDrcCdwB/NC5JVAMED6uFf8otI9GA4g+7qMdFS/b0R jMLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bT11fkTw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f19si2736409edx.542.2020.10.28.04.06.42; Wed, 28 Oct 2020 04:07:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bT11fkTw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1784740AbgJ0O7k (ORCPT + 99 others); Tue, 27 Oct 2020 10:59:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:51126 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1773192AbgJ0Ovn (ORCPT ); Tue, 27 Oct 2020 10:51:43 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BBF9A207DE; Tue, 27 Oct 2020 14:51:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603810302; bh=dvIZLbACW+xwduXQBY5j9WoNudiInwnxg8U3A+qjvdc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bT11fkTw2SFxjEgXtLBji1usA2ct+oGA2fSqlDGH7yuHxGuolOKNBclOjunVzwWVs ztibfVUmBM+oR43q1vjGlBNyH+A9zs1pyLNJRkvxIHrarX+HuMprrdwLRZrwHdQdEA wm19KfUIAjxisozZ1uZi+UXEXJokm0bVQDF+4cuo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Julien Thierry , Alexandru Elisei , Julien Thierry , Will Deacon , Mark Rutland , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Catalin Marinas , Will Deacon , Sasha Levin , Sumit Garg Subject: [PATCH 5.8 092/633] arm64: perf: Add missing ISB in armv8pmu_enable_counter() Date: Tue, 27 Oct 2020 14:47:15 +0100 Message-Id: <20201027135527.017508351@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135522.655719020@linuxfoundation.org> References: <20201027135522.655719020@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexandru Elisei [ Upstream commit 490d7b7c0845eacf5593db333fd2ae7715416e16 ] Writes to the PMXEVTYPER_EL0 register are not self-synchronising. In armv8pmu_enable_event(), the PE can reorder configuring the event type after we have enabled the counter and the interrupt. This can lead to an interrupt being asserted because of the previous event type that we were counting using the same counter, not the one that we've just configured. The same rationale applies to writes to the PMINTENSET_EL1 register. The PE can reorder enabling the interrupt at any point in the future after we have enabled the event. Prevent both situations from happening by adding an ISB just before we enable the event counter. Fixes: 030896885ade ("arm64: Performance counters support") Reported-by: Julien Thierry Signed-off-by: Alexandru Elisei Tested-by: Sumit Garg (Developerbox) Cc: Julien Thierry Cc: Will Deacon Cc: Mark Rutland Cc: Peter Zijlstra Cc: Ingo Molnar Cc: Arnaldo Carvalho de Melo Cc: Alexander Shishkin Cc: Jiri Olsa Cc: Namhyung Kim Cc: Catalin Marinas Link: https://lore.kernel.org/r/20200924110706.254996-2-alexandru.elisei@arm.com Signed-off-by: Will Deacon Signed-off-by: Sasha Levin --- arch/arm64/kernel/perf_event.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/arm64/kernel/perf_event.c b/arch/arm64/kernel/perf_event.c index 581602413a130..c26d84ff0e224 100644 --- a/arch/arm64/kernel/perf_event.c +++ b/arch/arm64/kernel/perf_event.c @@ -510,6 +510,11 @@ static u32 armv8pmu_event_cnten_mask(struct perf_event *event) static inline void armv8pmu_enable_counter(u32 mask) { + /* + * Make sure event configuration register writes are visible before we + * enable the counter. + * */ + isb(); write_sysreg(mask, pmcntenset_el0); } -- 2.25.1