linux-mips.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/30] KVM: MIPS: Implement GVA page tables
@ 2017-01-06  1:32 James Hogan
  2017-01-06  1:32 ` James Hogan
                   ` (30 more replies)
  0 siblings, 31 replies; 67+ messages in thread
From: James Hogan @ 2017-01-06  1:32 UTC (permalink / raw)
  To: linux-mips
  Cc: James Hogan, Paolo Bonzini, Radim Krčmář,
	Ralf Baechle, kvm, linux-mm

Note: My intention is to take this series via the MIPS KVM tree, with a
topic branch for the MIPS architecture changes, so acks welcome for the
relevant parts (mainly patches 1-4, 15, 28), and please don't apply yet.

This series primarily implements GVA->HPA page tables for MIPS T&E KVM
implementation, and a fast TLB refill handler generated at runtime using
uasm (sharing MIPS arch code to do this), accompanied by a bunch of
related cleanups. There are several solid advantages of this:

- An optimised TLB refill handler will be much faster than using the
  slow exit path through C code. It also avoids repeated guest TLB
  lookups for guest mapped addresses that are evicted from the host TLB
  (which are currently implemented as a linear walk through the guest
  TLB array).

- The TLB refill handler can be pretty much reused in future for VZ, to
  fill the root TLB with GPA->HPA mappings from a soon to be implemented
  GPA page table.

- Although not enabled yet, it potentially allows page table walker
  hardware (HTW) to be used during guest execution (both for VZ GPA
  mappings, and potentially T&E GVA mappings) further reducing TLB
  refill overhead.

- It improves the robustness of direct access to guest memory by KVM,
  i.e. reading guest instructions for emulation, writing guest
  instructions for dynamic translation, and emulating CACHE
  instructions. This is because the standard userland memory accessors
  can be used, allowing the host kernel TLB refill handler to safely
  fill from the GVA page table, allowing faults to be sanely detected,
  and allowing it to work when EVA is enabled (which requires different
  instructions to be used when accessing the user address space).

The main disadvantage is a higher flushing overhead when the guest ASID
is changed, due to the need to walk and invalidate GVA page tables
(since we only manage a single GVA page table for each guest privilege
mode, across all guest ASIDs).

The patches are roughly grouped as follows:

Patches 1-4:
  These are generic or MIPS architecture changes needed by the later
  patches, mainly to expose the existing MIPS TLB exception generation
  cade to KVM. As I mentioned above I intend to combine the MIPS ones
  into a topic branch which can be merged into both the MIPS
  architecture tree and the MIPS KVM tree.

Patches 5-13:
  These are preliminary MIPS KVM changes and cleanups.

Patches 14-25:
  These incrementally add GVA page table support, allocating the GVA
  page tables, adding the fast TLB refill handler, addng page table
  invalidation, and finally converting guest fault handling (KSeg0, TLB
  mapped, and commpage) to use the GVA page table rather than injecting
  entries directly into the host TLB.

Patches 26-27:
  These switch to using uaccess and protected cache ops, which fixes KVM
  on EVA enabled host kernels.

Patches 28-30:
  These make some final cleanups.

Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: "Radim Krčmář" <rkrcmar@redhat.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: linux-mips@linux-mips.org
Cc: kvm@vger.kernel.org
Cc: linux-mm@kvack.org

James Hogan (30):
  mm: Export init_mm for MIPS KVM use of pgd_alloc()
  MIPS: Export pgd/pmd symbols for KVM
  MIPS: uasm: Add include guards in asm/uasm.h
  MIPS: Export some tlbex internals for KVM to use
  KVM: MIPS: Drop partial KVM_NMI implementation
  KVM: MIPS/MMU: Simplify ASID restoration
  KVM: MIPS: Convert get/set_regs -> vcpu_load/put
  KVM: MIPS/MMU: Move preempt/ASID handling to implementation
  KVM: MIPS: Remove duplicated ASIDs from vcpu
  KVM: MIPS: Add vcpu_run() & vcpu_reenter() callbacks
  KVM: MIPS/T&E: Restore host asid on return to host
  KVM: MIPS/T&E: active_mm = init_mm in guest context
  KVM: MIPS: Wire up vcpu uninit
  KVM: MIPS/T&E: Allocate GVA -> HPA page tables
  KVM: MIPS/T&E: Activate GVA page tables in guest context
  KVM: MIPS: Support NetLogic KScratch registers
  KVM: MIPS: Add fast path TLB refill handler
  KVM: MIPS/TLB: Fix off-by-one in TLB invalidate
  KVM: MIPS/TLB: Generalise host TLB invalidate to kernel ASID
  KVM: MIPS/MMU: Invalidate GVA PTs on ASID changes
  KVM: MIPS/MMU: Invalidate stale GVA PTEs on TLBW
  KVM: MIPS/MMU: Convert KSeg0 faults to page tables
  KVM: MIPS/MMU: Convert TLB mapped faults to page tables
  KVM: MIPS/MMU: Convert commpage fault handling to page tables
  KVM: MIPS: Drop vm_init() callback
  KVM: MIPS: Use uaccess to read/modify guest instructions
  KVM: MIPS/Emulate: Fix CACHE emulation for EVA hosts
  KVM: MIPS/TLB: Drop kvm_local_flush_tlb_all()
  KVM: MIPS/Emulate: Drop redundant TLB flushes on exceptions
  KVM: MIPS/MMU: Drop kvm_get_new_mmu_context()

 arch/mips/include/asm/kvm_host.h    |  76 ++--
 arch/mips/include/asm/mmu_context.h |   9 +-
 arch/mips/include/asm/tlbex.h       |  26 +-
 arch/mips/include/asm/uasm.h        |   5 +-
 arch/mips/kvm/dyntrans.c            |  28 +-
 arch/mips/kvm/emulate.c             |  59 +--
 arch/mips/kvm/entry.c               | 141 +++++++-
 arch/mips/kvm/mips.c                | 130 +------
 arch/mips/kvm/mmu.c                 | 545 +++++++++++++++++------------
 arch/mips/kvm/tlb.c                 | 225 +-----------
 arch/mips/kvm/trap_emul.c           | 220 +++++++++++-
 arch/mips/mm/init.c                 |   1 +-
 arch/mips/mm/pgtable-32.c           |   1 +-
 arch/mips/mm/pgtable-64.c           |   3 +-
 arch/mips/mm/tlbex.c                |  38 +-
 mm/init-mm.c                        |   2 +-
 16 files changed, 861 insertions(+), 648 deletions(-)
 create mode 100644 arch/mips/include/asm/tlbex.h

-- 
git-series 0.8.10

^ permalink raw reply	[flat|nested] 67+ messages in thread

end of thread, other threads:[~2017-01-17 16:27 UTC | newest]

Thread overview: 67+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-06  1:32 [PATCH 0/30] KVM: MIPS: Implement GVA page tables James Hogan
2017-01-06  1:32 ` James Hogan
2017-01-06  1:32 ` [PATCH 1/30] mm: Export init_mm for MIPS KVM use of pgd_alloc() James Hogan
2017-01-06  1:32   ` James Hogan
2017-01-17 16:23   ` Ralf Baechle
2017-01-17 16:27   ` Ralf Baechle
2017-01-06  1:32 ` [PATCH 2/30] MIPS: Export pgd/pmd symbols for KVM James Hogan
2017-01-06  1:32   ` James Hogan
2017-01-17 16:24   ` Ralf Baechle
2017-01-06  1:32 ` [PATCH 3/30] MIPS: uasm: Add include guards in asm/uasm.h James Hogan
2017-01-06  1:32   ` James Hogan
2017-01-17 16:25   ` Ralf Baechle
2017-01-06  1:32 ` [PATCH 4/30] MIPS: Export some tlbex internals for KVM to use James Hogan
2017-01-06  1:32   ` James Hogan
2017-01-17 16:26   ` Ralf Baechle
2017-01-06  1:32 ` [PATCH 5/30] KVM: MIPS: Drop partial KVM_NMI implementation James Hogan
2017-01-06  1:32   ` James Hogan
2017-01-06  1:32 ` [PATCH 6/30] KVM: MIPS/MMU: Simplify ASID restoration James Hogan
2017-01-06  1:32   ` James Hogan
2017-01-06  1:32 ` [PATCH 7/30] KVM: MIPS: Convert get/set_regs -> vcpu_load/put James Hogan
2017-01-06  1:32   ` James Hogan
2017-01-06  1:32 ` [PATCH 8/30] KVM: MIPS/MMU: Move preempt/ASID handling to implementation James Hogan
2017-01-06  1:32   ` James Hogan
2017-01-06  1:32 ` [PATCH 9/30] KVM: MIPS: Remove duplicated ASIDs from vcpu James Hogan
2017-01-06  1:32   ` James Hogan
2017-01-06  1:32 ` [PATCH 10/30] KVM: MIPS: Add vcpu_run() & vcpu_reenter() callbacks James Hogan
2017-01-06  1:32   ` James Hogan
2017-01-06  1:32 ` [PATCH 11/30] KVM: MIPS/T&E: Restore host asid on return to host James Hogan
2017-01-06  1:32   ` James Hogan
2017-01-06  1:32 ` [PATCH 12/30] KVM: MIPS/T&E: active_mm = init_mm in guest context James Hogan
2017-01-06  1:32   ` James Hogan
2017-01-06  1:32 ` [PATCH 13/30] KVM: MIPS: Wire up vcpu uninit James Hogan
2017-01-06  1:32   ` James Hogan
2017-01-06  1:32 ` [PATCH 14/30] KVM: MIPS/T&E: Allocate GVA -> HPA page tables James Hogan
2017-01-06  1:32   ` James Hogan
2017-01-06  1:32 ` [PATCH 15/30] KVM: MIPS/T&E: Activate GVA page tables in guest context James Hogan
2017-01-06  1:32   ` James Hogan
2017-01-06  1:32 ` [PATCH 16/30] KVM: MIPS: Support NetLogic KScratch registers James Hogan
2017-01-06  1:32   ` James Hogan
2017-01-06  1:32 ` [PATCH 17/30] KVM: MIPS: Add fast path TLB refill handler James Hogan
2017-01-06  1:32   ` James Hogan
2017-01-06  1:32 ` [PATCH 18/30] KVM: MIPS/TLB: Fix off-by-one in TLB invalidate James Hogan
2017-01-06  1:32   ` James Hogan
2017-01-06  1:32 ` [PATCH 19/30] KVM: MIPS/TLB: Generalise host TLB invalidate to kernel ASID James Hogan
2017-01-06  1:32   ` James Hogan
2017-01-06  1:32 ` [PATCH 20/30] KVM: MIPS/MMU: Invalidate GVA PTs on ASID changes James Hogan
2017-01-06  1:32   ` James Hogan
2017-01-06  1:32 ` [PATCH 21/30] KVM: MIPS/MMU: Invalidate stale GVA PTEs on TLBW James Hogan
2017-01-06  1:32   ` James Hogan
2017-01-06  1:32 ` [PATCH 22/30] KVM: MIPS/MMU: Convert KSeg0 faults to page tables James Hogan
2017-01-06  1:32   ` James Hogan
2017-01-06  1:32 ` [PATCH 23/30] KVM: MIPS/MMU: Convert TLB mapped " James Hogan
2017-01-06  1:32   ` James Hogan
2017-01-06  1:32 ` [PATCH 24/30] KVM: MIPS/MMU: Convert commpage fault handling " James Hogan
2017-01-06  1:32   ` James Hogan
2017-01-06  1:32 ` [PATCH 25/30] KVM: MIPS: Drop vm_init() callback James Hogan
2017-01-06  1:32   ` James Hogan
2017-01-06  1:32 ` [PATCH 26/30] KVM: MIPS: Use uaccess to read/modify guest instructions James Hogan
2017-01-06  1:32   ` James Hogan
2017-01-06  1:32 ` [PATCH 27/30] KVM: MIPS/Emulate: Fix CACHE emulation for EVA hosts James Hogan
2017-01-06  1:32   ` James Hogan
2017-01-06  1:33 ` [PATCH 28/30] KVM: MIPS/TLB: Drop kvm_local_flush_tlb_all() James Hogan
2017-01-06  1:33   ` James Hogan
2017-01-06  1:33 ` [PATCH 29/30] KVM: MIPS/Emulate: Drop redundant TLB flushes on exceptions James Hogan
2017-01-06  1:33   ` James Hogan
2017-01-06  1:33 ` [PATCH 30/30] KVM: MIPS/MMU: Drop kvm_get_new_mmu_context() James Hogan
2017-01-06  1:33   ` James Hogan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).