Skip to content

Commit 8a4f7b7

Browse files
committed
Invalidate icache_var in SFENCE.VMA
1 parent d27423b commit 8a4f7b7

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/cpu/worker.mlog.jinja

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2201,10 +2201,14 @@ xRET__mprv_m_mode:
22012201
SFENCE.VMA:
22022202
#% do reset_locals()
22032203
# if executing in S-mode, raise an illegal instruction exception if TVM=1
2204-
# otherwise, no-op
2205-
jump end_instruction notEqual privilege_mode 0b01
2204+
jump SFENCE.VMA__no_tvm notEqual privilege_mode 0b01
22062205
op and $mstatus.tvm csr_mstatus 0b100000000000000000000
22072206
jump ILLEGAL_OP notEqual $mstatus.tvm 0
2207+
SFENCE.VMA__no_tvm:
2208+
2209+
# invalidate icache_var to force a page table walk
2210+
set icache_var null
2211+
22082212
jump end_instruction always
22092213

22102214
#% set modify_csr_start = 2
@@ -2585,7 +2589,7 @@ modify_csr__satp__ok:
25852589
set csr_satp $$new_value
25862590

25872591
# invalidate icache_var when writing satp because next_pc may now point to a different page
2588-
# TODO: we might be able to move this into SFENCE.VMA
2592+
# TODO: this may not be strictly required by the spec
25892593
set icache_var null
25902594

25912595
jump end_instruction_with_rd always

0 commit comments

Comments
 (0)