From 1100acd920924bf04e54a3ceaddb3e04c240320c Mon Sep 17 00:00:00 2001 From: andrew Date: Mon, 24 Aug 2015 12:01:39 +0000 Subject: [PATCH] Add support for pmap_sync_icache on arm64. Reviewed by: emaste, imp (both earlier version) Obtained from: ABT Systems Ltd Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D3438 --- sys/arm64/arm64/pmap.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/sys/arm64/arm64/pmap.c b/sys/arm64/arm64/pmap.c index a066361b7d12..578ca59d2097 100644 --- a/sys/arm64/arm64/pmap.c +++ b/sys/arm64/arm64/pmap.c @@ -3050,10 +3050,32 @@ pmap_activate(struct thread *td) } void -pmap_sync_icache(pmap_t pm, vm_offset_t va, vm_size_t sz) +pmap_sync_icache(pmap_t pmap, vm_offset_t va, vm_size_t sz) { - panic("ARM64TODO: pmap_sync_icache"); + if (va >= VM_MIN_KERNEL_ADDRESS) { + cpu_icache_sync_range(va, sz); + } else { + u_int len, offset; + vm_paddr_t pa; + + /* Find the length of data in this page to flush */ + offset = va & PAGE_MASK; + len = imin(PAGE_SIZE - offset, sz); + + while (sz != 0) { + /* Extract the physical address & find it in the DMAP */ + pa = pmap_extract(pmap, va); + if (pa != 0) + cpu_icache_sync_range(PHYS_TO_DMAP(pa), len); + + /* Move to the next page */ + sz -= len; + va += len; + /* Set the length for the next iteration */ + len = imin(PAGE_SIZE, sz); + } + } } /* -- 2.41.0