Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit af8f38b3 authored by Alexander Graf's avatar Alexander Graf Committed by Avi Kivity
Browse files

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: default avatarAlexander Graf <agraf@suse.de>
parent 930b412a
Loading
Loading
Loading
Loading
+5 −0
Original line number Original line Diff line number Diff line
@@ -284,6 +284,11 @@ struct kvm_guest_debug_arch {
#define KVM_INTERRUPT_UNSET	-2U
#define KVM_INTERRUPT_UNSET	-2U
#define KVM_INTERRUPT_SET_LEVEL	-3U
#define KVM_INTERRUPT_SET_LEVEL	-3U


#define KVM_CPU_440		1
#define KVM_CPU_E500V2		2
#define KVM_CPU_3S_32		3
#define KVM_CPU_3S_64		4

/* for KVM_CAP_SPAPR_TCE */
/* for KVM_CAP_SPAPR_TCE */
struct kvm_create_spapr_tce {
struct kvm_create_spapr_tce {
	__u64 liobn;
	__u64 liobn;
+2 −0
Original line number Original line Diff line number Diff line
@@ -390,6 +390,8 @@ struct kvm_vcpu_arch {
	u8 osi_needed;
	u8 osi_needed;
	u8 osi_enabled;
	u8 osi_enabled;
	u8 papr_enabled;
	u8 papr_enabled;
	u8 sane;
	u8 cpu_type;
	u8 hcall_needed;
	u8 hcall_needed;


	u32 cpr0_cfgaddr; /* holds the last set cpr0_cfgaddr */
	u32 cpr0_cfgaddr; /* holds the last set cpr0_cfgaddr */
+1 −0
Original line number Original line Diff line number Diff line
@@ -66,6 +66,7 @@ extern int kvmppc_emulate_instruction(struct kvm_run *run,
extern int kvmppc_emulate_mmio(struct kvm_run *run, struct kvm_vcpu *vcpu);
extern int kvmppc_emulate_mmio(struct kvm_run *run, struct kvm_vcpu *vcpu);
extern void kvmppc_emulate_dec(struct kvm_vcpu *vcpu);
extern void kvmppc_emulate_dec(struct kvm_vcpu *vcpu);
extern u32 kvmppc_get_dec(struct kvm_vcpu *vcpu, u64 tb);
extern u32 kvmppc_get_dec(struct kvm_vcpu *vcpu, u64 tb);
extern int kvmppc_sanity_check(struct kvm_vcpu *vcpu);


/* Core-specific hooks */
/* Core-specific hooks */


+2 −0
Original line number Original line Diff line number Diff line
@@ -78,6 +78,8 @@ int kvmppc_core_vcpu_setup(struct kvm_vcpu *vcpu)
	for (i = 0; i < ARRAY_SIZE(vcpu_44x->shadow_refs); i++)
	for (i = 0; i < ARRAY_SIZE(vcpu_44x->shadow_refs); i++)
		vcpu_44x->shadow_refs[i].gtlb_index = -1;
		vcpu_44x->shadow_refs[i].gtlb_index = -1;


	vcpu->arch.cpu_type = KVM_CPU_440;

	return 0;
	return 0;
}
}


+8 −0
Original line number Original line Diff line number Diff line
@@ -510,6 +510,9 @@ struct kvm_vcpu *kvmppc_core_vcpu_create(struct kvm *kvm, unsigned int id)
	spin_unlock(&vcore->lock);
	spin_unlock(&vcore->lock);
	vcpu->arch.vcore = vcore;
	vcpu->arch.vcore = vcore;


	vcpu->arch.cpu_type = KVM_CPU_3S_64;
	kvmppc_sanity_check(vcpu);

	return vcpu;
	return vcpu;


free_vcpu:
free_vcpu:
@@ -800,6 +803,11 @@ int kvmppc_vcpu_run(struct kvm_run *run, struct kvm_vcpu *vcpu)
{
{
	int r;
	int r;


	if (!vcpu->arch.sane) {
		run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
		return -EINVAL;
	}

	do {
	do {
		r = kvmppc_run_vcpu(run, vcpu);
		r = kvmppc_run_vcpu(run, vcpu);


Loading