Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp311242pxx; Wed, 28 Oct 2020 05:38:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJykq/dN+G+qxF/jV3u9OGLgCej5lCB1PYKhMb5apAa6utS9QQaYqgl20uqQ5ZT6bZwByNNn X-Received: by 2002:a17:906:3e4e:: with SMTP id t14mr7306916eji.242.1603888732146; Wed, 28 Oct 2020 05:38:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603888732; cv=none; d=google.com; s=arc-20160816; b=vcKSGNOX4vCRWN7fZC8nlzRFhHjyc/2rIuYVih8SKbwSh4NI4YiUhFHMtt6hy2SAIs XC1D290xMzFDMotJA7RkXWQGq8WYqEit1Tie4lxaqpLlGT1V0NHlgDIp5wbqu/A/JT4b HTz+ipbVuXCJvLh5TP5pGiVEF6IfYnjW8LtDfQQHlzANbbgfC9sYlxi6O0OvUMOypNfX KFOHNVWumuy5frkrmxgbRsXnr4fQEVyRKb9fZJOv5+8Bcotp3m++NJb1FxBljh81yckF 2k+shmVFRWIqG/OzGJPWIxy85dIdVBmYz7yyvAxSWvBVucAlRUG/VFRRd4XcbBVLdD7f BCNw== 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=4NBV9gVHoPdqr2TmmsARlReHgt27qpXxMZkwHRHi8Ns=; b=B2GI8kOD76zcKhtL9wdxtl5hd0BOTB2rAlpgV4upnu20+stz2rU6d/l32qdupj38pF KvtXBKGiucPOH9mw3kdAt4qsIPgj/wUAd95a/iL55Cf9D/qw3wbuRenGlhFQcFoDUn9+ ZMr0EeAKkGiIzdM3rBVpjZfUQb5NtiKwEGj9XEpg7R59maTPbmGuNo4OJbtKe19VCORi sJzJYJf4249CF+e7E/QC/LNlfpl6nwEJR3syvr5TDzyzjgLDL/GBhOM+74Pv6LoQrjLq Kglp9/BdGCvJ52xqrI6W8iUIsXJG0y66M8Oqea4ILbPxzDK7JV4frFnlfkYagREnO89B HpgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ZG7tE5uR; 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 dk22si2709939edb.258.2020.10.28.05.38.30; Wed, 28 Oct 2020 05:38:52 -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=ZG7tE5uR; 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 S1797515AbgJ0PYB (ORCPT + 99 others); Tue, 27 Oct 2020 11:24:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:37108 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1797225AbgJ0PWT (ORCPT ); Tue, 27 Oct 2020 11:22:19 -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 11FF120728; Tue, 27 Oct 2020 15:22:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603812138; bh=qcbtqMFBDuE4oRkZ6ZzbWvb7tYcgwL+MvzA/cB4cZTc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZG7tE5uRbDhYE4qZJ8Dnh8BTm/ghpJbRAuVcR4DnlBJyVfUvAoQsjfmHc8BX7stRd NBLGYV7kzjXe6CIo2WWarcrK2yOv1nMU3/VIaFaQg2cmBWRgsX31Cvto2fEOIawqGT RCw+3uy+hBcmdcdHHp73b/2gRtIhYdA2tvoD9xjY= 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.9 104/757] arm64: perf: Add missing ISB in armv8pmu_enable_counter() Date: Tue, 27 Oct 2020 14:45:54 +0100 Message-Id: <20201027135455.422462146@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135450.497324313@linuxfoundation.org> References: <20201027135450.497324313@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 462f9a9cc44be..481d48e3872b8 100644 --- a/arch/arm64/kernel/perf_event.c +++ b/arch/arm64/kernel/perf_event.c @@ -532,6 +532,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