All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: check for !is_zero_pfn() in kvm_is_mmio_pfn()
@ 2014-09-12 13:16 Ard Biesheuvel
  2014-09-12 13:36 ` Paolo Bonzini
  0 siblings, 1 reply; 2+ messages in thread
From: Ard Biesheuvel @ 2014-09-12 13:16 UTC (permalink / raw)
  To: gleb, pbonzini, marc.zyngier, christoffer.dall, kvm, kvmarm,
	steve.capper
  Cc: lersek, fu.wei, peter.maydell, Ard Biesheuvel

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;
 }
-- 
1.8.3.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] KVM: check for !is_zero_pfn() in kvm_is_mmio_pfn()
  2014-09-12 13:16 [PATCH] KVM: check for !is_zero_pfn() in kvm_is_mmio_pfn() Ard Biesheuvel
@ 2014-09-12 13:36 ` Paolo Bonzini
  0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2014-09-12 13:36 UTC (permalink / raw)
  To: Ard Biesheuvel, gleb, marc.zyngier, christoffer.dall, kvm, kvmarm,
	steve.capper
  Cc: lersek, fu.wei, peter.maydell

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-09-12 13:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-12 13:16 [PATCH] KVM: check for !is_zero_pfn() in kvm_is_mmio_pfn() Ard Biesheuvel
2014-09-12 13:36 ` Paolo Bonzini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.