[PATCH v19 01/20] KVM: arm64: protected VM: Handle user writes to CNTVCT_EL0/CNTPCT_EL0

Jonathan Cameron jonathan.cameron at oss.qualcomm.com
Wed Sep 23 09:48:15 PDT 2026


On Tue, 22 Sep 2026 22:53:48 +0100
Suzuki K Poulose <suzuki.poulose at arm.com> wrote:

> On 22/09/2026 20:25, Jonathan Cameron wrote:
> > On Sun, 20 Sep 2026 22:28:26 +0100
> > Suzuki K Poulose <suzuki.poulose at arm.com> wrote:
> > 
> > Hi Suzuki,
> >   
> >> Protected VMs doesn't allow setting offsets for virtual and phyiscal  
> > 
> > physical
> >   
> >> counters, as the offset is always fixed to 0. The VM ioclt is filtered  
> > 
> > ioctl
> >   
> >> out based on the cap. However we don't prevent the userspace from trying
> >> to write to the CNTVCT/CNTPCT registers. This would lead to KVM triggering
> >> a WARN() in timer_set_offset() as the vm_offset pointer is set to NULL.
> >>
> >> Fix this by always "fixing" the timer offsets to 0 and marking that the
> >> timer offset is set in the kvm->arch.flags at KVM init time for protected
> >> VMs. A userspace writing to the CNT*CT_EL0 would observe success, without
> >> any real effect. This was chosen over preventing the writes to these
> >> registers and returning -EPERM.  
> > 
> > Why?  I don't mind the decision but telling us what was chosen is something
> > we can see in the code - patch description should give us the stuff we
> > can't see.  
> 
> I have modified the paragraph to :
> 
> "Fix this by always "fixing" the timer offsets to 0 and marking that the
> timer offset is set in the kvm->arch.flags at KVM init time for
> protected VMs. This prevents the access to the VM specific vm_offset at
> low cost. A userspace writing to the CNT*CT_EL0 would observe success,
> without any real effect. This is cleaner over spilling *_is_protected()"
cleaner than spilling.

Snag is over spill is a whole different thing and got me wondering what
was over spilling!  

Otherwise that works nicely. Thanks!





More information about the linux-arm-kernel mailing list