Re: [PATCH v4 2/4] KVM: x86: Leave user-return notifier registered on reboot/shutdown

Chao Gao
2025-10-17T05:33:00Z

> bool kvm_vcpu_is_reset_bsp(struct kvm_vcpu *vcpu)
>@@ -14363,6 +14377,11 @@ module_init(kvm_x86_init);
>
> static void __exit kvm_x86_exit(void)
> {
>+ int cpu;
>+
>+ for_each_possible_cpu(cpu)
>+ WARN_ON_ONCE(per_cpu_ptr(user_return_msrs, cpu)->registered);

Is it OK to reference user_return_msrs during kvm.ko unloading? IIUC,
user_return_msrs has already been freed during kvm-{intel,amd}.ko unloading.
See:

vmx_exit/svm_exit()
-> kvm_x86_vendor_exit()
-> free_percpu(user_return_msrs);

>+
>t WARN_ON_ONCE(static_branch_unlikely(&kvm_has_noapic_vcpu));
> }
> module_exit(kvm_x86_exit);
>--
>2.51.0.858.gf9c4a03a3a-goog
>
>