VCPU threads may currently enter their run loops before all other VCPUs have "reset" to an appropriate initial state. Actually this normally works okay, but on pKVM-ARM the VM's Hyp state (including boot VCPU's initial state) gets set up by the first VCPU thread to call ioctl(KVM_RUN). This races boot VCPU thread's intialisation of register state, and can result in the boot VCPU starting execution at PC=0. The simplest fix is to reset each VCPU when it is first created, before the VCPU run threads are even created. Signed-off-by: Keir Fraser <keirf@xxxxxxxxxx> --- kvm-cpu.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kvm-cpu.c b/kvm-cpu.c index 1c566b3..f66dcd0 100644 --- a/kvm-cpu.c +++ b/kvm-cpu.c @@ -154,8 +154,6 @@ int kvm_cpu__start(struct kvm_cpu *cpu) signal(SIGKVMPAUSE, kvm_cpu_signal_handler); signal(SIGKVMTASK, kvm_cpu_signal_handler); - kvm_cpu__reset_vcpu(cpu); - if (cpu->kvm->cfg.single_step) kvm_cpu__enable_singlestep(cpu); @@ -293,6 +291,7 @@ int kvm_cpu__init(struct kvm *kvm) pr_err("unable to initialize KVM VCPU"); goto fail_alloc; } + kvm_cpu__reset_vcpu(kvm->cpus[i]); } return 0; -- 2.47.1.545.g3c1d2e2a6a-goog