Author: kib Date: Wed Dec 14 11:40:31 2016 New Revision: 310050 URL: https://svnweb.freebsd.org/changeset/base/310050
Log: Provide non-final but valid PCB pointer for thread0 for duration of hammer_time(). This makes assembler exception handlers not fault itself when setting PCB flags, and allow normal kernel trap handler to get control. The pointer is reset after FPU parameters are obtained. Set thread0.td_critnest to 1 for duration of hammer_time() as well. In particular, page faults at that early stage panic immediately instead of trying to call not yet operational VM to resolve it. As result, faults during second half of the hammer_time() execution have a chance to be reported instead of silent machine reboot or hang. Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Modified: head/sys/amd64/amd64/machdep.c Modified: head/sys/amd64/amd64/machdep.c ============================================================================== --- head/sys/amd64/amd64/machdep.c Wed Dec 14 07:36:36 2016 (r310049) +++ head/sys/amd64/amd64/machdep.c Wed Dec 14 11:40:31 2016 (r310050) @@ -1673,6 +1673,16 @@ hammer_time(u_int64_t modulep, u_int64_t wrmsr(MSR_SF_MASK, PSL_NT|PSL_T|PSL_I|PSL_C|PSL_D); /* + * Temporary forge some valid pointer to PCB, for exception + * handlers. It is reinitialized properly below after FPU is + * set up. Also set up td_critnest to short-cut the page + * fault handler. + */ + cpu_max_ext_state_size = sizeof(struct savefpu); + thread0.td_pcb = get_pcb_td(&thread0); + thread0.td_critnest = 1; + + /* * The console and kdb should be initialized even earlier than here, * but some console drivers don't work until after getmemsize(). * Default to late console initialization to support these drivers. @@ -1762,6 +1772,7 @@ hammer_time(u_int64_t modulep, u_int64_t #ifdef FDT x86_init_fdt(); #endif + thread0.td_critnest = 0; /* Location of kernel stack for locore */ return ((u_int64_t)thread0.td_pcb); _______________________________________________ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"