Skip to content

KVM: Clean up debugfs+stats init/destroy

Oliver Upton kvm kvmarm 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest5 patches 6 repliesIn review
  2. v15 patches 6 repliesSuperseded

Changes in v2 from the cover letter

- 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)

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5KVM: Shove vm stats_id init into kvm_create_vm()virt/kvm/kvm_main.c+3 -32 replies
2/5KVM: Shove vcpu stats_id init into kvm_vcpu_init()virt/kvm/kvm_main.c+4 -41 reply
3/5KVM: Get an fd before creating the VMvirt/kvm/kvm_main.c+16 -121 reply
4/5KVM: Actually create debugfs in kvm_create_vm()virt/kvm/kvm_main.c+23 -251 reply
5/5KVM: Hoist debugfs_dentry init to kvm_create_vm_debugfs() (again)virt/kvm/kvm_main.c+6 -61 reply

Reviews trailers per patch

1 of 5 patches has a Reviewed-by or Acked-by.

PatchSean Christopherson
1/5
2/5
3/5
4/5
5/5R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/5] KVM: Clean up debugfs+stats init/destroy

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.

Second two 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 5 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.

Applies cleanly to v5.18-rc5, since [1] is currently missing from kvm/queue or kvm/next. Tested with KVM selftests and the reproducer mentioned in [1] on an Intel Skylake machine.

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

v1: http://lore.kernel.org/r/[email protected]

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)

Oliver Upton (5):
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: Actually create debugfs in kvm_create_vm()
KVM: Hoist debugfs_dentry init to kvm_create_vm_debugfs() (again)

 virt/kvm/kvm_main.c | 96 +++++++++++++++++++++++----------------------
 1 file changed, 49 insertions(+), 47 deletions(-)
Signature · 6 lines
2.36.1.124.g0e6072fb45-goog

_______________________________________________
kvmarm mailing list
[email protected]
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm