Date: Mon, 16 Sep 2019 13:45:32 +0000 (UTC) From: Andrew Turner <andrew@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r352395 - stable/12/sys/arm64/arm64 Message-ID: <201909161345.x8GDjW4E096728@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: andrew Date: Mon Sep 16 13:45:31 2019 New Revision: 352395 URL: https://svnweb.freebsd.org/changeset/base/352395 Log: MFC r346996: Restore x18 in efi_arch_leave. Some UEFI implementations trash this register and, as we use it as a platform register, the kernel doesn't save it before calling into the UEFI runtime services. As we have a copy in tpidr_el1 restore from there when exiting the EFI environment. PR: 237234, 237055 Reviewed by: manu Tested On: Ampere eMAG Sponsored by: DARPA, AFRL Sponsored by: Ampere Computing (hardware) Differential Revision: https://reviews.freebsd.org/D20127 Modified: stable/12/sys/arm64/arm64/efirt_machdep.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/arm64/arm64/efirt_machdep.c ============================================================================== --- stable/12/sys/arm64/arm64/efirt_machdep.c Mon Sep 16 13:41:24 2019 (r352394) +++ stable/12/sys/arm64/arm64/efirt_machdep.c Mon Sep 16 13:45:31 2019 (r352395) @@ -260,6 +260,16 @@ efi_arch_leave(void) { 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"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201909161345.x8GDjW4E096728>