hw/scsi/mptsas: Reset doorbell state on reset
PATCH 1/1 hw/scsi/mptsas: Reset doorbell state on reset
Currently the mptsas reset function clears intr_status, but it doesn't reset the doorbell state machine. This means that the state machine and the interrupt state get out of sync, and the guest can trigger an assertion failure in mptsas_doorbell_read() where s->doorbell_state is still DOORBELL_READ but s->intr_status does not have MPI_HIS_DOORBELL_INTERRUPT set.
Fix this by having reset also reset the doorbell state. Strictly speaking we don't need to also clear doorbell_reply_idx and doorbell_reply_size, because those are only read when in DOORBELL_READ state, and the code always sets them up before transitioning into that state. But it's less confusing to clear them out on reset.
Cc: [email protected]
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/304
---
Disclaimer: this fixes the fuzzer repro case, and I have run "make check" and "make check-functional", but I'm pretty sure neither of those actually exercises the mptsas device...
--- hw/scsi/mptsas.c | 4 ++++ 1 file changed, 4 insertions(+)
hw/scsi/mptsas.c +4 -0
@@ -811,6 +811,10 @@ static void mptsas_soft_reset(MPTSASState *s) s->intr_status =0 ; s->intr_mask = save_mask; + s->doorbell_state =DOORBELL_NONE ; + s->doorbell_reply_idx =0 ; + s->doorbell_reply_size =0 ; + s->reply_free_tail =0 ; s->reply_free_head =0 ; s->reply_post_tail =0 ;
Signature · 1 line
2.43.0
Quoted 16 lines · Peter Maydell
Currently the mptsas reset function clears
intr_status, but it doesn't reset the doorbell state machine. This means that the state machine and the interrupt state get out of sync, and the guest can trigger an assertion failure inmptsas_doorbell_read()wheres->doorbell_stateis stillDOORBELL_READbuts->intr_statusdoes not haveMPI_HIS_DOORBELL_INTERRUPTset.Fix this by having reset also reset the doorbell state. Strictly speaking we don't need to also clear
doorbell_reply_idxanddoorbell_reply_size, because those are only read when inDOORBELL_READstate, and the code always sets them up before transitioning into that state. But it's less confusing to clear them out on reset.Cc: [email protected]
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/304
Quoted 8 lines
Signed-off-by Peter Maydell <[email protected]>---
Disclaimer: this fixes the fuzzer repro case, and I have run "make check" and "make check-functional", but I'm pretty sure neither of those actually exercises the mptsas device...--- hw/scsi/mptsas.c | 4 ++++ 1 file changed, 4 insertions(+)
Philippe Mathieu-Daudé
AppliedQuoted 16 lines · Peter Maydell
Currently the mptsas reset function clears
intr_status, but it doesn't reset the doorbell state machine. This means that the state machine and the interrupt state get out of sync, and the guest can trigger an assertion failure inmptsas_doorbell_read()wheres->doorbell_stateis stillDOORBELL_READbuts->intr_statusdoes not haveMPI_HIS_DOORBELL_INTERRUPTset.Fix this by having reset also reset the doorbell state. Strictly speaking we don't need to also clear
doorbell_reply_idxanddoorbell_reply_size, because those are only read when inDOORBELL_READstate, and the code always sets them up before transitioning into that state. But it's less confusing to clear them out on reset.Cc: [email protected]
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/304
Quoted 8 lines
Signed-off-by Peter Maydell <[email protected]>---
Disclaimer: this fixes the fuzzer repro case, and I have run "make check" and "make check-functional", but I'm pretty sure neither of those actually exercises the mptsas device...--- hw/scsi/mptsas.c | 4 ++++ 1 file changed, 4 insertions(+)
Queued via hw-misc tree, thanks.