From: Chao Gao <chao.gao@intel.com>
To: kvm@vger.kernel.org, pbonzini@redhat.com, kevin.tian@intel.com,
tglx@linutronix.de
Cc: "Guo Ren" <guoren@linux.alibaba.com>,
"Wanpeng Li" <wanpengli@tencent.com>,
"David Hildenbrand" <david@redhat.com>,
"Maciej S. Szmigiero" <maciej.szmigiero@oracle.com>,
"Dave Hansen" <dave.hansen@linux.intel.com>,
x86@kernel.org, linux-mips@vger.kernel.org,
"Atish Patra" <atish.patra@wdc.com>,
"Paul Mackerras" <paulus@samba.org>,
"H. Peter Anvin" <hpa@zytor.com>,
"Alexander Gordeev" <agordeev@linux.ibm.com>,
"Claudio Imbrenda" <imbrenda@linux.ibm.com>,
"Will Deacon" <will@kernel.org>,
kvmarm@lists.cs.columbia.edu, linux-s390@vger.kernel.org,
"Janosch Frank" <frankja@linux.ibm.com>,
"Marc Zyngier" <maz@kernel.org>, "Joerg Roedel" <joro@8bytes.org>,
"Huacai Chen" <chenhuacai@kernel.org>,
linux-riscv@lists.infradead.org,
"Aleksandar Markovic" <aleksandar.qemu.devel@gmail.com>,
"Ingo Molnar" <mingo@redhat.com>,
"Catalin Marinas" <catalin.marinas@arm.com>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
"Christian Borntraeger" <borntraeger@linux.ibm.com>,
"Chao Gao" <chao.gao@intel.com>,
"Ravi Bangoria" <ravi.bangoria@linux.ibm.com>,
"Albert Ou" <aou@eecs.berkeley.edu>,
"Vasily Gorbik" <gor@linux.ibm.com>,
"Suzuki K Poulose" <suzuki.poulose@arm.com>,
"Heiko Carstens" <hca@linux.ibm.com>,
"John Garry" <john.garry@huawei.com>,
"Nicholas Piggin" <npiggin@gmail.com>,
"Shaokun Zhang" <zhangshaokun@hisilicon.com>,
"Borislav Petkov" <bp@alien8.de>,
"Cédric Le Goater" <clg@kaod.org>,
"Paul Walmsley" <paul.walmsley@sifive.com>,
"Sumanth Korikkar" <sumanthk@linux.ibm.com>,
"Sean Christopherson" <seanjc@google.com>,
"Alexandru Elisei" <alexandru.elisei@arm.com>,
linux-arm-kernel@lists.infradead.org,
"Jim Mattson" <jmattson@google.com>,
"Thomas Bogendoerfer" <tsbogend@alpha.franken.de>,
"Fabiano Rosas" <farosas@linux.ibm.com>,
"Mel Gorman" <mgorman@techsingularity.net>,
"Anup Patel" <anup.patel@wdc.com>,
"Nick Desaulniers" <ndesaulniers@google.com>,
linux-kernel@vger.kernel.org,
"Bharata B Rao" <bharata@linux.ibm.com>,
"James Morse" <james.morse@arm.com>,
kvm-riscv@lists.infradead.org,
"Vitaly Kuznetsov" <vkuznets@redhat.com>,
linuxppc-dev@lists.ozlabs.org,
"Thomas Richter" <tmricht@linux.ibm.com>
Subject: [PATCH 0/6] Improve KVM's interaction with CPU hotplug
Date: Mon, 27 Dec 2021 16:15:06 +0800 [thread overview]
Message-ID: <20211227081515.2088920-1-chao.gao@intel.com> (raw)
KVM registers its CPU hotplug callback to CPU starting section. And in the
callback, KVM enables hardware virtualization on hotplugged CPUs if any VM
is running on existing CPUs.
There are two problems in the process:
1. KVM doesn't do compatibility checks before enabling hardware
virtualization on hotplugged CPUs. This may cause #GP if VMX isn't
supported or vmentry failure if some in-use VMX features are missing on
hotplugged CPUs. Both break running VMs.
2. Callbacks in CPU STARTING section cannot fail. So, even if KVM finds
some incompatible CPUs, its callback cannot block CPU hotplug.
This series improves KVM's interaction with CPU hotplug to avoid
incompatible CPUs breaking running VMs. Following changes are made:
1. move KVM's CPU hotplug callback to ONLINE section (suggested by Thomas)
2. do compatibility checks on hotplugged CPUs.
3. abort onlining incompatible CPUs if there is a running VM.
This series is a follow-up to the discussion about KVM and CPU hotplug
https://lore.kernel.org/lkml/3d3296f0-9245-40f9-1b5a-efffdb082de9@redhat.com/T/
Note: this series is tested only on Intel systems.
Chao Gao (6):
KVM: x86: Move check_processor_compatibility from init ops to runtime
ops
KVM: x86: Use kvm_x86_ops in kvm_arch_check_processor_compat
KVM: Remove opaque from kvm_arch_check_processor_compat
KVM: Rename and move CPUHP_AP_KVM_STARTING to ONLINE section
KVM: x86: Remove WARN_ON in kvm_arch_check_processor_compat
KVM: Do compatibility checks on hotplugged CPUs
arch/arm64/kvm/arm.c | 2 +-
arch/mips/kvm/mips.c | 2 +-
arch/powerpc/kvm/powerpc.c | 2 +-
arch/riscv/kvm/main.c | 2 +-
arch/s390/kvm/kvm-s390.c | 2 +-
arch/x86/include/asm/kvm_host.h | 2 +-
arch/x86/kvm/svm/svm.c | 4 +-
arch/x86/kvm/vmx/evmcs.c | 2 +-
arch/x86/kvm/vmx/evmcs.h | 2 +-
arch/x86/kvm/vmx/vmx.c | 12 +++---
arch/x86/kvm/x86.c | 7 +---
include/linux/cpuhotplug.h | 2 +-
include/linux/kvm_host.h | 2 +-
virt/kvm/kvm_main.c | 74 ++++++++++++++++++++++++---------
14 files changed, 74 insertions(+), 43 deletions(-)
--
2.25.1
next reply other threads:[~2021-12-28 8:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-27 8:15 Chao Gao [this message]
2021-12-27 8:15 ` [PATCH 3/6] KVM: Remove opaque from kvm_arch_check_processor_compat Chao Gao
2022-01-10 23:06 ` Sean Christopherson
2022-01-11 3:19 ` Chao Gao
2022-01-12 17:20 ` Sean Christopherson
2022-01-12 17:21 ` Sean Christopherson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211227081515.2088920-1-chao.gao@intel.com \
--to=chao.gao@intel.com \
--cc=agordeev@linux.ibm.com \
--cc=aleksandar.qemu.devel@gmail.com \
--cc=alexandru.elisei@arm.com \
--cc=anup.patel@wdc.com \
--cc=aou@eecs.berkeley.edu \
--cc=atish.patra@wdc.com \
--cc=bharata@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=bp@alien8.de \
--cc=catalin.marinas@arm.com \
--cc=chenhuacai@kernel.org \
--cc=clg@kaod.org \
--cc=dave.hansen@linux.intel.com \
--cc=david@redhat.com \
--cc=farosas@linux.ibm.com \
--cc=frankja@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=guoren@linux.alibaba.com \
--cc=hca@linux.ibm.com \
--cc=hpa@zytor.com \
--cc=imbrenda@linux.ibm.com \
--cc=james.morse@arm.com \
--cc=jmattson@google.com \
--cc=john.garry@huawei.com \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=kvm-riscv@lists.infradead.org \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=linux-s390@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maciej.szmigiero@oracle.com \
--cc=maz@kernel.org \
--cc=mgorman@techsingularity.net \
--cc=mingo@redhat.com \
--cc=ndesaulniers@google.com \
--cc=npiggin@gmail.com \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=paulus@samba.org \
--cc=pbonzini@redhat.com \
--cc=ravi.bangoria@linux.ibm.com \
--cc=seanjc@google.com \
--cc=sumanthk@linux.ibm.com \
--cc=suzuki.poulose@arm.com \
--cc=tglx@linutronix.de \
--cc=tmricht@linux.ibm.com \
--cc=tsbogend@alpha.franken.de \
--cc=vkuznets@redhat.com \
--cc=wanpengli@tencent.com \
--cc=will@kernel.org \
--cc=x86@kernel.org \
--cc=zhangshaokun@hisilicon.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).