Lines Matching +full:bat +full:- +full:present
1 // SPDX-License-Identifier: GPL-2.0-only
17 #include <asm/asm-prototypes.h>
64 /* Book3S_32 defines mfsrin(v) - but that messes up our abstract
77 if (vcpu->arch.papr_enabled && (level > PRIV_SUPER)) in spr_allowed()
90 memcpy(&vcpu->arch.gpr_tm[0], &vcpu->arch.regs.gpr[0], in kvmppc_copyto_vcpu_tm()
91 sizeof(vcpu->arch.gpr_tm)); in kvmppc_copyto_vcpu_tm()
92 memcpy(&vcpu->arch.fp_tm, &vcpu->arch.fp, in kvmppc_copyto_vcpu_tm()
94 memcpy(&vcpu->arch.vr_tm, &vcpu->arch.vr, in kvmppc_copyto_vcpu_tm()
96 vcpu->arch.ppr_tm = vcpu->arch.ppr; in kvmppc_copyto_vcpu_tm()
97 vcpu->arch.dscr_tm = vcpu->arch.dscr; in kvmppc_copyto_vcpu_tm()
98 vcpu->arch.amr_tm = vcpu->arch.amr; in kvmppc_copyto_vcpu_tm()
99 vcpu->arch.ctr_tm = vcpu->arch.regs.ctr; in kvmppc_copyto_vcpu_tm()
100 vcpu->arch.tar_tm = vcpu->arch.tar; in kvmppc_copyto_vcpu_tm()
101 vcpu->arch.lr_tm = vcpu->arch.regs.link; in kvmppc_copyto_vcpu_tm()
102 vcpu->arch.cr_tm = vcpu->arch.regs.ccr; in kvmppc_copyto_vcpu_tm()
103 vcpu->arch.xer_tm = vcpu->arch.regs.xer; in kvmppc_copyto_vcpu_tm()
104 vcpu->arch.vrsave_tm = vcpu->arch.vrsave; in kvmppc_copyto_vcpu_tm()
109 memcpy(&vcpu->arch.regs.gpr[0], &vcpu->arch.gpr_tm[0], in kvmppc_copyfrom_vcpu_tm()
110 sizeof(vcpu->arch.regs.gpr)); in kvmppc_copyfrom_vcpu_tm()
111 memcpy(&vcpu->arch.fp, &vcpu->arch.fp_tm, in kvmppc_copyfrom_vcpu_tm()
113 memcpy(&vcpu->arch.vr, &vcpu->arch.vr_tm, in kvmppc_copyfrom_vcpu_tm()
115 vcpu->arch.ppr = vcpu->arch.ppr_tm; in kvmppc_copyfrom_vcpu_tm()
116 vcpu->arch.dscr = vcpu->arch.dscr_tm; in kvmppc_copyfrom_vcpu_tm()
117 vcpu->arch.amr = vcpu->arch.amr_tm; in kvmppc_copyfrom_vcpu_tm()
118 vcpu->arch.regs.ctr = vcpu->arch.ctr_tm; in kvmppc_copyfrom_vcpu_tm()
119 vcpu->arch.tar = vcpu->arch.tar_tm; in kvmppc_copyfrom_vcpu_tm()
120 vcpu->arch.regs.link = vcpu->arch.lr_tm; in kvmppc_copyfrom_vcpu_tm()
121 vcpu->arch.regs.ccr = vcpu->arch.cr_tm; in kvmppc_copyfrom_vcpu_tm()
122 vcpu->arch.regs.xer = vcpu->arch.xer_tm; in kvmppc_copyfrom_vcpu_tm()
123 vcpu->arch.vrsave = vcpu->arch.vrsave_tm; in kvmppc_copyfrom_vcpu_tm()
133 vcpu->arch.regs.ccr = (vcpu->arch.regs.ccr & ~(CR0_MASK << CR0_SHIFT)) | in kvmppc_emulate_treclaim()
134 (((guest_msr & MSR_TS_MASK) >> (MSR_TS_S_LG - 1)) in kvmppc_emulate_treclaim()
155 vcpu->arch.texasr = texasr; in kvmppc_emulate_treclaim()
156 vcpu->arch.tfiar = kvmppc_get_pc(vcpu); in kvmppc_emulate_treclaim()
158 mtspr(SPRN_TFIAR, vcpu->arch.tfiar); in kvmppc_emulate_treclaim()
162 * treclaim need quit to non-transactional state. in kvmppc_emulate_treclaim()
168 if (vcpu->arch.shadow_fscr & FSCR_TAR) in kvmppc_emulate_treclaim()
169 mtspr(SPRN_TAR, vcpu->arch.tar); in kvmppc_emulate_treclaim()
201 * present. in kvmppc_emulate_tabort()
212 vcpu->arch.regs.ccr = (vcpu->arch.regs.ccr & ~(CR0_MASK << CR0_SHIFT)) | in kvmppc_emulate_tabort()
213 (((guest_msr & MSR_TS_MASK) >> (MSR_TS_S_LG - 1)) in kvmppc_emulate_tabort()
216 vcpu->arch.texasr = mfspr(SPRN_TEXASR); in kvmppc_emulate_tabort()
218 * and tabort will be treated as nops in non-transactional in kvmppc_emulate_tabort()
223 vcpu->arch.texasr &= ~(TEXASR_PR | TEXASR_HV); in kvmppc_emulate_tabort()
225 vcpu->arch.texasr |= TEXASR_PR; in kvmppc_emulate_tabort()
228 vcpu->arch.texasr |= TEXASR_HV; in kvmppc_emulate_tabort()
230 vcpu->arch.tfiar = kvmppc_get_pc(vcpu); in kvmppc_emulate_tabort()
321 if (vcpu->arch.mmu.mfsrin) { in kvmppc_core_emulate_op_pr()
323 sr = vcpu->arch.mmu.mfsrin(vcpu, srnum); in kvmppc_core_emulate_op_pr()
333 if (vcpu->arch.mmu.mfsrin) { in kvmppc_core_emulate_op_pr()
335 sr = vcpu->arch.mmu.mfsrin(vcpu, srnum); in kvmppc_core_emulate_op_pr()
341 vcpu->arch.mmu.mtsrin(vcpu, in kvmppc_core_emulate_op_pr()
346 vcpu->arch.mmu.mtsrin(vcpu, in kvmppc_core_emulate_op_pr()
355 vcpu->arch.mmu.tlbie(vcpu, addr, large); in kvmppc_core_emulate_op_pr()
366 !vcpu->arch.papr_enabled) { in kvmppc_core_emulate_op_pr()
374 vcpu->run->papr_hcall.nr = cmd; in kvmppc_core_emulate_op_pr()
377 vcpu->run->papr_hcall.args[i] = gpr; in kvmppc_core_emulate_op_pr()
380 vcpu->run->exit_reason = KVM_EXIT_PAPR_HCALL; in kvmppc_core_emulate_op_pr()
381 vcpu->arch.hcall_needed = 1; in kvmppc_core_emulate_op_pr()
389 if (!vcpu->arch.mmu.slbmte) in kvmppc_core_emulate_op_pr()
392 vcpu->arch.mmu.slbmte(vcpu, in kvmppc_core_emulate_op_pr()
397 if (!vcpu->arch.mmu.slbie) in kvmppc_core_emulate_op_pr()
400 vcpu->arch.mmu.slbie(vcpu, in kvmppc_core_emulate_op_pr()
404 if (!vcpu->arch.mmu.slbia) in kvmppc_core_emulate_op_pr()
407 vcpu->arch.mmu.slbia(vcpu); in kvmppc_core_emulate_op_pr()
410 if (!(inst & 1) || !vcpu->arch.mmu.slbfee) { in kvmppc_core_emulate_op_pr()
417 if (!vcpu->arch.mmu.slbfee(vcpu, b, &t)) in kvmppc_core_emulate_op_pr()
421 cr |= (vcpu->arch.regs.xer & 0x80000000) >> in kvmppc_core_emulate_op_pr()
422 (31 - CR0_SHIFT); in kvmppc_core_emulate_op_pr()
427 if (!vcpu->arch.mmu.slbmfee) { in kvmppc_core_emulate_op_pr()
433 t = vcpu->arch.mmu.slbmfee(vcpu, rb_val); in kvmppc_core_emulate_op_pr()
438 if (!vcpu->arch.mmu.slbmfev) { in kvmppc_core_emulate_op_pr()
444 t = vcpu->arch.mmu.slbmfev(vcpu, rb_val); in kvmppc_core_emulate_op_pr()
469 if ((r == -ENOENT) || (r == -EPERM)) { in kvmppc_core_emulate_op_pr()
472 vcpu->arch.fault_dar = vaddr; in kvmppc_core_emulate_op_pr()
475 if (r == -ENOENT) in kvmppc_core_emulate_op_pr()
477 else if (r == -EPERM) in kvmppc_core_emulate_op_pr()
481 vcpu->arch.fault_dsisr = dsisr; in kvmppc_core_emulate_op_pr()
503 vcpu->arch.regs.ccr = (CR0_TBEGIN_FAILURE | in kvmppc_core_emulate_op_pr()
504 (vcpu->arch.regs.ccr & ~(CR0_MASK << CR0_SHIFT))); in kvmppc_core_emulate_op_pr()
506 vcpu->arch.texasr = (TEXASR_FS | TEXASR_EXACT | in kvmppc_core_emulate_op_pr()
511 vcpu->arch.texasr |= TEXASR_ROT; in kvmppc_core_emulate_op_pr()
514 vcpu->arch.texasr |= TEXASR_HV; in kvmppc_core_emulate_op_pr()
516 vcpu->arch.tfhar = kvmppc_get_pc(vcpu) + 4; in kvmppc_core_emulate_op_pr()
517 vcpu->arch.tfiar = kvmppc_get_pc(vcpu); in kvmppc_core_emulate_op_pr()
637 void kvmppc_set_bat(struct kvm_vcpu *vcpu, struct kvmppc_bat *bat, bool upper, in kvmppc_set_bat() argument
641 /* Upper BAT */ in kvmppc_set_bat()
643 bat->bepi_mask = (~bl << 17); in kvmppc_set_bat()
644 bat->bepi = val & 0xfffe0000; in kvmppc_set_bat()
645 bat->vs = (val & 2) ? 1 : 0; in kvmppc_set_bat()
646 bat->vp = (val & 1) ? 1 : 0; in kvmppc_set_bat()
647 bat->raw = (bat->raw & 0xffffffff00000000ULL) | val; in kvmppc_set_bat()
649 /* Lower BAT */ in kvmppc_set_bat()
650 bat->brpn = val & 0xfffe0000; in kvmppc_set_bat()
651 bat->wimg = (val >> 3) & 0xf; in kvmppc_set_bat()
652 bat->pp = val & 3; in kvmppc_set_bat()
653 bat->raw = (bat->raw & 0x00000000ffffffffULL) | ((u64)val << 32); in kvmppc_set_bat()
660 struct kvmppc_bat *bat; in kvmppc_find_bat() local
664 bat = &vcpu_book3s->ibat[(sprn - SPRN_IBAT0U) / 2]; in kvmppc_find_bat()
667 bat = &vcpu_book3s->ibat[4 + ((sprn - SPRN_IBAT4U) / 2)]; in kvmppc_find_bat()
670 bat = &vcpu_book3s->dbat[(sprn - SPRN_DBAT0U) / 2]; in kvmppc_find_bat()
673 bat = &vcpu_book3s->dbat[4 + ((sprn - SPRN_DBAT4U) / 2)]; in kvmppc_find_bat()
679 return bat; in kvmppc_find_bat()
690 to_book3s(vcpu)->sdr1 = spr_val; in kvmppc_core_emulate_mtspr_pr()
699 to_book3s(vcpu)->hior = spr_val; in kvmppc_core_emulate_mtspr_pr()
706 struct kvmppc_bat *bat = kvmppc_find_bat(vcpu, sprn); in kvmppc_core_emulate_mtspr_pr() local
708 kvmppc_set_bat(vcpu, bat, !(sprn % 2), (u32)spr_val); in kvmppc_core_emulate_mtspr_pr()
709 /* BAT writes happen so rarely that we're ok to flush in kvmppc_core_emulate_mtspr_pr()
716 to_book3s(vcpu)->hid[0] = spr_val; in kvmppc_core_emulate_mtspr_pr()
719 to_book3s(vcpu)->hid[1] = spr_val; in kvmppc_core_emulate_mtspr_pr()
722 to_book3s(vcpu)->hid[2] = spr_val; in kvmppc_core_emulate_mtspr_pr()
725 to_book3s(vcpu)->hid[2] = spr_val; in kvmppc_core_emulate_mtspr_pr()
727 switch (vcpu->arch.pvr) { in kvmppc_core_emulate_mtspr_pr()
735 case 0x00083214: /* gekko 2.4e (8SE) - retail HW2 */ in kvmppc_core_emulate_mtspr_pr()
737 if (vcpu->arch.hflags & BOOK3S_HFLAG_NATIVE_PS) { in kvmppc_core_emulate_mtspr_pr()
740 vcpu->arch.hflags |= BOOK3S_HFLAG_PAIRED_SINGLE; in kvmppc_core_emulate_mtspr_pr()
743 vcpu->arch.hflags &= ~BOOK3S_HFLAG_PAIRED_SINGLE; in kvmppc_core_emulate_mtspr_pr()
750 to_book3s(vcpu)->hid[4] = spr_val; in kvmppc_core_emulate_mtspr_pr()
753 to_book3s(vcpu)->hid[5] = spr_val; in kvmppc_core_emulate_mtspr_pr()
755 if (vcpu->arch.mmu.is_dcbz32(vcpu) && in kvmppc_core_emulate_mtspr_pr()
757 vcpu->arch.hflags |= BOOK3S_HFLAG_DCBZ32; in kvmppc_core_emulate_mtspr_pr()
767 to_book3s(vcpu)->gqr[sprn - SPRN_GQR0] = spr_val; in kvmppc_core_emulate_mtspr_pr()
774 vcpu->arch.bescr = spr_val; in kvmppc_core_emulate_mtspr_pr()
777 vcpu->arch.ebbhr = spr_val; in kvmppc_core_emulate_mtspr_pr()
780 vcpu->arch.ebbrr = spr_val; in kvmppc_core_emulate_mtspr_pr()
799 * other than non-transactional state, with in kvmppc_core_emulate_mtspr_pr()
875 struct kvmppc_bat *bat = kvmppc_find_bat(vcpu, sprn); in kvmppc_core_emulate_mfspr_pr() local
878 *spr_val = bat->raw >> 32; in kvmppc_core_emulate_mfspr_pr()
880 *spr_val = bat->raw; in kvmppc_core_emulate_mfspr_pr()
887 *spr_val = to_book3s(vcpu)->sdr1; in kvmppc_core_emulate_mfspr_pr()
896 *spr_val = to_book3s(vcpu)->hior; in kvmppc_core_emulate_mfspr_pr()
899 *spr_val = to_book3s(vcpu)->hid[0]; in kvmppc_core_emulate_mfspr_pr()
902 *spr_val = to_book3s(vcpu)->hid[1]; in kvmppc_core_emulate_mfspr_pr()
906 *spr_val = to_book3s(vcpu)->hid[2]; in kvmppc_core_emulate_mfspr_pr()
910 *spr_val = to_book3s(vcpu)->hid[4]; in kvmppc_core_emulate_mfspr_pr()
913 *spr_val = to_book3s(vcpu)->hid[5]; in kvmppc_core_emulate_mfspr_pr()
923 *spr_val = vcpu->arch.purr; in kvmppc_core_emulate_mfspr_pr()
929 *spr_val = vcpu->arch.spurr; in kvmppc_core_emulate_mfspr_pr()
932 *spr_val = to_book3s(vcpu)->vtb; in kvmppc_core_emulate_mfspr_pr()
935 *spr_val = vcpu->arch.ic; in kvmppc_core_emulate_mfspr_pr()
945 *spr_val = to_book3s(vcpu)->gqr[sprn - SPRN_GQR0]; in kvmppc_core_emulate_mfspr_pr()
949 *spr_val = vcpu->arch.fscr; in kvmppc_core_emulate_mfspr_pr()
952 *spr_val = vcpu->arch.bescr; in kvmppc_core_emulate_mfspr_pr()
955 *spr_val = vcpu->arch.ebbhr; in kvmppc_core_emulate_mfspr_pr()
958 *spr_val = vcpu->arch.ebbrr; in kvmppc_core_emulate_mfspr_pr()
1043 return vcpu->arch.fault_dar; in kvmppc_alignment_dar()