Skip to content

Commit

Permalink
Provide catch-all error code to functions with paddr inputs
Browse files Browse the repository at this point in the history
Functions which take physical addresses return SBI_ERR_INVALID_ADDRESS
for address parameters or address parameter plus size parameter inputs
which result in invalid physical addresses with respect to the
platform's physical memory layout. Also provide these functions
SBI_ERR_FAILED which may be used for addresses that the specific SBI
implementation does not support. It should be less confusing to S-mode
to get a generic error than an invalid address error for addresses
which S-mode is sure are valid.

Also add a new specification to return SBI_ERR_INVALID_ADDRESS for
invalid physical addresses and non-normative text stating when
SBI_ERR_FAILED may be returned instead.

Signed-off-by: Andrew Jones <[email protected]>
  • Loading branch information
jones-drew committed Sep 12, 2024
1 parent fc84df2 commit d906e39
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/binary-encoding.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,19 @@ If an SBI function needs to pass a shared memory physical address range to
the SBI implementation (or higher privilege mode), then this physical memory
address range MUST satisfy the following requirements:

* The SBI implementation MUST check that the specified physical memory range
is composed of valid physical addresses and return SBI_ERR_INVALID_ADDRESS
when any address in the range is not valid.

NOTE: A valid address is one that is within the platform's physical memory
layout. As an SBI implementation may further restrict the allowed range, it
may return a generic SBI_ERR_FAILED (instead of SBI_ERR_INVALID_ADDRESS) when
input is invalid with respect to its specific limits. Returning SBI_ERR_FAILED
instead of SBI_ERR_INVALID_ADDRESS, in this case, is not a violation of the
above specification because the SBI implementation should detect the distinct
case of violating the more strict range first, making it appropriate to return
the error associated with the stricter range case immediately.

* The SBI implementation MUST check that the supervisor-mode software is
 allowed to access the specified physical memory range with the access
  type requested (read and/or write).
Expand Down
2 changes: 2 additions & 0 deletions src/ext-debug-triggers.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ The possible error codes returned in `sbiret.error` are shown in
and `shmem_phys_hi` parameters does not satisfy
the requirements described in
<<_shared_memory_physical_address_range_parameter>>.
| SBI_ERR_FAILED | The request failed for unspecified or unknown other
reasons.
|===

=== Function: Read triggers (FID #2)
Expand Down
2 changes: 2 additions & 0 deletions src/ext-nested-acceleration.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,8 @@ The possible error codes returned in `sbiret.error` are shown in
and `shmem_phys_hi` parameters does not satisfy
the requirements described in
<<_shared_memory_physical_address_range_parameter>>.
| SBI_ERR_FAILED | The request failed for unspecified or unknown other
reasons.
|===

=== Function: Synchronize shared memory CSRs (FID #2)
Expand Down
2 changes: 2 additions & 0 deletions src/ext-pmu.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,8 @@ The possible error codes returned in `sbiret.error` are shown in
and `shmem_phys_hi` parameters is not writable or
does not satisfy other requirements of
<<_shared_memory_physical_address_range_parameter>>.
| SBI_ERR_FAILED | The request failed for unspecified or unknown other
reasons.
|===
=== Function Listing
Expand Down
4 changes: 4 additions & 0 deletions src/ext-sse.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,8 @@ In case of an error, the possible error codes are shown in the
`output_phys_lo` and `output_phys_hi` parameters
does not satisfy the requirements described in
<<_shared_memory_physical_address_range_parameter>>.
| SBI_ERR_FAILED | The read failed for unspecified or unknown other
reasons.
|===

=== Function: Write software event attributes (FID #1)
Expand Down Expand Up @@ -402,6 +404,8 @@ The possible error codes returned in `sbiret.error` are shown in
`input_phys_lo` and `input_phys_hi` parameters
does not satisfy the requirements described in
<<_shared_memory_physical_address_range_parameter>>.
| SBI_ERR_FAILED | The write failed for unspecified or unknown other
reasons.
|===

=== Function: Register a software event (FID #2)
Expand Down

0 comments on commit d906e39

Please sign in to comment.