RFC Add support for restricted guest memory in kvmtool
Get series with b4
b4 am [email protected]Versions newest first
- v1 RFC Latest32 patches 4 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/32 | Initialize the return value in kvm__for_each_mem_bank()kvm.c | +3 | 0 replies | |
| 2/32 | Remove newline from end of die() abortsutil/ | +5 | 0 replies | |
| 3/32 | Make mmap_hugetlbfs() staticinclude/ util/ | +1 | 0 replies | |
| 4/32 | Rename parameter in mmap_anon_or_hugetlbfs()util/ | +5 | 0 replies | |
| 5/32 | Add hostmem va to debug printarm/ | +2 | 0 replies | |
| 6/32 | Factor out getting the hugetlb block sizeutil/ | +15 | 0 replies | |
| 7/32 | Use memfd for hugetlbfs when allocating guest ramutil/ | +11 | 0 replies | |
| 8/32 | Make blk_size a parameter and pass it to mmap_hugetlbfs()util/ | +18 | 0 replies | |
| 9/32 | Use memfd for all guest ram allocationsinclude/ include/ kvm.c +1 more | +26 | 0 replies | |
| 10/32 | Allocate pvtime memory with memfdarm/ | +15 | 0 replies | |
| 11/32 | Allocate vesa memory with memfdframebuffer.c hw/ include/ | +16 | 0 replies | |
| 12/32 | Add a function that allocates aligned memory if specifiedutil/ | +38 | 0 replies | |
| 13/32 | Use new function to align memoryarm/ riscv/ | +10 | 0 replies | |
| 14/32 | Remove struct fields and code used for alignmentarm/ arm/ riscv/ +1 more | +18 | 0 replies | |
| 15/32 | Replace kvm__arch_delete_ram() with kvm__delete_ram()arm/ include/ kvm.c +4 more | +9 | 0 replies | |
| 16/32 | Remove no-longer used macroinclude/ | +0 | 0 replies | |
| 17/32 | Factor out set_user_memory_region codekvm.c util/ | +29 | 0 replies | |
| 18/32 | Pass the memory file descriptor and offset when registering ramarm/ arm/ hw/ +8 more | +28 | 0 replies | |
| 19/32 | Add memfd_restricted system callutil/ | +11 | 0 replies | |
| 20/32 | Add kvm linux headers and structure extensions for restricted_fdinclude/ | +19 | 0 replies | |
| 21/32 | Add option for enabling restricted memory for guestsarm/ builtin-run.c include/ | +8 | 0 replies | |
| 22/32 | Change guest ram mapping from private to sharedutil/ | +1 | 0 replies | |
| 23/32 | Change pvtime mapping from private to sharedarm/ | +1 | 0 replies | |
| 24/32 | Change vesa mapping from private to sharedhw/ | +1 | 0 replies | |
| 25/32 | Allocate guest memory as restricted if neededarm/ hw/ include/ +1 more | +11 | 4 replies | |
| 26/32 | Use the new fd-based extended memory regionkvm.c | +49 | 0 replies | |
| 27/32 | Track the memfd in the bankinclude/ kvm.c | +4 | 0 replies | |
| 28/32 | Add functions for mapping/unmapping guest memoryinclude/ kvm.c | +187 | 0 replies | |
| 29/32 | pkvm: Add option to spawn a protected vm in pkvmarm/ arm/ arm/ +4 more | +31 | 0 replies | |
| 30/32 | pkvm: Enable exit hypercall capability if supportedarm/ arm/ arm/ +2 more | +36 | 0 replies | |
| 31/32 | pkvm: Handle (un)share hypercalls coming from the guestarm/ arm/ | +60 | 0 replies | |
| 32/32 | pkvm: Unmap all guest memory after initializationbuiltin-run.c | +3 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [RFC PATCH kvmtool v1 00/32] Add support for restricted guest memory in kvmtool
The main goal of this patch series is to add support for the the restricted guest memory proposali (V9) [1] to kvmtool (V10 was released today [2]). This proposal is still being discussed, but it seems to be close to its final form. The intention is that the restricted guest memory would be used in various confidential computing environments, such as TDX and pKVM.
This series is intended to work with the kernel in of the V9 proposal [1], in addition to work to port it to pKVM [3]. It has been tested on qemu/arm64.
The patch series is divided as follows:
Patches 1--4:
General fixes and tidying up
Patches 5--18:
Move kvmtool from allocating guest vm memory using anonymous mmap to using memfd/ftruncate. The main motivation is to support the fd-based kvm guest memory proposal [1, 2]. It also facilitates using ipc memory sharing should that be needed in the future. It also moves kvmtool to using only a file based backend for guest memory allocation, with the file descriptor being the canonical reference to guest memory. The idea is to refer to all allocated guest memory via a file descriptor.
Patches 19--28:
Add architecture-independent framework to support restricted guest memory.
Patches 29--32:
Add pKVM-specific (arm64) support for restricted guest memory.
I had posted a subset of this series earlier covering patches 1--18 [4]. This series incorporates fixes and suggestions from Alex into those patches.
Cheers,
/fuad
[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/
[3] https://android-kvm.googlesource.com/kvmtool/+/refs/heads/tabba/fdmem-v9-core
[4] https://lore.kernel.org/all/[email protected]/
Fuad Tabba (31):
Initialize the return value in kvm__for_each_mem_bank() Remove newline from end of die() aborts
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 used macro
Factor out set_user_memory_region code
Pass the memory file descriptor and offset when registering ram Add memfd_restricted system call
Add kvm linux headers and structure extensions for restricted_fd Add option for enabling restricted memory for guests Change guest ram mapping from private to shared Change pvtime mapping from private to shared
Change vesa mapping from private to shared
Allocate guest memory as restricted if needed
Use the new fd-based extended memory region
Track the memfd in the bank
Add functions for mapping/unmapping guest memory
pkvm: Enable exit hypercall capability if supported
pkvm: Handle (un)share hypercalls coming from the guest
pkvm: Unmap all guest memory after initialization
Will Deacon (1):
pkvm: Add option to spawn a protected vm in pkvm
arm/aarch32/include/kvm/kvm-arch.h | 1 + arm/aarch64/include/asm/kvm.h | 7 + arm/aarch64/include/kvm/kvm-arch.h | 1 + arm/aarch64/kvm.c | 26 +++ arm/aarch64/pvtime.c | 20 +- arm/fdt.c | 18 ++ arm/include/arm-common/fdt-arch.h | 2 +- arm/include/arm-common/kvm-arch.h | 7 - arm/kvm-cpu.c | 58 ++++++ arm/kvm.c | 41 ++-- arm/pci.c | 3 + builtin-run.c | 7 + framebuffer.c | 2 + hw/cfi_flash.c | 4 +- hw/vesa.c | 17 +- include/kvm/framebuffer.h | 1 + include/kvm/kvm-config.h | 2 + include/kvm/kvm.h | 25 ++- include/kvm/util.h | 5 +- include/linux/kvm.h | 19 ++ kvm.c | 301 ++++++++++++++++++++++++++--- mips/kvm.c | 11 +- powerpc/kvm.c | 7 +- riscv/include/kvm/kvm-arch.h | 7 - riscv/kvm.c | 26 +-- util/util.c | 131 ++++++++++--- vfio/core.c | 3 +- virtio/pci-modern.c | 3 + x86/kvm.c | 11 +- 29 files changed, 606 insertions(+), 160 deletions(-)
base-commit: e17d182ad3f797f01947fc234d95c96c050c534b
Signature · 1 line
2.39.0.rc0.267.gcb52ba06e7-goog