From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 938AF606A31C for ; Mon, 30 Nov 2026 11:15:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=BOEPRnvK; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=VqQJY6PI DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: References:In-Reply-To:Subject:Cc:To:From:Message-ID:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=s4I8CB6SQ6VWVCaEVlkVtFhPi1qVxh6MUu4Lo2QkjlA=; b=BOEPRnvKqz73MoflPHAJAv6sbJ fAPdYVK9H2/KsQhCpu+Sfba4H9CKqCHV7oxejfQrRXvZa5zmvrges/5e39+iWLYSyGAD1Lq0emsJ/ OUjdy0g/lMU2cnsCtM72/XLVt0wK/Vfv8MT+tzktSmOFZkTSf1EjrZEyCy24fOYYYWKhfvfqpGSCc SIWhGfS3PLOsxwBi/LApUFoGdXeHxHLycdMG1PwapypiorSWxPYwDN74dv0FueCVVn3sOV6g4Vsfe 5MnzZ/rTqpjjiDjamUWes3OYOF6rJEscWUVzbSizqXfdrlxwN/WQ8rl/BqBJuoBXrQX7gT3LpGp6g dG0Uyccg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xXzM9-00000004I2I-45Oy; Mon, 30 Nov 2026 11:15:37 +0000 Received: from tor.source.kernel.org ([172.105.4.254]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xXzLt-00000004Hzv-2aJd for linux-arm-kernel@lists.infradead.org; Mon, 30 Nov 2026 11:15:21 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id BE4C461F3C; Mon, 30 Nov 2026 11:15:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5C7741F00896; Mon, 30 Nov 2026 11:15:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796037320; bh=s4I8CB6SQ6VWVCaEVlkVtFhPi1qVxh6MUu4Lo2QkjlA=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=VqQJY6PIVumEFTTH3BuhbEfdm/jjUsOiurwRauu0wS9euZEfUHP2q1aoK0YHenwTE oosB9aAbzznuG0cL+8/XTag3Oub58P5Iw34X/evs3tShvspMjbDfhtmZPEsY4L1nvl 4IXs2zSoWciw+lLpI4CbHjNACu8sbcJoj2b/E7BaL3WRDCJ64MRYZ3vKocdvlfSGub j3tMaGwonwcwBCkQfJLLPvWcTVJSa4EuJFH1elaRWprtxkk8/vp1gNI11IwKvGgqxc czZ1PQ1MAOH/AguHU6D42jQZKK7ZmqisBjlDChk/XXd3uS8H91Bfid65gzNrExmIvC JJGqKF2rJOjvg== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xXzLp-00000004z8A-3RRo; Mon, 30 Nov 2026 11:15:17 +0000 Date: Mon, 30 Nov 2026 11:15:17 +0000 Message-ID: <86jyluy3i2.wl-maz@kernel.org> From: Marc Zyngier To: Vincent Donnefort Cc: oupton@kernel.org, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, joey.gouly@arm.com, seiden@linux.ibm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, kernel-team@android.com, fuad.tabba@linux.dev, stable@vger.kernel.org Subject: Re: [PATCH v1] KVM: arm64: Use CNTPCT_EL0 for hyp trace clock In-Reply-To: References: <20261127212743.1139739-1-vdonnefort@google.com> <86se0lxpti.wl-maz@kernel.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/30.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) X-Archived-By: MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: vdonnefort@google.com, oupton@kernel.org, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, joey.gouly@arm.com, seiden@linux.ibm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, kernel-team@android.com, fuad.tabba@linux.dev, stable@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-15.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On Mon, 30 Nov 2026 09:26:12 +0000, Vincent Donnefort wrote: > > On Sat, Nov 28, 2026 at 09:34:01AM +0000, Marc Zyngier wrote: > > On Fri, 27 Nov 2026 21:27:43 +0000, > > Vincent Donnefort wrote: > > > > > > trace_hyp_clock() reads the virtual counter (CNTVCT_EL0). Under nVHE > > > (and pKVM without hVHE), loading a guest with a non-zero offset applies > > > that offset to CNTVCT_EL0, corrupting the trace timestamps. Use > > > CNTPCT_EL0 instead. > > > > pKVM mandates CNTVOFF_EL2 being 0. Has that changed? > > > > > > > > Cc: stable@vger.kernel.org > > > Fixes: b22888917fa4 ("KVM: arm64: Sync boot clock with the nVHE/pKVM hyp") > > > Reported-by: Fuad Tabba > > > Signed-off-by: Vincent Donnefort > > > --- > > > arch/arm64/kvm/hyp/nvhe/clock.c | 2 +- > > > arch/arm64/kvm/hyp_trace.c | 4 ++-- > > > 2 files changed, 3 insertions(+), 3 deletions(-) > > > > > > diff --git a/arch/arm64/kvm/hyp/nvhe/clock.c b/arch/arm64/kvm/hyp/nvhe/clock.c > > > index f3e2619db4e4..ea4412e6737c 100644 > > > --- a/arch/arm64/kvm/hyp/nvhe/clock.c > > > +++ b/arch/arm64/kvm/hyp/nvhe/clock.c > > > @@ -54,7 +54,7 @@ u64 trace_hyp_clock(void) > > > u64 bank = smp_load_acquire(&clock->cur); > > > u64 cyc, ns; > > > > > > - cyc = __arch_counter_get_cntvct() - clock->data[bank].epoch_cyc; > > > + cyc = __arch_counter_get_cntpct() - clock->data[bank].epoch_cyc; > > > > > > if (likely(cyc < clock->data[bank].cyc_overflow64)) { > > > ns = cyc * clock->data[bank].mult; > > > diff --git a/arch/arm64/kvm/hyp_trace.c b/arch/arm64/kvm/hyp_trace.c > > > index b9404496f977..06d6bd7aeac7 100644 > > > --- a/arch/arm64/kvm/hyp_trace.c > > > +++ b/arch/arm64/kvm/hyp_trace.c > > > @@ -510,8 +510,8 @@ int __init kvm_hyp_trace_init(void) > > > per_cpu(timer_unstable_counter_workaround, cpu); > > > > > > if (IS_ENABLED(CONFIG_ARM_ARCH_TIMER_OOL_WORKAROUND) && > > > - wa && wa->read_cntvct_el0) { > > > - pr_warn("hyp trace can't handle CNTVCT workaround '%s'\n", wa->desc); > > > + wa && wa->read_cntpct_el0) { > > > + pr_warn("hyp trace can't handle CNTPCT workaround '%s'\n", wa->desc); > > > return -EOPNOTSUPP; > > > } > > > } > > > > > > > This is a bad idea. Virtualising the physical counter is extremely > > expensive, while the virtual counter is basically free. On top of > > that, nVHE is a dried up turd we shouldn't invest any effort into. > > > > I can see two options: disabling trace on nVHE altogether (my > > favourite one, because let's face it, *nobody* is using pKVM on that), > > or reset CNTVOFF_EL2 to 0 across the read of the counter when on nVHE. > > > > M. > > > > -- > > Without deviation from the norm, progress is not possible. > > I am more than happy with nuking the nVHE support, getting rid of it should > simplify a lot hyp_trace.c. Can we nuke nVHE support from pKVM entirely? ARMv8.1 was released in 2014, and it is high time we start moving forward. ARMv8.0 HW can still use KVM as initially intended (without paying the cost of S2 on the host). M. -- Without deviation from the norm, progress is not possible.