forked from riscv-non-isa/riscv-arch-test
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add menvcfg support (Zicbom_Zicboz_Zicsr_Ssdtso_Sstc)
The {m,s,h}envcfg CSRs have been defined a long time ago. They contain bits that are defined by a the following ISA extensions: Zicbom_Zicboz_Zicsr_Ssdtso_Sstc This patch introduces a test which attempts to write all of the defined bits in menvcfg (similar to riscv-non-isa#381). After the tests, the original value of the CSR will be restored to avoid side-effects with other tests. Future commits could introduce the following additional tests: * write tests for the bits in senvcfg * write tests for the bits in henvcfg * test that {m,s,h}envcfg CSRs are only accessible in the relevant modes Signed-off-by: Christoph Müllner <[email protected]>
- Loading branch information
Showing
2 changed files
with
152 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
// ----------- | ||
// Copyright (c) 2023. RISC-V International. All rights reserved. | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
// ----------- | ||
// | ||
// This assembly file tests the menvcfg CSR access. | ||
// | ||
|
||
#include "model_test.h" | ||
#include "arch_test.h" | ||
|
||
RVTEST_ISA("RV32I_Zicbom_Zicboz_Zicsr_Ssdtso_Sstc") | ||
|
||
# Test code region | ||
.section .text.init | ||
.globl rvtest_entry_point | ||
rvtest_entry_point: | ||
RVMODEL_BOOT | ||
RVTEST_CODE_BEGIN | ||
|
||
RVTEST_SIGBASE(a1,signature_a1_m) | ||
|
||
#define VAL_POS(VALUE, POSITION) ((VALUE) << (POSITION)) | ||
#define CSR_SET_BIT(CSR, TMP1, TMP2, BIT) \ | ||
csrr TMP1, CSR \ | ||
LI(BIT | ||
|
||
#ifdef TEST_CASE_1 | ||
|
||
RVTEST_CASE(0,"//check ISA:=regex(.*I.*Zicbom.*Zicboz.*Zicsr.*Ssdtso.*Sstc); def rvtest_mtrap_routine=True; def TEST_CASE_1=True",menvcfg) | ||
|
||
inst_0: | ||
// Simple read of the CSR's original value | ||
csrr t2, CSR_MENVCFG | ||
RVTEST_SIGUPD(a1, t2) | ||
|
||
inst_1: | ||
ori t1, t2, MENVCFG_FIOM | ||
csrw CSR_MENVCFG, t1 | ||
csrr t0, CSR_MENVCFG | ||
RVTEST_SIGUPD(a1, t0) | ||
|
||
inst_2: | ||
ori t1, t2, MENVCFG_CBIE | ||
csrw CSR_MENVCFG, t1 | ||
csrr t0, CSR_MENVCFG | ||
RVTEST_SIGUPD(a1, t0) | ||
|
||
inst_3: | ||
ori t1, t2, MENVCFG_CBCFE | ||
csrw CSR_MENVCFG, t1 | ||
csrr t0, CSR_MENVCFG | ||
RVTEST_SIGUPD(a1, t0) | ||
|
||
inst4: | ||
ori t1, t2, MENVCFG_CBZE | ||
csrw CSR_MENVCFG, t1 | ||
csrr t0, CSR_MENVCFG | ||
RVTEST_SIGUPD(a1, t0) | ||
|
||
inst5: | ||
ori t1, t2, MENVCFG_DTSO | ||
csrw CSR_MENVCFG, t1 | ||
csrr t0, CSR_MENVCFG | ||
RVTEST_SIGUPD(a1, t0) | ||
|
||
instLAST: | ||
// Restore the CSR's original value | ||
csrw CSR_MENVCFG, t2 | ||
csrr t0, CSR_MENVCFG | ||
RVTEST_SIGUPD(a1, t0) | ||
|
||
|
||
#endif | ||
|
||
|
||
RVTEST_CODE_END | ||
RVMODEL_HALT | ||
|
||
RVTEST_DATA_BEGIN | ||
# Input data section. | ||
.data | ||
.align 4 | ||
RVTEST_DATA_END | ||
|
||
# Output data section. | ||
RVMODEL_DATA_BEGIN | ||
rvtest_sig_begin: | ||
signature_a1_m: | ||
.fill 32*(XLEN/32),4,0xdeadbeef | ||
|
||
sig_begin_canary: | ||
CANARY; | ||
|
||
mtrap_sigptr: | ||
.fill 4, 4, 0xdeadbeef | ||
|
||
#ifdef rvtest_gpr_save | ||
gpr_save: | ||
.fill 32*(XLEN/32), 4, 0xdeadbeef | ||
#endif | ||
|
||
sig_end_canary: | ||
CANARY; | ||
rvtest_sig_end: | ||
RVMODEL_DATA_END |