linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Chao Gao <chao.gao@intel.com>
To: kvm@vger.kernel.org, seanjc@google.com, pbonzini@redhat.com,
	kevin.tian@intel.com, tglx@linutronix.de
Cc: "Thomas Richter" <tmricht@linux.ibm.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,
	"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>,
	"Anup Patel" <anup@brainfault.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>,
	"Atish Patra" <atishp@atishpatra.org>,
	"Sumanth Korikkar" <sumanthk@linux.ibm.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>,
	"Hector Martin" <marcan@marcan.st>,
	"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, "Marc Zyngier" <maz@kernel.org>,
	"Vitaly Kuznetsov" <vkuznets@redhat.com>,
	linuxppc-dev@lists.ozlabs.org
Subject: [PATCH v2 0/4] Improve KVM's interaction with CPU hotplug
Date: Tue, 18 Jan 2022 14:44:23 +0800	[thread overview]
Message-ID: <20220118064430.3882337-1-chao.gao@intel.com> (raw)

Changes from v1->v2: (all comments/suggestions on v1 are from Sean, thanks)
 - Merged v1's patch 2 into patch 1, and v1's patch 5 into patch 6.
 - Use static_call for check_processor_compatibility().
 - Generate patch 2 with "git revert" and do manual changes based on that.
 - Loosen the WARN_ON() in kvm_arch_check_processor_compat() instead of
   removing it.
 - KVM always prevent incompatible CPUs from being brought up regardless of
   running VMs.
 - Use pr_warn instead of pr_info to emit logs when KVM finds offending
   CPUs.

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

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 (4):
  KVM: x86: Move check_processor_compatibility from init ops to runtime
    ops
  Partially revert "KVM: Pass kvm_init()'s opaque param to additional
    arch funcs"
  KVM: Rename and move CPUHP_AP_KVM_STARTING to ONLINE section
  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-x86-ops.h |  1 +
 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                 | 16 +++++---
 include/linux/cpuhotplug.h         |  2 +-
 include/linux/kvm_host.h           |  2 +-
 virt/kvm/kvm_main.c                | 62 ++++++++++++++++++++----------
 15 files changed, 71 insertions(+), 44 deletions(-)

-- 
2.25.1


             reply	other threads:[~2022-01-18  6:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-18  6:44 Chao Gao [this message]
2022-01-18  6:44 ` [PATCH v2 2/4] Partially revert "KVM: Pass kvm_init()'s opaque param to additional arch funcs" Chao Gao

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=20220118064430.3882337-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@brainfault.org \
    --cc=aou@eecs.berkeley.edu \
    --cc=atishp@atishpatra.org \
    --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=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=marcan@marcan.st \
    --cc=maz@kernel.org \
    --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).