Commit 79024d0f authored by Ard Biesheuvel's avatar Ard Biesheuvel Committed by Jiri Slaby

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

commit 85c8555f upstream.

Read-only memory ranges may be backed by the zero page, so avoid
misidentifying it a a MMIO pfn.

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.
Signed-off-by: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
Fixes: b8865767 ("ARM: KVM: user_mem_abort: support stage 2 MMIO page mapping")
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
parent 571a8e0b
...@@ -104,7 +104,7 @@ static bool largepages_enabled = true; ...@@ -104,7 +104,7 @@ static bool largepages_enabled = true;
bool kvm_is_mmio_pfn(pfn_t pfn) bool kvm_is_mmio_pfn(pfn_t pfn)
{ {
if (pfn_valid(pfn)) if (pfn_valid(pfn))
return PageReserved(pfn_to_page(pfn)); return !is_zero_pfn(pfn) && PageReserved(pfn_to_page(pfn));
return true; return true;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment