Merge tag 'powerpc-5.4-1' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc...
[sfrench/cifs-2.6.git] / arch / powerpc / kvm / book3s_hv.c
index cde3f5a4b3e4709fe06a0eb27628a3fd537e30b9..efd8f93bc9dc1272686055f94d1cdbcee8f61d65 100644 (file)
@@ -1678,7 +1678,14 @@ static int kvmppc_get_one_reg_hv(struct kvm_vcpu *vcpu, u64 id,
                *val = get_reg_val(id, vcpu->arch.pspb);
                break;
        case KVM_REG_PPC_DPDES:
-               *val = get_reg_val(id, vcpu->arch.vcore->dpdes);
+               /*
+                * On POWER9, where we are emulating msgsndp etc.,
+                * we return 1 bit for each vcpu, which can come from
+                * either vcore->dpdes or doorbell_request.
+                * On POWER8, doorbell_request is 0.
+                */
+               *val = get_reg_val(id, vcpu->arch.vcore->dpdes |
+                                  vcpu->arch.doorbell_request);
                break;
        case KVM_REG_PPC_VTB:
                *val = get_reg_val(id, vcpu->arch.vcore->vtb);
@@ -2860,7 +2867,7 @@ static void collect_piggybacks(struct core_info *cip, int target_threads)
                if (!spin_trylock(&pvc->lock))
                        continue;
                prepare_threads(pvc);
-               if (!pvc->n_runnable) {
+               if (!pvc->n_runnable || !pvc->kvm->arch.mmu_ready) {
                        list_del_init(&pvc->preempt_list);
                        if (pvc->runner == NULL) {
                                pvc->vcore_state = VCORE_INACTIVE;
@@ -2881,15 +2888,20 @@ static void collect_piggybacks(struct core_info *cip, int target_threads)
        spin_unlock(&lp->lock);
 }
 
-static bool recheck_signals(struct core_info *cip)
+static bool recheck_signals_and_mmu(struct core_info *cip)
 {
        int sub, i;
        struct kvm_vcpu *vcpu;
+       struct kvmppc_vcore *vc;
 
-       for (sub = 0; sub < cip->n_subcores; ++sub)
-               for_each_runnable_thread(i, vcpu, cip->vc[sub])
+       for (sub = 0; sub < cip->n_subcores; ++sub) {
+               vc = cip->vc[sub];
+               if (!vc->kvm->arch.mmu_ready)
+                       return true;
+               for_each_runnable_thread(i, vcpu, vc)
                        if (signal_pending(vcpu->arch.run_task))
                                return true;
+       }
        return false;
 }
 
@@ -3119,7 +3131,7 @@ static noinline void kvmppc_run_core(struct kvmppc_vcore *vc)
        local_irq_disable();
        hard_irq_disable();
        if (lazy_irq_pending() || need_resched() ||
-           recheck_signals(&core_info) || !vc->kvm->arch.mmu_ready) {
+           recheck_signals_and_mmu(&core_info)) {
                local_irq_enable();
                vc->vcore_state = VCORE_INACTIVE;
                /* Unlock all except the primary vcore */
@@ -5462,6 +5474,12 @@ static int kvmppc_radix_possible(void)
 static int kvmppc_book3s_init_hv(void)
 {
        int r;
+
+       if (!tlbie_capable) {
+               pr_err("KVM-HV: Host does not support TLBIE\n");
+               return -ENODEV;
+       }
+
        /*
         * FIXME!! Do we need to check on all cpus ?
         */