Commit f257d6dc authored by Sean Christopherson's avatar Sean Christopherson Committed by Paolo Bonzini
Browse files

KVM: Directly return result from kvm_arch_check_processor_compat()



Add a wrapper to invoke kvm_arch_check_processor_compat() so that the
boilerplate ugliness of checking virtualization support on all CPUs is
hidden from the arch specific code.  x86's implementation in particular
is quite heinous, as it unnecessarily propagates the out-param pattern
into kvm_x86_ops.

While the x86 specific issue could be resolved solely by changing
kvm_x86_ops, make the change for all architectures as returning a value
directly is prettier and technically more robust, e.g. s390 doesn't set
the out param, which could lead to subtle breakage in the (highly
unlikely) scenario where the out-param was not pre-initialized by the
caller.

Opportunistically annotate svm_check_processor_compat() with __init.

Signed-off-by: default avatarSean Christopherson <sean.j.christopherson@intel.com>
Reviewed-by: default avatarCornelia Huck <cohuck@redhat.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 0532dd52
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -123,9 +123,9 @@ int kvm_arch_hardware_setup(void)
	return 0;
}

void kvm_arch_check_processor_compat(void *rtn)
int kvm_arch_check_processor_compat(void)
{
	*(int *)rtn = 0;
	return 0;
}

int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
+2 −2
Original line number Diff line number Diff line
@@ -425,9 +425,9 @@ int kvm_arch_hardware_setup(void)
	return 0;
}

void kvm_arch_check_processor_compat(void *rtn)
int kvm_arch_check_processor_compat(void)
{
	*(int *)rtn = kvmppc_core_check_processor_compat();
	return kvmppc_core_check_processor_compat();
}

int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
+0 −1
Original line number Diff line number Diff line
@@ -905,7 +905,6 @@ extern int kvm_s390_gisc_register(struct kvm *kvm, u32 gisc);
extern int kvm_s390_gisc_unregister(struct kvm *kvm, u32 gisc);

static inline void kvm_arch_hardware_disable(void) {}
static inline void kvm_arch_check_processor_compat(void *rtn) {}
static inline void kvm_arch_sync_events(struct kvm *kvm) {}
static inline void kvm_arch_vcpu_uninit(struct kvm_vcpu *vcpu) {}
static inline void kvm_arch_sched_in(struct kvm_vcpu *vcpu, int cpu) {}
+5 −0
Original line number Diff line number Diff line
@@ -227,6 +227,11 @@ int kvm_arch_hardware_enable(void)
	return 0;
}

int kvm_arch_check_processor_compat(void)
{
	return 0;
}

static void kvm_gmap_notifier(struct gmap *gmap, unsigned long start,
			      unsigned long end);

+1 −1
Original line number Diff line number Diff line
@@ -999,7 +999,7 @@ struct kvm_x86_ops {
	int (*disabled_by_bios)(void);             /* __init */
	int (*hardware_enable)(void);
	void (*hardware_disable)(void);
	void (*check_processor_compatibility)(void *rtn);
	int (*check_processor_compatibility)(void);/* __init */
	int (*hardware_setup)(void);               /* __init */
	void (*hardware_unsetup)(void);            /* __exit */
	bool (*cpu_has_accelerated_tpr)(void);
Loading