提交 5c7df80e 编写于 作者: S Sean Christopherson 提交者: Peter Zijlstra

KVM: x86: Register perf callbacks after calling vendor's hardware_setup()

Wait to register perf callbacks until after doing vendor hardaware setup.
VMX's hardware_setup() configures Intel Processor Trace (PT) mode, and a
future fix to register the Intel PT guest interrupt hook if and only if
Intel PT is exposed to the guest will consume the configured PT mode.

Delaying registration to hardware setup is effectively a nop as KVM's perf
hooks all pivot on the per-CPU current_vcpu, which is non-NULL only when
KVM is handling an IRQ/NMI in a VM-Exit path.  I.e. current_vcpu will be
NULL throughout both kvm_arch_init() and kvm_arch_hardware_setup().
Signed-off-by: NSean Christopherson <seanjc@google.com>
Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: NPaolo Bonzini <pbonzini@redhat.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20211111020738.2512932-3-seanjc@google.com
上级 ff083a2d
...@@ -8626,8 +8626,6 @@ int kvm_arch_init(void *opaque) ...@@ -8626,8 +8626,6 @@ int kvm_arch_init(void *opaque)
kvm_timer_init(); kvm_timer_init();
perf_register_guest_info_callbacks(&kvm_guest_cbs);
if (boot_cpu_has(X86_FEATURE_XSAVE)) { if (boot_cpu_has(X86_FEATURE_XSAVE)) {
host_xcr0 = xgetbv(XCR_XFEATURE_ENABLED_MASK); host_xcr0 = xgetbv(XCR_XFEATURE_ENABLED_MASK);
supported_xcr0 = host_xcr0 & KVM_SUPPORTED_XCR0; supported_xcr0 = host_xcr0 & KVM_SUPPORTED_XCR0;
...@@ -8659,7 +8657,6 @@ void kvm_arch_exit(void) ...@@ -8659,7 +8657,6 @@ void kvm_arch_exit(void)
clear_hv_tscchange_cb(); clear_hv_tscchange_cb();
#endif #endif
kvm_lapic_exit(); kvm_lapic_exit();
perf_unregister_guest_info_callbacks(&kvm_guest_cbs);
if (!boot_cpu_has(X86_FEATURE_CONSTANT_TSC)) if (!boot_cpu_has(X86_FEATURE_CONSTANT_TSC))
cpufreq_unregister_notifier(&kvmclock_cpufreq_notifier_block, cpufreq_unregister_notifier(&kvmclock_cpufreq_notifier_block,
...@@ -11225,6 +11222,8 @@ int kvm_arch_hardware_setup(void *opaque) ...@@ -11225,6 +11222,8 @@ int kvm_arch_hardware_setup(void *opaque)
memcpy(&kvm_x86_ops, ops->runtime_ops, sizeof(kvm_x86_ops)); memcpy(&kvm_x86_ops, ops->runtime_ops, sizeof(kvm_x86_ops));
kvm_ops_static_call_update(); kvm_ops_static_call_update();
perf_register_guest_info_callbacks(&kvm_guest_cbs);
if (!kvm_cpu_cap_has(X86_FEATURE_XSAVES)) if (!kvm_cpu_cap_has(X86_FEATURE_XSAVES))
supported_xss = 0; supported_xss = 0;
...@@ -11252,6 +11251,8 @@ int kvm_arch_hardware_setup(void *opaque) ...@@ -11252,6 +11251,8 @@ int kvm_arch_hardware_setup(void *opaque)
void kvm_arch_hardware_unsetup(void) void kvm_arch_hardware_unsetup(void)
{ {
perf_unregister_guest_info_callbacks(&kvm_guest_cbs);
static_call(kvm_x86_hardware_unsetup)(); static_call(kvm_x86_hardware_unsetup)();
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册