Skip to content

RFC KVM: x86: KVM_MEM_ALLONES memory

Vitaly Kuznetsov kvm lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest5 patches 12 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5KVM: rename labels in kvm_init()virt/kvm/kvm_main.c+16 -170 replies
2/5KVM: x86: introduce KVM_MEM_ALLONES memoryDocumentation/virt/kvm/api.rst arch/x86/include/uapi/asm/kvm.h arch/x86/kvm/x86.c +3 more+113 -152 replies
3/5KVM: x86: move kvm_vcpu_gfn_to_memslot() out of try_async_pf()arch/x86/kvm/mmu/mmu.c arch/x86/kvm/mmu/paging_tmpl.h+13 -80 replies
4/5KVM: x86: aggressively map PTEs in KVM_MEM_ALLONES slotsarch/x86/kvm/mmu/mmu.c arch/x86/kvm/mmu/paging_tmpl.h+39 -43 replies
5/5KVM: selftests: add KVM_MEM_ALLONES testtools/testing/selftests/kvm/Makefile tools/testing/selftests/kvm/include/kvm_util.h tools/testing/selftests/kvm/lib/kvm_util.c +1 more+162 -330 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH RFC 0/5] KVM: x86: KVM_MEM_ALLONES memory

The idea of the patchset was suggested by Michael S. Tsirkin.

PCIe config space can (depending on the configuration) be quite big but usually is sparsely populated. Guest may scan it by accessing individual device's page which, when device is missing, is supposed to have 'pci holes' semantics: reads return '0xff' and writes get discarded. Currently, userspace has to allocate real memory for these holes and fill them with '0xff'. Moreover, different VMs usually require different memory.

The idea behind the feature introduced by this patch is: let's have a single read-only page filled with '0xff' in KVM and map it to all such PCI holes in all VMs. This will free userspace of obligation to allocate real memory and also allow us to speed up access to these holes as we can aggressively map the whole slot upon first fault.

RFC. I've only tested the feature with the selftest (PATCH5) on Intel/AMD with and wiuthout EPT/NPT. I haven't tested memslot modifications yet.

Patches are against kvm/next.

Vitaly Kuznetsov (5):
KVM: rename labels in kvm_init()
KVM: x86: introduce KVM_MEM_ALLONES memory
KVM: x86: move kvm_vcpu_gfn_to_memslot() out of try_async_pf()
KVM: x86: aggressively map PTEs in KVM_MEM_ALLONES slots
KVM: selftests: add KVM_MEM_ALLONES test

 Documentation/virt/kvm/api.rst                |  22 ++--
 arch/x86/include/uapi/asm/kvm.h               |   1 +
 arch/x86/kvm/mmu/mmu.c                        |  34 ++++--
 arch/x86/kvm/mmu/paging_tmpl.h                |  30 ++++-
 arch/x86/kvm/x86.c                            |   9 +-
 include/linux/kvm_host.h                      |  15 ++-
 include/uapi/linux/kvm.h                      |   2 +
 tools/testing/selftests/kvm/Makefile          |   1 +
 .../testing/selftests/kvm/include/kvm_util.h  |   1 +
 tools/testing/selftests/kvm/lib/kvm_util.c    |  81 +++++++------
 .../kvm/x86_64/memory_region_allones.c        | 112 ++++++++++++++++++
 virt/kvm/kvm_main.c                           | 110 +++++++++++++----
 12 files changed, 342 insertions(+), 76 deletions(-)
 create mode 100644 tools/testing/selftests/kvm/x86_64/memory_region_allones.c
Signature · 1 line
2.25.4