Repository navigation
Conversation
|
@romancardenas ready for review :) |
romancardenas
left a comment
There was a problem hiding this comment.
Thanks! I added a few comments.
| pub enum Interrupt { | ||
| SupervisorSoft = 1, | ||
| VirtSupervisorSoft = 2, | ||
| SupervisorTimer = 5, | ||
| VirtSupervisorTimer = 6, | ||
| SupervisorExternal = 9, | ||
| VirtSupervisorExternal = 10, | ||
| SupervisorGuestExternal = 12, | ||
| } |
There was a problem hiding this comment.
Could you add the new variants to interrupt::machine.rs and interrupt::supervisor.rs?
There was a problem hiding this comment.
@romancardenas I'm not sure I'm following here. When I look at interrupt::supervisor.rs it does not contain m-mode interrupts. also interrupt::supervisor.rs would not be active at the export on the crate level, as s-mode would not be enabled while hs-mode is. I believe m-mode could see hs-mode, so i can add them there.
There was a problem hiding this comment.
added exceptions and interrupts to machine.rs as well.
There was a problem hiding this comment.
I started working on this logic on another branch for interrupt::hypervisor.rs and I see why you want them in interrupt::supervisor.rs now. Do you want me to ensure the new exceptions and interrupts are behind the hs-mode flag, so they do not impact any other crate users? Some might not have a catch _ arm when switching on the invariants. causing them to need to add one before they can use the new crate version.
| // User or Virtual User Environment Call | ||
| UserVEnvCall = 8, | ||
| SupervisorEnvCall = 9, | ||
| // Virtual Supervisor Environment Call | ||
| GuestSupervisorEnvCall = 10, | ||
| InstructionPageFault = 12, | ||
| LoadPageFault = 13, | ||
| StorePageFault = 15, | ||
| SoftwareCheck = 18, | ||
| HardwareError = 19, | ||
| // 2 stage translation fault on instruction fetch | ||
| InstructionGuestFault = 20, | ||
| // 2 stage translation fault on memory load | ||
| LoadGuestFault = 21, | ||
| VirtualInstructionGuest = 22, | ||
| // 2 stage translation fault on memory store or atomic op | ||
| StoreGuestPageFault = 23, |
There was a problem hiding this comment.
Add these new variants to interrupt::machine.rs and interrupt::supervisor.rs.
Also, preserve the naming for already user-level causes.
There was a problem hiding this comment.
Same as here. Let me know your thoughts on supervisor receiving the new exceptions. I believe it should be fine either way, but I don't think supervisor => s-mode in this repository can ever actually trap on the hs-mode ones.
|
|
||
| /// Disables interrupts globally in the current hart (hypervisor mode). | ||
| #[inline] | ||
| pub fn disable() { |
There was a problem hiding this comment.
For same functions as in supervisor level, you can just reexport them from interrupt::supervisor.rs
There was a problem hiding this comment.
I'm not sure if I can yet. I have not worked through the logic, but I think a lot of things depend on whether the trap came from HS, or VS-VU mode. Is it okay if I tackle this later?
| where | ||
| F: FnOnce() -> R, | ||
| { | ||
| let sstatus = sstatus::read(); |
There was a problem hiding this comment.
You can reuse the interrupt::supervisor::nested function and just add the code required for hypervisor mode.
There was a problem hiding this comment.
I'm not sure if I can yet. I have not worked through the logic, but I think a lot of things depend on whether the trap came from HS, or VS-VU mode. Is it okay if I tackle this later?
| #[cfg(target_arch = "riscv32")] | ||
| use crate::bits::bf_extract; | ||
| #[cfg(not(target_arch = "riscv32"))] | ||
| use crate::bits::{bf_extract, bf_insert}; |
There was a problem hiding this comment.
| #[cfg(target_arch = "riscv32")] | |
| use crate::bits::bf_extract; | |
| #[cfg(not(target_arch = "riscv32"))] | |
| use crate::bits::{bf_extract, bf_insert}; | |
| use crate::bits::bf_extract; | |
| #[cfg(not(target_arch = "riscv32"))] | |
| use crate::bits::bf_insert; |
There was a problem hiding this comment.
i needed a change to this as something wasn't compiling. take a look
| mask: 0x30, | ||
| } | ||
|
|
||
| csr_field_enum! { |
There was a problem hiding this comment.
Please, reexport it from mstatus. The same for GVA.
There was a problem hiding this comment.
I believe I have done what you needed here. Please take a look.
| read_only_csr_field! { | ||
| Mstatush, | ||
| /// Machine Previous Virtualization | ||
| mpv: 7, |
There was a problem hiding this comment.
Use the macro variant to use the field structure (same as in mstatus)
There was a problem hiding this comment.
i used the variant { ..., mpv, MPV: [7:7] }
| read_only_csr_field! { | ||
| Mstatush, | ||
| /// Guest Virtual Address | ||
| gva: 6, |
There was a problem hiding this comment.
Use the macro variant to use the field structure (same as in mstatus)
There was a problem hiding this comment.
i used the variant { ..., gva, GVA: [6:6] }
Co-authored-by: Román Cárdenas Rodríguez <rcardenas.rod@gmail.com>
Co-authored-by: Román Cárdenas Rodríguez <rcardenas.rod@gmail.com>
Co-authored-by: Román Cárdenas Rodríguez <rcardenas.rod@gmail.com>
Co-authored-by: Román Cárdenas Rodríguez <rcardenas.rod@gmail.com>
Co-authored-by: Román Cárdenas Rodríguez <rcardenas.rod@gmail.com>
Co-authored-by: Román Cárdenas Rodríguez <rcardenas.rod@gmail.com>
Co-authored-by: Román Cárdenas Rodríguez <rcardenas.rod@gmail.com>
Co-authored-by: Román Cárdenas Rodríguez <rcardenas.rod@gmail.com>
|
@romancardenas I have a few open questions for yourself as well. Thank you for taking a look and going through all of this. I'm very excited. |
This pr contains the ground work for supporting
hs-modein theriscvcrate.A step is added to riscv github workflow which builds with the feature
hs-modehs-mode,m-mode, ands-modeare completely independent of each other.A few changes have been made to
mstatusandmstatushin order to support fields that are used to indicate information if trapped fromhs-mode.Snapshot testing is used for
riscv_rtfor expected missing implementations of Interrupts and Exceptions. hypervisor lines were added to the snapshot.A
makefilegitignoreentry was added as I prefer to run commands and tests via makefiles. less memorization for me.Note: I am not an expert in any of this stuff. Please double check field values.