Page MenuHomeFreeBSD

vmm: Lookup vcpu pointers in vmmdev_ioctl.
ClosedPublic

Authored by jhb on Oct 27 2022, 3:05 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Apr 22, 1:19 AM
Unknown Object (File)
Sun, Apr 21, 8:16 PM
Unknown Object (File)
Sun, Mar 31, 11:57 AM
Unknown Object (File)
Mar 2 2024, 4:58 AM
Unknown Object (File)
Feb 15 2024, 5:36 AM
Unknown Object (File)
Feb 15 2024, 5:36 AM
Unknown Object (File)
Feb 15 2024, 5:36 AM
Unknown Object (File)
Feb 15 2024, 5:36 AM

Details

Summary

Centralize mapping vCPU IDs to struct vcpu objects in vmmdev_ioctl and
pass vcpu pointers to the routines in vmm.c. For operations that want
to perform an action on all vCPUs or on a single vCPU, pass pointers
to both the VM and the vCPU using a NULL vCPU pointer to request
global actions.

Diff Detail

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

Event Timeline

jhb requested review of this revision.Oct 27 2022, 3:05 PM
corvink added inline comments.
sys/amd64/vmm/vmm_dev.c
445

Nit

541–548
555

vcpu could be left uninitialized. Might be a good idea to always initialize it. Not sure if the compiler will complain about it when enabling more warnings.

sys/amd64/vmm/vmm_dev.c
435

vcpu is initialized to NULL here btw.

jhb marked 2 inline comments as done.Nov 4 2022, 9:23 PM
This revision is now accepted and ready to land.Nov 7 2022, 7:16 AM
markj added inline comments.
sys/amd64/vmm/vmm_lapic.c
80

This is a semantic change, right? Before, if vm_active_cpus() is empty, this function would do nothing and return 0 instead of ENOENT.

sys/amd64/vmm/vmm_lapic.c
80

Hmm, it is. Probably I shouldn't change the semantics in this commit (enough moving parts).

jhb marked an inline comment as done.Nov 11 2022, 5:37 PM
sys/amd64/vmm/vmm_lapic.c
80

Btw: why did you changed the layout of the function? The old layout avoids some nesting. This commit could change it to something like:

if (vcpu == NULL)
  dmask = vm_active_cpus(vm);
else
  CPU_SETOF(vcpu_vcpuid(vcpu), &dmask);
error = 0;
CPU_FOREACH_ISSET(cpuid, &dmask)
...
sys/amd64/vmm/vmm_lapic.c
80

I think it was just to avoid doing a round trip of vcpu = vm_vcpu(vm, vm_vcpuid(vcpu)).

sys/amd64/vmm/vmm_lapic.c
80

Yeah, this round trip looks unnecessary. The old layout avoids some code duplication for vlapic = vm_lapic(vcpu); error = vlapic_trigger_lvt(vlapic, vector);.

This revision was automatically updated to reflect the committed changes.