History

MIPS: KVM: Check for pfn noslot case

When mapping a page into the guest we error check using is_error_pfn(), however this doesn't detect a value of KVM_PFN_NOSLOT, indicating an error HVA for the page. This can only happen on MIPS right now due to unusual memslot management (e.g. being moved / removed / resized), or with an Enhanced Virtual Memory (EVA) configuration where the default KVM_HVA_ERR_* and kvm_is_error_hva() definitions are unsuitable (fixed in a later patch). This case will be treated as a pfn of zero, mapping the first page of physical memory into the guest. It would appear the MIPS KVM port wasn't updated prior to being merged (in v3.10) to take commit 81c52c56e2b4 ("KVM: do not treat noslot pfn as a error pfn") into account (merged v3.8), which converted a bunch of is_error_pfn() calls to is_error_noslot_pfn(). Switch to using is_error_noslot_pfn() instead to catch this case properly.

James Hogan committed 10 years ago

Commit ba913e41 parent 2eeb3211 file · +1 −1Browse files

Unified · Split

arch/mips/kvm/mmu.c+1−1
@@ -40,7 +40,7 @@ static int kvm_mips_map_page(struct kvm *kvm, gfn_t gfn) · 39 unmodified lines
4040 srcu_idx = srcu_read_lock(&kvm->srcu);
4141 pfn = gfn_to_pfn(kvm, gfn);
4242
43− if (is_error_pfn(pfn)) {
43+ if (is_error_noslot_pfn(pfn)) {
4444 kvm_err("Couldn't get pfn for gfn %#llx!\n", gfn);
4545 err = -EFAULT;
4646 goto out;