[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <fc3c8c0a3bb5a5aa38a8c261e992ac636de4da3c.1662679124.git.isaku.yamahata@intel.com>
Date: Thu, 8 Sep 2022 16:25:38 -0700
From: isaku.yamahata@...el.com
To: linux-kernel@...r.kernel.org, kvm@...r.kernel.org,
Paolo Bonzini <pbonzini@...hat.com>,
Sean Christopherson <seanjc@...gle.com>,
Marc Zyngier <maz@...nel.org>, Will Deacon <will@...nel.org>,
Yuan Yao <yuan.yao@...ux.intel.com>
Cc: isaku.yamahata@...el.com, isaku.yamahata@...il.com,
Kai Huang <kai.huang@...el.com>, Chao Gao <chao.gao@...el.com>,
Atish Patra <atishp@...shpatra.org>,
Shaokun Zhang <zhangshaokun@...ilicon.com>,
Qi Liu <liuqi115@...wei.com>,
John Garry <john.garry@...wei.com>,
Daniel Lezcano <daniel.lezcano@...aro.org>,
Huang Ying <ying.huang@...el.com>,
Huacai Chen <chenhuacai@...nel.org>
Subject: [PATCH v4 22/26] KVM: x86: Make x86 processor compat check callback empty
From: Isaku Yamahata <isaku.yamahata@...el.com>
Move processor compatibility check on all processors into
kvm_arch_hardware_setup() and make kvm_arch_check_processor_compat{,_all}()
empty. This is a preparation step to eliminate them.
Suggested-by: Sean Christopherson <seanjc@...gle.com>
Signed-off-by: Isaku Yamahata <isaku.yamahata@...el.com>
---
arch/x86/kvm/x86.c | 47 +++++++++++++++++++++++++++++-----------------
1 file changed, 30 insertions(+), 17 deletions(-)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 0c9d965859c6..9dd90f0521c3 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -129,6 +129,8 @@ static int kvm_vcpu_do_singlestep(struct kvm_vcpu *vcpu);
static int __set_sregs2(struct kvm_vcpu *vcpu, struct kvm_sregs2 *sregs2);
static void __get_sregs2(struct kvm_vcpu *vcpu, struct kvm_sregs2 *sregs2);
+static int kvm_check_processor_compatibility(void);
+
struct kvm_x86_ops kvm_x86_ops __read_mostly;
#define KVM_X86_OP(func) \
@@ -11911,21 +11913,8 @@ int kvm_arch_del_vm(int usage_count)
return 0;
}
-static void check_processor_compat(void *rtn)
-{
- *(int *)rtn = kvm_arch_check_processor_compat();
-}
-
int kvm_arch_check_processor_compat_all(void)
{
- int cpu;
- int r;
-
- for_each_online_cpu(cpu) {
- smp_call_function_single(cpu, check_processor_compat, &r, 1);
- if (r < 0)
- return r;
- }
return 0;
}
@@ -11933,7 +11922,7 @@ int kvm_arch_online_cpu(unsigned int cpu, int usage_count)
{
int ret;
- ret = kvm_arch_check_processor_compat();
+ ret = kvm_check_processor_compatibility();
if (ret)
return ret;
@@ -11997,7 +11986,7 @@ void kvm_arch_resume(int usage_count)
u64 max_tsc = 0;
bool stable, backwards_tsc = false;
- if (kvm_arch_check_processor_compat())
+ if (kvm_check_processor_compatibility())
return; /* FIXME: disable KVM. */
if (!usage_count)
@@ -12103,6 +12092,24 @@ static inline void kvm_ops_update(struct kvm_x86_init_ops *ops)
kvm_pmu_ops_update(ops->pmu_ops);
}
+static void check_processor_compat(void *rtn)
+{
+ *(int *)rtn = kvm_check_processor_compatibility();
+}
+
+static int kvm_check_processor_compatibility_all(void)
+{
+ int cpu;
+ int r;
+
+ for_each_online_cpu(cpu) {
+ smp_call_function_single(cpu, check_processor_compat, &r, 1);
+ if (r < 0)
+ return r;
+ }
+ return 0;
+}
+
int kvm_arch_hardware_setup(void *opaque)
{
struct kvm_x86_init_ops *ops = opaque;
@@ -12143,7 +12150,8 @@ int kvm_arch_hardware_setup(void *opaque)
}
kvm_caps.default_tsc_scaling_ratio = 1ULL << kvm_caps.tsc_scaling_ratio_frac_bits;
kvm_init_msr_list();
- return 0;
+
+ return kvm_check_processor_compatibility_all();
}
void kvm_arch_hardware_unsetup(void)
@@ -12155,7 +12163,7 @@ void kvm_arch_hardware_unsetup(void)
static_call(kvm_x86_hardware_unsetup)();
}
-int kvm_arch_check_processor_compat(void)
+static int kvm_check_processor_compatibility(void)
{
int cpu = smp_processor_id();
struct cpuinfo_x86 *c = &cpu_data(cpu);
@@ -12175,6 +12183,11 @@ int kvm_arch_check_processor_compat(void)
return static_call(kvm_x86_check_processor_compatibility)();
}
+int kvm_arch_check_processor_compat(void)
+{
+ return 0;
+}
+
bool kvm_vcpu_is_reset_bsp(struct kvm_vcpu *vcpu)
{
return vcpu->kvm->arch.bsp_vcpu_id == vcpu->vcpu_id;
--
2.25.1
Powered by blists - more mailing lists