Skip to content

KVM: MMU: fast invalidate all mmio sptes

Xiao Guangrong kvm lkml 3 versions – Applied

Status from this message: Applied all to queue for now. Will graduate to next after doing some

Get series with b4
b4 am 1370595088-3315-1-git-send-email-xiaoguangrong@linux.vnet.ibm.com

Versions newest first · linked by author and title

  1. v3 Latest6 patches 25 repliesApplied
  2. v26 patches 6 repliesSuperseded
  3. v15 patches 23 repliesSuperseded

Changes in v3 from the cover letter

All of these changes are from Gleb's review:
1) rename RET_MMIO_PF_EMU to RET_MMIO_PF_EMULATE.
2) smartly adjust kvm generation number in kvm_current_mmio_generatio()

Patches in v3 Applied

#Subject and filesSizeRepliesApplied
1/6KVM: MMU: retain more available bits on mmio sptearch/x86/kvm/vmx.c arch/x86/kvm/x86.c+9 -30 replies
2/6KVM: MMU: store generation-number into mmio sptearch/x86/kvm/mmu.c arch/x86/kvm/mmutrace.h arch/x86/kvm/paging_tmpl.h+56 -150 replies
3/6KVM: MMU: make return value of mmio page fault handler more readablearch/x86/kvm/mmu.c arch/x86/kvm/mmu.h arch/x86/kvm/vmx.c+21 -124 replies
4/6KVM: MMU: fast invalidate all mmio sptesarch/x86/include/asm/kvm_host.h arch/x86/kvm/mmu.c arch/x86/kvm/mmu.h +3 more+61 -148 replies
5/6KVM: MMU: add tracepoint for check_mmio_sptearch/x86/kvm/mmu.c arch/x86/kvm/mmutrace.h+31 -20 replies
6/6KVM: MMU: init kvm generation close to mmio wrap-around valuearch/x86/kvm/mmu.c+6 -10 replies

Reviews trailers per patch

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

Read the v3 thread

Cover letter [PATCH v3 0/6] KVM: MMU: fast invalidate all mmio sptes

Changelog:
V3:
All of these changes are from Gleb's review:
1) rename RET_MMIO_PF_EMU to RET_MMIO_PF_EMULATE.
2) smartly adjust kvm generation number in kvm_current_mmio_generatio()

     to avoid kvm_memslots->generation overflow.

V2:
- rename kvm_mmu_invalid_mmio_spte to kvm_mmu_invalid_mmio_sptes
- use kvm->memslots->generation as kvm global generation-number
- fix comment and codestyle
- init kvm generation close to mmio wrap-around value
- keep kvm_mmu_zap_mmio_sptes

The current way is holding hot mmu-lock and walking all shadow pages, this is not scale. This patchset tries to introduce a very simple and scale way to fast invalidate all mmio sptes - it need not walk any shadow pages and hold any locks.

The idea is simple:
KVM maintains a global mmio valid generation-number which is stored in kvm->memslots.generation and every mmio spte stores the current global generation-number into his available bits when it is created

When KVM need zap all mmio sptes, it just simply increase the global generation-number. When guests do mmio access, KVM intercepts a MMIO #PF then it walks the shadow page table and get the mmio spte. If the generation-number on the spte does not equal the global generation-number, it will go to the normal #PF handler to update the mmio spte

Since 19 bits are used to store generation-number on mmio spte, we zap all mmio sptes when the number is round

Xiao Guangrong (6):
KVM: MMU: retain more available bits on mmio spte
KVM: MMU: store generation-number into mmio spte
KVM: MMU: make return value of mmio page fault handler more readable
KVM: MMU: fast invalidate all mmio sptes
KVM: MMU: add tracepoint for check_mmio_spte
KVM: MMU: init kvm generation close to mmio wrap-around value

 arch/x86/include/asm/kvm_host.h |   2 +-
 arch/x86/kvm/mmu.c              | 131 ++++++++++++++++++++++++++++++++--------
 arch/x86/kvm/mmu.h              |  17 ++++++
 arch/x86/kvm/mmutrace.h         |  34 +++++++++--
 arch/x86/kvm/paging_tmpl.h      |  10 ++-
 arch/x86/kvm/vmx.c              |  12 ++--
 arch/x86/kvm/x86.c              |  11 +++-
 7 files changed, 177 insertions(+), 40 deletions(-)
Signature · 1 line
1.8.1.4