ia64/xen-unstable

changeset 17337:b667e220e556

x86, hvm: MMIO emulations should defer domain shutdown requests until
the relevant instruction has been fully emulated (which may require
multiple round trips to qemu-dm).
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Mar 27 11:39:57 2008 +0000 (2008-03-27)
parents a294519d97d2
children a8328ea7853d
files xen/arch/x86/hvm/io.c xen/common/domain.c
line diff
     1.1 --- a/xen/arch/x86/hvm/io.c	Thu Mar 27 11:03:45 2008 +0000
     1.2 +++ b/xen/arch/x86/hvm/io.c	Thu Mar 27 11:39:57 2008 +0000
     1.3 @@ -221,35 +221,34 @@ int handle_mmio_with_translation(unsigne
     1.4  
     1.5  void hvm_io_assist(void)
     1.6  {
     1.7 -    struct vcpu *v = current;
     1.8 -    ioreq_t *p = &get_ioreq(v)->vp_ioreq;
     1.9 +    struct vcpu *curr = current;
    1.10 +    ioreq_t *p = &get_ioreq(curr)->vp_ioreq;
    1.11      enum hvm_io_state io_state;
    1.12  
    1.13      if ( p->state != STATE_IORESP_READY )
    1.14      {
    1.15          gdprintk(XENLOG_ERR, "Unexpected HVM iorequest state %d.\n", p->state);
    1.16 -        domain_crash(v->domain);
    1.17 -        goto out;
    1.18 +        domain_crash_synchronous();
    1.19      }
    1.20  
    1.21      rmb(); /* see IORESP_READY /then/ read contents of ioreq */
    1.22  
    1.23      p->state = STATE_IOREQ_NONE;
    1.24  
    1.25 -    io_state = v->arch.hvm_vcpu.io_state;
    1.26 -    v->arch.hvm_vcpu.io_state = HVMIO_none;
    1.27 +    io_state = curr->arch.hvm_vcpu.io_state;
    1.28 +    curr->arch.hvm_vcpu.io_state = HVMIO_none;
    1.29  
    1.30      if ( (io_state == HVMIO_awaiting_completion) ||
    1.31           (io_state == HVMIO_handle_mmio_awaiting_completion) )
    1.32      {
    1.33 -        v->arch.hvm_vcpu.io_state = HVMIO_completed;
    1.34 -        v->arch.hvm_vcpu.io_data = p->data;
    1.35 +        curr->arch.hvm_vcpu.io_state = HVMIO_completed;
    1.36 +        curr->arch.hvm_vcpu.io_data = p->data;
    1.37          if ( io_state == HVMIO_handle_mmio_awaiting_completion )
    1.38              (void)handle_mmio();
    1.39      }
    1.40  
    1.41 - out:
    1.42 -    vcpu_end_shutdown_deferral(v);
    1.43 +    if ( p->state == STATE_IOREQ_NONE )
    1.44 +        vcpu_end_shutdown_deferral(curr);
    1.45  }
    1.46  
    1.47  void dpci_ioport_read(uint32_t mport, ioreq_t *p)
     2.1 --- a/xen/common/domain.c	Thu Mar 27 11:03:45 2008 +0000
     2.2 +++ b/xen/common/domain.c	Thu Mar 27 11:39:57 2008 +0000
     2.3 @@ -393,6 +393,8 @@ void __domain_crash_synchronous(void)
     2.4          this_cpu(mc_state).flags = 0;
     2.5      }
     2.6  
     2.7 +    vcpu_end_shutdown_deferral(current);
     2.8 +
     2.9      for ( ; ; )
    2.10          do_softirq();
    2.11  }
    2.12 @@ -459,10 +461,14 @@ void domain_resume(struct domain *d)
    2.13  
    2.14  int vcpu_start_shutdown_deferral(struct vcpu *v)
    2.15  {
    2.16 +    if ( v->defer_shutdown )
    2.17 +        return 1;
    2.18 +
    2.19      v->defer_shutdown = 1;
    2.20      smp_mb(); /* set deferral status /then/ check for shutdown */
    2.21      if ( unlikely(v->domain->is_shutting_down) )
    2.22          vcpu_check_shutdown(v);
    2.23 +
    2.24      return v->defer_shutdown;
    2.25  }
    2.26