-
Notifications
You must be signed in to change notification settings - Fork 878
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
Fix read value of CSR mip. #1869
base: master
Are you sure you want to change the base?
Conversation
#1590 add the hvip read. |
Yes, the read value of |
without hvip read, the MIP_VSEIP and MIP_VSTIP will miss when reading mip. bool hvip_csr_t::unlogged_write(const reg_t val) noexcept { |
Thank you for the reminder! Yes, the read value of Previously, directly OR-ing the read value of I will revise the |
0178ba8
to
a5699bf
Compare
I have some questions about this. I mostly agree with what has changed but I don't quite get how an LCOF interrupt is ever to become pending through hvip. Spike currently reads mip to get knowledge of which interrupts are pending: void take_pending_interrupt() { take_interrupt(state.mip->read() & state.mie->read()); } If hvip has its own set of bits then mip.lcof must either be an alias of hvip.lcof or the interrupt pending logic has to also look at hvip.lcof. I am not sure if the spec is clear on what relation hvip.lcof has to mip and the other xIP CSRs. In any case, mip_csr_t::ip_read() only allows VSEIP and VSTIP bits of hvip to be read in mip. If this is the case I can't see any way for the IRQ to actually happen? Anything I am missing here? edit: The interrupt logic also has to be updated for this to work. diff --git a/riscv/processor.cc b/riscv/processor.cc
index 26af4a81..aadd987c 100644
--- a/riscv/processor.cc
+++ b/riscv/processor.cc
@@ -495,9 +495,22 @@ void processor_t::take_trap(trap_t& t, reg_t epc)
- reg_t adjusted_cause = interrupt ? bit - 1 : bit; // VSSIP -> SSIP, etc
+ int adjust_factor = 0;
+ if (interrupt){
+ switch (t.cause() & ~interrupt_bit){
+ // Reported as SEI when in VS mode
+ case IRQ_S_GEXT:
+ adjust_factor = IRQ_S_GEXT - IRQ_S_EXT;
+ break;
+ // Reported as is in VS mode
+ case IRQ_LCOF:
+ adjust_factor = 0;
+ break;
+ default:
+ adjust_factor = 1;
+ }
+ }
+ reg_t adjusted_cause = interrupt ? bit - adjust_factor : bit; // VSSIP -> SSIP, etc |
The read value of mip should only depend on the two bits, VSEIP and VSTIP of hvip. This PR fix the read value of CSR mip when Sscofpmf extension enabled. After implementing the Sscofpmf extension, hvip.LCOFIP became writable. This caused an issue where the entire value of hvip was OR-ed when reading mip. I revise the mip read logic to make it depend only on the hvip.VSEIP and hvip.VSTIP bits. Co-authored-by: Zhaoyang You <[email protected]>
a5699bf
to
019cd2f
Compare
The read value of mip should not depend on the value of hvip.
hvip.VSSIP is an alias of mip.VSSIP, so when reading hvip, the VSSIP bit of mip needs to be OR-ed. Similarly, when writing to hvip, the VSSIP bit of mip also needs to be updated.
However, there is no reason for the value of mip to depend on the value of hvip when being read.