Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp422348ybt; Wed, 17 Jun 2020 04:43:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy+yvps3xp5xKNyXpX8Srt4DL/8fQBPpXTxydB1HsBOP05h/ZLIM5MqQDZCFDAKjmCPwcoJ X-Received: by 2002:a50:ee01:: with SMTP id g1mr6652072eds.44.1592394230832; Wed, 17 Jun 2020 04:43:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592394230; cv=none; d=google.com; s=arc-20160816; b=UDjk01A1aTOGi5F2iqlhXBR9LichJ+kM5fy2Owz+xsYytoR8RyCPshhc3gFmGpD8XL ViUCRztFnamZ/ODsljLhYGTpEAahVW3N6E7PL2YBgZZE7bg6RSe3Wz85lm6BevMN3D9o 9L6AXMeU7pOBs0DANSaZ7sKCC7LeMPUIvQyYu3FmMuovLW28dbjpslCs56E824K6Hq27 +r5zbpP7WLxpg0yG+E8TAEm2QaKrQGGCCzG/YFvKV4w1kjF7RfyUNqi/NiyKPCR6JKjn eZ7Clv1ccDs6yr6EJCNWhiw43qmC06R8BV6/v+VbPyhx8TjC8wZXwUZHwi9SW+Xtlcqc rrxw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=J8eHrUcMAtyGozsCs+xfCxq0zkuBhJzWpPMzvF1s55I=; b=vyfAWsL+7sgYDtDoBkbHmYRtuWIjYQ6gNAn/hDUSGSBRIzNyoAO06O/026iQdCLKnE R/8SRLbO0b2QlkBfpM9cZVTUf97JfjHlMHRuHNgfClvEMGjkRH0+hoMdrvecMB2K+Bl1 aeU4s958kVpFMMZ9WEU+/EH+gAK+AWd4AeOxcNvEctx+inHOZWIXo2WIHB8PrjU69Vi+ 8eeJrupO2FRBXHbiZi71hFjLbZmxFfiVKtV4sy+a209p4h6NQjvLrmtnAFWL4W/RAa+B sAR33Vq+doXjsna6QKxNX+xUPEJsFC2yDaDsVwT3Th/WRkQUtw6y9NWnzePM1ToVAtPU iw3A== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u27si12776574eje.558.2020.06.17.04.43.28; Wed, 17 Jun 2020 04:43:50 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726972AbgFQLia (ORCPT + 99 others); Wed, 17 Jun 2020 07:38:30 -0400 Received: from foss.arm.com ([217.140.110.172]:56240 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726939AbgFQLiW (ORCPT ); Wed, 17 Jun 2020 07:38:22 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 371C81045; Wed, 17 Jun 2020 04:38:21 -0700 (PDT) Received: from monolith.arm.com (unknown [10.37.8.7]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 89A583F71F; Wed, 17 Jun 2020 04:38:18 -0700 (PDT) From: Alexandru Elisei To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: maz@kernel.org, will@kernel.org, catalin.marinas@arm.com, mark.rutland@arm.com, Julien Thierry , Will Deacon , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Julien Thierry Subject: [PATCH v5 1/7] arm64: perf: Add missing ISB in armv8pmu_enable_event() Date: Wed, 17 Jun 2020 12:38:45 +0100 Message-Id: <20200617113851.607706-2-alexandru.elisei@arm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200617113851.607706-1-alexandru.elisei@arm.com> References: <20200617113851.607706-1-alexandru.elisei@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 the of the previous event type that we were counting, not the one that we've just enabled. 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. 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 Fixes: 030896885ade ("arm64: Performance counters support") Reported-by: Julien Thierry Signed-off-by: Alexandru Elisei --- arch/arm64/kernel/perf_event.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm64/kernel/perf_event.c b/arch/arm64/kernel/perf_event.c index 4d7879484cec..ee180b2a5b39 100644 --- a/arch/arm64/kernel/perf_event.c +++ b/arch/arm64/kernel/perf_event.c @@ -605,6 +605,7 @@ static void armv8pmu_enable_event(struct perf_event *event) * Enable interrupt for this counter */ armv8pmu_enable_event_irq(event); + isb(); /* * Enable counter -- 2.27.0