-
Notifications
You must be signed in to change notification settings - Fork 11
[sw-sysemu] Fix rvtimer write_mtimecmp immediate interrupt raise #66
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
base: master
Are you sure you want to change the base?
[sw-sysemu] Fix rvtimer write_mtimecmp immediate interrupt raise #66
Conversation
When mtimecmp is written to a value already in the past (mtime >= mtimecmp) and the interrupt was not previously asserted, raise the timer interrupt immediately. This mirrors hardware behavior where the comparator fires as soon as the condition is met. If the interrupt was already asserted (MIP bit already set), no action is needed — the hart already has a pending interrupt. Without this fix, tickless kernels that write mtimecmp to a nearly-passed value can deadlock: the internal interrupt flag is set but the hart MIP bit is never updated, so the ISR never fires and no subsequent write_mtimecmp call is made.
|
Good catch! (And yes, this does match rtl, took a while to untangle). Could you a add a minimal test case (we have a few in `tests/erbium/)? |
Of course! |
07e7244 to
1a34bc4
Compare
Done. |
1a34bc4 to
f31b49d
Compare
|
Force-pushing to fix the copyright date dismissed the CI flow |
From DV point of view I think this is change is fine! |
When mtimecmp is written to a value already in the past (mtime >= mtimecmp) and the interrupt was not previously asserted, raise the timer interrupt immediately. This mirrors hardware behavior where the comparator fires as soon as the condition is met.
If the interrupt was already asserted (MIP bit already set), no action is needed as the hart already has a pending interrupt.
Without this fix, tickless kernels that write mtimecmp to a nearly-passed value can deadlock: the internal interrupt flag is set but the hart MIP bit is never updated, so the ISR never fires and no subsequent write_mtimecmp call is made.