diff mbox

KVM: check for !is_zero_pfn() in kvm_is_mmio_pfn()

Message ID 1410527760-19737-1-git-send-email-ard.biesheuvel@linaro.org (mailing list archive)
State New, archived
Headers show

Commit Message

Ard Biesheuvel Sept. 12, 2014, 1:16 p.m. UTC
Read-only memory ranges may be backed by the zero page, so avoid
misidentifying it a a MMIO pfn.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Fixes: b88657674d39 ("ARM: KVM: user_mem_abort: support stage 2 MMIO page mapping")
---

This fixes another issue I identified when testing QEMU+KVM_UEFI, where
a read to an uninitialized emulated NOR flash brought in the zero page,
but mapped as a read-write device region, because kvm_is_mmio_pfn()
misidentifies it as a MMIO pfn due to its PG_reserved bit being set.

 virt/kvm/kvm_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Paolo Bonzini Sept. 12, 2014, 1:36 p.m. UTC | #1
Il 12/09/2014 15:16, Ard Biesheuvel ha scritto:
> Read-only memory ranges may be backed by the zero page, so avoid
> misidentifying it a a MMIO pfn.
> 
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Fixes: b88657674d39 ("ARM: KVM: user_mem_abort: support stage 2 MMIO page mapping")
> ---
> 
> This fixes another issue I identified when testing QEMU+KVM_UEFI, where
> a read to an uninitialized emulated NOR flash brought in the zero page,
> but mapped as a read-write device region, because kvm_is_mmio_pfn()
> misidentifies it as a MMIO pfn due to its PG_reserved bit being set.
> 
>  virt/kvm/kvm_main.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index 36b887dd0c84..f8adaabeac13 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -110,7 +110,7 @@ static bool largepages_enabled = true;
>  bool kvm_is_mmio_pfn(pfn_t pfn)
>  {
>  	if (pfn_valid(pfn))
> -		return PageReserved(pfn_to_page(pfn));
> +		return !is_zero_pfn(pfn) && PageReserved(pfn_to_page(pfn));
>  
>  	return true;
>  }
> 

Thanks, applying to kvm/master.

Paolo
--
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/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 36b887dd0c84..f8adaabeac13 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -110,7 +110,7 @@  static bool largepages_enabled = true;
 bool kvm_is_mmio_pfn(pfn_t pfn)
 {
 	if (pfn_valid(pfn))
-		return PageReserved(pfn_to_page(pfn));
+		return !is_zero_pfn(pfn) && PageReserved(pfn_to_page(pfn));
 
 	return true;
 }