ia64/xen-unstable

changeset 16936:3daab9b636c1

ioemu: Better fix for SB16 infinite looping.

Qemu upstream solves "Fix an infinite loop in the emulated SB16
device" issue differently as stated in [2]

[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. Caglar Onur <caglar@pardus.org.tr>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Jan 30 09:33:26 2008 +0000 (2008-01-30)
parents daf1862c4ee5
children 4942f9909ec8
files tools/ioemu/hw/dma.c tools/ioemu/hw/sb16.c
line diff
     1.1 --- a/tools/ioemu/hw/dma.c	Wed Jan 30 09:31:35 2008 +0000
     1.2 +++ b/tools/ioemu/hw/dma.c	Wed Jan 30 09:33:26 2008 +0000
     1.3 @@ -440,6 +440,13 @@ static void dma_reset(void *opaque)
     1.4      write_cont (d, (0x0d << d->dshift), 0);
     1.5  }
     1.6  
     1.7 +static int dma_phony_handler (void *opaque, int nchan, int dma_pos, int dma_len)
     1.8 +{
     1.9 +    dolog ("unregistered DMA channel used nchan=%d dma_pos=%d dma_len=%d\n",
    1.10 +           nchan, dma_pos, dma_len);
    1.11 +    return dma_pos;
    1.12 +}
    1.13 +
    1.14  /* dshift = 0: 8 bit DMA, 1 = 16 bit DMA */
    1.15  static void dma_init2(struct dma_cont *d, int base, int dshift,
    1.16                        int page_base, int pageh_base)
    1.17 @@ -472,6 +479,9 @@ static void dma_init2(struct dma_cont *d
    1.18      }
    1.19      qemu_register_reset(dma_reset, d);
    1.20      dma_reset(d);
    1.21 +    for (i = 0; i < LENOFA (d->regs); ++i) {
    1.22 +        d->regs[i].transfer_handler = dma_phony_handler;
    1.23 +    }
    1.24  }
    1.25  
    1.26  static void dma_save (QEMUFile *f, void *opaque)
     2.1 --- a/tools/ioemu/hw/sb16.c	Wed Jan 30 09:31:35 2008 +0000
     2.2 +++ b/tools/ioemu/hw/sb16.c	Wed Jan 30 09:33:26 2008 +0000
     2.3 @@ -1188,6 +1188,12 @@ static int SB_read_DMA (void *opaque, in
     2.4      SB16State *s = opaque;
     2.5      int till, copy, written, free;
     2.6  
     2.7 +    if (s->block_size <= 0) {
     2.8 +        dolog ("invalid block size=%d nchan=%d dma_pos=%d dma_len=%d\n",
     2.9 +               s->block_size, nchan, dma_pos, dma_len);
    2.10 +        return dma_pos;
    2.11 +    }
    2.12 +
    2.13      if (s->left_till_irq < 0) {
    2.14          s->left_till_irq = s->block_size;
    2.15      }
    2.16 @@ -1235,10 +1241,8 @@ static int SB_read_DMA (void *opaque, in
    2.17              s->block_size);
    2.18  #endif
    2.19  
    2.20 -    if (s->block_size) {
    2.21 -        while (s->left_till_irq <= 0) {
    2.22 -            s->left_till_irq = s->block_size + s->left_till_irq;
    2.23 -        }
    2.24 +    while (s->left_till_irq <= 0) {
    2.25 +        s->left_till_irq = s->block_size + s->left_till_irq;
    2.26      }
    2.27  
    2.28      return dma_pos;