From 85273db668cbef2eccb90c9dea08d44473d5ca38 Mon Sep 17 00:00:00 2001 From: Will Deacon Date: Thu, 7 Jul 2022 15:52:11 +0100 Subject: [PATCH] Revert "FROMGIT: KVM: arm64: Merge kvm_arch_vcpu_run_pid_change() and kvm_vcpu_first_run_init()" This reverts commit d4a75950cb02676dd03e49b4fbcfc39caaa49037. Bug: 233587962 Signed-off-by: Will Deacon Change-Id: Icef82bccb6f723f8327078b906160619edf8346f --- arch/arm64/kvm/arm.c | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index fdc5414ddfe8..4749b0e0e48f 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -592,34 +592,22 @@ static void update_vmid(struct kvm_vmid *vmid) spin_unlock(&kvm_vmid_lock); } -static int kvm_vcpu_initialized(struct kvm_vcpu *vcpu) -{ - return vcpu->arch.target >= 0; -} - -/* - * Handle both the initialisation that is being done when the vcpu is - * run for the first time, as well as the updates that must be - * performed each time we get a new thread dealing with this vcpu. - */ int kvm_arch_vcpu_run_pid_change(struct kvm_vcpu *vcpu) +{ + return kvm_arch_vcpu_run_map_fp(vcpu); +} + +static int kvm_vcpu_first_run_init(struct kvm_vcpu *vcpu) { struct kvm *kvm = vcpu->kvm; - int ret; - - if (!kvm_vcpu_initialized(vcpu)) - return -ENOEXEC; - - if (!kvm_arm_vcpu_is_finalized(vcpu)) - return -EPERM; - - ret = kvm_arch_vcpu_run_map_fp(vcpu); - if (ret) - return ret; + int ret = 0; if (likely(vcpu->arch.has_run_once)) return 0; + if (!kvm_arm_vcpu_is_finalized(vcpu)) + return -EPERM; + kvm_arm_vcpu_init_debug(vcpu); if (likely(irqchip_in_kernel(kvm))) { @@ -708,6 +696,11 @@ static void vcpu_req_sleep(struct kvm_vcpu *vcpu) smp_rmb(); } +static int kvm_vcpu_initialized(struct kvm_vcpu *vcpu) +{ + return vcpu->arch.target >= 0; +} + static void check_vcpu_requests(struct kvm_vcpu *vcpu) { if (kvm_request_pending(vcpu)) { @@ -821,6 +814,13 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu) struct kvm_run *run = vcpu->run; int ret; + if (unlikely(!kvm_vcpu_initialized(vcpu))) + return -ENOEXEC; + + ret = kvm_vcpu_first_run_init(vcpu); + if (ret) + return ret; + if (run->exit_reason == KVM_EXIT_MMIO) { ret = kvm_handle_mmio_return(vcpu); if (ret)