From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: [PATCH] KVM: check for !is_zero_pfn() in kvm_is_mmio_pfn() Date: Fri, 12 Sep 2014 15:36:55 +0200 Message-ID: <5412F6F7.8000903@redhat.com> References: <1410527760-19737-1-git-send-email-ard.biesheuvel@linaro.org> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 7bit Cc: lersek@redhat.com, fu.wei@linaro.org, peter.maydell@linaro.org To: Ard Biesheuvel , gleb@kernel.org, marc.zyngier@arm.com, christoffer.dall@linaro.org, kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, steve.capper@linaro.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:59818 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754734AbaILNhO (ORCPT ); Fri, 12 Sep 2014 09:37:14 -0400 In-Reply-To: <1410527760-19737-1-git-send-email-ard.biesheuvel@linaro.org> Sender: kvm-owner@vger.kernel.org List-ID: 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 > 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