Commit ee4d919f30f1378cda697dd94d5a21b2a7f4d90d
1 parent
72ecb8d9
LSI SCSI: raise UDC on infinite loop (Marcelo Tosatti)
Raise UDC (Unexpected Disconnect) when a large enough number of instructions has been executed by the SCRIPTS processor. This "solution" is much simpler than temporarily interrupting execution. This remedies the situation with Windows which downloads SCRIPTS code that busy loops on guest main memory. Their drivers _do_ handle UDC appropriately (at least XP and 2003). It would be nicer to actually detect infinite loops, but until then, this bandaid seems acceptable. Since the situation seems to be rare enough, raise the number of instructions to 10000 (previously 1000). Three people other than myself had success with this patch. Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5293 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
8 additions
and
2 deletions
hw/lsi53c895a.c
... | ... | @@ -839,9 +839,11 @@ static void lsi_execute_script(LSIState *s) |
839 | 839 | uint32_t insn; |
840 | 840 | uint32_t addr; |
841 | 841 | int opcode; |
842 | + int insn_processed = 0; | |
842 | 843 | |
843 | 844 | s->istat1 |= LSI_ISTAT1_SRUN; |
844 | 845 | again: |
846 | + insn_processed++; | |
845 | 847 | insn = read_dword(s, s->dsp); |
846 | 848 | addr = read_dword(s, s->dsp + 4); |
847 | 849 | DPRINTF("SCRIPTS dsp=%08x opcode %08x arg %08x\n", s->dsp, insn, addr); |
... | ... | @@ -1196,8 +1198,12 @@ again: |
1196 | 1198 | } |
1197 | 1199 | } |
1198 | 1200 | } |
1199 | - /* ??? Need to avoid infinite loops. */ | |
1200 | - if (s->istat1 & LSI_ISTAT1_SRUN && !s->waiting) { | |
1201 | + if (insn_processed > 10000 && !s->waiting) { | |
1202 | + if (!(s->sien0 & LSI_SIST0_UDC)) | |
1203 | + fprintf(stderr, "inf. loop with UDC masked\n"); | |
1204 | + lsi_script_scsi_interrupt(s, LSI_SIST0_UDC, 0); | |
1205 | + lsi_disconnect(s); | |
1206 | + } else if (s->istat1 & LSI_ISTAT1_SRUN && !s->waiting) { | |
1201 | 1207 | if (s->dcntl & LSI_DCNTL_SSM) { |
1202 | 1208 | lsi_script_dma_interrupt(s, LSI_DSTAT_SSI); |
1203 | 1209 | } else { | ... | ... |