Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft : Added test cases for load address match trigger in sdtrig extension #487

Open
wants to merge 31 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
ac1e9a3
Added test cases for load address match trigger in sdtrig extension
anuani21 Sep 3, 2024
16c1028
Merge branch 'dev' into Sdtrig
anuani21 Sep 3, 2024
222b4d6
Updated load test cases and added store, execute test cases with diff…
anuani21 Sep 30, 2024
04b414d
Merge branch 'dev' into Sdtrig
anuani21 Sep 30, 2024
d2e7cd8
updated tests
anuani21 Oct 4, 2024
dbb9090
Merge branch 'Sdtrig' of https://github.com/anuani21/riscv-arch-test …
anuani21 Oct 4, 2024
fc0c35e
Modified test cases
anuani21 Oct 4, 2024
02b07a3
Removed
anuani21 Oct 4, 2024
486cab3
Delete riscv-test-suite/rv32i_m/sdtrig/store_match5.S
anuani21 Oct 4, 2024
66801c4
Delete riscv-test-suite/rv32i_m/sdtrig/execute_match0.S
anuani21 Oct 4, 2024
65c0e80
Delete riscv-test-suite/rv32i_m/sdtrig/execute_match2.S
anuani21 Oct 4, 2024
491877e
Delete riscv-test-suite/rv32i_m/sdtrig/execute_match3.S
anuani21 Oct 4, 2024
c22ab26
Delete riscv-test-suite/rv32i_m/sdtrig/execute_match4.S
anuani21 Oct 4, 2024
c33f0d4
Delete riscv-test-suite/rv32i_m/sdtrig/execute_match5.S
anuani21 Oct 4, 2024
eab99bd
Delete riscv-test-suite/rv32i_m/sdtrig/load_match0.S
anuani21 Oct 4, 2024
0eaefef
Delete riscv-test-suite/rv32i_m/sdtrig/load_match1.S
anuani21 Oct 4, 2024
b401d05
Delete riscv-test-suite/rv32i_m/sdtrig/load_match2.S
anuani21 Oct 4, 2024
16949c0
Delete riscv-test-suite/rv32i_m/sdtrig/load_match3.S
anuani21 Oct 4, 2024
821d960
Delete riscv-test-suite/rv32i_m/sdtrig/load_match4.S
anuani21 Oct 4, 2024
29cc8b1
Delete riscv-test-suite/rv32i_m/sdtrig/load_match5.S
anuani21 Oct 4, 2024
2020acc
Delete riscv-test-suite/rv32i_m/sdtrig/store_match0.S
anuani21 Oct 4, 2024
9d52f76
Delete riscv-test-suite/rv32i_m/sdtrig/store_match1.S
anuani21 Oct 4, 2024
47f0808
Delete riscv-test-suite/rv32i_m/sdtrig/store_match2.S
anuani21 Oct 4, 2024
2198dd5
Delete riscv-test-suite/rv32i_m/sdtrig/store_match3.S
anuani21 Oct 4, 2024
18abd78
Delete riscv-test-suite/rv32i_m/sdtrig/store_match4.S
anuani21 Oct 4, 2024
b3abd20
Delete riscv-test-suite/rv32i_m/sdtrig/src directory
anuani21 Oct 4, 2024
c858b14
Updated test cases for execute,load and store operations
anuani21 Oct 4, 2024
717eaf8
Merge branch 'riscv-non-isa:dev' into Sdtrig
anuani21 Oct 15, 2024
2d0b254
Updated test cases
anuani21 Oct 15, 2024
61b43c4
Icount test cases
anuani21 Nov 1, 2024
8ea168a
Merge branch 'riscv-non-isa:dev' into Sdtrig
anuani21 Nov 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3,112 changes: 3,112 additions & 0 deletions riscv-test-suite/env/debug_defines.h

Large diffs are not rendered by default.

137 changes: 137 additions & 0 deletions riscv-test-suite/rv32i_m/sdtrig/src/execute_match0.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
#include "model_test.h"
#include "arch_test.h"
#include "debug_defines.h"
RVTEST_ISA("RV32IZicsr_Sdtrig")

.section .text.init
.globl rvtest_entry_point
rvtest_entry_point:
RVMODEL_BOOT
RVTEST_CODE_BEGIN

#ifdef TEST_CASE_1
RVTEST_CASE(1,"//check ISA:=regex(.*I.*Zicsr.*Sdtrig.*);def TEST_CASE_1=True;",execute_match0)
RVTEST_SIGBASE(x1, signature_x1_0)
# Set mtvec to the address of the trap handler
la a0, trap_handler
csrw mtvec, a0

# Read the misa
csrr t2, misa
RVTEST_SIGUPD(x1,t2)
li t1, (1 << 18)
and t2,t2,t1

bnez t2, implement_mie
beqz t2 , implement_tcontrol

implement_mie:
li t1,(1<<3)
csrw mstatus, t1
csrr t4, mstatus
RVTEST_SIGUPD(x1, t4)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since these tests test triggers, but not explicitly test native re-entrant issues, I think it's better not to add this to the signature. Then these tests can compare DUTs and references that have different ways of enabling triggers.

But I might be misunderstanding the philosophy behind these tests.

j resume_code

implement_tcontrol:

li t3, (1<<3)
csrw tcontrol, t3
csrr t4, tcontrol
j resume_code

resume_code:
# Write 0 to tselect, read back and append it to the signature
csrw tselect, zero
csrr t0, tselect
RVTEST_SIGUPD(x1, t0)

# Read tinfo and append it to the signature
csrr t6, tinfo
RVTEST_SIGUPD(x1, t6)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For similar reasons, do we want tinfo in the signature? I think we only care that the specific trigger type being tested is supported.


csrw tdata1, zero
csrr a3, tdata1
RVTEST_SIGUPD(x1, a3)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is another one. The spec only requires that the trigger is now disabled, but there are many encodings that could represent a disabled register.


# Set the address for tdata2 where the trigger should occur
la t2, 0x80001234 # Set the data value to match
csrw tdata2, t2


# Set up trigger to cause a trap on a breakpoint
# Configure tdata1 for address match control
li t2, (CSR_TDATA1_TYPE_MCONTROL6 << 28 | \
CSR_TDATA1_DMODE_BOTH << 27 | \
CSR_MCONTROL6_SELECT_ADDRESS << 21 | \
CSR_MCONTROL6_SIZE_ANY << 16 | \
CSR_MCONTROL6_CHAIN_DISABLED << 11 | \
CSR_MCONTROL6_ACTION_BREAKPOINT << 12 | \
CSR_MCONTROL6_MATCH_EQUAL << 7 | \
CSR_MCONTROL6_M | \
CSR_MCONTROL6_EXECUTE)
csrw tdata1, t2
csrr t4,tdata1
RVTEST_SIGUPD(x1, t4)
csrr t6,tdata2
RVTEST_SIGUPD(x1, t6)

# Trigger setup complete; now perform an instruction that will hit the trigger
la t4, 0x80001234
jalr x0,0(t4)
nop
nop

#endif

trap_handler:
# Save trap information
csrr t0, mcause # Cause of the trap
csrr t1, mepc # Program counter at the time of trap
csrr t2, mtval # Trap value
RVTEST_SIGUPD(x1, t0) # Update signature with mcause
RVTEST_SIGUPD(x1, t1) # Update signature with mepc
RVTEST_SIGUPD(x1, t2) # Update signature with mtval

# Check if the trigger hit bit is set (bit 22 in tdata1)
csrr t3, tdata1
RVTEST_SIGUPD(x1, t3)

end:
RVTEST_CODE_END
RVMODEL_HALT

RVTEST_DATA_BEGIN
.align 12
page_4k:
.fill 4096/REGWIDTH, REGWIDTH, 0
RVTEST_DATA_END

.align 12
rvtest_Sroot_pg_tbl:
.fill 4096/REGWIDTH, REGWIDTH, 0
.section .data

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need these?


# Output data section.
RVMODEL_DATA_BEGIN
rvtest_sig_begin:
sig_begin_canary:
CANARY;

signature_x1_0:
.fill 128*(XLEN/32),4,0xdeadbeef

#ifdef rvtest_mtrap_routine
mtrap_sigptr:
.fill 128*4, 4, 0xdeadbeef
#endif

#ifdef rvtest_gpr_save
gpr_save:
.fill 32*(XLEN/32), 4, 0xdeadbeef
#endif

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can also delete these.


sig_end_canary:
CANARY;
rvtest_sig_end:
RVMODEL_DATA_END

137 changes: 137 additions & 0 deletions riscv-test-suite/rv32i_m/sdtrig/src/execute_match1.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
#include "model_test.h"
#include "arch_test.h"
#include "debug_defines.h"
RVTEST_ISA("RV32IZicsr_Sdtrig")

.section .text.init
.globl rvtest_entry_point
rvtest_entry_point:
RVMODEL_BOOT
RVTEST_CODE_BEGIN

#ifdef TEST_CASE_1
RVTEST_CASE(1,"//check ISA:=regex(.*I.*Zicsr.*Sdtrig.*);def TEST_CASE_1=True;",execute_match1)
RVTEST_SIGBASE(x1, signature_x1_0)
# Set mtvec to the address of the trap handler
la a0, trap_handler
csrw mtvec, a0

# Read the misa
csrr t2, misa
RVTEST_SIGUPD(x1,t2)
li t1, (1 << 18)
and t2,t2,t1

bnez t2, implement_mie
beqz t2 , implement_tcontrol

implement_mie:
li t1,(1<<3)
csrw mstatus, t1
csrr t4, mstatus
RVTEST_SIGUPD(x1, t4)
j resume_code

implement_tcontrol:

li t3, (1<<3)
csrw tcontrol, t3
csrr t4, tcontrol
j resume_code

resume_code:

# Write 0 to tselect, read back and append it to the signature
csrw tselect, zero
csrr t0, tselect
RVTEST_SIGUPD(x1, t0)

# Read tinfo and append it to the signature
csrr t6, tinfo
RVTEST_SIGUPD(x1, t6)

csrw tdata1, zero
csrr a3, tdata1
RVTEST_SIGUPD(x1, a3)

# Set the address for tdata2 where the trigger should occur
la t2, 0x80001001 # Set the data value to match
csrw tdata2, t2
csrr t6,tdata2
RVTEST_SIGUPD(x1, t6)

# Set up trigger to cause a trap on a breakpoint
# Configure tdata1 for address match control
li t2, (CSR_TDATA1_TYPE_MCONTROL6 << 28 | \
CSR_TDATA1_DMODE_BOTH << 27 | \
CSR_MCONTROL6_SELECT_ADDRESS << 21 | \
CSR_MCONTROL6_SIZE_ANY << 16 | \
CSR_MCONTROL6_CHAIN_DISABLED << 11 | \
CSR_MCONTROL6_ACTION_BREAKPOINT << 12 | \
CSR_MCONTROL6_MATCH_NAPOT << 7 | \
CSR_MCONTROL6_M | \
CSR_MCONTROL6_EXECUTE)
csrw tdata1, t2
csrr t4,tdata1
RVTEST_SIGUPD(x1, t4)

# Trigger setup complete; now perform an instruction that will hit the trigger
la t4, 0x80001000
jalr x0,0(t4)
nop
nop

#endif

trap_handler:
# Save trap information
csrr t0, mcause # Cause of the trap
csrr t1, mepc # Program counter at the time of trap
csrr t2, mtval # Trap value
RVTEST_SIGUPD(x1, t0) # Update signature with mcause
RVTEST_SIGUPD(x1, t1) # Update signature with mepc
RVTEST_SIGUPD(x1, t2) # Update signature with mtval

# Check if the trigger hit bit is set (bit 22 in tdata1)
csrr t3, tdata1
RVTEST_SIGUPD(x1, t3)

end:
RVTEST_CODE_END
RVMODEL_HALT

RVTEST_DATA_BEGIN
.align 12
page_4k:
.fill 4096/REGWIDTH, REGWIDTH, 0
RVTEST_DATA_END

.align 12
rvtest_Sroot_pg_tbl:
.fill 4096/REGWIDTH, REGWIDTH, 0
.section .data

# Output data section.
RVMODEL_DATA_BEGIN
rvtest_sig_begin:
sig_begin_canary:
CANARY;

signature_x1_0:
.fill 128*(XLEN/32),4,0xdeadbeef

#ifdef rvtest_mtrap_routine
mtrap_sigptr:
.fill 128*4, 4, 0xdeadbeef
#endif

#ifdef rvtest_gpr_save
gpr_save:
.fill 32*(XLEN/32), 4, 0xdeadbeef
#endif

sig_end_canary:
CANARY;
rvtest_sig_end:
RVMODEL_DATA_END

Loading