Skip to content

Commit 5f6e257

Browse files
Nicolas Pitrenashif
authored andcommitted
arm64: provide an optimized arch_page_phys_get()
The AT instruction gives the corresponding physical address directly. Much faster than the default implementation. Signed-off-by: Nicolas Pitre <[email protected]>
1 parent 6a8148f commit 5f6e257

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

arch/arm64/core/mmu.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -908,6 +908,27 @@ void arch_mem_unmap(void *addr, size_t size)
908908
}
909909
}
910910

911+
int arch_page_phys_get(void *virt, uintptr_t *phys)
912+
{
913+
uint64_t par;
914+
int key;
915+
916+
key = arch_irq_lock();
917+
__asm__ volatile ("at S1E1R, %0" : : "r" (virt));
918+
isb();
919+
par = read_sysreg(PAR_EL1);
920+
arch_irq_unlock(key);
921+
922+
if (par & BIT(0)) {
923+
return -EFAULT;
924+
}
925+
926+
if (phys) {
927+
*phys = par & GENMASK(47, 12);
928+
}
929+
return 0;
930+
}
931+
911932
#ifdef CONFIG_USERSPACE
912933

913934
static inline bool is_ptable_active(struct arm_mmu_ptables *ptables)

0 commit comments

Comments
 (0)