ANDROID: arm64: Check if pfn is valid for all ioremap loop iterations

The size could cover pfns that are valid.

Fixes:
arm64: Implement ioremap/iounmap hooks calling into KVM's MMIO guard

Bug: 251432016
Change-Id: Ie3b678d40d629ed610b0ee484b5007cb64437435
Signed-off-by: Fuad Tabba <tabba@google.com>
Signed-off-by: Quentin Perret <qperret@google.com>
This commit is contained in:
Fuad Tabba
2022-11-09 14:32:41 +00:00
committed by Quentin Perret
parent 437fc98ccb
commit 9720e4d374

View File

@@ -114,9 +114,6 @@ void ioremap_phys_range_hook(phys_addr_t phys_addr, size_t size, pgprot_t prot)
if (!static_branch_unlikely(&ioremap_guard_key))
return;
if (pfn_valid(__phys_to_pfn(phys_addr)))
return;
mutex_lock(&ioremap_guard_lock);
while (size) {
@@ -124,6 +121,9 @@ void ioremap_phys_range_hook(phys_addr_t phys_addr, size_t size, pgprot_t prot)
struct ioremap_guard_ref *ref;
struct arm_smccc_res res;
if (pfn_valid(__phys_to_pfn(phys_addr)))
goto next;
ref = xa_load(&ioremap_guard_array, pfn);
if (ref) {
refcount_inc(&ref->count);