• James Hogan's avatar
    MIPS: KVM: Fix mapped fault broken commpage handling · 0ef8db5d
    James Hogan authored
    commit c604cffa upstream.
    
    kvm_mips_handle_mapped_seg_tlb_fault() appears to map the guest page at
    virtual address 0 to PFN 0 if the guest has created its own mapping
    there. The intention is unclear, but it may have been an attempt to
    protect the zero page from being mapped to anything but the comm page in
    code paths you wouldn't expect from genuine commpage accesses (guest
    kernel mode cache instructions on that address, hitting trapping
    instructions when executing from that address with a coincidental TLB
    eviction during the KVM handling, and guest user mode accesses to that
    address).
    
    Fix this to check for mappings exactly at KVM_GUEST_COMMPAGE_ADDR (it
    may not be at address 0 since commit 42aa12e7 ("MIPS: KVM: Move
    commpage so 0x0 is unmapped")), and set the corresponding EntryLo to be
    interpreted as 0 (invalid).
    
    Fixes: 858dd5d4 ("KVM/MIPS32: MMU/TLB operations for the Guest.")
    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
    Cc: <stable@vger.kernel.org> # 3.10.x-
    Signed-off-by: default avatarRadim Krčmář <rkrcmar@redhat.com>
    [james.hogan@imgtec.com: Backport to v4.7]
    Signed-off-by: default avatarJames Hogan <james.hogan@imgtec.com>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    0ef8db5d
tlb.c 20.3 KB