KVM: s390: Move guts of kvm_arch_vcpu_init() into kvm_arch_vcpu_create()
authorSean Christopherson <sean.j.christopherson@intel.com>
Wed, 18 Dec 2019 21:55:10 +0000 (13:55 -0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 24 Jan 2020 08:19:08 +0000 (09:19 +0100)
Move all of kvm_arch_vcpu_init(), which is invoked at the very end of
kvm_vcpu_init(), into kvm_arch_vcpu_create() in preparation of moving
the call to kvm_vcpu_init().  Moving kvm_vcpu_init() is itself a
preparatory step for moving allocation and initialization to common KVM
code.

No functional change inteded.

Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/s390/kvm/kvm-s390.c

index 57c6838..0049b62 100644 (file)
@@ -2705,34 +2705,6 @@ static int sca_can_add_vcpu(struct kvm *kvm, unsigned int id)
 
 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu)
 {
-       vcpu->arch.pfault_token = KVM_S390_PFAULT_TOKEN_INVALID;
-       kvm_clear_async_pf_completion_queue(vcpu);
-       vcpu->run->kvm_valid_regs = KVM_SYNC_PREFIX |
-                                   KVM_SYNC_GPRS |
-                                   KVM_SYNC_ACRS |
-                                   KVM_SYNC_CRS |
-                                   KVM_SYNC_ARCH0 |
-                                   KVM_SYNC_PFAULT;
-       kvm_s390_set_prefix(vcpu, 0);
-       if (test_kvm_facility(vcpu->kvm, 64))
-               vcpu->run->kvm_valid_regs |= KVM_SYNC_RICCB;
-       if (test_kvm_facility(vcpu->kvm, 82))
-               vcpu->run->kvm_valid_regs |= KVM_SYNC_BPBC;
-       if (test_kvm_facility(vcpu->kvm, 133))
-               vcpu->run->kvm_valid_regs |= KVM_SYNC_GSCB;
-       if (test_kvm_facility(vcpu->kvm, 156))
-               vcpu->run->kvm_valid_regs |= KVM_SYNC_ETOKEN;
-       /* fprs can be synchronized via vrs, even if the guest has no vx. With
-        * MACHINE_HAS_VX, (load|store)_fpu_regs() will work with vrs format.
-        */
-       if (MACHINE_HAS_VX)
-               vcpu->run->kvm_valid_regs |= KVM_SYNC_VRS;
-       else
-               vcpu->run->kvm_valid_regs |= KVM_SYNC_FPRS;
-
-       if (kvm_is_ucontrol(vcpu->kvm))
-               return __kvm_ucontrol_vcpu_init(vcpu);
-
        return 0;
 }
 
@@ -3077,11 +3049,45 @@ struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm,
        rc = kvm_vcpu_init(vcpu, kvm, id);
        if (rc)
                goto out_free_sie_block;
+
+       vcpu->arch.pfault_token = KVM_S390_PFAULT_TOKEN_INVALID;
+       kvm_clear_async_pf_completion_queue(vcpu);
+       vcpu->run->kvm_valid_regs = KVM_SYNC_PREFIX |
+                                   KVM_SYNC_GPRS |
+                                   KVM_SYNC_ACRS |
+                                   KVM_SYNC_CRS |
+                                   KVM_SYNC_ARCH0 |
+                                   KVM_SYNC_PFAULT;
+       kvm_s390_set_prefix(vcpu, 0);
+       if (test_kvm_facility(vcpu->kvm, 64))
+               vcpu->run->kvm_valid_regs |= KVM_SYNC_RICCB;
+       if (test_kvm_facility(vcpu->kvm, 82))
+               vcpu->run->kvm_valid_regs |= KVM_SYNC_BPBC;
+       if (test_kvm_facility(vcpu->kvm, 133))
+               vcpu->run->kvm_valid_regs |= KVM_SYNC_GSCB;
+       if (test_kvm_facility(vcpu->kvm, 156))
+               vcpu->run->kvm_valid_regs |= KVM_SYNC_ETOKEN;
+       /* fprs can be synchronized via vrs, even if the guest has no vx. With
+        * MACHINE_HAS_VX, (load|store)_fpu_regs() will work with vrs format.
+        */
+       if (MACHINE_HAS_VX)
+               vcpu->run->kvm_valid_regs |= KVM_SYNC_VRS;
+       else
+               vcpu->run->kvm_valid_regs |= KVM_SYNC_FPRS;
+
+       if (kvm_is_ucontrol(vcpu->kvm)) {
+               rc = __kvm_ucontrol_vcpu_init(vcpu);
+               if (rc)
+                       goto out_uninit_vcpu;
+       }
+
        VM_EVENT(kvm, 3, "create cpu %d at 0x%pK, sie block at 0x%pK", id, vcpu,
                 vcpu->arch.sie_block);
        trace_kvm_s390_create_vcpu(id, vcpu, vcpu->arch.sie_block);
 
        return vcpu;
+out_uninit_vcpu:
+       kvm_vcpu_uninit(vcpu);
 out_free_sie_block:
        free_page((unsigned long)(vcpu->arch.sie_block));
 out_free_cpu: