diff mbox

MIPS: KVM: Check for pfn noslot case

Message ID 30bb792dbba5a6fa2a274c11740bbc7005a3ca31.1471611726.git-series.james.hogan@imgtec.com (mailing list archive)
State New, archived
Headers show

Commit Message

James Hogan Aug. 19, 2016, 1:30 p.m. UTC
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.

Fixes: 858dd5d45733 ("KVM/MIPS32: MMU/TLB operations for the Guest.")
Signed-off-by: James 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.y-
---
 arch/mips/kvm/mmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Paolo Bonzini Aug. 19, 2016, 3:38 p.m. UTC | #1
On 19/08/2016 15:30, James Hogan wrote:
> 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.
> 
> Fixes: 858dd5d45733 ("KVM/MIPS32: MMU/TLB operations for the Guest.")
> Signed-off-by: James 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.y-
> ---
>  arch/mips/kvm/mmu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/mips/kvm/mmu.c b/arch/mips/kvm/mmu.c
> index 6cfdcf55572d..121008c0fcc9 100644
> --- a/arch/mips/kvm/mmu.c
> +++ b/arch/mips/kvm/mmu.c
> @@ -40,7 +40,7 @@ static int kvm_mips_map_page(struct kvm *kvm, gfn_t gfn)
>  	srcu_idx = srcu_read_lock(&kvm->srcu);
>  	pfn = gfn_to_pfn(kvm, gfn);
>  
> -	if (is_error_pfn(pfn)) {
> +	if (is_error_noslot_pfn(pfn)) {
>  		kvm_err("Couldn't get pfn for gfn %#llx!\n", gfn);
>  		err = -EFAULT;
>  		goto out;
> 

Queued for 4.8-rc3, thanks.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arch/mips/kvm/mmu.c b/arch/mips/kvm/mmu.c
index 6cfdcf55572d..121008c0fcc9 100644
--- a/arch/mips/kvm/mmu.c
+++ b/arch/mips/kvm/mmu.c
@@ -40,7 +40,7 @@  static int kvm_mips_map_page(struct kvm *kvm, gfn_t gfn)
 	srcu_idx = srcu_read_lock(&kvm->srcu);
 	pfn = gfn_to_pfn(kvm, gfn);
 
-	if (is_error_pfn(pfn)) {
+	if (is_error_noslot_pfn(pfn)) {
 		kvm_err("Couldn't get pfn for gfn %#llx!\n", gfn);
 		err = -EFAULT;
 		goto out;