Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 132fe70

Browse files
authoredFeb 9, 2024
Draft: Add s-mode CLIC interrupt testcases
his is a draft version of the s-mode (Ssclic) CLIC interrupt testcases using clint MSW and MTIMER macros. Note: pulls are not yet available for spike or sail that support CLIC but these testcases should help enable their development. This pull requires: riscv-software-src/riscv-config#169, riscv-software-src/riscof#106 riscv-software-src/riscv-isa-sim#1596 To include s-mode CLIC interrupt tests in riscof testlist flow, add Ssclic to riscof yaml file, e.g.: spike/spike_isa.yaml: ISA: RV32IMCZicsr_Zifencei_Ssclic Signed-off-by: Dan Smathers <dan.smathers@seagate.com>
1 parent 11afbf0 commit 132fe70

File tree

1 file changed

+387
-0
lines changed

1 file changed

+387
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,387 @@
1+
==== sclicnodeleg-01.S
2+
.Description: Verify when executing in s-mode, the m-mode interrupt will be handled even though mstatus.mie is 0:
3+
- generate m-mode interrupt (msw)
4+
- switch to s-mode (mstatus.mie disabled),
5+
- trigger (m-mode handler),
6+
- clear interrupt,
7+
- return to s-mode,
8+
- ecall back to m-mode
9+
[%autofit]
10+
----
11+
RVMODEL_MSTATUS_MIE = 0
12+
RVMODEL_SET_MINT1 = RVMODEL_SET_MSW_INT;
13+
RVMODEL_CLEAR_MINT1 = RVMODEL_CLEAR_MSW_INT;
14+
RVMODEL_MINTTHRESH = RVMODEL_MINTTHRESH_MAX
15+
----
16+
Coverage
17+
----
18+
clicintattr[msw].mode == 11 | verify interrupt is handled in m-mode
19+
mstatus.mie=0 | verify m-mode interrupt will occur in s-mode when mstatus.mie=0
20+
mcause signature | verify msw cause signature
21+
----
22+
==== sclicdeleg-01.S
23+
.Description: Verify when executing in s-mode, an s-mode interrupt will be handled when mstatus.sie is 1:
24+
- generate s-mode interrupt (sint1),
25+
- switch to s-mode,
26+
- trigger (s-mode handler),
27+
- clear interrupt,
28+
- ecall back to m-mode
29+
[%autofit]
30+
----
31+
RVMODEL_MSTATUS_MIE = MSTATUS_SIE
32+
RVMODEL_SINT1_CLICINTATTR = RVMODEL_CLICINTATTR_SMODE
33+
RVMODEL_SET_SINT1 = RVMODEL_SET_MSW_INT
34+
RVMODEL_CLEAR_SINT1 = RVMODEL_CLEAR_MSW_INT
35+
RVMODEL_SINT1_EXCCODE = 0x3
36+
----
37+
Coverage
38+
----
39+
clicintattr[sint1].mode == 01 | verify interrupt is handled in s-mode
40+
mstatus.sie=1 | verify s-mode interrupt will occur in s-mode when mstatus.sie=1
41+
scause signature | verify msw signature
42+
mcause signature | verify ecall signature
43+
----
44+
==== sclicorder-01.S
45+
.Description: Verify order of 2 s-mode interrupts
46+
- generate 2 s-mode interrupts (msw, mtimer),
47+
- switch to s-mode,
48+
- trigger (s-mode handler),
49+
- clear interrupts,
50+
- ecall back to m-mode
51+
[%autofit]
52+
----
53+
RVMODEL_MSTATUS_MIE = MSTATUS_SIE
54+
RVMODEL_SINT1_CLICINTATTR = RVMODEL_CLICINTATTR_SMODE
55+
RVMODEL_SET_SINT1 = RVMODEL_SET_MSW_INT
56+
RVMODEL_CLEAR_SINT1 = RVMODEL_CLEAR_MSW_INT
57+
RVMODEL_SINT2_CLICINTATTR = RVMODEL_CLICINTATTR_SMODE
58+
RVMODEL_SET_SINT2 = RVMODEL_SET_MTIMER_INT
59+
RVMODEL_CLEAR_SINT2 = RVMODEL_CLEAR_MTIMER_INT
60+
RVMODEL_SINT1_CLICINTCTL = RVMODEL_CLICINTCTL_MAX
61+
RVMODEL_SINT2_CLICINTCTL = RVMODEL_CLICINTCTL_MIN
62+
RVMODEL_SINT1_EXCCODE = 0x3
63+
RVMODEL_SINT2_EXCCODE = 0x7
64+
----
65+
Coverage
66+
----
67+
scause signature | verify priority of int1/int2
68+
----
69+
==== sclicorder-02.S
70+
.Description:
71+
- generate 2 s-mode interrupts (msw, mtimer),
72+
- switch to s-mode,
73+
- trigger (s-mode handler),
74+
- only sint1 is cleared,
75+
- re-enable mstatus.sie
76+
- trigger (go to stvec_finish, capture cause signature)
77+
- ecall back to m-mode
78+
[%autofit]
79+
----
80+
RVMODEL_MSTATUS_MIE = MSTATUS_SIE
81+
RVMODEL_SINT1_CLICINTATTR = RVMODEL_CLICINTATTR_SMODE
82+
RVMODEL_SET_SINT1 = RVMODEL_SET_MSW_INT
83+
RVMODEL_CLEAR_SINT1 = RVMODEL_CLEAR_MSW_INT
84+
RVMODEL_SINT2_CLICINTATTR = RVMODEL_CLICINTATTR_SMODE
85+
RVMODEL_SET_SINT2 = RVMODEL_SET_MTIMER_INT
86+
RVMODEL_SINT1_CLICINTCTL = RVMODEL_CLICINTCTL_MAX
87+
RVMODEL_SINT2_CLICINTCTL = RVMODEL_CLICINTCTL_MIN
88+
RVMODEL_SINT1_EXCCODE = 0x3
89+
RVMODEL_SINT2_EXCCODE = 0x7
90+
RVMODEL_CLEAR_SSTATUS_SPIE = 0
91+
----
92+
Coverage - same as order-01.S except
93+
----
94+
scause 2nd signature | verify sti occurs after ssi cleared and sret
95+
----
96+
==== sclicorder-03.S
97+
.Description:
98+
- generate 2 s-mode interrupts (msw, mtimer),
99+
- switch to s-mode,
100+
- trigger (s-mode handler),
101+
- only sint1 is cleared,
102+
- set sintthresh
103+
- re-enable mstatus.sie
104+
- ecall back to m-mode
105+
[%autofit]
106+
----
107+
RVMODEL_MSTATUS_MIE = MSTATUS_SIE
108+
RVMODEL_SINT1_CLICINTATTR = RVMODEL_CLICINTATTR_SMODE
109+
RVMODEL_SET_SINT1 = RVMODEL_SET_MSW_INT
110+
RVMODEL_CLEAR_SINT1 = RVMODEL_CLEAR_MSW_INT
111+
RVMODEL_SINT2_CLICINTATTR = RVMODEL_CLICINTATTR_SMODE
112+
RVMODEL_SET_SINT2 = RVMODEL_SET_MTIMER_INT
113+
RVMODEL_SINT1_CLICINTCTL = RVMODEL_CLICINTCTL_MAX
114+
RVMODEL_SINT2_CLICINTCTL = RVMODEL_CLICINTCTL_MIN
115+
RVMODEL_SINTTHRESH_HNDLR1 = RVMODEL_SINTTHRESH_MAX
116+
RVMODEL_SINT1_EXCCODE = 0x3
117+
RVMODEL_SINT2_EXCCODE = 0x7
118+
RVMODEL_CLEAR_SSTATUS_SPIE = 0
119+
----
120+
Coverage - same as order-01.S except
121+
----
122+
scause 2nd signature | verify sti only occurs after ssi cleared and sret if sti level > sintthresh
123+
----
124+
==== sclicorder-04.S
125+
.Description:
126+
- generate 2 s-mode interrupts (msw, mtimer),
127+
- switch to s-mode,
128+
- trigger (s-mode handler),
129+
- only sint2 is cleared,
130+
- re-enable mstatus.sie
131+
- trigger (go to stvec_finish, capture cause signature)
132+
- ecall back to m-mode
133+
[%autofit]
134+
----
135+
RVMODEL_MSTATUS_MIE = MSTATUS_SIE
136+
RVMODEL_SINT1_CLICINTATTR = RVMODEL_CLICINTATTR_SMODE
137+
RVMODEL_SET_SINT1 = RVMODEL_SET_MSW_INT
138+
RVMODEL_SINT2_CLICINTATTR = RVMODEL_CLICINTATTR_SMODE
139+
RVMODEL_SET_SINT2 = RVMODEL_SET_MTIMER_INT
140+
RVMODEL_CLEAR_SINT2 = RVMODEL_CLEAR_MTIMER_INT
141+
RVMODEL_SINT1_CLICINTCTL = RVMODEL_CLICINTCTL_MAX
142+
RVMODEL_SINT2_CLICINTCTL = RVMODEL_CLICINTCTL_MIN
143+
RVMODEL_SINT1_EXCCODE = 0x3
144+
RVMODEL_SINT2_EXCCODE = 0x7
145+
RVMODEL_CLEAR_SSTATUS_SPIE = 0
146+
----
147+
Coverage - verify uncleared ssi interrupt will retrigger after sret
148+
----
149+
scause 2nd signature | verify 2nd signature
150+
----
151+
==== sclicprivorder-01.S
152+
.Description: Verify m-mode interrupt is handled before s-mode interrupt
153+
- generate 1 m-mode interrupt (mtimer) and 1 s-mode interrupt (msw),
154+
- switch to s-mode,
155+
- trigger (m-mode handler),
156+
- clear m-mode interrupt
157+
- return to s-mode
158+
- trigger (s-mode handler)
159+
- clear s-mode interrupt
160+
- return to s-mode
161+
- ecall back to m-mode
162+
[%autofit]
163+
----
164+
RVMODEL_MSTATUS_MIE = MSTATUS_SIE
165+
RVMODEL_SINT1_CLICINTATTR = RVMODEL_CLICINTATTR_SMODE
166+
RVMODEL_SET_SINT1 = RVMODEL_SET_MSW_INT
167+
RVMODEL_CLEAR_SINT1 = RVMODEL_CLEAR_MSW_INT
168+
RVMODEL_MINT2_CLICINTATTR = RVMODEL_CLICINTATTR_MMODE
169+
RVMODEL_SET_MINT2 = RVMODEL_SET_MTIMER_INT
170+
RVMODEL_CLEAR_MINT2 = RVMODEL_CLEAR_MTIMER_INT
171+
RVMODEL_SINT1_CLICINTCTL = RVMODEL_CLICINTCTL_MAX
172+
RVMODEL_MINT2_CLICINTCTL = RVMODEL_CLICINTCTL_MIN
173+
RVMODEL_SINT1_EXCCODE = 0x3
174+
RVMODEL_MINT2_EXCCODE = 0x7
175+
----
176+
Coverage - same as order-04.S except
177+
----
178+
mcause 1st signature | verify m-mode int 1st signature
179+
scause 2nd signature | verify s-mode int 2nd signature
180+
----
181+
==== sclicprivorder-02.S
182+
.Description: Verify m-mode interrupt is handled before s-mode interrupt setting sintthresh to max
183+
- generate 1 m-mode interrupt (mtimer) and 1 s-mode interrupt (msw),
184+
- switch to s-mode,
185+
- trigger (m-mode handler),
186+
- clear m-mode interrupt
187+
- return to s-mode
188+
- trigger (s-mode handler)
189+
- clear s-mode interrupt
190+
- return to s-mode
191+
- ecall back to m-mode
192+
[%autofit]
193+
----
194+
RVMODEL_MSTATUS_MIE = MSTATUS_SIE
195+
RVMODEL_SINT1_CLICINTATTR = RVMODEL_CLICINTATTR_SMODE
196+
RVMODEL_SET_SINT1 = RVMODEL_SET_MSW_INT
197+
RVMODEL_CLEAR_SINT1 = RVMODEL_CLEAR_MSW_INT
198+
RVMODEL_MINT2_CLICINTATTR = RVMODEL_CLICINTATTR_MMODE
199+
RVMODEL_SET_MINT2 = RVMODEL_SET_MTIMER_INT
200+
RVMODEL_CLEAR_MINT2 = RVMODEL_CLEAR_MTIMER_INT
201+
RVMODEL_SINT1_CLICINTCTL = RVMODEL_CLICINTCTL_MAX
202+
RVMODEL_MINT2_CLICINTCTL = RVMODEL_CLICINTCTL_MIN
203+
RVMODEL_SINTTHRESH_HNDLR1 = RVMODEL_SINTTHRESH_MAX
204+
RVMODEL_SINT1_EXCCODE = 0x3
205+
RVMODEL_MINT2_EXCCODE = 0x7
206+
----
207+
Coverage
208+
----
209+
mcause 1st signature | verify m-mode int 1st signature
210+
scause 2nd signature | verify s-mode int 2nd signature
211+
----
212+
==== sclicprivorder-03.S
213+
.Description: Verify m-mode interrupt is handled before s-mode interrupt setting mintthresh to max
214+
- generate 1 m-mode interrupt (mtimer) and 1 s-mode interrupt (msw),
215+
- switch to s-mode,
216+
- trigger (m-mode handler),
217+
- clear m-mode interrupt
218+
- return to s-mode
219+
- trigger (s-mode handler)
220+
- clear s-mode interrupt
221+
- return to s-mode
222+
- ecall back to m-mode
223+
[%autofit]
224+
----
225+
RVMODEL_MSTATUS_MIE = MSTATUS_SIE
226+
RVMODEL_SINT1_CLICINTATTR = RVMODEL_CLICINTATTR_SMODE
227+
RVMODEL_SET_SINT1 = RVMODEL_SET_MSW_INT
228+
RVMODEL_CLEAR_SINT1 = RVMODEL_CLEAR_MSW_INT
229+
RVMODEL_MINT2_CLICINTATTR = RVMODEL_CLICINTATTR_MMODE
230+
RVMODEL_SET_MINT2 = RVMODEL_SET_MTIMER_INT
231+
RVMODEL_CLEAR_MINT2 = RVMODEL_CLEAR_MTIMER_INT
232+
RVMODEL_SINT1_CLICINTCTL = RVMODEL_CLICINTCTL_MAX
233+
RVMODEL_MINT2_CLICINTCTL = RVMODEL_CLICINTCTL_MIN
234+
RVMODEL_MINTTHRESH_HNDLR1 = RVMODEL_MINTTHRESH_MAX
235+
RVMODEL_SINT1_EXCCODE = 0x3
236+
RVMODEL_MINT2_EXCCODE = 0x7
237+
----
238+
Coverage
239+
----
240+
mcause 1st signature | verify m-mode int 1st signature
241+
scause 2nd signature | verify s-mode int 2nd signature
242+
----
243+
==== sclicmdisable-01.S
244+
.Description: Verify m-mode interrupt not taken in m-mode when mstatus.mie is 0
245+
- generate m-mode interrupt (msw)
246+
- stay in m-mode
247+
- wfi
248+
- wakeup
249+
- jump to done
250+
- ecall
251+
[%autofit]
252+
----
253+
RVMODEL_SWITCH_TO_S_MODE = <EMPTY>
254+
RVMODEL_MSTATUS_MIE = 0
255+
RVMODEL_MINT1_CLICINTATTR = RVMODEL_CLICINTATTR_MMODE
256+
RVMODEL_SET_MINT1 = RVMODEL_SET_MSW_INT
257+
RVMODEL_CLEAR_MINT1 = RVMODEL_CLEAR_MSW_INT
258+
RVMODEL_MINT1_EXCCODE = 0x3
259+
----
260+
Coverage
261+
----
262+
mstatus.mie | verify no m-mode interrupt taken when in m-mode and clicintie is 0
263+
----
264+
==== sclicmdisable-02.S
265+
.Description: Verify m-mode interrupt not taken in m-mode when clicintie is 0
266+
- generate m-mode interrupt (msw)
267+
- stay in m-mode
268+
- nop
269+
- wakeup
270+
- jump to done
271+
- ecall
272+
[%autofit]
273+
----
274+
RVMODEL_WFI = nop
275+
RVMODEL_SWITCH_TO_S_MODE = <EMPTY>
276+
RVMODEL_MSTATUS_MIE = MSTATUS_MIE
277+
RVMODEL_MINT1_CLICINTIE = 0x0
278+
RVMODEL_MINT1_CLICINTATTR = RVMODEL_CLICINTATTR_MMODE
279+
RVMODEL_SET_MINT1 = RVMODEL_SET_MSW_INT
280+
RVMODEL_CLEAR_MINT1 = RVMODEL_CLEAR_MSW_INT
281+
RVMODEL_MINT1_EXCCODE = 0x3
282+
----
283+
Coverage
284+
----
285+
clicintie=0 | verify m-mode interrupt not taken when in m-mode and clicintie is 0
286+
----
287+
==== sclicmdisable-03.S
288+
.Description: Verify s-mode interrupt not taken in m-mode
289+
- generate s-mode interrupt (msw)
290+
- stay in m-mode
291+
- wfi
292+
- wakeup
293+
- jump to done
294+
- ecall
295+
[%autofit]
296+
----
297+
RVMODEL_SWITCH_TO_S_MODE = <EMPTY>
298+
RVMODEL_SINT1_CLICINTATTR = RVMODEL_CLICINTATTR_SMODE
299+
RVMODEL_SET_SINT1 = RVMODEL_SET_MSW_INT
300+
RVMODEL_CLEAR_SINT1 = RVMODEL_CLEAR_MSW_INT
301+
RVMODEL_SINT1_EXCCODE = 0x3
302+
----
303+
Coverage
304+
----
305+
mstatus.sie=1 | verify s-mode interrupt not taken when in m-mode
306+
----
307+
==== sclicsdisable-01.S
308+
.Description: Verify s-mode interrupt not taken in s-mode when mstatus.sie is 0
309+
- generate s-mode interrupt (msw)
310+
- switch to s-mode,
311+
- wfi
312+
- wakeup
313+
- jump to done
314+
- ecall back to m-mode
315+
[%autofit]
316+
----
317+
RVMODEL_MSTATUS_SIE = 0
318+
RVMODEL_SINT1_CLICINTATTR = RVMODEL_CLICINTATTR_SMODE
319+
RVMODEL_SET_SINT1 = RVMODEL_SET_MSW_INT
320+
RVMODEL_CLEAR_SINT1 = RVMODEL_CLEAR_MSW_INT
321+
RVMODEL_SINT1_EXCCODE = 0x3
322+
----
323+
Coverage
324+
----
325+
mstatus.mie=1, mstatus.sie=0 | verify s-mode interrupt not taken when in s-mode when mstatus.sie is 0
326+
----
327+
==== sclicsdisable-02.S
328+
.Description: Verify s-mode interrupt not taken in s-mode when clcintie is 0
329+
- generate s-mode interrupt (msw)
330+
- switch to s-mode,
331+
- nop
332+
- jump to done
333+
- ecall back to m-mode
334+
[%autofit]
335+
----
336+
RVMODEL_WFI = nop
337+
RVMODEL_MSTATUS_MIE = MSTATUS_SIE
338+
RVMODEL_SINT1_CLICINTIE = 0x0
339+
RVMODEL_SINT1_CLICINTATTR = RVMODEL_CLICINTATTR_SMODE
340+
RVMODEL_SET_SINT1 = RVMODEL_SET_MSW_INT
341+
RVMODEL_CLEAR_SINT1 = RVMODEL_CLEAR_MSW_INT
342+
RVMODEL_SINT1_EXCCODE = 0x3
343+
----
344+
Coverage
345+
----
346+
sie=0 | verify s-mode interrupt not taken when in s-mode when clicintie=0
347+
----
348+
==== sclicsdisable-03.S
349+
.Description: Verify s-mode interrupt not taken in m-mode when mstatus.sie is 1 (but wfi acts as nop)
350+
- generate s-mode interrupt (msw)
351+
- wfi
352+
- wakeup
353+
- jump to done
354+
[%autofit]
355+
----
356+
RVMODEL_SWITCH_TO_S_MODE = <EMPTY>
357+
RVMODEL_MSTATUS_MIE = MSTATUS_SIE
358+
RVMODEL_SINT1_CLICINTATTR = RVMODEL_CLICINTATTR_SMODE
359+
RVMODEL_SET_SINT1 = RVMODEL_SET_MSW_INT
360+
RVMODEL_CLEAR_SINT1 = RVMODEL_CLEAR_MSW_INT
361+
RVMODEL_SINT1_EXCCODE = 0x3
362+
----
363+
Coverage
364+
----
365+
mstatus.sie=1, mstatus.sie=1 | verify s-mode interrupt not taken when in m-mode when mstatus.sie is 1
366+
----
367+
==== sclicwfi-01.S
368+
.Description: expect wfi to behave like a nop when a single interrupt is pending when mstatus.mie is disabled
369+
- enable clicintie (default)
370+
- generate s-mode interrupt (msw)
371+
- wfi
372+
- wakeup
373+
- jump to finish
374+
[%autofit]
375+
----
376+
RVMODEL_MSTATUS_MIE = 0
377+
RVMODEL_SET_SINT1 = RVMODEL_SET_MSW_INT
378+
RVMODEL_CLEAR_INT1 = RVMODEL_CLEAR_MSW_INT
379+
RVMODEL_SINT1_CLICINTATTR = RVMODEL_CLICINTATTR_SMODE
380+
RVMODEL_SINT1_EXCCODE = 0x3
381+
----
382+
Coverage
383+
----
384+
mstatus.mie | verify no interrupt occurs in m-mode if mstatus.mie is 0
385+
wfi | verify wakeup/nop occurs with mstatus.mie = 0
386+
wfi | verify wakeup/nop occurs with pending interrupt
387+
----

0 commit comments

Comments
 (0)
Please sign in to comment.