Skip to content

Commit fc3c941

Browse files
committed
KVM: x86: Sanity check that kvm_has_noapic_vcpu is zero at module_exit()
WARN if kvm.ko is unloaded with an elevated kvm_has_noapic_vcpu to guard against incorrect management of the key, e.g. to detect if KVM fails to decrement the key in error paths. Because kvm_has_noapic_vcpu is purely an optimization, in all likelihood KVM could completely botch handling of kvm_has_noapic_vcpu and no one would notice (which is a good argument for deleting the key entirely, but that's a problem for another day). Note, ideally the sanity check would be performance when kvm_usage_count goes to zero, but adding an arch callback just for this sanity check isn't at all worth doing. Link: https://lore.kernel.org/r/20240209222047.394389-3-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent a78d904 commit fc3c941

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

arch/x86/kvm/x86.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13871,9 +13871,6 @@ module_init(kvm_x86_init);
1387113871

1387213872
static void __exit kvm_x86_exit(void)
1387313873
{
13874-
/*
13875-
* If module_init() is implemented, module_exit() must also be
13876-
* implemented to allow module unload.
13877-
*/
13874+
WARN_ON_ONCE(static_branch_unlikely(&kvm_has_noapic_vcpu));
1387813875
}
1387913876
module_exit(kvm_x86_exit);

0 commit comments

Comments
 (0)