OSDN Git Service

KVM: PPC: booke: add sregs support
[android-x86/kernel.git] / arch / powerpc / kvm / powerpc.c
index 9975846..616dd51 100644 (file)
@@ -175,7 +175,11 @@ int kvm_dev_ioctl_check_extension(long ext)
        int r;
 
        switch (ext) {
+#ifdef CONFIG_BOOKE
+       case KVM_CAP_PPC_BOOKE_SREGS:
+#else
        case KVM_CAP_PPC_SEGSTATE:
+#endif
        case KVM_CAP_PPC_PAIRED_SINGLES:
        case KVM_CAP_PPC_UNSET_IRQ:
        case KVM_CAP_PPC_IRQ_LEVEL:
@@ -284,6 +288,10 @@ int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu)
        tasklet_init(&vcpu->arch.tasklet, kvmppc_decrementer_func, (ulong)vcpu);
        vcpu->arch.dec_timer.function = kvmppc_decrementer_wakeup;
 
+#ifdef CONFIG_KVM_EXIT_TIMING
+       mutex_init(&vcpu->arch.exit_timing_lock);
+#endif
+
        return 0;
 }
 
@@ -294,12 +302,25 @@ void kvm_arch_vcpu_uninit(struct kvm_vcpu *vcpu)
 
 void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
 {
+#ifdef CONFIG_BOOKE
+       /*
+        * vrsave (formerly usprg0) isn't used by Linux, but may
+        * be used by the guest.
+        *
+        * On non-booke this is associated with Altivec and
+        * is handled by code in book3s.c.
+        */
+       mtspr(SPRN_VRSAVE, vcpu->arch.vrsave);
+#endif
        kvmppc_core_vcpu_load(vcpu, cpu);
 }
 
 void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu)
 {
        kvmppc_core_vcpu_put(vcpu);
+#ifdef CONFIG_BOOKE
+       vcpu->arch.vrsave = mfspr(SPRN_VRSAVE);
+#endif
 }
 
 int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,