Skip to content

KVM: PPC: Book3S HV: HPT read/write functions for userspace

Paul Mackerras kvm kvm-ppc 1 version Applied

Status from this message: Thanks, applied to kvm-ppc-next.

Get series with b4
b4 am 20121114043034.GA13832@drongo

Versions newest first

  1. v1 Latest4 patches 7 repliesApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/4KVM: PPC: Book3S HV: Restructure HPT entry creation codearch/powerpc/include/asm/kvm_book3s.h arch/powerpc/kvm/book3s_64_mmu_hv.c arch/powerpc/kvm/book3s_hv_rm_mmu.c+45 -231 reply
2/4KVM: PPC: Book3S HV: Add a mechanism for recording modified HPTEsarch/powerpc/include/asm/kvm_book3s_64.h arch/powerpc/include/asm/kvm_host.h arch/powerpc/kvm/book3s_hv_rm_mmu.c+29 -34 replies
3/4KVM: PPC: Book3S HV: Make a HPTE removal function availablearch/powerpc/include/asm/kvm_book3s.h arch/powerpc/kvm/book3s_hv_rm_mmu.c+16 -60 replies
4/4KVM: PPC: Book3S HV: Provide a method for userspace to read and write the HPTDocumentation/virtual/kvm/api.txt arch/powerpc/include/asm/kvm_book3s_64.h arch/powerpc/include/asm/kvm_ppc.h +5 more+461 -122 replies

Reviews trailers per patch

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

Read the v1 thread

Cover letter [PATCH 0/4] KVM: PPC: Book3S HV: HPT read/write functions for userspace

This series of patches provides an interface by which userspace can read and write the hashed page table (HPT) of a Book3S HV guest. The interface is an ioctl which provides a file descriptor which can be accessed with the read() and write() system calls. The data read and written is the guest view of the HPT, in which the second doubleword of each HPTE (HPT entry) contains a guest physical address, as distinct from the real HPT that the hardware accesses, where the second doubleword of each HPTE contains a real address.

Because the HPT is divided into groups (HPTEGs) of 8 entries each, where each HPTEG usually only contains a few valid entries, or none, the data format that we use does run-length encoding of the invalid entries, so in fact the invalid entries take up no space in the stream.

The interface also provides for doing multiple passes over the HPT, where the first pass provides information on all HPTEs, and subsequent passes only return the HPTEs that have changed since the previous pass.

I have implemented a read/write interface rather than an mmap-based interface because the data is not stored contiguously anywhere in kernel memory. Of each 16-byte HPTE, the first 8 bytes come from the real HPT and the second 8 bytes come from the parallel vmalloc'd array where we store the guest view of the guest physical address, permissions, accessed/dirty bits etc. Thus a mmap-based interface would not be practicable (not without doubling the size of the parallel array, typically requiring an extra 8MB of kernel memory per guest). This is also why I have not used the memslot interface for this.

This implements the interface for HV-style KVM but not for PR-style KVM. Userspace does not need any additional interface with PR-style KVM because userspace maintains the guest HPT already in that case, and has an image of the guest view of the HPT in its address space.

This series is against the next branch of the kvm tree. The patches are basically identical to the previous posting of the series, just rediffed for the move of kvm.h from include/linux to include/uapi/linux, and for commit 8ca40a70a7 ("KVM: Take kvm instead of vcpu to mmu_notifier_retry"), which supersedes patch 1 of the old series.

The overall diffstat is:

 Documentation/virtual/kvm/api.txt        |   53 +++++
 arch/powerpc/include/asm/kvm_book3s.h    |    8 +-
 arch/powerpc/include/asm/kvm_book3s_64.h |   24 ++
 arch/powerpc/include/asm/kvm_host.h      |    1 +
 arch/powerpc/include/asm/kvm_ppc.h       |    2 +
 arch/powerpc/include/uapi/asm/kvm.h      |   24 ++
 arch/powerpc/kvm/book3s_64_mmu_hv.c      |  380 +++++++++++++++++++++++++++++-
 arch/powerpc/kvm/book3s_hv.c             |   12 -
 arch/powerpc/kvm/book3s_hv_rm_mmu.c      |   71 ++++--
 arch/powerpc/kvm/powerpc.c               |   17 ++
 include/uapi/linux/kvm.h                 |    3 +
 11 files changed, 551 insertions(+), 44 deletions(-)

Please apply.

Paul.