Page MenuHomeFreeBSD

RISC-V: Initialize pcpu slightly earlier
ClosedPublic

Authored by mhorne on Mar 27 2019, 3:06 PM.
Tags
None
Referenced Files
F91573412: D19726.id.diff
Mon, Aug 19, 7:30 AM
Unknown Object (File)
Sun, Aug 18, 5:40 PM
Unknown Object (File)
Jul 10 2024, 7:42 PM
Unknown Object (File)
Jul 8 2024, 10:43 AM
Unknown Object (File)
Jul 1 2024, 10:27 PM
Unknown Object (File)
May 22 2024, 3:26 AM
Unknown Object (File)
May 20 2024, 4:50 AM
Unknown Object (File)
May 20 2024, 4:50 AM
Subscribers

Details

Summary

For some reason, the code emitted for _vprintf will try to load the pcpu
pointer, even though it does nothing with it. In certain cases, printf can be
called before pcpu is initialized, causing a hang in early boot.

Move pcpu initialization up to before any printfs occur.

Test Plan

Noticed this hang when "options TSLOG" was added to my kernel config; test
that the system boots with this option enabled.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

mhorne added inline comments.
sys/riscv/riscv/machdep.c
124 ↗(On Diff #55498)

No reason this needs to be a global, as it is not referenced outside of this file.

For some reason, the code emitted for _vprintf will try to load the pcpu pointer, even though it does nothing with it.

This is probably the curthread reference from the TSENTER() macro?

For some reason, the code emitted for _vprintf will try to load the pcpu pointer, even though it does nothing with it.

This is probably the curthread reference from the TSENTER() macro?

Yep. That would definitely explain it.

Approved. I suggest giving other reviewers a day or so to chime in though.

This revision is now accepted and ready to land.Mar 27 2019, 4:00 PM
This revision was automatically updated to reflect the committed changes.