[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <436cecd4b5a11056f89a46f2cd1cae67be18b192.1661860550.git.isaku.yamahata@intel.com>
Date: Tue, 30 Aug 2022 05:01:28 -0700
From: isaku.yamahata@...el.com
To: kvm@...r.kernel.org, linux-kernel@...r.kernel.org
Cc: isaku.yamahata@...el.com, isaku.yamahata@...il.com,
Paolo Bonzini <pbonzini@...hat.com>,
Sean Christopherson <seanjc@...gle.com>,
Kai Huang <kai.huang@...el.com>, Chao Gao <chao.gao@...el.com>,
Will Deacon <will@...nel.org>
Subject: [PATCH v2 13/19] KVM: Do processor compatibility check on cpu online and resume
From: Isaku Yamahata <isaku.yamahata@...el.com>
So far the processor compatibility check is not done for newly added CPU.
It should be done. For online cpu case, the function is called by kernel
thread bind to the cpu without irq disabled. So remove
WARN_ON(!irq_disabled()).
Signed-off-by: Isaku Yamahata <isaku.yamahata@...el.com>
---
arch/x86/kvm/x86.c | 2 --
virt/kvm/kvm_arch.c | 15 +++++++++++++--
2 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 0b112cd7de58..ac185e199f69 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -12003,8 +12003,6 @@ int kvm_arch_check_processor_compat(void)
{
struct cpuinfo_x86 *c = &cpu_data(smp_processor_id());
- WARN_ON(!irqs_disabled());
-
if (__cr4_reserved_bits(cpu_has, c) !=
__cr4_reserved_bits(cpu_has, &boot_cpu_data))
return -EIO;
diff --git a/virt/kvm/kvm_arch.c b/virt/kvm/kvm_arch.c
index 3990f85edab3..e440d4a99c8a 100644
--- a/virt/kvm/kvm_arch.c
+++ b/virt/kvm/kvm_arch.c
@@ -99,6 +99,12 @@ __weak int kvm_arch_del_vm(int usage_count)
__weak int kvm_arch_online_cpu(unsigned int cpu, int usage_count)
{
+ int r;
+
+ r = kvm_arch_check_processor_compat();
+ if (r)
+ return r;
+
if (usage_count) {
/*
* Abort the CPU online process if hardware virtualization cannot
@@ -132,6 +138,11 @@ __weak int kvm_arch_suspend(int usage_count)
__weak void kvm_arch_resume(int usage_count)
{
- if (usage_count)
- (void)__hardware_enable();
+ if (kvm_arch_check_processor_compat())
+ return; /* FIXME: disable KVM */
+
+ if (!usage_count)
+ return;
+
+ (void)__hardware_enable();
}
--
2.25.1
Powered by blists - more mailing lists