[PATCH v2] KVM: arm64: Restore the VM's feature bitmap when kvm_setup_vcpu() fails
Oliver Upton
oupton at kernel.org
Mon Sep 21 11:39:33 PDT 2026
Hey Lorenzo,
On Mon, Sep 21, 2026 at 02:34:12PM +0100, Lorenzo Stoakes (ARM) wrote:
> On Mon, Sep 21, 2026 at 08:24:56AM +0100, Fuad Tabba wrote:
> > Hi Oliver,
> >
> > On Mon, 21 Sep 2026 00:09:17 -0700, Oliver Upton <oupton at kernel.org> wrote:
> > [...]
> > > > Nothing in the tree loads a vCPU whose init failed, so this is latent.
> > > > The upcoming series that enables KVM_PRE_FAULT_MEMORY for arm64 exposes
> > > > it: the generic kvm_vcpu_pre_fault_memory() calls vcpu_load() whether
> > > > or not the vCPU has been initialised.
> > >
> > > That's a bug, not a feature. We should require an initialized vcpu for
> > > the ioctl.
> >
> > That one is for Lorenzo then :) I'll reword the message so the stale
> > bitmap comes first and the pre-fault crash is just how it showed up.
>
> In general this is the behaviour of _generic_ KVM code
> (kvm_vcpu_pre_fault_memory()), which itself does not require an initialised
> vCPU, and no other arch seems to requires that either in the arch-specific
> pre-fault code.
>
> The actual pre-faulting implementation intentionally only targets the
> canonical MMU to fault in S2 page tables, which doesn't need initialisation
> to have taken place AFAICT.
>
> However I could add:
>
> if (!kvm_vcpu_initialized(vcpu))
> return -ENOEXEC;
>
> To kvm_arch_vcpu_pre_fault_memory(), which would make this a requirement,
> though that would bring us out of line with other archs.
Actually, we need this enforcement to happen before the arch-generic
implementation calls vcpu_load(). So that would be some amount of
kvm_arch_* boilerplate added to the generic code to enforce this
requirement like we do on the other vCPU ioctls.
I'm not too worried about aligning this with other architectures; the
idea of a half-baked vCPU getting loaded is worrying.
> OTOH, I don't see why anybody would pre-fault BEFORE init, feels like
> something that should be done later on in VMM bring up right?
>
> So I doubt doing this would really break any sane user.
>
> Let me know if you want that change in the series and I can respin it.
Please do, thank you for addressing this.
Best,
Oliver
More information about the linux-arm-kernel
mailing list