Page MenuHomeFreeBSD

vmm svm: Refactor per-vCPU data.
ClosedPublic

Authored by jhb on Oct 27 2022, 3:03 PM.
Tags
None
Referenced Files
F102697577: D37148.diff
Sat, Nov 16, 12:15 AM
Unknown Object (File)
Sep 28 2024, 1:21 AM
Unknown Object (File)
Sep 27 2024, 6:00 PM
Unknown Object (File)
Sep 27 2024, 10:05 AM
Unknown Object (File)
Sep 24 2024, 9:53 PM
Unknown Object (File)
Sep 24 2024, 8:46 PM
Unknown Object (File)
Sep 20 2024, 4:42 PM
Unknown Object (File)
Sep 20 2024, 12:47 AM

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 Skipped
Unit
Tests Skipped
Build Status
Buildable 48134
Build 45021: arc lint + arc unit

Event Timeline

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

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?

616

Indeed, or use malloc_aligned().

2406–2407

Same here.

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

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

616

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
616

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.