[Bug 247945] Kernel option KERN_TLS leads to an immediate panic while booting on ARM64 (RPi4)

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Thu Jul 23 16:22:31 UTC 2020


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=247945

John Baldwin <jhb at FreeBSD.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kib at FreeBSD.org

--- Comment #5 from John Baldwin <jhb at FreeBSD.org> ---
This may be a bug in the arm64 fpu interface?  Note that the kthread calls
fpu_kern_thread() first thing before it's done any work at all.

Ah, I think I see the bug.  cpu_copy_thread() in vm_machdep.c just blindly
copies pcb_flags which means that if the first kthread runs before another one
is forked, the newly forked thread will bogusly have PCB_FP_KERN set in
pcb_flags.

The amd64 version is careful to do this in cpu_copy_thread:

        clear_pcb_flags(pcb2, PCB_FPUINITDONE | PCB_USERFPUINITDONE |
            PCB_KERNFPU);

cpu_fork() for amd64 does an fpuexit() before copying the pcb which effectively
does the same thing.

On arm64, cpu_fork() calls vfp_save_state which does not clear any pcb_flags
after doing vfp_store/vfp_disable.  It also doesn't check pcb_flags to
determine if it should store/disable which is probably wrong. 
cpu_copy_thread() just needs to clear the relevant flags in the new pcb I
think.

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-bugs mailing list