History

KVM: Add separate helper for putting borrowed reference to kvm

Add a new helper, kvm_put_kvm_no_destroy(), to handle putting a borrowed reference[*] to the VM when installing a new file descriptor fails. KVM expects the refcount to remain valid in this case, as the in-progress ioctl() has an explicit reference to the VM. The primary motiviation for the helper is to document that the 'kvm' pointer is still valid after putting the borrowed reference, e.g. to document that doing mutex(&kvm->lock) immediately after putting a ref to kvm isn't broken. [*] When exposing a new object to userspace via a file descriptor, e.g. a new vcpu, KVM grabs a reference to itself (the VM) prior to making the object visible to userspace to avoid prematurely freeing the VM in the scenario where userspace immediately closes file descriptor.

Sean Christopherson committed 7 years ago

Commit 149487b1 parent c90992b4 files · +17 −4Browse files

Showing the changes to include/linux (1 of 4 files). Show all

Unified · Split

include/linux/kvm_host.h+1−0
@@ -621,6 +621,7 @@ void kvm_exit(void); · 620 unmodified lines
621621
622622 void kvm_get_kvm(struct kvm *kvm);
623623 void kvm_put_kvm(struct kvm *kvm);
624+void kvm_put_kvm_no_destroy(struct kvm *kvm);
624625
625626 static inline struct kvm_memslots *__kvm_memslots(struct kvm *kvm, int as_id)
626627 {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t