Re: [PATCH 03/17] KVM: arm64: Reject the PVTIME vCPU attribute for protected VMs
From: Fuad Tabba
Date: Thu Sep 03 2026 - 13:16:52 EST
On Wed, 2 Sept 2026 at 14:30, Vincent Donnefort <vdonnefort@xxxxxxxxxx> wrote:
>
> On Mon, Aug 31, 2026 at 05:34:07PM +0100, Fuad Tabba wrote:
> > pKVM currently does not support steal time for protected guests:
> > KVM_CAP_STEAL_TIME reports 0 for them. The host still accepts the
> > KVM_ARM_VCPU_PVTIME_CTRL attribute, whose IPA would point
> > kvm_update_stolen_time() at the guest's private memory on every vCPU
> > load. Return -EPERM for the attribute group instead.
> >
> > Signed-off-by: Fuad Tabba <fuad.tabba@xxxxxxxxx>
> > ---
> > arch/arm64/kvm/guest.c | 10 ++++++++++
> > 1 file changed, 10 insertions(+)
> >
> > diff --git a/arch/arm64/kvm/guest.c b/arch/arm64/kvm/guest.c
> > index b01d6622b8720..23f725e2cf745 100644
> > --- a/arch/arm64/kvm/guest.c
> > +++ b/arch/arm64/kvm/guest.c
> > @@ -916,6 +916,10 @@ int kvm_arm_vcpu_arch_set_attr(struct kvm_vcpu *vcpu,
> > ret = kvm_arm_timer_set_attr(vcpu, attr);
> > break;
> > case KVM_ARM_VCPU_PVTIME_CTRL:
> > + /* Steal time is not offered to protected guests. */
> > + if (kvm_vm_is_protected(vcpu->kvm))
> > + return -EPERM;
> > +
>
> nit: We have vcpu_is_protected()
Will do, and I found others in this series to fix with it.
> Also, would that make more sense to put that check in kvm_arm_pvtime_supported()?
kvm_arm_pvtime_supported() takes no vcpu, and its other caller reports
KVM_CAP_STEAL_TIME, which is already 0 for a protected VM. More
important, moving them would turn these three into -ENXIO, where
-EPERM is the right errno: steal time is implemented, it's just not
permitted for a protected VM.
Cheers,
/fuad
>
> > ret = kvm_arm_pvtime_set_attr(vcpu, attr);
> > break;
> > default:
> > @@ -939,6 +943,9 @@ int kvm_arm_vcpu_arch_get_attr(struct kvm_vcpu *vcpu,
> > ret = kvm_arm_timer_get_attr(vcpu, attr);
> > break;
> > case KVM_ARM_VCPU_PVTIME_CTRL:
> > + if (kvm_vm_is_protected(vcpu->kvm))
> > + return -EPERM;
> > +
> > ret = kvm_arm_pvtime_get_attr(vcpu, attr);
> > break;
> > default:
> > @@ -962,6 +969,9 @@ int kvm_arm_vcpu_arch_has_attr(struct kvm_vcpu *vcpu,
> > ret = kvm_arm_timer_has_attr(vcpu, attr);
> > break;
> > case KVM_ARM_VCPU_PVTIME_CTRL:
> > + if (kvm_vm_is_protected(vcpu->kvm))
> > + return -EPERM;
> > +
> > ret = kvm_arm_pvtime_has_attr(vcpu, attr);
> > break;
> > default:
> > --
> > 2.39.5
> >
>
> --
> Vincent