[PATCH] KVM: arm64: Fix hvhe and broken CNTVOFF_EL2
Fuad Tabba
tabba at google.com
Thu Aug 6 09:55:50 PDT 2026
Hi Mostafa,
On Thu, 6 Aug 2026 at 16:01, Mostafa Saleh <smostafa at google.com> wrote:
...
> void __kvm_timer_set_cntvoff(u64 cntvoff)
> {
> @@ -63,7 +64,7 @@ void __timer_enable_traps(struct kvm_vcpu *vcpu)
> * Trap the virtual counter/timer if we have a broken cntvoff
> * implementation.
> */
> - if (has_broken_cntvoff())
> + if (has_broken_cntvoff() && hyp_timer_get_offset(vcpu_vtimer(vcpu)))
> set |= CNTHCTL_EL1TVT | CNTHCTL_EL1TVCT;
nit: the comment above could note the trap is now gated on a non-zero
virtual offset, to match timer_set_traps() on the VHE side (well...
maybe you don't want to _completely_ match _that_ comment, but you get
my drift ;)) .
Tested on QEMU with a forced has_broken_cntvoff(), then booted a
protected guest: without the patch it hits the UNDEF, with it the
guest boots.
Reviewed-by: Fuad Tabba <fuad.tabba at linux.dev>
Tested-by: Fuad Tabba < fuad.tabba at linux.dev>
Cheers,
/fuad
>
> sysreg_clear_set(cnthctl_el2, clr, set);
> --
> 2.55.0.654.g21b8a5bc05-goog
>
More information about the linux-arm-kernel
mailing list