Lines Matching full:vcpu
56 STATS_DESC_COUNTER(VCPU, sum_exits),
57 STATS_DESC_COUNTER(VCPU, mmio_exits),
58 STATS_DESC_COUNTER(VCPU, signal_exits),
59 STATS_DESC_COUNTER(VCPU, light_exits),
60 STATS_DESC_COUNTER(VCPU, itlb_real_miss_exits),
61 STATS_DESC_COUNTER(VCPU, itlb_virt_miss_exits),
62 STATS_DESC_COUNTER(VCPU, dtlb_real_miss_exits),
63 STATS_DESC_COUNTER(VCPU, dtlb_virt_miss_exits),
64 STATS_DESC_COUNTER(VCPU, syscall_exits),
65 STATS_DESC_COUNTER(VCPU, isi_exits),
66 STATS_DESC_COUNTER(VCPU, dsi_exits),
67 STATS_DESC_COUNTER(VCPU, emulated_inst_exits),
68 STATS_DESC_COUNTER(VCPU, dec_exits),
69 STATS_DESC_COUNTER(VCPU, ext_intr_exits),
70 STATS_DESC_COUNTER(VCPU, halt_successful_wait),
71 STATS_DESC_COUNTER(VCPU, dbell_exits),
72 STATS_DESC_COUNTER(VCPU, gdbell_exits),
73 STATS_DESC_COUNTER(VCPU, ld),
74 STATS_DESC_COUNTER(VCPU, st),
75 STATS_DESC_COUNTER(VCPU, pthru_all),
76 STATS_DESC_COUNTER(VCPU, pthru_host),
77 STATS_DESC_COUNTER(VCPU, pthru_bad_aff)
90 void kvmppc_dump_vcpu(struct kvm_vcpu *vcpu) in kvmppc_dump_vcpu() argument
94 printk("pc: %08lx msr: %08llx\n", vcpu->arch.regs.nip, in kvmppc_dump_vcpu()
95 vcpu->arch.shared->msr); in kvmppc_dump_vcpu()
96 printk("lr: %08lx ctr: %08lx\n", vcpu->arch.regs.link, in kvmppc_dump_vcpu()
97 vcpu->arch.regs.ctr); in kvmppc_dump_vcpu()
98 printk("srr0: %08llx srr1: %08llx\n", vcpu->arch.shared->srr0, in kvmppc_dump_vcpu()
99 vcpu->arch.shared->srr1); in kvmppc_dump_vcpu()
101 printk("exceptions: %08lx\n", vcpu->arch.pending_exceptions); in kvmppc_dump_vcpu()
105 kvmppc_get_gpr(vcpu, i), in kvmppc_dump_vcpu()
106 kvmppc_get_gpr(vcpu, i+1), in kvmppc_dump_vcpu()
107 kvmppc_get_gpr(vcpu, i+2), in kvmppc_dump_vcpu()
108 kvmppc_get_gpr(vcpu, i+3)); in kvmppc_dump_vcpu()
113 void kvmppc_vcpu_disable_spe(struct kvm_vcpu *vcpu) in kvmppc_vcpu_disable_spe() argument
117 kvmppc_save_guest_spe(vcpu); in kvmppc_vcpu_disable_spe()
119 vcpu->arch.shadow_msr &= ~MSR_SPE; in kvmppc_vcpu_disable_spe()
123 static void kvmppc_vcpu_enable_spe(struct kvm_vcpu *vcpu) in kvmppc_vcpu_enable_spe() argument
127 kvmppc_load_guest_spe(vcpu); in kvmppc_vcpu_enable_spe()
129 vcpu->arch.shadow_msr |= MSR_SPE; in kvmppc_vcpu_enable_spe()
133 static void kvmppc_vcpu_sync_spe(struct kvm_vcpu *vcpu) in kvmppc_vcpu_sync_spe() argument
135 if (vcpu->arch.shared->msr & MSR_SPE) { in kvmppc_vcpu_sync_spe()
136 if (!(vcpu->arch.shadow_msr & MSR_SPE)) in kvmppc_vcpu_sync_spe()
137 kvmppc_vcpu_enable_spe(vcpu); in kvmppc_vcpu_sync_spe()
138 } else if (vcpu->arch.shadow_msr & MSR_SPE) { in kvmppc_vcpu_sync_spe()
139 kvmppc_vcpu_disable_spe(vcpu); in kvmppc_vcpu_sync_spe()
143 static void kvmppc_vcpu_sync_spe(struct kvm_vcpu *vcpu) in kvmppc_vcpu_sync_spe() argument
149 * Load up guest vcpu FP state if it's needed.
152 * guest vcpu FP state if other threads require to use FPU.
157 static inline void kvmppc_load_guest_fp(struct kvm_vcpu *vcpu) in kvmppc_load_guest_fp() argument
162 load_fp_state(&vcpu->arch.fp); in kvmppc_load_guest_fp()
164 current->thread.fp_save_area = &vcpu->arch.fp; in kvmppc_load_guest_fp()
171 * Save guest vcpu FP state into thread.
174 static inline void kvmppc_save_guest_fp(struct kvm_vcpu *vcpu) in kvmppc_save_guest_fp() argument
183 static void kvmppc_vcpu_sync_fpu(struct kvm_vcpu *vcpu) in kvmppc_vcpu_sync_fpu() argument
188 vcpu->arch.shadow_msr &= ~MSR_FP; in kvmppc_vcpu_sync_fpu()
189 vcpu->arch.shadow_msr |= vcpu->arch.shared->msr & MSR_FP; in kvmppc_vcpu_sync_fpu()
198 static inline void kvmppc_load_guest_altivec(struct kvm_vcpu *vcpu) in kvmppc_load_guest_altivec() argument
204 load_vr_state(&vcpu->arch.vr); in kvmppc_load_guest_altivec()
206 current->thread.vr_save_area = &vcpu->arch.vr; in kvmppc_load_guest_altivec()
214 * Save guest vcpu AltiVec state into thread.
217 static inline void kvmppc_save_guest_altivec(struct kvm_vcpu *vcpu) in kvmppc_save_guest_altivec() argument
228 static void kvmppc_vcpu_sync_debug(struct kvm_vcpu *vcpu) in kvmppc_vcpu_sync_debug() argument
232 vcpu->arch.shadow_msr &= ~MSR_DE; in kvmppc_vcpu_sync_debug()
233 vcpu->arch.shadow_msr |= vcpu->arch.shared->msr & MSR_DE; in kvmppc_vcpu_sync_debug()
237 if (vcpu->guest_debug) { in kvmppc_vcpu_sync_debug()
243 vcpu->arch.shared->msr |= MSR_DE; in kvmppc_vcpu_sync_debug()
245 vcpu->arch.shadow_msr |= MSR_DE; in kvmppc_vcpu_sync_debug()
246 vcpu->arch.shared->msr &= ~MSR_DE; in kvmppc_vcpu_sync_debug()
255 void kvmppc_set_msr(struct kvm_vcpu *vcpu, u32 new_msr) in kvmppc_set_msr() argument
257 u32 old_msr = vcpu->arch.shared->msr; in kvmppc_set_msr()
263 vcpu->arch.shared->msr = new_msr; in kvmppc_set_msr()
265 kvmppc_mmu_msr_notify(vcpu, old_msr); in kvmppc_set_msr()
266 kvmppc_vcpu_sync_spe(vcpu); in kvmppc_set_msr()
267 kvmppc_vcpu_sync_fpu(vcpu); in kvmppc_set_msr()
268 kvmppc_vcpu_sync_debug(vcpu); in kvmppc_set_msr()
271 static void kvmppc_booke_queue_irqprio(struct kvm_vcpu *vcpu, in kvmppc_booke_queue_irqprio() argument
274 trace_kvm_booke_queue_irqprio(vcpu, priority); in kvmppc_booke_queue_irqprio()
275 set_bit(priority, &vcpu->arch.pending_exceptions); in kvmppc_booke_queue_irqprio()
278 void kvmppc_core_queue_dtlb_miss(struct kvm_vcpu *vcpu, in kvmppc_core_queue_dtlb_miss() argument
281 vcpu->arch.queued_dear = dear_flags; in kvmppc_core_queue_dtlb_miss()
282 vcpu->arch.queued_esr = esr_flags; in kvmppc_core_queue_dtlb_miss()
283 kvmppc_booke_queue_irqprio(vcpu, BOOKE_IRQPRIO_DTLB_MISS); in kvmppc_core_queue_dtlb_miss()
286 void kvmppc_core_queue_data_storage(struct kvm_vcpu *vcpu, ulong srr1_flags, in kvmppc_core_queue_data_storage() argument
290 vcpu->arch.queued_dear = dear_flags; in kvmppc_core_queue_data_storage()
291 vcpu->arch.queued_esr = esr_flags; in kvmppc_core_queue_data_storage()
292 kvmppc_booke_queue_irqprio(vcpu, BOOKE_IRQPRIO_DATA_STORAGE); in kvmppc_core_queue_data_storage()
295 void kvmppc_core_queue_itlb_miss(struct kvm_vcpu *vcpu) in kvmppc_core_queue_itlb_miss() argument
297 kvmppc_booke_queue_irqprio(vcpu, BOOKE_IRQPRIO_ITLB_MISS); in kvmppc_core_queue_itlb_miss()
300 void kvmppc_core_queue_inst_storage(struct kvm_vcpu *vcpu, ulong esr_flags) in kvmppc_core_queue_inst_storage() argument
302 vcpu->arch.queued_esr = esr_flags; in kvmppc_core_queue_inst_storage()
303 kvmppc_booke_queue_irqprio(vcpu, BOOKE_IRQPRIO_INST_STORAGE); in kvmppc_core_queue_inst_storage()
306 static void kvmppc_core_queue_alignment(struct kvm_vcpu *vcpu, ulong dear_flags, in kvmppc_core_queue_alignment() argument
309 vcpu->arch.queued_dear = dear_flags; in kvmppc_core_queue_alignment()
310 vcpu->arch.queued_esr = esr_flags; in kvmppc_core_queue_alignment()
311 kvmppc_booke_queue_irqprio(vcpu, BOOKE_IRQPRIO_ALIGNMENT); in kvmppc_core_queue_alignment()
314 void kvmppc_core_queue_program(struct kvm_vcpu *vcpu, ulong esr_flags) in kvmppc_core_queue_program() argument
316 vcpu->arch.queued_esr = esr_flags; in kvmppc_core_queue_program()
317 kvmppc_booke_queue_irqprio(vcpu, BOOKE_IRQPRIO_PROGRAM); in kvmppc_core_queue_program()
320 void kvmppc_core_queue_fpunavail(struct kvm_vcpu *vcpu, ulong srr1_flags) in kvmppc_core_queue_fpunavail() argument
323 kvmppc_booke_queue_irqprio(vcpu, BOOKE_IRQPRIO_FP_UNAVAIL); in kvmppc_core_queue_fpunavail()
327 void kvmppc_core_queue_vec_unavail(struct kvm_vcpu *vcpu, ulong srr1_flags) in kvmppc_core_queue_vec_unavail() argument
330 kvmppc_booke_queue_irqprio(vcpu, BOOKE_IRQPRIO_ALTIVEC_UNAVAIL); in kvmppc_core_queue_vec_unavail()
334 void kvmppc_core_queue_dec(struct kvm_vcpu *vcpu) in kvmppc_core_queue_dec() argument
336 kvmppc_booke_queue_irqprio(vcpu, BOOKE_IRQPRIO_DECREMENTER); in kvmppc_core_queue_dec()
339 int kvmppc_core_pending_dec(struct kvm_vcpu *vcpu) in kvmppc_core_pending_dec() argument
341 return test_bit(BOOKE_IRQPRIO_DECREMENTER, &vcpu->arch.pending_exceptions); in kvmppc_core_pending_dec()
344 void kvmppc_core_dequeue_dec(struct kvm_vcpu *vcpu) in kvmppc_core_dequeue_dec() argument
346 clear_bit(BOOKE_IRQPRIO_DECREMENTER, &vcpu->arch.pending_exceptions); in kvmppc_core_dequeue_dec()
349 void kvmppc_core_queue_external(struct kvm_vcpu *vcpu, in kvmppc_core_queue_external() argument
357 kvmppc_booke_queue_irqprio(vcpu, prio); in kvmppc_core_queue_external()
360 void kvmppc_core_dequeue_external(struct kvm_vcpu *vcpu) in kvmppc_core_dequeue_external() argument
362 clear_bit(BOOKE_IRQPRIO_EXTERNAL, &vcpu->arch.pending_exceptions); in kvmppc_core_dequeue_external()
363 clear_bit(BOOKE_IRQPRIO_EXTERNAL_LEVEL, &vcpu->arch.pending_exceptions); in kvmppc_core_dequeue_external()
366 static void kvmppc_core_queue_watchdog(struct kvm_vcpu *vcpu) in kvmppc_core_queue_watchdog() argument
368 kvmppc_booke_queue_irqprio(vcpu, BOOKE_IRQPRIO_WATCHDOG); in kvmppc_core_queue_watchdog()
371 static void kvmppc_core_dequeue_watchdog(struct kvm_vcpu *vcpu) in kvmppc_core_dequeue_watchdog() argument
373 clear_bit(BOOKE_IRQPRIO_WATCHDOG, &vcpu->arch.pending_exceptions); in kvmppc_core_dequeue_watchdog()
376 void kvmppc_core_queue_debug(struct kvm_vcpu *vcpu) in kvmppc_core_queue_debug() argument
378 kvmppc_booke_queue_irqprio(vcpu, BOOKE_IRQPRIO_DEBUG); in kvmppc_core_queue_debug()
381 void kvmppc_core_dequeue_debug(struct kvm_vcpu *vcpu) in kvmppc_core_dequeue_debug() argument
383 clear_bit(BOOKE_IRQPRIO_DEBUG, &vcpu->arch.pending_exceptions); in kvmppc_core_dequeue_debug()
386 static void set_guest_srr(struct kvm_vcpu *vcpu, unsigned long srr0, u32 srr1) in set_guest_srr() argument
388 kvmppc_set_srr0(vcpu, srr0); in set_guest_srr()
389 kvmppc_set_srr1(vcpu, srr1); in set_guest_srr()
392 static void set_guest_csrr(struct kvm_vcpu *vcpu, unsigned long srr0, u32 srr1) in set_guest_csrr() argument
394 vcpu->arch.csrr0 = srr0; in set_guest_csrr()
395 vcpu->arch.csrr1 = srr1; in set_guest_csrr()
398 static void set_guest_dsrr(struct kvm_vcpu *vcpu, unsigned long srr0, u32 srr1) in set_guest_dsrr() argument
401 vcpu->arch.dsrr0 = srr0; in set_guest_dsrr()
402 vcpu->arch.dsrr1 = srr1; in set_guest_dsrr()
404 set_guest_csrr(vcpu, srr0, srr1); in set_guest_dsrr()
408 static void set_guest_mcsrr(struct kvm_vcpu *vcpu, unsigned long srr0, u32 srr1) in set_guest_mcsrr() argument
410 vcpu->arch.mcsrr0 = srr0; in set_guest_mcsrr()
411 vcpu->arch.mcsrr1 = srr1; in set_guest_mcsrr()
415 static int kvmppc_booke_irqprio_deliver(struct kvm_vcpu *vcpu, in kvmppc_booke_irqprio_deliver() argument
421 ulong crit_raw = vcpu->arch.shared->critical; in kvmppc_booke_irqprio_deliver()
422 ulong crit_r1 = kvmppc_get_gpr(vcpu, 1); in kvmppc_booke_irqprio_deliver()
426 ulong new_msr = vcpu->arch.shared->msr; in kvmppc_booke_irqprio_deliver()
429 if (!(vcpu->arch.shared->msr & MSR_SF)) { in kvmppc_booke_irqprio_deliver()
437 crit = crit && !(vcpu->arch.shared->msr & MSR_PR); in kvmppc_booke_irqprio_deliver()
444 if ((priority == BOOKE_IRQPRIO_EXTERNAL) && vcpu->arch.epr_flags) in kvmppc_booke_irqprio_deliver()
477 allowed = vcpu->arch.shared->msr & MSR_CE; in kvmppc_booke_irqprio_deliver()
483 allowed = vcpu->arch.shared->msr & MSR_ME; in kvmppc_booke_irqprio_deliver()
493 allowed = vcpu->arch.shared->msr & MSR_EE; in kvmppc_booke_irqprio_deliver()
499 allowed = vcpu->arch.shared->msr & MSR_DE; in kvmppc_booke_irqprio_deliver()
513 set_guest_srr(vcpu, vcpu->arch.regs.nip, in kvmppc_booke_irqprio_deliver()
514 vcpu->arch.shared->msr); in kvmppc_booke_irqprio_deliver()
517 set_guest_csrr(vcpu, vcpu->arch.regs.nip, in kvmppc_booke_irqprio_deliver()
518 vcpu->arch.shared->msr); in kvmppc_booke_irqprio_deliver()
521 set_guest_dsrr(vcpu, vcpu->arch.regs.nip, in kvmppc_booke_irqprio_deliver()
522 vcpu->arch.shared->msr); in kvmppc_booke_irqprio_deliver()
525 set_guest_mcsrr(vcpu, vcpu->arch.regs.nip, in kvmppc_booke_irqprio_deliver()
526 vcpu->arch.shared->msr); in kvmppc_booke_irqprio_deliver()
530 vcpu->arch.regs.nip = vcpu->arch.ivpr | in kvmppc_booke_irqprio_deliver()
531 vcpu->arch.ivor[priority]; in kvmppc_booke_irqprio_deliver()
533 kvmppc_set_esr(vcpu, vcpu->arch.queued_esr); in kvmppc_booke_irqprio_deliver()
535 kvmppc_set_dar(vcpu, vcpu->arch.queued_dear); in kvmppc_booke_irqprio_deliver()
537 if (vcpu->arch.epr_flags & KVMPPC_EPR_USER) in kvmppc_booke_irqprio_deliver()
538 kvm_make_request(KVM_REQ_EPR_EXIT, vcpu); in kvmppc_booke_irqprio_deliver()
539 else if (vcpu->arch.epr_flags & KVMPPC_EPR_KERNEL) { in kvmppc_booke_irqprio_deliver()
540 BUG_ON(vcpu->arch.irq_type != KVMPPC_IRQ_MPIC); in kvmppc_booke_irqprio_deliver()
541 kvmppc_mpic_set_epr(vcpu); in kvmppc_booke_irqprio_deliver()
547 if (vcpu->arch.epcr & SPRN_EPCR_ICM) in kvmppc_booke_irqprio_deliver()
550 kvmppc_set_msr(vcpu, new_msr); in kvmppc_booke_irqprio_deliver()
553 clear_bit(priority, &vcpu->arch.pending_exceptions); in kvmppc_booke_irqprio_deliver()
562 if (vcpu->arch.pending_exceptions & BOOKE_IRQMASK_EE) in kvmppc_booke_irqprio_deliver()
563 kvmppc_set_pending_interrupt(vcpu, INT_CLASS_NONCRIT); in kvmppc_booke_irqprio_deliver()
564 if (vcpu->arch.pending_exceptions & BOOKE_IRQMASK_CE) in kvmppc_booke_irqprio_deliver()
565 kvmppc_set_pending_interrupt(vcpu, INT_CLASS_CRIT); in kvmppc_booke_irqprio_deliver()
566 if (vcpu->arch.pending_exceptions & BOOKE_IRQPRIO_MACHINE_CHECK) in kvmppc_booke_irqprio_deliver()
567 kvmppc_set_pending_interrupt(vcpu, INT_CLASS_MC); in kvmppc_booke_irqprio_deliver()
578 static unsigned long watchdog_next_timeout(struct kvm_vcpu *vcpu) in watchdog_next_timeout() argument
582 u32 period = TCR_GET_WP(vcpu->arch.tcr); in watchdog_next_timeout()
604 static void arm_next_watchdog(struct kvm_vcpu *vcpu) in arm_next_watchdog() argument
613 if ((vcpu->arch.tsr & (TSR_ENW | TSR_WIS)) != (TSR_ENW | TSR_WIS)) in arm_next_watchdog()
614 kvm_clear_request(KVM_REQ_WATCHDOG, vcpu); in arm_next_watchdog()
616 spin_lock_irqsave(&vcpu->arch.wdt_lock, flags); in arm_next_watchdog()
617 nr_jiffies = watchdog_next_timeout(vcpu); in arm_next_watchdog()
623 mod_timer(&vcpu->arch.wdt_timer, jiffies + nr_jiffies); in arm_next_watchdog()
625 del_timer(&vcpu->arch.wdt_timer); in arm_next_watchdog()
626 spin_unlock_irqrestore(&vcpu->arch.wdt_lock, flags); in arm_next_watchdog()
631 struct kvm_vcpu *vcpu = from_timer(vcpu, t, arch.wdt_timer); in kvmppc_watchdog_func() local
636 new_tsr = tsr = vcpu->arch.tsr; in kvmppc_watchdog_func()
648 } while (cmpxchg(&vcpu->arch.tsr, tsr, new_tsr) != tsr); in kvmppc_watchdog_func()
652 kvm_make_request(KVM_REQ_PENDING_TIMER, vcpu); in kvmppc_watchdog_func()
653 kvm_vcpu_kick(vcpu); in kvmppc_watchdog_func()
660 if (final && (vcpu->arch.tcr & TCR_WRC_MASK) && in kvmppc_watchdog_func()
661 vcpu->arch.watchdog_enabled) { in kvmppc_watchdog_func()
663 kvm_make_request(KVM_REQ_WATCHDOG, vcpu); in kvmppc_watchdog_func()
664 kvm_vcpu_kick(vcpu); in kvmppc_watchdog_func()
674 arm_next_watchdog(vcpu); in kvmppc_watchdog_func()
677 static void update_timer_ints(struct kvm_vcpu *vcpu) in update_timer_ints() argument
679 if ((vcpu->arch.tcr & TCR_DIE) && (vcpu->arch.tsr & TSR_DIS)) in update_timer_ints()
680 kvmppc_core_queue_dec(vcpu); in update_timer_ints()
682 kvmppc_core_dequeue_dec(vcpu); in update_timer_ints()
684 if ((vcpu->arch.tcr & TCR_WIE) && (vcpu->arch.tsr & TSR_WIS)) in update_timer_ints()
685 kvmppc_core_queue_watchdog(vcpu); in update_timer_ints()
687 kvmppc_core_dequeue_watchdog(vcpu); in update_timer_ints()
690 static void kvmppc_core_check_exceptions(struct kvm_vcpu *vcpu) in kvmppc_core_check_exceptions() argument
692 unsigned long *pending = &vcpu->arch.pending_exceptions; in kvmppc_core_check_exceptions()
697 if (kvmppc_booke_irqprio_deliver(vcpu, priority)) in kvmppc_core_check_exceptions()
706 vcpu->arch.shared->int_pending = !!*pending; in kvmppc_core_check_exceptions()
710 int kvmppc_core_prepare_to_enter(struct kvm_vcpu *vcpu) in kvmppc_core_prepare_to_enter() argument
715 kvmppc_core_check_exceptions(vcpu); in kvmppc_core_prepare_to_enter()
717 if (kvm_request_pending(vcpu)) { in kvmppc_core_prepare_to_enter()
722 if (vcpu->arch.shared->msr & MSR_WE) { in kvmppc_core_prepare_to_enter()
724 kvm_vcpu_halt(vcpu); in kvmppc_core_prepare_to_enter()
727 kvmppc_set_exit_type(vcpu, EMULATED_MTMSRWE_EXITS); in kvmppc_core_prepare_to_enter()
734 int kvmppc_core_check_requests(struct kvm_vcpu *vcpu) in kvmppc_core_check_requests() argument
738 if (kvm_check_request(KVM_REQ_PENDING_TIMER, vcpu)) in kvmppc_core_check_requests()
739 update_timer_ints(vcpu); in kvmppc_core_check_requests()
741 if (kvm_check_request(KVM_REQ_TLB_FLUSH, vcpu)) in kvmppc_core_check_requests()
742 kvmppc_core_flush_tlb(vcpu); in kvmppc_core_check_requests()
745 if (kvm_check_request(KVM_REQ_WATCHDOG, vcpu)) { in kvmppc_core_check_requests()
746 vcpu->run->exit_reason = KVM_EXIT_WATCHDOG; in kvmppc_core_check_requests()
750 if (kvm_check_request(KVM_REQ_EPR_EXIT, vcpu)) { in kvmppc_core_check_requests()
751 vcpu->run->epr.epr = 0; in kvmppc_core_check_requests()
752 vcpu->arch.epr_needed = true; in kvmppc_core_check_requests()
753 vcpu->run->exit_reason = KVM_EXIT_EPR; in kvmppc_core_check_requests()
760 int kvmppc_vcpu_run(struct kvm_vcpu *vcpu) in kvmppc_vcpu_run() argument
765 if (!vcpu->arch.sane) { in kvmppc_vcpu_run()
766 vcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR; in kvmppc_vcpu_run()
770 s = kvmppc_prepare_to_enter(vcpu); in kvmppc_vcpu_run()
785 kvmppc_load_guest_fp(vcpu); in kvmppc_vcpu_run()
796 kvmppc_load_guest_altivec(vcpu); in kvmppc_vcpu_run()
800 debug = vcpu->arch.dbg_reg; in kvmppc_vcpu_run()
803 current->thread.debug = vcpu->arch.dbg_reg; in kvmppc_vcpu_run()
805 vcpu->arch.pgdir = vcpu->kvm->mm->pgd; in kvmppc_vcpu_run()
808 ret = __kvmppc_vcpu_run(vcpu); in kvmppc_vcpu_run()
818 kvmppc_save_guest_fp(vcpu); in kvmppc_vcpu_run()
822 kvmppc_save_guest_altivec(vcpu); in kvmppc_vcpu_run()
826 vcpu->mode = OUTSIDE_GUEST_MODE; in kvmppc_vcpu_run()
830 static int emulation_exit(struct kvm_vcpu *vcpu) in emulation_exit() argument
834 er = kvmppc_emulate_instruction(vcpu); in emulation_exit()
838 kvmppc_account_exit_stat(vcpu, EMULATED_INST_EXITS); in emulation_exit()
848 __func__, vcpu->arch.regs.nip, vcpu->arch.last_inst); in emulation_exit()
851 vcpu->run->hw.hardware_exit_reason = ~0ULL << 32; in emulation_exit()
852 vcpu->run->hw.hardware_exit_reason |= vcpu->arch.last_inst; in emulation_exit()
853 kvmppc_core_queue_program(vcpu, ESR_PIL); in emulation_exit()
864 static int kvmppc_handle_debug(struct kvm_vcpu *vcpu) in kvmppc_handle_debug() argument
866 struct kvm_run *run = vcpu->run; in kvmppc_handle_debug()
867 struct debug_reg *dbg_reg = &(vcpu->arch.dbg_reg); in kvmppc_handle_debug()
868 u32 dbsr = vcpu->arch.dbsr; in kvmppc_handle_debug()
870 if (vcpu->guest_debug == 0) { in kvmppc_handle_debug()
881 if (dbsr && (vcpu->arch.shared->msr & MSR_DE) && in kvmppc_handle_debug()
882 (vcpu->arch.dbg_reg.dbcr0 & DBCR0_IDM)) in kvmppc_handle_debug()
883 kvmppc_core_queue_debug(vcpu); in kvmppc_handle_debug()
886 if ((dbsr & DBSR_TIE) && !(vcpu->arch.shared->msr & MSR_DE)) in kvmppc_handle_debug()
887 kvmppc_core_queue_program(vcpu, ESR_PTR); in kvmppc_handle_debug()
894 * Clear guest dbsr (vcpu->arch.dbsr) in kvmppc_handle_debug()
896 vcpu->arch.dbsr = 0; in kvmppc_handle_debug()
898 run->debug.arch.address = vcpu->arch.regs.nip; in kvmppc_handle_debug()
937 static void kvmppc_restart_interrupt(struct kvm_vcpu *vcpu, in kvmppc_restart_interrupt() argument
978 vcpu->arch.dbsr = mfspr(SPRN_DBSR); in kvmppc_restart_interrupt()
984 static int kvmppc_resume_inst_load(struct kvm_vcpu *vcpu, in kvmppc_resume_inst_load() argument
993 __func__, vcpu->arch.regs.nip); in kvmppc_resume_inst_load()
996 vcpu->run->hw.hardware_exit_reason = ~0ULL << 32; in kvmppc_resume_inst_load()
997 vcpu->run->hw.hardware_exit_reason |= last_inst; in kvmppc_resume_inst_load()
998 kvmppc_core_queue_program(vcpu, ESR_PIL); in kvmppc_resume_inst_load()
1011 int kvmppc_handle_exit(struct kvm_vcpu *vcpu, unsigned int exit_nr) in kvmppc_handle_exit() argument
1013 struct kvm_run *run = vcpu->run; in kvmppc_handle_exit()
1025 kvmppc_update_timing_stats(vcpu); in kvmppc_handle_exit()
1028 kvmppc_restart_interrupt(vcpu, exit_nr); in kvmppc_handle_exit()
1038 emulated = kvmppc_get_last_inst(vcpu, INST_GENERIC, &pinst); in kvmppc_handle_exit()
1043 if (vcpu->guest_debug & KVM_GUESTDBG_USE_SW_BP) { in kvmppc_handle_exit()
1044 emulated = kvmppc_get_last_inst(vcpu, INST_GENERIC, &pinst); in kvmppc_handle_exit()
1052 trace_kvm_exit(exit_nr, vcpu); in kvmppc_handle_exit()
1075 r = kvmppc_resume_inst_load(vcpu, emulated, last_inst); in kvmppc_handle_exit()
1082 kvmppc_dump_vcpu(vcpu); in kvmppc_handle_exit()
1090 kvmppc_account_exit(vcpu, EXT_INTR_EXITS); in kvmppc_handle_exit()
1095 kvmppc_account_exit(vcpu, DEC_EXITS); in kvmppc_handle_exit()
1104 kvmppc_account_exit(vcpu, DBELL_EXITS); in kvmppc_handle_exit()
1109 kvmppc_account_exit(vcpu, GDBELL_EXITS); in kvmppc_handle_exit()
1120 kvmppc_account_exit(vcpu, GDBELL_EXITS); in kvmppc_handle_exit()
1135 r = emulation_exit(vcpu); in kvmppc_handle_exit()
1139 if ((vcpu->guest_debug & KVM_GUESTDBG_USE_SW_BP) && in kvmppc_handle_exit()
1145 r = kvmppc_handle_debug(vcpu); in kvmppc_handle_exit()
1147 kvmppc_account_exit(vcpu, DEBUG_EXITS); in kvmppc_handle_exit()
1151 if (vcpu->arch.shared->msr & (MSR_PR | MSR_GS)) { in kvmppc_handle_exit()
1160 kvmppc_core_queue_program(vcpu, vcpu->arch.fault_esr); in kvmppc_handle_exit()
1162 kvmppc_account_exit(vcpu, USR_PR_INST); in kvmppc_handle_exit()
1166 r = emulation_exit(vcpu); in kvmppc_handle_exit()
1170 kvmppc_booke_queue_irqprio(vcpu, BOOKE_IRQPRIO_FP_UNAVAIL); in kvmppc_handle_exit()
1171 kvmppc_account_exit(vcpu, FP_UNAVAIL); in kvmppc_handle_exit()
1177 if (vcpu->arch.shared->msr & MSR_SPE) in kvmppc_handle_exit()
1178 kvmppc_vcpu_enable_spe(vcpu); in kvmppc_handle_exit()
1180 kvmppc_booke_queue_irqprio(vcpu, in kvmppc_handle_exit()
1187 kvmppc_booke_queue_irqprio(vcpu, BOOKE_IRQPRIO_SPE_FP_DATA); in kvmppc_handle_exit()
1192 kvmppc_booke_queue_irqprio(vcpu, BOOKE_IRQPRIO_SPE_FP_ROUND); in kvmppc_handle_exit()
1201 kvmppc_core_queue_program(vcpu, ESR_PUO | ESR_SPV); in kvmppc_handle_exit()
1212 __func__, exit_nr, vcpu->arch.regs.nip); in kvmppc_handle_exit()
1224 kvmppc_booke_queue_irqprio(vcpu, BOOKE_IRQPRIO_ALTIVEC_UNAVAIL); in kvmppc_handle_exit()
1229 kvmppc_booke_queue_irqprio(vcpu, BOOKE_IRQPRIO_ALTIVEC_ASSIST); in kvmppc_handle_exit()
1235 kvmppc_core_queue_data_storage(vcpu, 0, vcpu->arch.fault_dear, in kvmppc_handle_exit()
1236 vcpu->arch.fault_esr); in kvmppc_handle_exit()
1237 kvmppc_account_exit(vcpu, DSI_EXITS); in kvmppc_handle_exit()
1242 kvmppc_core_queue_inst_storage(vcpu, vcpu->arch.fault_esr); in kvmppc_handle_exit()
1243 kvmppc_account_exit(vcpu, ISI_EXITS); in kvmppc_handle_exit()
1248 kvmppc_core_queue_alignment(vcpu, vcpu->arch.fault_dear, in kvmppc_handle_exit()
1249 vcpu->arch.fault_esr); in kvmppc_handle_exit()
1255 if (!(vcpu->arch.shared->msr & MSR_PR)) { in kvmppc_handle_exit()
1256 kvmppc_set_gpr(vcpu, 3, kvmppc_kvm_pv(vcpu)); in kvmppc_handle_exit()
1262 kvmppc_core_queue_program(vcpu, ESR_PPR); in kvmppc_handle_exit()
1269 if (!(vcpu->arch.shared->msr & MSR_PR) && in kvmppc_handle_exit()
1270 (((u32)kvmppc_get_gpr(vcpu, 0)) == KVM_SC_MAGIC_R0)) { in kvmppc_handle_exit()
1272 kvmppc_set_gpr(vcpu, 3, kvmppc_kvm_pv(vcpu)); in kvmppc_handle_exit()
1276 kvmppc_booke_queue_irqprio(vcpu, BOOKE_IRQPRIO_SYSCALL); in kvmppc_handle_exit()
1278 kvmppc_account_exit(vcpu, SYSCALL_EXITS); in kvmppc_handle_exit()
1284 unsigned long eaddr = vcpu->arch.fault_dear; in kvmppc_handle_exit()
1290 if (!(vcpu->arch.shared->msr & MSR_PR) && in kvmppc_handle_exit()
1291 (eaddr & PAGE_MASK) == vcpu->arch.magic_page_ea) { in kvmppc_handle_exit()
1292 kvmppc_map_magic(vcpu); in kvmppc_handle_exit()
1293 kvmppc_account_exit(vcpu, DTLB_VIRT_MISS_EXITS); in kvmppc_handle_exit()
1301 gtlb_index = kvmppc_mmu_dtlb_index(vcpu, eaddr); in kvmppc_handle_exit()
1304 kvmppc_core_queue_dtlb_miss(vcpu, in kvmppc_handle_exit()
1305 vcpu->arch.fault_dear, in kvmppc_handle_exit()
1306 vcpu->arch.fault_esr); in kvmppc_handle_exit()
1307 kvmppc_mmu_dtlb_miss(vcpu); in kvmppc_handle_exit()
1308 kvmppc_account_exit(vcpu, DTLB_REAL_MISS_EXITS); in kvmppc_handle_exit()
1313 idx = srcu_read_lock(&vcpu->kvm->srcu); in kvmppc_handle_exit()
1315 gpaddr = kvmppc_mmu_xlate(vcpu, gtlb_index, eaddr); in kvmppc_handle_exit()
1318 if (kvm_is_visible_gfn(vcpu->kvm, gfn)) { in kvmppc_handle_exit()
1325 kvmppc_mmu_map(vcpu, eaddr, gpaddr, gtlb_index); in kvmppc_handle_exit()
1326 kvmppc_account_exit(vcpu, DTLB_VIRT_MISS_EXITS); in kvmppc_handle_exit()
1331 vcpu->arch.paddr_accessed = gpaddr; in kvmppc_handle_exit()
1332 vcpu->arch.vaddr_accessed = eaddr; in kvmppc_handle_exit()
1333 r = kvmppc_emulate_mmio(vcpu); in kvmppc_handle_exit()
1334 kvmppc_account_exit(vcpu, MMIO_EXITS); in kvmppc_handle_exit()
1337 srcu_read_unlock(&vcpu->kvm->srcu, idx); in kvmppc_handle_exit()
1342 unsigned long eaddr = vcpu->arch.regs.nip; in kvmppc_handle_exit()
1350 gtlb_index = kvmppc_mmu_itlb_index(vcpu, eaddr); in kvmppc_handle_exit()
1353 kvmppc_booke_queue_irqprio(vcpu, BOOKE_IRQPRIO_ITLB_MISS); in kvmppc_handle_exit()
1354 kvmppc_mmu_itlb_miss(vcpu); in kvmppc_handle_exit()
1355 kvmppc_account_exit(vcpu, ITLB_REAL_MISS_EXITS); in kvmppc_handle_exit()
1359 kvmppc_account_exit(vcpu, ITLB_VIRT_MISS_EXITS); in kvmppc_handle_exit()
1361 idx = srcu_read_lock(&vcpu->kvm->srcu); in kvmppc_handle_exit()
1363 gpaddr = kvmppc_mmu_xlate(vcpu, gtlb_index, eaddr); in kvmppc_handle_exit()
1366 if (kvm_is_visible_gfn(vcpu->kvm, gfn)) { in kvmppc_handle_exit()
1373 kvmppc_mmu_map(vcpu, eaddr, gpaddr, gtlb_index); in kvmppc_handle_exit()
1376 kvmppc_booke_queue_irqprio(vcpu, BOOKE_IRQPRIO_MACHINE_CHECK); in kvmppc_handle_exit()
1379 srcu_read_unlock(&vcpu->kvm->srcu, idx); in kvmppc_handle_exit()
1384 r = kvmppc_handle_debug(vcpu); in kvmppc_handle_exit()
1387 kvmppc_account_exit(vcpu, DEBUG_EXITS); in kvmppc_handle_exit()
1402 s = kvmppc_prepare_to_enter(vcpu); in kvmppc_handle_exit()
1408 kvmppc_load_guest_fp(vcpu); in kvmppc_handle_exit()
1409 kvmppc_load_guest_altivec(vcpu); in kvmppc_handle_exit()
1416 static void kvmppc_set_tsr(struct kvm_vcpu *vcpu, u32 new_tsr) in kvmppc_set_tsr() argument
1418 u32 old_tsr = vcpu->arch.tsr; in kvmppc_set_tsr()
1420 vcpu->arch.tsr = new_tsr; in kvmppc_set_tsr()
1422 if ((old_tsr ^ vcpu->arch.tsr) & (TSR_ENW | TSR_WIS)) in kvmppc_set_tsr()
1423 arm_next_watchdog(vcpu); in kvmppc_set_tsr()
1425 update_timer_ints(vcpu); in kvmppc_set_tsr()
1428 int kvmppc_subarch_vcpu_init(struct kvm_vcpu *vcpu) in kvmppc_subarch_vcpu_init() argument
1431 spin_lock_init(&vcpu->arch.wdt_lock); in kvmppc_subarch_vcpu_init()
1432 timer_setup(&vcpu->arch.wdt_timer, kvmppc_watchdog_func, 0); in kvmppc_subarch_vcpu_init()
1442 void kvmppc_subarch_vcpu_uninit(struct kvm_vcpu *vcpu) in kvmppc_subarch_vcpu_uninit() argument
1444 del_timer_sync(&vcpu->arch.wdt_timer); in kvmppc_subarch_vcpu_uninit()
1447 int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs) in kvm_arch_vcpu_ioctl_get_regs() argument
1451 vcpu_load(vcpu); in kvm_arch_vcpu_ioctl_get_regs()
1453 regs->pc = vcpu->arch.regs.nip; in kvm_arch_vcpu_ioctl_get_regs()
1454 regs->cr = kvmppc_get_cr(vcpu); in kvm_arch_vcpu_ioctl_get_regs()
1455 regs->ctr = vcpu->arch.regs.ctr; in kvm_arch_vcpu_ioctl_get_regs()
1456 regs->lr = vcpu->arch.regs.link; in kvm_arch_vcpu_ioctl_get_regs()
1457 regs->xer = kvmppc_get_xer(vcpu); in kvm_arch_vcpu_ioctl_get_regs()
1458 regs->msr = vcpu->arch.shared->msr; in kvm_arch_vcpu_ioctl_get_regs()
1459 regs->srr0 = kvmppc_get_srr0(vcpu); in kvm_arch_vcpu_ioctl_get_regs()
1460 regs->srr1 = kvmppc_get_srr1(vcpu); in kvm_arch_vcpu_ioctl_get_regs()
1461 regs->pid = vcpu->arch.pid; in kvm_arch_vcpu_ioctl_get_regs()
1462 regs->sprg0 = kvmppc_get_sprg0(vcpu); in kvm_arch_vcpu_ioctl_get_regs()
1463 regs->sprg1 = kvmppc_get_sprg1(vcpu); in kvm_arch_vcpu_ioctl_get_regs()
1464 regs->sprg2 = kvmppc_get_sprg2(vcpu); in kvm_arch_vcpu_ioctl_get_regs()
1465 regs->sprg3 = kvmppc_get_sprg3(vcpu); in kvm_arch_vcpu_ioctl_get_regs()
1466 regs->sprg4 = kvmppc_get_sprg4(vcpu); in kvm_arch_vcpu_ioctl_get_regs()
1467 regs->sprg5 = kvmppc_get_sprg5(vcpu); in kvm_arch_vcpu_ioctl_get_regs()
1468 regs->sprg6 = kvmppc_get_sprg6(vcpu); in kvm_arch_vcpu_ioctl_get_regs()
1469 regs->sprg7 = kvmppc_get_sprg7(vcpu); in kvm_arch_vcpu_ioctl_get_regs()
1472 regs->gpr[i] = kvmppc_get_gpr(vcpu, i); in kvm_arch_vcpu_ioctl_get_regs()
1474 vcpu_put(vcpu); in kvm_arch_vcpu_ioctl_get_regs()
1478 int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs) in kvm_arch_vcpu_ioctl_set_regs() argument
1482 vcpu_load(vcpu); in kvm_arch_vcpu_ioctl_set_regs()
1484 vcpu->arch.regs.nip = regs->pc; in kvm_arch_vcpu_ioctl_set_regs()
1485 kvmppc_set_cr(vcpu, regs->cr); in kvm_arch_vcpu_ioctl_set_regs()
1486 vcpu->arch.regs.ctr = regs->ctr; in kvm_arch_vcpu_ioctl_set_regs()
1487 vcpu->arch.regs.link = regs->lr; in kvm_arch_vcpu_ioctl_set_regs()
1488 kvmppc_set_xer(vcpu, regs->xer); in kvm_arch_vcpu_ioctl_set_regs()
1489 kvmppc_set_msr(vcpu, regs->msr); in kvm_arch_vcpu_ioctl_set_regs()
1490 kvmppc_set_srr0(vcpu, regs->srr0); in kvm_arch_vcpu_ioctl_set_regs()
1491 kvmppc_set_srr1(vcpu, regs->srr1); in kvm_arch_vcpu_ioctl_set_regs()
1492 kvmppc_set_pid(vcpu, regs->pid); in kvm_arch_vcpu_ioctl_set_regs()
1493 kvmppc_set_sprg0(vcpu, regs->sprg0); in kvm_arch_vcpu_ioctl_set_regs()
1494 kvmppc_set_sprg1(vcpu, regs->sprg1); in kvm_arch_vcpu_ioctl_set_regs()
1495 kvmppc_set_sprg2(vcpu, regs->sprg2); in kvm_arch_vcpu_ioctl_set_regs()
1496 kvmppc_set_sprg3(vcpu, regs->sprg3); in kvm_arch_vcpu_ioctl_set_regs()
1497 kvmppc_set_sprg4(vcpu, regs->sprg4); in kvm_arch_vcpu_ioctl_set_regs()
1498 kvmppc_set_sprg5(vcpu, regs->sprg5); in kvm_arch_vcpu_ioctl_set_regs()
1499 kvmppc_set_sprg6(vcpu, regs->sprg6); in kvm_arch_vcpu_ioctl_set_regs()
1500 kvmppc_set_sprg7(vcpu, regs->sprg7); in kvm_arch_vcpu_ioctl_set_regs()
1503 kvmppc_set_gpr(vcpu, i, regs->gpr[i]); in kvm_arch_vcpu_ioctl_set_regs()
1505 vcpu_put(vcpu); in kvm_arch_vcpu_ioctl_set_regs()
1509 static void get_sregs_base(struct kvm_vcpu *vcpu, in get_sregs_base() argument
1516 sregs->u.e.csrr0 = vcpu->arch.csrr0; in get_sregs_base()
1517 sregs->u.e.csrr1 = vcpu->arch.csrr1; in get_sregs_base()
1518 sregs->u.e.mcsr = vcpu->arch.mcsr; in get_sregs_base()
1519 sregs->u.e.esr = kvmppc_get_esr(vcpu); in get_sregs_base()
1520 sregs->u.e.dear = kvmppc_get_dar(vcpu); in get_sregs_base()
1521 sregs->u.e.tsr = vcpu->arch.tsr; in get_sregs_base()
1522 sregs->u.e.tcr = vcpu->arch.tcr; in get_sregs_base()
1523 sregs->u.e.dec = kvmppc_get_dec(vcpu, tb); in get_sregs_base()
1525 sregs->u.e.vrsave = vcpu->arch.vrsave; in get_sregs_base()
1528 static int set_sregs_base(struct kvm_vcpu *vcpu, in set_sregs_base() argument
1534 vcpu->arch.csrr0 = sregs->u.e.csrr0; in set_sregs_base()
1535 vcpu->arch.csrr1 = sregs->u.e.csrr1; in set_sregs_base()
1536 vcpu->arch.mcsr = sregs->u.e.mcsr; in set_sregs_base()
1537 kvmppc_set_esr(vcpu, sregs->u.e.esr); in set_sregs_base()
1538 kvmppc_set_dar(vcpu, sregs->u.e.dear); in set_sregs_base()
1539 vcpu->arch.vrsave = sregs->u.e.vrsave; in set_sregs_base()
1540 kvmppc_set_tcr(vcpu, sregs->u.e.tcr); in set_sregs_base()
1543 vcpu->arch.dec = sregs->u.e.dec; in set_sregs_base()
1544 kvmppc_emulate_dec(vcpu); in set_sregs_base()
1548 kvmppc_set_tsr(vcpu, sregs->u.e.tsr); in set_sregs_base()
1553 static void get_sregs_arch206(struct kvm_vcpu *vcpu, in get_sregs_arch206() argument
1558 sregs->u.e.pir = vcpu->vcpu_id; in get_sregs_arch206()
1559 sregs->u.e.mcsrr0 = vcpu->arch.mcsrr0; in get_sregs_arch206()
1560 sregs->u.e.mcsrr1 = vcpu->arch.mcsrr1; in get_sregs_arch206()
1561 sregs->u.e.decar = vcpu->arch.decar; in get_sregs_arch206()
1562 sregs->u.e.ivpr = vcpu->arch.ivpr; in get_sregs_arch206()
1565 static int set_sregs_arch206(struct kvm_vcpu *vcpu, in set_sregs_arch206() argument
1571 if (sregs->u.e.pir != vcpu->vcpu_id) in set_sregs_arch206()
1574 vcpu->arch.mcsrr0 = sregs->u.e.mcsrr0; in set_sregs_arch206()
1575 vcpu->arch.mcsrr1 = sregs->u.e.mcsrr1; in set_sregs_arch206()
1576 vcpu->arch.decar = sregs->u.e.decar; in set_sregs_arch206()
1577 vcpu->arch.ivpr = sregs->u.e.ivpr; in set_sregs_arch206()
1582 int kvmppc_get_sregs_ivor(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs) in kvmppc_get_sregs_ivor() argument
1586 sregs->u.e.ivor_low[0] = vcpu->arch.ivor[BOOKE_IRQPRIO_CRITICAL]; in kvmppc_get_sregs_ivor()
1587 sregs->u.e.ivor_low[1] = vcpu->arch.ivor[BOOKE_IRQPRIO_MACHINE_CHECK]; in kvmppc_get_sregs_ivor()
1588 sregs->u.e.ivor_low[2] = vcpu->arch.ivor[BOOKE_IRQPRIO_DATA_STORAGE]; in kvmppc_get_sregs_ivor()
1589 sregs->u.e.ivor_low[3] = vcpu->arch.ivor[BOOKE_IRQPRIO_INST_STORAGE]; in kvmppc_get_sregs_ivor()
1590 sregs->u.e.ivor_low[4] = vcpu->arch.ivor[BOOKE_IRQPRIO_EXTERNAL]; in kvmppc_get_sregs_ivor()
1591 sregs->u.e.ivor_low[5] = vcpu->arch.ivor[BOOKE_IRQPRIO_ALIGNMENT]; in kvmppc_get_sregs_ivor()
1592 sregs->u.e.ivor_low[6] = vcpu->arch.ivor[BOOKE_IRQPRIO_PROGRAM]; in kvmppc_get_sregs_ivor()
1593 sregs->u.e.ivor_low[7] = vcpu->arch.ivor[BOOKE_IRQPRIO_FP_UNAVAIL]; in kvmppc_get_sregs_ivor()
1594 sregs->u.e.ivor_low[8] = vcpu->arch.ivor[BOOKE_IRQPRIO_SYSCALL]; in kvmppc_get_sregs_ivor()
1595 sregs->u.e.ivor_low[9] = vcpu->arch.ivor[BOOKE_IRQPRIO_AP_UNAVAIL]; in kvmppc_get_sregs_ivor()
1596 sregs->u.e.ivor_low[10] = vcpu->arch.ivor[BOOKE_IRQPRIO_DECREMENTER]; in kvmppc_get_sregs_ivor()
1597 sregs->u.e.ivor_low[11] = vcpu->arch.ivor[BOOKE_IRQPRIO_FIT]; in kvmppc_get_sregs_ivor()
1598 sregs->u.e.ivor_low[12] = vcpu->arch.ivor[BOOKE_IRQPRIO_WATCHDOG]; in kvmppc_get_sregs_ivor()
1599 sregs->u.e.ivor_low[13] = vcpu->arch.ivor[BOOKE_IRQPRIO_DTLB_MISS]; in kvmppc_get_sregs_ivor()
1600 sregs->u.e.ivor_low[14] = vcpu->arch.ivor[BOOKE_IRQPRIO_ITLB_MISS]; in kvmppc_get_sregs_ivor()
1601 sregs->u.e.ivor_low[15] = vcpu->arch.ivor[BOOKE_IRQPRIO_DEBUG]; in kvmppc_get_sregs_ivor()
1605 int kvmppc_set_sregs_ivor(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs) in kvmppc_set_sregs_ivor() argument
1610 vcpu->arch.ivor[BOOKE_IRQPRIO_CRITICAL] = sregs->u.e.ivor_low[0]; in kvmppc_set_sregs_ivor()
1611 vcpu->arch.ivor[BOOKE_IRQPRIO_MACHINE_CHECK] = sregs->u.e.ivor_low[1]; in kvmppc_set_sregs_ivor()
1612 vcpu->arch.ivor[BOOKE_IRQPRIO_DATA_STORAGE] = sregs->u.e.ivor_low[2]; in kvmppc_set_sregs_ivor()
1613 vcpu->arch.ivor[BOOKE_IRQPRIO_INST_STORAGE] = sregs->u.e.ivor_low[3]; in kvmppc_set_sregs_ivor()
1614 vcpu->arch.ivor[BOOKE_IRQPRIO_EXTERNAL] = sregs->u.e.ivor_low[4]; in kvmppc_set_sregs_ivor()
1615 vcpu->arch.ivor[BOOKE_IRQPRIO_ALIGNMENT] = sregs->u.e.ivor_low[5]; in kvmppc_set_sregs_ivor()
1616 vcpu->arch.ivor[BOOKE_IRQPRIO_PROGRAM] = sregs->u.e.ivor_low[6]; in kvmppc_set_sregs_ivor()
1617 vcpu->arch.ivor[BOOKE_IRQPRIO_FP_UNAVAIL] = sregs->u.e.ivor_low[7]; in kvmppc_set_sregs_ivor()
1618 vcpu->arch.ivor[BOOKE_IRQPRIO_SYSCALL] = sregs->u.e.ivor_low[8]; in kvmppc_set_sregs_ivor()
1619 vcpu->arch.ivor[BOOKE_IRQPRIO_AP_UNAVAIL] = sregs->u.e.ivor_low[9]; in kvmppc_set_sregs_ivor()
1620 vcpu->arch.ivor[BOOKE_IRQPRIO_DECREMENTER] = sregs->u.e.ivor_low[10]; in kvmppc_set_sregs_ivor()
1621 vcpu->arch.ivor[BOOKE_IRQPRIO_FIT] = sregs->u.e.ivor_low[11]; in kvmppc_set_sregs_ivor()
1622 vcpu->arch.ivor[BOOKE_IRQPRIO_WATCHDOG] = sregs->u.e.ivor_low[12]; in kvmppc_set_sregs_ivor()
1623 vcpu->arch.ivor[BOOKE_IRQPRIO_DTLB_MISS] = sregs->u.e.ivor_low[13]; in kvmppc_set_sregs_ivor()
1624 vcpu->arch.ivor[BOOKE_IRQPRIO_ITLB_MISS] = sregs->u.e.ivor_low[14]; in kvmppc_set_sregs_ivor()
1625 vcpu->arch.ivor[BOOKE_IRQPRIO_DEBUG] = sregs->u.e.ivor_low[15]; in kvmppc_set_sregs_ivor()
1630 int kvm_arch_vcpu_ioctl_get_sregs(struct kvm_vcpu *vcpu, in kvm_arch_vcpu_ioctl_get_sregs() argument
1635 vcpu_load(vcpu); in kvm_arch_vcpu_ioctl_get_sregs()
1637 sregs->pvr = vcpu->arch.pvr; in kvm_arch_vcpu_ioctl_get_sregs()
1639 get_sregs_base(vcpu, sregs); in kvm_arch_vcpu_ioctl_get_sregs()
1640 get_sregs_arch206(vcpu, sregs); in kvm_arch_vcpu_ioctl_get_sregs()
1641 ret = vcpu->kvm->arch.kvm_ops->get_sregs(vcpu, sregs); in kvm_arch_vcpu_ioctl_get_sregs()
1643 vcpu_put(vcpu); in kvm_arch_vcpu_ioctl_get_sregs()
1647 int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu, in kvm_arch_vcpu_ioctl_set_sregs() argument
1652 vcpu_load(vcpu); in kvm_arch_vcpu_ioctl_set_sregs()
1653 if (vcpu->arch.pvr != sregs->pvr) in kvm_arch_vcpu_ioctl_set_sregs()
1656 ret = set_sregs_base(vcpu, sregs); in kvm_arch_vcpu_ioctl_set_sregs()
1660 ret = set_sregs_arch206(vcpu, sregs); in kvm_arch_vcpu_ioctl_set_sregs()
1664 ret = vcpu->kvm->arch.kvm_ops->set_sregs(vcpu, sregs); in kvm_arch_vcpu_ioctl_set_sregs()
1667 vcpu_put(vcpu); in kvm_arch_vcpu_ioctl_set_sregs()
1671 int kvmppc_get_one_reg(struct kvm_vcpu *vcpu, u64 id, in kvmppc_get_one_reg() argument
1678 *val = get_reg_val(id, vcpu->arch.dbg_reg.iac1); in kvmppc_get_one_reg()
1681 *val = get_reg_val(id, vcpu->arch.dbg_reg.iac2); in kvmppc_get_one_reg()
1685 *val = get_reg_val(id, vcpu->arch.dbg_reg.iac3); in kvmppc_get_one_reg()
1688 *val = get_reg_val(id, vcpu->arch.dbg_reg.iac4); in kvmppc_get_one_reg()
1692 *val = get_reg_val(id, vcpu->arch.dbg_reg.dac1); in kvmppc_get_one_reg()
1695 *val = get_reg_val(id, vcpu->arch.dbg_reg.dac2); in kvmppc_get_one_reg()
1698 u32 epr = kvmppc_get_epr(vcpu); in kvmppc_get_one_reg()
1704 *val = get_reg_val(id, vcpu->arch.epcr); in kvmppc_get_one_reg()
1708 *val = get_reg_val(id, vcpu->arch.tcr); in kvmppc_get_one_reg()
1711 *val = get_reg_val(id, vcpu->arch.tsr); in kvmppc_get_one_reg()
1717 *val = get_reg_val(id, vcpu->arch.vrsave); in kvmppc_get_one_reg()
1720 r = vcpu->kvm->arch.kvm_ops->get_one_reg(vcpu, id, val); in kvmppc_get_one_reg()
1727 int kvmppc_set_one_reg(struct kvm_vcpu *vcpu, u64 id, in kvmppc_set_one_reg() argument
1734 vcpu->arch.dbg_reg.iac1 = set_reg_val(id, *val); in kvmppc_set_one_reg()
1737 vcpu->arch.dbg_reg.iac2 = set_reg_val(id, *val); in kvmppc_set_one_reg()
1741 vcpu->arch.dbg_reg.iac3 = set_reg_val(id, *val); in kvmppc_set_one_reg()
1744 vcpu->arch.dbg_reg.iac4 = set_reg_val(id, *val); in kvmppc_set_one_reg()
1748 vcpu->arch.dbg_reg.dac1 = set_reg_val(id, *val); in kvmppc_set_one_reg()
1751 vcpu->arch.dbg_reg.dac2 = set_reg_val(id, *val); in kvmppc_set_one_reg()
1755 kvmppc_set_epr(vcpu, new_epr); in kvmppc_set_one_reg()
1761 kvmppc_set_epcr(vcpu, new_epcr); in kvmppc_set_one_reg()
1767 kvmppc_set_tsr_bits(vcpu, tsr_bits); in kvmppc_set_one_reg()
1772 kvmppc_clr_tsr_bits(vcpu, tsr_bits); in kvmppc_set_one_reg()
1777 kvmppc_set_tsr(vcpu, tsr); in kvmppc_set_one_reg()
1782 kvmppc_set_tcr(vcpu, tcr); in kvmppc_set_one_reg()
1786 vcpu->arch.vrsave = set_reg_val(id, *val); in kvmppc_set_one_reg()
1789 r = vcpu->kvm->arch.kvm_ops->set_one_reg(vcpu, id, val); in kvmppc_set_one_reg()
1796 int kvm_arch_vcpu_ioctl_get_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu) in kvm_arch_vcpu_ioctl_get_fpu() argument
1801 int kvm_arch_vcpu_ioctl_set_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu) in kvm_arch_vcpu_ioctl_set_fpu() argument
1806 int kvm_arch_vcpu_ioctl_translate(struct kvm_vcpu *vcpu, in kvm_arch_vcpu_ioctl_translate() argument
1811 vcpu_load(vcpu); in kvm_arch_vcpu_ioctl_translate()
1812 r = kvmppc_core_vcpu_translate(vcpu, tr); in kvm_arch_vcpu_ioctl_translate()
1813 vcpu_put(vcpu); in kvm_arch_vcpu_ioctl_translate()
1850 void kvmppc_set_epcr(struct kvm_vcpu *vcpu, u32 new_epcr) in kvmppc_set_epcr() argument
1853 vcpu->arch.epcr = new_epcr; in kvmppc_set_epcr()
1855 vcpu->arch.shadow_epcr &= ~SPRN_EPCR_GICM; in kvmppc_set_epcr()
1856 if (vcpu->arch.epcr & SPRN_EPCR_ICM) in kvmppc_set_epcr()
1857 vcpu->arch.shadow_epcr |= SPRN_EPCR_GICM; in kvmppc_set_epcr()
1862 void kvmppc_set_tcr(struct kvm_vcpu *vcpu, u32 new_tcr) in kvmppc_set_tcr() argument
1864 vcpu->arch.tcr = new_tcr; in kvmppc_set_tcr()
1865 arm_next_watchdog(vcpu); in kvmppc_set_tcr()
1866 update_timer_ints(vcpu); in kvmppc_set_tcr()
1869 void kvmppc_set_tsr_bits(struct kvm_vcpu *vcpu, u32 tsr_bits) in kvmppc_set_tsr_bits() argument
1871 set_bits(tsr_bits, &vcpu->arch.tsr); in kvmppc_set_tsr_bits()
1873 kvm_make_request(KVM_REQ_PENDING_TIMER, vcpu); in kvmppc_set_tsr_bits()
1874 kvm_vcpu_kick(vcpu); in kvmppc_set_tsr_bits()
1877 void kvmppc_clr_tsr_bits(struct kvm_vcpu *vcpu, u32 tsr_bits) in kvmppc_clr_tsr_bits() argument
1879 clear_bits(tsr_bits, &vcpu->arch.tsr); in kvmppc_clr_tsr_bits()
1886 arm_next_watchdog(vcpu); in kvmppc_clr_tsr_bits()
1888 update_timer_ints(vcpu); in kvmppc_clr_tsr_bits()
1891 void kvmppc_decrementer_func(struct kvm_vcpu *vcpu) in kvmppc_decrementer_func() argument
1893 if (vcpu->arch.tcr & TCR_ARE) { in kvmppc_decrementer_func()
1894 vcpu->arch.dec = vcpu->arch.decar; in kvmppc_decrementer_func()
1895 kvmppc_emulate_dec(vcpu); in kvmppc_decrementer_func()
1898 kvmppc_set_tsr_bits(vcpu, TSR_DIS); in kvmppc_decrementer_func()
1956 static void kvm_guest_protect_msr(struct kvm_vcpu *vcpu, ulong prot_bitmap, in kvm_guest_protect_msr() argument
1964 vcpu->arch.shadow_msrp |= MSRP_UCLEP; in kvm_guest_protect_msr()
1966 vcpu->arch.shadow_msrp |= MSRP_DEP; in kvm_guest_protect_msr()
1968 vcpu->arch.shadow_msrp |= MSRP_PMMP; in kvm_guest_protect_msr()
1971 vcpu->arch.shadow_msrp &= ~MSRP_UCLEP; in kvm_guest_protect_msr()
1973 vcpu->arch.shadow_msrp &= ~MSRP_DEP; in kvm_guest_protect_msr()
1975 vcpu->arch.shadow_msrp &= ~MSRP_PMMP; in kvm_guest_protect_msr()
1980 int kvmppc_xlate(struct kvm_vcpu *vcpu, ulong eaddr, enum xlate_instdata xlid, in kvmppc_xlate() argument
1987 if (!(vcpu->arch.shared->msr & MSR_PR) && in kvmppc_xlate()
1988 (eaddr & PAGE_MASK) == vcpu->arch.magic_page_ea) { in kvmppc_xlate()
1990 pte->raddr = (vcpu->arch.magic_page_pa & PAGE_MASK) | in kvmppc_xlate()
2004 gtlb_index = kvmppc_mmu_itlb_index(vcpu, eaddr); in kvmppc_xlate()
2007 gtlb_index = kvmppc_mmu_dtlb_index(vcpu, eaddr); in kvmppc_xlate()
2017 gpaddr = kvmppc_mmu_xlate(vcpu, gtlb_index, eaddr); in kvmppc_xlate()
2031 int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu, in kvm_arch_vcpu_ioctl_set_guest_debug() argument
2038 vcpu_load(vcpu); in kvm_arch_vcpu_ioctl_set_guest_debug()
2041 vcpu->arch.dbg_reg.dbcr0 = 0; in kvm_arch_vcpu_ioctl_set_guest_debug()
2042 vcpu->guest_debug = 0; in kvm_arch_vcpu_ioctl_set_guest_debug()
2043 kvm_guest_protect_msr(vcpu, MSR_DE, false); in kvm_arch_vcpu_ioctl_set_guest_debug()
2047 kvm_guest_protect_msr(vcpu, MSR_DE, true); in kvm_arch_vcpu_ioctl_set_guest_debug()
2048 vcpu->guest_debug = dbg->control; in kvm_arch_vcpu_ioctl_set_guest_debug()
2049 vcpu->arch.dbg_reg.dbcr0 = 0; in kvm_arch_vcpu_ioctl_set_guest_debug()
2051 if (vcpu->guest_debug & KVM_GUESTDBG_SINGLESTEP) in kvm_arch_vcpu_ioctl_set_guest_debug()
2052 vcpu->arch.dbg_reg.dbcr0 |= DBCR0_IDM | DBCR0_IC; in kvm_arch_vcpu_ioctl_set_guest_debug()
2055 dbg_reg = &(vcpu->arch.dbg_reg); in kvm_arch_vcpu_ioctl_set_guest_debug()
2075 if (!(vcpu->guest_debug & KVM_GUESTDBG_USE_HW_BP)) in kvm_arch_vcpu_ioctl_set_guest_debug()
2105 vcpu_put(vcpu); in kvm_arch_vcpu_ioctl_set_guest_debug()
2109 void kvmppc_booke_vcpu_load(struct kvm_vcpu *vcpu, int cpu) in kvmppc_booke_vcpu_load() argument
2111 vcpu->cpu = smp_processor_id(); in kvmppc_booke_vcpu_load()
2112 current->thread.kvm_vcpu = vcpu; in kvmppc_booke_vcpu_load()
2115 void kvmppc_booke_vcpu_put(struct kvm_vcpu *vcpu) in kvmppc_booke_vcpu_put() argument
2118 vcpu->cpu = -1; in kvmppc_booke_vcpu_put()
2129 int kvmppc_core_vcpu_create(struct kvm_vcpu *vcpu) in kvmppc_core_vcpu_create() argument
2134 r = vcpu->kvm->arch.kvm_ops->vcpu_create(vcpu); in kvmppc_core_vcpu_create()
2139 vcpu->arch.regs.nip = 0; in kvmppc_core_vcpu_create()
2140 vcpu->arch.shared->pir = vcpu->vcpu_id; in kvmppc_core_vcpu_create()
2141 kvmppc_set_gpr(vcpu, 1, (16<<20) - 8); /* -8 for the callee-save LR slot */ in kvmppc_core_vcpu_create()
2142 kvmppc_set_msr(vcpu, 0); in kvmppc_core_vcpu_create()
2145 vcpu->arch.shadow_msr = MSR_USER | MSR_IS | MSR_DS; in kvmppc_core_vcpu_create()
2146 vcpu->arch.shadow_pid = 1; in kvmppc_core_vcpu_create()
2147 vcpu->arch.shared->msr = 0; in kvmppc_core_vcpu_create()
2152 vcpu->arch.ivpr = 0x55550000; in kvmppc_core_vcpu_create()
2154 vcpu->arch.ivor[i] = 0x7700 | i * 4; in kvmppc_core_vcpu_create()
2156 kvmppc_init_timing_stats(vcpu); in kvmppc_core_vcpu_create()
2158 r = kvmppc_core_vcpu_setup(vcpu); in kvmppc_core_vcpu_create()
2160 vcpu->kvm->arch.kvm_ops->vcpu_free(vcpu); in kvmppc_core_vcpu_create()
2161 kvmppc_sanity_check(vcpu); in kvmppc_core_vcpu_create()
2165 void kvmppc_core_vcpu_free(struct kvm_vcpu *vcpu) in kvmppc_core_vcpu_free() argument
2167 vcpu->kvm->arch.kvm_ops->vcpu_free(vcpu); in kvmppc_core_vcpu_free()
2175 void kvmppc_core_vcpu_load(struct kvm_vcpu *vcpu, int cpu) in kvmppc_core_vcpu_load() argument
2177 vcpu->kvm->arch.kvm_ops->vcpu_load(vcpu, cpu); in kvmppc_core_vcpu_load()
2180 void kvmppc_core_vcpu_put(struct kvm_vcpu *vcpu) in kvmppc_core_vcpu_put() argument
2182 vcpu->kvm->arch.kvm_ops->vcpu_put(vcpu); in kvmppc_core_vcpu_put()