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)
Thu, Sep 26, 7:30 PM
Unknown Object (File)
Mon, Sep 23, 1:48 AM
Unknown Object (File)
Sat, Sep 21, 8:08 AM
Unknown Object (File)
Fri, Sep 20, 6:39 AM
Unknown Object (File)
Fri, Sep 20, 6:21 AM
Unknown Object (File)
Thu, Sep 19, 9:03 AM
Unknown Object (File)
Mon, Sep 16, 11:03 PM
Unknown Object (File)
Sep 3 2024, 3:11 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.