ia64/xen-unstable

changeset 17394:b7637c5269d1

x86: Avoid use of domain_crash_synchronous() in C code.

We continue to use it in asm where it is a greater convenience and
where also it is much more clearly correct.

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Apr 04 16:25:52 2008 +0100 (2008-04-04)
parents 271ec82db921
children b1c0a0896488
files xen/arch/x86/hvm/emulate.c xen/arch/x86/hvm/hvm.c xen/arch/x86/hvm/intercept.c xen/arch/x86/hvm/io.c xen/arch/x86/hvm/vmx/realmode.c xen/arch/x86/hvm/vmx/vmcs.c xen/arch/x86/hvm/vmx/x86_32/exits.S xen/arch/x86/hvm/vmx/x86_64/exits.S
line diff
     1.1 --- a/xen/arch/x86/hvm/emulate.c	Fri Apr 04 16:25:03 2008 +0100
     1.2 +++ b/xen/arch/x86/hvm/emulate.c	Fri Apr 04 16:25:52 2008 +0100
     1.3 @@ -41,13 +41,16 @@ static int hvmemul_do_io(
     1.4          return X86EMUL_UNHANDLEABLE;
     1.5      }
     1.6  
     1.7 +    if ( p->state != STATE_IOREQ_NONE )
     1.8 +    {
     1.9 +        gdprintk(XENLOG_WARNING, "WARNING: io already pending (%d)?\n",
    1.10 +                 p->state);
    1.11 +        return X86EMUL_UNHANDLEABLE;
    1.12 +    }
    1.13 +
    1.14      curr->arch.hvm_vcpu.io_state =
    1.15          (val == NULL) ? HVMIO_dispatched : HVMIO_awaiting_completion;
    1.16  
    1.17 -    if ( p->state != STATE_IOREQ_NONE )
    1.18 -        gdprintk(XENLOG_WARNING, "WARNING: io already pending (%d)?\n",
    1.19 -                 p->state);
    1.20 -
    1.21      p->dir = dir;
    1.22      p->data_is_ptr = value_is_ptr;
    1.23      p->type = is_mmio ? IOREQ_TYPE_COPY : IOREQ_TYPE_PIO;
     2.1 --- a/xen/arch/x86/hvm/hvm.c	Fri Apr 04 16:25:03 2008 +0100
     2.2 +++ b/xen/arch/x86/hvm/hvm.c	Fri Apr 04 16:25:52 2008 +0100
     2.3 @@ -181,7 +181,8 @@ void hvm_do_resume(struct vcpu *v)
     2.4              break;
     2.5          default:
     2.6              gdprintk(XENLOG_ERR, "Weird HVM iorequest state %d.\n", p->state);
     2.7 -            domain_crash_synchronous();
     2.8 +            domain_crash(v->domain);
     2.9 +            return; /* bail */
    2.10          }
    2.11      }
    2.12  }
    2.13 @@ -742,9 +743,10 @@ void hvm_send_assist_req(struct vcpu *v)
    2.14      p = &get_ioreq(v)->vp_ioreq;
    2.15      if ( unlikely(p->state != STATE_IOREQ_NONE) )
    2.16      {
    2.17 -        /* This indicates a bug in the device model.  Crash the domain. */
    2.18 +        /* This indicates a bug in the device model. Crash the domain. */
    2.19          gdprintk(XENLOG_ERR, "Device model set bad IO state %d.\n", p->state);
    2.20 -        domain_crash_synchronous();
    2.21 +        domain_crash(v->domain);
    2.22 +        return;
    2.23      }
    2.24  
    2.25      prepare_wait_on_xen_event_channel(v->arch.hvm_vcpu.xen_port);
     3.1 --- a/xen/arch/x86/hvm/intercept.c	Fri Apr 04 16:25:03 2008 +0100
     3.2 +++ b/xen/arch/x86/hvm/intercept.c	Fri Apr 04 16:25:52 2008 +0100
     3.3 @@ -52,45 +52,45 @@ static inline void hvm_mmio_access(struc
     3.4  {
     3.5      unsigned long data;
     3.6  
     3.7 -    switch ( p->type )
     3.8 +    if ( !p->data_is_ptr )
     3.9      {
    3.10 -    case IOREQ_TYPE_COPY:
    3.11 -        if ( !p->data_is_ptr ) {
    3.12 -            if ( p->dir == IOREQ_READ )
    3.13 -                p->data = read_handler(v, p->addr, p->size);
    3.14 -            else    /* p->dir == IOREQ_WRITE */
    3.15 -                write_handler(v, p->addr, p->size, p->data);
    3.16 -        } else {    /* p->data_is_ptr */
    3.17 -            int i, sign = (p->df) ? -1 : 1;
    3.18 +        if ( p->dir == IOREQ_READ )
    3.19 +            p->data = read_handler(v, p->addr, p->size);
    3.20 +        else    /* p->dir == IOREQ_WRITE */
    3.21 +            write_handler(v, p->addr, p->size, p->data);
    3.22 +    }
    3.23 +    else
    3.24 +    {
    3.25 +        int i, sign = (p->df) ? -1 : 1;
    3.26  
    3.27 -            if ( p->dir == IOREQ_READ ) {
    3.28 -                for ( i = 0; i < p->count; i++ ) {
    3.29 -                    data = read_handler(v,
    3.30 -                        p->addr + (sign * i * p->size),
    3.31 -                        p->size);
    3.32 -                    (void)hvm_copy_to_guest_phys(
    3.33 -                        p->data + (sign * i * p->size),
    3.34 -                        &data,
    3.35 -                        p->size);
    3.36 -                }
    3.37 -            } else {/* p->dir == IOREQ_WRITE */
    3.38 -                for ( i = 0; i < p->count; i++ ) {
    3.39 -                    (void)hvm_copy_from_guest_phys(
    3.40 -                        &data,
    3.41 -                        p->data + (sign * i * p->size),
    3.42 -                        p->size);
    3.43 -                    write_handler(v,
    3.44 -                        p->addr + (sign * i * p->size),
    3.45 -                        p->size, data);
    3.46 -                }
    3.47 +        if ( p->dir == IOREQ_READ )
    3.48 +        {
    3.49 +            for ( i = 0; i < p->count; i++ )
    3.50 +            {
    3.51 +                data = read_handler(
    3.52 +                    v,
    3.53 +                    p->addr + (sign * i * p->size),
    3.54 +                    p->size);
    3.55 +                (void)hvm_copy_to_guest_phys(
    3.56 +                    p->data + (sign * i * p->size),
    3.57 +                    &data,
    3.58 +                    p->size);
    3.59              }
    3.60          }
    3.61 -        break;
    3.62 -
    3.63 -    default:
    3.64 -        printk("hvm_mmio_access: error ioreq type %x\n", p->type);
    3.65 -        domain_crash_synchronous();
    3.66 -        break;
    3.67 +        else
    3.68 +        {
    3.69 +            for ( i = 0; i < p->count; i++ )
    3.70 +            {
    3.71 +                (void)hvm_copy_from_guest_phys(
    3.72 +                    &data,
    3.73 +                    p->data + (sign * i * p->size),
    3.74 +                    p->size);
    3.75 +                write_handler(
    3.76 +                    v,
    3.77 +                    p->addr + (sign * i * p->size),
    3.78 +                    p->size, data);
    3.79 +            }
    3.80 +        }
    3.81      }
    3.82  }
    3.83  
     4.1 --- a/xen/arch/x86/hvm/io.c	Fri Apr 04 16:25:03 2008 +0100
     4.2 +++ b/xen/arch/x86/hvm/io.c	Fri Apr 04 16:25:52 2008 +0100
     4.3 @@ -148,20 +148,19 @@ void send_timeoffset_req(unsigned long t
     4.4  void send_invalidate_req(void)
     4.5  {
     4.6      struct vcpu *v = current;
     4.7 -    vcpu_iodata_t *vio;
     4.8 +    vcpu_iodata_t *vio = get_ioreq(v);
     4.9      ioreq_t *p;
    4.10  
    4.11 -    vio = get_ioreq(v);
    4.12 -    if ( vio == NULL )
    4.13 -    {
    4.14 -        printk("bad shared page: %lx\n", (unsigned long) vio);
    4.15 -        domain_crash_synchronous();
    4.16 -    }
    4.17 +    BUG_ON(vio == NULL);
    4.18  
    4.19      p = &vio->vp_ioreq;
    4.20      if ( p->state != STATE_IOREQ_NONE )
    4.21 -        printk("WARNING: send invalidate req with something "
    4.22 -               "already pending (%d)?\n", p->state);
    4.23 +    {
    4.24 +        gdprintk(XENLOG_ERR, "WARNING: send invalidate req with something "
    4.25 +                 "already pending (%d)?\n", p->state);
    4.26 +        domain_crash(v->domain);
    4.27 +        return;
    4.28 +    }
    4.29  
    4.30      p->type = IOREQ_TYPE_INVALIDATE;
    4.31      p->size = 4;
    4.32 @@ -225,12 +224,6 @@ void hvm_io_assist(void)
    4.33      ioreq_t *p = &get_ioreq(curr)->vp_ioreq;
    4.34      enum hvm_io_state io_state;
    4.35  
    4.36 -    if ( p->state != STATE_IORESP_READY )
    4.37 -    {
    4.38 -        gdprintk(XENLOG_ERR, "Unexpected HVM iorequest state %d.\n", p->state);
    4.39 -        domain_crash_synchronous();
    4.40 -    }
    4.41 -
    4.42      rmb(); /* see IORESP_READY /then/ read contents of ioreq */
    4.43  
    4.44      p->state = STATE_IOREQ_NONE;
     5.1 --- a/xen/arch/x86/hvm/vmx/realmode.c	Fri Apr 04 16:25:03 2008 +0100
     5.2 +++ b/xen/arch/x86/hvm/vmx/realmode.c	Fri Apr 04 16:25:52 2008 +0100
     5.3 @@ -172,7 +172,7 @@ static void realmode_emulate_one(struct 
     5.4               hvmemul_ctxt->insn_buf[0], hvmemul_ctxt->insn_buf[1],
     5.5               hvmemul_ctxt->insn_buf[2], hvmemul_ctxt->insn_buf[3],
     5.6               hvmemul_ctxt->insn_buf[4], hvmemul_ctxt->insn_buf[5]);
     5.7 -    domain_crash_synchronous();
     5.8 +    domain_crash(curr->domain);
     5.9  }
    5.10  
    5.11  void vmx_realmode(struct cpu_user_regs *regs)
     6.1 --- a/xen/arch/x86/hvm/vmx/vmcs.c	Fri Apr 04 16:25:03 2008 +0100
     6.2 +++ b/xen/arch/x86/hvm/vmx/vmcs.c	Fri Apr 04 16:25:52 2008 +0100
     6.3 @@ -729,14 +729,14 @@ void vmx_destroy_vmcs(struct vcpu *v)
     6.4      arch_vmx->vmcs = NULL;
     6.5  }
     6.6  
     6.7 -void vm_launch_fail(unsigned long eflags)
     6.8 +void vm_launch_fail(void)
     6.9  {
    6.10      unsigned long error = __vmread(VM_INSTRUCTION_ERROR);
    6.11      printk("<vm_launch_fail> error code %lx\n", error);
    6.12      domain_crash_synchronous();
    6.13  }
    6.14  
    6.15 -void vm_resume_fail(unsigned long eflags)
    6.16 +void vm_resume_fail(void)
    6.17  {
    6.18      unsigned long error = __vmread(VM_INSTRUCTION_ERROR);
    6.19      printk("<vm_resume_fail> error code %lx\n", error);
     7.1 --- a/xen/arch/x86/hvm/vmx/x86_32/exits.S	Fri Apr 04 16:25:03 2008 +0100
     7.2 +++ b/xen/arch/x86/hvm/vmx/x86_32/exits.S	Fri Apr 04 16:25:52 2008 +0100
     7.3 @@ -129,7 +129,6 @@ ENTRY(vmx_asm_do_vmentry)
     7.4  /*vmx_resume:*/
     7.5          HVM_RESTORE_ALL_NOSEGREGS
     7.6          VMRESUME
     7.7 -        pushf
     7.8          call vm_resume_fail
     7.9          ud2
    7.10  
    7.11 @@ -137,7 +136,6 @@ vmx_launch:
    7.12          movb $1,VCPU_vmx_launched(%ebx)
    7.13          HVM_RESTORE_ALL_NOSEGREGS
    7.14          VMLAUNCH
    7.15 -        pushf
    7.16          call vm_launch_fail
    7.17          ud2
    7.18  
     8.1 --- a/xen/arch/x86/hvm/vmx/x86_64/exits.S	Fri Apr 04 16:25:03 2008 +0100
     8.2 +++ b/xen/arch/x86/hvm/vmx/x86_64/exits.S	Fri Apr 04 16:25:52 2008 +0100
     8.3 @@ -148,7 +148,6 @@ ENTRY(vmx_asm_do_vmentry)
     8.4  /*vmx_resume:*/
     8.5          HVM_RESTORE_ALL_NOSEGREGS
     8.6          VMRESUME
     8.7 -        pushfq
     8.8          call vm_resume_fail
     8.9          ud2
    8.10  
    8.11 @@ -156,7 +155,6 @@ vmx_launch:
    8.12          movb $1,VCPU_vmx_launched(%rbx)
    8.13          HVM_RESTORE_ALL_NOSEGREGS
    8.14          VMLAUNCH
    8.15 -        pushfq
    8.16          call vm_launch_fail
    8.17          ud2
    8.18