@@ -8538,12 +8538,6 @@ int kvm_arch_init(void *opaque)
struct kvm_x86_init_ops *ops = opaque;
int r;
- if (kvm_x86_ops.hardware_enable) {
- pr_err("kvm: already loaded vendor module '%s'\n", kvm_x86_ops.name);
- r = -EEXIST;
- goto out;
- }
-
if (!ops->cpu_has_kvm_support()) {
pr_err_ratelimited("kvm: no hardware support for '%s'\n",
ops->runtime_ops->name);
@@ -8556,6 +8550,11 @@ int kvm_arch_init(void *opaque)
r = -EOPNOTSUPP;
goto out;
}
+ if (kvm_x86_ops.hardware_enable) {
+ pr_err("kvm: already loaded vendor module '%s'\n", kvm_x86_ops.name);
+ r = -EEXIST;
+ goto out;
+ }
/*
* KVM explicitly assumes that the guest has an FPU and
Move KVM's check for a vendor module already being loaded below the basic functionality checks so that attempting to load an unsupported module provides the same result regardless of whether or not a supported vendor module is already loaded. Intentionally keep the err non-ratelimited; if userspace is probing two different modules for the same vendor on all CPUs, it deserves the spam. Reported-by: Paul Menzel <pmenzel@molgen.mpg.de> Cc: Maciej S. Szmigiero <mail@maciej.szmigiero.name> Signed-off-by: Sean Christopherson <seanjc@google.com> --- arch/x86/kvm/x86.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)