Page MenuHomeFreeBSD

vmm: Start reconciling amd64 and arm64 copies of vmm_dev.c
ClosedPublic

Authored by markj on Apr 28 2024, 4:57 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Jul 8, 12:02 AM
Unknown Object (File)
Jun 13 2024, 6:28 PM
Unknown Object (File)
May 28 2024, 8:59 PM
Unknown Object (File)
May 27 2024, 2:14 AM
Unknown Object (File)
May 8 2024, 11:42 PM
Unknown Object (File)
May 8 2024, 1:38 PM
Unknown Object (File)
May 1 2024, 1:11 AM
Unknown Object (File)
Apr 30 2024, 5:36 PM

Details

Summary

Most of the code in vmm_dev.c and vmm.c can and should be shared between
amd64 and arm64 (and eventually riscv) rather than being duplicated. To
the end of adding a shared implementation in sys/dev/vmm, this patch
eliminates most of the differences between the two copies of vmm_dev.c.

  • Remove an unneeded cdefs.h include.
  • Simplify the amd64 implementation of vcpu_unlock_one().
  • Simplify the arm64 implementation of vcpu_lock_one().
  • Pass buffer sizes to alloc_memseg() and get_memseg() on arm64. On amd64 this is needed for compat ioctls, but these functions should be merged.
  • Make devmem_mmap_single() stricter on arm64.

Diff Detail

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

Event Timeline

markj requested review of this revision.Apr 28 2024, 4:57 PM
sys/arm64/vmm/vmm_dev.c
274

Shouldn't we check that len <= mseg->name?

sys/arm64/vmm/vmm_dev.c
274

In general it's up to the caller to pass the correct len, as mseg might be a struct vm_memseg or a struct vm_memseg_fbsd12.

Are you asking me to add KASSERT(len <= sizeof(mseg->name)) or so? That's fine, but I'd probably put that in a separate commit; this patch is just about minimizing differences between amd64 and arm64.

This revision is now accepted and ready to land.Apr 30 2024, 9:59 PM
corvink added inline comments.
sys/arm64/vmm/vmm_dev.c
274

Yes, a kassert might be a good idea.

sys/arm64/vmm/vmm_dev.c
274

Actually, that assertion would be wrong in the COMPAT12 case, struct vm_memseg_fbsd12's name field is larger than the one in struct vm_memseg. (That is a bit surprising really.) So, I think I prefer to leave the code as it is.