Page MenuHomeFreeBSD

vmm: Use struct vcpu in the instruction emulation code.
ClosedPublic

Authored by jhb on Oct 27 2022, 3:04 PM.
Tags
None
Referenced Files
F102701184: D37161.diff
Sat, Nov 16, 1:29 AM
Unknown Object (File)
Tue, Nov 5, 1:10 AM
Unknown Object (File)
Oct 16 2024, 4:04 PM
Unknown Object (File)
Oct 12 2024, 7:13 PM
Unknown Object (File)
Oct 12 2024, 6:26 AM
Unknown Object (File)
Oct 12 2024, 6:26 AM
Unknown Object (File)
Oct 10 2024, 11:17 PM
Unknown Object (File)
Oct 9 2024, 12:43 PM

Details

Summary

This passes struct vcpu down in place of struct vm and and integer
vcpu index through the in-kernel instruction emulation code. To
minimize userland disruption, helper macros are used for the vCPU
arguments passed into and through the shared instruction emulation
code.

A few other APIs used by the instruction emulation code have also been
updated to accept struct vcpu in the kernel including
vm_get/set_register and vm_inject_fault.

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:04 PM
corvink added a subscriber: corvink.
corvink added inline comments.
sys/amd64/include/vmm_instruction_emul.h
36–44

I have a bad feeling about this "hack". I think it will be hard to maintain.

This revision is now accepted and ready to land.Nov 11 2022, 11:37 AM
jhb added inline comments.
sys/amd64/include/vmm_instruction_emul.h
36–44

There are some other options. illumos uses separate instruction emulation code in userland rather than sharing the code. Another option is to add a 'struct vcpu' to libvmmapi.h. I started on this latter approach but it would be another large change in its own right. That said, having a 'struct vcpu' and using it in bhyve in userspace might be a nice cleanup. It also makes it easier to possibly use anonymous file descriptors for vCPUs (something @grehan has talked about in the past).

sys/amd64/include/vmm_instruction_emul.h
36–44

A 'struct vcpu' in userspace sounds good. If we have to add more of such "hacks" in the future, we should consider using another approach for instruction emulation.

I know it requires some work to get rid of this "hack". So, this commit is fine for now.

markj added inline comments.
sys/amd64/include/vmm_instruction_emul.h
36–44

I'd suggest adding a comment noting that we should eventually modify userspace to use the same interface as the kernel.

Expand comment for VCPU* helper macros

This revision now requires review to proceed.Nov 14 2022, 6:43 PM
This revision is now accepted and ready to land.Nov 15 2022, 6:20 AM