From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.43 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796049203; b=H0CaFLrEav5LWGksZz4SF1fqGtuZtYtqLu408zS20AxFOOGXvUP6saerWQSe/kQ2AQuS TtLvMNYdDirxi5PfOJawYdvDIcpobPEY76Nx6IxUUtBkGXwFuBwwDcoBz0sMUE7zqqU7b LwHt3UFYiOVH9gHl3Su9R6j317TR58/Ak1f86f0TtTUXzN0Atp2skB3rcl9Lae/OtzfB1 m2zl9aAZcazfpyaovF7UdtafIunWF8ydmqsYec34ijsKYMWOMMEynKWXyxzDpYIonxpkH +2l79kVeKgBu0kntsDgCHWQggqViTQ1YW8iuFJxy9/2E0YzZhScklHSgPXkfF2p89cw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796049203; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; bh=jUuCNL0rvgtk5zxma4xiUNNjSGY3EWLqxsr5+RjpZks=; b=CW0gLOm/cqVWovx4DsK6HRRtoImyRBuygJgJqnx+TmxiZO1hHyWGZ24maRk134r4Rdeq Pcnz4oluXTs/ENi4S+4r+nga0p42SyKBVvViCQqSOm3vHDg0mI22UrXDm8iiVh1YDgX3X 3byik1XglfrnK9nuNrzL/oEjCXCTTOj+Qe6whPXaa20ZWsbuOj9m2vvmfoS+M9RDJXHw+ GTf32Y+4m3G6J9vwQkL++u+h1DEj7QVJONWjVPkKstc6JOgdgxYummSize0xbubMRzM15 v1Rldf0ZBwzXmuk/Y3shtupOy7TyraM7MZBqBi3e3gcCFMrob3lA7plP9lN0tWEzK6A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=I4wKYd85; arc=none smtp.remote-ip=209.85.128.43 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D5964606A31C for ; Mon, 30 Nov 2026 14:33:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D5964606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=I4wKYd85 Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-4bb70074ab2so111681605e9.0 for ; Mon, 30 Nov 2026 06:33:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796049201; x=1796654001; darn=lists.linux.dev; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=jUuCNL0rvgtk5zxma4xiUNNjSGY3EWLqxsr5+RjpZks=; b=I4wKYd85kvl9Rdt086lLZKcTnc9Q8+yeLd6oDK3S9mXOPV5uHYqBHZmKJ0QrZTKHKj rLZS0+e8fMTo7NPnLBuqbgB8WbcCKKsOwdtC6H8C5Ny70bGwVnq0FG3QQP+Zxft+e7hR T70TR7N4V4un3AziHAdvDhb18HiAX3oeZ61vgqGjgSI9mj6N3fZ8J2nx++f+nwNiHtFM GfC9540iMyrzTu9JEmZA5otrFigDwj1vZ+rQW4blmOwNfkeEmYrEfcQi0R9QwEBIERir 94sPt67p4opfLWTN9tVs8NPt8FZLN/N4iciGlnXgW0dC6D9n1yvM4y78WiNZ8oHA3F7Y MZ1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796049201; x=1796654001; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=jUuCNL0rvgtk5zxma4xiUNNjSGY3EWLqxsr5+RjpZks=; b=eQp7gfVqXMtMWQLDO/cv12uAjKwIO45uoqxsa4cE64EKR9nQKKHTQ79ceBbnsz+1gI jIqTZ74GH6FR+U2TZuTjUVVYn5aJv68aUOt50rtrL1Nf9+05vdKkSwtvpKvlveGglGJI Mdje9Rtp9MpGYxZcdlyeiH6uEmSXU4qTkm+xRdQ1oAqzLeJoIV1IK9CVVR/iEuDTe6+f VME/4ogzN1h/IfQUtvxCzkgF8P/Bo1fgjrXZ1sSzMw8lM6rQ8xf3Op+rbwJFBAXKo6ly PdpI7dzAQWlZ8z7HO/Lbixs+y77RP2iN3h/2xyj2xscL8SZ0TfmOW2bjJ5Mcx0CPLUWz a9dw== X-Forwarded-Encrypted: i=1; AL+hErFj6IJxmQoOheKJIxH5Ko/QmKiZ+Ui9LFDvVAz5ogrcSNhUpjghTEK08vPgO6opn93FUq9L4sE=@lists.linux.dev X-Gm-Message-State: APuU4Z96xgFUZBkWCfTH0re5CyvQ3IuqoVvI+R6m36krOh+QROiscpxj V9nLEZSosHg/dPsV22TgXH+qnwfXY/N4J06vC50iEIghIIeROT3fbL0CNMZHbBM7uA== X-Gm-Gg: AZFdTZfHzlQk6B3HPAg38oNpI4Oh3LPOcO5RQS6i5PUtNnYoohSkpk0PHJyQXgE/VoX sLqmZ2QYoWcNobqWbJsjeudwus89SyBm8a9ULw/yRUY80FmDQEibgBzk6ekpWAaQ+cwGXaR/R1X TRSyNkF6IerUA8RjgifLHU96SzXIzfw7B9rXulTfcxJhVY2TnToL9Lg8hSLbtGlDiwbBhA3Ux7P EXQbT7LiLra3oJofEy9qxdBJN7LD022LbM8HrL0b0hVNpVQBLQAlMZESZm/3TvSd5ONKIRWwaFt xAuchE7O5DxyNg2xn8/Nz9NCBtpueXxHO4nIY1BQFcz1YEmZsFOwvX74VzRV7dlKeb9B3jZY3b7 pLbjFoQJjNooJlyV7bb0x9CSNku5g9ZHQ3BhHeA5GQQdhwTL8GnMkgz7jCOt3Ose9825zMuwn0I +aLXdYgNaY3zzWATNymCpTm9d/AimVAM+tcn/unNfkj/fm9Iymb3EN80oIFrjBZF+JXDnSWssVU fBoe2uhk6C0mvO604Y1PEbEcSGoPkgn6ugw+NPApXnxBft6XK14hcMryjB6lLn5gth7QUSC3aHZ 57bY4mnZyC/UjwwbLYAdZ7WkuZEzbw8Qx/Oj1rdeqhFMn1F8YYjMMw46kcEHzXBd/u5dRVGUB8x BwgJ9+9gyxUAjBda0qhIVSw== X-Received: by 2002:a05:600c:37c6:b0:4bb:7033:c938 with SMTP id 5b1f17b1804b1-4bb888147b7mr677384115e9.14.1796049200581; Mon, 30 Nov 2026 06:33:20 -0800 (PST) Received: from google.com (0.182.34.34.bc.googleusercontent.com. [34.34.182.0]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bb884b39b6sm868100595e9.12.2026.11.30.06.33.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 06:33:19 -0800 (PST) Date: Mon, 30 Nov 2026 14:33:16 +0000 From: Vincent Donnefort To: Marc Zyngier 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 Message-ID: References: <20261127212743.1139739-1-vdonnefort@google.com> <86se0lxpti.wl-maz@kernel.org> <86jyluy3i2.wl-maz@kernel.org> X-Mailing-List: kvmarm@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <86jyluy3i2.wl-maz@kernel.org> On Mon, Nov 30, 2026 at 11:15:17AM +0000, Marc Zyngier wrote: > 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. We need a bit of time to verify we wouldn't break any existing pKVM user, if we can't find any issue, we'll send a broader series. -- Vincent