Skip to contentSkip to conversation

KVM: MIPS: GVA/GPA page tables, dirty logging, SYNC_MMU etc

GIT PULL James Hogan 2 participants 2 messages Feb 3, 2017 – Feb 7, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi Paolo, Radim,

The following changes since commit 0b4c208d443ba2af82b4c70f99ca8df31e9a0020:

Revert "KVM: nested VMX: disable perf cpuid reporting" (2017-01-20 22:18:55 +0100)

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/jhogan/kvm-mips.git tags/kvm_mips_4.11_1

for you to fetch changes up to 12ed1faece3f141c2604b5b3a8377ba71d23ec9d:

KVM: MIPS: Allow multiple VCPUs to be created (2017-02-03 15:21:34 +0000)

It is already included in linux-next (though I did tweak one of the commit messages just now to remove a patch changelog I had accidentally left in, with no changes to the code).

It includes a merge of my mips branch in the same repo, which is based on v4.10-rc2 and contains the general MIPS changes in the GVA/GPA page tables series, for Ralf to also merge if he likes.

Cheers
James

----------------------------------------------------------------
KVM: MIPS: GVA/GPA page tables, dirty logging, SYNC_MMU etc

Numerous MIPS KVM fixes, improvements, and features for 4.11, many of which continue to pave the way for VZ support, the most interesting of which are:

- Add GVA->HPA page tables for T&E, to cache GVA mappings.
- Generate fast-path TLB refill exception handler which loads host TLB entries from GVA page table, avoiding repeated guest memory translation and guest TLB lookups.
- Use uaccess macros when T&E needs to access guest memory, which with GVA page tables and the Linux TLB refill handler improves robustness against TLB faults and fixes EVA hosts.
- Use BadInstr/BadInstrP registers when available to obtain instruction encodings after a synchronous trap.
- Add GPA->HPA page tables to replace the inflexible linear array, allowing for multiple sparsely arranged memory regions.
- Properly implement dirty page logging.
- Add KVM_CAP_SYNC_MMU support so that changes in GPA mappings become effective in guests even if they are already running, allowing for copy-on-write, KSM, idle page tracking, swapping, and guest memory ballooning.
- Add KVM_CAP_READONLY_MEM support, so writes to specified memory regions are treated as MMIO.
- Implement proper CP0_EBase support in T&E.
- Expose a few more missing CP0 registers to userland.
- Add KVM_CAP_NR_VCPUS and KVM_CAP_MAX_VCPUS support, and allow up to 8 VCPUs to be created in a VM.
- Various cleanups and dropping of dead and duplicated code.

----------------------------------------------------------------
James Hogan (63):
MIPS: Move pgd_alloc() out of header
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
MIPS: Add return errors to protected cache ops
Merge MIPS prerequisites
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()
KVM: MIPS/T&E: Don't treat code fetch faults as MMIO
KVM: MIPS: Improve kvm_get_inst() error return
KVM: MIPS: Use CP0_BadInstr[P] for emulation
KVM: MIPS/MMU: Convert guest physical map to page table
KVM: MIPS: Update vcpu->mode and vcpu->cpu
KVM: MIPS/T&E: Handle TLB invalidation requests
KVM: MIPS/T&E: Reduce stale ASID checks
KVM: MIPS/T&E: Add lockless GVA access helpers
KVM: MIPS/T&E: Use lockless GVA helpers for dyntrans
KVM: MIPS/MMU: Use lockless GVA helpers for get_inst()
KVM: MIPS/Emulate: Use lockless GVA helpers for cache emulation
KVM: MIPS: Implement kvm_arch_flush_shadow_all/memslot
KVM: MIPS/T&E: Ignore user writes to CP0_Config7
KVM: MIPS: Pass type of fault down to kvm_mips_map_page()
KVM: MIPS/T&E: Abstract bad access handling
KVM: MIPS/T&E: Treat unhandled guest KSeg0 as MMIO
KVM: MIPS/T&E: Handle read only GPA in TLB mod
KVM: MIPS/MMU: Add GPA PT mkclean helper
KVM: MIPS/MMU: Use generic dirty log & protect helper
KVM: MIPS: Clean & flush on dirty page logging enable
KVM: MIPS/MMU: Handle dirty logging on GPA faults
KVM: MIPS/MMU: Pass GPA PTE bits to KSeg0 GVA PTEs
KVM: MIPS/MMU: Pass GPA PTE bits to mapped GVA PTEs
KVM: MIPS/MMU: Implement KVM_CAP_SYNC_MMU
KVM: MIPS: Claim KVM_CAP_READONLY_MEM support
KVM: MIPS/T&E: Move CP0 register access into T&E
KVM: MIPS/T&E: Implement CP0_EBase register
KVM: MIPS/T&E: Default to reset vector
KVM: MIPS/T&E: Expose CP0_EntryLo0/1 registers
KVM: MIPS/T&E: Expose read-only CP0_IntCtl register
KVM: MIPS: Allow multiple VCPUs to be created

Markus Elfring (1):
MIPS: KVM: Return directly after a failed copy_from_user() in kvm_arch_vcpu_ioctl()

 Documentation/virtual/kvm/api.txt   |   10 +
 arch/mips/include/asm/kvm_host.h    |  183 +++--
 arch/mips/include/asm/mmu_context.h |    9 +-
 arch/mips/include/asm/pgalloc.h     |   16 +-
 arch/mips/include/asm/r4kcache.h    |   55 +-
 arch/mips/include/asm/tlbex.h       |   26 +
 arch/mips/include/asm/uasm.h        |    5 +
 arch/mips/include/uapi/asm/kvm.h    |    2 +
 arch/mips/kvm/Kconfig               |    2 +
 arch/mips/kvm/dyntrans.c            |   50 +-
 arch/mips/kvm/emulate.c             |  432 ++++++------
 arch/mips/kvm/entry.c               |  155 +++-
 arch/mips/kvm/interrupt.c           |    5 +-
 arch/mips/kvm/mips.c                |  496 ++++---------
 arch/mips/kvm/mmu.c                 | 1335 ++++++++++++++++++++++++++++-------
 arch/mips/kvm/tlb.c                 |  299 ++------
 arch/mips/kvm/trap_emul.c           |  740 ++++++++++++++++---
 arch/mips/mm/Makefile               |    2 +-
 arch/mips/mm/init.c                 |    1 +
 arch/mips/mm/pgtable-64.c           |    2 +
 arch/mips/mm/pgtable.c              |   25 +
 arch/mips/mm/tlbex.c                |   38 +-
 22 files changed, 2611 insertions(+), 1277 deletions(-)
 create mode 100644 arch/mips/include/asm/tlbex.h
 create mode 100644 arch/mips/mm/pgtable.c
maintainer
#1 lore raw
Quoted 142 lines · James Hogan

Hi Paolo, Radim,

The following changes since commit 0b4c208d443ba2af82b4c70f99ca8df31e9a0020:

Revert "KVM: nested VMX: disable perf cpuid reporting" (2017-01-20 22:18:55 +0100)

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/jhogan/kvm-mips.git tags/kvm_mips_4.11_1

for you to fetch changes up to 12ed1faece3f141c2604b5b3a8377ba71d23ec9d:

KVM: MIPS: Allow multiple VCPUs to be created (2017-02-03 15:21:34 +0000)

It is already included in linux-next (though I did tweak one of the commit messages just now to remove a patch changelog I had accidentally left in, with no changes to the code).

It includes a merge of my mips branch in the same repo, which is based on v4.10-rc2 and contains the general MIPS changes in the GVA/GPA page tables series, for Ralf to also merge if he likes.

Cheers
James

----------------------------------------------------------------
KVM: MIPS: GVA/GPA page tables, dirty logging, SYNC_MMU etc

Numerous MIPS KVM fixes, improvements, and features for 4.11, many of which continue to pave the way for VZ support, the most interesting of which are:

- Add GVA->HPA page tables for T&E, to cache GVA mappings.
- Generate fast-path TLB refill exception handler which loads host TLB entries from GVA page table, avoiding repeated guest memory translation and guest TLB lookups.
- Use uaccess macros when T&E needs to access guest memory, which with GVA page tables and the Linux TLB refill handler improves robustness against TLB faults and fixes EVA hosts.
- Use BadInstr/BadInstrP registers when available to obtain instruction encodings after a synchronous trap.
- Add GPA->HPA page tables to replace the inflexible linear array, allowing for multiple sparsely arranged memory regions.
- Properly implement dirty page logging.
- Add KVM_CAP_SYNC_MMU support so that changes in GPA mappings become effective in guests even if they are already running, allowing for copy-on-write, KSM, idle page tracking, swapping, and guest memory ballooning.
- Add KVM_CAP_READONLY_MEM support, so writes to specified memory regions are treated as MMIO.
- Implement proper CP0_EBase support in T&E.
- Expose a few more missing CP0 registers to userland.
- Add KVM_CAP_NR_VCPUS and KVM_CAP_MAX_VCPUS support, and allow up to 8 VCPUs to be created in a VM.
- Various cleanups and dropping of dead and duplicated code.

----------------------------------------------------------------
James Hogan (63):
MIPS: Move pgd_alloc() out of header
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
MIPS: Add return errors to protected cache ops
Merge MIPS prerequisites
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()
KVM: MIPS/T&E: Don't treat code fetch faults as MMIO
KVM: MIPS: Improve kvm_get_inst() error return
KVM: MIPS: Use CP0_BadInstr[P] for emulation
KVM: MIPS/MMU: Convert guest physical map to page table
KVM: MIPS: Update vcpu->mode and vcpu->cpu
KVM: MIPS/T&E: Handle TLB invalidation requests
KVM: MIPS/T&E: Reduce stale ASID checks
KVM: MIPS/T&E: Add lockless GVA access helpers
KVM: MIPS/T&E: Use lockless GVA helpers for dyntrans
KVM: MIPS/MMU: Use lockless GVA helpers for get_inst()
KVM: MIPS/Emulate: Use lockless GVA helpers for cache emulation
KVM: MIPS: Implement kvm_arch_flush_shadow_all/memslot
KVM: MIPS/T&E: Ignore user writes to CP0_Config7
KVM: MIPS: Pass type of fault down to kvm_mips_map_page()
KVM: MIPS/T&E: Abstract bad access handling
KVM: MIPS/T&E: Treat unhandled guest KSeg0 as MMIO
KVM: MIPS/T&E: Handle read only GPA in TLB mod
KVM: MIPS/MMU: Add GPA PT mkclean helper
KVM: MIPS/MMU: Use generic dirty log & protect helper
KVM: MIPS: Clean & flush on dirty page logging enable
KVM: MIPS/MMU: Handle dirty logging on GPA faults
KVM: MIPS/MMU: Pass GPA PTE bits to KSeg0 GVA PTEs
KVM: MIPS/MMU: Pass GPA PTE bits to mapped GVA PTEs
KVM: MIPS/MMU: Implement KVM_CAP_SYNC_MMU
KVM: MIPS: Claim KVM_CAP_READONLY_MEM support
KVM: MIPS/T&E: Move CP0 register access into T&E
KVM: MIPS/T&E: Implement CP0_EBase register
KVM: MIPS/T&E: Default to reset vector
KVM: MIPS/T&E: Expose CP0_EntryLo0/1 registers
KVM: MIPS/T&E: Expose read-only CP0_IntCtl register
KVM: MIPS: Allow multiple VCPUs to be created

Markus Elfring (1):
MIPS: KVM: Return directly after a failed copy_from_user() in kvm_arch_vcpu_ioctl()

 Documentation/virtual/kvm/api.txt   |   10 +
 arch/mips/include/asm/kvm_host.h    |  183 +++--
 arch/mips/include/asm/mmu_context.h |    9 +-
 arch/mips/include/asm/pgalloc.h     |   16 +-
 arch/mips/include/asm/r4kcache.h    |   55 +-
 arch/mips/include/asm/tlbex.h       |   26 +
 arch/mips/include/asm/uasm.h        |    5 +
 arch/mips/include/uapi/asm/kvm.h    |    2 +
 arch/mips/kvm/Kconfig               |    2 +
 arch/mips/kvm/dyntrans.c            |   50 +-
 arch/mips/kvm/emulate.c             |  432 ++++++------
 arch/mips/kvm/entry.c               |  155 +++-
 arch/mips/kvm/interrupt.c           |    5 +-
 arch/mips/kvm/mips.c                |  496 ++++---------
 arch/mips/kvm/mmu.c                 | 1335 ++++++++++++++++++++++++++++-------
 arch/mips/kvm/tlb.c                 |  299 ++------
 arch/mips/kvm/trap_emul.c           |  740 ++++++++++++++++---
Quoted 9 lines
 arch/mips/mm/Makefile               |    2 +-
 arch/mips/mm/init.c                 |    1 +
 arch/mips/mm/pgtable-64.c           |    2 +
 arch/mips/mm/pgtable.c              |   25 +
 arch/mips/mm/tlbex.c                |   38 +-
 22 files changed, 2611 insertions(+), 1277 deletions(-)
 create mode 100644 arch/mips/include/asm/tlbex.h
 create mode 100644 arch/mips/mm/pgtable.c

Pulled, thanks.

Paolo