Page MenuHomeFreeBSD

vmm svm: Refactor per-vCPU data.
ClosedPublic

Authored by jhb on Oct 27 2022, 3:03 PM.
Tags
None
Referenced Files
Unknown Object (File)
May 8 2024, 1:41 PM
Unknown Object (File)
May 8 2024, 1:41 PM
Unknown Object (File)
May 8 2024, 1:41 PM
Unknown Object (File)
May 8 2024, 1:40 PM
Unknown Object (File)
May 8 2024, 12:03 PM
Unknown Object (File)
Apr 24 2024, 1:50 PM
Unknown Object (File)
Apr 24 2024, 1:50 PM
Unknown Object (File)
Apr 24 2024, 1:50 PM

Details

Summary
  • Allocate VMCBs separately to avoid excessive padding in struct svm_vcpu.
  • Allocate APIC pages dynamically directly in struct vlapic.
  • Move vm_mtrr into struct svm_vcpu rather than using a separate parallel array.

Diff Detail

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

Event Timeline

corvink added inline comments.
sys/amd64/vmm/amd/svm.c
620

I'm not sure if we should check if the vmcb is page aligned or not. Same for other structures of your patch series. malloc docs say:

IMPLEMENTATION NOTES
     The memory	allocator allocates memory in chunks that have size a power of
     two for requests up to the	size of	a page of memory.  For larger re-
     quests, one or more pages is allocated.  While it should not be relied
     upon, this	information may	be useful for optimizing the efficiency	of
     memory use.

I think it's unlikely that this behaviour changes. Nevertheless, it would be safer to add an assertion.

sys/amd64/vmm/amd/svm.c
569

Presumably it doesn't matter if the softc isn't page-aligned?

620

Indeed, or use malloc_aligned().

2410–2411

Same here.

sys/amd64/vmm/amd/svm.c
569

I don't think it does. I think this was only for the VMCB.

620

I can use malloc_aligned(). I do think many many places in the kernel assume that malloc(PAGE_SIZE) returns an aligned page though.

jhb marked 3 inline comments as done.Nov 3 2022, 11:14 PM
corvink added inline comments.
sys/amd64/vmm/amd/svm.c
620

Thanks for changing it. IMHO, we should avoid not well defined behaviour just because many other places assume it. Additionally, malloc_aligned documents the alignment requirement.

This revision is now accepted and ready to land.Nov 4 2022, 7:00 AM
This revision was automatically updated to reflect the committed changes.