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)
Sun, Oct 27, 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
Unknown Object (File)
Sep 7 2024, 7:45 PM
Unknown Object (File)
Aug 19 2024, 7:30 AM
Unknown Object (File)
Aug 18 2024, 5:40 PM
Unknown Object (File)
Jul 10 2024, 7:42 PM
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.