Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'topic/ppc-kvm' into next

Merge some KVM patches we are keeping in a topic branch in case there
are any merge conflicts that need resolving.

+180 -139
+1
arch/powerpc/include/asm/kvm_book3s_64.h
··· 39 39 pgd_t *shadow_pgtable; /* our page table for this guest */ 40 40 u64 l1_gr_to_hr; /* L1's addr of part'n-scoped table */ 41 41 u64 process_table; /* process table entry for this guest */ 42 + u64 hfscr; /* HFSCR that the L1 requested for this nested guest */ 42 43 long refcnt; /* number of pointers to this struct */ 43 44 struct mutex tlb_lock; /* serialize page faults and tlbies */ 44 45 struct kvm_nested_guest *next;
+2
arch/powerpc/include/asm/kvm_host.h
··· 811 811 812 812 u32 online; 813 813 814 + u64 hfscr_permitted; /* A mask of permitted HFSCR facilities */ 815 + 814 816 /* For support of nested guests */ 815 817 struct kvm_nested_guest *nested; 816 818 u32 nested_vcpu_id;
+7
arch/powerpc/include/asm/pmc.h
··· 34 34 #endif 35 35 } 36 36 37 + #ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE 38 + static inline int ppc_get_pmu_inuse(void) 39 + { 40 + return get_paca()->pmcregs_in_use; 41 + } 42 + #endif 43 + 37 44 extern void power4_enable_pmcs(void); 38 45 39 46 #else /* CONFIG_PPC64 */
+2 -1
arch/powerpc/include/asm/reg.h
··· 415 415 #define FSCR_TAR __MASK(FSCR_TAR_LG) 416 416 #define FSCR_EBB __MASK(FSCR_EBB_LG) 417 417 #define FSCR_DSCR __MASK(FSCR_DSCR_LG) 418 + #define FSCR_INTR_CAUSE (ASM_CONST(0xFF) << 56) /* interrupt cause */ 418 419 #define SPRN_HFSCR 0xbe /* HV=1 Facility Status & Control Register */ 419 420 #define HFSCR_PREFIX __MASK(FSCR_PREFIX_LG) 420 421 #define HFSCR_MSGP __MASK(FSCR_MSGP_LG) ··· 427 426 #define HFSCR_DSCR __MASK(FSCR_DSCR_LG) 428 427 #define HFSCR_VECVSX __MASK(FSCR_VECVSX_LG) 429 428 #define HFSCR_FP __MASK(FSCR_FP_LG) 430 - #define HFSCR_INTR_CAUSE (ASM_CONST(0xFF) << 56) /* interrupt cause */ 429 + #define HFSCR_INTR_CAUSE FSCR_INTR_CAUSE 431 430 #define SPRN_TAR 0x32f /* Target Address Register */ 432 431 #define SPRN_LPCR 0x13E /* LPAR Control Register */ 433 432 #define LPCR_VPM0 ASM_CONST(0x8000000000000000)
+7 -5
arch/powerpc/kvm/book3s_64_mmu_radix.c
··· 44 44 (to != NULL) ? __pa(to): 0, 45 45 (from != NULL) ? __pa(from): 0, n); 46 46 47 + if (eaddr & (0xFFFUL << 52)) 48 + return ret; 49 + 47 50 quadrant = 1; 48 51 if (!pid) 49 52 quadrant = 2; ··· 68 65 } 69 66 isync(); 70 67 68 + pagefault_disable(); 71 69 if (is_load) 72 - ret = copy_from_user_nofault(to, (const void __user *)from, n); 70 + ret = __copy_from_user_inatomic(to, (const void __user *)from, n); 73 71 else 74 - ret = copy_to_user_nofault((void __user *)to, from, n); 72 + ret = __copy_to_user_inatomic((void __user *)to, from, n); 73 + pagefault_enable(); 75 74 76 75 /* switch the pid first to avoid running host with unallocated pid */ 77 76 if (quadrant == 1 && pid != old_pid) ··· 86 81 87 82 return ret; 88 83 } 89 - EXPORT_SYMBOL_GPL(__kvmhv_copy_tofrom_guest_radix); 90 84 91 85 static long kvmhv_copy_tofrom_guest_radix(struct kvm_vcpu *vcpu, gva_t eaddr, 92 86 void *to, void *from, unsigned long n) ··· 121 117 122 118 return ret; 123 119 } 124 - EXPORT_SYMBOL_GPL(kvmhv_copy_from_guest_radix); 125 120 126 121 long kvmhv_copy_to_guest_radix(struct kvm_vcpu *vcpu, gva_t eaddr, void *from, 127 122 unsigned long n) 128 123 { 129 124 return kvmhv_copy_tofrom_guest_radix(vcpu, eaddr, NULL, from, n); 130 125 } 131 - EXPORT_SYMBOL_GPL(kvmhv_copy_to_guest_radix); 132 126 133 127 int kvmppc_mmu_walk_radix_tree(struct kvm_vcpu *vcpu, gva_t eaddr, 134 128 struct kvmppc_pte *gpte, u64 root,
+72 -16
arch/powerpc/kvm/book3s_hv.c
··· 59 59 #include <asm/kvm_book3s.h> 60 60 #include <asm/mmu_context.h> 61 61 #include <asm/lppaca.h> 62 + #include <asm/pmc.h> 62 63 #include <asm/processor.h> 63 64 #include <asm/cputhreads.h> 64 65 #include <asm/page.h> ··· 1680 1679 r = RESUME_GUEST; 1681 1680 } 1682 1681 break; 1682 + 1683 + #ifdef CONFIG_PPC_TRANSACTIONAL_MEM 1684 + case BOOK3S_INTERRUPT_HV_SOFTPATCH: 1685 + /* 1686 + * This occurs for various TM-related instructions that 1687 + * we need to emulate on POWER9 DD2.2. We have already 1688 + * handled the cases where the guest was in real-suspend 1689 + * mode and was transitioning to transactional state. 1690 + */ 1691 + r = kvmhv_p9_tm_emulation(vcpu); 1692 + if (r != -1) 1693 + break; 1694 + fallthrough; /* go to facility unavailable handler */ 1695 + #endif 1696 + 1683 1697 /* 1684 1698 * This occurs if the guest (kernel or userspace), does something that 1685 1699 * is prohibited by HFSCR. ··· 1712 1696 r = RESUME_GUEST; 1713 1697 } 1714 1698 break; 1715 - 1716 - #ifdef CONFIG_PPC_TRANSACTIONAL_MEM 1717 - case BOOK3S_INTERRUPT_HV_SOFTPATCH: 1718 - /* 1719 - * This occurs for various TM-related instructions that 1720 - * we need to emulate on POWER9 DD2.2. We have already 1721 - * handled the cases where the guest was in real-suspend 1722 - * mode and was transitioning to transactional state. 1723 - */ 1724 - r = kvmhv_p9_tm_emulation(vcpu); 1725 - break; 1726 - #endif 1727 1699 1728 1700 case BOOK3S_INTERRUPT_HV_RM_HARD: 1729 1701 r = RESUME_PASSTHROUGH; ··· 1731 1727 1732 1728 static int kvmppc_handle_nested_exit(struct kvm_vcpu *vcpu) 1733 1729 { 1730 + struct kvm_nested_guest *nested = vcpu->arch.nested; 1734 1731 int r; 1735 1732 int srcu_idx; 1736 1733 ··· 1816 1811 * mode and was transitioning to transactional state. 1817 1812 */ 1818 1813 r = kvmhv_p9_tm_emulation(vcpu); 1819 - break; 1814 + if (r != -1) 1815 + break; 1816 + fallthrough; /* go to facility unavailable handler */ 1820 1817 #endif 1818 + 1819 + case BOOK3S_INTERRUPT_H_FAC_UNAVAIL: { 1820 + u64 cause = vcpu->arch.hfscr >> 56; 1821 + 1822 + /* 1823 + * Only pass HFU interrupts to the L1 if the facility is 1824 + * permitted but disabled by the L1's HFSCR, otherwise 1825 + * the interrupt does not make sense to the L1 so turn 1826 + * it into a HEAI. 1827 + */ 1828 + if (!(vcpu->arch.hfscr_permitted & (1UL << cause)) || 1829 + (nested->hfscr & (1UL << cause))) { 1830 + vcpu->arch.trap = BOOK3S_INTERRUPT_H_EMUL_ASSIST; 1831 + 1832 + /* 1833 + * If the fetch failed, return to guest and 1834 + * try executing it again. 1835 + */ 1836 + r = kvmppc_get_last_inst(vcpu, INST_GENERIC, 1837 + &vcpu->arch.emul_inst); 1838 + if (r != EMULATE_DONE) 1839 + r = RESUME_GUEST; 1840 + else 1841 + r = RESUME_HOST; 1842 + } else { 1843 + r = RESUME_HOST; 1844 + } 1845 + 1846 + break; 1847 + } 1821 1848 1822 1849 case BOOK3S_INTERRUPT_HV_RM_HARD: 1823 1850 vcpu->arch.trap = 0; ··· 2721 2684 spin_lock_init(&vcpu->arch.vpa_update_lock); 2722 2685 spin_lock_init(&vcpu->arch.tbacct_lock); 2723 2686 vcpu->arch.busy_preempt = TB_NIL; 2687 + vcpu->arch.shregs.msr = MSR_ME; 2724 2688 vcpu->arch.intr_msr = MSR_SF | MSR_ME; 2725 2689 2726 2690 /* ··· 2742 2704 } 2743 2705 if (cpu_has_feature(CPU_FTR_TM_COMP)) 2744 2706 vcpu->arch.hfscr |= HFSCR_TM; 2707 + 2708 + vcpu->arch.hfscr_permitted = vcpu->arch.hfscr; 2745 2709 2746 2710 kvmppc_mmu_book3s_hv_init(vcpu); 2747 2711 ··· 3767 3727 mtspr(SPRN_EBBHR, vcpu->arch.ebbhr); 3768 3728 mtspr(SPRN_EBBRR, vcpu->arch.ebbrr); 3769 3729 mtspr(SPRN_BESCR, vcpu->arch.bescr); 3770 - mtspr(SPRN_WORT, vcpu->arch.wort); 3771 3730 mtspr(SPRN_TIDR, vcpu->arch.tid); 3772 3731 mtspr(SPRN_AMR, vcpu->arch.amr); 3773 3732 mtspr(SPRN_UAMOR, vcpu->arch.uamor); ··· 3793 3754 vcpu->arch.ebbhr = mfspr(SPRN_EBBHR); 3794 3755 vcpu->arch.ebbrr = mfspr(SPRN_EBBRR); 3795 3756 vcpu->arch.bescr = mfspr(SPRN_BESCR); 3796 - vcpu->arch.wort = mfspr(SPRN_WORT); 3797 3757 vcpu->arch.tid = mfspr(SPRN_TIDR); 3798 3758 vcpu->arch.amr = mfspr(SPRN_AMR); 3799 3759 vcpu->arch.uamor = mfspr(SPRN_UAMOR); ··· 3824 3786 struct p9_host_os_sprs *host_os_sprs) 3825 3787 { 3826 3788 mtspr(SPRN_PSPB, 0); 3827 - mtspr(SPRN_WORT, 0); 3828 3789 mtspr(SPRN_UAMOR, 0); 3829 3790 3830 3791 mtspr(SPRN_DSCR, host_os_sprs->dscr); ··· 3889 3852 cpu_has_feature(CPU_FTR_P9_TM_HV_ASSIST)) 3890 3853 kvmppc_restore_tm_hv(vcpu, vcpu->arch.shregs.msr, true); 3891 3854 3855 + #ifdef CONFIG_PPC_PSERIES 3856 + if (kvmhv_on_pseries()) { 3857 + barrier(); 3858 + if (vcpu->arch.vpa.pinned_addr) { 3859 + struct lppaca *lp = vcpu->arch.vpa.pinned_addr; 3860 + get_lppaca()->pmcregs_in_use = lp->pmcregs_in_use; 3861 + } else { 3862 + get_lppaca()->pmcregs_in_use = 1; 3863 + } 3864 + barrier(); 3865 + } 3866 + #endif 3892 3867 kvmhv_load_guest_pmu(vcpu); 3893 3868 3894 3869 msr_check_and_set(MSR_FP | MSR_VEC | MSR_VSX); ··· 4035 3986 save_pmu |= nesting_enabled(vcpu->kvm); 4036 3987 4037 3988 kvmhv_save_guest_pmu(vcpu, save_pmu); 3989 + #ifdef CONFIG_PPC_PSERIES 3990 + if (kvmhv_on_pseries()) { 3991 + barrier(); 3992 + get_lppaca()->pmcregs_in_use = ppc_get_pmu_inuse(); 3993 + barrier(); 3994 + } 3995 + #endif 4038 3996 4039 3997 vc->entry_exit_map = 0x101; 4040 3998 vc->in_guest = 0;
+50 -51
arch/powerpc/kvm/book3s_hv_nested.c
··· 99 99 hr->dawrx1 = swab64(hr->dawrx1); 100 100 } 101 101 102 - static void save_hv_return_state(struct kvm_vcpu *vcpu, int trap, 102 + static void save_hv_return_state(struct kvm_vcpu *vcpu, 103 103 struct hv_guest_state *hr) 104 104 { 105 105 struct kvmppc_vcore *vc = vcpu->arch.vcore; 106 106 107 107 hr->dpdes = vc->dpdes; 108 - hr->hfscr = vcpu->arch.hfscr; 109 108 hr->purr = vcpu->arch.purr; 110 109 hr->spurr = vcpu->arch.spurr; 111 110 hr->ic = vcpu->arch.ic; ··· 118 119 hr->pidr = vcpu->arch.pid; 119 120 hr->cfar = vcpu->arch.cfar; 120 121 hr->ppr = vcpu->arch.ppr; 121 - switch (trap) { 122 + switch (vcpu->arch.trap) { 122 123 case BOOK3S_INTERRUPT_H_DATA_STORAGE: 123 124 hr->hdar = vcpu->arch.fault_dar; 124 125 hr->hdsisr = vcpu->arch.fault_dsisr; ··· 127 128 case BOOK3S_INTERRUPT_H_INST_STORAGE: 128 129 hr->asdr = vcpu->arch.fault_gpa; 129 130 break; 131 + case BOOK3S_INTERRUPT_H_FAC_UNAVAIL: 132 + hr->hfscr = ((~HFSCR_INTR_CAUSE & hr->hfscr) | 133 + (HFSCR_INTR_CAUSE & vcpu->arch.hfscr)); 134 + break; 130 135 case BOOK3S_INTERRUPT_H_EMUL_ASSIST: 131 136 hr->heir = vcpu->arch.emul_inst; 132 137 break; 133 138 } 134 139 } 135 140 136 - /* 137 - * This can result in some L0 HV register state being leaked to an L1 138 - * hypervisor when the hv_guest_state is copied back to the guest after 139 - * being modified here. 140 - * 141 - * There is no known problem with such a leak, and in many cases these 142 - * register settings could be derived by the guest by observing behaviour 143 - * and timing, interrupts, etc., but it is an issue to consider. 144 - */ 145 - static void sanitise_hv_regs(struct kvm_vcpu *vcpu, struct hv_guest_state *hr) 146 - { 147 - struct kvmppc_vcore *vc = vcpu->arch.vcore; 148 - u64 mask; 149 - 150 - /* 151 - * Don't let L1 change LPCR bits for the L2 except these: 152 - */ 153 - mask = LPCR_DPFD | LPCR_ILE | LPCR_TC | LPCR_AIL | LPCR_LD | 154 - LPCR_LPES | LPCR_MER; 155 - 156 - /* 157 - * Additional filtering is required depending on hardware 158 - * and configuration. 159 - */ 160 - hr->lpcr = kvmppc_filter_lpcr_hv(vcpu->kvm, 161 - (vc->lpcr & ~mask) | (hr->lpcr & mask)); 162 - 163 - /* 164 - * Don't let L1 enable features for L2 which we've disabled for L1, 165 - * but preserve the interrupt cause field. 166 - */ 167 - hr->hfscr &= (HFSCR_INTR_CAUSE | vcpu->arch.hfscr); 168 - 169 - /* Don't let data address watchpoint match in hypervisor state */ 170 - hr->dawrx0 &= ~DAWRX_HYP; 171 - hr->dawrx1 &= ~DAWRX_HYP; 172 - 173 - /* Don't let completed instruction address breakpt match in HV state */ 174 - if ((hr->ciabr & CIABR_PRIV) == CIABR_PRIV_HYPER) 175 - hr->ciabr &= ~CIABR_PRIV; 176 - } 177 - 178 - static void restore_hv_regs(struct kvm_vcpu *vcpu, struct hv_guest_state *hr) 141 + static void restore_hv_regs(struct kvm_vcpu *vcpu, const struct hv_guest_state *hr) 179 142 { 180 143 struct kvmppc_vcore *vc = vcpu->arch.vcore; 181 144 ··· 249 288 sizeof(struct pt_regs)); 250 289 } 251 290 291 + static void load_l2_hv_regs(struct kvm_vcpu *vcpu, 292 + const struct hv_guest_state *l2_hv, 293 + const struct hv_guest_state *l1_hv, u64 *lpcr) 294 + { 295 + struct kvmppc_vcore *vc = vcpu->arch.vcore; 296 + u64 mask; 297 + 298 + restore_hv_regs(vcpu, l2_hv); 299 + 300 + /* 301 + * Don't let L1 change LPCR bits for the L2 except these: 302 + */ 303 + mask = LPCR_DPFD | LPCR_ILE | LPCR_TC | LPCR_AIL | LPCR_LD | 304 + LPCR_LPES | LPCR_MER; 305 + 306 + /* 307 + * Additional filtering is required depending on hardware 308 + * and configuration. 309 + */ 310 + *lpcr = kvmppc_filter_lpcr_hv(vcpu->kvm, 311 + (vc->lpcr & ~mask) | (*lpcr & mask)); 312 + 313 + /* 314 + * Don't let L1 enable features for L2 which we don't allow for L1, 315 + * but preserve the interrupt cause field. 316 + */ 317 + vcpu->arch.hfscr = l2_hv->hfscr & (HFSCR_INTR_CAUSE | vcpu->arch.hfscr_permitted); 318 + 319 + /* Don't let data address watchpoint match in hypervisor state */ 320 + vcpu->arch.dawrx0 = l2_hv->dawrx0 & ~DAWRX_HYP; 321 + vcpu->arch.dawrx1 = l2_hv->dawrx1 & ~DAWRX_HYP; 322 + 323 + /* Don't let completed instruction address breakpt match in HV state */ 324 + if ((l2_hv->ciabr & CIABR_PRIV) == CIABR_PRIV_HYPER) 325 + vcpu->arch.ciabr = l2_hv->ciabr & ~CIABR_PRIV; 326 + } 327 + 252 328 long kvmhv_enter_nested_guest(struct kvm_vcpu *vcpu) 253 329 { 254 330 long int err, r; ··· 294 296 struct hv_guest_state l2_hv = {0}, saved_l1_hv; 295 297 struct kvmppc_vcore *vc = vcpu->arch.vcore; 296 298 u64 hv_ptr, regs_ptr; 297 - u64 hdec_exp; 299 + u64 hdec_exp, lpcr; 298 300 s64 delta_purr, delta_spurr, delta_ic, delta_vtb; 299 301 300 302 if (vcpu->kvm->arch.l1_ptcr == 0) ··· 362 364 /* set L1 state to L2 state */ 363 365 vcpu->arch.nested = l2; 364 366 vcpu->arch.nested_vcpu_id = l2_hv.vcpu_token; 367 + l2->hfscr = l2_hv.hfscr; 365 368 vcpu->arch.regs = l2_regs; 366 369 367 370 /* Guest must always run with ME enabled, HV disabled. */ 368 371 vcpu->arch.shregs.msr = (vcpu->arch.regs.msr | MSR_ME) & ~MSR_HV; 369 372 370 - sanitise_hv_regs(vcpu, &l2_hv); 371 - restore_hv_regs(vcpu, &l2_hv); 373 + lpcr = l2_hv.lpcr; 374 + load_l2_hv_regs(vcpu, &l2_hv, &saved_l1_hv, &lpcr); 372 375 373 376 vcpu->arch.ret = RESUME_GUEST; 374 377 vcpu->arch.trap = 0; ··· 379 380 r = RESUME_HOST; 380 381 break; 381 382 } 382 - r = kvmhv_run_single_vcpu(vcpu, hdec_exp, l2_hv.lpcr); 383 + r = kvmhv_run_single_vcpu(vcpu, hdec_exp, lpcr); 383 384 } while (is_kvmppc_resume_guest(r)); 384 385 385 386 /* save L2 state for return */ ··· 389 390 delta_spurr = vcpu->arch.spurr - l2_hv.spurr; 390 391 delta_ic = vcpu->arch.ic - l2_hv.ic; 391 392 delta_vtb = vc->vtb - l2_hv.vtb; 392 - save_hv_return_state(vcpu, vcpu->arch.trap, &l2_hv); 393 + save_hv_return_state(vcpu, &l2_hv); 393 394 394 395 /* restore L1 state */ 395 396 vcpu->arch.nested = NULL;
-42
arch/powerpc/kvm/book3s_hv_rmhandlers.S
··· 1088 1088 cmpwi r12, BOOK3S_INTERRUPT_H_INST_STORAGE 1089 1089 beq kvmppc_hisi 1090 1090 1091 - #ifdef CONFIG_PPC_TRANSACTIONAL_MEM 1092 - /* For softpatch interrupt, go off and do TM instruction emulation */ 1093 - cmpwi r12, BOOK3S_INTERRUPT_HV_SOFTPATCH 1094 - beq kvmppc_tm_emul 1095 - #endif 1096 - 1097 1091 /* See if this is a leftover HDEC interrupt */ 1098 1092 cmpwi r12,BOOK3S_INTERRUPT_HV_DECREMENTER 1099 1093 bne 2f ··· 1592 1598 mr r4, r9 1593 1599 blt deliver_guest_interrupt 1594 1600 b guest_exit_cont 1595 - 1596 - #ifdef CONFIG_PPC_TRANSACTIONAL_MEM 1597 - /* 1598 - * Softpatch interrupt for transactional memory emulation cases 1599 - * on POWER9 DD2.2. This is early in the guest exit path - we 1600 - * haven't saved registers or done a treclaim yet. 1601 - */ 1602 - kvmppc_tm_emul: 1603 - /* Save instruction image in HEIR */ 1604 - mfspr r3, SPRN_HEIR 1605 - stw r3, VCPU_HEIR(r9) 1606 - 1607 - /* 1608 - * The cases we want to handle here are those where the guest 1609 - * is in real suspend mode and is trying to transition to 1610 - * transactional mode. 1611 - */ 1612 - lbz r0, HSTATE_FAKE_SUSPEND(r13) 1613 - cmpwi r0, 0 /* keep exiting guest if in fake suspend */ 1614 - bne guest_exit_cont 1615 - rldicl r3, r11, 64 - MSR_TS_S_LG, 62 1616 - cmpwi r3, 1 /* or if not in suspend state */ 1617 - bne guest_exit_cont 1618 - 1619 - /* Call C code to do the emulation */ 1620 - mr r3, r9 1621 - bl kvmhv_p9_tm_emulation_early 1622 - nop 1623 - ld r9, HSTATE_KVM_VCPU(r13) 1624 - li r12, BOOK3S_INTERRUPT_HV_SOFTPATCH 1625 - cmpwi r3, 0 1626 - beq guest_exit_cont /* continue exiting if not handled */ 1627 - ld r10, VCPU_PC(r9) 1628 - ld r11, VCPU_MSR(r9) 1629 - b fast_interrupt_c_return /* go back to guest if handled */ 1630 - #endif /* CONFIG_PPC_TRANSACTIONAL_MEM */ 1631 1601 1632 1602 /* 1633 1603 * Check whether an HDSI is an HPTE not found fault or something else.
+39 -22
arch/powerpc/kvm/book3s_hv_tm.c
··· 47 47 int ra, rs; 48 48 49 49 /* 50 + * The TM softpatch interrupt sets NIP to the instruction following 51 + * the faulting instruction, which is not executed. Rewind nip to the 52 + * faulting instruction so it looks like a normal synchronous 53 + * interrupt, then update nip in the places where the instruction is 54 + * emulated. 55 + */ 56 + vcpu->arch.regs.nip -= 4; 57 + 58 + /* 50 59 * rfid, rfebb, and mtmsrd encode bit 31 = 0 since it's a reserved bit 51 60 * in these instructions, so masking bit 31 out doesn't change these 52 61 * instructions. For treclaim., tsr., and trechkpt. instructions if bit ··· 76 67 (newmsr & MSR_TM))); 77 68 newmsr = sanitize_msr(newmsr); 78 69 vcpu->arch.shregs.msr = newmsr; 79 - vcpu->arch.cfar = vcpu->arch.regs.nip - 4; 70 + vcpu->arch.cfar = vcpu->arch.regs.nip; 80 71 vcpu->arch.regs.nip = vcpu->arch.shregs.srr0; 81 72 return RESUME_GUEST; 82 73 ··· 88 79 } 89 80 /* check EBB facility is available */ 90 81 if (!(vcpu->arch.hfscr & HFSCR_EBB)) { 91 - /* generate an illegal instruction interrupt */ 92 - kvmppc_core_queue_program(vcpu, SRR1_PROGILL); 93 - return RESUME_GUEST; 82 + vcpu->arch.hfscr &= ~HFSCR_INTR_CAUSE; 83 + vcpu->arch.hfscr |= (u64)FSCR_EBB_LG << 56; 84 + vcpu->arch.trap = BOOK3S_INTERRUPT_H_FAC_UNAVAIL; 85 + return -1; /* rerun host interrupt handler */ 94 86 } 95 87 if ((msr & MSR_PR) && !(vcpu->arch.fscr & FSCR_EBB)) { 96 88 /* generate a facility unavailable interrupt */ 97 - vcpu->arch.fscr = (vcpu->arch.fscr & ~(0xffull << 56)) | 98 - ((u64)FSCR_EBB_LG << 56); 89 + vcpu->arch.fscr &= ~FSCR_INTR_CAUSE; 90 + vcpu->arch.fscr |= (u64)FSCR_EBB_LG << 56; 99 91 kvmppc_book3s_queue_irqprio(vcpu, BOOK3S_INTERRUPT_FAC_UNAVAIL); 100 92 return RESUME_GUEST; 101 93 } ··· 110 100 vcpu->arch.bescr = bescr; 111 101 msr = (msr & ~MSR_TS_MASK) | MSR_TS_T; 112 102 vcpu->arch.shregs.msr = msr; 113 - vcpu->arch.cfar = vcpu->arch.regs.nip - 4; 103 + vcpu->arch.cfar = vcpu->arch.regs.nip; 114 104 vcpu->arch.regs.nip = vcpu->arch.ebbrr; 115 105 return RESUME_GUEST; 116 106 ··· 126 116 newmsr = (newmsr & ~MSR_LE) | (msr & MSR_LE); 127 117 newmsr = sanitize_msr(newmsr); 128 118 vcpu->arch.shregs.msr = newmsr; 119 + vcpu->arch.regs.nip += 4; 129 120 return RESUME_GUEST; 130 121 131 122 /* ignore bit 31, see comment above */ ··· 139 128 } 140 129 /* check for TM disabled in the HFSCR or MSR */ 141 130 if (!(vcpu->arch.hfscr & HFSCR_TM)) { 142 - /* generate an illegal instruction interrupt */ 143 - kvmppc_core_queue_program(vcpu, SRR1_PROGILL); 144 - return RESUME_GUEST; 131 + vcpu->arch.hfscr &= ~HFSCR_INTR_CAUSE; 132 + vcpu->arch.hfscr |= (u64)FSCR_TM_LG << 56; 133 + vcpu->arch.trap = BOOK3S_INTERRUPT_H_FAC_UNAVAIL; 134 + return -1; /* rerun host interrupt handler */ 145 135 } 146 136 if (!(msr & MSR_TM)) { 147 137 /* generate a facility unavailable interrupt */ 148 - vcpu->arch.fscr = (vcpu->arch.fscr & ~(0xffull << 56)) | 149 - ((u64)FSCR_TM_LG << 56); 138 + vcpu->arch.fscr &= ~FSCR_INTR_CAUSE; 139 + vcpu->arch.fscr |= (u64)FSCR_TM_LG << 56; 150 140 kvmppc_book3s_queue_irqprio(vcpu, 151 141 BOOK3S_INTERRUPT_FAC_UNAVAIL); 152 142 return RESUME_GUEST; ··· 164 152 msr = (msr & ~MSR_TS_MASK) | MSR_TS_S; 165 153 } 166 154 vcpu->arch.shregs.msr = msr; 155 + vcpu->arch.regs.nip += 4; 167 156 return RESUME_GUEST; 168 157 169 158 /* ignore bit 31, see comment above */ 170 159 case (PPC_INST_TRECLAIM & PO_XOP_OPCODE_MASK): 171 160 /* check for TM disabled in the HFSCR or MSR */ 172 161 if (!(vcpu->arch.hfscr & HFSCR_TM)) { 173 - /* generate an illegal instruction interrupt */ 174 - kvmppc_core_queue_program(vcpu, SRR1_PROGILL); 175 - return RESUME_GUEST; 162 + vcpu->arch.hfscr &= ~HFSCR_INTR_CAUSE; 163 + vcpu->arch.hfscr |= (u64)FSCR_TM_LG << 56; 164 + vcpu->arch.trap = BOOK3S_INTERRUPT_H_FAC_UNAVAIL; 165 + return -1; /* rerun host interrupt handler */ 176 166 } 177 167 if (!(msr & MSR_TM)) { 178 168 /* generate a facility unavailable interrupt */ 179 - vcpu->arch.fscr = (vcpu->arch.fscr & ~(0xffull << 56)) | 180 - ((u64)FSCR_TM_LG << 56); 169 + vcpu->arch.fscr &= ~FSCR_INTR_CAUSE; 170 + vcpu->arch.fscr |= (u64)FSCR_TM_LG << 56; 181 171 kvmppc_book3s_queue_irqprio(vcpu, 182 172 BOOK3S_INTERRUPT_FAC_UNAVAIL); 183 173 return RESUME_GUEST; ··· 203 189 vcpu->arch.regs.ccr = (vcpu->arch.regs.ccr & 0x0fffffff) | 204 190 (((msr & MSR_TS_MASK) >> MSR_TS_S_LG) << 29); 205 191 vcpu->arch.shregs.msr &= ~MSR_TS_MASK; 192 + vcpu->arch.regs.nip += 4; 206 193 return RESUME_GUEST; 207 194 208 195 /* ignore bit 31, see comment above */ ··· 211 196 /* XXX do we need to check for PR=0 here? */ 212 197 /* check for TM disabled in the HFSCR or MSR */ 213 198 if (!(vcpu->arch.hfscr & HFSCR_TM)) { 214 - /* generate an illegal instruction interrupt */ 215 - kvmppc_core_queue_program(vcpu, SRR1_PROGILL); 216 - return RESUME_GUEST; 199 + vcpu->arch.hfscr &= ~HFSCR_INTR_CAUSE; 200 + vcpu->arch.hfscr |= (u64)FSCR_TM_LG << 56; 201 + vcpu->arch.trap = BOOK3S_INTERRUPT_H_FAC_UNAVAIL; 202 + return -1; /* rerun host interrupt handler */ 217 203 } 218 204 if (!(msr & MSR_TM)) { 219 205 /* generate a facility unavailable interrupt */ 220 - vcpu->arch.fscr = (vcpu->arch.fscr & ~(0xffull << 56)) | 221 - ((u64)FSCR_TM_LG << 56); 206 + vcpu->arch.fscr &= ~FSCR_INTR_CAUSE; 207 + vcpu->arch.fscr |= (u64)FSCR_TM_LG << 56; 222 208 kvmppc_book3s_queue_irqprio(vcpu, 223 209 BOOK3S_INTERRUPT_FAC_UNAVAIL); 224 210 return RESUME_GUEST; ··· 236 220 vcpu->arch.regs.ccr = (vcpu->arch.regs.ccr & 0x0fffffff) | 237 221 (((msr & MSR_TS_MASK) >> MSR_TS_S_LG) << 29); 238 222 vcpu->arch.shregs.msr = msr | MSR_TS_S; 223 + vcpu->arch.regs.nip += 4; 239 224 return RESUME_GUEST; 240 225 } 241 226
-2
arch/powerpc/platforms/powernv/idle.c
··· 667 667 sprs.purr = mfspr(SPRN_PURR); 668 668 sprs.spurr = mfspr(SPRN_SPURR); 669 669 sprs.dscr = mfspr(SPRN_DSCR); 670 - sprs.wort = mfspr(SPRN_WORT); 671 670 sprs.ciabr = mfspr(SPRN_CIABR); 672 671 673 672 sprs.mmcra = mfspr(SPRN_MMCRA); ··· 784 785 mtspr(SPRN_PURR, sprs.purr); 785 786 mtspr(SPRN_SPURR, sprs.spurr); 786 787 mtspr(SPRN_DSCR, sprs.dscr); 787 - mtspr(SPRN_WORT, sprs.wort); 788 788 mtspr(SPRN_CIABR, sprs.ciabr); 789 789 790 790 mtspr(SPRN_MMCRA, sprs.mmcra);