Skip to content

Commit 5c7df80

Browse files
sean-jcPeter Zijlstra
authored andcommitted
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: Sean Christopherson <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Acked-by: Paolo Bonzini <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected]
1 parent ff083a2 commit 5c7df80

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

arch/x86/kvm/x86.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8626,8 +8626,6 @@ int kvm_arch_init(void *opaque)
86268626

86278627
kvm_timer_init();
86288628

8629-
perf_register_guest_info_callbacks(&kvm_guest_cbs);
8630-
86318629
if (boot_cpu_has(X86_FEATURE_XSAVE)) {
86328630
host_xcr0 = xgetbv(XCR_XFEATURE_ENABLED_MASK);
86338631
supported_xcr0 = host_xcr0 & KVM_SUPPORTED_XCR0;
@@ -8659,7 +8657,6 @@ void kvm_arch_exit(void)
86598657
clear_hv_tscchange_cb();
86608658
#endif
86618659
kvm_lapic_exit();
8662-
perf_unregister_guest_info_callbacks(&kvm_guest_cbs);
86638660

86648661
if (!boot_cpu_has(X86_FEATURE_CONSTANT_TSC))
86658662
cpufreq_unregister_notifier(&kvmclock_cpufreq_notifier_block,
@@ -11225,6 +11222,8 @@ int kvm_arch_hardware_setup(void *opaque)
1122511222
memcpy(&kvm_x86_ops, ops->runtime_ops, sizeof(kvm_x86_ops));
1122611223
kvm_ops_static_call_update();
1122711224

11225+
perf_register_guest_info_callbacks(&kvm_guest_cbs);
11226+
1122811227
if (!kvm_cpu_cap_has(X86_FEATURE_XSAVES))
1122911228
supported_xss = 0;
1123011229

@@ -11252,6 +11251,8 @@ int kvm_arch_hardware_setup(void *opaque)
1125211251

1125311252
void kvm_arch_hardware_unsetup(void)
1125411253
{
11254+
perf_unregister_guest_info_callbacks(&kvm_guest_cbs);
11255+
1125511256
static_call(kvm_x86_hardware_unsetup)();
1125611257
}
1125711258

0 commit comments

Comments
 (0)