Page MenuHomeFreeBSD

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

Authored by markj on Apr 28 2024, 4:57 PM.
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



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

rG FreeBSD src repository
Lint Not Applicable
Tests Not Applicable

Event Timeline

markj requested review of this revision.Apr 28 2024, 4:57 PM

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


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.

Yes, a kassert might be a good idea.


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.