Subject: Re: [PATCH 02/16] clocksource/drivers/arm_arch_timer: Default to EL2 virtual timer when running VHE

From: Marc Zyngier <[email-masked]>
Date: Fri, 08 May 2026 15:15:23 +0100

On Thu, 07 May 2026 13:55:30 +0100,
Marc Zyngier <[email-masked]> wrote:
> 
> When running with at EL2 with VHE enabled, the architecture provides
> two EL2 timer/counters, dubbed physical and virtual. Apart from their
> names, they are strictly identical.
> 
> However, they don't get virtualised the same way, specially when
> it comes to adding arbitrary offsets to the timers. When running as
> a guest, the host CNTVOFF_EL2 does apply to the guest's view of
> CNTHV*_El2. This is not true for CNTPOFF_EL2 and CNTHP*_EL2, as
> the architecture is broken past the first level of virtualisation
> (it lacks some essential mechanisms to be usable, despite what
> the ARM ARM pretends).
> 
> This means that when running as a L2 guest hypervisor, using the
> physical timer results in traps to L0, which are then forwarded to
> L1 in order to emulate the offset, leading to even worse performance
> due to massive trap amplification (the combination of register and
> ERET trapping is absolutely lethal).
> 
> Switch the arch timer code to using the virtual timer when running
> in VHE by default, only using the physical timer if the interrupt
> is not correctly described in the firmware tables (which seems
> to be an unfortunately common case). This comes as no impact on
> bare-metal, and slightly improves the situation in the virtualised
> case.

One thing I missed in this patch is that although we now use the EL2
virtual timer, we are still using the EL2 physical counter. They both
report the same thing, but this is missing a reasonable optimisation
in the NV case, which is the whole purpose of this patch.

I'll fix that for v2.

Thanks,

	M.

-- 
Without deviation from the norm, progress is not possible.