From: "=?utf-8?q?S=2E=C3=87a=C4=9Flar?= Onur" Subject: [PATCH] Fix an infinite loop in the emulated SB16 device (c/s 3ef467ebd2f8 on 3.1-testing) Date: Tue, 29 Jan 2008 23:20:42 +0200 Message-ID: <200801292320.43960.caglar@pardus.org.tr> Reply-To: caglar@pardus.org.tr Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Return-path: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Keir Fraser Cc: Robert Buchholz , xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org Hi; Qemu upstream solves "Fix an infinite loop in the emulated SB16 device" i= ssue differently as stated in [2] Following patch (against xen-3.1-testing) reverts Xen [1] changes and mer= ges qemu ones, please apply. [1] http://xenbits.xensource.com/xen-3.1-testing.hg?rev/4b22d472bda6 [2] http://lists.gnu.org/archive/html/qemu-devel/2008-01/msg00709.html Signed-off-by: S.=C3=87a=C4=9Flar Onur diff -r ef03fdafc731 tools/ioemu/hw/dma.c --- a/tools/ioemu/hw/dma.c Mon Jan 28 10:42:14 2008 +0000 +++ b/tools/ioemu/hw/dma.c Tue Jan 29 23:09:20 2008 +0200 @@ -440,6 +440,13 @@ static void dma_reset(void *opaque) write_cont (d, (0x0d << d->dshift), 0); } =20 +static int dma_phony_handler (void *opaque, int nchan, int dma_pos, int = dma_len) +{ + dolog ("unregistered DMA channel used nchan=3D%d dma_pos=3D%d dma_le= n=3D%d\n", + nchan, dma_pos, dma_len); + return dma_pos; +} + /* dshift =3D 0: 8 bit DMA, 1 =3D 16 bit DMA */ static void dma_init2(struct dma_cont *d, int base, int dshift, int page_base, int pageh_base) @@ -472,6 +479,9 @@ static void dma_init2(struct dma_cont *d } qemu_register_reset(dma_reset, d); dma_reset(d); + for (i =3D 0; i < LENOFA (d->regs); ++i) { + d->regs[i].transfer_handler =3D dma_phony_handler; + } } =20 static void dma_save (QEMUFile *f, void *opaque) diff -r ef03fdafc731 tools/ioemu/hw/sb16.c --- a/tools/ioemu/hw/sb16.c Mon Jan 28 10:42:14 2008 +0000 +++ b/tools/ioemu/hw/sb16.c Tue Jan 29 23:09:20 2008 +0200 @@ -1188,6 +1188,12 @@ static int SB_read_DMA (void *opaque, in SB16State *s =3D opaque; int till, copy, written, free; =20 + if (s->block_size <=3D 0) { + dolog ("invalid block size=3D%d nchan=3D%d dma_pos=3D%d dma_len=3D= %d\n", + s->block_size, nchan, dma_pos, dma_len); + return dma_pos; + } + if (s->left_till_irq < 0) { s->left_till_irq =3D s->block_size; } @@ -1235,10 +1241,8 @@ static int SB_read_DMA (void *opaque, in s->block_size); #endif =20 - if (s->block_size) { - while (s->left_till_irq <=3D 0) { - s->left_till_irq =3D s->block_size + s->left_till_irq; - } + while (s->left_till_irq <=3D 0) { + s->left_till_irq =3D s->block_size + s->left_till_irq; } =20 return dma_pos; Cheers --=20 S.=C3=87a=C4=9Flar Onur http://cekirdek.pardus.org.tr/~caglar/ Linux is like living in a teepee. No Windows, no Gates and an Apache in h= ouse!