Page MenuHomeFreeBSD

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

Authored by markj on Sun, Apr 28, 4:57 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, May 8, 11:42 PM
Unknown Object (File)
Wed, May 8, 1:38 PM
Unknown Object (File)
Wed, May 1, 1:11 AM
Unknown Object (File)
Tue, Apr 30, 5:36 PM
Unknown Object (File)
Tue, Apr 30, 9:10 AM
Unknown Object (File)
Tue, Apr 30, 9:06 AM
Unknown Object (File)
Tue, Apr 30, 5:48 AM
Unknown Object (File)
Mon, Apr 29, 7:56 AM

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.Sun, Apr 28, 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.Tue, Apr 30, 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.