Lines Matching +full:intc +full:- +full:no +full:- +full:eoi
1 // SPDX-License-Identifier: GPL-2.0-only
9 * Kevin Wolf <mail@kevin-wolf.de>
32 #include <linux/page-flags.h>
50 #include <asm/ppc-opcode.h>
51 #include <asm/asm-prototypes.h>
73 #include <asm/pnv-pci.h>
108 MODULE_PARM_DESC(dynamic_mt_modes, "Set of allowed dynamic micro-threading modes: 0 (= none), 2, 4,…
170 vcpu = READ_ONCE(vc->runnable_threads[i]); in next_runnable_thread()
181 for (i = -1; (vcpu = next_runnable_thread(vc, &i)); )
215 if (paca_ptrs[cpu]->kvm_hstate.xics_phys) { in kvmppc_ipi_thread()
241 ++vcpu->stat.generic.halt_wakeup; in kvmppc_fast_vcpu_kick_hv()
243 cpu = READ_ONCE(vcpu->arch.thread_cpu); in kvmppc_fast_vcpu_kick_hv()
248 cpu = vcpu->cpu; in kvmppc_fast_vcpu_kick_hv()
267 * a vcore using vc->stolen_tb, and the stolen time when the vcpu
281 * updates to vc->stolen_tb are protected by the vcore->stoltb_lock
299 spin_lock_irqsave(&vc->stoltb_lock, flags); in kvmppc_core_start_stolen()
300 vc->preempt_tb = tb; in kvmppc_core_start_stolen()
301 spin_unlock_irqrestore(&vc->stoltb_lock, flags); in kvmppc_core_start_stolen()
310 spin_lock_irqsave(&vc->stoltb_lock, flags); in kvmppc_core_end_stolen()
311 if (vc->preempt_tb != TB_NIL) { in kvmppc_core_end_stolen()
312 vc->stolen_tb += tb - vc->preempt_tb; in kvmppc_core_end_stolen()
313 vc->preempt_tb = TB_NIL; in kvmppc_core_end_stolen()
315 spin_unlock_irqrestore(&vc->stoltb_lock, flags); in kvmppc_core_end_stolen()
320 struct kvmppc_vcore *vc = vcpu->arch.vcore; in kvmppc_core_vcpu_load_hv()
325 if (vcpu->arch.busy_preempt != TB_NIL) { in kvmppc_core_vcpu_load_hv()
326 WARN_ON_ONCE(vcpu->arch.state != KVMPPC_VCPU_BUSY_IN_HOST); in kvmppc_core_vcpu_load_hv()
327 vc->stolen_tb += mftb() - vcpu->arch.busy_preempt; in kvmppc_core_vcpu_load_hv()
328 vcpu->arch.busy_preempt = TB_NIL; in kvmppc_core_vcpu_load_hv()
336 * We can test vc->runner without taking the vcore lock, in kvmppc_core_vcpu_load_hv()
337 * because only this task ever sets vc->runner to this in kvmppc_core_vcpu_load_hv()
341 if (vc->runner == vcpu && vc->vcore_state >= VCORE_SLEEPING) in kvmppc_core_vcpu_load_hv()
344 spin_lock_irqsave(&vcpu->arch.tbacct_lock, flags); in kvmppc_core_vcpu_load_hv()
345 if (vcpu->arch.state == KVMPPC_VCPU_BUSY_IN_HOST && in kvmppc_core_vcpu_load_hv()
346 vcpu->arch.busy_preempt != TB_NIL) { in kvmppc_core_vcpu_load_hv()
347 vcpu->arch.busy_stolen += now - vcpu->arch.busy_preempt; in kvmppc_core_vcpu_load_hv()
348 vcpu->arch.busy_preempt = TB_NIL; in kvmppc_core_vcpu_load_hv()
350 spin_unlock_irqrestore(&vcpu->arch.tbacct_lock, flags); in kvmppc_core_vcpu_load_hv()
355 struct kvmppc_vcore *vc = vcpu->arch.vcore; in kvmppc_core_vcpu_put_hv()
364 WARN_ON_ONCE(vcpu->arch.state == KVMPPC_VCPU_RUNNABLE); in kvmppc_core_vcpu_put_hv()
370 vcpu->arch.state == KVMPPC_VCPU_BUSY_IN_HOST) in kvmppc_core_vcpu_put_hv()
371 vcpu->arch.busy_preempt = mftb(); in kvmppc_core_vcpu_put_hv()
377 if (vc->runner == vcpu && vc->vcore_state >= VCORE_SLEEPING) in kvmppc_core_vcpu_put_hv()
380 spin_lock_irqsave(&vcpu->arch.tbacct_lock, flags); in kvmppc_core_vcpu_put_hv()
381 if (vcpu->arch.state == KVMPPC_VCPU_BUSY_IN_HOST) in kvmppc_core_vcpu_put_hv()
382 vcpu->arch.busy_preempt = now; in kvmppc_core_vcpu_put_hv()
383 spin_unlock_irqrestore(&vcpu->arch.tbacct_lock, flags); in kvmppc_core_vcpu_put_hv()
388 vcpu->arch.pvr = pvr; in kvmppc_set_pvr_hv()
415 struct kvmppc_vcore *vc = vcpu->arch.vcore; in kvmppc_set_arch_compat()
451 return -EINVAL; in kvmppc_set_arch_compat()
457 return -EINVAL; in kvmppc_set_arch_compat()
467 return -EINVAL; in kvmppc_set_arch_compat()
470 spin_lock(&vc->lock); in kvmppc_set_arch_compat()
471 vc->arch_compat = arch_compat; in kvmppc_set_arch_compat()
477 vc->pcr = (host_pcr_bit - guest_pcr_bit) | PCR_MASK; in kvmppc_set_arch_compat()
478 spin_unlock(&vc->lock); in kvmppc_set_arch_compat()
487 pr_err("vcpu %p (%d):\n", vcpu, vcpu->vcpu_id); in kvmppc_dump_regs()
489 vcpu->arch.regs.nip, vcpu->arch.shregs.msr, vcpu->arch.trap); in kvmppc_dump_regs()
495 vcpu->arch.regs.ctr, vcpu->arch.regs.link); in kvmppc_dump_regs()
497 vcpu->arch.shregs.srr0, vcpu->arch.shregs.srr1); in kvmppc_dump_regs()
499 vcpu->arch.shregs.sprg0, vcpu->arch.shregs.sprg1); in kvmppc_dump_regs()
501 vcpu->arch.shregs.sprg2, vcpu->arch.shregs.sprg3); in kvmppc_dump_regs()
503 vcpu->arch.regs.ccr, vcpu->arch.regs.xer, vcpu->arch.shregs.dsisr); in kvmppc_dump_regs()
504 pr_err("dar = %.16llx\n", vcpu->arch.shregs.dar); in kvmppc_dump_regs()
506 vcpu->arch.fault_dar, vcpu->arch.fault_dsisr); in kvmppc_dump_regs()
507 pr_err("SLB (%d entries):\n", vcpu->arch.slb_max); in kvmppc_dump_regs()
508 for (r = 0; r < vcpu->arch.slb_max; ++r) in kvmppc_dump_regs()
510 vcpu->arch.slb[r].orige, vcpu->arch.slb[r].origv); in kvmppc_dump_regs()
512 vcpu->arch.vcore->lpcr, vcpu->kvm->arch.sdr1, in kvmppc_dump_regs()
513 vcpu->arch.last_inst); in kvmppc_dump_regs()
523 vpa->__old_status |= LPPACA_OLD_SHARED_PROC; in init_vpa()
524 vpa->yield_count = cpu_to_be32(1); in init_vpa()
531 if (addr & (L1_CACHE_BYTES - 1)) in set_vpa()
532 return -EINVAL; in set_vpa()
533 spin_lock(&vcpu->arch.vpa_update_lock); in set_vpa()
534 if (v->next_gpa != addr || v->len != len) { in set_vpa()
535 v->next_gpa = addr; in set_vpa()
536 v->len = addr ? len : 0; in set_vpa()
537 v->update_pending = 1; in set_vpa()
539 spin_unlock(&vcpu->arch.vpa_update_lock); in set_vpa()
543 /* Length for a per-processor buffer is passed in at offset 4 in the buffer */
554 if (vpap->update_pending) in vpa_is_registered()
555 return vpap->next_gpa != 0; in vpa_is_registered()
556 return vpap->pinned_addr != NULL; in vpa_is_registered()
563 struct kvm *kvm = vcpu->kvm; in do_h_register_vpa()
578 /* Registering new area - address must be cache-line aligned */ in do_h_register_vpa()
579 if ((vpa & (L1_CACHE_BYTES - 1)) || !vpa) in do_h_register_vpa()
587 len = be16_to_cpu(((struct reg_vpa *)va)->length.hword); in do_h_register_vpa()
589 len = be32_to_cpu(((struct reg_vpa *)va)->length.word); in do_h_register_vpa()
602 spin_lock(&tvcpu->arch.vpa_update_lock); in do_h_register_vpa()
615 vpap = &tvcpu->arch.vpa; in do_h_register_vpa()
622 len -= len % sizeof(struct dtl_entry); in do_h_register_vpa()
626 if (!vpa_is_registered(&tvcpu->arch.vpa)) in do_h_register_vpa()
629 vpap = &tvcpu->arch.dtl; in do_h_register_vpa()
636 if (!vpa_is_registered(&tvcpu->arch.vpa)) in do_h_register_vpa()
639 vpap = &tvcpu->arch.slb_shadow; in do_h_register_vpa()
646 if (vpa_is_registered(&tvcpu->arch.dtl) || in do_h_register_vpa()
647 vpa_is_registered(&tvcpu->arch.slb_shadow)) in do_h_register_vpa()
650 vpap = &tvcpu->arch.vpa; in do_h_register_vpa()
655 vpap = &tvcpu->arch.dtl; in do_h_register_vpa()
660 vpap = &tvcpu->arch.slb_shadow; in do_h_register_vpa()
666 vpap->next_gpa = vpa; in do_h_register_vpa()
667 vpap->len = len; in do_h_register_vpa()
668 vpap->update_pending = 1; in do_h_register_vpa()
671 spin_unlock(&tvcpu->arch.vpa_update_lock); in do_h_register_vpa()
679 struct kvm *kvm = vcpu->kvm; in kvmppc_update_vpa()
685 * We need to pin the page pointed to by vpap->next_gpa, in kvmppc_update_vpa()
693 gpa = vpap->next_gpa; in kvmppc_update_vpa()
694 spin_unlock(&vcpu->arch.vpa_update_lock); in kvmppc_update_vpa()
699 spin_lock(&vcpu->arch.vpa_update_lock); in kvmppc_update_vpa()
700 if (gpa == vpap->next_gpa) in kvmppc_update_vpa()
707 vpap->update_pending = 0; in kvmppc_update_vpa()
708 if (va && nb < vpap->len) { in kvmppc_update_vpa()
719 vpap->gpa = gpa; in kvmppc_update_vpa()
720 vpap->pinned_addr = va; in kvmppc_update_vpa()
721 vpap->dirty = false; in kvmppc_update_vpa()
723 vpap->pinned_end = va + vpap->len; in kvmppc_update_vpa()
728 struct kvm *kvm = vcpu->kvm; in kvmppc_update_vpas()
731 if (!(vcpu->arch.vpa.update_pending || in kvmppc_update_vpas()
732 vcpu->arch.slb_shadow.update_pending || in kvmppc_update_vpas()
733 vcpu->arch.dtl.update_pending)) in kvmppc_update_vpas()
736 spin_lock(&vcpu->arch.vpa_update_lock); in kvmppc_update_vpas()
737 if (vcpu->arch.vpa.update_pending) { in kvmppc_update_vpas()
738 kvmppc_update_vpa(vcpu, &vcpu->arch.vpa, &old_vpa); in kvmppc_update_vpas()
745 if (vcpu->arch.vpa.pinned_addr) { in kvmppc_update_vpas()
746 init_vpa(vcpu, vcpu->arch.vpa.pinned_addr); in kvmppc_update_vpas()
748 kvmhv_nestedv2_set_vpa(vcpu, __pa(vcpu->arch.vpa.pinned_addr)); in kvmppc_update_vpas()
751 if (vcpu->arch.dtl.update_pending) { in kvmppc_update_vpas()
752 kvmppc_update_vpa(vcpu, &vcpu->arch.dtl, &old_vpa); in kvmppc_update_vpas()
756 vcpu->arch.dtl_ptr = vcpu->arch.dtl.pinned_addr; in kvmppc_update_vpas()
757 vcpu->arch.dtl_index = 0; in kvmppc_update_vpas()
759 if (vcpu->arch.slb_shadow.update_pending) { in kvmppc_update_vpas()
760 kvmppc_update_vpa(vcpu, &vcpu->arch.slb_shadow, &old_vpa); in kvmppc_update_vpas()
766 spin_unlock(&vcpu->arch.vpa_update_lock); in kvmppc_update_vpas()
780 spin_lock_irqsave(&vc->stoltb_lock, flags); in vcore_stolen_time()
781 p = vc->stolen_tb; in vcore_stolen_time()
782 if (vc->vcore_state != VCORE_INACTIVE && in vcore_stolen_time()
783 vc->preempt_tb != TB_NIL) in vcore_stolen_time()
784 p += now - vc->preempt_tb; in vcore_stolen_time()
785 spin_unlock_irqrestore(&vc->stoltb_lock, flags); in vcore_stolen_time()
796 dt = vcpu->arch.dtl_ptr; in __kvmppc_create_dtl_entry()
801 dt->dispatch_reason = 7; in __kvmppc_create_dtl_entry()
802 dt->preempt_reason = 0; in __kvmppc_create_dtl_entry()
803 dt->processor_id = cpu_to_be16(pcpu + vcpu->arch.ptid); in __kvmppc_create_dtl_entry()
804 dt->enqueue_to_dispatch_time = cpu_to_be32(stolen); in __kvmppc_create_dtl_entry()
805 dt->ready_to_enqueue_time = 0; in __kvmppc_create_dtl_entry()
806 dt->waiting_to_ready_time = 0; in __kvmppc_create_dtl_entry()
807 dt->timebase = cpu_to_be64(now); in __kvmppc_create_dtl_entry()
808 dt->fault_addr = 0; in __kvmppc_create_dtl_entry()
809 dt->srr0 = cpu_to_be64(kvmppc_get_pc(vcpu)); in __kvmppc_create_dtl_entry()
810 dt->srr1 = cpu_to_be64(vcpu->arch.shregs.msr); in __kvmppc_create_dtl_entry()
813 if (dt == vcpu->arch.dtl.pinned_end) in __kvmppc_create_dtl_entry()
814 dt = vcpu->arch.dtl.pinned_addr; in __kvmppc_create_dtl_entry()
815 vcpu->arch.dtl_ptr = dt; in __kvmppc_create_dtl_entry()
816 /* order writing *dt vs. writing vpa->dtl_idx */ in __kvmppc_create_dtl_entry()
818 vpa->dtl_idx = cpu_to_be64(++vcpu->arch.dtl_index); in __kvmppc_create_dtl_entry()
820 /* vcpu->arch.dtl.dirty is set by the caller */ in __kvmppc_create_dtl_entry()
832 vpa = vcpu->arch.vpa.pinned_addr; in kvmppc_update_vpa_dispatch()
839 stolen = core_stolen - vcpu->arch.stolen_logged; in kvmppc_update_vpa_dispatch()
840 vcpu->arch.stolen_logged = core_stolen; in kvmppc_update_vpa_dispatch()
841 spin_lock_irqsave(&vcpu->arch.tbacct_lock, flags); in kvmppc_update_vpa_dispatch()
842 stolen += vcpu->arch.busy_stolen; in kvmppc_update_vpa_dispatch()
843 vcpu->arch.busy_stolen = 0; in kvmppc_update_vpa_dispatch()
844 spin_unlock_irqrestore(&vcpu->arch.tbacct_lock, flags); in kvmppc_update_vpa_dispatch()
846 vpa->enqueue_dispatch_tb = cpu_to_be64(be64_to_cpu(vpa->enqueue_dispatch_tb) + stolen); in kvmppc_update_vpa_dispatch()
848 __kvmppc_create_dtl_entry(vcpu, vpa, vc->pcpu, now + kvmppc_get_tb_offset(vcpu), stolen); in kvmppc_update_vpa_dispatch()
850 vcpu->arch.vpa.dirty = true; in kvmppc_update_vpa_dispatch()
861 vpa = vcpu->arch.vpa.pinned_addr; in kvmppc_update_vpa_dispatch_p9()
865 stolen = vc->stolen_tb; in kvmppc_update_vpa_dispatch_p9()
866 stolen_delta = stolen - vcpu->arch.stolen_logged; in kvmppc_update_vpa_dispatch_p9()
867 vcpu->arch.stolen_logged = stolen; in kvmppc_update_vpa_dispatch_p9()
869 vpa->enqueue_dispatch_tb = cpu_to_be64(stolen); in kvmppc_update_vpa_dispatch_p9()
871 __kvmppc_create_dtl_entry(vcpu, vpa, vc->pcpu, now, stolen_delta); in kvmppc_update_vpa_dispatch_p9()
873 vcpu->arch.vpa.dirty = true; in kvmppc_update_vpa_dispatch_p9()
882 if (vcpu->arch.doorbell_request) in kvmppc_doorbell_pending()
887 * Ensure that the read of vcore->dpdes comes after the read in kvmppc_doorbell_pending()
888 * of vcpu->doorbell_request. This barrier matches the in kvmppc_doorbell_pending()
892 vc = vcpu->arch.vcore; in kvmppc_doorbell_pending()
893 thr = vcpu->vcpu_id - vc->first_vcpuid; in kvmppc_doorbell_pending()
894 return !!(vc->dpdes & (1 << thr)); in kvmppc_doorbell_pending()
943 if (!vcpu->kvm->arch.dawr1_enabled) in kvmppc_h_set_mode()
966 /* Copy guest memory in place - must reside within a single memslot */
978 return -EFAULT; in kvmppc_copy_guest()
979 if ((from + len) >= ((from_memslot->base_gfn + from_memslot->npages) in kvmppc_copy_guest()
981 return -EINVAL; in kvmppc_copy_guest()
984 return -EFAULT; in kvmppc_copy_guest()
985 from_addr |= (from & (PAGE_SIZE - 1)); in kvmppc_copy_guest()
990 return -EFAULT; in kvmppc_copy_guest()
991 if ((to + len) >= ((to_memslot->base_gfn + to_memslot->npages) in kvmppc_copy_guest()
993 return -EINVAL; in kvmppc_copy_guest()
996 return -EFAULT; in kvmppc_copy_guest()
997 to_addr |= (to & (PAGE_SIZE - 1)); in kvmppc_copy_guest()
1003 return -EFAULT; in kvmppc_copy_guest()
1012 u64 pg_mask = SZ_4K - 1; in kvmppc_h_page_init()
1026 ret = kvmppc_copy_guest(vcpu->kvm, dest, src, pg_sz); in kvmppc_h_page_init()
1030 ret = kvm_clear_guest(vcpu->kvm, dest, pg_sz); in kvmppc_h_page_init()
1042 struct kvmppc_vcore *vcore = target->arch.vcore; in kvm_arch_vcpu_yield_to()
1052 * mode handler is not called but no other threads are in the in kvm_arch_vcpu_yield_to()
1056 spin_lock(&vcore->lock); in kvm_arch_vcpu_yield_to()
1057 if (target->arch.state == KVMPPC_VCPU_RUNNABLE && in kvm_arch_vcpu_yield_to()
1058 vcore->vcore_state != VCORE_INACTIVE && in kvm_arch_vcpu_yield_to()
1059 vcore->runner) in kvm_arch_vcpu_yield_to()
1060 target = vcore->runner; in kvm_arch_vcpu_yield_to()
1061 spin_unlock(&vcore->lock); in kvm_arch_vcpu_yield_to()
1072 spin_lock(&vcpu->arch.vpa_update_lock); in kvmppc_get_yield_count()
1073 lppaca = (struct lppaca *)vcpu->arch.vpa.pinned_addr; in kvmppc_get_yield_count()
1075 yield_count = be32_to_cpu(lppaca->yield_count); in kvmppc_get_yield_count()
1076 spin_unlock(&vcpu->arch.vpa_update_lock); in kvmppc_get_yield_count()
1083 * Handles only nested process-scoped invalidation requests in L0.
1091 * The partition-scoped invalidations aren't handled here in L0. in kvmppc_nested_h_rpt_invalidate()
1101 do_h_rpt_invalidate_prt(pid, vcpu->arch.nested->shadow_lpid, in kvmppc_nested_h_rpt_invalidate()
1113 if (!kvm_is_radix(vcpu->kvm)) in kvmppc_h_rpt_invalidate()
1120 * Partition-scoped invalidation for nested guests. in kvmppc_h_rpt_invalidate()
1123 if (!nesting_enabled(vcpu->kvm)) in kvmppc_h_rpt_invalidate()
1135 * Process-scoped invalidation for L1 guests. in kvmppc_h_rpt_invalidate()
1137 do_h_rpt_invalidate_prt(id, vcpu->kvm->arch.lpid, in kvmppc_h_rpt_invalidate()
1144 struct kvm *kvm = vcpu->kvm; in kvmppc_pseries_do_hcall()
1152 !test_bit(req/4, vcpu->kvm->arch.enabled_hcalls)) in kvmppc_pseries_do_hcall()
1211 tvcpu->arch.prodded = 1; in kvmppc_pseries_do_hcall()
1213 if (tvcpu->arch.ceded) in kvmppc_pseries_do_hcall()
1218 if (target == -1) in kvmppc_pseries_do_hcall()
1236 if (list_empty(&kvm->arch.rtas_tokens)) in kvmppc_pseries_do_hcall()
1239 idx = srcu_read_lock(&kvm->srcu); in kvmppc_pseries_do_hcall()
1241 srcu_read_unlock(&kvm->srcu, idx); in kvmppc_pseries_do_hcall()
1243 if (rc == -ENOENT) in kvmppc_pseries_do_hcall()
1350 vcpu->arch.hcall_needed = 0; in kvmppc_pseries_do_hcall()
1351 return -EINTR; in kvmppc_pseries_do_hcall()
1354 vcpu->arch.hcall_needed = 0; in kvmppc_pseries_do_hcall()
1404 * Instead the kvm->arch.secure_guest flag is checked inside in kvmppc_pseries_do_hcall()
1415 vcpu->arch.hcall_needed = 0; in kvmppc_pseries_do_hcall()
1420 * Handle H_CEDE in the P9 path where we don't call the real-mode hcall
1429 vcpu->arch.ceded = 1; in kvmppc_cede()
1431 if (vcpu->arch.prodded) { in kvmppc_cede()
1432 vcpu->arch.prodded = 0; in kvmppc_cede()
1434 vcpu->arch.ceded = 0; in kvmppc_cede()
1467 /* See if it's in the real-mode table */ in kvmppc_hcall_impl_hv()
1485 vcpu->run->exit_reason = KVM_EXIT_DEBUG; in kvmppc_emulate_debug_inst()
1486 vcpu->run->debug.arch.address = kvmppc_get_pc(vcpu); in kvmppc_emulate_debug_inst()
1505 nthreads = vcpu->kvm->arch.emul_smt_mode; in kvmppc_read_dpdes()
1507 cpu = vcpu->vcpu_id & ~(nthreads - 1); in kvmppc_read_dpdes()
1509 v = kvmppc_find_vcpu(vcpu->kvm, cpu); in kvmppc_read_dpdes()
1515 * which will update its vcore->dpdes value. in kvmppc_read_dpdes()
1517 pcpu = READ_ONCE(v->cpu); in kvmppc_read_dpdes()
1527 * On POWER9, emulate doorbell-related instructions in order to
1528 * give the guest the illusion of running on a multi-threaded core.
1536 struct kvm *kvm = vcpu->kvm; in kvmppc_emulate_doorbell_instr()
1546 thr = vcpu->vcpu_id & (kvm->arch.emul_smt_mode - 1); in kvmppc_emulate_doorbell_instr()
1553 if (arg >= kvm->arch.emul_smt_mode) in kvmppc_emulate_doorbell_instr()
1555 tvcpu = kvmppc_find_vcpu(kvm, vcpu->vcpu_id - thr + arg); in kvmppc_emulate_doorbell_instr()
1558 if (!tvcpu->arch.doorbell_request) { in kvmppc_emulate_doorbell_instr()
1559 tvcpu->arch.doorbell_request = 1; in kvmppc_emulate_doorbell_instr()
1567 vcpu->arch.vcore->dpdes = 0; in kvmppc_emulate_doorbell_instr()
1568 vcpu->arch.doorbell_request = 0; in kvmppc_emulate_doorbell_instr()
1599 if (!(vcpu->arch.hfscr_permitted & HFSCR_PM)) in kvmppc_pmu_unavailable()
1609 if (!(vcpu->arch.hfscr_permitted & HFSCR_EBB)) in kvmppc_ebb_unavailable()
1619 if (!(vcpu->arch.hfscr_permitted & HFSCR_TM)) in kvmppc_tm_unavailable()
1630 struct kvm_run *run = vcpu->run; in kvmppc_handle_exit_hv()
1633 vcpu->stat.sum_exits++; in kvmppc_handle_exit_hv()
1638 * setting paca->kvm_hstate.in_guest to KVM_GUEST_MODE_GUEST_HV in kvmppc_handle_exit_hv()
1646 vcpu->arch.trap, kvmppc_get_pc(vcpu), in kvmppc_handle_exit_hv()
1647 vcpu->arch.shregs.msr); in kvmppc_handle_exit_hv()
1649 run->exit_reason = KVM_EXIT_INTERNAL_ERROR; in kvmppc_handle_exit_hv()
1650 run->hw.hardware_exit_reason = vcpu->arch.trap; in kvmppc_handle_exit_hv()
1653 run->exit_reason = KVM_EXIT_UNKNOWN; in kvmppc_handle_exit_hv()
1654 run->ready_for_interrupt_injection = 1; in kvmppc_handle_exit_hv()
1655 switch (vcpu->arch.trap) { in kvmppc_handle_exit_hv()
1656 /* We're good on these - the host merely wanted to get our attention */ in kvmppc_handle_exit_hv()
1659 vcpu->arch.trap = BOOK3S_INTERRUPT_HV_DECREMENTER; in kvmppc_handle_exit_hv()
1662 vcpu->stat.dec_exits++; in kvmppc_handle_exit_hv()
1668 vcpu->stat.ext_intr_exits++; in kvmppc_handle_exit_hv()
1685 machine_check_print_event_info(&vcpu->arch.mce_evt,false, true); in kvmppc_handle_exit_hv()
1693 if (!vcpu->kvm->arch.fwnmi_enabled) { in kvmppc_handle_exit_hv()
1702 run->exit_reason = KVM_EXIT_NMI; in kvmppc_handle_exit_hv()
1703 run->hw.hardware_exit_reason = vcpu->arch.trap; in kvmppc_handle_exit_hv()
1704 /* Clear out the old NMI status from run->flags */ in kvmppc_handle_exit_hv()
1705 run->flags &= ~KVM_RUN_PPC_NMI_DISP_MASK; in kvmppc_handle_exit_hv()
1707 if (vcpu->arch.mce_evt.disposition == MCE_DISPOSITION_RECOVERED) in kvmppc_handle_exit_hv()
1708 run->flags |= KVM_RUN_PPC_NMI_DISP_FULLY_RECOV; in kvmppc_handle_exit_hv()
1710 run->flags |= KVM_RUN_PPC_NMI_DISP_NOT_RECOV; in kvmppc_handle_exit_hv()
1761 * hcall - gather args and set exit_reason. This will next be in kvmppc_handle_exit_hv()
1765 run->papr_hcall.nr = kvmppc_get_gpr(vcpu, 3); in kvmppc_handle_exit_hv()
1767 run->papr_hcall.args[i] = kvmppc_get_gpr(vcpu, 4 + i); in kvmppc_handle_exit_hv()
1768 run->exit_reason = KVM_EXIT_PAPR_HCALL; in kvmppc_handle_exit_hv()
1769 vcpu->arch.hcall_needed = 1; in kvmppc_handle_exit_hv()
1788 unlikely(vcpu->arch.fault_dsisr == HDSISR_CANARY)) { in kvmppc_handle_exit_hv()
1793 if (kvm_is_radix(vcpu->kvm) || !cpu_has_feature(CPU_FTR_ARCH_300)) { in kvmppc_handle_exit_hv()
1795 * Radix doesn't require anything, and pre-ISAv3.0 hash in kvmppc_handle_exit_hv()
1804 if (!(vcpu->arch.fault_dsisr & (DSISR_NOHPTE | DSISR_PROTFAULT))) { in kvmppc_handle_exit_hv()
1807 vcpu->arch.fault_dar, vcpu->arch.fault_dsisr); in kvmppc_handle_exit_hv()
1813 vsid = vcpu->kvm->arch.vrma_slb_v; in kvmppc_handle_exit_hv()
1815 vsid = vcpu->arch.fault_gpa; in kvmppc_handle_exit_hv()
1817 err = kvmppc_hpte_hv_fault(vcpu, vcpu->arch.fault_dar, in kvmppc_handle_exit_hv()
1818 vsid, vcpu->arch.fault_dsisr, true); in kvmppc_handle_exit_hv()
1821 } else if (err == -1 || err == -2) { in kvmppc_handle_exit_hv()
1826 vcpu->arch.fault_dar, err); in kvmppc_handle_exit_hv()
1835 vcpu->arch.fault_dar = kvmppc_get_pc(vcpu); in kvmppc_handle_exit_hv()
1836 vcpu->arch.fault_dsisr = __kvmppc_get_msr_hv(vcpu) & in kvmppc_handle_exit_hv()
1838 if (kvm_is_radix(vcpu->kvm) || !cpu_has_feature(CPU_FTR_ARCH_300)) { in kvmppc_handle_exit_hv()
1840 * Radix doesn't require anything, and pre-ISAv3.0 hash in kvmppc_handle_exit_hv()
1846 vcpu->arch.fault_dsisr |= DSISR_ISSTORE; in kvmppc_handle_exit_hv()
1851 if (!(vcpu->arch.fault_dsisr & SRR1_ISI_NOPT)) { in kvmppc_handle_exit_hv()
1853 vcpu->arch.fault_dsisr | in kvmppc_handle_exit_hv()
1860 vsid = vcpu->kvm->arch.vrma_slb_v; in kvmppc_handle_exit_hv()
1862 vsid = vcpu->arch.fault_gpa; in kvmppc_handle_exit_hv()
1864 err = kvmppc_hpte_hv_fault(vcpu, vcpu->arch.fault_dar, in kvmppc_handle_exit_hv()
1865 vsid, vcpu->arch.fault_dsisr, false); in kvmppc_handle_exit_hv()
1868 } else if (err == -1) { in kvmppc_handle_exit_hv()
1886 if (vcpu->arch.emul_inst != KVM_INST_FETCH_FAILED) in kvmppc_handle_exit_hv()
1887 vcpu->arch.last_inst = kvmppc_need_byteswap(vcpu) ? in kvmppc_handle_exit_hv()
1888 swab32(vcpu->arch.emul_inst) : in kvmppc_handle_exit_hv()
1889 vcpu->arch.emul_inst; in kvmppc_handle_exit_hv()
1890 if (vcpu->guest_debug & KVM_GUESTDBG_USE_SW_BP) { in kvmppc_handle_exit_hv()
1902 * This occurs for various TM-related instructions that in kvmppc_handle_exit_hv()
1904 * handled the cases where the guest was in real-suspend in kvmppc_handle_exit_hv()
1908 if (r != -1) in kvmppc_handle_exit_hv()
1956 vcpu->arch.trap, kvmppc_get_pc(vcpu), in kvmppc_handle_exit_hv()
1958 run->hw.hardware_exit_reason = vcpu->arch.trap; in kvmppc_handle_exit_hv()
1971 vcpu->stat.sum_exits++; in kvmppc_handle_nested_exit()
1976 * setting paca->kvm_hstate.in_guest to KVM_GUEST_MODE_GUEST_HV in kvmppc_handle_nested_exit()
1984 vcpu->arch.trap, kvmppc_get_pc(vcpu), in kvmppc_handle_nested_exit()
1989 switch (vcpu->arch.trap) { in kvmppc_handle_nested_exit()
1990 /* We're good on these - the host merely wanted to get our attention */ in kvmppc_handle_nested_exit()
1992 vcpu->stat.dec_exits++; in kvmppc_handle_nested_exit()
1996 vcpu->stat.ext_intr_exits++; in kvmppc_handle_nested_exit()
2001 vcpu->stat.ext_intr_exits++; in kvmppc_handle_nested_exit()
2006 vcpu->arch.trap = BOOK3S_INTERRUPT_HV_DECREMENTER; in kvmppc_handle_nested_exit()
2007 vcpu->stat.dec_exits++; in kvmppc_handle_nested_exit()
2024 machine_check_print_event_info(&vcpu->arch.mce_evt, false, true); in kvmppc_handle_nested_exit()
2034 srcu_idx = srcu_read_lock(&vcpu->kvm->srcu); in kvmppc_handle_nested_exit()
2036 srcu_read_unlock(&vcpu->kvm->srcu, srcu_idx); in kvmppc_handle_nested_exit()
2039 vcpu->arch.fault_dar = kvmppc_get_pc(vcpu); in kvmppc_handle_nested_exit()
2040 vcpu->arch.fault_dsisr = kvmppc_get_msr(vcpu) & in kvmppc_handle_nested_exit()
2043 vcpu->arch.fault_dsisr |= DSISR_ISSTORE; in kvmppc_handle_nested_exit()
2044 srcu_idx = srcu_read_lock(&vcpu->kvm->srcu); in kvmppc_handle_nested_exit()
2046 srcu_read_unlock(&vcpu->kvm->srcu, srcu_idx); in kvmppc_handle_nested_exit()
2052 * This occurs for various TM-related instructions that in kvmppc_handle_nested_exit()
2054 * handled the cases where the guest was in real-suspend in kvmppc_handle_nested_exit()
2058 if (r != -1) in kvmppc_handle_nested_exit()
2064 u64 cause = vcpu->arch.hfscr >> 56; in kvmppc_handle_nested_exit()
2072 if (!(vcpu->arch.hfscr_permitted & (1UL << cause)) || in kvmppc_handle_nested_exit()
2073 (vcpu->arch.nested_hfscr & (1UL << cause))) { in kvmppc_handle_nested_exit()
2075 vcpu->arch.trap = BOOK3S_INTERRUPT_H_EMUL_ASSIST; in kvmppc_handle_nested_exit()
2082 vcpu->arch.emul_inst = ppc_inst_val(pinst); in kvmppc_handle_nested_exit()
2095 vcpu->arch.trap = 0; in kvmppc_handle_nested_exit()
2106 * guests for process-scoped invalidations when in kvmppc_handle_nested_exit()
2131 sregs->pvr = vcpu->arch.pvr; in kvm_arch_vcpu_ioctl_get_sregs_hv()
2132 for (i = 0; i < vcpu->arch.slb_max; i++) { in kvm_arch_vcpu_ioctl_get_sregs_hv()
2133 sregs->u.s.ppc64.slb[i].slbe = vcpu->arch.slb[i].orige; in kvm_arch_vcpu_ioctl_get_sregs_hv()
2134 sregs->u.s.ppc64.slb[i].slbv = vcpu->arch.slb[i].origv; in kvm_arch_vcpu_ioctl_get_sregs_hv()
2146 if (sregs->pvr != vcpu->arch.pvr) in kvm_arch_vcpu_ioctl_set_sregs_hv()
2147 return -EINVAL; in kvm_arch_vcpu_ioctl_set_sregs_hv()
2150 for (i = 0; i < vcpu->arch.slb_nr; i++) { in kvm_arch_vcpu_ioctl_set_sregs_hv()
2151 if (sregs->u.s.ppc64.slb[i].slbe & SLB_ESID_V) { in kvm_arch_vcpu_ioctl_set_sregs_hv()
2152 vcpu->arch.slb[j].orige = sregs->u.s.ppc64.slb[i].slbe; in kvm_arch_vcpu_ioctl_set_sregs_hv()
2153 vcpu->arch.slb[j].origv = sregs->u.s.ppc64.slb[i].slbv; in kvm_arch_vcpu_ioctl_set_sregs_hv()
2157 vcpu->arch.slb_max = j; in kvm_arch_vcpu_ioctl_set_sregs_hv()
2208 struct kvm *kvm = vcpu->kvm; in kvmppc_set_lpcr()
2209 struct kvmppc_vcore *vc = vcpu->arch.vcore; in kvmppc_set_lpcr()
2212 spin_lock(&vc->lock); in kvmppc_set_lpcr()
2216 * DPFD (default prefetch depth), ILE (interrupt little-endian), in kvmppc_set_lpcr()
2223 /* Broken 32-bit version of LPCR must not clear top bits */ in kvmppc_set_lpcr()
2228 (vc->lpcr & ~mask) | (new_lpcr & mask)); in kvmppc_set_lpcr()
2231 * If ILE (interrupt little-endian) has changed, update the in kvmppc_set_lpcr()
2234 if ((new_lpcr & LPCR_ILE) != (vc->lpcr & LPCR_ILE)) { in kvmppc_set_lpcr()
2239 if (vcpu->arch.vcore != vc) in kvmppc_set_lpcr()
2242 vcpu->arch.intr_msr |= MSR_LE; in kvmppc_set_lpcr()
2244 vcpu->arch.intr_msr &= ~MSR_LE; in kvmppc_set_lpcr()
2248 vc->lpcr = new_lpcr; in kvmppc_set_lpcr()
2251 spin_unlock(&vc->lock); in kvmppc_set_lpcr()
2268 *val = get_reg_val(id, vcpu->arch.dabr); in kvmppc_get_one_reg_hv()
2271 *val = get_reg_val(id, vcpu->arch.dabrx); in kvmppc_get_one_reg_hv()
2289 i = id - KVM_REG_PPC_MMCR0; in kvmppc_get_one_reg_hv()
2299 *val = get_reg_val(id, vcpu->arch.mmcrs); in kvmppc_get_one_reg_hv()
2305 i = id - KVM_REG_PPC_PMC1; in kvmppc_get_one_reg_hv()
2309 i = id - KVM_REG_PPC_SPMC1; in kvmppc_get_one_reg_hv()
2310 *val = get_reg_val(id, vcpu->arch.spmc[i]); in kvmppc_get_one_reg_hv()
2337 * either vcore->dpdes or doorbell_request. in kvmppc_get_one_reg_hv()
2341 *val = get_reg_val(id, vcpu->arch.doorbell_request); in kvmppc_get_one_reg_hv()
2343 *val = get_reg_val(id, vcpu->arch.vcore->dpdes); in kvmppc_get_one_reg_hv()
2373 *val = get_reg_val(id, vcpu->arch.csigr); in kvmppc_get_one_reg_hv()
2376 *val = get_reg_val(id, vcpu->arch.tacr); in kvmppc_get_one_reg_hv()
2379 *val = get_reg_val(id, vcpu->arch.tcscr); in kvmppc_get_one_reg_hv()
2385 *val = get_reg_val(id, vcpu->arch.acop); in kvmppc_get_one_reg_hv()
2391 *val = get_reg_val(id, vcpu->arch.tid); in kvmppc_get_one_reg_hv()
2394 *val = get_reg_val(id, vcpu->arch.psscr); in kvmppc_get_one_reg_hv()
2397 spin_lock(&vcpu->arch.vpa_update_lock); in kvmppc_get_one_reg_hv()
2398 *val = get_reg_val(id, vcpu->arch.vpa.next_gpa); in kvmppc_get_one_reg_hv()
2399 spin_unlock(&vcpu->arch.vpa_update_lock); in kvmppc_get_one_reg_hv()
2402 spin_lock(&vcpu->arch.vpa_update_lock); in kvmppc_get_one_reg_hv()
2403 val->vpaval.addr = vcpu->arch.slb_shadow.next_gpa; in kvmppc_get_one_reg_hv()
2404 val->vpaval.length = vcpu->arch.slb_shadow.len; in kvmppc_get_one_reg_hv()
2405 spin_unlock(&vcpu->arch.vpa_update_lock); in kvmppc_get_one_reg_hv()
2408 spin_lock(&vcpu->arch.vpa_update_lock); in kvmppc_get_one_reg_hv()
2409 val->vpaval.addr = vcpu->arch.dtl.next_gpa; in kvmppc_get_one_reg_hv()
2410 val->vpaval.length = vcpu->arch.dtl.len; in kvmppc_get_one_reg_hv()
2411 spin_unlock(&vcpu->arch.vpa_update_lock); in kvmppc_get_one_reg_hv()
2425 *val = get_reg_val(id, vcpu->arch.tfhar); in kvmppc_get_one_reg_hv()
2428 *val = get_reg_val(id, vcpu->arch.tfiar); in kvmppc_get_one_reg_hv()
2431 *val = get_reg_val(id, vcpu->arch.texasr); in kvmppc_get_one_reg_hv()
2434 i = id - KVM_REG_PPC_TM_GPR0; in kvmppc_get_one_reg_hv()
2435 *val = get_reg_val(id, vcpu->arch.gpr_tm[i]); in kvmppc_get_one_reg_hv()
2440 i = id - KVM_REG_PPC_TM_VSR0; in kvmppc_get_one_reg_hv()
2443 val->vsxval[j] = vcpu->arch.fp_tm.fpr[i][j]; in kvmppc_get_one_reg_hv()
2446 val->vval = vcpu->arch.vr_tm.vr[i-32]; in kvmppc_get_one_reg_hv()
2448 r = -ENXIO; in kvmppc_get_one_reg_hv()
2453 *val = get_reg_val(id, vcpu->arch.cr_tm); in kvmppc_get_one_reg_hv()
2456 *val = get_reg_val(id, vcpu->arch.xer_tm); in kvmppc_get_one_reg_hv()
2459 *val = get_reg_val(id, vcpu->arch.lr_tm); in kvmppc_get_one_reg_hv()
2462 *val = get_reg_val(id, vcpu->arch.ctr_tm); in kvmppc_get_one_reg_hv()
2465 *val = get_reg_val(id, vcpu->arch.fp_tm.fpscr); in kvmppc_get_one_reg_hv()
2468 *val = get_reg_val(id, vcpu->arch.amr_tm); in kvmppc_get_one_reg_hv()
2471 *val = get_reg_val(id, vcpu->arch.ppr_tm); in kvmppc_get_one_reg_hv()
2474 *val = get_reg_val(id, vcpu->arch.vrsave_tm); in kvmppc_get_one_reg_hv()
2478 *val = get_reg_val(id, vcpu->arch.vr_tm.vscr.u[3]); in kvmppc_get_one_reg_hv()
2480 r = -ENXIO; in kvmppc_get_one_reg_hv()
2483 *val = get_reg_val(id, vcpu->arch.dscr_tm); in kvmppc_get_one_reg_hv()
2486 *val = get_reg_val(id, vcpu->arch.tar_tm); in kvmppc_get_one_reg_hv()
2496 *val = get_reg_val(id, vcpu->arch.online); in kvmppc_get_one_reg_hv()
2499 *val = get_reg_val(id, vcpu->kvm->arch.l1_ptcr); in kvmppc_get_one_reg_hv()
2505 r = -EINVAL; in kvmppc_get_one_reg_hv()
2523 r = -EINVAL; in kvmppc_set_one_reg_hv()
2526 vcpu->arch.dabr = set_reg_val(id, *val); in kvmppc_set_one_reg_hv()
2529 vcpu->arch.dabrx = set_reg_val(id, *val) & ~DABRX_HYP; in kvmppc_set_one_reg_hv()
2547 i = id - KVM_REG_PPC_MMCR0; in kvmppc_set_one_reg_hv()
2557 vcpu->arch.mmcrs = set_reg_val(id, *val); in kvmppc_set_one_reg_hv()
2563 i = id - KVM_REG_PPC_PMC1; in kvmppc_set_one_reg_hv()
2567 i = id - KVM_REG_PPC_SPMC1; in kvmppc_set_one_reg_hv()
2568 vcpu->arch.spmc[i] = set_reg_val(id, *val); in kvmppc_set_one_reg_hv()
2593 vcpu->arch.doorbell_request = set_reg_val(id, *val) & 1; in kvmppc_set_one_reg_hv()
2595 vcpu->arch.vcore->dpdes = set_reg_val(id, *val); in kvmppc_set_one_reg_hv()
2628 vcpu->arch.csigr = set_reg_val(id, *val); in kvmppc_set_one_reg_hv()
2631 vcpu->arch.tacr = set_reg_val(id, *val); in kvmppc_set_one_reg_hv()
2634 vcpu->arch.tcscr = set_reg_val(id, *val); in kvmppc_set_one_reg_hv()
2640 vcpu->arch.acop = set_reg_val(id, *val); in kvmppc_set_one_reg_hv()
2646 vcpu->arch.tid = set_reg_val(id, *val); in kvmppc_set_one_reg_hv()
2649 vcpu->arch.psscr = set_reg_val(id, *val) & PSSCR_GUEST_VIS; in kvmppc_set_one_reg_hv()
2653 r = -EINVAL; in kvmppc_set_one_reg_hv()
2654 if (!addr && (vcpu->arch.slb_shadow.next_gpa || in kvmppc_set_one_reg_hv()
2655 vcpu->arch.dtl.next_gpa)) in kvmppc_set_one_reg_hv()
2657 r = set_vpa(vcpu, &vcpu->arch.vpa, addr, sizeof(struct lppaca)); in kvmppc_set_one_reg_hv()
2660 addr = val->vpaval.addr; in kvmppc_set_one_reg_hv()
2661 len = val->vpaval.length; in kvmppc_set_one_reg_hv()
2662 r = -EINVAL; in kvmppc_set_one_reg_hv()
2663 if (addr && !vcpu->arch.vpa.next_gpa) in kvmppc_set_one_reg_hv()
2665 r = set_vpa(vcpu, &vcpu->arch.slb_shadow, addr, len); in kvmppc_set_one_reg_hv()
2668 addr = val->vpaval.addr; in kvmppc_set_one_reg_hv()
2669 len = val->vpaval.length; in kvmppc_set_one_reg_hv()
2670 r = -EINVAL; in kvmppc_set_one_reg_hv()
2672 !vcpu->arch.vpa.next_gpa)) in kvmppc_set_one_reg_hv()
2674 len -= len % sizeof(struct dtl_entry); in kvmppc_set_one_reg_hv()
2675 r = set_vpa(vcpu, &vcpu->arch.dtl, addr, len); in kvmppc_set_one_reg_hv()
2708 vcpu->arch.tfhar = set_reg_val(id, *val); in kvmppc_set_one_reg_hv()
2711 vcpu->arch.tfiar = set_reg_val(id, *val); in kvmppc_set_one_reg_hv()
2714 vcpu->arch.texasr = set_reg_val(id, *val); in kvmppc_set_one_reg_hv()
2717 i = id - KVM_REG_PPC_TM_GPR0; in kvmppc_set_one_reg_hv()
2718 vcpu->arch.gpr_tm[i] = set_reg_val(id, *val); in kvmppc_set_one_reg_hv()
2723 i = id - KVM_REG_PPC_TM_VSR0; in kvmppc_set_one_reg_hv()
2726 vcpu->arch.fp_tm.fpr[i][j] = val->vsxval[j]; in kvmppc_set_one_reg_hv()
2729 vcpu->arch.vr_tm.vr[i-32] = val->vval; in kvmppc_set_one_reg_hv()
2731 r = -ENXIO; in kvmppc_set_one_reg_hv()
2735 vcpu->arch.cr_tm = set_reg_val(id, *val); in kvmppc_set_one_reg_hv()
2738 vcpu->arch.xer_tm = set_reg_val(id, *val); in kvmppc_set_one_reg_hv()
2741 vcpu->arch.lr_tm = set_reg_val(id, *val); in kvmppc_set_one_reg_hv()
2744 vcpu->arch.ctr_tm = set_reg_val(id, *val); in kvmppc_set_one_reg_hv()
2747 vcpu->arch.fp_tm.fpscr = set_reg_val(id, *val); in kvmppc_set_one_reg_hv()
2750 vcpu->arch.amr_tm = set_reg_val(id, *val); in kvmppc_set_one_reg_hv()
2753 vcpu->arch.ppr_tm = set_reg_val(id, *val); in kvmppc_set_one_reg_hv()
2756 vcpu->arch.vrsave_tm = set_reg_val(id, *val); in kvmppc_set_one_reg_hv()
2760 vcpu->arch.vr.vscr.u[3] = set_reg_val(id, *val); in kvmppc_set_one_reg_hv()
2762 r = - ENXIO; in kvmppc_set_one_reg_hv()
2765 vcpu->arch.dscr_tm = set_reg_val(id, *val); in kvmppc_set_one_reg_hv()
2768 vcpu->arch.tar_tm = set_reg_val(id, *val); in kvmppc_set_one_reg_hv()
2779 if (i && !vcpu->arch.online) in kvmppc_set_one_reg_hv()
2780 atomic_inc(&vcpu->arch.vcore->online_count); in kvmppc_set_one_reg_hv()
2781 else if (!i && vcpu->arch.online) in kvmppc_set_one_reg_hv()
2782 atomic_dec(&vcpu->arch.vcore->online_count); in kvmppc_set_one_reg_hv()
2783 vcpu->arch.online = i; in kvmppc_set_one_reg_hv()
2786 vcpu->kvm->arch.l1_ptcr = set_reg_val(id, *val); in kvmppc_set_one_reg_hv()
2792 r = -EINVAL; in kvmppc_set_one_reg_hv()
2822 spin_lock_init(&vcore->lock); in kvmppc_vcore_create()
2823 spin_lock_init(&vcore->stoltb_lock); in kvmppc_vcore_create()
2824 rcuwait_init(&vcore->wait); in kvmppc_vcore_create()
2825 vcore->preempt_tb = TB_NIL; in kvmppc_vcore_create()
2826 vcore->lpcr = kvm->arch.lpcr; in kvmppc_vcore_create()
2827 vcore->first_vcpuid = id; in kvmppc_vcore_create()
2828 vcore->kvm = kvm; in kvmppc_vcore_create()
2829 INIT_LIST_HEAD(&vcore->preempt_list); in kvmppc_vcore_create()
2866 struct kvm_vcpu *vcpu = inode->i_private; in debugfs_timings_open()
2871 return -ENOMEM; in debugfs_timings_open()
2873 kvm_get_kvm(vcpu->kvm); in debugfs_timings_open()
2874 p->vcpu = vcpu; in debugfs_timings_open()
2875 file->private_data = p; in debugfs_timings_open()
2882 struct debugfs_timings_state *p = file->private_data; in debugfs_timings_release()
2884 kvm_put_kvm(p->vcpu->kvm); in debugfs_timings_release()
2892 struct debugfs_timings_state *p = file->private_data; in debugfs_timings_read()
2893 struct kvm_vcpu *vcpu = p->vcpu; in debugfs_timings_read()
2902 if (!p->buflen) { in debugfs_timings_read()
2903 s = p->buf; in debugfs_timings_read()
2904 buf_end = s + sizeof(p->buf); in debugfs_timings_read()
2912 count = acc->seqcount; in debugfs_timings_read()
2917 if (count == acc->seqcount) { in debugfs_timings_read()
2925 snprintf(s, buf_end - s, "%s: stuck\n", in debugfs_timings_read()
2928 snprintf(s, buf_end - s, in debugfs_timings_read()
2936 p->buflen = s - p->buf; in debugfs_timings_read()
2940 if (pos >= p->buflen) in debugfs_timings_read()
2942 if (len > p->buflen - pos) in debugfs_timings_read()
2943 len = p->buflen - pos; in debugfs_timings_read()
2944 n = copy_to_user(buf, p->buf + pos, len); in debugfs_timings_read()
2947 return -EFAULT; in debugfs_timings_read()
2948 len -= n; in debugfs_timings_read()
2957 return -EACCES; in debugfs_timings_write()
2993 kvm = vcpu->kvm; in kvmppc_core_vcpu_create_hv()
2994 id = vcpu->vcpu_id; in kvmppc_core_vcpu_create_hv()
2996 vcpu->arch.shared = &vcpu->arch.shregs; in kvmppc_core_vcpu_create_hv()
3003 vcpu->arch.shared_big_endian = true; in kvmppc_core_vcpu_create_hv()
3005 vcpu->arch.shared_big_endian = false; in kvmppc_core_vcpu_create_hv()
3010 err = kvmhv_nestedv2_vcpu_create(vcpu, &vcpu->arch.nestedv2_io); in kvmppc_core_vcpu_create_hv()
3024 spin_lock_init(&vcpu->arch.vpa_update_lock); in kvmppc_core_vcpu_create_hv()
3025 spin_lock_init(&vcpu->arch.tbacct_lock); in kvmppc_core_vcpu_create_hv()
3026 vcpu->arch.busy_preempt = TB_NIL; in kvmppc_core_vcpu_create_hv()
3028 vcpu->arch.intr_msr = MSR_SF | MSR_ME; in kvmppc_core_vcpu_create_hv()
3053 vcpu->arch.hfscr |= HFSCR_TM; in kvmppc_core_vcpu_create_hv()
3055 vcpu->arch.hfscr_permitted = kvmppc_get_hfscr_hv(vcpu); in kvmppc_core_vcpu_create_hv()
3058 * PM, EBB, TM are demand-faulted so start with it clear. in kvmppc_core_vcpu_create_hv()
3064 vcpu->arch.state = KVMPPC_VCPU_NOTREADY; in kvmppc_core_vcpu_create_hv()
3066 init_waitqueue_head(&vcpu->arch.cpu_run); in kvmppc_core_vcpu_create_hv()
3068 mutex_lock(&kvm->lock); in kvmppc_core_vcpu_create_hv()
3070 err = -EINVAL; in kvmppc_core_vcpu_create_hv()
3072 if (id >= (KVM_MAX_VCPUS * kvm->arch.emul_smt_mode)) { in kvmppc_core_vcpu_create_hv()
3076 BUG_ON(kvm->arch.smt_mode != 1); in kvmppc_core_vcpu_create_hv()
3080 core = id / kvm->arch.smt_mode; in kvmppc_core_vcpu_create_hv()
3083 vcore = kvm->arch.vcores[core]; in kvmppc_core_vcpu_create_hv()
3092 err = -ENOMEM; in kvmppc_core_vcpu_create_hv()
3094 id & ~(kvm->arch.smt_mode - 1)); in kvmppc_core_vcpu_create_hv()
3095 mutex_lock(&kvm->arch.mmu_setup_lock); in kvmppc_core_vcpu_create_hv()
3096 kvm->arch.vcores[core] = vcore; in kvmppc_core_vcpu_create_hv()
3097 kvm->arch.online_vcores++; in kvmppc_core_vcpu_create_hv()
3098 mutex_unlock(&kvm->arch.mmu_setup_lock); in kvmppc_core_vcpu_create_hv()
3101 mutex_unlock(&kvm->lock); in kvmppc_core_vcpu_create_hv()
3106 spin_lock(&vcore->lock); in kvmppc_core_vcpu_create_hv()
3107 ++vcore->num_threads; in kvmppc_core_vcpu_create_hv()
3108 spin_unlock(&vcore->lock); in kvmppc_core_vcpu_create_hv()
3109 vcpu->arch.vcore = vcore; in kvmppc_core_vcpu_create_hv()
3110 vcpu->arch.ptid = vcpu->vcpu_id - vcore->first_vcpuid; in kvmppc_core_vcpu_create_hv()
3111 vcpu->arch.thread_cpu = -1; in kvmppc_core_vcpu_create_hv()
3112 vcpu->arch.prev_cpu = -1; in kvmppc_core_vcpu_create_hv()
3114 vcpu->arch.cpu_type = KVM_CPU_3S_64; in kvmppc_core_vcpu_create_hv()
3127 return -EINVAL; in kvmhv_set_smt_mode()
3129 return -EINVAL; in kvmhv_set_smt_mode()
3136 return -EINVAL; in kvmhv_set_smt_mode()
3145 mutex_lock(&kvm->lock); in kvmhv_set_smt_mode()
3146 err = -EBUSY; in kvmhv_set_smt_mode()
3147 if (!kvm->arch.online_vcores) { in kvmhv_set_smt_mode()
3148 kvm->arch.smt_mode = smt_mode; in kvmhv_set_smt_mode()
3149 kvm->arch.emul_smt_mode = esmt; in kvmhv_set_smt_mode()
3152 mutex_unlock(&kvm->lock); in kvmhv_set_smt_mode()
3159 if (vpa->pinned_addr) in unpin_vpa()
3160 kvmppc_unpin_guest_page(kvm, vpa->pinned_addr, vpa->gpa, in unpin_vpa()
3161 vpa->dirty); in unpin_vpa()
3166 spin_lock(&vcpu->arch.vpa_update_lock); in kvmppc_core_vcpu_free_hv()
3167 unpin_vpa(vcpu->kvm, &vcpu->arch.dtl); in kvmppc_core_vcpu_free_hv()
3168 unpin_vpa(vcpu->kvm, &vcpu->arch.slb_shadow); in kvmppc_core_vcpu_free_hv()
3169 unpin_vpa(vcpu->kvm, &vcpu->arch.vpa); in kvmppc_core_vcpu_free_hv()
3170 spin_unlock(&vcpu->arch.vpa_update_lock); in kvmppc_core_vcpu_free_hv()
3172 kvmhv_nestedv2_vcpu_free(vcpu, &vcpu->arch.nestedv2_io); in kvmppc_core_vcpu_free_hv()
3192 dec_nsec = tb_to_ns(kvmppc_dec_expires_host_tb(vcpu) - now); in kvmppc_set_timer()
3193 hrtimer_start(&vcpu->arch.dec_timer, dec_nsec, HRTIMER_MODE_REL); in kvmppc_set_timer()
3194 vcpu->arch.timer_running = 1; in kvmppc_set_timer()
3204 if (vcpu->arch.state != KVMPPC_VCPU_RUNNABLE) in kvmppc_remove_runnable()
3206 spin_lock_irq(&vcpu->arch.tbacct_lock); in kvmppc_remove_runnable()
3208 vcpu->arch.busy_stolen += vcore_stolen_time(vc, now) - in kvmppc_remove_runnable()
3209 vcpu->arch.stolen_logged; in kvmppc_remove_runnable()
3210 vcpu->arch.busy_preempt = now; in kvmppc_remove_runnable()
3211 vcpu->arch.state = KVMPPC_VCPU_BUSY_IN_HOST; in kvmppc_remove_runnable()
3212 spin_unlock_irq(&vcpu->arch.tbacct_lock); in kvmppc_remove_runnable()
3213 --vc->n_runnable; in kvmppc_remove_runnable()
3214 WRITE_ONCE(vc->runnable_threads[vcpu->arch.ptid], NULL); in kvmppc_remove_runnable()
3225 tpaca->kvm_hstate.kvm_vcpu = NULL; in kvmppc_grab_hwthread()
3226 tpaca->kvm_hstate.kvm_vcore = NULL; in kvmppc_grab_hwthread()
3227 tpaca->kvm_hstate.napping = 0; in kvmppc_grab_hwthread()
3229 tpaca->kvm_hstate.hwthread_req = 1; in kvmppc_grab_hwthread()
3241 while (tpaca->kvm_hstate.hwthread_state == KVM_HWTHREAD_IN_KERNEL) { in kvmppc_grab_hwthread()
3242 if (--timeout <= 0) { in kvmppc_grab_hwthread()
3244 return -EBUSY; in kvmppc_grab_hwthread()
3256 tpaca->kvm_hstate.hwthread_req = 0; in kvmppc_release_hwthread()
3257 tpaca->kvm_hstate.kvm_vcpu = NULL; in kvmppc_release_hwthread()
3258 tpaca->kvm_hstate.kvm_vcore = NULL; in kvmppc_release_hwthread()
3259 tpaca->kvm_hstate.kvm_split_mode = NULL; in kvmppc_release_hwthread()
3266 struct kvm_nested_guest *nested = vcpu->arch.nested; in radix_flush_cpu()
3271 need_tlb_flush = &nested->need_tlb_flush; in radix_flush_cpu()
3273 need_tlb_flush = &kvm->arch.need_tlb_flush; in radix_flush_cpu()
3301 struct kvm *kvm = vcpu->kvm; in do_migrate_away_vcpu()
3311 if (kvm->arch.lpcr & LPCR_GTSE) in do_migrate_away_vcpu()
3319 struct kvm_nested_guest *nested = vcpu->arch.nested; in kvmppc_prepare_radix_vcpu()
3320 struct kvm *kvm = vcpu->kvm; in kvmppc_prepare_radix_vcpu()
3327 prev_cpu = nested->prev_cpu[vcpu->arch.nested_vcpu_id]; in kvmppc_prepare_radix_vcpu()
3329 prev_cpu = vcpu->arch.prev_cpu; in kvmppc_prepare_radix_vcpu()
3352 nested->prev_cpu[vcpu->arch.nested_vcpu_id] = pcpu; in kvmppc_prepare_radix_vcpu()
3354 vcpu->arch.prev_cpu = pcpu; in kvmppc_prepare_radix_vcpu()
3363 cpu = vc->pcpu; in kvmppc_start_thread()
3365 if (vcpu->arch.timer_running) { in kvmppc_start_thread()
3366 hrtimer_try_to_cancel(&vcpu->arch.dec_timer); in kvmppc_start_thread()
3367 vcpu->arch.timer_running = 0; in kvmppc_start_thread()
3369 cpu += vcpu->arch.ptid; in kvmppc_start_thread()
3370 vcpu->cpu = vc->pcpu; in kvmppc_start_thread()
3371 vcpu->arch.thread_cpu = cpu; in kvmppc_start_thread()
3374 tpaca->kvm_hstate.kvm_vcpu = vcpu; in kvmppc_start_thread()
3375 tpaca->kvm_hstate.ptid = cpu - vc->pcpu; in kvmppc_start_thread()
3376 tpaca->kvm_hstate.fake_suspend = 0; in kvmppc_start_thread()
3379 tpaca->kvm_hstate.kvm_vcore = vc; in kvmppc_start_thread()
3396 * for any threads that still have a non-NULL vcore ptr. in kvmppc_wait_for_nap()
3399 if (paca_ptrs[cpu + i]->kvm_hstate.kvm_vcore) in kvmppc_wait_for_nap()
3409 if (paca_ptrs[cpu + i]->kvm_hstate.kvm_vcore) in kvmppc_wait_for_nap()
3415 * this core are off-line. Then grab the threads so they can't
3438 } while (--thr > 0); in on_primary_thread()
3463 spin_lock_init(&lp->lock); in init_vcore_lists()
3464 INIT_LIST_HEAD(&lp->list); in init_vcore_lists()
3474 vc->vcore_state = VCORE_PREEMPT; in kvmppc_vcore_preempt()
3475 vc->pcpu = smp_processor_id(); in kvmppc_vcore_preempt()
3476 if (vc->num_threads < threads_per_vcore(vc->kvm)) { in kvmppc_vcore_preempt()
3477 spin_lock(&lp->lock); in kvmppc_vcore_preempt()
3478 list_add_tail(&vc->preempt_list, &lp->list); in kvmppc_vcore_preempt()
3479 spin_unlock(&lp->lock); in kvmppc_vcore_preempt()
3493 if (!list_empty(&vc->preempt_list)) { in kvmppc_vcore_end_preempt()
3494 lp = &per_cpu(preempted_vcores, vc->pcpu); in kvmppc_vcore_end_preempt()
3495 spin_lock(&lp->lock); in kvmppc_vcore_end_preempt()
3496 list_del_init(&vc->preempt_list); in kvmppc_vcore_end_preempt()
3497 spin_unlock(&lp->lock); in kvmppc_vcore_end_preempt()
3499 vc->vcore_state = VCORE_INACTIVE; in kvmppc_vcore_end_preempt()
3515 * This mapping means subcores 0 and 1 can use threads 0-3 and 4-7
3516 * respectively in 2-way micro-threading (split-core) mode on POWER8.
3523 cip->n_subcores = 1; in init_core_info()
3524 cip->max_subcore_threads = vc->num_threads; in init_core_info()
3525 cip->total_threads = vc->num_threads; in init_core_info()
3526 cip->subcore_threads[0] = vc->num_threads; in init_core_info()
3527 cip->vc[0] = vc; in init_core_info()
3533 * POWER9 "SMT4" cores are permanently in what is effectively a 4-way in subcore_config_ok()
3534 * split-core mode, with one thread per subcore. in subcore_config_ok()
3556 vc->entry_exit_map = 0; in init_vcore_to_run()
3557 vc->in_guest = 0; in init_vcore_to_run()
3558 vc->napping_threads = 0; in init_vcore_to_run()
3559 vc->conferring_threads = 0; in init_vcore_to_run()
3560 vc->tb_offset_applied = 0; in init_vcore_to_run()
3565 int n_threads = vc->num_threads; in can_dynamic_split()
3572 if (one_vm_per_core && vc->kvm != cip->vc[0]->kvm) in can_dynamic_split()
3575 if (n_threads < cip->max_subcore_threads) in can_dynamic_split()
3576 n_threads = cip->max_subcore_threads; in can_dynamic_split()
3577 if (!subcore_config_ok(cip->n_subcores + 1, n_threads)) in can_dynamic_split()
3579 cip->max_subcore_threads = n_threads; in can_dynamic_split()
3581 sub = cip->n_subcores; in can_dynamic_split()
3582 ++cip->n_subcores; in can_dynamic_split()
3583 cip->total_threads += vc->num_threads; in can_dynamic_split()
3584 cip->subcore_threads[sub] = vc->num_threads; in can_dynamic_split()
3585 cip->vc[sub] = vc; in can_dynamic_split()
3587 list_del_init(&vc->preempt_list); in can_dynamic_split()
3599 if (cip->total_threads + pvc->num_threads > target_threads) in can_piggyback()
3611 if (signal_pending(vcpu->arch.run_task)) in prepare_threads()
3612 vcpu->arch.ret = -EINTR; in prepare_threads()
3613 else if (vcpu->arch.vpa.update_pending || in prepare_threads()
3614 vcpu->arch.slb_shadow.update_pending || in prepare_threads()
3615 vcpu->arch.dtl.update_pending) in prepare_threads()
3616 vcpu->arch.ret = RESUME_GUEST; in prepare_threads()
3620 wake_up(&vcpu->arch.cpu_run); in prepare_threads()
3629 spin_lock(&lp->lock); in collect_piggybacks()
3630 list_for_each_entry_safe(pvc, vcnext, &lp->list, preempt_list) { in collect_piggybacks()
3631 if (!spin_trylock(&pvc->lock)) in collect_piggybacks()
3634 if (!pvc->n_runnable || !pvc->kvm->arch.mmu_ready) { in collect_piggybacks()
3635 list_del_init(&pvc->preempt_list); in collect_piggybacks()
3636 if (pvc->runner == NULL) { in collect_piggybacks()
3637 pvc->vcore_state = VCORE_INACTIVE; in collect_piggybacks()
3640 spin_unlock(&pvc->lock); in collect_piggybacks()
3644 spin_unlock(&pvc->lock); in collect_piggybacks()
3648 pvc->vcore_state = VCORE_PIGGYBACK; in collect_piggybacks()
3649 if (cip->total_threads >= target_threads) in collect_piggybacks()
3652 spin_unlock(&lp->lock); in collect_piggybacks()
3661 for (sub = 0; sub < cip->n_subcores; ++sub) { in recheck_signals_and_mmu()
3662 vc = cip->vc[sub]; in recheck_signals_and_mmu()
3663 if (!vc->kvm->arch.mmu_ready) in recheck_signals_and_mmu()
3666 if (signal_pending(vcpu->arch.run_task)) in recheck_signals_and_mmu()
3679 spin_lock(&vc->lock); in post_guest_process()
3689 spin_unlock(&vc->lock); in post_guest_process()
3698 if (vcpu->arch.trap) in post_guest_process()
3700 vcpu->arch.run_task); in post_guest_process()
3702 vcpu->arch.ret = ret; in post_guest_process()
3703 vcpu->arch.trap = 0; in post_guest_process()
3705 spin_lock(&vc->lock); in post_guest_process()
3706 if (is_kvmppc_resume_guest(vcpu->arch.ret)) { in post_guest_process()
3707 if (vcpu->arch.pending_exceptions) in post_guest_process()
3709 if (vcpu->arch.ceded) in post_guest_process()
3715 wake_up(&vcpu->arch.cpu_run); in post_guest_process()
3721 } else if (vc->runner) { in post_guest_process()
3722 vc->vcore_state = VCORE_PREEMPT; in post_guest_process()
3725 vc->vcore_state = VCORE_INACTIVE; in post_guest_process()
3727 if (vc->n_runnable > 0 && vc->runner == NULL) { in post_guest_process()
3729 i = -1; in post_guest_process()
3731 wake_up(&vcpu->arch.cpu_run); in post_guest_process()
3734 spin_unlock(&vc->lock); in post_guest_process()
3754 kvmppc_host_rm_ops_hv->rm_core[core].rm_state.in_host = 0; in kvmppc_clear_host_core()
3775 kvmppc_host_rm_ops_hv->rm_core[core].rm_state.in_host = 1; in kvmppc_set_host_core()
3783 local_paca->irq_happened |= PACA_IRQ_EE; in set_irq_happened()
3786 local_paca->irq_happened |= PACA_IRQ_DBELL; in set_irq_happened()
3789 local_paca->irq_happened |= PACA_IRQ_HMI; in set_irq_happened()
3799 * Called with vc->lock held.
3828 /* if the runner is no longer runnable, let the caller pick a new one */ in kvmppc_run_core()
3829 if (vc->runner->arch.state != KVMPPC_VCPU_RUNNABLE) in kvmppc_run_core()
3836 vc->preempt_tb = TB_NIL; in kvmppc_run_core()
3843 controlled_threads = threads_per_vcore(vc->kvm); in kvmppc_run_core()
3851 ((vc->num_threads > threads_per_subcore) || !on_primary_thread())) { in kvmppc_run_core()
3853 vcpu->arch.ret = -EBUSY; in kvmppc_run_core()
3855 wake_up(&vcpu->arch.cpu_run); in kvmppc_run_core()
3869 if (vc->num_threads < target_threads) in kvmppc_run_core()
3873 * Hard-disable interrupts, and check resched flag and signals. in kvmppc_run_core()
3884 vc->vcore_state = VCORE_INACTIVE; in kvmppc_run_core()
3890 spin_unlock(&pvc->lock); in kvmppc_run_core()
3899 /* Decide on micro-threading (split-core) mode */ in kvmppc_run_core()
3937 paca->kvm_hstate.napping = 0; in kvmppc_run_core()
3938 paca->kvm_hstate.kvm_split_mode = sip; in kvmppc_run_core()
3941 /* Initiate micro-threading (split-core) on POWER8 if required */ in kvmppc_run_core()
3964 int n_online = atomic_read(&vc->online_count); in kvmppc_run_core()
3967 * Use the 8-thread value if we're doing split-core in kvmppc_run_core()
3983 pvc->pcpu = pcpu + thr; in kvmppc_run_core()
3987 * It updates vcpu->cpu and vcpu->arch.thread_cpu in kvmppc_run_core()
3996 if (!vcpu->arch.ptid) in kvmppc_run_core()
3998 active |= 1 << (thr + vcpu->arch.ptid); in kvmppc_run_core()
4015 * When doing micro-threading, poke the inactive threads as well. in kvmppc_run_core()
4026 vc->vcore_state = VCORE_RUNNING; in kvmppc_run_core()
4032 spin_unlock(&core_info.vc[sub]->lock); in kvmppc_run_core()
4036 srcu_idx = srcu_read_lock(&vc->kvm->srcu); in kvmppc_run_core()
4046 srcu_read_unlock(&vc->kvm->srcu, srcu_idx); in kvmppc_run_core()
4050 spin_lock(&vc->lock); in kvmppc_run_core()
4052 vc->vcore_state = VCORE_EXITING; in kvmppc_run_core()
4057 /* Return to whole-core mode if we split the core earlier */ in kvmppc_run_core()
4096 if (sip && sip->napped[i]) in kvmppc_run_core()
4100 spin_unlock(&vc->lock); in kvmppc_run_core()
4112 spin_lock(&vc->lock); in kvmppc_run_core()
4115 vc->vcore_state = VCORE_INACTIVE; in kvmppc_run_core()
4127 struct lppaca *lp = vcpu->arch.vpa.pinned_addr; in vcpu_vpa_increment_dispatch()
4129 u32 yield_count = be32_to_cpu(lp->yield_count) + 1; in vcpu_vpa_increment_dispatch()
4130 lp->yield_count = cpu_to_be32(yield_count); in vcpu_vpa_increment_dispatch()
4131 vcpu->arch.vpa.dirty = 1; in vcpu_vpa_increment_dispatch()
4144 get_lppaca()->l2_counters_enable; in kvmhv_get_l2_counters_status()
4184 l1_to_l2_ns = tb_to_ns(be64_to_cpu(lp->l1_to_l2_cs_tb)); in do_trace_nested_cs_time()
4185 l2_to_l1_ns = tb_to_ns(be64_to_cpu(lp->l2_to_l1_cs_tb)); in do_trace_nested_cs_time()
4186 l2_runtime_ns = tb_to_ns(be64_to_cpu(lp->l2_runtime_tb)); in do_trace_nested_cs_time()
4187 trace_kvmppc_vcpu_stats(vcpu, l1_to_l2_ns - *l1_to_l2_cs_ptr, in do_trace_nested_cs_time()
4188 l2_to_l1_ns - *l2_to_l1_cs_ptr, in do_trace_nested_cs_time()
4189 l2_runtime_ns - *l2_runtime_agg_ptr); in do_trace_nested_cs_time()
4214 if (vcpu->arch.doorbell_request) { in kvmhv_vcpu_entry_nestedv2()
4215 vcpu->arch.doorbell_request = 0; in kvmhv_vcpu_entry_nestedv2()
4219 io = &vcpu->arch.nestedv2_io; in kvmhv_vcpu_entry_nestedv2()
4228 return -EINVAL; in kvmhv_vcpu_entry_nestedv2()
4230 kvmppc_gse_put_u64(io->vcpu_run_input, KVMPPC_GSID_LPCR, lpcr); in kvmhv_vcpu_entry_nestedv2()
4232 accumulate_time(vcpu, &vcpu->arch.in_guest); in kvmhv_vcpu_entry_nestedv2()
4233 rc = plpar_guest_run_vcpu(0, vcpu->kvm->arch.lpid, vcpu->vcpu_id, in kvmhv_vcpu_entry_nestedv2()
4244 return -EINVAL; in kvmhv_vcpu_entry_nestedv2()
4246 accumulate_time(vcpu, &vcpu->arch.guest_exit); in kvmhv_vcpu_entry_nestedv2()
4249 kvmppc_gsm_reset(io->vcpu_message); in kvmhv_vcpu_entry_nestedv2()
4250 kvmppc_gsm_reset(io->vcore_message); in kvmhv_vcpu_entry_nestedv2()
4251 kvmppc_gsbm_zero(&io->valids); in kvmhv_vcpu_entry_nestedv2()
4255 return -EINVAL; in kvmhv_vcpu_entry_nestedv2()
4295 if (vcpu->arch.psscr != host_psscr) in kvmhv_vcpu_entry_p9_nested()
4296 mtspr(SPRN_PSSCR_PR, vcpu->arch.psscr); in kvmhv_vcpu_entry_p9_nested()
4301 vcpu->arch.regs.msr = vcpu->arch.shregs.msr; in kvmhv_vcpu_entry_p9_nested()
4303 if (vcpu->arch.nested) { in kvmhv_vcpu_entry_p9_nested()
4304 hvregs.lpid = vcpu->arch.nested->shadow_lpid; in kvmhv_vcpu_entry_p9_nested()
4305 hvregs.vcpu_token = vcpu->arch.nested_vcpu_id; in kvmhv_vcpu_entry_p9_nested()
4307 hvregs.lpid = vcpu->kvm->arch.lpid; in kvmhv_vcpu_entry_p9_nested()
4308 hvregs.vcpu_token = vcpu->vcpu_id; in kvmhv_vcpu_entry_p9_nested()
4326 mtspr(SPRN_DEC, kvmppc_dec_expires_host_tb(vcpu) - *tb); in kvmhv_vcpu_entry_p9_nested()
4328 mtspr(SPRN_DAR, vcpu->arch.shregs.dar); in kvmhv_vcpu_entry_p9_nested()
4329 mtspr(SPRN_DSISR, vcpu->arch.shregs.dsisr); in kvmhv_vcpu_entry_p9_nested()
4331 accumulate_time(vcpu, &vcpu->arch.in_guest); in kvmhv_vcpu_entry_p9_nested()
4333 __pa(&vcpu->arch.regs)); in kvmhv_vcpu_entry_p9_nested()
4334 accumulate_time(vcpu, &vcpu->arch.guest_exit); in kvmhv_vcpu_entry_p9_nested()
4337 vcpu->arch.shregs.msr = vcpu->arch.regs.msr; in kvmhv_vcpu_entry_p9_nested()
4338 vcpu->arch.shregs.dar = mfspr(SPRN_DAR); in kvmhv_vcpu_entry_p9_nested()
4339 vcpu->arch.shregs.dsisr = mfspr(SPRN_DSISR); in kvmhv_vcpu_entry_p9_nested()
4340 vcpu->arch.psscr = mfspr(SPRN_PSSCR_PR); in kvmhv_vcpu_entry_p9_nested()
4348 vcpu->arch.dec_expires = dec + (*tb + kvmppc_get_tb_offset(vcpu)); in kvmhv_vcpu_entry_p9_nested()
4353 if (vcpu->arch.psscr != host_psscr) in kvmhv_vcpu_entry_p9_nested()
4365 struct kvm *kvm = vcpu->kvm; in kvmhv_p9_guest_entry()
4366 struct kvm_nested_guest *nested = vcpu->arch.nested; in kvmhv_p9_guest_entry()
4378 vcpu->arch.ceded = 0; in kvmhv_p9_guest_entry()
4425 vcpu->arch.ceded = 0; in kvmhv_p9_guest_entry()
4457 vcpu->arch.slb_max = 0; in kvmhv_p9_guest_entry()
4474 prepare_to_wait(&vcpu->arch.cpu_run, &wait, wait_state); in kvmppc_wait_for_exec()
4475 if (vcpu->arch.state == KVMPPC_VCPU_RUNNABLE) { in kvmppc_wait_for_exec()
4476 spin_unlock(&vc->lock); in kvmppc_wait_for_exec()
4478 spin_lock(&vc->lock); in kvmppc_wait_for_exec()
4480 finish_wait(&vcpu->arch.cpu_run, &wait); in kvmppc_wait_for_exec()
4488 vc->halt_poll_ns *= halt_poll_ns_grow; in grow_halt_poll_ns()
4489 if (vc->halt_poll_ns < halt_poll_ns_grow_start) in grow_halt_poll_ns()
4490 vc->halt_poll_ns = halt_poll_ns_grow_start; in grow_halt_poll_ns()
4496 vc->halt_poll_ns = 0; in shrink_halt_poll_ns()
4498 vc->halt_poll_ns /= halt_poll_ns_shrink; in shrink_halt_poll_ns()
4506 return vcpu->arch.irq_pending || vcpu->arch.xive_saved_state.pipr < in xive_interrupt_pending()
4507 vcpu->arch.xive_saved_state.cppr; in xive_interrupt_pending()
4518 if (vcpu->arch.pending_exceptions || vcpu->arch.prodded || in kvmppc_vcpu_woken()
4527 if (!vcpu->arch.ceded || kvmppc_vcpu_woken(vcpu)) in kvmppc_vcpu_check_block()
4534 * exceptions or are no longer ceded
4551 * or external interrupt to one of the vcpus. vc->lock is held.
4563 if (vc->halt_poll_ns) { in kvmppc_vcore_blocked()
4564 ktime_t stop = ktime_add_ns(start_poll, vc->halt_poll_ns); in kvmppc_vcore_blocked()
4565 ++vc->runner->stat.generic.halt_attempted_poll; in kvmppc_vcore_blocked()
4567 vc->vcore_state = VCORE_POLLING; in kvmppc_vcore_blocked()
4568 spin_unlock(&vc->lock); in kvmppc_vcore_blocked()
4578 spin_lock(&vc->lock); in kvmppc_vcore_blocked()
4579 vc->vcore_state = VCORE_INACTIVE; in kvmppc_vcore_blocked()
4582 ++vc->runner->stat.generic.halt_successful_poll; in kvmppc_vcore_blocked()
4587 prepare_to_rcuwait(&vc->wait); in kvmppc_vcore_blocked()
4590 finish_rcuwait(&vc->wait); in kvmppc_vcore_blocked()
4593 if (vc->halt_poll_ns) in kvmppc_vcore_blocked()
4594 ++vc->runner->stat.generic.halt_successful_poll; in kvmppc_vcore_blocked()
4600 vc->vcore_state = VCORE_SLEEPING; in kvmppc_vcore_blocked()
4601 trace_kvmppc_vcore_blocked(vc->runner, 0); in kvmppc_vcore_blocked()
4602 spin_unlock(&vc->lock); in kvmppc_vcore_blocked()
4604 finish_rcuwait(&vc->wait); in kvmppc_vcore_blocked()
4605 spin_lock(&vc->lock); in kvmppc_vcore_blocked()
4606 vc->vcore_state = VCORE_INACTIVE; in kvmppc_vcore_blocked()
4607 trace_kvmppc_vcore_blocked(vc->runner, 1); in kvmppc_vcore_blocked()
4608 ++vc->runner->stat.halt_successful_wait; in kvmppc_vcore_blocked()
4613 block_ns = ktime_to_ns(cur) - ktime_to_ns(start_poll); in kvmppc_vcore_blocked()
4617 vc->runner->stat.generic.halt_wait_ns += in kvmppc_vcore_blocked()
4618 ktime_to_ns(cur) - ktime_to_ns(start_wait); in kvmppc_vcore_blocked()
4620 vc->runner->stat.generic.halt_wait_hist, in kvmppc_vcore_blocked()
4621 ktime_to_ns(cur) - ktime_to_ns(start_wait)); in kvmppc_vcore_blocked()
4623 if (vc->halt_poll_ns) { in kvmppc_vcore_blocked()
4624 vc->runner->stat.generic.halt_poll_fail_ns += in kvmppc_vcore_blocked()
4625 ktime_to_ns(start_wait) - in kvmppc_vcore_blocked()
4628 vc->runner->stat.generic.halt_poll_fail_hist, in kvmppc_vcore_blocked()
4629 ktime_to_ns(start_wait) - in kvmppc_vcore_blocked()
4634 if (vc->halt_poll_ns) { in kvmppc_vcore_blocked()
4635 vc->runner->stat.generic.halt_poll_success_ns += in kvmppc_vcore_blocked()
4636 ktime_to_ns(cur) - in kvmppc_vcore_blocked()
4639 vc->runner->stat.generic.halt_poll_success_hist, in kvmppc_vcore_blocked()
4640 ktime_to_ns(cur) - ktime_to_ns(start_poll)); in kvmppc_vcore_blocked()
4646 if (block_ns <= vc->halt_poll_ns) in kvmppc_vcore_blocked()
4649 else if (vc->halt_poll_ns && block_ns > halt_poll_ns) in kvmppc_vcore_blocked()
4652 else if (vc->halt_poll_ns < halt_poll_ns && in kvmppc_vcore_blocked()
4655 if (vc->halt_poll_ns > halt_poll_ns) in kvmppc_vcore_blocked()
4656 vc->halt_poll_ns = halt_poll_ns; in kvmppc_vcore_blocked()
4658 vc->halt_poll_ns = 0; in kvmppc_vcore_blocked()
4670 struct kvm *kvm = vcpu->kvm; in kvmhv_setup_mmu()
4672 mutex_lock(&kvm->arch.mmu_setup_lock); in kvmhv_setup_mmu()
4673 if (!kvm->arch.mmu_ready) { in kvmhv_setup_mmu()
4679 kvm->arch.mmu_ready = 1; in kvmhv_setup_mmu()
4682 mutex_unlock(&kvm->arch.mmu_setup_lock); in kvmhv_setup_mmu()
4688 struct kvm_run *run = vcpu->run; in kvmppc_run_vcpu()
4695 run->exit_reason = 0; in kvmppc_run_vcpu()
4696 vcpu->arch.ret = RESUME_GUEST; in kvmppc_run_vcpu()
4697 vcpu->arch.trap = 0; in kvmppc_run_vcpu()
4703 vc = vcpu->arch.vcore; in kvmppc_run_vcpu()
4704 spin_lock(&vc->lock); in kvmppc_run_vcpu()
4705 vcpu->arch.ceded = 0; in kvmppc_run_vcpu()
4706 vcpu->arch.run_task = current; in kvmppc_run_vcpu()
4707 vcpu->arch.stolen_logged = vcore_stolen_time(vc, mftb()); in kvmppc_run_vcpu()
4708 vcpu->arch.state = KVMPPC_VCPU_RUNNABLE; in kvmppc_run_vcpu()
4709 vcpu->arch.busy_preempt = TB_NIL; in kvmppc_run_vcpu()
4710 WRITE_ONCE(vc->runnable_threads[vcpu->arch.ptid], vcpu); in kvmppc_run_vcpu()
4711 ++vc->n_runnable; in kvmppc_run_vcpu()
4719 if ((vc->vcore_state == VCORE_PIGGYBACK || in kvmppc_run_vcpu()
4720 vc->vcore_state == VCORE_RUNNING) && in kvmppc_run_vcpu()
4725 } else if (vc->vcore_state == VCORE_SLEEPING) { in kvmppc_run_vcpu()
4726 rcuwait_wake_up(&vc->wait); in kvmppc_run_vcpu()
4731 while (vcpu->arch.state == KVMPPC_VCPU_RUNNABLE && in kvmppc_run_vcpu()
4734 if (!vcpu->kvm->arch.mmu_ready) { in kvmppc_run_vcpu()
4735 spin_unlock(&vc->lock); in kvmppc_run_vcpu()
4737 spin_lock(&vc->lock); in kvmppc_run_vcpu()
4739 run->exit_reason = KVM_EXIT_FAIL_ENTRY; in kvmppc_run_vcpu()
4740 run->fail_entry. in kvmppc_run_vcpu()
4742 vcpu->arch.ret = r; in kvmppc_run_vcpu()
4747 if (vc->vcore_state == VCORE_PREEMPT && vc->runner == NULL) in kvmppc_run_vcpu()
4750 if (vc->vcore_state != VCORE_INACTIVE) { in kvmppc_run_vcpu()
4756 if (signal_pending(v->arch.run_task)) { in kvmppc_run_vcpu()
4758 v->stat.signal_exits++; in kvmppc_run_vcpu()
4759 v->run->exit_reason = KVM_EXIT_INTR; in kvmppc_run_vcpu()
4760 v->arch.ret = -EINTR; in kvmppc_run_vcpu()
4761 wake_up(&v->arch.cpu_run); in kvmppc_run_vcpu()
4764 if (!vc->n_runnable || vcpu->arch.state != KVMPPC_VCPU_RUNNABLE) in kvmppc_run_vcpu()
4769 n_ceded += v->arch.ceded; in kvmppc_run_vcpu()
4771 v->arch.ceded = 0; in kvmppc_run_vcpu()
4773 vc->runner = vcpu; in kvmppc_run_vcpu()
4774 if (n_ceded == vc->n_runnable) { in kvmppc_run_vcpu()
4779 cond_resched_lock(&vc->lock); in kvmppc_run_vcpu()
4780 if (vc->vcore_state == VCORE_PREEMPT) in kvmppc_run_vcpu()
4785 vc->runner = NULL; in kvmppc_run_vcpu()
4788 while (vcpu->arch.state == KVMPPC_VCPU_RUNNABLE && in kvmppc_run_vcpu()
4789 (vc->vcore_state == VCORE_RUNNING || in kvmppc_run_vcpu()
4790 vc->vcore_state == VCORE_EXITING || in kvmppc_run_vcpu()
4791 vc->vcore_state == VCORE_PIGGYBACK)) in kvmppc_run_vcpu()
4794 if (vc->vcore_state == VCORE_PREEMPT && vc->runner == NULL) in kvmppc_run_vcpu()
4797 if (vcpu->arch.state == KVMPPC_VCPU_RUNNABLE) { in kvmppc_run_vcpu()
4799 vcpu->stat.signal_exits++; in kvmppc_run_vcpu()
4800 run->exit_reason = KVM_EXIT_INTR; in kvmppc_run_vcpu()
4801 vcpu->arch.ret = -EINTR; in kvmppc_run_vcpu()
4804 if (vc->n_runnable && vc->vcore_state == VCORE_INACTIVE) { in kvmppc_run_vcpu()
4806 i = -1; in kvmppc_run_vcpu()
4808 wake_up(&v->arch.cpu_run); in kvmppc_run_vcpu()
4812 spin_unlock(&vc->lock); in kvmppc_run_vcpu()
4813 return vcpu->arch.ret; in kvmppc_run_vcpu()
4820 struct kvm_run *run = vcpu->run; in kvmhv_run_single_vcpu()
4824 struct kvm *kvm = vcpu->kvm; in kvmhv_run_single_vcpu()
4825 struct kvm_nested_guest *nested = vcpu->arch.nested; in kvmhv_run_single_vcpu()
4831 run->exit_reason = 0; in kvmhv_run_single_vcpu()
4832 vcpu->arch.ret = RESUME_GUEST; in kvmhv_run_single_vcpu()
4833 vcpu->arch.trap = 0; in kvmhv_run_single_vcpu()
4835 vc = vcpu->arch.vcore; in kvmhv_run_single_vcpu()
4836 vcpu->arch.ceded = 0; in kvmhv_run_single_vcpu()
4837 vcpu->arch.run_task = current; in kvmhv_run_single_vcpu()
4838 vcpu->arch.last_inst = KVM_INST_FETCH_FAILED; in kvmhv_run_single_vcpu()
4841 if (unlikely(!kvm->arch.mmu_ready)) { in kvmhv_run_single_vcpu()
4844 run->exit_reason = KVM_EXIT_FAIL_ENTRY; in kvmhv_run_single_vcpu()
4845 run->fail_entry.hardware_entry_failure_reason = 0; in kvmhv_run_single_vcpu()
4846 vcpu->arch.ret = r; in kvmhv_run_single_vcpu()
4861 /* flags save not required, but irq_pmu has no disable/enable API */ in kvmhv_run_single_vcpu()
4864 vcpu->arch.state = KVMPPC_VCPU_RUNNABLE; in kvmhv_run_single_vcpu()
4868 if (need_resched() || !kvm->arch.mmu_ready) in kvmhv_run_single_vcpu()
4871 vcpu->cpu = pcpu; in kvmhv_run_single_vcpu()
4872 vcpu->arch.thread_cpu = pcpu; in kvmhv_run_single_vcpu()
4873 vc->pcpu = pcpu; in kvmhv_run_single_vcpu()
4874 local_paca->kvm_hstate.kvm_vcpu = vcpu; in kvmhv_run_single_vcpu()
4875 local_paca->kvm_hstate.ptid = 0; in kvmhv_run_single_vcpu()
4876 local_paca->kvm_hstate.fake_suspend = 0; in kvmhv_run_single_vcpu()
4889 &vcpu->arch.pending_exceptions) || in kvmhv_run_single_vcpu()
4903 * L1's copy of L2's LPCR (vcpu->arch.vcore->lpcr) can get its MER bit in kvmhv_run_single_vcpu()
4904 * unexpectedly set - for e.g. during NMI handling when all register in kvmhv_run_single_vcpu()
4914 } else if (vcpu->arch.pending_exceptions || in kvmhv_run_single_vcpu()
4915 vcpu->arch.doorbell_request || in kvmhv_run_single_vcpu()
4917 vcpu->arch.ret = RESUME_HOST; in kvmhv_run_single_vcpu()
4921 if (vcpu->arch.timer_running) { in kvmhv_run_single_vcpu()
4922 hrtimer_try_to_cancel(&vcpu->arch.dec_timer); in kvmhv_run_single_vcpu()
4923 vcpu->arch.timer_running = 0; in kvmhv_run_single_vcpu()
4934 srcu_idx = srcu_read_lock(&kvm->srcu); in kvmhv_run_single_vcpu()
4940 vcpu->arch.trap = trap; in kvmhv_run_single_vcpu()
4945 srcu_read_unlock(&kvm->srcu, srcu_idx); in kvmhv_run_single_vcpu()
4949 vcpu->cpu = -1; in kvmhv_run_single_vcpu()
4950 vcpu->arch.thread_cpu = -1; in kvmhv_run_single_vcpu()
4951 vcpu->arch.state = KVMPPC_VCPU_BUSY_IN_HOST; in kvmhv_run_single_vcpu()
4990 vcpu->arch.ret = r; in kvmhv_run_single_vcpu()
4999 vcpu->stat.signal_exits++; in kvmhv_run_single_vcpu()
5000 run->exit_reason = KVM_EXIT_INTR; in kvmhv_run_single_vcpu()
5001 vcpu->arch.ret = -EINTR; in kvmhv_run_single_vcpu()
5014 vcpu->arch.ceded = 0; in kvmhv_run_single_vcpu()
5019 return vcpu->arch.ret; in kvmhv_run_single_vcpu()
5022 vcpu->stat.signal_exits++; in kvmhv_run_single_vcpu()
5023 run->exit_reason = KVM_EXIT_INTR; in kvmhv_run_single_vcpu()
5024 vcpu->arch.ret = -EINTR; in kvmhv_run_single_vcpu()
5026 vcpu->cpu = -1; in kvmhv_run_single_vcpu()
5027 vcpu->arch.thread_cpu = -1; in kvmhv_run_single_vcpu()
5028 vcpu->arch.state = KVMPPC_VCPU_BUSY_IN_HOST; in kvmhv_run_single_vcpu()
5036 struct kvm_run *run = vcpu->run; in kvmppc_vcpu_run_hv()
5042 start_timing(vcpu, &vcpu->arch.vcpu_entry); in kvmppc_vcpu_run_hv()
5044 if (!vcpu->arch.sane) { in kvmppc_vcpu_run_hv()
5045 run->exit_reason = KVM_EXIT_INTERNAL_ERROR; in kvmppc_vcpu_run_hv()
5046 return -EINVAL; in kvmppc_vcpu_run_hv()
5049 /* No need to go into the guest when all we'll do is come back out */ in kvmppc_vcpu_run_hv()
5051 run->exit_reason = KVM_EXIT_INTR; in kvmppc_vcpu_run_hv()
5052 return -EINTR; in kvmppc_vcpu_run_hv()
5060 if (cpu_has_feature(CPU_FTR_TM) && current->thread.regs && in kvmppc_vcpu_run_hv()
5061 (current->thread.regs->msr & MSR_TM)) { in kvmppc_vcpu_run_hv()
5062 if (MSR_TM_ACTIVE(current->thread.regs->msr)) { in kvmppc_vcpu_run_hv()
5063 run->exit_reason = KVM_EXIT_FAIL_ENTRY; in kvmppc_vcpu_run_hv()
5064 run->fail_entry.hardware_entry_failure_reason = 0; in kvmppc_vcpu_run_hv()
5065 return -EINVAL; in kvmppc_vcpu_run_hv()
5074 if (!vcpu->arch.online) { in kvmppc_vcpu_run_hv()
5075 atomic_inc(&vcpu->arch.vcore->online_count); in kvmppc_vcpu_run_hv()
5076 vcpu->arch.online = 1; in kvmppc_vcpu_run_hv()
5081 kvm = vcpu->kvm; in kvmppc_vcpu_run_hv()
5082 atomic_inc(&kvm->arch.vcpus_running); in kvmppc_vcpu_run_hv()
5104 vcpu->arch.waitp = &vcpu->arch.vcore->wait; in kvmppc_vcpu_run_hv()
5105 vcpu->arch.pgdir = kvm->mm->pgd; in kvmppc_vcpu_run_hv()
5106 vcpu->arch.state = KVMPPC_VCPU_BUSY_IN_HOST; in kvmppc_vcpu_run_hv()
5109 accumulate_time(vcpu, &vcpu->arch.guest_entry); in kvmppc_vcpu_run_hv()
5112 vcpu->arch.vcore->lpcr); in kvmppc_vcpu_run_hv()
5116 if (run->exit_reason == KVM_EXIT_PAPR_HCALL) { in kvmppc_vcpu_run_hv()
5117 accumulate_time(vcpu, &vcpu->arch.hcall); in kvmppc_vcpu_run_hv()
5134 accumulate_time(vcpu, &vcpu->arch.pg_fault); in kvmppc_vcpu_run_hv()
5135 srcu_idx = srcu_read_lock(&kvm->srcu); in kvmppc_vcpu_run_hv()
5137 vcpu->arch.fault_dar, vcpu->arch.fault_dsisr); in kvmppc_vcpu_run_hv()
5138 srcu_read_unlock(&kvm->srcu, srcu_idx); in kvmppc_vcpu_run_hv()
5146 accumulate_time(vcpu, &vcpu->arch.vcpu_exit); in kvmppc_vcpu_run_hv()
5148 vcpu->arch.state = KVMPPC_VCPU_NOTREADY; in kvmppc_vcpu_run_hv()
5149 atomic_dec(&kvm->arch.vcpus_running); in kvmppc_vcpu_run_hv()
5161 (*sps)->page_shift = shift; in kvmppc_add_seg_page_size()
5162 (*sps)->slb_enc = sllp; in kvmppc_add_seg_page_size()
5163 (*sps)->enc[0].page_shift = shift; in kvmppc_add_seg_page_size()
5164 (*sps)->enc[0].pte_enc = kvmppc_pgsize_lp_encoding(shift, shift); in kvmppc_add_seg_page_size()
5170 if (penc != -1) { in kvmppc_add_seg_page_size()
5171 (*sps)->enc[1].page_shift = 24; in kvmppc_add_seg_page_size()
5172 (*sps)->enc[1].pte_enc = penc; in kvmppc_add_seg_page_size()
5188 info->data_keys = 32; in kvm_vm_ioctl_get_smmu_info_hv()
5189 info->instr_keys = cpu_has_feature(CPU_FTR_ARCH_207S) ? 32 : 0; in kvm_vm_ioctl_get_smmu_info_hv()
5191 /* POWER7, 8 and 9 all have 1T segments and 32-entry SLB */ in kvm_vm_ioctl_get_smmu_info_hv()
5192 info->flags = KVM_PPC_PAGE_SIZES_REAL | KVM_PPC_1T_SEGMENTS; in kvm_vm_ioctl_get_smmu_info_hv()
5193 info->slb_size = 32; in kvm_vm_ioctl_get_smmu_info_hv()
5195 /* We only support these sizes for now, and no muti-size segments */ in kvm_vm_ioctl_get_smmu_info_hv()
5196 sps = &info->sps[0]; in kvm_vm_ioctl_get_smmu_info_hv()
5203 info->flags |= KVM_PPC_NO_HASH; in kvm_vm_ioctl_get_smmu_info_hv()
5221 mutex_lock(&kvm->slots_lock); in kvm_vm_ioctl_get_dirty_log_hv()
5223 r = -EINVAL; in kvm_vm_ioctl_get_dirty_log_hv()
5224 if (log->slot >= KVM_USER_MEM_SLOTS) in kvm_vm_ioctl_get_dirty_log_hv()
5228 memslot = id_to_memslot(slots, log->slot); in kvm_vm_ioctl_get_dirty_log_hv()
5229 r = -ENOENT; in kvm_vm_ioctl_get_dirty_log_hv()
5230 if (!memslot || !memslot->dirty_bitmap) in kvm_vm_ioctl_get_dirty_log_hv()
5238 buf = memslot->dirty_bitmap + n / sizeof(long); in kvm_vm_ioctl_get_dirty_log_hv()
5254 p = memslot->dirty_bitmap; in kvm_vm_ioctl_get_dirty_log_hv()
5261 spin_lock(&vcpu->arch.vpa_update_lock); in kvm_vm_ioctl_get_dirty_log_hv()
5262 kvmppc_harvest_vpa_dirty(&vcpu->arch.vpa, memslot, buf); in kvm_vm_ioctl_get_dirty_log_hv()
5263 kvmppc_harvest_vpa_dirty(&vcpu->arch.dtl, memslot, buf); in kvm_vm_ioctl_get_dirty_log_hv()
5264 spin_unlock(&vcpu->arch.vpa_update_lock); in kvm_vm_ioctl_get_dirty_log_hv()
5267 r = -EFAULT; in kvm_vm_ioctl_get_dirty_log_hv()
5268 if (copy_to_user(log->dirty_bitmap, buf, n)) in kvm_vm_ioctl_get_dirty_log_hv()
5273 mutex_unlock(&kvm->slots_lock); in kvm_vm_ioctl_get_dirty_log_hv()
5279 vfree(slot->arch.rmap); in kvmppc_core_free_memslot_hv()
5280 slot->arch.rmap = NULL; in kvmppc_core_free_memslot_hv()
5289 unsigned long size = array_size(new->npages, sizeof(*new->arch.rmap)); in kvmppc_core_prepare_memory_region_hv()
5292 return -ENOMEM; in kvmppc_core_prepare_memory_region_hv()
5294 new->arch.rmap = vzalloc(size); in kvmppc_core_prepare_memory_region_hv()
5295 if (!new->arch.rmap) in kvmppc_core_prepare_memory_region_hv()
5296 return -ENOMEM; in kvmppc_core_prepare_memory_region_hv()
5298 new->arch.rmap = old->arch.rmap; in kvmppc_core_prepare_memory_region_hv()
5312 * MMIO be no longer emulated MMIO, so invalidate in kvmppc_core_commit_memory_region_hv()
5316 atomic64_inc(&kvm->arch.mmio_update); in kvmppc_core_commit_memory_region_hv()
5321 * flush shadow mappings. For KVM_MR_CREATE we have no in kvmppc_core_commit_memory_region_hv()
5326 * to get rid of any THP PTEs in the partition-scoped page tables in kvmppc_core_commit_memory_region_hv()
5332 ((new->flags ^ old->flags) & KVM_MEM_LOG_DIRTY_PAGES)) in kvmppc_core_commit_memory_region_hv()
5337 if (!kvm->arch.secure_guest) in kvmppc_core_commit_memory_region_hv()
5358 * Update LPCR values in kvm->arch and in vcores.
5359 * Caller must hold kvm->arch.mmu_setup_lock (for mutual exclusion
5360 * of kvm->arch.lpcr update).
5367 if ((kvm->arch.lpcr & mask) == lpcr) in kvmppc_update_lpcr()
5370 kvm->arch.lpcr = (kvm->arch.lpcr & ~mask) | lpcr; in kvmppc_update_lpcr()
5373 struct kvmppc_vcore *vc = kvm->arch.vcores[i]; in kvmppc_update_lpcr()
5377 spin_lock(&vc->lock); in kvmppc_update_lpcr()
5378 vc->lpcr = (vc->lpcr & ~mask) | lpcr; in kvmppc_update_lpcr()
5379 verify_lpcr(kvm, vc->lpcr); in kvmppc_update_lpcr()
5380 spin_unlock(&vc->lock); in kvmppc_update_lpcr()
5381 if (++cores_done >= kvm->arch.online_vcores) in kvmppc_update_lpcr()
5399 /* PS field - page size for VRMA */ in kvmppc_setup_partition_table()
5400 dw0 = ((kvm->arch.vrma_slb_v & SLB_VSID_L) >> 1) | in kvmppc_setup_partition_table()
5401 ((kvm->arch.vrma_slb_v & SLB_VSID_LP) << 1); in kvmppc_setup_partition_table()
5403 dw0 |= kvm->arch.sdr1; in kvmppc_setup_partition_table()
5406 dw1 = kvm->arch.process_table; in kvmppc_setup_partition_table()
5409 __pa(kvm->arch.pgtable) | RADIX_PGD_INDEX_SIZE; in kvmppc_setup_partition_table()
5410 dw1 = PATB_GR | kvm->arch.process_table; in kvmppc_setup_partition_table()
5412 kvmhv_set_ptbl_entry(kvm->arch.lpid, dw0, dw1); in kvmppc_setup_partition_table()
5416 * Set up HPT (hashed page table) and RMA (real-mode area).
5417 * Must be called with kvm->arch.mmu_setup_lock held.
5422 struct kvm *kvm = vcpu->kvm; in kvmppc_hv_setup_htab_rma()
5431 if (!kvm->arch.hpt.virt) { in kvmppc_hv_setup_htab_rma()
5439 while ((err == -ENOMEM) && --order >= PPC_MIN_HPT_ORDER) in kvmppc_hv_setup_htab_rma()
5451 srcu_idx = srcu_read_lock(&kvm->srcu); in kvmppc_hv_setup_htab_rma()
5455 err = -EINVAL; in kvmppc_hv_setup_htab_rma()
5456 if (!memslot || (memslot->flags & KVM_MEMSLOT_INVALID)) in kvmppc_hv_setup_htab_rma()
5460 hva = memslot->userspace_addr; in kvmppc_hv_setup_htab_rma()
5461 mmap_read_lock(kvm->mm); in kvmppc_hv_setup_htab_rma()
5462 vma = vma_lookup(kvm->mm, hva); in kvmppc_hv_setup_htab_rma()
5463 if (!vma || (vma->vm_flags & VM_IO)) in kvmppc_hv_setup_htab_rma()
5468 mmap_read_unlock(kvm->mm); in kvmppc_hv_setup_htab_rma()
5480 kvm->arch.vrma_slb_v = senc | SLB_VSID_B_1T | in kvmppc_hv_setup_htab_rma()
5487 /* the -4 is to account for senc values starting at 0x10 */ in kvmppc_hv_setup_htab_rma()
5488 lpcr = senc << (LPCR_VRMASD_SH - 4); in kvmppc_hv_setup_htab_rma()
5492 /* Order updates to kvm->arch.lpcr etc. vs. mmu_ready */ in kvmppc_hv_setup_htab_rma()
5496 srcu_read_unlock(&kvm->srcu, srcu_idx); in kvmppc_hv_setup_htab_rma()
5501 mmap_read_unlock(kvm->mm); in kvmppc_hv_setup_htab_rma()
5506 * Must be called with kvm->arch.mmu_setup_lock held and
5507 * mmu_ready = 0 and no vcpus running.
5516 kvm->arch.process_table = 0; in kvmppc_switch_mmu_to_hpt()
5518 spin_lock(&kvm->mmu_lock); in kvmppc_switch_mmu_to_hpt()
5519 kvm->arch.radix = 0; in kvmppc_switch_mmu_to_hpt()
5520 spin_unlock(&kvm->mmu_lock); in kvmppc_switch_mmu_to_hpt()
5533 * Must be called with kvm->arch.mmu_setup_lock held and
5534 * mmu_ready = 0 and no vcpus running.
5546 spin_lock(&kvm->mmu_lock); in kvmppc_switch_mmu_to_radix()
5547 kvm->arch.radix = 1; in kvmppc_switch_mmu_to_radix()
5548 spin_unlock(&kvm->mmu_lock); in kvmppc_switch_mmu_to_radix()
5549 kvmppc_free_hpt(&kvm->arch.hpt); in kvmppc_switch_mmu_to_radix()
5556 (kvm->arch.host_lpcr & LPCR_HAIL)) in kvmppc_switch_mmu_to_radix()
5566 * Allocate a per-core structure for managing state about which cores are
5571 * It is only freed when the kvm-hv module is unloaded.
5594 ops->rm_core = kzalloc(size, GFP_KERNEL); in kvmppc_alloc_host_rm_ops()
5596 if (!ops->rm_core) { in kvmppc_alloc_host_rm_ops()
5608 ops->rm_core[core].rm_state.in_host = 1; in kvmppc_alloc_host_rm_ops()
5611 ops->vcpu_kick = kvmppc_fast_vcpu_kick_hv; in kvmppc_alloc_host_rm_ops()
5616 * Do an atomic assignment (no locks used here), but if someone in kvmppc_alloc_host_rm_ops()
5624 kfree(ops->rm_core); in kvmppc_alloc_host_rm_ops()
5640 kfree(kvmppc_host_rm_ops_hv->rm_core); in kvmppc_free_host_rm_ops()
5652 mutex_init(&kvm->arch.uvmem_lock); in kvmppc_core_init_vm_hv()
5653 INIT_LIST_HEAD(&kvm->arch.uvmem_pfns); in kvmppc_core_init_vm_hv()
5654 mutex_init(&kvm->arch.mmu_setup_lock); in kvmppc_core_init_vm_hv()
5661 return -ENOMEM; in kvmppc_core_init_vm_hv()
5662 kvm->arch.lpid = lpid; in kvmppc_core_init_vm_hv()
5682 return -EINVAL; in kvmppc_core_init_vm_hv()
5685 return -ENOMEM; in kvmppc_core_init_vm_hv()
5687 return -EPERM; in kvmppc_core_init_vm_hv()
5689 return -EBUSY; in kvmppc_core_init_vm_hv()
5691 kvm->arch.lpid = guest_id; in kvmppc_core_init_vm_hv()
5703 cpumask_setall(&kvm->arch.need_tlb_flush); in kvmppc_core_init_vm_hv()
5706 memcpy(kvm->arch.enabled_hcalls, default_enabled_hcalls, in kvmppc_core_init_vm_hv()
5707 sizeof(kvm->arch.enabled_hcalls)); in kvmppc_core_init_vm_hv()
5710 kvm->arch.host_sdr1 = mfspr(SPRN_SDR1); in kvmppc_core_init_vm_hv()
5714 kvm->arch.host_lpid = mfspr(SPRN_LPID); in kvmppc_core_init_vm_hv()
5715 kvm->arch.host_lpcr = lpcr = mfspr(SPRN_LPCR); in kvmppc_core_init_vm_hv()
5726 kvm->arch.vrma_slb_v = SLB_VSID_B_1T | in kvmppc_core_init_vm_hv()
5735 * be unnecessary but better safe than sorry in case we re-enable in kvmppc_core_init_vm_hv()
5754 kvm->arch.radix = 1; in kvmppc_core_init_vm_hv()
5755 kvm->arch.mmu_ready = 1; in kvmppc_core_init_vm_hv()
5760 (kvm->arch.host_lpcr & LPCR_HAIL)) in kvmppc_core_init_vm_hv()
5765 plpar_guest_delete(0, kvm->arch.lpid); in kvmppc_core_init_vm_hv()
5767 kvmppc_free_lpid(kvm->arch.lpid); in kvmppc_core_init_vm_hv()
5774 kvm->arch.lpcr = lpcr; in kvmppc_core_init_vm_hv()
5777 kvm->arch.resize_hpt = NULL; in kvmppc_core_init_vm_hv()
5787 kvm->arch.tlb_sets = 1; in kvmppc_core_init_vm_hv()
5789 kvm->arch.tlb_sets = POWER9_TLB_SETS_RADIX; /* 128 */ in kvmppc_core_init_vm_hv()
5791 kvm->arch.tlb_sets = POWER9_TLB_SETS_HASH; /* 256 */ in kvmppc_core_init_vm_hv()
5793 kvm->arch.tlb_sets = POWER8_TLB_SETS; /* 512 */ in kvmppc_core_init_vm_hv()
5795 kvm->arch.tlb_sets = POWER7_TLB_SETS; /* 128 */ in kvmppc_core_init_vm_hv()
5812 kvm->arch.smt_mode = threads_per_subcore; in kvmppc_core_init_vm_hv()
5814 kvm->arch.smt_mode = 1; in kvmppc_core_init_vm_hv()
5815 kvm->arch.emul_smt_mode = 1; in kvmppc_core_init_vm_hv()
5833 kfree(kvm->arch.vcores[i]); in kvmppc_free_vcores()
5834 kvm->arch.online_vcores = 0; in kvmppc_free_vcores()
5848 kvmppc_free_hpt(&kvm->arch.hpt); in kvmppc_core_destroy_vm_hv()
5854 kvm->arch.process_table = 0; in kvmppc_core_destroy_vm_hv()
5855 if (kvm->arch.secure_guest) in kvmppc_core_destroy_vm_hv()
5856 uv_svm_terminate(kvm->arch.lpid); in kvmppc_core_destroy_vm_hv()
5858 kvmhv_set_ptbl_entry(kvm->arch.lpid, 0, 0); in kvmppc_core_destroy_vm_hv()
5862 kvmhv_flush_lpid(kvm->arch.lpid); in kvmppc_core_destroy_vm_hv()
5863 plpar_guest_delete(0, kvm->arch.lpid); in kvmppc_core_destroy_vm_hv()
5865 kvmppc_free_lpid(kvm->arch.lpid); in kvmppc_core_destroy_vm_hv()
5900 return -EIO; in kvmppc_core_check_processor_compat_hv()
5907 kfree(kvm->arch.pimap); in kvmppc_free_pimap()
5929 return -EIO; in kvmppc_set_passthru_irq()
5931 mutex_lock(&kvm->lock); in kvmppc_set_passthru_irq()
5933 pimap = kvm->arch.pimap; in kvmppc_set_passthru_irq()
5938 mutex_unlock(&kvm->lock); in kvmppc_set_passthru_irq()
5939 return -ENOMEM; in kvmppc_set_passthru_irq()
5941 kvm->arch.pimap = pimap; in kvmppc_set_passthru_irq()
5945 * For now, we only support interrupts for which the EOI operation in kvmppc_set_passthru_irq()
5947 * what our real-mode EOI code does, or a XIVE interrupt in kvmppc_set_passthru_irq()
5949 chip = irq_data_get_irq_chip(&desc->irq_data); in kvmppc_set_passthru_irq()
5953 mutex_unlock(&kvm->lock); in kvmppc_set_passthru_irq()
5954 return -ENOENT; in kvmppc_set_passthru_irq()
5960 * otherwise re-use this entry. in kvmppc_set_passthru_irq()
5962 for (i = 0; i < pimap->n_mapped; i++) { in kvmppc_set_passthru_irq()
5963 if (guest_gsi == pimap->mapped[i].v_hwirq) { in kvmppc_set_passthru_irq()
5964 if (pimap->mapped[i].r_hwirq) { in kvmppc_set_passthru_irq()
5965 mutex_unlock(&kvm->lock); in kvmppc_set_passthru_irq()
5966 return -EINVAL; in kvmppc_set_passthru_irq()
5973 mutex_unlock(&kvm->lock); in kvmppc_set_passthru_irq()
5974 return -EAGAIN; /* table is full */ in kvmppc_set_passthru_irq()
5977 irq_map = &pimap->mapped[i]; in kvmppc_set_passthru_irq()
5979 irq_map->v_hwirq = guest_gsi; in kvmppc_set_passthru_irq()
5980 irq_map->desc = desc; in kvmppc_set_passthru_irq()
5989 * The 'host_irq' number is mapped in the PCI-MSI domain but in kvmppc_set_passthru_irq()
5990 * the underlying calls, which will EOI the interrupt in real in kvmppc_set_passthru_irq()
5994 irq_map->r_hwirq = (unsigned int)irqd_to_hwirq(host_data); in kvmppc_set_passthru_irq()
5996 if (i == pimap->n_mapped) in kvmppc_set_passthru_irq()
5997 pimap->n_mapped++; in kvmppc_set_passthru_irq()
6002 kvmppc_xics_set_mapped(kvm, guest_gsi, irq_map->r_hwirq); in kvmppc_set_passthru_irq()
6004 irq_map->r_hwirq = 0; in kvmppc_set_passthru_irq()
6006 mutex_unlock(&kvm->lock); in kvmppc_set_passthru_irq()
6022 return -EIO; in kvmppc_clr_passthru_irq()
6024 mutex_lock(&kvm->lock); in kvmppc_clr_passthru_irq()
6025 if (!kvm->arch.pimap) in kvmppc_clr_passthru_irq()
6028 pimap = kvm->arch.pimap; in kvmppc_clr_passthru_irq()
6030 for (i = 0; i < pimap->n_mapped; i++) { in kvmppc_clr_passthru_irq()
6031 if (guest_gsi == pimap->mapped[i].v_hwirq) in kvmppc_clr_passthru_irq()
6035 if (i == pimap->n_mapped) { in kvmppc_clr_passthru_irq()
6036 mutex_unlock(&kvm->lock); in kvmppc_clr_passthru_irq()
6037 return -ENODEV; in kvmppc_clr_passthru_irq()
6043 kvmppc_xics_clr_mapped(kvm, guest_gsi, pimap->mapped[i].r_hwirq); in kvmppc_clr_passthru_irq()
6046 pimap->mapped[i].r_hwirq = 0; in kvmppc_clr_passthru_irq()
6053 mutex_unlock(&kvm->lock); in kvmppc_clr_passthru_irq()
6064 irqfd->producer = prod; in kvmppc_irq_bypass_add_producer_hv()
6066 ret = kvmppc_set_passthru_irq(irqfd->kvm, prod->irq, irqfd->gsi); in kvmppc_irq_bypass_add_producer_hv()
6069 prod->irq, irqfd->gsi, ret); in kvmppc_irq_bypass_add_producer_hv()
6081 irqfd->producer = NULL; in kvmppc_irq_bypass_del_producer_hv()
6085 * default external interrupt handling mode - KVM real mode in kvmppc_irq_bypass_del_producer_hv()
6088 ret = kvmppc_clr_passthru_irq(irqfd->kvm, prod->irq, irqfd->gsi); in kvmppc_irq_bypass_del_producer_hv()
6091 prod->irq, irqfd->gsi, ret); in kvmppc_irq_bypass_del_producer_hv()
6098 struct kvm *kvm __maybe_unused = filp->private_data; in kvm_arch_vm_ioctl_hv()
6109 r = -EOPNOTSUPP; in kvm_arch_vm_ioctl_hv()
6113 r = -EFAULT; in kvm_arch_vm_ioctl_hv()
6126 r = -EFAULT; in kvm_arch_vm_ioctl_hv()
6136 r = -EFAULT; in kvm_arch_vm_ioctl_hv()
6147 r = -EFAULT; in kvm_arch_vm_ioctl_hv()
6156 r = -ENOTTY; in kvm_arch_vm_ioctl_hv()
6165 * all hcalls that were implemented before the hcall-enabling
6215 return -ENODEV; in kvmhv_configure_mmu()
6218 if (cfg->flags & ~(KVM_PPC_MMUV3_RADIX | KVM_PPC_MMUV3_GTSE)) in kvmhv_configure_mmu()
6219 return -EINVAL; in kvmhv_configure_mmu()
6222 radix = !!(cfg->flags & KVM_PPC_MMUV3_RADIX); in kvmhv_configure_mmu()
6223 if (!!(cfg->process_table & PATB_GR) != radix) in kvmhv_configure_mmu()
6224 return -EINVAL; in kvmhv_configure_mmu()
6227 if ((cfg->process_table & PRTS_MASK) > 24) in kvmhv_configure_mmu()
6228 return -EINVAL; in kvmhv_configure_mmu()
6232 return -EINVAL; in kvmhv_configure_mmu()
6236 return -EINVAL; in kvmhv_configure_mmu()
6238 mutex_lock(&kvm->arch.mmu_setup_lock); in kvmhv_configure_mmu()
6240 if (kvm->arch.mmu_ready) { in kvmhv_configure_mmu()
6241 kvm->arch.mmu_ready = 0; in kvmhv_configure_mmu()
6244 if (atomic_read(&kvm->arch.vcpus_running)) { in kvmhv_configure_mmu()
6245 kvm->arch.mmu_ready = 1; in kvmhv_configure_mmu()
6246 err = -EBUSY; in kvmhv_configure_mmu()
6258 kvm->arch.process_table = cfg->process_table; in kvmhv_configure_mmu()
6261 lpcr = (cfg->flags & KVM_PPC_MMUV3_GTSE) ? LPCR_GTSE : 0; in kvmhv_configure_mmu()
6266 mutex_unlock(&kvm->arch.mmu_setup_lock); in kvmhv_configure_mmu()
6273 return -EPERM; in kvmhv_enable_nested()
6275 return -ENODEV; in kvmhv_enable_nested()
6277 return -ENODEV; in kvmhv_enable_nested()
6279 return -ENODEV; in kvmhv_enable_nested()
6283 kvm->arch.nested_enable = true; in kvmhv_enable_nested()
6290 int rc = -EINVAL; in kvmhv_load_from_eaddr()
6296 rc = -EINVAL; in kvmhv_load_from_eaddr()
6300 if (rc && vcpu->arch.nested) in kvmhv_load_from_eaddr()
6301 rc = -EAGAIN; in kvmhv_load_from_eaddr()
6309 int rc = -EINVAL; in kvmhv_store_to_eaddr()
6315 rc = -EINVAL; in kvmhv_store_to_eaddr()
6319 if (rc && vcpu->arch.nested) in kvmhv_store_to_eaddr()
6320 rc = -EAGAIN; in kvmhv_store_to_eaddr()
6328 vpa->gpa = 0; in unpin_vpa_reset()
6329 vpa->pinned_addr = NULL; in unpin_vpa_reset()
6330 vpa->dirty = false; in unpin_vpa_reset()
6331 vpa->update_pending = 0; in unpin_vpa_reset()
6343 return -EINVAL; in kvmhv_enable_svm()
6345 kvm->arch.svm_enabled = 1; in kvmhv_enable_svm()
6352 * - Release all device pages
6353 * - Issue ucall to terminate the guest on the UV side
6354 * - Unpin the VPA pages.
6355 * - Reinit the partition scoped page tables
6365 if (!(kvm->arch.secure_guest & KVMPPC_SECURE_INIT_START)) in kvmhv_svm_off()
6368 mutex_lock(&kvm->arch.mmu_setup_lock); in kvmhv_svm_off()
6369 mmu_was_ready = kvm->arch.mmu_ready; in kvmhv_svm_off()
6370 if (kvm->arch.mmu_ready) { in kvmhv_svm_off()
6371 kvm->arch.mmu_ready = 0; in kvmhv_svm_off()
6374 if (atomic_read(&kvm->arch.vcpus_running)) { in kvmhv_svm_off()
6375 kvm->arch.mmu_ready = 1; in kvmhv_svm_off()
6376 ret = -EBUSY; in kvmhv_svm_off()
6381 srcu_idx = srcu_read_lock(&kvm->srcu); in kvmhv_svm_off()
6392 uv_unregister_mem_slot(kvm->arch.lpid, memslot->id); in kvmhv_svm_off()
6395 srcu_read_unlock(&kvm->srcu, srcu_idx); in kvmhv_svm_off()
6397 ret = uv_svm_terminate(kvm->arch.lpid); in kvmhv_svm_off()
6399 ret = -EINVAL; in kvmhv_svm_off()
6405 * to UV via UV_PAGE_IN before the non-boot vcpus get a in kvmhv_svm_off()
6414 spin_lock(&vcpu->arch.vpa_update_lock); in kvmhv_svm_off()
6415 unpin_vpa_reset(kvm, &vcpu->arch.dtl); in kvmhv_svm_off()
6416 unpin_vpa_reset(kvm, &vcpu->arch.slb_shadow); in kvmhv_svm_off()
6417 unpin_vpa_reset(kvm, &vcpu->arch.vpa); in kvmhv_svm_off()
6418 spin_unlock(&vcpu->arch.vpa_update_lock); in kvmhv_svm_off()
6422 kvm->arch.secure_guest = 0; in kvmhv_svm_off()
6423 kvm->arch.mmu_ready = mmu_was_ready; in kvmhv_svm_off()
6425 mutex_unlock(&kvm->arch.mmu_setup_lock); in kvmhv_svm_off()
6432 return -ENODEV; in kvmhv_enable_dawr1()
6436 kvm->arch.dawr1_enabled = true; in kvmhv_enable_dawr1()
6522 if (paca_ptrs[first_cpu]->sibling_subcore_state) in kvm_init_subcore_bitmap()
6529 return -ENOMEM; in kvm_init_subcore_bitmap()
6535 paca_ptrs[cpu]->sibling_subcore_state = in kvm_init_subcore_bitmap()
6552 pr_err("KVM-HV: Host does not support TLBIE\n"); in kvmppc_book3s_init_hv()
6553 return -ENODEV; in kvmppc_book3s_init_hv()
6561 return -ENODEV; in kvmppc_book3s_init_hv()
6575 * either directly, via paca_ptrs[cpu]->kvm_hstate.xics_phys, or in kvmppc_book3s_init_hv()
6580 !local_paca->kvm_hstate.xics_phys) { in kvmppc_book3s_init_hv()
6583 np = of_find_compatible_node(NULL, NULL, "ibm,opal-intc"); in kvmppc_book3s_init_hv()
6585 pr_err("KVM-HV: Cannot determine method for accessing XICS\n"); in kvmppc_book3s_init_hv()
6586 r = -ENODEV; in kvmppc_book3s_init_hv()
6589 /* presence of intc confirmed - node can be dropped again */ in kvmppc_book3s_init_hv()
6610 pr_err("KVM-HV: kvmppc_uvmem_init failed %d\n", r); in kvmppc_book3s_init_hv()