-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generating instruction footprints for different privilege modes. #86
Comments
Hello, So I debugged further on the above and found out that even after specifying the register value in the riscv64_config.toml, it was being overwritten when there is a Define-Enum event for Privilege. So I tried to update the privilege mode (cur_privilege) by overwriting it to what I wanted to set it with, in isla-lib/src/executor.rs in the get_id_and_initialize function. Here’s the diff:
It's a bit of a hack, I check using the id 1683 when cur_privilege is being checked for, and I return the desired value instead of what "shared_state.type_info.enum_members.get" returns. But I am not sure if it's working as expected, because for instance, with supervisor mode especially, I observe certain unexpected outputs. Following are some of those scenarios, The unexpected outputs: (1) I see an illegal instruction trap in the trace (a write to mcause in the trace with the value "2", write to mepc with current PC, etc.) on trying to read the S-mode registers like 'sstatus', 'stvec', 'sscratch', 'sepc', 'scause', 'stval', 'sip', 'sie', 'satp', 'scounteren', 'senvcfg' with Supervisor mode priivleges. (2) Further, executing the mret instruction doesn't trap on setting the privilege mode to Supervisor or User. (trace attached: sup_mret.txt) |
By default, Another option is to avoid The hack you've tried won't work in general because it will override all accesses even if the register is changed by the instruction, and it's fragile - when the numbering changes because of changes to the Sail source code it will break. |
Hello Brian, Thanks for your response. Though configuring the cur_privilege by adding it to registers.reset in the config file doesn't work (not sure why), using the -R command line option works! Indeed the hack I tried caused some issues, because the discrepancies I mentioned earlier (that occurred with my hack) are gone now. I have one more question regarding the traces: In the trace, some of the events are like the following where you have a field of a register (mstatus in this case) being read. Is there a way to also retrieve which field of mstatus is being read? e.g. MIE/MPP, etc.
|
Not directly, especially as you can access arbitrary bit-ranges in the register without giving a field. That said, most of the time they are accessed via helper functions, so if you add (for example) |
Hmm, the |
Hello Brian, indeed the --trace-function option works in that case. Thanks a lot! Hello Alasdair, |
Hello,
I am wondering if it's possible to generate footprints for each instruction that are specific to different privilege modes?
Particularly for RISC-V, I tried to set the cur_privilege to Supervisor in the config. Here's what the trace looked like:
Even though I can see the assume-reg cur_privilege with value Supervisor, eventually it says "define-enum" and sets that to Machine, so when cur_privilege is read after the (cycle) event, it's set to Machine and not Supervisor.
I haven't deep dived into the code to see what's causing this yet, it would be great if you can point me to that.
What I want to achieve is for instance, an instruction like "mret" should trap if executed by Supervisor mode.
Similarly, a "csrw mstatus, " should also trap if executed by Supervisor mode. Is this possible to observe in the footprints generated by Isla?
The text was updated successfully, but these errors were encountered: