From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KeCvf-0006PH-7X for qemu-devel@nongnu.org; Fri, 12 Sep 2008 13:59:35 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KeCvd-0006OE-Q5 for qemu-devel@nongnu.org; Fri, 12 Sep 2008 13:59:34 -0400 Received: from [199.232.76.173] (port=38281 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KeCvd-0006O5-K1 for qemu-devel@nongnu.org; Fri, 12 Sep 2008 13:59:33 -0400 Received: from an-out-0708.google.com ([209.85.132.240]:44470) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KeCvd-0000vb-LX for qemu-devel@nongnu.org; Fri, 12 Sep 2008 13:59:33 -0400 Received: by an-out-0708.google.com with SMTP id d18so117029and.130 for ; Fri, 12 Sep 2008 10:59:31 -0700 (PDT) Message-ID: <48CAADCF.4000404@codemonkey.ws> Date: Fri, 12 Sep 2008 12:58:39 -0500 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] LSI SCSI: raise UDC on infinite loop (resend #1) References: <20080912123831.GA22472@dmt.cnet> In-Reply-To: <20080912123831.GA22472@dmt.cnet> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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 Cc: Paul Brook Paul: do you have an objection to me applying this? Regards, Anthony Liguori Marcelo Tosatti wrote: > 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. > > > diff --git a/qemu/hw/lsi53c895a.c b/qemu/hw/lsi53c895a.c > index 72ed5c3..50f66aa 100644 > --- a/qemu/hw/lsi53c895a.c > +++ b/qemu/hw/lsi53c895a.c > @@ -840,9 +840,11 @@ static void lsi_execute_script(LSIState *s) > 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); > @@ -1197,8 +1199,12 @@ again: > } > } > } > - /* ??? 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 { > > >