@@ -34,16 +34,45 @@ RVTEST_CODE_BEGIN
34
34
li t2, 1
35
35
sw t2, dummy - DRAM_BASE, a0
36
36
37
- # Set SUM=1 so user memory access is permitted
38
37
li TESTNUM, 3
38
+ # set ADUE to 0
39
+ #if __riscv_xlen == 64
40
+ li a1 , MENVCFG_ADUE
41
+ csrc menvcfg, a1
42
+ #else
43
+ li a1 , MENVCFGH_ADUE
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 ADUE and branch to here:
49
+ 1 :
50
+ # Set SUM=1 so user memory access is permitted
39
51
li a1 , ((MSTATUS_MPP & ~(MSTATUS_MPP<<1 )) * PRV_S) | MSTATUS_SUM
40
52
csrs mstatus, a1
41
53
42
54
# Make sure SUM=1 works
43
55
lw t0, dummy - DRAM_BASE
44
56
bnez t0, die
45
57
46
- # Try a non-faulting store to make sure dirty bit is set
58
+ # Clear D bit, then do a non-faulting store and ensure D bit is set
59
+ # Leave MPRV
60
+ li t0, MSTATUS_MPRV
61
+ csrc mstatus, t0
62
+
63
+ # Clear D bit
64
+ lw t0, page_table_1
65
+ li a0 , ~(PTE_D)
66
+ and t0, t0, a0
67
+ sw t0, page_table_1, a0
68
+ sfence.vma
69
+
70
+ # Enter MPRV again
71
+ li t0, MSTATUS_MPRV
72
+ csrs mstatus, t0
73
+
74
+ # Now, the non-faulting store
75
+ addi t2, t2, 1
47
76
sw t2, dummy - DRAM_BASE, a0
48
77
49
78
# Make sure it succeeded
@@ -55,6 +84,7 @@ RVTEST_CODE_BEGIN
55
84
csrc mstatus, t0
56
85
57
86
# Make sure D bit is set
87
+ sfence.vma
58
88
lw t0, page_table_1
59
89
li a0 , PTE_A | PTE_D
60
90
and t0, t0, a0
@@ -64,8 +94,26 @@ RVTEST_CODE_BEGIN
64
94
li t0, MSTATUS_MPRV
65
95
csrs mstatus, t0
66
96
97
+ addi TESTNUM, TESTNUM, 1
98
+ li t0, 5
99
+ beq TESTNUM , t0, 1f
100
+
101
+ # reset this value:
102
+ sw zero, dummy - DRAM_BASE, a0
103
+
104
+ # set ADUE to 1
105
+ #if __riscv_xlen == 64
106
+ li a1 , MENVCFG_ADUE
107
+ csrs menvcfg, a1
108
+ #else
109
+ li a1 , MENVCFGH_ADUE
110
+ csrs menvcfgh, a1
111
+ #endif
112
+
113
+ j 1b
114
+ 1 :
67
115
# Make sure that superpage entries trap when PPN LSBs are set .
68
- li TESTNUM, 4
116
+ li TESTNUM, 5
69
117
lw a0 , page_table_1 - DRAM_BASE
70
118
or a0 , a0 , 1 << PTE_PPN_SHIFT
71
119
sw a0 , page_table_1 - DRAM_BASE, t0
@@ -97,9 +145,21 @@ skip:
97
145
mret
98
146
99
147
1 :
100
- li t1, 3
101
- bne TESTNUM , t1, 1f
148
+ li t1, 4
149
+ bgt TESTNUM , t1, 1f
102
150
# The implementation doesn't appear to set D bits in HW.
151
+ # Verify that ADUE is 0 .
152
+ #if __riscv_xlen == 64
153
+ csrr a1 , menvcfg
154
+ li t0, MENVCFG_ADUE
155
+ and a1 , a1 , t0
156
+ bnez a1 , die
157
+ #else
158
+ csrr a1 , menvcfgh
159
+ li t0, MENVCFGH_ADUE
160
+ and a1 , a1 , t0
161
+ bnez a1 , die
162
+ #endif
103
163
# Make sure the D bit really is clear.
104
164
lw t0, page_table_1
105
165
and t1, t0, PTE_D
@@ -111,7 +171,7 @@ skip:
111
171
mret
112
172
113
173
1 :
114
- li t1, 4
174
+ li t1, 5
115
175
bne TESTNUM , t1, 1f
116
176
j pass
117
177
0 commit comments