]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
KVM: PPC: BookE: Setup vcpu during kvmppc_core_vcpu_create()
authorSean Christopherson <sean.j.christopherson@intel.com>
Wed, 18 Dec 2019 21:55:21 +0000 (13:55 -0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Mon, 27 Jan 2020 18:59:28 +0000 (19:59 +0100)
Fold setup() into create() now that the two are called back-to-back by
common KVM code.  This paves the way for removing kvm_arch_vcpu_setup().
Note, BookE directly implements kvm_arch_vcpu_setup() and PPC's common
kvm_arch_vcpu_create() is responsible for its own cleanup, thus the only
cleanup required when directly invoking kvmppc_core_vcpu_setup() is to
call .vcpu_free(), which is the BookE specific portion of PPC's
kvm_arch_vcpu_destroy() by way of kvmppc_core_vcpu_free().

No functional change intended.

Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/powerpc/kvm/booke.c

index d41765157f0e2f330b1fb7f33c08259b54f52dab..e291c62187fe307e967b63217d2512249eb1f5f7 100644 (file)
@@ -1377,34 +1377,9 @@ static void kvmppc_set_tsr(struct kvm_vcpu *vcpu, u32 new_tsr)
        update_timer_ints(vcpu);
 }
 
-/* Initial guest state: 16MB mapping 0 -> 0, PC = 0, MSR = 0, R1 = 16MB */
 int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu)
 {
-       int i;
-       int r;
-
-       vcpu->arch.regs.nip = 0;
-       vcpu->arch.shared->pir = vcpu->vcpu_id;
-       kvmppc_set_gpr(vcpu, 1, (16<<20) - 8); /* -8 for the callee-save LR slot */
-       kvmppc_set_msr(vcpu, 0);
-
-#ifndef CONFIG_KVM_BOOKE_HV
-       vcpu->arch.shadow_msr = MSR_USER | MSR_IS | MSR_DS;
-       vcpu->arch.shadow_pid = 1;
-       vcpu->arch.shared->msr = 0;
-#endif
-
-       /* Eye-catching numbers so we know if the guest takes an interrupt
-        * before it's programmed its own IVPR/IVORs. */
-       vcpu->arch.ivpr = 0x55550000;
-       for (i = 0; i < BOOKE_IRQPRIO_MAX; i++)
-               vcpu->arch.ivor[i] = 0x7700 | i * 4;
-
-       kvmppc_init_timing_stats(vcpu);
-
-       r = kvmppc_core_vcpu_setup(vcpu);
-       kvmppc_sanity_check(vcpu);
-       return r;
+       return 0;
 }
 
 int kvmppc_subarch_vcpu_init(struct kvm_vcpu *vcpu)
@@ -2116,7 +2091,38 @@ int kvmppc_core_init_vm(struct kvm *kvm)
 
 int kvmppc_core_vcpu_create(struct kvm_vcpu *vcpu)
 {
-       return vcpu->kvm->arch.kvm_ops->vcpu_create(vcpu);
+       int i;
+       int r;
+
+       r = vcpu->kvm->arch.kvm_ops->vcpu_create(vcpu);
+       if (r)
+               return r;
+
+       /* Initial guest state: 16MB mapping 0 -> 0, PC = 0, MSR = 0, R1 = 16MB */
+       vcpu->arch.regs.nip = 0;
+       vcpu->arch.shared->pir = vcpu->vcpu_id;
+       kvmppc_set_gpr(vcpu, 1, (16<<20) - 8); /* -8 for the callee-save LR slot */
+       kvmppc_set_msr(vcpu, 0);
+
+#ifndef CONFIG_KVM_BOOKE_HV
+       vcpu->arch.shadow_msr = MSR_USER | MSR_IS | MSR_DS;
+       vcpu->arch.shadow_pid = 1;
+       vcpu->arch.shared->msr = 0;
+#endif
+
+       /* Eye-catching numbers so we know if the guest takes an interrupt
+        * before it's programmed its own IVPR/IVORs. */
+       vcpu->arch.ivpr = 0x55550000;
+       for (i = 0; i < BOOKE_IRQPRIO_MAX; i++)
+               vcpu->arch.ivor[i] = 0x7700 | i * 4;
+
+       kvmppc_init_timing_stats(vcpu);
+
+       r = kvmppc_core_vcpu_setup(vcpu);
+       if (r)
+               vcpu->kvm->arch.kvm_ops->vcpu_free(vcpu);
+       kvmppc_sanity_check(vcpu);
+       return r;
 }
 
 void kvmppc_core_vcpu_free(struct kvm_vcpu *vcpu)