Skip to content

Commit 85c8555

Browse files
Ard Biesheuvelbonzini
authored andcommitted
KVM: check for !is_zero_pfn() in kvm_is_mmio_pfn()
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: Ard Biesheuvel <ard.biesheuvel@linaro.org> Fixes: b886576 ("ARM: KVM: user_mem_abort: support stage 2 MMIO page mapping") Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent 0b70068 commit 85c8555

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎virt/kvm/kvm_main.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ static bool largepages_enabled = true;
110110
bool kvm_is_mmio_pfn(pfn_t pfn)
111111
{
112112
if (pfn_valid(pfn))
113-
return PageReserved(pfn_to_page(pfn));
113+
return !is_zero_pfn(pfn) && PageReserved(pfn_to_page(pfn));
114114

115115
return true;
116116
}

0 commit comments

Comments
 (0)