From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Khntb-0006QA-WA for qemu-devel@nongnu.org; Mon, 22 Sep 2008 12:04:20 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Khntb-0006Pk-78 for qemu-devel@nongnu.org; Mon, 22 Sep 2008 12:04:19 -0400 Received: from [199.232.76.173] (port=54387 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Khntb-0006Pc-1o for qemu-devel@nongnu.org; Mon, 22 Sep 2008 12:04:19 -0400 Received: from savannah.gnu.org ([199.232.41.3]:39420 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Khnta-00051G-Gi for qemu-devel@nongnu.org; Mon, 22 Sep 2008 12:04:18 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1KhntZ-0006Sy-Qw for qemu-devel@nongnu.org; Mon, 22 Sep 2008 16:04:17 +0000 Received: from aliguori by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1KhntZ-0006St-FV for qemu-devel@nongnu.org; Mon, 22 Sep 2008 16:04:17 +0000 MIME-Version: 1.0 Errors-To: aliguori Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Anthony Liguori Message-Id: Date: Mon, 22 Sep 2008 16:04:17 +0000 Subject: [Qemu-devel] [5293] LSI SCSI: raise UDC on infinite loop (Marcelo Tosatti) Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Revision: 5293 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5293 Author: aliguori Date: 2008-09-22 16:04:16 +0000 (Mon, 22 Sep 2008) Log Message: ----------- 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 Signed-off-by: Anthony Liguori Modified Paths: -------------- trunk/hw/lsi53c895a.c Modified: trunk/hw/lsi53c895a.c =================================================================== --- trunk/hw/lsi53c895a.c 2008-09-22 15:30:26 UTC (rev 5292) +++ trunk/hw/lsi53c895a.c 2008-09-22 16:04:16 UTC (rev 5293) @@ -839,9 +839,11 @@ uint32_t insn; uint32_t addr; int opcode; + int insn_processed = 0; s->istat1 |= LSI_ISTAT1_SRUN; again: + insn_processed++; insn = read_dword(s, s->dsp); addr = read_dword(s, s->dsp + 4); DPRINTF("SCRIPTS dsp=%08x opcode %08x arg %08x\n", s->dsp, insn, addr); @@ -1196,8 +1198,12 @@ } } } - /* ??? Need to avoid infinite loops. */ - if (s->istat1 & LSI_ISTAT1_SRUN && !s->waiting) { + if (insn_processed > 10000 && !s->waiting) { + if (!(s->sien0 & LSI_SIST0_UDC)) + fprintf(stderr, "inf. loop with UDC masked\n"); + lsi_script_scsi_interrupt(s, LSI_SIST0_UDC, 0); + lsi_disconnect(s); + } else if (s->istat1 & LSI_ISTAT1_SRUN && !s->waiting) { if (s->dcntl & LSI_DCNTL_SSM) { lsi_script_dma_interrupt(s, LSI_DSTAT_SSI); } else {