Page MenuHomeFreeBSD

vmm: do not leak halted_cpus bit after suspension
ClosedPublic

Authored by kib on Oct 31 2022, 11:33 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Jun 1, 7:44 AM
Unknown Object (File)
Sun, May 18, 11:34 AM
Unknown Object (File)
May 8 2025, 8:09 PM
Unknown Object (File)
May 6 2025, 2:28 AM
Unknown Object (File)
Apr 27 2025, 11:07 AM
Unknown Object (File)
Apr 16 2025, 7:21 AM
Unknown Object (File)
Apr 6 2025, 5:57 PM
Unknown Object (File)
Feb 8 2025, 3:24 PM

Details

Summary

Reported by: bz
PR: 267468

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kib requested review of this revision.Oct 31 2022, 11:33 PM
markj added inline comments.
sys/amd64/vmm/vmm.c
1408

If there are two vcpus, and one is already halted, then we may suspend the VM here. Then the halted vcpu thread can wake up and handle a signal, so the VM will be suspended but halted_cpus != active_cpus. Hmm, but vmx_run() and svm_run() will return VM_EXITCODE_SUSPENDED once the vcpu tries to continue executing the (suspended) guest, so this seems ok.

This revision is now accepted and ready to land.Nov 1 2022, 2:13 PM
sys/amd64/vmm/vmm.c
1408

When adding this patch, I wondered if clearing of the bit in halted_cpus should be done under vcpu spin lock. But it seems that vm_resume_cpu() does not care, so I did not do locked the spin lock in the error path as well.

I suspect that vm_suspend() in fact needs more synchronization there, regardless of my fix.