git: 9d0859637f99 - main - powerpc/radix: fix double page offset in mmu_radix_sync_icache()

From: Piotr Kubaj <pkubaj_at_FreeBSD.org>
Date: Wed, 23 Sep 2026 10:36:48 UTC
The branch main has been updated by pkubaj:

URL: https://cgit.FreeBSD.org/src/commit/?id=9d0859637f99160e17b656df153effae3df31f8b

commit 9d0859637f99160e17b656df153effae3df31f8b
Author:     Piotr Kubaj <pkubaj@FreeBSD.org>
AuthorDate: 2026-09-21 07:45:27 +0000
Commit:     Piotr Kubaj <pkubaj@FreeBSD.org>
CommitDate: 2026-09-23 10:36:18 +0000

    powerpc/radix: fix double page offset in mmu_radix_sync_icache()
    
    mmu_radix_sync_icache() adds the offset of va within its page to the
    physical address it gets from mmu_radix_extract_locked().  That address
    already includes the offset - the extract routines return the physical
    address of the byte, not of the frame - so the offset is counted twice
    and __syncicache() is handed frame + 2 * offset.
    
    The hash MMU counterpart, moea64_sync_icache(), has to add the offset
    because PVO_PADDR() yields only the frame.  Here the addition is wrong.
    
    Fixes:  6f0b2a235a13 ("powerpc/pmap: Add pmap_sync_icache() for radix pmap")
    Reviewed by:    jhibbits
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D59870
---
 sys/powerpc/aim/mmu_radix.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/sys/powerpc/aim/mmu_radix.c b/sys/powerpc/aim/mmu_radix.c
index 145b0ec5560b..5a249c18c511 100644
--- a/sys/powerpc/aim/mmu_radix.c
+++ b/sys/powerpc/aim/mmu_radix.c
@@ -6006,10 +6006,8 @@ mmu_radix_sync_icache(pmap_t pm, vm_offset_t va, vm_size_t sz)
 		pa = mmu_radix_extract_locked(pm, va);
 		sync_sz = PAGE_SIZE - (va & PAGE_MASK);
 		sync_sz = min(sync_sz, sz);
-		if (pa != 0) {
-			pa += (va & PAGE_MASK);
+		if (pa != 0)
 			__syncicache(PHYS_TO_DMAP(pa), sync_sz);
-		}
 		va += sync_sz;
 		sz -= sync_sz;
 	}