diff options
Diffstat (limited to 'arch/powerpc/kvm/powerpc.c')
-rw-r--r-- | arch/powerpc/kvm/powerpc.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c index 13bc798a4441..a8000ce562b0 100644 --- a/arch/powerpc/kvm/powerpc.c +++ b/arch/powerpc/kvm/powerpc.c | |||
@@ -95,6 +95,31 @@ int kvmppc_kvm_pv(struct kvm_vcpu *vcpu) | |||
95 | return r; | 95 | return r; |
96 | } | 96 | } |
97 | 97 | ||
98 | int kvmppc_sanity_check(struct kvm_vcpu *vcpu) | ||
99 | { | ||
100 | int r = false; | ||
101 | |||
102 | /* We have to know what CPU to virtualize */ | ||
103 | if (!vcpu->arch.pvr) | ||
104 | goto out; | ||
105 | |||
106 | /* PAPR only works with book3s_64 */ | ||
107 | if ((vcpu->arch.cpu_type != KVM_CPU_3S_64) && vcpu->arch.papr_enabled) | ||
108 | goto out; | ||
109 | |||
110 | #ifdef CONFIG_KVM_BOOK3S_64_HV | ||
111 | /* HV KVM can only do PAPR mode for now */ | ||
112 | if (!vcpu->arch.papr_enabled) | ||
113 | goto out; | ||
114 | #endif | ||
115 | |||
116 | r = true; | ||
117 | |||
118 | out: | ||
119 | vcpu->arch.sane = r; | ||
120 | return r ? 0 : -EINVAL; | ||
121 | } | ||
122 | |||
98 | int kvmppc_emulate_mmio(struct kvm_run *run, struct kvm_vcpu *vcpu) | 123 | int kvmppc_emulate_mmio(struct kvm_run *run, struct kvm_vcpu *vcpu) |
99 | { | 124 | { |
100 | enum emulation_result er; | 125 | enum emulation_result er; |
@@ -582,6 +607,9 @@ static int kvm_vcpu_ioctl_enable_cap(struct kvm_vcpu *vcpu, | |||
582 | break; | 607 | break; |
583 | } | 608 | } |
584 | 609 | ||
610 | if (!r) | ||
611 | r = kvmppc_sanity_check(vcpu); | ||
612 | |||
585 | return r; | 613 | return r; |
586 | } | 614 | } |
587 | 615 | ||