Page MenuHomeFreeBSD

riscv: add support for SBI legacy replacement functions
ClosedPublic

Authored by mhorne on Oct 25 2020, 10:38 PM.
Tags
None
Referenced Files
Unknown Object (File)
Oct 13 2023, 12:23 PM
Unknown Object (File)
Sep 6 2023, 8:42 AM
Unknown Object (File)
Sep 6 2023, 8:41 AM
Unknown Object (File)
Sep 6 2023, 8:41 AM
Unknown Object (File)
Sep 6 2023, 8:39 AM
Unknown Object (File)
Sep 6 2023, 8:39 AM
Unknown Object (File)
Sep 1 2023, 7:58 AM
Unknown Object (File)
Aug 6 2023, 7:55 AM

Details

Summary

Version 0.2 of the SBI specification [1] marked the existing SBI
functions as "legacy" in order to move to a newer calling convention. It
also introduced a set of replacement extensions for some of the legacy
functionality. In particular, the TIME, IPI, and RFNC extensions
implement and extend the semantics of their legacy counterparts, while
conforming to the newer version of the spec.

Update our SBI code to use the new replacement extensions when
available, and fall back to the legacy ones. These will eventually be
dropped, when support for version 0.2 is ubiquitous.

[1] https://github.com/riscv/riscv-sbi-doc/blob/master/riscv-sbi.adoc

Submitted by: Danjel Q. <dan1555@gmail.com>

Test Plan

Boot to multiuser with OpenSBI and BBL.

Diff Detail

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

Event Timeline

mhorne created this revision.

I know the current spec says SBI_SUCCESS is the only documented return value for some of these, but we should really be asserting on all of them IMO. Although for some of them we might want to propagate the error up to recover from it rather than asserting...

sys/riscv/riscv/sbi.c
254 ↗(On Diff #78755)

missing "them" after this change.

I know the current spec says SBI_SUCCESS is the only documented return value for some of these, but we should really be asserting on all of them IMO. Although for some of them we might want to propagate the error up to recover from it rather than asserting...

Asserting for all of them is a good idea. For this patch I think it's better to maintain the existing function signatures. Most of the RFENCE SBI calls are from pmap code which doesn't expect failure, but it would be worth looking at more closely.

Add asserts to all affected functions. Use SBI_SUCCESS instead of 0.

mhorne added inline comments.
sys/riscv/riscv/sbi.c
254 ↗(On Diff #78755)

d'oh!

Other than the incorrect comparison in the assertion I think this is good to go.

sys/riscv/riscv/sbi.c
137 ↗(On Diff #78756)

==

mhorne marked an inline comment as done.

Fix assert, assignment -> comparison.

This revision is now accepted and ready to land.Oct 26 2020, 3:00 PM