Page MenuHomeFreeBSD

Use the HSM SBI extension to start APs
ClosedPublic

Authored by mhorne on Apr 19 2020, 2:28 AM.
Tags
None
Referenced Files
F81665625: D24497.diff
Fri, Apr 19, 4:31 PM
Unknown Object (File)
Dec 23 2023, 1:32 AM
Unknown Object (File)
Sep 7 2023, 2:20 PM
Unknown Object (File)
Sep 7 2023, 2:20 PM
Unknown Object (File)
Sep 7 2023, 2:19 PM
Unknown Object (File)
Sep 7 2023, 2:17 PM
Unknown Object (File)
Sep 7 2023, 2:17 PM
Unknown Object (File)
Sep 1 2023, 11:13 PM
Subscribers

Details

Summary

The addition of the HSM SBI extension to OpenSBI introduces a new
breaking change: secondary harts will remain parked in the firmware,
until they are brought up explicitly via sbi_hsm_hart_start(). Add
the call to do this, sending the secondary harts to mpentry.

If the HSM extension is not present, secondary harts are assumed to be
released by the firmware, as is the case for OpenSBI =< v0.6 and BBL.

On non-INVARIANTS kernels secondary harts may fail to start, but the
system will continue to boot and print a warning to the console. Harts
which are started but fail to come up during release_aps() will continue
to cause a panic.

Diff Detail

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

Event Timeline

Update smp_after_idle_runnable to use mp_maxid. This way we can still free all
bootstacks even if the CPUs that came online have a sparse layout.

sys/riscv/riscv/mp_machdep.c
301 ↗(On Diff #71175)

Shouldn't it be <=? mp_maxid is a valid CPU ID.

markj added inline comments.
sys/riscv/riscv/mp_machdep.c
458 ↗(On Diff #71190)

What are the possible error conditions here?

IMO it is a bit weird to only allow bootup without INVARIANTS - I would use a tunable to control it instead. If we're not going to allow execution to continue with debug assertions on, it means that this code path is not properly tested, so the kernel is likely to eventually blow up if an error occurs in a !INVARIANTS kernel. I think arm64 does something similar though, so I don't object.

This revision is now accepted and ready to land.Apr 30 2020, 3:32 PM
sys/riscv/riscv/mp_machdep.c
458 ↗(On Diff #71190)

I did get the idea from arm64, but you're right that it is a little weird. Maybe we should just go with one or the other; either panic every time or allow the system to proceed. It seems to me that it would be useful to establish common semantics for this across architectures, although that might end up being more work than benefit.

sbi_hsm_hart_start() can return the following errors:

SBI_ERR_INVALID_ADDRESS - start_addr is not valid
SBI_ERR_INVALID_PARAM - hartid is not a valid hartid/can't be started in supervisor mode
SBI_ERR_ALREADY_AVAILABLE - The given hartid is already started.
SBI_ERR_FAILED - other "unknown" error

This revision was automatically updated to reflect the committed changes.