Index: sys/arm64/arm64/efirt_machdep.c =================================================================== --- sys/arm64/arm64/efirt_machdep.c +++ sys/arm64/arm64/efirt_machdep.c @@ -259,6 +259,16 @@ { struct thread *td; + /* + * Restore the pcpu pointer. Some UEFI implementations trash it and + * we don't store it before calling into them. To fix this we need + * to restore it after returning to the kernel context. As reading + * curthread will access x18 we need to restore it before loading + * the thread pointer. + */ + __asm __volatile( + "mrs x18, tpidr_el1 \n" + ); td = curthread; __asm __volatile( "msr ttbr0_el1, %0 \n"