RE: [PATCH 1/3] KVM: arm64: Don't load hardware vCPU state before first run
From: Justin He
Date: Tue Nov 24 2026 - 04:07:25 EST
> -----Original Message-----
[...]
> On Mon, 23 Nov 2026 15:09:15 +0000,
> Jia He <justin.he@xxxxxxx> wrote:
> >
> > KVM_PRE_FAULT_MEMORY calls vcpu_load() as soon as
> KVM_ARM_VCPU_INIT has
> > completed. On arm64, however, kvm->arch.sysreg_masks, the trap
> > configuration, vncr_tlb and nested vGIC state are only set up on the
> > first KVM_RUN in kvm_arch_vcpu_run_pid_change().
>
> I think I'm going to queue a patch disabling prefaulting immediately,
> and then we can fix this crap.
I can still reproduce the same vncr_tlb NULL dereference with prefaulting
disabled. On kvmarm/fixes, commit 5651590be08a ("KVM: arm64: Load the vcpu
in KVM_SET_VCPU_EVENTS") added a vcpu_load() call to KVM_SET_VCPU_EVENTS.
A single KVM_SET_VCPU_EVENTS with an all-zero struct kvm_vcpu_events,
issued before the first KVM_RUN, is enough to trigger it.
For v2, I'll build on your patch and use vcpu_has_run_once() to gate the
arch load/put paths for both ioctls.
___
Best Regards,
Jia He (Justin)