Note: My intention is to take this series via the MIPS KVM tree. This series is based on my other series posted this cycle: [0/10] KVM: MIPS: Implement GVA page tables and shadow flushing [0/3] KVM: MIPS: Use CP0_BadInstr[P] for emulation [0/30] KVM: MIPS: Implement GVA page tables This series adds proper dirty page logging, KVM_CAP_SYNC_MMU, and KVM_CAP_READONLY_MEM support to MIPS KVM. The existing dirty page logging support (integral to live migration) was basically incomplete as pages were never marked read only or recorded as being dirty on a TLB modified exception. This series incrementally adds proper support, using the dirty bit in the GPA and GVA page tables to trigger TLB modified exceptions. Support is added for KVM_CAP_SYNC_MMU, which adds MMU notifiers so that KVM can react to asynchronous (and synchronous) host virtual MM changes. This allows for several features to work with guest RAM which require mappings to be altered or protected, such as copy-on-write, KSM (Kernel Samepage Merging), idle page tracking, memory swapping, and guest memory ballooning, as well as paving the way for KVM_CAP_READONLY_MEM. Finally support is added for read only memory regions (KVM_CAP_READONLY_MEM), which can be supported fairly minimally once dirty page logging and KVM_CAP_SYNC_MMU are in place. This allows memory regions to be marked read only to the guest so that reads work but writes trigger MMIO. The patches are roughly grouped as follows: Patches 1-2: Preliminary changes for readonly regions / dirty logging. Patches 3-5: Add handling of read only regions (or areas with no region) as MMIO, and also call fault handling for dirty logging. Patches 6-11: Incrementally add proper dirty logging support, first making ranges of GPA clean when log read or region is made readonly, then adding the fast path fault handling for dirty logging, and finally transferring GPA protection bits (including dirty) across to GVA page tables so they take effect. Patch 12: Add KVM_CAP_SYNC_MMU support. Patch 13: Enable KVM_CAP_READONLY_MEM. This is after KVM_CAP_SYNC_MMU support as it needs to use gfn_to_pfn_prot() to know whether the GFN is read only, which opens up the possibility of getting copy-on-write enabled pages, which aren't safe without KVM_CAP_SYNC_MMU since the guest mappings wouldn't get updated after a copy-on-write took place. Cc: Paolo Bonzini <pbonzini@xxxxxxxxxx> Cc: "Radim Krčmář" <rkrcmar@xxxxxxxxxx> Cc: Ralf Baechle <ralf@xxxxxxxxxxxxxx> Cc: linux-mips@xxxxxxxxxxxxxx Cc: kvm@xxxxxxxxxxxxxxx James Hogan (13): 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 arch/mips/include/asm/kvm_host.h | 28 +- arch/mips/include/uapi/asm/kvm.h | 2 +- arch/mips/kvm/Kconfig | 2 +- arch/mips/kvm/emulate.c | 38 +-- arch/mips/kvm/mips.c | 68 ++-- arch/mips/kvm/mmu.c | 546 ++++++++++++++++++++++++++++---- arch/mips/kvm/trap_emul.c | 203 +++++++----- 7 files changed, 693 insertions(+), 194 deletions(-) -- git-series 0.8.10 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html