From patchwork Tue Oct 6 15:05:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Elisei X-Patchwork-Id: 11818839 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 657E26CB for ; Tue, 6 Oct 2020 15:04:42 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EC8A2206B5 for ; Tue, 6 Oct 2020 15:04:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="vTKyqYE2" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EC8A2206B5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=/UkDPBrXr7YmEHT6cs6T2M7VqBYvOL0lE0Ca/9CCHhs=; b=vTKyqYE2aUj0WBLeir8+f5gLCF EeuTM5BRNJAnWc7CKnFSYzRoAGziy6DwcmsiSntgTck+OgKOgJgZD7lqtXHhU/I5basozcN8DgUlZ 11APlPMXFxPu2ErYZbsQTKenLgTNNy+ym1a5eqYv+alUhU0eeAZ3XJKGl3v8nK+KxI7Jy8TTO6Q/K eljRlgbLU9+HQFYR6eGhp5N6VJZntAUWrScOY/daB8sousw0Ku7jrUFndpHf3Rd8cUSVe1gUpajhx pe9ItdYjf5GGXyqu3H28RDTk69/kS1y+nsv7mWiUXtKm8XYrXGzQauBwbL31NVfoOm5ZIEaKs6NPZ vmM74GxQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kPoVp-00051L-5W; Tue, 06 Oct 2020 15:04:21 +0000 Received: from foss.arm.com ([217.140.110.172]) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kPoVm-00050p-To for linux-arm-kernel@lists.infradead.org; Tue, 06 Oct 2020 15:04:19 +0000 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 5B7F3113E; Tue, 6 Oct 2020 08:04:15 -0700 (PDT) Received: from monolith.localdoman (unknown [10.37.12.66]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A69653F71F; Tue, 6 Oct 2020 08:04:13 -0700 (PDT) From: Alexandru Elisei To: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org Subject: [PATCH] perf: arm_spe: Use Inner Shareable DSB when draining the buffer Date: Tue, 6 Oct 2020 16:05:20 +0100 Message-Id: <20201006150520.161985-1-alexandru.elisei@arm.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201006_110419_026598_E13D25A6 X-CRM114-Status: GOOD ( 13.78 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [217.140.110.172 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, suzuki.poulose@arm.com, maz@kernel.org, james.morse@arm.com, catalin.marinas@arm.com, will@kernel.org, julien.thierry.kdev@gmail.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From ARM DDI 0487F.b, page D9-2807: "Although the Statistical Profiling Extension acts as another observer in the system, for determining the Shareability domain of the DSB instructions, the writes of sample records are treated as coming from the PE that is being profiled." Similarly, on page D9-2801: "The memory type and attributes that are used for a write by the Statistical Profiling Extension to the Profiling Buffer is taken from the translation table entries for the virtual address being written to. That is: - The writes are treated as coming from an observer that is coherent with all observers in the Shareability domain that is defined by the translation tables." All the PEs are in the Inner Shareable domain, use a DSB ISH to make sure writes to the profiling buffer have completed. Fixes: d5d9696b0380 ("drivers/perf: Add support for ARMv8.2 Statistical Profiling Extension") Signed-off-by: Alexandru Elisei --- Found by code inspection. All the places where the buffer was drained were found by using the command "grep -r psb_csync". arch/arm64/kvm/hyp/nvhe/debug-sr.c | 2 +- drivers/perf/arm_spe_pmu.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/arm64/kvm/hyp/nvhe/debug-sr.c b/arch/arm64/kvm/hyp/nvhe/debug-sr.c index 91a711aa8382..e05a08c5ad1f 100644 --- a/arch/arm64/kvm/hyp/nvhe/debug-sr.c +++ b/arch/arm64/kvm/hyp/nvhe/debug-sr.c @@ -43,7 +43,7 @@ static void __debug_save_spe(u64 *pmscr_el1) /* Now drain all buffered data to memory */ psb_csync(); - dsb(nsh); + dsb(ish); } static void __debug_restore_spe(u64 pmscr_el1) diff --git a/drivers/perf/arm_spe_pmu.c b/drivers/perf/arm_spe_pmu.c index cc00915ad6d1..402892caef34 100644 --- a/drivers/perf/arm_spe_pmu.c +++ b/drivers/perf/arm_spe_pmu.c @@ -525,7 +525,7 @@ static void arm_spe_pmu_disable_and_drain_local(void) /* Drain any buffered data */ psb_csync(); - dsb(nsh); + dsb(ish); /* Disable the profiling buffer */ write_sysreg_s(0, SYS_PMBLIMITR_EL1); @@ -545,7 +545,7 @@ arm_spe_pmu_buf_get_fault_act(struct perf_output_handle *handle) * aborts have been resolved. */ psb_csync(); - dsb(nsh); + dsb(ish); /* Ensure hardware updates to PMBPTR_EL1 are visible */ isb();