KVM: MMU: fix validation of mmio page fault
authorXiao Guangrong <guangrong.xiao@linux.intel.com>
Wed, 5 Aug 2015 04:04:19 +0000 (12:04 +0800)
committerSasha Levin <sasha.levin@oracle.com>
Wed, 28 Oct 2015 02:14:46 +0000 (22:14 -0400)
commit2c333eb66bca69bfadf5ae3424a3fb32037b5d48
tree8a8101dd46e7fa69ed7db8f73f6bd9c32b9ccb11
parentc22fac8485a145a8e8b2634839c7a33bc334d16b
KVM: MMU: fix validation of mmio page fault

[ Upstream commit 6f691251c0350ac52a007c54bf3ef62e9d8cdc5e ]

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: Pavel Shirshov <ru.pchel@gmail.com>
Tested-by: Pavel Shirshov <ru.pchel@gmail.com>
Signed-off-by: Xiao Guangrong <guangrong.xiao@linux.intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
arch/x86/kvm/mmu.c