···3939 pgd_t *shadow_pgtable; /* our page table for this guest */4040 u64 l1_gr_to_hr; /* L1's addr of part'n-scoped table */4141 u64 process_table; /* process table entry for this guest */4242+ u64 hfscr; /* HFSCR that the L1 requested for this nested guest */4243 long refcnt; /* number of pointers to this struct */4344 struct mutex tlb_lock; /* serialize page faults and tlbies */4445 struct kvm_nested_guest *next;
+2
arch/powerpc/include/asm/kvm_host.h
···811811812812 u32 online;813813814814+ u64 hfscr_permitted; /* A mask of permitted HFSCR facilities */815815+814816 /* For support of nested guests */815817 struct kvm_nested_guest *nested;816818 u32 nested_vcpu_id;
···4444 (to != NULL) ? __pa(to): 0,4545 (from != NULL) ? __pa(from): 0, n);46464747+ if (eaddr & (0xFFFUL << 52))4848+ return ret;4949+4750 quadrant = 1;4851 if (!pid)4952 quadrant = 2;···6865 }6966 isync();70676868+ pagefault_disable();7169 if (is_load)7272- ret = copy_from_user_nofault(to, (const void __user *)from, n);7070+ ret = __copy_from_user_inatomic(to, (const void __user *)from, n);7371 else7474- ret = copy_to_user_nofault((void __user *)to, from, n);7272+ ret = __copy_to_user_inatomic((void __user *)to, from, n);7373+ pagefault_enable();75747675 /* switch the pid first to avoid running host with unallocated pid */7776 if (quadrant == 1 && pid != old_pid)···86818782 return ret;8883}8989-EXPORT_SYMBOL_GPL(__kvmhv_copy_tofrom_guest_radix);90849185static long kvmhv_copy_tofrom_guest_radix(struct kvm_vcpu *vcpu, gva_t eaddr,9286 void *to, void *from, unsigned long n)···121117122118 return ret;123119}124124-EXPORT_SYMBOL_GPL(kvmhv_copy_from_guest_radix);125120126121long kvmhv_copy_to_guest_radix(struct kvm_vcpu *vcpu, gva_t eaddr, void *from,127122 unsigned long n)128123{129124 return kvmhv_copy_tofrom_guest_radix(vcpu, eaddr, NULL, from, n);130125}131131-EXPORT_SYMBOL_GPL(kvmhv_copy_to_guest_radix);132126133127int kvmppc_mmu_walk_radix_tree(struct kvm_vcpu *vcpu, gva_t eaddr,134128 struct kvmppc_pte *gpte, u64 root,
+72-16
arch/powerpc/kvm/book3s_hv.c
···5959#include <asm/kvm_book3s.h>6060#include <asm/mmu_context.h>6161#include <asm/lppaca.h>6262+#include <asm/pmc.h>6263#include <asm/processor.h>6364#include <asm/cputhreads.h>6465#include <asm/page.h>···16801679 r = RESUME_GUEST;16811680 }16821681 break;16821682+16831683+#ifdef CONFIG_PPC_TRANSACTIONAL_MEM16841684+ case BOOK3S_INTERRUPT_HV_SOFTPATCH:16851685+ /*16861686+ * This occurs for various TM-related instructions that16871687+ * we need to emulate on POWER9 DD2.2. We have already16881688+ * handled the cases where the guest was in real-suspend16891689+ * mode and was transitioning to transactional state.16901690+ */16911691+ r = kvmhv_p9_tm_emulation(vcpu);16921692+ if (r != -1)16931693+ break;16941694+ fallthrough; /* go to facility unavailable handler */16951695+#endif16961696+16831697 /*16841698 * This occurs if the guest (kernel or userspace), does something that16851699 * is prohibited by HFSCR.···17121696 r = RESUME_GUEST;17131697 }17141698 break;17151715-17161716-#ifdef CONFIG_PPC_TRANSACTIONAL_MEM17171717- case BOOK3S_INTERRUPT_HV_SOFTPATCH:17181718- /*17191719- * This occurs for various TM-related instructions that17201720- * we need to emulate on POWER9 DD2.2. We have already17211721- * handled the cases where the guest was in real-suspend17221722- * mode and was transitioning to transactional state.17231723- */17241724- r = kvmhv_p9_tm_emulation(vcpu);17251725- break;17261726-#endif1727169917281700 case BOOK3S_INTERRUPT_HV_RM_HARD:17291701 r = RESUME_PASSTHROUGH;···1731172717321728static int kvmppc_handle_nested_exit(struct kvm_vcpu *vcpu)17331729{17301730+ struct kvm_nested_guest *nested = vcpu->arch.nested;17341731 int r;17351732 int srcu_idx;17361733···18161811 * mode and was transitioning to transactional state.18171812 */18181813 r = kvmhv_p9_tm_emulation(vcpu);18191819- break;18141814+ if (r != -1)18151815+ break;18161816+ fallthrough; /* go to facility unavailable handler */18201817#endif18181818+18191819+ case BOOK3S_INTERRUPT_H_FAC_UNAVAIL: {18201820+ u64 cause = vcpu->arch.hfscr >> 56;18211821+18221822+ /*18231823+ * Only pass HFU interrupts to the L1 if the facility is18241824+ * permitted but disabled by the L1's HFSCR, otherwise18251825+ * the interrupt does not make sense to the L1 so turn18261826+ * it into a HEAI.18271827+ */18281828+ if (!(vcpu->arch.hfscr_permitted & (1UL << cause)) ||18291829+ (nested->hfscr & (1UL << cause))) {18301830+ vcpu->arch.trap = BOOK3S_INTERRUPT_H_EMUL_ASSIST;18311831+18321832+ /*18331833+ * If the fetch failed, return to guest and18341834+ * try executing it again.18351835+ */18361836+ r = kvmppc_get_last_inst(vcpu, INST_GENERIC,18371837+ &vcpu->arch.emul_inst);18381838+ if (r != EMULATE_DONE)18391839+ r = RESUME_GUEST;18401840+ else18411841+ r = RESUME_HOST;18421842+ } else {18431843+ r = RESUME_HOST;18441844+ }18451845+18461846+ break;18471847+ }1821184818221849 case BOOK3S_INTERRUPT_HV_RM_HARD:18231850 vcpu->arch.trap = 0;···27212684 spin_lock_init(&vcpu->arch.vpa_update_lock);27222685 spin_lock_init(&vcpu->arch.tbacct_lock);27232686 vcpu->arch.busy_preempt = TB_NIL;26872687+ vcpu->arch.shregs.msr = MSR_ME;27242688 vcpu->arch.intr_msr = MSR_SF | MSR_ME;2725268927262690 /*···27422704 }27432705 if (cpu_has_feature(CPU_FTR_TM_COMP))27442706 vcpu->arch.hfscr |= HFSCR_TM;27072707+27082708+ vcpu->arch.hfscr_permitted = vcpu->arch.hfscr;2745270927462710 kvmppc_mmu_book3s_hv_init(vcpu);27472711···37673727 mtspr(SPRN_EBBHR, vcpu->arch.ebbhr);37683728 mtspr(SPRN_EBBRR, vcpu->arch.ebbrr);37693729 mtspr(SPRN_BESCR, vcpu->arch.bescr);37703770- mtspr(SPRN_WORT, vcpu->arch.wort);37713730 mtspr(SPRN_TIDR, vcpu->arch.tid);37723731 mtspr(SPRN_AMR, vcpu->arch.amr);37733732 mtspr(SPRN_UAMOR, vcpu->arch.uamor);···37933754 vcpu->arch.ebbhr = mfspr(SPRN_EBBHR);37943755 vcpu->arch.ebbrr = mfspr(SPRN_EBBRR);37953756 vcpu->arch.bescr = mfspr(SPRN_BESCR);37963796- vcpu->arch.wort = mfspr(SPRN_WORT);37973757 vcpu->arch.tid = mfspr(SPRN_TIDR);37983758 vcpu->arch.amr = mfspr(SPRN_AMR);37993759 vcpu->arch.uamor = mfspr(SPRN_UAMOR);···38243786 struct p9_host_os_sprs *host_os_sprs)38253787{38263788 mtspr(SPRN_PSPB, 0);38273827- mtspr(SPRN_WORT, 0);38283789 mtspr(SPRN_UAMOR, 0);3829379038303791 mtspr(SPRN_DSCR, host_os_sprs->dscr);···38893852 cpu_has_feature(CPU_FTR_P9_TM_HV_ASSIST))38903853 kvmppc_restore_tm_hv(vcpu, vcpu->arch.shregs.msr, true);3891385438553855+#ifdef CONFIG_PPC_PSERIES38563856+ if (kvmhv_on_pseries()) {38573857+ barrier();38583858+ if (vcpu->arch.vpa.pinned_addr) {38593859+ struct lppaca *lp = vcpu->arch.vpa.pinned_addr;38603860+ get_lppaca()->pmcregs_in_use = lp->pmcregs_in_use;38613861+ } else {38623862+ get_lppaca()->pmcregs_in_use = 1;38633863+ }38643864+ barrier();38653865+ }38663866+#endif38923867 kvmhv_load_guest_pmu(vcpu);3893386838943869 msr_check_and_set(MSR_FP | MSR_VEC | MSR_VSX);···40353986 save_pmu |= nesting_enabled(vcpu->kvm);4036398740373988 kvmhv_save_guest_pmu(vcpu, save_pmu);39893989+#ifdef CONFIG_PPC_PSERIES39903990+ if (kvmhv_on_pseries()) {39913991+ barrier();39923992+ get_lppaca()->pmcregs_in_use = ppc_get_pmu_inuse();39933993+ barrier();39943994+ }39953995+#endif4038399640393997 vc->entry_exit_map = 0x101;40403998 vc->in_guest = 0;
+50-51
arch/powerpc/kvm/book3s_hv_nested.c
···9999 hr->dawrx1 = swab64(hr->dawrx1);100100}101101102102-static void save_hv_return_state(struct kvm_vcpu *vcpu, int trap,102102+static void save_hv_return_state(struct kvm_vcpu *vcpu,103103 struct hv_guest_state *hr)104104{105105 struct kvmppc_vcore *vc = vcpu->arch.vcore;106106107107 hr->dpdes = vc->dpdes;108108- hr->hfscr = vcpu->arch.hfscr;109108 hr->purr = vcpu->arch.purr;110109 hr->spurr = vcpu->arch.spurr;111110 hr->ic = vcpu->arch.ic;···118119 hr->pidr = vcpu->arch.pid;119120 hr->cfar = vcpu->arch.cfar;120121 hr->ppr = vcpu->arch.ppr;121121- switch (trap) {122122+ switch (vcpu->arch.trap) {122123 case BOOK3S_INTERRUPT_H_DATA_STORAGE:123124 hr->hdar = vcpu->arch.fault_dar;124125 hr->hdsisr = vcpu->arch.fault_dsisr;···127128 case BOOK3S_INTERRUPT_H_INST_STORAGE:128129 hr->asdr = vcpu->arch.fault_gpa;129130 break;131131+ case BOOK3S_INTERRUPT_H_FAC_UNAVAIL:132132+ hr->hfscr = ((~HFSCR_INTR_CAUSE & hr->hfscr) |133133+ (HFSCR_INTR_CAUSE & vcpu->arch.hfscr));134134+ break;130135 case BOOK3S_INTERRUPT_H_EMUL_ASSIST:131136 hr->heir = vcpu->arch.emul_inst;132137 break;133138 }134139}135140136136-/*137137- * This can result in some L0 HV register state being leaked to an L1138138- * hypervisor when the hv_guest_state is copied back to the guest after139139- * being modified here.140140- *141141- * There is no known problem with such a leak, and in many cases these142142- * register settings could be derived by the guest by observing behaviour143143- * and timing, interrupts, etc., but it is an issue to consider.144144- */145145-static void sanitise_hv_regs(struct kvm_vcpu *vcpu, struct hv_guest_state *hr)146146-{147147- struct kvmppc_vcore *vc = vcpu->arch.vcore;148148- u64 mask;149149-150150- /*151151- * Don't let L1 change LPCR bits for the L2 except these:152152- */153153- mask = LPCR_DPFD | LPCR_ILE | LPCR_TC | LPCR_AIL | LPCR_LD |154154- LPCR_LPES | LPCR_MER;155155-156156- /*157157- * Additional filtering is required depending on hardware158158- * and configuration.159159- */160160- hr->lpcr = kvmppc_filter_lpcr_hv(vcpu->kvm,161161- (vc->lpcr & ~mask) | (hr->lpcr & mask));162162-163163- /*164164- * Don't let L1 enable features for L2 which we've disabled for L1,165165- * but preserve the interrupt cause field.166166- */167167- hr->hfscr &= (HFSCR_INTR_CAUSE | vcpu->arch.hfscr);168168-169169- /* Don't let data address watchpoint match in hypervisor state */170170- hr->dawrx0 &= ~DAWRX_HYP;171171- hr->dawrx1 &= ~DAWRX_HYP;172172-173173- /* Don't let completed instruction address breakpt match in HV state */174174- if ((hr->ciabr & CIABR_PRIV) == CIABR_PRIV_HYPER)175175- hr->ciabr &= ~CIABR_PRIV;176176-}177177-178178-static void restore_hv_regs(struct kvm_vcpu *vcpu, struct hv_guest_state *hr)141141+static void restore_hv_regs(struct kvm_vcpu *vcpu, const struct hv_guest_state *hr)179142{180143 struct kvmppc_vcore *vc = vcpu->arch.vcore;181144···249288 sizeof(struct pt_regs));250289}251290291291+static void load_l2_hv_regs(struct kvm_vcpu *vcpu,292292+ const struct hv_guest_state *l2_hv,293293+ const struct hv_guest_state *l1_hv, u64 *lpcr)294294+{295295+ struct kvmppc_vcore *vc = vcpu->arch.vcore;296296+ u64 mask;297297+298298+ restore_hv_regs(vcpu, l2_hv);299299+300300+ /*301301+ * Don't let L1 change LPCR bits for the L2 except these:302302+ */303303+ mask = LPCR_DPFD | LPCR_ILE | LPCR_TC | LPCR_AIL | LPCR_LD |304304+ LPCR_LPES | LPCR_MER;305305+306306+ /*307307+ * Additional filtering is required depending on hardware308308+ * and configuration.309309+ */310310+ *lpcr = kvmppc_filter_lpcr_hv(vcpu->kvm,311311+ (vc->lpcr & ~mask) | (*lpcr & mask));312312+313313+ /*314314+ * Don't let L1 enable features for L2 which we don't allow for L1,315315+ * but preserve the interrupt cause field.316316+ */317317+ vcpu->arch.hfscr = l2_hv->hfscr & (HFSCR_INTR_CAUSE | vcpu->arch.hfscr_permitted);318318+319319+ /* Don't let data address watchpoint match in hypervisor state */320320+ vcpu->arch.dawrx0 = l2_hv->dawrx0 & ~DAWRX_HYP;321321+ vcpu->arch.dawrx1 = l2_hv->dawrx1 & ~DAWRX_HYP;322322+323323+ /* Don't let completed instruction address breakpt match in HV state */324324+ if ((l2_hv->ciabr & CIABR_PRIV) == CIABR_PRIV_HYPER)325325+ vcpu->arch.ciabr = l2_hv->ciabr & ~CIABR_PRIV;326326+}327327+252328long kvmhv_enter_nested_guest(struct kvm_vcpu *vcpu)253329{254330 long int err, r;···294296 struct hv_guest_state l2_hv = {0}, saved_l1_hv;295297 struct kvmppc_vcore *vc = vcpu->arch.vcore;296298 u64 hv_ptr, regs_ptr;297297- u64 hdec_exp;299299+ u64 hdec_exp, lpcr;298300 s64 delta_purr, delta_spurr, delta_ic, delta_vtb;299301300302 if (vcpu->kvm->arch.l1_ptcr == 0)···362364 /* set L1 state to L2 state */363365 vcpu->arch.nested = l2;364366 vcpu->arch.nested_vcpu_id = l2_hv.vcpu_token;367367+ l2->hfscr = l2_hv.hfscr;365368 vcpu->arch.regs = l2_regs;366369367370 /* Guest must always run with ME enabled, HV disabled. */368371 vcpu->arch.shregs.msr = (vcpu->arch.regs.msr | MSR_ME) & ~MSR_HV;369372370370- sanitise_hv_regs(vcpu, &l2_hv);371371- restore_hv_regs(vcpu, &l2_hv);373373+ lpcr = l2_hv.lpcr;374374+ load_l2_hv_regs(vcpu, &l2_hv, &saved_l1_hv, &lpcr);372375373376 vcpu->arch.ret = RESUME_GUEST;374377 vcpu->arch.trap = 0;···379380 r = RESUME_HOST;380381 break;381382 }382382- r = kvmhv_run_single_vcpu(vcpu, hdec_exp, l2_hv.lpcr);383383+ r = kvmhv_run_single_vcpu(vcpu, hdec_exp, lpcr);383384 } while (is_kvmppc_resume_guest(r));384385385386 /* save L2 state for return */···389390 delta_spurr = vcpu->arch.spurr - l2_hv.spurr;390391 delta_ic = vcpu->arch.ic - l2_hv.ic;391392 delta_vtb = vc->vtb - l2_hv.vtb;392392- save_hv_return_state(vcpu, vcpu->arch.trap, &l2_hv);393393+ save_hv_return_state(vcpu, &l2_hv);393394394395 /* restore L1 state */395396 vcpu->arch.nested = NULL;
-42
arch/powerpc/kvm/book3s_hv_rmhandlers.S
···10881088 cmpwi r12, BOOK3S_INTERRUPT_H_INST_STORAGE10891089 beq kvmppc_hisi1090109010911091-#ifdef CONFIG_PPC_TRANSACTIONAL_MEM10921092- /* For softpatch interrupt, go off and do TM instruction emulation */10931093- cmpwi r12, BOOK3S_INTERRUPT_HV_SOFTPATCH10941094- beq kvmppc_tm_emul10951095-#endif10961096-10971091 /* See if this is a leftover HDEC interrupt */10981092 cmpwi r12,BOOK3S_INTERRUPT_HV_DECREMENTER10991093 bne 2f···15921598 mr r4, r915931599 blt deliver_guest_interrupt15941600 b guest_exit_cont15951595-15961596-#ifdef CONFIG_PPC_TRANSACTIONAL_MEM15971597-/*15981598- * Softpatch interrupt for transactional memory emulation cases15991599- * on POWER9 DD2.2. This is early in the guest exit path - we16001600- * haven't saved registers or done a treclaim yet.16011601- */16021602-kvmppc_tm_emul:16031603- /* Save instruction image in HEIR */16041604- mfspr r3, SPRN_HEIR16051605- stw r3, VCPU_HEIR(r9)16061606-16071607- /*16081608- * The cases we want to handle here are those where the guest16091609- * is in real suspend mode and is trying to transition to16101610- * transactional mode.16111611- */16121612- lbz r0, HSTATE_FAKE_SUSPEND(r13)16131613- cmpwi r0, 0 /* keep exiting guest if in fake suspend */16141614- bne guest_exit_cont16151615- rldicl r3, r11, 64 - MSR_TS_S_LG, 6216161616- cmpwi r3, 1 /* or if not in suspend state */16171617- bne guest_exit_cont16181618-16191619- /* Call C code to do the emulation */16201620- mr r3, r916211621- bl kvmhv_p9_tm_emulation_early16221622- nop16231623- ld r9, HSTATE_KVM_VCPU(r13)16241624- li r12, BOOK3S_INTERRUPT_HV_SOFTPATCH16251625- cmpwi r3, 016261626- beq guest_exit_cont /* continue exiting if not handled */16271627- ld r10, VCPU_PC(r9)16281628- ld r11, VCPU_MSR(r9)16291629- b fast_interrupt_c_return /* go back to guest if handled */16301630-#endif /* CONFIG_PPC_TRANSACTIONAL_MEM */1631160116321602/*16331603 * Check whether an HDSI is an HPTE not found fault or something else.
+39-22
arch/powerpc/kvm/book3s_hv_tm.c
···4747 int ra, rs;48484949 /*5050+ * The TM softpatch interrupt sets NIP to the instruction following5151+ * the faulting instruction, which is not executed. Rewind nip to the5252+ * faulting instruction so it looks like a normal synchronous5353+ * interrupt, then update nip in the places where the instruction is5454+ * emulated.5555+ */5656+ vcpu->arch.regs.nip -= 4;5757+5858+ /*5059 * rfid, rfebb, and mtmsrd encode bit 31 = 0 since it's a reserved bit5160 * in these instructions, so masking bit 31 out doesn't change these5261 * instructions. For treclaim., tsr., and trechkpt. instructions if bit···7667 (newmsr & MSR_TM)));7768 newmsr = sanitize_msr(newmsr);7869 vcpu->arch.shregs.msr = newmsr;7979- vcpu->arch.cfar = vcpu->arch.regs.nip - 4;7070+ vcpu->arch.cfar = vcpu->arch.regs.nip;8071 vcpu->arch.regs.nip = vcpu->arch.shregs.srr0;8172 return RESUME_GUEST;8273···8879 }8980 /* check EBB facility is available */9081 if (!(vcpu->arch.hfscr & HFSCR_EBB)) {9191- /* generate an illegal instruction interrupt */9292- kvmppc_core_queue_program(vcpu, SRR1_PROGILL);9393- return RESUME_GUEST;8282+ vcpu->arch.hfscr &= ~HFSCR_INTR_CAUSE;8383+ vcpu->arch.hfscr |= (u64)FSCR_EBB_LG << 56;8484+ vcpu->arch.trap = BOOK3S_INTERRUPT_H_FAC_UNAVAIL;8585+ return -1; /* rerun host interrupt handler */9486 }9587 if ((msr & MSR_PR) && !(vcpu->arch.fscr & FSCR_EBB)) {9688 /* generate a facility unavailable interrupt */9797- vcpu->arch.fscr = (vcpu->arch.fscr & ~(0xffull << 56)) |9898- ((u64)FSCR_EBB_LG << 56);8989+ vcpu->arch.fscr &= ~FSCR_INTR_CAUSE;9090+ vcpu->arch.fscr |= (u64)FSCR_EBB_LG << 56;9991 kvmppc_book3s_queue_irqprio(vcpu, BOOK3S_INTERRUPT_FAC_UNAVAIL);10092 return RESUME_GUEST;10193 }···110100 vcpu->arch.bescr = bescr;111101 msr = (msr & ~MSR_TS_MASK) | MSR_TS_T;112102 vcpu->arch.shregs.msr = msr;113113- vcpu->arch.cfar = vcpu->arch.regs.nip - 4;103103+ vcpu->arch.cfar = vcpu->arch.regs.nip;114104 vcpu->arch.regs.nip = vcpu->arch.ebbrr;115105 return RESUME_GUEST;116106···126116 newmsr = (newmsr & ~MSR_LE) | (msr & MSR_LE);127117 newmsr = sanitize_msr(newmsr);128118 vcpu->arch.shregs.msr = newmsr;119119+ vcpu->arch.regs.nip += 4;129120 return RESUME_GUEST;130121131122 /* ignore bit 31, see comment above */···139128 }140129 /* check for TM disabled in the HFSCR or MSR */141130 if (!(vcpu->arch.hfscr & HFSCR_TM)) {142142- /* generate an illegal instruction interrupt */143143- kvmppc_core_queue_program(vcpu, SRR1_PROGILL);144144- return RESUME_GUEST;131131+ vcpu->arch.hfscr &= ~HFSCR_INTR_CAUSE;132132+ vcpu->arch.hfscr |= (u64)FSCR_TM_LG << 56;133133+ vcpu->arch.trap = BOOK3S_INTERRUPT_H_FAC_UNAVAIL;134134+ return -1; /* rerun host interrupt handler */145135 }146136 if (!(msr & MSR_TM)) {147137 /* generate a facility unavailable interrupt */148148- vcpu->arch.fscr = (vcpu->arch.fscr & ~(0xffull << 56)) |149149- ((u64)FSCR_TM_LG << 56);138138+ vcpu->arch.fscr &= ~FSCR_INTR_CAUSE;139139+ vcpu->arch.fscr |= (u64)FSCR_TM_LG << 56;150140 kvmppc_book3s_queue_irqprio(vcpu,151141 BOOK3S_INTERRUPT_FAC_UNAVAIL);152142 return RESUME_GUEST;···164152 msr = (msr & ~MSR_TS_MASK) | MSR_TS_S;165153 }166154 vcpu->arch.shregs.msr = msr;155155+ vcpu->arch.regs.nip += 4;167156 return RESUME_GUEST;168157169158 /* ignore bit 31, see comment above */170159 case (PPC_INST_TRECLAIM & PO_XOP_OPCODE_MASK):171160 /* check for TM disabled in the HFSCR or MSR */172161 if (!(vcpu->arch.hfscr & HFSCR_TM)) {173173- /* generate an illegal instruction interrupt */174174- kvmppc_core_queue_program(vcpu, SRR1_PROGILL);175175- return RESUME_GUEST;162162+ vcpu->arch.hfscr &= ~HFSCR_INTR_CAUSE;163163+ vcpu->arch.hfscr |= (u64)FSCR_TM_LG << 56;164164+ vcpu->arch.trap = BOOK3S_INTERRUPT_H_FAC_UNAVAIL;165165+ return -1; /* rerun host interrupt handler */176166 }177167 if (!(msr & MSR_TM)) {178168 /* generate a facility unavailable interrupt */179179- vcpu->arch.fscr = (vcpu->arch.fscr & ~(0xffull << 56)) |180180- ((u64)FSCR_TM_LG << 56);169169+ vcpu->arch.fscr &= ~FSCR_INTR_CAUSE;170170+ vcpu->arch.fscr |= (u64)FSCR_TM_LG << 56;181171 kvmppc_book3s_queue_irqprio(vcpu,182172 BOOK3S_INTERRUPT_FAC_UNAVAIL);183173 return RESUME_GUEST;···203189 vcpu->arch.regs.ccr = (vcpu->arch.regs.ccr & 0x0fffffff) |204190 (((msr & MSR_TS_MASK) >> MSR_TS_S_LG) << 29);205191 vcpu->arch.shregs.msr &= ~MSR_TS_MASK;192192+ vcpu->arch.regs.nip += 4;206193 return RESUME_GUEST;207194208195 /* ignore bit 31, see comment above */···211196 /* XXX do we need to check for PR=0 here? */212197 /* check for TM disabled in the HFSCR or MSR */213198 if (!(vcpu->arch.hfscr & HFSCR_TM)) {214214- /* generate an illegal instruction interrupt */215215- kvmppc_core_queue_program(vcpu, SRR1_PROGILL);216216- return RESUME_GUEST;199199+ vcpu->arch.hfscr &= ~HFSCR_INTR_CAUSE;200200+ vcpu->arch.hfscr |= (u64)FSCR_TM_LG << 56;201201+ vcpu->arch.trap = BOOK3S_INTERRUPT_H_FAC_UNAVAIL;202202+ return -1; /* rerun host interrupt handler */217203 }218204 if (!(msr & MSR_TM)) {219205 /* generate a facility unavailable interrupt */220220- vcpu->arch.fscr = (vcpu->arch.fscr & ~(0xffull << 56)) |221221- ((u64)FSCR_TM_LG << 56);206206+ vcpu->arch.fscr &= ~FSCR_INTR_CAUSE;207207+ vcpu->arch.fscr |= (u64)FSCR_TM_LG << 56;222208 kvmppc_book3s_queue_irqprio(vcpu,223209 BOOK3S_INTERRUPT_FAC_UNAVAIL);224210 return RESUME_GUEST;···236220 vcpu->arch.regs.ccr = (vcpu->arch.regs.ccr & 0x0fffffff) |237221 (((msr & MSR_TS_MASK) >> MSR_TS_S_LG) << 29);238222 vcpu->arch.shregs.msr = msr | MSR_TS_S;223223+ vcpu->arch.regs.nip += 4;239224 return RESUME_GUEST;240225 }241226