We can have critical sections on booke as well as book3s. Move the detection
code whether the guest is in a critical section to generic code.

Signed-off-by: Alexander Graf <ag...@suse.de>
---
 arch/powerpc/include/asm/kvm_ppc.h |  1 +
 arch/powerpc/kvm/book3s.c          | 26 --------------------------
 arch/powerpc/kvm/powerpc.c         | 26 ++++++++++++++++++++++++++
 3 files changed, 27 insertions(+), 26 deletions(-)

diff --git a/arch/powerpc/include/asm/kvm_ppc.h 
b/arch/powerpc/include/asm/kvm_ppc.h
index b141eae..6f7a4e5 100644
--- a/arch/powerpc/include/asm/kvm_ppc.h
+++ b/arch/powerpc/include/asm/kvm_ppc.h
@@ -117,6 +117,7 @@ extern int kvmppc_core_vcpu_translate(struct kvm_vcpu *vcpu,
 extern void kvmppc_core_vcpu_load(struct kvm_vcpu *vcpu, int cpu);
 extern void kvmppc_core_vcpu_put(struct kvm_vcpu *vcpu);
 
+extern bool kvmppc_critical_section(struct kvm_vcpu *vcpu);
 extern int kvmppc_core_prepare_to_enter(struct kvm_vcpu *vcpu);
 extern int kvmppc_core_pending_dec(struct kvm_vcpu *vcpu);
 extern void kvmppc_core_queue_program(struct kvm_vcpu *vcpu, ulong flags);
diff --git a/arch/powerpc/kvm/book3s.c b/arch/powerpc/kvm/book3s.c
index 9f2a5ec..d66d31e06 100644
--- a/arch/powerpc/kvm/book3s.c
+++ b/arch/powerpc/kvm/book3s.c
@@ -90,32 +90,6 @@ static inline void kvmppc_update_int_pending(struct kvm_vcpu 
*vcpu,
                kvmppc_set_int_pending(vcpu, 0);
 }
 
-static inline bool kvmppc_critical_section(struct kvm_vcpu *vcpu)
-{
-       ulong crit_raw;
-       ulong crit_r1;
-       bool crit;
-
-       if (is_kvmppc_hv_enabled(vcpu->kvm))
-               return false;
-
-       crit_raw = kvmppc_get_critical(vcpu);
-       crit_r1 = kvmppc_get_gpr(vcpu, 1);
-
-       /* Truncate crit indicators in 32 bit mode */
-       if (!(kvmppc_get_msr(vcpu) & MSR_SF)) {
-               crit_raw &= 0xffffffff;
-               crit_r1 &= 0xffffffff;
-       }
-
-       /* Critical section when crit == r1 */
-       crit = (crit_raw == crit_r1);
-       /* ... and we're in supervisor mode */
-       crit = crit && !(kvmppc_get_msr(vcpu) & MSR_PR);
-
-       return crit;
-}
-
 void kvmppc_inject_interrupt(struct kvm_vcpu *vcpu, int vec, u64 flags)
 {
        kvmppc_set_srr0(vcpu, kvmppc_get_pc(vcpu));
diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
index 5b1a8d6..2269799 100644
--- a/arch/powerpc/kvm/powerpc.c
+++ b/arch/powerpc/kvm/powerpc.c
@@ -57,6 +57,32 @@ int kvm_arch_vcpu_should_kick(struct kvm_vcpu *vcpu)
        return 1;
 }
 
+bool kvmppc_critical_section(struct kvm_vcpu *vcpu)
+{
+       ulong crit_raw;
+       ulong crit_r1;
+       bool crit;
+
+       if (is_kvmppc_hv_enabled(vcpu->kvm))
+               return false;
+
+       crit_raw = kvmppc_get_critical(vcpu);
+       crit_r1 = kvmppc_get_gpr(vcpu, 1);
+
+       /* Truncate crit indicators in 32 bit mode */
+       if (!(kvmppc_get_msr(vcpu) & MSR_SF)) {
+               crit_raw &= 0xffffffff;
+               crit_r1 &= 0xffffffff;
+       }
+
+       /* Critical section when crit == r1 */
+       crit = (crit_raw == crit_r1);
+       /* ... and we're in supervisor mode */
+       crit = crit && !(kvmppc_get_msr(vcpu) & MSR_PR);
+
+       return crit;
+}
+
 /*
  * Common checks before entering the guest world.  Call with interrupts
  * disabled.
-- 
1.8.1.4

--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to