• Xiao Guangrong's avatar
    KVM: MMU: fix validation of mmio page fault · 41e3025e
    Xiao Guangrong authored
    commit 6f691251 upstream.
    
    We got the bug that qemu complained with "KVM: unknown exit, hardware
    reason 31" and KVM shown these info:
    [84245.284948] EPT: Misconfiguration.
    [84245.285056] EPT: GPA: 0xfeda848
    [84245.285154] ept_misconfig_inspect_spte: spte 0x5eaef50107 level 4
    [84245.285344] ept_misconfig_inspect_spte: spte 0x5f5fadc107 level 3
    [84245.285532] ept_misconfig_inspect_spte: spte 0x5141d18107 level 2
    [84245.285723] ept_misconfig_inspect_spte: spte 0x52e40dad77 level 1
    
    This is because we got a mmio #PF and the handler see the mmio spte becomes
    normal (points to the ram page)
    
    However, this is valid after introducing fast mmio spte invalidation which
    increases the generation-number instead of zapping mmio sptes, a example
    is as follows:
    1. QEMU drops mmio region by adding a new memslot
    2. invalidate all mmio sptes
    3.
    
            VCPU 0                        VCPU 1
        access the invalid mmio spte
                                access the region originally was MMIO before
                                set the spte to the normal ram map
    
        mmio #PF
        check the spte and see it becomes normal ram mapping !!!
    
    This patch fixes the bug just by dropping the check in mmio handler, it's
    good for backport. Full check will be introduced in later patches
    Reported-by: default avatarPavel Shirshov <ru.pchel@gmail.com>
    Tested-by: default avatarPavel Shirshov <ru.pchel@gmail.com>
    Signed-off-by: default avatarXiao Guangrong <guangrong.xiao@linux.intel.com>
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    [bwh: Backported to 3.2: error code from handle_mmio_page_fault_common()
     was not named]
    Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
    41e3025e
mmu.c 97.6 KB