Skip to content

KVM PPC PV framework

Alexander Graf kvm kvm-ppc linuxppc-dev 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest16 of 27 patches 25 repliesIn review

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

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

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
2/27KVM: PPC: Convert MSR to shared pagearch/powerpc/include/asm/kvm_host.h arch/powerpc/include/asm/kvm_para.h arch/powerpc/kernel/asm-offsets.c +15 more+93 -840 replies
3/27KVM: PPC: Convert DSISR to shared pagearch/powerpc/include/asm/kvm_book3s.h arch/powerpc/include/asm/kvm_para.h arch/powerpc/kvm/book3s.c +2 more+11 -100 replies
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
8/27KVM: PPC: Add PV guest critical sectionsarch/powerpc/include/asm/kvm_para.h arch/powerpc/kvm/book3s.c arch/powerpc/kvm/booke.c+32 -20 replies
9/27KVM: PPC: Add PV guest scratch registersarch/powerpc/include/asm/kvm_para.h+3 -00 replies
11/27KVM: PPC: Make RMO a definearch/powerpc/include/asm/kvm_host.h arch/powerpc/kvm/book3s.c+5 -21 reply
14/27KVM: PPC: Magic Page BookE supportarch/powerpc/kvm/booke.c arch/powerpc/kvm/e500_tlb.c+46 -23 replies
15/27KVM: PPC: Expose magic page support to guestarch/powerpc/include/asm/kvm_para.h arch/powerpc/kvm/powerpc.c+13 -00 replies
17/27KVM: PPC: Generic KVM PV guest supportarch/powerpc/kernel/Makefile arch/powerpc/kernel/asm-offsets.c arch/powerpc/kernel/kvm.c +2 more+88 -00 replies
18/27KVM: PPC: KVM PV guest stubsarch/powerpc/kernel/kvm.c+63 -00 replies
19/27KVM: PPC: PV instructions to loads and storesarch/powerpc/kernel/kvm.c+111 -00 replies
21/27KVM: PPC: Introduce kvm_tmp frameworkarch/powerpc/kernel/kvm.c+39 -20 replies
23/27KVM: PPC: PV assembler helpersarch/powerpc/kernel/kvm_emul.S+29 -00 replies
24/27KVM: PPC: PV mtmsrd L=1arch/powerpc/kernel/kvm.c arch/powerpc/kernel/kvm_emul.S+101 -00 replies
27/27KVM: PPC: Add Documentation about PV interfaceDocumentation/kvm/ppc-pv.txt+185 -017 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

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.

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

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 RMO a define
KVM: PPC: First magic page steps
KVM: PPC: Magic Page Book3s support
KVM: PPC: Magic Page BookE 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

 Documentation/kvm/ppc-pv.txt             |  185 ++++++++++++++
 arch/powerpc/include/asm/kvm_book3s.h    |    1 -
 arch/powerpc/include/asm/kvm_host.h      |   15 +-
 arch/powerpc/include/asm/kvm_para.h      |  121 +++++++++-
 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                |  408 ++++++++++++++++++++++++++++++
 arch/powerpc/kernel/kvm_emul.S           |  237 +++++++++++++++++
 arch/powerpc/kvm/44x.c                   |    7 +
 arch/powerpc/kvm/44x_tlb.c               |    8 +-
 arch/powerpc/kvm/book3s.c                |  165 ++++++++-----
 arch/powerpc/kvm/book3s_32_mmu.c         |   28 ++-
 arch/powerpc/kvm/book3s_32_mmu_host.c    |   16 +-
 arch/powerpc/kvm/book3s_64_mmu.c         |   42 +++-
 arch/powerpc/kvm/book3s_64_mmu_host.c    |   16 +-
 arch/powerpc/kvm/book3s_emulate.c        |   25 +-
 arch/powerpc/kvm/book3s_paired_singles.c |   11 +-
 arch/powerpc/kvm/booke.c                 |  113 +++++++--
 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              |   31 ++-
 arch/powerpc/kvm/e500_tlb.h              |    2 +-
 arch/powerpc/kvm/emulate.c               |   47 +++-
 arch/powerpc/kvm/powerpc.c               |   42 +++-
 arch/powerpc/platforms/Kconfig           |   10 +
 arch/x86/include/asm/kvm_para.h          |    6 +
 include/linux/kvm_para.h                 |    7 +-
 30 files changed, 1420 insertions(+), 174 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