[PATCH v1] KVM: arm64: Use CNTPCT_EL0 for hyp trace clock

Fuad Tabba fuad.tabba at linux.dev
Sat Nov 28 02:23:20 PST 2026


Hi Marc,

On Sat, 28 Nov 2026 09:34:01 +0000, Marc Zyngier <maz at kernel.org> wrote:
> On Fri, 27 Nov 2026 21:27:43 +0000,
> Vincent Donnefort <vdonnefort at google.com> 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?

Not for non-protected VMs. flush_hyp_timer_state() zeroes CNTVOFF_EL2
only for a protected vCPU, and a non-protected VM in pKVM uses the
offset the host sets. Without hVHE, the hypervisor's CNTVCT_EL0 reads
then include that offset. I saw the trace timestamps jump on QEMU with
pKVM on a cortex-a57, running a non-protected guest.

Cheers,
/fuad



More information about the linux-arm-kernel mailing list