Page MenuHomeFreeBSD

vmm: Refactor storage of CPU-dependent per-vCPU data.
ClosedPublic

Authored by jhb on Oct 27 2022, 3:03 PM.
Tags
None
Referenced Files
F82537170: D37151.id113292.diff
Mon, Apr 29, 11:27 PM
Unknown Object (File)
Sun, Apr 28, 11:43 AM
Unknown Object (File)
Wed, Apr 24, 2:29 PM
Unknown Object (File)
Wed, Apr 24, 2:29 PM
Unknown Object (File)
Wed, Apr 24, 2:29 PM
Unknown Object (File)
Wed, Apr 24, 2:28 PM
Unknown Object (File)
Wed, Apr 24, 2:26 PM
Unknown Object (File)
Sun, Apr 21, 8:19 PM

Details

Summary

Rather than storing static arrays of per-vCPU data in the CPU-specific
per-VM structure, adopt a more dynamic model similar to that used to
manage CPU-specific per-VM data.

That is, add new vmmops methods to init and cleanup a single vCPU.
The init method returns a pointer that is stored in 'struct vcpu' as a
cookie pointer. This cookie pointer is now passed to other vmmops
callbacks in place of the integer index. The index is now only used
in KTR traces and when calling back into the CPU-independent layer.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 48023
Build 44910: arc lint + arc unit

Event Timeline

corvink added inline comments.
sys/amd64/vmm/amd/svm.c
385

sc is unused. It's a vcpu specific function. So, I would drop the sc parameter. The same applies to other vcpu specific functions.

sys/amd64/vmm/intel/vmx.h
170

Looks like this change is not related to the commit. The change is fine but I would split it into another commit.

sys/amd64/vmm/vmm.c
2877–2879
2970–2971
sys/amd64/vmm/amd/svm.c
295
sys/amd64/vmm/amd/svm.c
385

Sry, haven't looked at your next commit.

sys/amd64/vmm/intel/vmx.h
170

It's related in that the vcpus[] array was removed in this commit. I could maybe split out just the new bool though.

sys/amd64/vmm/vmm.c
2877–2879

I've assumed that vmm.c itself could directly access members of struct vcpu. At the end of this series vcpu_cookie is no longer present. It was more a helper function for intermediate commits in the series.

corvink added inline comments.
sys/amd64/vmm/intel/vmx.h
170

Got it. Thanks. If you split out the new bool, we could merge it earlier but that's you're decision.

sys/amd64/vmm/vmm.c
2877–2879

You're usage of vcpu_cookie is inconsistent. Some functions of vmm.c directly access it (like this one) and others are using vcpu_cookie to access it (like vm_set_capability). As it's only an intermediate helper you can leave it like it is.

This revision is now accepted and ready to land.Nov 4 2022, 6:30 AM
sys/amd64/vmm/intel/vmx.h
170

I will probably split it out into a new commit just before this one in the series.

sys/amd64/vmm/vmm.c
2877–2879

Hmm, I re-read the patch again and I see what I did. If I had an existing struct vcpu * then I used vcpu->cookie. If there wasn't an existing struct vcpu *, then the code uses vcpu_cookie() as a transition aid. Eventually the functions that use the helper are changed to take a struct vcpu *vcpu as a function argument instead of struct vm *vm, int vcpu and at that point the functions are changed to use vcpu->cookie directly.

This revision now requires review to proceed.Nov 4 2022, 8:14 PM
jhb marked 5 inline comments as done.Nov 4 2022, 8:18 PM
This revision is now accepted and ready to land.Nov 8 2022, 7:06 AM