Skip to content

Commit 92be690

Browse files
Add spec for Wait-on-Reservation-Set Instructions (#640)
Spec for extension Zawrs instructions (#224) - `wrs.nto` - `wrs.sto`
1 parent 34a414b commit 92be690

File tree

2 files changed

+68
-6
lines changed

2 files changed

+68
-6
lines changed

arch/inst/Zawrs/wrs.nto.yaml

+36-3
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,44 @@
33
$schema: "inst_schema.json#"
44
kind: instruction
55
name: wrs.nto
6-
long_name: No synopsis available
6+
long_name: Wait-on-Reservation-Set-with-No-Timeout
77
description: |
8-
No description available.
8+
-id: inst-wrs.nto-behaviour
9+
-normative: false
10+
-text: |
11+
To mitigate the wasteful looping in such usages, a `wrs.nto` (WRS-with-no-timeout) instruction is provided.
12+
Instead of polling for a store to a specific memory location, software registers a reservation set that
13+
includes all the bytes of the memory location using the LR instruction. Then a subsequent `wrs.nto`
14+
instruction would cause the hart to temporarily stall execution in a low-power state until a store
15+
occurs to the reservation set or an interrupt is observed.
16+
17+
This instruction is not supported in a constrained LR/SC loop.
18+
While stalled, an implementation is permitted to occasionally terminate the stall and complete
19+
execution for any reason.
20+
21+
`wrs.nto` follows the rules of the WFI instruction for resuming execution
22+
on a pending interrupt.
23+
24+
When the TW (Timeout Wait) bit in `mstatus` is set and `wrs.nto` is executed
25+
in any privilege mode otherthan M mode, and it does not complete within an implementation-specific
26+
bounded time limit, the `wrs.nto` instruction will cause an illegal instruction exception.
27+
28+
When executing in VS or VU mode, if the VTW bit is set in `hstatus`, the TW bit in `mstatus` is clear,
29+
and the `wrs.nto` does not complete within an implementation-specific bounded time limit,
30+
the `wrs.nto` instruction will cause a virtual instruction exception.
31+
32+
[Note]
33+
Since `wrs.nto` can complete execution for reasons other than stores to the reservation set,
34+
software will likely need a means of looping until the required stores have occurred.
35+
36+
[Note]
37+
`wrs.nto`, unlike WFI, is not specified to cause an illegal instruction exception if executed in U-mode
38+
when the governing TW bit is 0. WFI is typically not expected to be used in U-mode and on many systems
39+
may promptly cause an illegal instruction exception if used at U-mode.
40+
Unlike WFI, `wrs.nto` is expected to be used by software in U-mode when waiting on memory but without
41+
a deadline for that wait.
942
definedBy: Zawrs
10-
assembly: wrs_nto
43+
assembly: ""
1144
encoding:
1245
match: "00000000110100000000000001110011"
1346
variables: []

arch/inst/Zawrs/wrs.sto.yaml

+32-3
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,40 @@
33
$schema: "inst_schema.json#"
44
kind: instruction
55
name: wrs.sto
6-
long_name: No synopsis available
6+
long_name: Wait-on-Reservation-Set-with-Short-Timeout
77
description: |
8-
No description available.
8+
-id: inst-wrs.sto-behaviour
9+
-normative: false
10+
-text: |
11+
Instead of polling for a store to a specific memory location, software registers a
12+
reservation set that includes all the bytes of the memory location using the LR instruction.
13+
A subsequent `wrs.sto` instruction would cause the hart to temporarily stall execution in a
14+
low-power state until a store occurs to the reservation set or an interrupt is observed.
15+
Sometimes the program waiting on a memory update may also need to carry out a task at a future time
16+
or otherwise place an upper bound on the wait. To support such use cases, `wrs.sto` bounds the
17+
stall duration to an implementation-define short timeout such that the stall is terminated on the
18+
timeout if no other conditions have occurred to terminate the stall. The program using this instruction
19+
may then determine if its deadline has been reached.
20+
`wrs.sto` causes the hart to temporarily stall execution in a low-power state as long as the reservation
21+
set is valid and no pending interrupts, even if disabled, are observed. For `wrs.sto` the stall duration
22+
is bounded by an implementation defined short timeout. These instructions are not supported in a
23+
constrained LR/SC loop.
24+
Hart execution may be stalled while the following conditions are all satisfied:
25+
a. The reservation set is valid
26+
b. If `wrs.sto`, a "short" duration since start of stall has not elapsed
27+
c. No pending interrupt is observed (see the rules below)
28+
29+
While stalled, an implementation is permitted to occasionally terminate the stall and complete
30+
execution for any reason. `wrs.sto` follows the rules of the WFI instruction for resuming execution
31+
on a pending interrupt. Since `wrs.sto` can complete execution for reasons other than stores to
32+
the reservation set, software will likely need a means of looping until the required stores have occurred.
33+
34+
[Note]
35+
The duration of a `wrs.sto` instruction's timeout may vary significantly within and among implementations.
36+
In typical implementations this duration should be roughly in the range of 10 to 100 times an on-chip
37+
cache miss latency or a cacheless access to main memory.
938
definedBy: Zawrs
10-
assembly: wrs_sto
39+
assembly: ""
1140
encoding:
1241
match: "00000001110100000000000001110011"
1342
variables: []

0 commit comments

Comments
 (0)