KVM: Restrict kvm_get_kvm/kvm_put_kvm export to internal KVM modules

Switch kvm_get_kvm, kvm_get_kvm_safe, and kvm_put_kvm from
EXPORT_SYMBOL_GPL to EXPORT_SYMBOL_FOR_KVM_INTERNAL. These symbols are
now only used within KVM itself. No external module needs them now that
VFIO uses file-based reference counting. Remove the corresponding
exemptions from the x86 KVM Makefile exports check.

Suggested-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Acked-by: Janosch Frank <frankja@linux.ibm.com>
Acked-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Christian Borntraeger <borntraeger@linux.ibm.com>
This commit is contained in:
Steffen Eiden 2026-09-28 15:07:06 +02:00 committed by Christian Borntraeger
parent 5c3ea6d3e8
commit 00aa2c8a02
2 changed files with 4 additions and 7 deletions

View File

@ -61,10 +61,7 @@ exports_grep_trailer := --include='*.[ch]' -nrw $(srctree)/virt/kvm $(srctree)/a
-e kvm_page_track_unregister_notifier \
-e kvm_write_track_add_gfn \
-e kvm_write_track_remove_gfn \
-e kvm_file_to_kvm_fn \
-e kvm_get_kvm \
-e kvm_get_kvm_safe \
-e kvm_put_kvm
-e kvm_file_to_kvm_fn
# Force grep to emit a goofy group separator that can in turn be replaced with
# the above newline macro (newlines in Make are a nightmare). Note, grep only

View File

@ -1314,7 +1314,7 @@ void kvm_get_kvm(struct kvm *kvm)
{
refcount_inc(&kvm->users_count);
}
EXPORT_SYMBOL_GPL(kvm_get_kvm);
EXPORT_SYMBOL_FOR_KVM_INTERNAL(kvm_get_kvm);
/*
* Make sure the vm is not during destruction, which is a safe version of
@ -1324,14 +1324,14 @@ bool kvm_get_kvm_safe(struct kvm *kvm)
{
return refcount_inc_not_zero(&kvm->users_count);
}
EXPORT_SYMBOL_GPL(kvm_get_kvm_safe);
EXPORT_SYMBOL_FOR_KVM_INTERNAL(kvm_get_kvm_safe);
void kvm_put_kvm(struct kvm *kvm)
{
if (refcount_dec_and_test(&kvm->users_count))
kvm_destroy_vm(kvm);
}
EXPORT_SYMBOL_GPL(kvm_put_kvm);
EXPORT_SYMBOL_FOR_KVM_INTERNAL(kvm_put_kvm);
/*
* Used to put a reference that was taken on behalf of an object associated