Skip to content

KVM PPC PV framework v3

Alexander Graf kvm kvm-ppc linuxppc-dev 1 version Applied

Status from this message: Applied this and your follow on 7-part series, thanks.

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest14 of 27 patches 10 repliesApplied

v1 -> v2 from the cover letter

- change hypervisor calls to use r0 and r3
- make crit detection only trigger in supervisor mode
- RMO -> PAM
- introduce kvm_patch_ins
- only flush icache when patching
- introduce kvm_patch_ins_b
- update documentation

14 of 27 patches are in this archive. The cover letter announces 27.

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
4/27KVM: PPC: Convert DAR to shared page.arch/powerpc/include/asm/kvm_host.h arch/powerpc/include/asm/kvm_para.h arch/powerpc/kvm/book3s.c +4 more+15 -150 replies
5/27KVM: PPC: Convert SRR0 and SRR1 to shared pagearch/powerpc/include/asm/kvm_host.h arch/powerpc/include/asm/kvm_para.h arch/powerpc/kvm/book3s.c +4 more+28 -230 replies
7/27KVM: PPC: Implement hypervisor interfacearch/powerpc/include/asm/kvm_para.h arch/powerpc/include/asm/kvm_ppc.h arch/powerpc/kernel/Makefile +5 more+233 -40 replies
9/27KVM: PPC: Add PV guest scratch registersarch/powerpc/include/asm/kvm_para.h+3 -00 replies
11/27KVM: PPC: Make PAM a definearch/powerpc/include/asm/kvm_host.h arch/powerpc/kvm/book3s.c+5 -20 replies
12/27KVM: PPC: First magic page stepsarch/powerpc/include/asm/kvm_host.h include/linux/kvm_para.h+3 -00 replies
13/27KVM: PPC: Magic Page Book3s supportarch/powerpc/include/asm/kvm_book3s.h arch/powerpc/kvm/book3s.c arch/powerpc/kvm/book3s_32_mmu.c +3 more+81 -120 replies
15/27KVM: Move kvm_guest_init out of generic codearch/x86/include/asm/kvm_para.h include/linux/kvm_para.h+6 -50 replies
16/27KVM: PPC: Generic KVM PV guest supportarch/powerpc/kernel/Makefile arch/powerpc/kernel/asm-offsets.c arch/powerpc/kernel/kvm.c +2 more+66 -10 replies
17/27KVM: PPC: KVM PV guest stubsarch/powerpc/kernel/kvm.c+95 -01 reply
18/27KVM: PPC: PV instructions to loads and storesarch/powerpc/kernel/kvm.c+109 -00 replies
22/27KVM: PPC: PV assembler helpersarch/powerpc/kernel/kvm_emul.S+29 -00 replies
24/27KVM: PPC: PV mtmsrd L=0 and mtmsrarch/powerpc/kernel/kvm.c arch/powerpc/kernel/kvm_emul.S+135 -00 replies
27/27KVM: PPC: Add get_pvinfo interface to query hypercall instructionsDocumentation/kvm/api.txt arch/powerpc/kvm/powerpc.c include/linux/kvm.h+72 -00 replies

Reviews trailers per patch

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

Read the v1 thread

Cover letter [PATCH 00/27] KVM PPC PV framework v3

On PPC we run PR=0 (kernel mode) code in PR=1 (user mode) and don't use the hypervisor extensions.

While that is all great to show that virtualization is possible, there are quite some cases where the emulation overhead of privileged instructions is killing performance.

This patchset tackles exactly that issue. It introduces a paravirtual framework using which KVM and Linux share a page to exchange register state with. That way we don't have to switch to the hypervisor just to change a value of a privileged register.

To prove my point, I ran the same test I did for the MMU optimizations against the PV framework. Here are the results:

[without]

debian-powerpc:~# time for i in {1..1000}; do /bin/echo hello > /dev/null; done
real    0m14.659s
user    0m8.967s
sys     0m5.688s

[with]

debian-powerpc:~# time for i in {1..1000}; do /bin/echo hello > /dev/null; done
real    0m7.557s
user    0m4.121s
sys     0m3.426s

So this is a significant performance improvement! I'm quite happy how fast this whole thing becomes :)

I tried to take all comments I've heard from people so far about such a PV framework into account. In case you told me something before that is a no-go and I still did it, please just tell me again.

To make use of this whole thing you also need patches to qemu and openbios. I have them in my queue, but want to see this set upstream first before I start sending patches to the other projects.

Now go and have fun with fast VMs on PPC! Get yourself a G5 on ebay and start experiencing the power yourself. - heh

v1 -> v2:

- change hypervisor calls to use r0 and r3
- make crit detection only trigger in supervisor mode
- RMO -> PAM
- introduce kvm_patch_ins
- only flush icache when patching
- introduce kvm_patch_ins_b
- update documentation

v2 -> v3:

- use pPAPR conventions for hypercall interface
- only use r0 as magic sc number
- remove PVR detection
- remove BookE shared page mapping support
- combine book3s-64 and -32 magic page ra override
- add self-test check if the mapping works to guest code
- add safety check for relocatable kernels

Alexander Graf (27):
KVM: PPC: Introduce shared page
KVM: PPC: Convert MSR to shared page
KVM: PPC: Convert DSISR to shared page
KVM: PPC: Convert DAR to shared page.
KVM: PPC: Convert SRR0 and SRR1 to shared page
KVM: PPC: Convert SPRG[0-4] to shared page
KVM: PPC: Implement hypervisor interface
KVM: PPC: Add PV guest critical sections
KVM: PPC: Add PV guest scratch registers
KVM: PPC: Tell guest about pending interrupts
KVM: PPC: Make PAM a define
KVM: PPC: First magic page steps
KVM: PPC: Magic Page Book3s support
KVM: PPC: Expose magic page support to guest
KVM: Move kvm_guest_init out of generic code
KVM: PPC: Generic KVM PV guest support
KVM: PPC: KVM PV guest stubs
KVM: PPC: PV instructions to loads and stores
KVM: PPC: PV tlbsync to nop
KVM: PPC: Introduce kvm_tmp framework
KVM: PPC: Introduce branch patching helper
KVM: PPC: PV assembler helpers
KVM: PPC: PV mtmsrd L=1
KVM: PPC: PV mtmsrd L=0 and mtmsr
KVM: PPC: PV wrteei
KVM: PPC: Add Documentation about PV interface
KVM: PPC: Add get_pvinfo interface to query hypercall instructions

 Documentation/kvm/api.txt                |   23 ++
 Documentation/kvm/ppc-pv.txt             |  180 +++++++++++
 arch/powerpc/include/asm/kvm_book3s.h    |    2 +-
 arch/powerpc/include/asm/kvm_host.h      |   15 +-
 arch/powerpc/include/asm/kvm_para.h      |  135 ++++++++-
 arch/powerpc/include/asm/kvm_ppc.h       |    1 +
 arch/powerpc/kernel/Makefile             |    2 +
 arch/powerpc/kernel/asm-offsets.c        |   18 +-
 arch/powerpc/kernel/kvm.c                |  485 ++++++++++++++++++++++++++++++
 arch/powerpc/kernel/kvm_emul.S           |  247 +++++++++++++++
 arch/powerpc/kvm/44x.c                   |    7 +
 arch/powerpc/kvm/44x_tlb.c               |    8 +-
 arch/powerpc/kvm/book3s.c                |  188 ++++++++----
 arch/powerpc/kvm/book3s_32_mmu.c         |   28 ++-
 arch/powerpc/kvm/book3s_32_mmu_host.c    |    6 +-
 arch/powerpc/kvm/book3s_64_mmu.c         |   42 +++-
 arch/powerpc/kvm/book3s_64_mmu_host.c    |   13 +-
 arch/powerpc/kvm/book3s_emulate.c        |   25 +-
 arch/powerpc/kvm/book3s_paired_singles.c |   11 +-
 arch/powerpc/kvm/booke.c                 |   83 ++++--
 arch/powerpc/kvm/booke.h                 |    6 +-
 arch/powerpc/kvm/booke_emulate.c         |   14 +-
 arch/powerpc/kvm/booke_interrupts.S      |    3 +-
 arch/powerpc/kvm/e500.c                  |    7 +
 arch/powerpc/kvm/e500_tlb.c              |   12 +-
 arch/powerpc/kvm/e500_tlb.h              |    2 +-
 arch/powerpc/kvm/emulate.c               |   36 ++-
 arch/powerpc/kvm/powerpc.c               |   84 +++++-
 arch/powerpc/platforms/Kconfig           |   10 +
 arch/x86/include/asm/kvm_para.h          |    6 +
 include/linux/kvm.h                      |   11 +
 include/linux/kvm_para.h                 |    7 +-
 32 files changed, 1538 insertions(+), 179 deletions(-)
 create mode 100644 Documentation/kvm/ppc-pv.txt
 create mode 100644 arch/powerpc/kernel/kvm.c
 create mode 100644 arch/powerpc/kernel/kvm_emul.S