Skip to content

Commit adf2fbe

Browse files
committed
dirty.S: Add test for HADE bit
1 parent 0ab6b90 commit adf2fbe

File tree

2 files changed

+49
-7
lines changed

2 files changed

+49
-7
lines changed

isa/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ vpath %.S $(src_dir)
5050
$(RISCV_OBJDUMP) $< > $@
5151

5252
%.out: %
53-
$(RISCV_SIM) --isa=rv64gc_zfh_zicboz_svnapot_zicntr --misaligned $< 2> $@
53+
$(RISCV_SIM) --isa=rv64gc_zfh_zicboz_svnapot_zicntr_svadu --misaligned $< 2> $@
5454

5555
%.out32: %
56-
$(RISCV_SIM) --isa=rv32gc_zfh_zicboz_svnapot_zicntr --misaligned $< 2> $@
56+
$(RISCV_SIM) --isa=rv32gc_zfh_zicboz_svnapot_zicntr_svadu --misaligned $< 2> $@
5757

5858
define compile_template
5959

isa/rv64si/dirty.S

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,20 @@ RVTEST_CODE_BEGIN
3434
li t2, 1
3535
sw t2, dummy - DRAM_BASE, a0
3636

37-
# Set SUM=1 so user memory access is permitted
3837
li TESTNUM, 3
38+
# set HADE to 0
39+
#if __riscv_xlen == 64
40+
li a1, MENVCFG_HADE
41+
csrc menvcfg, a1
42+
#else
43+
li a1, MENVCFGH_HADE
44+
csrc menvcfgh, a1
45+
#endif
46+
47+
# We do this test twice (as 3 and again as 4). For the second run,
48+
# we'll have toggled HADE and branch to here:
49+
1:
50+
# Set SUM=1 so user memory access is permitted
3951
li a1, ((MSTATUS_MPP & ~(MSTATUS_MPP<<1)) * PRV_S) | MSTATUS_SUM
4052
csrs mstatus, a1
4153

@@ -64,8 +76,26 @@ RVTEST_CODE_BEGIN
6476
li t0, MSTATUS_MPRV
6577
csrs mstatus, t0
6678

79+
addi TESTNUM, TESTNUM, 1
80+
li t0, 5
81+
beq TESTNUM, t0, 1f
82+
83+
# reset this value:
84+
sw zero, dummy - DRAM_BASE, a0
85+
86+
# set HADE to 1
87+
#if __riscv_xlen == 64
88+
li a1, MENVCFG_HADE
89+
csrs menvcfg, a1
90+
#else
91+
li a1, MENVCFGH_HADE
92+
csrs menvcfgh, a1
93+
#endif
94+
95+
j 1b
96+
1:
6797
# Make sure that superpage entries trap when PPN LSBs are set.
68-
li TESTNUM, 4
98+
li TESTNUM, 5
6999
lw a0, page_table_1 - DRAM_BASE
70100
or a0, a0, 1 << PTE_PPN_SHIFT
71101
sw a0, page_table_1 - DRAM_BASE, t0
@@ -97,9 +127,21 @@ skip:
97127
mret
98128

99129
1:
100-
li t1, 3
101-
bne TESTNUM, t1, 1f
130+
li t1, 4
131+
bgt TESTNUM, t1, 1f
102132
# The implementation doesn't appear to set D bits in HW.
133+
# Verify that HADE is 0.
134+
#if __riscv_xlen == 64
135+
csrr a1, menvcfg
136+
li t0, MENVCFG_HADE
137+
and a1, a1, t0
138+
bnez a1, die
139+
#else
140+
csrr a1, menvcfgh
141+
li t0, MENVCFGH_HADE
142+
and a1, a1, t0
143+
bnez a1, die
144+
#endif
103145
# Make sure the D bit really is clear.
104146
lw t0, page_table_1
105147
and t1, t0, PTE_D
@@ -111,7 +153,7 @@ skip:
111153
mret
112154

113155
1:
114-
li t1, 4
156+
li t1, 5
115157
bne TESTNUM, t1, 1f
116158
j pass
117159

0 commit comments

Comments
 (0)