Repository navigation
Conversation
Fix race conditions and timing discrepancies during reset handling in `ot_rstmgr` and `ot_sysrst_ctrl`: - In `ot_rstmgr_reset_bus`: when called while the vCPU is running (`s->cpu->running`), queue the bus reset via `async_run_on_cpu` and issue `cpu_exit(s->cpu)`. This prevents synchronous reset handling during an in-flight TCG translation block, avoiding PC corruption (`0x8080` -> `0x8084` via `CF_PCREL` `+4` epilogue) and subsequent illegal instruction exceptions in mask ROM. - In `ot_rstmgr_reset_req`: when on the vCPU thread (`qemu_cpu_is_self`), only call `cpu_exit(s->cpu)` instead of `cpu_pause(s->cpu)` to avoid prematurely setting `s->cpu->stopped = true` before the execution loop has unwound. - Clean up the vCPU stop-wait logic in `ot_rstmgr_reset_bus` to guard the wait loop on `!qemu_cpu_is_self && !s->cpu->stopped`, avoiding self-deadlock and ensuring `s->cpu->stop = false` across all paths. - In `ot_sysrst_ctrl`: switch `combo_rst_timer` from `QEMU_CLOCK_REALTIME` + hardcoded 3 ms to `OT_VIRTUAL_CLOCK` using `(rst_det_cyc + 1) * 5000 ns` to accurately match the 200 kHz AON clock cycle timing in `COM_DET_CTL`. - In `ot_sysrst_ctrl`: delete `combo_rst_timer` and lower `rst_req` on combo deassertion (`prev_trig && !curr_trig`), matching `sysrst_ctrl_combo.sv`, and remove ungrounded timer re-arming on input pin changes. Co-authored-by: Google Antigravity <242056456+google-antigravity@users.noreply.github.com> Signed-off-by: Yi-Hsuan Deng <yhdeng@google.com> Change-Id: I8c6e38a670d60bedf5133ebd6ea32d046a6a6964
|
|
||
| static void ot_rstmgr_reset_bus(void *opaque); | ||
|
|
||
| static void ot_rstmgr_reset_bus_on_cpu(CPUState *cpu, run_on_cpu_data data) |
There was a problem hiding this comment.
Nit: probably you can move this function down so we don't define the dummy ot_rstmgr_reset_bus
| } else if (prev_trig && !curr_trig) { | ||
| if (out_ctl & R_COM_OUT_CTL_0_RST_REQ_MASK) { | ||
| timer_del(s->combo_rst_timer); | ||
| ibex_irq_set(&s->rst_req, 0); |
There was a problem hiding this comment.
In sysrst_ctrl_comboact.sv, rst_req_q is actually latched (assign rst_req_d = rst_req_q | combo_ot_pulse) and only cleared on reset (!rst_ni, which ot_sysrst_ctrl_reset_enter already handles), hence releasing the combo keys shouldn't lower rst_req here (only timer_del(s->combo_rst_timer) should happen if the detection timer hasn't expired yet)
| qemu_clock_get_ns(QEMU_CLOCK_REALTIME) + | ||
| (rst_det_cyc > 0u ? 3000000LL : 0LL)); | ||
| qemu_clock_get_ns(OT_VIRTUAL_CLOCK) + | ||
| (int64_t)(rst_det_cyc + 1u) * 5000LL); |
There was a problem hiding this comment.
Nit: ((int64_t)rst_det_cyc + 1) * 5000LL to avoid 32-bit unsigned overflow if rst_det_cyc == UINT32_MAX (also IIUC u_sysrst_ctrl_detect in sysrst_ctrl_combo.sv counts key_intr_debounce_ctl + 1 cycles in DebounceSt before DetectSt, in case we want to include that too)
Fix race conditions and timing discrepancies during reset handling in
ot_rstmgrandot_sysrst_ctrl:ot_rstmgr_reset_bus: when called while the vCPU is running (s->cpu->running), queue the bus reset viaasync_run_on_cpuand issuecpu_exit(s->cpu). This prevents synchronous reset handling during an in-flight TCG translation block, avoiding PC corruption (0x8080->0x8084viaCF_PCREL+4epilogue) and subsequent illegal instruction exceptions in mask ROM.ot_rstmgr_reset_req: when on the vCPU thread (qemu_cpu_is_self), only callcpu_exit(s->cpu)instead ofcpu_pause(s->cpu)to avoid prematurely settings->cpu->stopped = truebefore the execution loop has unwound.ot_rstmgr_reset_busto guard the wait loop on!qemu_cpu_is_self && !s->cpu->stopped, avoiding self-deadlock and ensurings->cpu->stop = falseacross all paths.ot_sysrst_ctrl: switchcombo_rst_timerfromQEMU_CLOCK_REALTIME+ hardcoded 3 ms toOT_VIRTUAL_CLOCKusing(rst_det_cyc + 1) * 5000 nsto accurately match the 200 kHz AON clock cycle timing inCOM_DET_CTL.ot_sysrst_ctrl: deletecombo_rst_timerand lowerrst_reqon combo deassertion (prev_trig && !curr_trig), matchingsysrst_ctrl_combo.sv, and remove ungrounded timer re-arming on input pin changes.