• James Hogan's avatar
    KVM: MIPS/MMU: Use generic dirty log & protect helper · e88643ba
    James Hogan authored
    MIPS hasn't up to this point properly supported dirty page logging, as
    pages in slots with dirty logging enabled aren't made clean, and tlbmod
    exceptions from writes to clean pages have been assumed to be due to
    guest TLB protection and unconditionally passed to the guest.
    
    Use the generic dirty logging helper kvm_get_dirty_log_protect() to
    properly implement kvm_vm_ioctl_get_dirty_log(), similar to how ARM
    does. This uses xchg to clear the dirty bits when reading them, rather
    than wiping them out afterwards with a memset, which would potentially
    wipe recently set bits that weren't caught by kvm_get_dirty_log(). It
    also makes the pages clean again using the
    kvm_arch_mmu_enable_log_dirty_pt_masked() architecture callback so that
    further writes after the shadow memslot is flushed will trigger tlbmod
    exceptions and dirty handling.
    Signed-off-by: default avatarJames Hogan <james.hogan@imgtec.com>
    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
    e88643ba
mips.c 44.3 KB