Skip to content

Add configuration option for reserved mtvec[MODE] values - #1533

Merged
Tim Hutt (Timmmm) merged 3 commits into
riscv:masterfrom
challenger1024:mtvec
Mar 1, 2026
Merged

Tim Hutt (Timmmm) merged 3 commits into
riscv:masterfrom
challenger1024:mtvec

Conversation

@challenger1024

@challenger1024 Jiacheng Tong (challenger1024) commented Feb 6, 2026 •

Copy link
Copy Markdown
Contributor

Some mtvec[MODE] values are currently reserved. Add an option to configure what happens if a reserved value is written.

@github-actions

github-actions Bot commented Feb 6, 2026 •

Copy link
Copy Markdown

Test Results

2 314 tests  ±0   2 314 ✅ ±0   31m 43s ⏱️ +34s
    1 suites ±0       0 💤 ±0 
    1 files   ±0       0 ❌ ±0 

Results for commit eafd9af. ± Comparison against base commit a33475a.

♻️ This comment has been updated with latest results.

@Timmmm Tim Hutt (Timmmm) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Probably should be Xtvec everywhere since it also applies to stvec?

Otherwise LGTM.

Comment thread model/core/sys_regs.sail Outdated
TV_Direct => v,
TV_Vector => v,
_ => match mtvec_mode_reserved_behavior {
Mtvec_Fatal => reserved_behavior("Tried to write a reserved value to the MODE field of mtvec."),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Probably could add the value that was written?

Comment thread model/core/platform_config.sail Outdated

mapping MtvecModeReservedBehavior_str : MtvecModeReservedBehavior <-> string = {
Mtvec_Fatal <-> "Mtvec_Fatal",
Mtvec_UseOld <-> "Mtvec_UseOld",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Maybe Mtvec_Ignore? UseOld sounds a bit weird to me. Very minor though.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Are these string mappings used anywhere?

Comment thread model/core/sys_regs.sail Outdated
_ => [v with Mode = o[Mode]]
}
let v = Mk_Mtvec(v);
match (trapVectorMode_of_bits(v[Mode])) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
match (trapVectorMode_of_bits(v[Mode])) {
match trapVectorMode_of_bits(v[Mode]) {

Comment thread model/core/platform_config.sail Outdated

mapping MtvecModeReservedBehavior_str : MtvecModeReservedBehavior <-> string = {
Mtvec_Fatal <-> "Mtvec_Fatal",
Mtvec_UseOld <-> "Mtvec_UseOld",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Are these string mappings used anywhere?

@allenjbaum

Allen Baum (allenjbaum) commented Feb 7, 2026 via email

Copy link
Copy Markdown
Collaborator

@Timmmm

Copy link
Copy Markdown
Collaborator

Yeah it's defining the particular behaviour that the model already had hard-coded. We should probably decide how exactly we want to deal with all the WARL fields before adding more.

@challenger1024

Copy link
Copy Markdown
Contributor Author

I have changed UseOld to Ignore .
Tim Hutt (@Timmmm)

Comment thread model/core/platform_config.sail Outdated

@Timmmm Tim Hutt (Timmmm) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nice, thanks!

@Timmmm Tim Hutt (Timmmm) changed the title add configuration option for Mtvec Add configuration option for reserved mtvec[MODE] values Feb 28, 2026
@jordancarlin Jordan Carlin (jordancarlin) added the configuration Additional configuration settings needed for the model label Mar 1, 2026
@Timmmm Tim Hutt (Timmmm) added the will be merged Scheduled to be merged soon if nobody objects label Mar 1, 2026
@Timmmm
Tim Hutt (Timmmm) added this pull request to the merge queue Mar 1, 2026
Merged via the queue into riscv:master with commit 684d688 Mar 1, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

configuration Additional configuration settings needed for the model will be merged Scheduled to be merged soon if nobody objects

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants