Page MenuHomeFreeBSD

x86: Always use clean FPU and segment base state for new kthreads.
ClosedPublic

Authored by jhb on Mar 10 2021, 10:13 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Mar 16, 10:15 PM
Unknown Object (File)
Sat, Mar 16, 10:12 PM
Unknown Object (File)
Sat, Mar 16, 10:12 PM
Unknown Object (File)
Sat, Mar 16, 10:12 PM
Unknown Object (File)
Sat, Mar 16, 9:59 PM
Unknown Object (File)
Feb 23 2024, 12:34 AM
Unknown Object (File)
Dec 14 2023, 6:31 AM
Unknown Object (File)
Dec 13 2023, 1:18 AM
Subscribers

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 37786
Build 34675: arc lint + arc unit

Event Timeline

sys/amd64/amd64/vm_machdep.c
189

Should we clear PCB_KERNFPU_THR, or leave it alone?

sys/amd64/amd64/vm_machdep.c
189

To get clean state we should probably clear it as well. That's probably a (small) bug that we don't clear it now.

601

We could perhaps assert that neither KERNFPU nor KERNFPU_THR is set here instead of clearing. No user process calling thr_new() should have active kernel FPU state here. cpu_fork() doesn't currently bother clearing this flag (so I didn't add it), but I would like these two code blocks to be as identical as possible between cpu_fork() and cpu_copy_thread(). (It's somewhat temping to see if I could come up with some kind of 'copy_pcb' function for the shared logic between the two functions.)

609

This comment seems a bit stale as it doesn't create a stack at all. For exec_setregs where I think this was copied from, we bzero the trap frame before setting registers. I wonder if for the trapframe cpu_thread_copy() shouldn't be more like exec and rely on cpu_set_upcall() instead.

jhb marked an inline comment as done.Mar 11 2021, 6:16 PM
sys/amd64/amd64/vm_machdep.c
609

This comment seems a bit stale as it doesn't create a stack at all. For exec_setregs where I think this was copied from, we bzero the trap frame before setting registers. I wonder if for the trapframe cpu_thread_copy() shouldn't be more like exec and rely on cpu_set_upcall() instead.

I tried doing a bzero here and it didn't work out well. cpu_set_upcall() below doesn't set tf_ss (though it sets all the others) which blew up. The 32-bit cpu_set_upcall() doesn't set any seg regs at all, and linux_set_upcall_kse() assumes a copy instead of clear. I will make the comment more accurate though.

  • Clear PCB_KERN*_THR as well.
This revision is now accepted and ready to land.Mar 12 2021, 12:56 PM