Page MenuHomeFreeBSD

RISC-V: Initialize pcpu slightly earlier
ClosedPublic

Authored by mhorne on Mar 27 2019, 3:06 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Dec 9, 5:20 PM
Unknown Object (File)
Nov 9 2024, 10:32 PM
Unknown Object (File)
Nov 5 2024, 6:18 AM
Unknown Object (File)
Nov 5 2024, 6:10 AM
Unknown Object (File)
Oct 27 2024, 4:06 PM
Unknown Object (File)
Sep 17 2024, 1:02 AM
Unknown Object (File)
Sep 8 2024, 12:52 PM
Unknown Object (File)
Sep 8 2024, 7:03 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.