From: Chao Gao <chao.gao@intel.com>
To: Sean Christopherson <seanjc@google.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>, <kvm@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, Kai Huang <kai.huang@intel.com>
Subject: Re: [PATCH v2 6/6] KVM: x86: Register "emergency disable" callbacks when virt is enabled
Date: Thu, 23 May 2024 13:59:49 +0800 [thread overview]
Message-ID: <Zk7bVYh0iJkX/GYs@chao-email> (raw)
In-Reply-To: <20240522022827.1690416-7-seanjc@google.com>
On Tue, May 21, 2024 at 07:28:27PM -0700, Sean Christopherson wrote:
>Register the "disable virtualization in an emergency" callback just
>before KVM enables virtualization in hardware, as there is no functional
>need to keep the callbacks registered while KVM happens to be loaded, but
>is inactive, i.e. if KVM hasn't enabled virtualization.
>
>Note, unregistering the callback every time the last VM is destroyed could
>have measurable latency due to the synchronize_rcu() needed to ensure all
>references to the callback are dropped before KVM is unloaded. But the
>latency should be a small fraction of the total latency of disabling
>virtualization across all CPUs, and userspace can set enable_virt_at_load
>to completely eliminate the runtime overhead.
>
>Add a pointer in kvm_x86_ops to allow vendor code to provide its callback.
>There is no reason to force vendor code to do the registration, and either
>way KVM would need a new kvm_x86_ops hook.
>
>Suggested-by: Kai Huang <kai.huang@intel.com>
>Signed-off-by: Sean Christopherson <seanjc@google.com>
Reviewed-by: Chao Gao <chao.gao@intel.com>
...
>--- a/arch/x86/kvm/vmx/vmx.c
>+++ b/arch/x86/kvm/vmx/vmx.c
>@@ -753,7 +753,7 @@ static int kvm_cpu_vmxoff(void)
> return -EIO;
> }
>
>-static void vmx_emergency_disable(void)
>+void vmx_emergency_disable(void)
> {
> int cpu = raw_smp_processor_id();
> struct loaded_vmcs *v;
>@@ -8613,8 +8613,6 @@ static void __vmx_exit(void)
> {
> allow_smaller_maxphyaddr = false;
>
>- cpu_emergency_unregister_virt_callback(vmx_emergency_disable);
>-
> vmx_cleanup_l1d_flush();
> }
>
>@@ -8661,8 +8659,6 @@ static int __init vmx_init(void)
> pi_init_cpu(cpu);
> }
>
>- cpu_emergency_register_virt_callback(vmx_emergency_disable);
>-
Nit: with the removal of calls to cpu_emergency_(un)register_virt_callback,
there is no need to include asm/reboot.h in vmx.c any more. right?
prev parent reply other threads:[~2024-05-23 6:00 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-22 2:28 [PATCH v2 0/6] KVM: Register cpuhp/syscore callbacks when enabling virt Sean Christopherson
2024-05-22 2:28 ` [PATCH v2 1/6] KVM: Register cpuhp and syscore callbacks when enabling hardware Sean Christopherson
2024-05-22 6:10 ` Chao Gao
2024-05-29 14:29 ` Sean Christopherson
2024-05-22 2:28 ` [PATCH v2 2/6] KVM: Rename functions related to enabling virtualization hardware Sean Christopherson
2024-05-22 7:10 ` Chao Gao
2024-05-22 22:34 ` Huang, Kai
2024-05-22 2:28 ` [PATCH v2 3/6] KVM: Add a module param to allow enabling virtualization when KVM is loaded Sean Christopherson
2024-05-22 22:27 ` Huang, Kai
2024-05-23 4:23 ` Chao Gao
2024-05-23 23:11 ` Huang, Kai
2024-05-24 2:39 ` Chao Gao
2024-05-27 22:36 ` Huang, Kai
2024-05-29 15:01 ` Sean Christopherson
2024-05-29 22:45 ` Huang, Kai
2024-05-29 23:07 ` Sean Christopherson
2024-05-30 0:06 ` Huang, Kai
2024-05-22 2:28 ` [PATCH v2 4/6] KVM: Add arch hooks for enabling/disabling virtualization Sean Christopherson
2024-05-22 22:33 ` Huang, Kai
2024-05-28 22:50 ` Sean Christopherson
2024-05-23 5:31 ` Chao Gao
2024-05-22 2:28 ` [PATCH v2 5/6] x86/reboot: Unconditionally define cpu_emergency_virt_cb typedef Sean Christopherson
2024-05-22 22:35 ` Huang, Kai
2024-05-23 5:41 ` Chao Gao
2024-05-22 2:28 ` [PATCH v2 6/6] KVM: x86: Register "emergency disable" callbacks when virt is enabled Sean Christopherson
2024-05-22 22:37 ` Huang, Kai
2024-05-23 5:59 ` Chao Gao [this message]
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=Zk7bVYh0iJkX/GYs@chao-email \
--to=chao.gao@intel.com \
--cc=kai.huang@intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.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.