Fix the condition part of the for loop in p2m_invalidate_root() that uses P2M_ROOT_LEVEL instead of P2M_ROOT_PAGES. The goal here is to invalidate all root page tables (that can be concatenated), so the loop must iterate through all these pages. Root level can be 0 or 1, whereas there can be 1,2,8,16 root pages. The issue may lead to some pages not being invalidated and therefore the guest access won't be trapped. We use it to track pages accessed by guest for set/way emulation provided no IOMMU, IOMMU not enabled for the domain or P2M not shared with IOMMU.
Fixes: 2148a125b73b ("xen/arm: Track page accessed between batch of Set/Way operations") Signed-off-by: Michal Orzel <michal.or...@amd.com> --- xen/arch/arm/mmu/p2m.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/arch/arm/mmu/p2m.c b/xen/arch/arm/mmu/p2m.c index d96078f547d5..67296dabb587 100644 --- a/xen/arch/arm/mmu/p2m.c +++ b/xen/arch/arm/mmu/p2m.c @@ -1291,7 +1291,7 @@ static void p2m_invalidate_root(struct p2m_domain *p2m) p2m_write_lock(p2m); - for ( i = 0; i < P2M_ROOT_LEVEL; i++ ) + for ( i = 0; i < P2M_ROOT_PAGES; i++ ) p2m_invalidate_table(p2m, page_to_mfn(p2m->root + i)); p2m_write_unlock(p2m); -- 2.25.1