KVM: Register cpuhp/syscore callbacks when enabling virt
Status from this message: Queued, thanks.
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v4 Latest10 patches 6 repliesApplied
- v38 patches 22 repliesSuperseded
- v26 patches 20 repliesSuperseded
Earlier versions · 1
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v1 | 4 patches | 18 replies | Superseded |
Changes in v4 from the cover letter
- Collect more reviews.
- Fix documentation for kvm_usage_lock. [Kai]
- Add a blurb in locking.rst to call out that cpus_read_lock() vs kvm_lock is a general problem.
- Add a paragraph in the locking patch to suggest switching vm_list to an (S)RCU-protected list, so that walkers don't need to take kvm_lock.
- Add an example call chain for the other cpus_read_lock() vs kvm_lock issues that are lurking.
- Enable the module param by default from the get-go. [Paolo]
- Rename even more APIs/symbols (all of 'em I could find). [Paolo]
- Clarify that it's the 0=>1 VM creation that's problematic, not simply the creation of the very first VM. [Paolo]
- Document enable_virt_at_load, and call out the (dis)advantages of enabling virtualization when KVM is loaded.
- Drop the WARN on kvm_usage_count being elevated at the end of kvm_uninit_virtualization(), as it's annoyingly difficult to keep the WARN and still allow arch code (i.e. TDX) to enable virtualization during setup.
Patches in v4 Applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/10 | KVM: Use dedicated mutex to protect kvm_usage_count to avoid deadlockDocumentation/ virt/ | +39 | 3 replies | |
| 2/10 | KVM: Register cpuhp and syscore callbacks when enabling hardwareDocumentation/ virt/ | +66 | 0 replies | |
| 3/10 | KVM: Rename symbols related to enabling virtualization hardwarevirt/ | +21 | 0 replies | |
| 4/10 | KVM: Rename arch hooks related to per-CPU virtualization enablingarch/ arch/ arch/ +4 more | +16 | 1 reply | |
| 5/10 | KVM: MIPS: Rename virtualization {en,dis}abling APIs to match common KVMarch/ arch/ arch/ | +8 | 0 replies | |
| 6/10 | KVM: x86: Rename virtualization {en,dis}abling APIs to match common KVMarch/ arch/ arch/ +4 more | +27 | 1 reply | |
| 7/10 | KVM: Add a module param to allow enabling virtualization when KVM is loadedDocumentation/ virt/ | +52 | 0 replies | |
| 8/10 | KVM: Add arch hooks for enabling/disabling virtualizationinclude/ virt/ | +28 | 0 replies | |
| 9/10 | x86/reboot: Unconditionally define cpu_emergency_virt_cb typedefarch/ | +1 | 0 replies | |
| 10/10 | KVM: x86: Register "emergency disable" callbacks when virt is enabledarch/ arch/ arch/ +3 more | +18 | 0 replies |
Reviews trailers per patch
9 of 10 patches have a Reviewed-by or Acked-by.
| Patch | Kai Huang | Farrah Chen | Chao Gao |
|---|---|---|---|
| 1/10 | R-b A-b | T-b | |
| 2/10 | R-b A-b | T-b | |
| 3/10 | R-b A-b | T-b | R-b |
| 4/10 | R-b | ||
| 5/10 | |||
| 6/10 | R-b | ||
| 7/10 | A-b R-b | T-b | R-b |
| 8/10 | R-b A-b | T-b | R-b |
| 9/10 | A-b R-b | T-b | R-b |
| 10/10 | R-b A-b | T-b | R-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.
Cover letter [PATCH v4 00/10] KVM: Register cpuhp/syscore callbacks when enabling virt
Register KVM's cpuhp and syscore callbacks when enabling virtualization in hardware, as the sole purpose of said callbacks is to disable and re-enable virtualization as needed.
The primary motivation for this series is to simplify dealing with enabling virtualization for Intel's TDX, which needs to enable virtualization when kvm-intel.ko is loaded, i.e. long before the first VM is created.
That said, this is a nice cleanup on its own. By registering the callbacks on-demand, the callbacks themselves don't need to check kvm_usage_count, because their very existence implies a non-zero count.
Patch 1 (re)adds a dedicated lock for kvm_usage_count. Hopefully it's a temporary lock, as we can likely fix the cpus_read_lock() vs. kvm_lock mess for good by switching vm_list to an (S)RCU-protected list.
v4:
- Collect more reviews.
- Fix documentation for kvm_usage_lock. [Kai]
- Add a blurb in locking.rst to call out that cpus_read_lock() vs kvm_lock is a general problem.
- Add a paragraph in the locking patch to suggest switching vm_list to an (S)RCU-protected list, so that walkers don't need to take kvm_lock.
- Add an example call chain for the other cpus_read_lock() vs kvm_lock issues that are lurking.
- Enable the module param by default from the get-go. [Paolo]
- Rename even more APIs/symbols (all of 'em I could find). [Paolo]
- Clarify that it's the 0=>1 VM creation that's problematic, not simply the creation of the very first VM. [Paolo]
- Document enable_virt_at_load, and call out the (dis)advantages of enabling virtualization when KVM is loaded.
- Drop the WARN on kvm_usage_count being elevated at the end of kvm_uninit_virtualization(), as it's annoyingly difficult to keep the WARN and still allow arch code (i.e. TDX) to enable virtualization during setup.
v3:
- https://lore.kernel.org/all/20240608000639.3295768-1-seanjc at google.com
- Collect reviews/acks.
- Switch to kvm_usage_lock in a dedicated patch, Cc'd for stable at . [Chao]
- Enable virt at load by default. [Chao]
- Add comments to document how kvm_arch_{en,dis}able_virtualization() fit into the overall flow. [Kai]
v2:
- https://lore.kernel.org/all/20240522022827.1690416-1-seanjc at google.com
- Use a dedicated mutex to avoid lock inversion issues between kvm_lock and the cpuhp lock.
- Register emergency disable callbacks on-demand. [Kai]
- Drop an unintended s/junk/ign rename. [Kai]
- Decrement kvm_usage_count on failure. [Chao]
v1: https://lore.kernel.org/all/20240425233951.3344485-1-seanjc at google.com
Sean Christopherson (10):
KVM: Use dedicated mutex to protect kvm_usage_count to avoid deadlock
KVM: Register cpuhp and syscore callbacks when enabling hardware
KVM: Rename symbols related to enabling virtualization hardware
KVM: Rename arch hooks related to per-CPU virtualization enabling
KVM: MIPS: Rename virtualization {en,dis}abling APIs to match common
KVM
KVM: x86: Rename virtualization {en,dis}abling APIs to match common
KVM
KVM: Add a module param to allow enabling virtualization when KVM is
loaded
KVM: Add arch hooks for enabling/disabling virtualization x86/reboot: Unconditionally define cpu_emergency_virt_cb typedef
KVM: x86: Register "emergency disable" callbacks when virt is enabled
.../admin-guide/kernel-parameters.txt | 17 ++ Documentation/virt/kvm/locking.rst | 31 +- arch/arm64/kvm/arm.c | 6 +- arch/loongarch/kvm/main.c | 4 +- arch/mips/include/asm/kvm_host.h | 4 +- arch/mips/kvm/mips.c | 8 +- arch/mips/kvm/vz.c | 8 +- arch/riscv/kvm/main.c | 4 +- arch/x86/include/asm/kvm-x86-ops.h | 4 +- arch/x86/include/asm/kvm_host.h | 7 +- arch/x86/include/asm/reboot.h | 2 +- arch/x86/kvm/svm/svm.c | 19 +- arch/x86/kvm/vmx/main.c | 6 +- arch/x86/kvm/vmx/vmx.c | 10 +- arch/x86/kvm/vmx/x86_ops.h | 5 +- arch/x86/kvm/x86.c | 26 +- include/linux/kvm_host.h | 18 +- virt/kvm/kvm_main.c | 270 +++++++++--------- 18 files changed, 251 insertions(+), 198 deletions(-)
base-commit: 15e1c3d65975524c5c792fcd59f7d89f00402261
Signature · 1 line
2.46.0.469.g59c65b2a67-goog