ia64/xen-unstable

changeset 16358:c0bdfda5183d

hvm: Clean up buf_ioreq handling.
Also, disable stdvga caching on hvm save/restore, as the shadow vga
state is not preserved.
Signed-off-by: Keir Fraser <keir@xensource.com>
author Keir Fraser <keir@xensource.com>
date Thu Nov 08 14:50:01 2007 +0000 (2007-11-08)
parents cb6675149af8
children 0ebac8576495
files tools/ioemu/target-i386-dm/helper2.c xen/arch/ia64/vmx/mmio.c xen/arch/ia64/vmx/save.c xen/arch/x86/hvm/intercept.c xen/arch/x86/hvm/save.c xen/arch/x86/hvm/stdvga.c xen/common/hvm/save.c xen/include/public/hvm/ioreq.h xen/include/xen/hvm/save.h
line diff
     1.1 --- a/tools/ioemu/target-i386-dm/helper2.c	Thu Nov 08 13:14:03 2007 +0000
     1.2 +++ b/tools/ioemu/target-i386-dm/helper2.c	Thu Nov 08 14:50:01 2007 +0000
     1.3 @@ -541,27 +541,28 @@ void __handle_buffered_iopage(CPUState *
     1.4  {
     1.5      buf_ioreq_t *buf_req = NULL;
     1.6      ioreq_t req;
     1.7 -    int qw = 0;
     1.8 +    int qw;
     1.9  
    1.10      if (!buffered_io_page)
    1.11          return;
    1.12  
    1.13      while (buffered_io_page->read_pointer !=
    1.14             buffered_io_page->write_pointer) {
    1.15 -        memset(&req, 0, sizeof(req));
    1.16 -        buf_req = &buffered_io_page->buf_ioreq[buffered_io_page->read_pointer %
    1.17 -				       IOREQ_BUFFER_SLOT_NUM];
    1.18 +        buf_req = &buffered_io_page->buf_ioreq[
    1.19 +            buffered_io_page->read_pointer % IOREQ_BUFFER_SLOT_NUM];
    1.20          req.size = 1UL << buf_req->size;
    1.21          req.count = 1;
    1.22          req.addr = buf_req->addr;
    1.23          req.data = buf_req->data;
    1.24          req.state = STATE_IOREQ_READY;
    1.25 -        req.dir  = buf_req->dir;
    1.26 +        req.dir = buf_req->dir;
    1.27 +        req.df = buf_req->df;
    1.28          req.type = buf_req->type;
    1.29 -        qw = req.size == 8;
    1.30 +        req.data_is_ptr = 0;
    1.31 +        qw = (req.size == 8);
    1.32          if (qw) {
    1.33 -            buf_req = &buffered_io_page->buf_ioreq[(buffered_io_page->read_pointer+1) %
    1.34 -                                               IOREQ_BUFFER_SLOT_NUM];
    1.35 +            buf_req = &buffered_io_page->buf_ioreq[
    1.36 +                (buffered_io_page->read_pointer+1) % IOREQ_BUFFER_SLOT_NUM];
    1.37              req.data |= ((uint64_t)buf_req->data) << 32;
    1.38          }
    1.39  
     2.1 --- a/xen/arch/ia64/vmx/mmio.c	Thu Nov 08 13:14:03 2007 +0000
     2.2 +++ b/xen/arch/ia64/vmx/mmio.c	Thu Nov 08 14:50:01 2007 +0000
     2.3 @@ -65,7 +65,7 @@ static int hvm_buffered_io_intercept(ior
     2.4  
     2.5      /* ignore READ ioreq_t and anything buffered io can't deal with */
     2.6      if (p->dir == IOREQ_READ || p->addr > 0xFFFFFUL ||
     2.7 -        p->data_is_ptr || p->df || p->count != 1)
     2.8 +        p->data_is_ptr || p->count != 1)
     2.9          return 0;
    2.10  
    2.11      for (i = 0; i < HVM_BUFFERED_IO_RANGE_NR; i++) {
    2.12 @@ -80,6 +80,7 @@ static int hvm_buffered_io_intercept(ior
    2.13  
    2.14      bp.type = p->type;
    2.15      bp.dir = p->dir;
    2.16 +    bp.df = p->df;
    2.17      switch (p->size) {
    2.18      case 1:
    2.19          bp.size = 0;
     3.1 --- a/xen/arch/ia64/vmx/save.c	Thu Nov 08 13:14:03 2007 +0000
     3.2 +++ b/xen/arch/ia64/vmx/save.c	Thu Nov 08 14:50:01 2007 +0000
     3.3 @@ -23,8 +23,7 @@
     3.4  #include <xen/types.h>
     3.5  #include <xen/hvm/save.h>
     3.6  
     3.7 -void
     3.8 -arch_hvm_save(struct hvm_save_header *hdr)
     3.9 +void arch_hvm_save(struct domain *d, struct hvm_save_header *hdr)
    3.10  {
    3.11      unsigned int i;
    3.12      
    3.13 @@ -32,8 +31,7 @@ arch_hvm_save(struct hvm_save_header *hd
    3.14          hdr->cpuid[i] = ia64_get_cpuid(i);
    3.15  }
    3.16  
    3.17 -int
    3.18 -arch_hvm_load(struct hvm_save_header *hdr)
    3.19 +int arch_hvm_load(struct domain *d, struct hvm_save_header *hdr)
    3.20  {
    3.21      unsigned int i;
    3.22      if (hdr->magic != HVM_FILE_MAGIC) {
     4.1 --- a/xen/arch/x86/hvm/intercept.c	Thu Nov 08 13:14:03 2007 +0000
     4.2 +++ b/xen/arch/x86/hvm/intercept.c	Thu Nov 08 14:50:01 2007 +0000
     4.3 @@ -163,18 +163,20 @@ int hvm_buffered_io_send(ioreq_t *p)
     4.4      /* Ensure buffered_iopage fits in a page */
     4.5      BUILD_BUG_ON(sizeof(buffered_iopage_t) > PAGE_SIZE);
     4.6  
     4.7 -    /* Return 0 for the cases we can't deal with. */
     4.8 -    if ( (p->addr > 0xffffful) || p->data_is_ptr || p->df || (p->count != 1) )
     4.9 -    {
    4.10 -        gdprintk(XENLOG_DEBUG, "slow ioreq. type:%d size:%"PRIu64" addr:0x%"
    4.11 -                 PRIx64" dir:%d ptr:%d df:%d count:%"PRIu64"\n",
    4.12 -                 p->type, p->size, p->addr, !!p->dir,
    4.13 -                 !!p->data_is_ptr, !!p->df, p->count);
    4.14 +    /*
    4.15 +     * Return 0 for the cases we can't deal with:
    4.16 +     *  - 'addr' is only a 20-bit field, so we cannot address beyond 1MB
    4.17 +     *  - we cannot buffer accesses to guest memory buffers, as the guest
    4.18 +     *    may expect the memory buffer to be synchronously accessed
    4.19 +     *  - the count field is usually used with data_is_ptr and since we don't
    4.20 +     *    support data_is_ptr we do not waste space for the count field either
    4.21 +     */
    4.22 +    if ( (p->addr > 0xffffful) || p->data_is_ptr || (p->count != 1) )
    4.23          return 0;
    4.24 -    }
    4.25  
    4.26      bp.type = p->type;
    4.27      bp.dir  = p->dir;
    4.28 +    bp.df   = p->df;
    4.29      switch ( p->size )
    4.30      {
    4.31      case 1:
     5.1 --- a/xen/arch/x86/hvm/save.c	Thu Nov 08 13:14:03 2007 +0000
     5.2 +++ b/xen/arch/x86/hvm/save.c	Thu Nov 08 14:50:01 2007 +0000
     5.3 @@ -24,8 +24,7 @@
     5.4  #include <asm/hvm/support.h>
     5.5  #include <public/hvm/save.h>
     5.6  
     5.7 -void
     5.8 -arch_hvm_save(struct hvm_save_header *hdr)
     5.9 +void arch_hvm_save(struct domain *d, struct hvm_save_header *hdr)
    5.10  {
    5.11      uint32_t eax, ebx, ecx, edx;
    5.12  
    5.13 @@ -36,10 +35,10 @@ arch_hvm_save(struct hvm_save_header *hd
    5.14      hdr->pad0 = 0;
    5.15  }
    5.16  
    5.17 -int
    5.18 -arch_hvm_load(struct hvm_save_header *hdr)
    5.19 +int arch_hvm_load(struct domain *d, struct hvm_save_header *hdr)
    5.20  {
    5.21      uint32_t eax, ebx, ecx, edx;
    5.22 +
    5.23      if ( hdr->magic != HVM_FILE_MAGIC )
    5.24      {
    5.25          gdprintk(XENLOG_ERR, 
    5.26 @@ -55,11 +54,14 @@ arch_hvm_load(struct hvm_save_header *hd
    5.27      }
    5.28  
    5.29      cpuid(1, &eax, &ebx, &ecx, &edx);
    5.30 -    /*TODO: need to define how big a difference is acceptable */
    5.31 +    /* TODO: need to define how big a difference is acceptable? */
    5.32      if ( hdr->cpuid != eax )
    5.33          gdprintk(XENLOG_WARNING, "HVM restore: saved CPUID (%#"PRIx32") "
    5.34                 "does not match host (%#"PRIx32").\n", hdr->cpuid, eax);
    5.35  
    5.36 +    /* VGA state is not saved/restored, so we nobble the cache. */
    5.37 +    d->arch.hvm_domain.stdvga.cache = 0;
    5.38 +
    5.39      return 0;
    5.40  }
    5.41  
     6.1 --- a/xen/arch/x86/hvm/stdvga.c	Thu Nov 08 13:14:03 2007 +0000
     6.2 +++ b/xen/arch/x86/hvm/stdvga.c	Thu Nov 08 14:50:01 2007 +0000
     6.3 @@ -220,7 +220,9 @@ static void stdvga_outb(uint64_t addr, u
     6.4          gdprintk(XENLOG_INFO, "entering stdvga and caching modes\n");
     6.5      }
     6.6      else if ( prev_stdvga && !s->stdvga )
     6.7 +    {
     6.8          gdprintk(XENLOG_INFO, "leaving stdvga\n");
     6.9 +    }
    6.10  }
    6.11  
    6.12  static void stdvga_outv(uint64_t addr, uint64_t data, uint32_t size)
    6.13 @@ -636,7 +638,7 @@ int stdvga_intercept_mmio(ioreq_t *p)
    6.14              buf = mmio_op(s, p);
    6.15              break;
    6.16          default:
    6.17 -            gdprintk(XENLOG_ERR, "unsupported mmio request type:%d "
    6.18 +            gdprintk(XENLOG_WARNING, "unsupported mmio request type:%d "
    6.19                       "addr:0x%04x data:0x%04x size:%d count:%d state:%d "
    6.20                       "isptr:%d dir:%d df:%d\n",
    6.21                       p->type, (int)p->addr, (int)p->data, (int)p->size,
     7.1 --- a/xen/common/hvm/save.c	Thu Nov 08 13:14:03 2007 +0000
     7.2 +++ b/xen/common/hvm/save.c	Thu Nov 08 14:50:01 2007 +0000
     7.3 @@ -94,7 +94,7 @@ int hvm_save(struct domain *d, hvm_domai
     7.4      else 
     7.5          hdr.changeset = -1ULL; /* Unknown */
     7.6  
     7.7 -    arch_hvm_save(&hdr);
     7.8 +    arch_hvm_save(d, &hdr);
     7.9  
    7.10      if ( hvm_save_entry(HEADER, 0, h, &hdr) != 0 )
    7.11      {
    7.12 @@ -144,7 +144,7 @@ int hvm_load(struct domain *d, hvm_domai
    7.13      if ( hvm_load_entry(HEADER, h, &hdr) != 0 ) 
    7.14          return -1;
    7.15  
    7.16 -    if ( arch_hvm_load(&hdr) )
    7.17 +    if ( arch_hvm_load(d, &hdr) )
    7.18          return -1;
    7.19  
    7.20      c = strrchr(xen_changeset(), ':');
     8.1 --- a/xen/include/public/hvm/ioreq.h	Thu Nov 08 13:14:03 2007 +0000
     8.2 +++ b/xen/include/public/hvm/ioreq.h	Thu Nov 08 14:50:01 2007 +0000
     8.3 @@ -78,11 +78,12 @@ struct shared_iopage {
     8.4  typedef struct shared_iopage shared_iopage_t;
     8.5  
     8.6  struct buf_ioreq {
     8.7 -    uint8_t  type;   /*  I/O type                    */
     8.8 -    uint8_t  dir:1;  /*  1=read, 0=write             */
     8.9 -    uint8_t  size:2; /*  0=>1, 1=>2, 2=>4, 3=>8. If 8, use two buf_ioreqs */
    8.10 -    uint32_t addr:20;/*  physical address            */
    8.11 -    uint32_t data;   /*  data                        */
    8.12 +    uint8_t  type;   /* I/O type                    */
    8.13 +    uint8_t  df:1;   /* EFLAGS.DF                   */
    8.14 +    uint8_t  dir:1;  /* 1=read, 0=write             */
    8.15 +    uint8_t  size:2; /* 0=>1, 1=>2, 2=>4, 3=>8. If 8, use two buf_ioreqs */
    8.16 +    uint32_t addr:20;/* physical address            */
    8.17 +    uint32_t data;   /* data                        */
    8.18  };
    8.19  typedef struct buf_ioreq buf_ioreq_t;
    8.20  
     9.1 --- a/xen/include/xen/hvm/save.h	Thu Nov 08 13:14:03 2007 +0000
     9.2 +++ b/xen/include/xen/hvm/save.h	Thu Nov 08 14:50:01 2007 +0000
     9.3 @@ -155,7 +155,7 @@ int hvm_load(struct domain *d, hvm_domai
     9.4  
     9.5  /* Arch-specific definitions. */
     9.6  struct hvm_save_header;
     9.7 -void arch_hvm_save(struct hvm_save_header *hdr);
     9.8 -int arch_hvm_load(struct hvm_save_header *hdr);
     9.9 +void arch_hvm_save(struct domain *d, struct hvm_save_header *hdr);
    9.10 +int arch_hvm_load(struct domain *d, struct hvm_save_header *hdr);
    9.11  
    9.12  #endif /* __XEN_HVM_SAVE_H__ */