]> git.openfabrics.org - ~emulex/infiniband.git/commitdiff
KVM: PPC: PR: Handle FSCR feature deselects
authorAlexander Graf <agraf@suse.de>
Thu, 31 Jul 2014 08:21:59 +0000 (10:21 +0200)
committerAlexander Graf <agraf@suse.de>
Thu, 31 Jul 2014 08:23:46 +0000 (10:23 +0200)
We handle FSCR feature bits (well, TAR only really today) lazily when the guest
starts using them. So when a guest activates the bit and later uses that feature
we enable it for real in hardware.

However, when the guest stops using that bit we don't stop setting it in
hardware. That means we can potentially lose a trap that the guest expects to
happen because it thinks a feature is not active.

This patch adds support to drop TAR when then guest turns it off in FSCR. While
at it it also restricts FSCR access to 64bit systems - 32bit ones don't have it.

Signed-off-by: Alexander Graf <agraf@suse.de>
arch/powerpc/include/asm/kvm_book3s.h
arch/powerpc/kvm/book3s_emulate.c
arch/powerpc/kvm/book3s_pr.c

index 61667913ec985221223b767f9046330fb5e1ffda..6acf0c2a0f99cf82474fbf0b2798700b6984bfff 100644 (file)
@@ -182,6 +182,7 @@ extern long kvmppc_hv_get_dirty_log(struct kvm *kvm,
                        struct kvm_memory_slot *memslot, unsigned long *map);
 extern void kvmppc_update_lpcr(struct kvm *kvm, unsigned long lpcr,
                        unsigned long mask);
+extern void kvmppc_set_fscr(struct kvm_vcpu *vcpu, u64 fscr);
 
 extern void kvmppc_entry_trampoline(void);
 extern void kvmppc_hv_entry_trampoline(void);
index 84fddcd6c1f8386e91498ab8d308d7030ba281a3..5a2bc4b0dfe5a9b83c4d5be3b820bda90e57a641 100644 (file)
@@ -449,10 +449,10 @@ int kvmppc_core_emulate_mtspr_pr(struct kvm_vcpu *vcpu, int sprn, ulong spr_val)
        case SPRN_GQR7:
                to_book3s(vcpu)->gqr[sprn - SPRN_GQR0] = spr_val;
                break;
+#ifdef CONFIG_PPC_BOOK3S_64
        case SPRN_FSCR:
-               vcpu->arch.fscr = spr_val;
+               kvmppc_set_fscr(vcpu, spr_val);
                break;
-#ifdef CONFIG_PPC_BOOK3S_64
        case SPRN_BESCR:
                vcpu->arch.bescr = spr_val;
                break;
@@ -593,10 +593,10 @@ int kvmppc_core_emulate_mfspr_pr(struct kvm_vcpu *vcpu, int sprn, ulong *spr_val
        case SPRN_GQR7:
                *spr_val = to_book3s(vcpu)->gqr[sprn - SPRN_GQR0];
                break;
+#ifdef CONFIG_PPC_BOOK3S_64
        case SPRN_FSCR:
                *spr_val = vcpu->arch.fscr;
                break;
-#ifdef CONFIG_PPC_BOOK3S_64
        case SPRN_BESCR:
                *spr_val = vcpu->arch.bescr;
                break;
index e7a1fa2517b15b6c2d8c4a9271f950fd9f5c63dc..faffb27badd9de362465c6a8ea12052cb7ab53ef 100644 (file)
@@ -871,6 +871,15 @@ static int kvmppc_handle_fac(struct kvm_vcpu *vcpu, ulong fac)
 
        return RESUME_GUEST;
 }
+
+void kvmppc_set_fscr(struct kvm_vcpu *vcpu, u64 fscr)
+{
+       if ((vcpu->arch.fscr & FSCR_TAR) && !(fscr & FSCR_TAR)) {
+               /* TAR got dropped, drop it in shadow too */
+               kvmppc_giveup_fac(vcpu, FSCR_TAR_LG);
+       }
+       vcpu->arch.fscr = fscr;
+}
 #endif
 
 int kvmppc_handle_exit_pr(struct kvm_run *run, struct kvm_vcpu *vcpu,