Add configuration option for reserved mtvec[MODE] values - #1533
Conversation
Tim Hutt (Timmmm)
left a comment
There was a problem hiding this comment.
Probably should be Xtvec everywhere since it also applies to stvec?
Otherwise LGTM.
| 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."), |
There was a problem hiding this comment.
Probably could add the value that was written?
|
|
||
| mapping MtvecModeReservedBehavior_str : MtvecModeReservedBehavior <-> string = { | ||
| Mtvec_Fatal <-> "Mtvec_Fatal", | ||
| Mtvec_UseOld <-> "Mtvec_UseOld", |
There was a problem hiding this comment.
Maybe Mtvec_Ignore? UseOld sounds a bit weird to me. Very minor though.
There was a problem hiding this comment.
Are these string mappings used anywhere?
| _ => [v with Mode = o[Mode]] | ||
| } | ||
| let v = Mk_Mtvec(v); | ||
| match (trapVectorMode_of_bits(v[Mode])) { |
There was a problem hiding this comment.
| match (trapVectorMode_of_bits(v[Mode])) { | |
| match trapVectorMode_of_bits(v[Mode]) { |
|
|
||
| mapping MtvecModeReservedBehavior_str : MtvecModeReservedBehavior <-> string = { | ||
| Mtvec_Fatal <-> "Mtvec_Fatal", | ||
| Mtvec_UseOld <-> "Mtvec_UseOld", |
There was a problem hiding this comment.
Are these string mappings used anywhere?
|
My Sail semantics is weak at best, but are you defining a specific
illegal->legal mapping for writing an illegal value to mtvec (UseOld)?
IT is a 2 bit fWAL ield , and that isn't the only possibility that an
implementation is allowed (it could keep the old value, ignore only the
write to bit 1, force mallest legal value, or force largest)
…On Fri, Feb 6, 2026 at 9:26 AM Prashanth Mundkur ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In model/core/sys_regs.sail
<#1533 (comment)>:
> @@ -578,12 +578,15 @@ register mtvec : Mtvec // Trap Vector
// PUBLIC: invoked from set_{ms}tvec() [exceptions/sys_exceptions.sail]
function legalize_tvec(o : Mtvec, v : xlenbits) -> Mtvec = {
- let v = Mk_Mtvec(v);
- match (trapVectorMode_of_bits(v[Mode])) {
- TV_Direct => v,
- TV_Vector => v,
- _ => [v with Mode = o[Mode]]
- }
+ let v = Mk_Mtvec(v);
+ match (trapVectorMode_of_bits(v[Mode])) {
⬇️ Suggested change
- match (trapVectorMode_of_bits(v[Mode])) {
+ match trapVectorMode_of_bits(v[Mode]) {
------------------------------
In model/core/platform_config.sail
<#1533 (comment)>:
> @@ -104,6 +104,17 @@ mapping XenvcfgCbieReservedBehavior_str : XenvcfgCbieReservedBehavior <-> string
}
overload to_str = {XenvcfgCbieReservedBehavior_str}
+enum MtvecModeReservedBehavior = {
+ Mtvec_Fatal,
+ Mtvec_UseOld,
+}
+
+mapping MtvecModeReservedBehavior_str : MtvecModeReservedBehavior <-> string = {
+ Mtvec_Fatal <-> "Mtvec_Fatal",
+ Mtvec_UseOld <-> "Mtvec_UseOld",
Are these string mappings used anywhere?
—
Reply to this email directly, view it on GitHub
<#1533 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AHPXVJRRHCB7OT533UJFI5L4KTFDNAVCNFSM6AAAAACUFIYYZOVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZTONRUGMYTEMBRGY>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
|
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. |
880d03f to
abd6314
Compare
|
I have changed UseOld to Ignore . |
Tim Hutt (Timmmm)
left a comment
There was a problem hiding this comment.
Nice, thanks!
Some mtvec[MODE] values are currently reserved. Add an option to configure what happens if a reserved value is written.