aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kvm/powerpc.c
diff options
context:
space:
mode:
authorAlexander Graf <agraf@suse.de>2011-08-10 07:57:08 -0400
committerAvi Kivity <avi@redhat.com>2011-09-25 12:52:27 -0400
commitaf8f38b3499f0d4a3c354df2435f0fb2dded250a (patch)
tree129cf6f362fb623c80f8c2aa89c6fb3030b04c8d /arch/powerpc/kvm/powerpc.c
parent930b412a005bde2ea3f05911eaaeeb10f11d79ab (diff)
KVM: PPC: Add sanity checking to vcpu_run
There are multiple features in PowerPC KVM that can now be enabled depending on the user's wishes. Some of the combinations don't make sense or don't work though. So this patch adds a way to check if the executing environment would actually be able to run the guest properly. It also adds sanity checks if PVR is set (should always be true given the current code flow), if PAPR is only used with book3s_64 where it works and that HV KVM is only used in PAPR mode. Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'arch/powerpc/kvm/powerpc.c')
-rw-r--r--arch/powerpc/kvm/powerpc.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
index 13bc798a444..a8000ce562b 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
98int 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
118out:
119 vcpu->arch.sane = r;
120 return r ? 0 : -EINVAL;
121}
122
98int kvmppc_emulate_mmio(struct kvm_run *run, struct kvm_vcpu *vcpu) 123int 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