Skip to content

Commit fd1e6fa

Browse files
committed
Add EARLY VERSION Split Instruction Description for Priv vs Unpriv Spec
Signed-off-by: Afonso Oliveira <[email protected]>
1 parent 144b633 commit fd1e6fa

File tree

3 files changed

+2070
-82
lines changed

3 files changed

+2070
-82
lines changed

instr-encoding-privileged.adoc

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
==== SFENCE_VMA
2+
3+
Synopsis::
4+
5+
Mnemonic::
6+
+
7+
`sfence_vma rs1, rs2`
8+
+
9+
10+
Encoding::
11+
[wavedrom, , svg]
12+
....
13+
{reg:[
14+
{bits: 15, name: 0x73},
15+
{bits: 5, name: 'rs1'},
16+
{bits: 5, name: 'rs2'},
17+
{bits: 7, name: 0x9}
18+
]}
19+
....
20+
21+
Description::
22+
23+
Arguments::
24+
[%autowidth]
25+
[%header,cols="4,2,2"]
26+
|===
27+
|Register |Direction |Definition
28+
|rs1 |input |Source register 1
29+
|rs2 |input |Source register 2
30+
|===
31+
32+
Sail Code::
33+
34+
[source,sail]
35+
--
36+
function clause execute SFENCE_VMA(rs1, rs2) = {
37+
let addr : option(xlenbits) = if rs1 == 0b00000 then None() else Some(X(rs1));
38+
let asid : option(xlenbits) = if rs2 == 0b00000 then None() else Some(X(rs2));
39+
match cur_privilege {
40+
User => { handle_illegal(); RETIRE_FAIL },
41+
Supervisor => match (architecture(get_mstatus_SXL(mstatus)), mstatus[TVM]) {
42+
(Some(_), 0b1) => { handle_illegal(); RETIRE_FAIL },
43+
(Some(_), 0b0) => { flush_TLB(asid, addr); RETIRE_SUCCESS },
44+
(_, _) => internal_error(__FILE__, __LINE__, "unimplemented sfence architecture")
45+
},
46+
Machine => { flush_TLB(asid, addr); RETIRE_SUCCESS }
47+
}
48+
}
49+
--
50+
51+
<<<
52+
53+
==== SRET
54+
55+
Synopsis::
56+
57+
Mnemonic::
58+
+
59+
`sret`
60+
+
61+
62+
Encoding::
63+
[wavedrom, , svg]
64+
....
65+
{reg:[
66+
{bits: 32, name: 0x10200073}
67+
]}
68+
....
69+
70+
Description::
71+
72+
Arguments::
73+
[%autowidth]
74+
[%header,cols="4,2,2"]
75+
|===
76+
|Register |Direction |Definition
77+
|===
78+
79+
Sail Code::
80+
81+
[source,sail]
82+
--
83+
function clause execute SRET() = {
84+
let sret_illegal : bool = match cur_privilege {
85+
User => true,
86+
Supervisor => not(haveSupMode ()) | mstatus[TSR] == 0b1,
87+
Machine => not(haveSupMode ())
88+
};
89+
if sret_illegal
90+
then { handle_illegal(); RETIRE_FAIL }
91+
else if not(ext_check_xret_priv (Supervisor))
92+
then { ext_fail_xret_priv(); RETIRE_FAIL }
93+
else {
94+
set_next_pc(exception_handler(cur_privilege, CTL_SRET(), PC));
95+
RETIRE_SUCCESS
96+
}
97+
}
98+
--
99+
100+
<<<
101+

0 commit comments

Comments
 (0)