kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/6] KVM: Clean up debugfs init/destroy
@ 2022-07-20  9:22 Oliver Upton
  2022-07-20  9:22 ` [PATCH v3 1/6] KVM: Shove vm stats_id init into kvm_create_vm() Oliver Upton
                   ` (8 more replies)
  0 siblings, 9 replies; 19+ messages in thread
From: Oliver Upton @ 2022-07-20  9:22 UTC (permalink / raw)
  To: kvm; +Cc: Paolo Bonzini, Sean Christopherson, Oliver Upton

From: Oliver Upton <oupton@google.com>

The way that KVM handles debugfs init/destroy is somewhat sloppy. Even
though debugfs is stood up after kvm_create_vm(), it is torn down from
kvm_destroy_vm(). There exists a window where we need to tear down a VM
before debugfs is created, requiring delicate handling.

This series cleans up the debugfs lifecycle by fully tying it to the
VM's init/destroy pattern.

First two patches hoist some unrelated stats initialization to a more
appropriate place for kvm and kvm_vcpu.

The next 3 patches are the meat of the series, changing around the
initialization order to get an FD early and wiring in debugfs
initialization to kvm_create_vm().

Lastly, patch 6 is essentially a revert of Sean's fix [1] for a NULL deref
in debugfs, though I stopped short of an outright revert since that one
went to stable and is still entirely correct.

"Works on my machine", and with luck it will on yours too.

[1] 5c697c367a66 ("KVM: Initialize debugfs_dentry when a VM is created to avoid NULL deref")

v1: http://lore.kernel.org/r/20220415201542.1496582-1-oupton@google.com
v2: https://lore.kernel.org/kvm/20220518175811.2758661-1-oupton@google.com

v1 -> v2:
 - Don't conflate debugfs+stats. Initialize stats_id outside of the
   context of debugfs (Sean)
 - Pass around the FD as a string to avoid subsequent KVM changes
   inappropriately using the FD (Sean)

v2 -> v3:
 - Spare readers from needing to refer to the title of a commit (Sean)
 - Crack fd stringization and move of kvm_create_vm_debugfs() into two
   patches (Sean)
 - Fix a bug that crops up in the middle of the series. Failed to pass
   the fd through to kvm_create_vm_debugfs()

Oliver Upton (6):
  KVM: Shove vm stats_id init into kvm_create_vm()
  KVM: Shove vcpu stats_id init into kvm_vcpu_init()
  KVM: Get an fd before creating the VM
  KVM: Pass the name of the VM fd to kvm_create_vm_debugfs()
  KVM: Actually create debugfs in kvm_create_vm()
  KVM: Hoist debugfs_dentry init to kvm_create_vm_debugfs() (again)

 virt/kvm/kvm_main.c | 91 +++++++++++++++++++++++++--------------------
 1 file changed, 50 insertions(+), 41 deletions(-)


base-commit: 8031d87aa9953ddeb047a5356ebd0b240c30f233
-- 
2.37.0.170.g444d1eabd0-goog


^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2022-08-09 20:00 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-20  9:22 [PATCH v3 0/6] KVM: Clean up debugfs init/destroy Oliver Upton
2022-07-20  9:22 ` [PATCH v3 1/6] KVM: Shove vm stats_id init into kvm_create_vm() Oliver Upton
2022-08-05 19:09   ` Sean Christopherson
2022-07-20  9:22 ` [PATCH v3 2/6] KVM: Shove vcpu stats_id init into kvm_vcpu_init() Oliver Upton
2022-08-05 19:06   ` Sean Christopherson
2022-08-09 14:52     ` Paolo Bonzini
2022-07-20  9:22 ` [PATCH v3 3/6] KVM: Get an fd before creating the VM Oliver Upton
2022-08-05 19:03   ` Sean Christopherson
2022-07-20  9:22 ` [PATCH v3 4/6] KVM: Pass the name of the VM fd to kvm_create_vm_debugfs() Oliver Upton
2022-08-05 19:20   ` Sean Christopherson
2022-07-20  9:22 ` [PATCH v3 5/6] KVM: Actually create debugfs in kvm_create_vm() Oliver Upton
2022-08-05 19:16   ` Sean Christopherson
2022-07-20  9:22 ` [PATCH v3 6/6] KVM: Hoist debugfs_dentry init to kvm_create_vm_debugfs() (again) Oliver Upton
2022-08-05 19:02   ` Sean Christopherson
2022-08-09 14:56     ` Paolo Bonzini
2022-08-09 19:59       ` Oliver Upton
2022-07-20  9:22 ` [PATCH v3 0/6] KVM: Clean up debugfs init/destroy Oliver Upton
2022-07-20  9:22 ` [PATCH v3 1/6] KVM: Shove vm stats_id init into kvm_create_vm() Oliver Upton
2022-07-20  9:22 ` [PATCH v3 2/6] KVM: Shove vcpu stats_id init into kvm_vcpu_init() Oliver Upton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).