MCPcopy Create free account
hub / github.com/F-Stack/f-stack / fpudna

Function fpudna

freebsd/amd64/amd64/fpu.c:798–835  ·  view source on GitHub ↗

* Device Not Available (DNA, #NM) exception handler. * * It would be better to switch FP context here (if curthread != * fpcurthread) and not necessarily for every context switch, but it * is too hard to access foreign pcb's. */

Source from the content-addressed store, hash-verified

796 * is too hard to access foreign pcb's.
797 */
798void
799fpudna(void)
800{
801 struct thread *td;
802
803 td = curthread;
804 /*
805 * This handler is entered with interrupts enabled, so context
806 * switches may occur before critical_enter() is executed. If
807 * a context switch occurs, then when we regain control, our
808 * state will have been completely restored. The CPU may
809 * change underneath us, but the only part of our context that
810 * lives in the CPU is CR0.TS and that will be "restored" by
811 * setting it on the new CPU.
812 */
813 critical_enter();
814
815 KASSERT((curpcb->pcb_flags & PCB_FPUNOSAVE) == 0,
816 ("fpudna while in fpu_kern_enter(FPU_KERN_NOCTX)"));
817 if (__predict_false(PCPU_GET(fpcurthread) == td)) {
818 /*
819 * Some virtual machines seems to set %cr0.TS at
820 * arbitrary moments. Silently clear the TS bit
821 * regardless of the eager/lazy FPU context switch
822 * mode.
823 */
824 stop_emulating();
825 } else {
826 if (__predict_false(PCPU_GET(fpcurthread) != NULL)) {
827 panic(
828 "fpudna: fpcurthread = %p (%d), curthread = %p (%d)\n",
829 PCPU_GET(fpcurthread),
830 PCPU_GET(fpcurthread)->td_tid, td, td->td_tid);
831 }
832 restore_fpu_curthread(td);
833 }
834 critical_exit();
835}
836
837void fpu_activate_sw(struct thread *td); /* Called from the context switch */
838void

Callers 1

trapFunction · 0.85

Calls 4

restore_fpu_curthreadFunction · 0.85
critical_enterFunction · 0.50
panicFunction · 0.50
critical_exitFunction · 0.50

Tested by

no test coverage detected