On main, bhyve activates all vCPUs before running the BSP. In 13.1,
bhyve instead just runs the BSP and activates APs when
VM_EXITCODE_SPINUP_AP messages are received. Furthermore, vmm now
allocates vcpu structures lazily.
When an INIT or STARTUP IPI is raised, vlapic_calcdest() only returns
active vCPUs. So with old bhyve, it would return an empty set and
vm_handle_ipi() would do nothing. Fix this by modifying
vlapic_calcdest() to return "inactive" vCPUs in these special cases.
Then, vm_handle_ipi() handles INIT by reinitializing the vlapic on all
destination vCPUs. This does not work with lazy vcpu allocation.
Instead, just rendezvous with active vCPUs, since vm_alloc_vcpu() will
perform the same initialization later anyway.
Finally, fix encoding of the vcpuid in VM_EXITCODE_SPINUP_AP messages.
Also fix some other nits found along the way:
- Collapse two identical cases in vlapic_icrlo_write_handler() into one.
- Don't bother reinitializing "retu" before calling vm_handle_ipi(), since that function sets it unconditionally.
- Handle the default case in vm_handle_ipi() by panicking rather than returning EPERM (1) to userspace.