public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] KVM: Clean up debugfs+stats init/destroy
@ 2022-04-15 20:15 Oliver Upton
  2022-04-15 20:15 ` [PATCH 1/5] KVM: Shove vm stats_id init into kvm_create_vm_debugfs() Oliver Upton
                   ` (5 more replies)
  0 siblings, 6 replies; 12+ messages in thread
From: Oliver Upton @ 2022-04-15 20:15 UTC (permalink / raw)
  To: kvm; +Cc: seanjc, pbonzini, maz, kvmarm, Oliver Upton

The way KVM handles debugfs initialization and destruction is somewhat
sloppy. Although the debugfs + stats bits get initialized *after*
kvm_create_vm(), they are torn down from kvm_destroy_vm(). And yes,
there is a window where we could theoretically destroy a VM before
debugfs is ever instantiated.

This series does away with the mess by coupling debugfs+stats to the
overall VM create/destroy pattern. We already fail the VM creation if
kvm_create_vm_debugfs() fails, so there really isn't a need to do these
separately in the first place.

The first two patches hoist some unrelated tidbits of stats state into
the debugfs constructors just so its all handled under one roof.

The second two patches realize the the intention of the series, changing
the initialization order so we can get an FD for the vm early.

Lastly, patch 5 is essentially a revert of Sean's proposed fix [1], but
I deliberately am not proposing a revert outright, in case alarm bells
go off that a stable patch got reverted (it is correct).

Applies to the following commit w/ the addition of Sean's patch:

  fb649bda6f56 ("Merge tag 'block-5.18-2022-04-15' of git://git.kernel.dk/linux-block")

Tested (I promise) on an Intel Skylake machine with KVM selftests. I
poked around in debugfs to make sure there were no stragglers, and I ran
the reproducer for [1] to confirm the null ptr deref wasn't introduced
yet again.

Oliver Upton (5):
  KVM: Shove vm stats_id init into kvm_create_vm_debugfs()
  KVM: Shove vcpu stats_id init into kvm_vcpu_create_debugfs()
  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 | 92 ++++++++++++++++++++++-----------------------
 1 file changed, 46 insertions(+), 46 deletions(-)

-- 
2.36.0.rc0.470.gd361397f0d-goog


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

end of thread, other threads:[~2022-05-16 23:56 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-15 20:15 [PATCH 0/5] KVM: Clean up debugfs+stats init/destroy Oliver Upton
2022-04-15 20:15 ` [PATCH 1/5] KVM: Shove vm stats_id init into kvm_create_vm_debugfs() Oliver Upton
2022-05-16 20:58   ` Sean Christopherson
2022-04-15 20:15 ` [PATCH 2/5] KVM: Shove vcpu stats_id init into kvm_vcpu_create_debugfs() Oliver Upton
2022-05-16 21:01   ` Sean Christopherson
2022-05-16 22:26     ` Oliver Upton
2022-04-15 20:15 ` [PATCH 3/5] KVM: Get an fd before creating the VM Oliver Upton
2022-04-15 20:15 ` [PATCH 4/5] KVM: Actually create debugfs in kvm_create_vm() Oliver Upton
2022-05-16 22:19   ` Sean Christopherson
2022-05-16 23:55     ` Oliver Upton
2022-04-15 20:15 ` [PATCH 5/5] KVM: Hoist debugfs_dentry init to kvm_create_vm_debugfs() (again) Oliver Upton
2022-04-15 20:19 ` [PATCH 0/5] KVM: Clean up debugfs+stats init/destroy Oliver Upton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox