Skip to content

Use memfd for guest vm memory allocation

Fuad Tabba kvm 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest17 patches 18 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/17Initialize the return value in kvm__for_each_mem_bank()kvm.c+1 -13 replies
2/17Make mmap_hugetlbfs() staticinclude/kvm/util.h util/util.c+1 -21 reply
3/17Rename parameter in mmap_anon_or_hugetlbfs()include/kvm/util.h util/util.c+4 -42 replies
4/17Add hostmem va to debug printarm/kvm.c+2 -20 replies
5/17Factor out getting the hugetlb block sizeutil/util.c+15 -90 replies
6/17Use memfd for hugetlbfs when allocating guest ramutil/util.c+20 -52 replies
7/17Make blk_size a parameter and pass it to mmap_hugetlbfs()util/util.c+19 -190 replies
8/17Use memfd for all guest ram allocationsinclude/kvm/kvm.h include/kvm/util.h kvm.c +1 more+28 -1310 replies
9/17Allocate pvtime memory with memfdarm/aarch64/pvtime.c+15 -30 replies
10/17Allocate vesa memory with memfdframebuffer.c hw/vesa.c include/kvm/framebuffer.h+16 -20 replies
11/17Add a function that allocates aligned memory if specifiedutil/util.c+38 -30 replies
12/17Use new function to align memoryarm/kvm.c riscv/kvm.c+10 -100 replies
13/17Remove struct fields and code used for alignmentarm/include/arm-common/kvm-arch.h arm/kvm.c riscv/include/kvm/kvm-arch.h +1 more+18 -480 replies
14/17Replace kvm_arch_delete_ram with kvm_delete_ramarm/kvm.c include/kvm/kvm.h kvm.c +4 more+9 -300 replies
15/17Remove no-longer unused macroinclude/kvm/util.h+0 -10 replies
16/17Factor out set_user_memory_region codekvm.c+28 -250 replies
17/17Pass the memory file descriptor and offset when registering ramarm/aarch64/pvtime.c arm/kvm.c hw/cfi_flash.c +8 more+28 -220 replies

Reviews trailers per patch

2 of 17 patches have a Reviewed-by or Acked-by.

PatchAndre Przywara
1/17R-b
2/17R-b
3/17
4/17
5/17
6/17
7/17
8/17
9/17
10/17
11/17
12/17
13/17
14/17
15/17
16/17
17/17

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH kvmtool v1 00/17] Use memfd for guest vm memory allocation

This patch series moves kvmtool from allocating guest vm memory using anonymous mmap to using memfd/ftruncate. The main motivation is to ease the transition to the fd-based kvm guest memory proposal [*]. It also facilitates using ipc memory sharing should that be needed in the future. Moreover, it removes the need for using temporary files if the memory is backed by hugetlbfs.

In the process of this rework, this patch series fixes a bug (uninitalized return value). It also adds a memory allocation function that allocates aligned memory without the need to over-map/allocate. This facilitates refactoring, which simplifies the code and removes a lot of the arch-specific code.

Cheers,
/fuad

[*] https://lore.kernel.org/all/[email protected]/

Fuad Tabba (17):
Initialize the return value in kvm__for_each_mem_bank() Make mmap_hugetlbfs() static
Rename parameter in mmap_anon_or_hugetlbfs()
Add hostmem va to debug print
Factor out getting the hugetlb block size
Use memfd for hugetlbfs when allocating guest ram Make blk_size a parameter and pass it to mmap_hugetlbfs() Use memfd for all guest ram allocations
Allocate pvtime memory with memfd
Allocate vesa memory with memfd
Add a function that allocates aligned memory if specified Use new function to align memory
Remove struct fields and code used for alignment Replace kvm_arch_delete_ram with kvm_delete_ram Remove no-longer unused macro
Factor out set_user_memory_region code
Pass the memory file descriptor and offset when registering ram

 arm/aarch64/pvtime.c              |  20 ++++-
 arm/include/arm-common/kvm-arch.h |   7 --
 arm/kvm.c                         |  35 +++------
 framebuffer.c                     |   2 +
 hw/cfi_flash.c                    |   4 +-
 hw/vesa.c                         |  17 ++++-
 include/kvm/framebuffer.h         |   1 +
 include/kvm/kvm.h                 |  19 ++---
 include/kvm/util.h                |   7 +-
 kvm.c                             |  69 ++++++++++-------
 mips/kvm.c                        |  11 +--
 powerpc/kvm.c                     |   7 +-
 riscv/include/kvm/kvm-arch.h      |   7 --
 riscv/kvm.c                       |  26 ++-----
 util/util.c                       | 119 +++++++++++++++++++++++-------
 vfio/core.c                       |   3 +-
 x86/kvm.c                         |  11 +--
 17 files changed, 209 insertions(+), 156 deletions(-)

base-commit: e17d182ad3f797f01947fc234d95c96c050c534b

Signature · 1 line
2.38.1.431.g37b22c650d-goog