From: Thomas Gleixner <tglx@linutronix.de>
To: "Tian, Kevin" <kevin.tian@intel.com>,
Paolo Bonzini <pbonzini@redhat.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
"Yamahata, Isaku" <isaku.yamahata@intel.com>,
"Huang, Kai" <kai.huang@intel.com>,
"Nakajima, Jun" <jun.nakajima@intel.com>,
"Hansen, Dave" <dave.hansen@intel.com>,
"Gao, Chao" <chao.gao@intel.com>
Subject: RE: Q. about KVM and CPU hotplug
Date: Wed, 01 Dec 2021 11:30:57 +0100 [thread overview]
Message-ID: <87bl20aa72.ffs@tglx> (raw)
In-Reply-To: <BN9PR11MB54333C976289C4AA42D7B1AA8C689@BN9PR11MB5433.namprd11.prod.outlook.com>
On Wed, Dec 01 2021 at 06:59, Kevin Tian wrote:
>> From: Paolo Bonzini <paolo.bonzini@gmail.com>
>> It should fail the first vmptrld instruction. It will result in a few
>> WARN_ONCE and pr_warn_ratelimited (see vmx_insn_failed). For VMX this
>> should be a pretty bad firmware bug, and it has never been reported.
>> KVM did find some undocumented errata but not this one!
>>
>
> or it may be caused by incompatible CPU capabilities, which is currently
> missing a check in kvm_starting_cpu(). So far the compatibility check is
> done only once before registering cpu hotplug state machine:
>
> for_each_online_cpu(cpu) {
> smp_call_function_single(cpu, check_processor_compat, &c, 1);
> if (r < 0)
> goto out_free_2;
> }
>
> r = cpuhp_setup_state_nocalls(CPUHP_AP_KVM_STARTING, "kvm/cpu:starting",
> kvm_starting_cpu, kvm_dying_cpu);
Duh. This is silly _and_ broken.
Using for_each_inline_cpu() without holding cpus_read_lock() is racy
against concurrent hotplug. But even if the locking is added then
nothing prevents a CPU from being plugged _after_ the lock is dropped.
The right solution is to move the hotplug state into the threaded
section as I pointed out and do:
r = cpuhp_setup_state(CPUHP_AP_KVM_STARTING, "kvm/cpu:starting",
kvm_starting_cpu, kvm_dying_cpu);
which will do the right thing automatically. Checking for compatibility
would just be part of the kvm_starting_cpu() callback.
Thanks,
tglx
next prev parent reply other threads:[~2021-12-01 10:31 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-30 8:27 Q. about KVM and CPU hotplug Tian, Kevin
2021-11-30 9:28 ` Paolo Bonzini
2021-11-30 14:05 ` Thomas Gleixner
2021-11-30 16:27 ` Paolo Bonzini
2021-12-01 7:18 ` Tian, Kevin
2021-11-30 20:02 ` Sean Christopherson
2021-12-01 6:59 ` Tian, Kevin
2021-12-01 10:30 ` Thomas Gleixner [this message]
2021-12-04 3:57 ` Tian, Kevin
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=87bl20aa72.ffs@tglx \
--to=tglx@linutronix.de \
--cc=chao.gao@intel.com \
--cc=dave.hansen@intel.com \
--cc=isaku.yamahata@intel.com \
--cc=jun.nakajima@intel.com \
--cc=kai.huang@intel.com \
--cc=kevin.tian@intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.