[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] x86: Avoid use of domain_crash_synchronous() in C code.



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1207322752 -3600
# Node ID b7637c5269d133fc0828e76814e7f4333729caec
# Parent  271ec82db9218b42f5b04c94d41282e145343cc4
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@xxxxxxxxxx>
---
 xen/arch/x86/hvm/emulate.c          |   11 +++--
 xen/arch/x86/hvm/hvm.c              |    8 ++-
 xen/arch/x86/hvm/intercept.c        |   78 ++++++++++++++++++------------------
 xen/arch/x86/hvm/io.c               |   23 +++-------
 xen/arch/x86/hvm/vmx/realmode.c     |    2 
 xen/arch/x86/hvm/vmx/vmcs.c         |    4 -
 xen/arch/x86/hvm/vmx/x86_32/exits.S |    2 
 xen/arch/x86/hvm/vmx/x86_64/exits.S |    2 
 8 files changed, 62 insertions(+), 68 deletions(-)

diff -r 271ec82db921 -r b7637c5269d1 xen/arch/x86/hvm/emulate.c
--- a/xen/arch/x86/hvm/emulate.c        Fri Apr 04 16:25:03 2008 +0100
+++ b/xen/arch/x86/hvm/emulate.c        Fri Apr 04 16:25:52 2008 +0100
@@ -41,12 +41,15 @@ static int hvmemul_do_io(
         return X86EMUL_UNHANDLEABLE;
     }
 
+    if ( p->state != STATE_IOREQ_NONE )
+    {
+        gdprintk(XENLOG_WARNING, "WARNING: io already pending (%d)?\n",
+                 p->state);
+        return X86EMUL_UNHANDLEABLE;
+    }
+
     curr->arch.hvm_vcpu.io_state =
         (val == NULL) ? HVMIO_dispatched : HVMIO_awaiting_completion;
-
-    if ( p->state != STATE_IOREQ_NONE )
-        gdprintk(XENLOG_WARNING, "WARNING: io already pending (%d)?\n",
-                 p->state);
 
     p->dir = dir;
     p->data_is_ptr = value_is_ptr;
diff -r 271ec82db921 -r b7637c5269d1 xen/arch/x86/hvm/hvm.c
--- a/xen/arch/x86/hvm/hvm.c    Fri Apr 04 16:25:03 2008 +0100
+++ b/xen/arch/x86/hvm/hvm.c    Fri Apr 04 16:25:52 2008 +0100
@@ -181,7 +181,8 @@ void hvm_do_resume(struct vcpu *v)
             break;
         default:
             gdprintk(XENLOG_ERR, "Weird HVM iorequest state %d.\n", p->state);
-            domain_crash_synchronous();
+            domain_crash(v->domain);
+            return; /* bail */
         }
     }
 }
@@ -742,9 +743,10 @@ void hvm_send_assist_req(struct vcpu *v)
     p = &get_ioreq(v)->vp_ioreq;
     if ( unlikely(p->state != STATE_IOREQ_NONE) )
     {
-        /* This indicates a bug in the device model.  Crash the domain. */
+        /* This indicates a bug in the device model. Crash the domain. */
         gdprintk(XENLOG_ERR, "Device model set bad IO state %d.\n", p->state);
-        domain_crash_synchronous();
+        domain_crash(v->domain);
+        return;
     }
 
     prepare_wait_on_xen_event_channel(v->arch.hvm_vcpu.xen_port);
diff -r 271ec82db921 -r b7637c5269d1 xen/arch/x86/hvm/intercept.c
--- a/xen/arch/x86/hvm/intercept.c      Fri Apr 04 16:25:03 2008 +0100
+++ b/xen/arch/x86/hvm/intercept.c      Fri Apr 04 16:25:52 2008 +0100
@@ -52,45 +52,45 @@ static inline void hvm_mmio_access(struc
 {
     unsigned long data;
 
-    switch ( p->type )
-    {
-    case IOREQ_TYPE_COPY:
-        if ( !p->data_is_ptr ) {
-            if ( p->dir == IOREQ_READ )
-                p->data = read_handler(v, p->addr, p->size);
-            else    /* p->dir == IOREQ_WRITE */
-                write_handler(v, p->addr, p->size, p->data);
-        } else {    /* p->data_is_ptr */
-            int i, sign = (p->df) ? -1 : 1;
-
-            if ( p->dir == IOREQ_READ ) {
-                for ( i = 0; i < p->count; i++ ) {
-                    data = read_handler(v,
-                        p->addr + (sign * i * p->size),
-                        p->size);
-                    (void)hvm_copy_to_guest_phys(
-                        p->data + (sign * i * p->size),
-                        &data,
-                        p->size);
-                }
-            } else {/* p->dir == IOREQ_WRITE */
-                for ( i = 0; i < p->count; i++ ) {
-                    (void)hvm_copy_from_guest_phys(
-                        &data,
-                        p->data + (sign * i * p->size),
-                        p->size);
-                    write_handler(v,
-                        p->addr + (sign * i * p->size),
-                        p->size, data);
-                }
-            }
-        }
-        break;
-
-    default:
-        printk("hvm_mmio_access: error ioreq type %x\n", p->type);
-        domain_crash_synchronous();
-        break;
+    if ( !p->data_is_ptr )
+    {
+        if ( p->dir == IOREQ_READ )
+            p->data = read_handler(v, p->addr, p->size);
+        else    /* p->dir == IOREQ_WRITE */
+            write_handler(v, p->addr, p->size, p->data);
+    }
+    else
+    {
+        int i, sign = (p->df) ? -1 : 1;
+
+        if ( p->dir == IOREQ_READ )
+        {
+            for ( i = 0; i < p->count; i++ )
+            {
+                data = read_handler(
+                    v,
+                    p->addr + (sign * i * p->size),
+                    p->size);
+                (void)hvm_copy_to_guest_phys(
+                    p->data + (sign * i * p->size),
+                    &data,
+                    p->size);
+            }
+        }
+        else
+        {
+            for ( i = 0; i < p->count; i++ )
+            {
+                (void)hvm_copy_from_guest_phys(
+                    &data,
+                    p->data + (sign * i * p->size),
+                    p->size);
+                write_handler(
+                    v,
+                    p->addr + (sign * i * p->size),
+                    p->size, data);
+            }
+        }
     }
 }
 
diff -r 271ec82db921 -r b7637c5269d1 xen/arch/x86/hvm/io.c
--- a/xen/arch/x86/hvm/io.c     Fri Apr 04 16:25:03 2008 +0100
+++ b/xen/arch/x86/hvm/io.c     Fri Apr 04 16:25:52 2008 +0100
@@ -148,20 +148,19 @@ void send_invalidate_req(void)
 void send_invalidate_req(void)
 {
     struct vcpu *v = current;
-    vcpu_iodata_t *vio;
+    vcpu_iodata_t *vio = get_ioreq(v);
     ioreq_t *p;
 
-    vio = get_ioreq(v);
-    if ( vio == NULL )
-    {
-        printk("bad shared page: %lx\n", (unsigned long) vio);
-        domain_crash_synchronous();
-    }
+    BUG_ON(vio == NULL);
 
     p = &vio->vp_ioreq;
     if ( p->state != STATE_IOREQ_NONE )
-        printk("WARNING: send invalidate req with something "
-               "already pending (%d)?\n", p->state);
+    {
+        gdprintk(XENLOG_ERR, "WARNING: send invalidate req with something "
+                 "already pending (%d)?\n", p->state);
+        domain_crash(v->domain);
+        return;
+    }
 
     p->type = IOREQ_TYPE_INVALIDATE;
     p->size = 4;
@@ -225,12 +224,6 @@ void hvm_io_assist(void)
     ioreq_t *p = &get_ioreq(curr)->vp_ioreq;
     enum hvm_io_state io_state;
 
-    if ( p->state != STATE_IORESP_READY )
-    {
-        gdprintk(XENLOG_ERR, "Unexpected HVM iorequest state %d.\n", p->state);
-        domain_crash_synchronous();
-    }
-
     rmb(); /* see IORESP_READY /then/ read contents of ioreq */
 
     p->state = STATE_IOREQ_NONE;
diff -r 271ec82db921 -r b7637c5269d1 xen/arch/x86/hvm/vmx/realmode.c
--- a/xen/arch/x86/hvm/vmx/realmode.c   Fri Apr 04 16:25:03 2008 +0100
+++ b/xen/arch/x86/hvm/vmx/realmode.c   Fri Apr 04 16:25:52 2008 +0100
@@ -172,7 +172,7 @@ static void realmode_emulate_one(struct 
              hvmemul_ctxt->insn_buf[0], hvmemul_ctxt->insn_buf[1],
              hvmemul_ctxt->insn_buf[2], hvmemul_ctxt->insn_buf[3],
              hvmemul_ctxt->insn_buf[4], hvmemul_ctxt->insn_buf[5]);
-    domain_crash_synchronous();
+    domain_crash(curr->domain);
 }
 
 void vmx_realmode(struct cpu_user_regs *regs)
diff -r 271ec82db921 -r b7637c5269d1 xen/arch/x86/hvm/vmx/vmcs.c
--- a/xen/arch/x86/hvm/vmx/vmcs.c       Fri Apr 04 16:25:03 2008 +0100
+++ b/xen/arch/x86/hvm/vmx/vmcs.c       Fri Apr 04 16:25:52 2008 +0100
@@ -729,14 +729,14 @@ void vmx_destroy_vmcs(struct vcpu *v)
     arch_vmx->vmcs = NULL;
 }
 
-void vm_launch_fail(unsigned long eflags)
+void vm_launch_fail(void)
 {
     unsigned long error = __vmread(VM_INSTRUCTION_ERROR);
     printk("<vm_launch_fail> error code %lx\n", error);
     domain_crash_synchronous();
 }
 
-void vm_resume_fail(unsigned long eflags)
+void vm_resume_fail(void)
 {
     unsigned long error = __vmread(VM_INSTRUCTION_ERROR);
     printk("<vm_resume_fail> error code %lx\n", error);
diff -r 271ec82db921 -r b7637c5269d1 xen/arch/x86/hvm/vmx/x86_32/exits.S
--- a/xen/arch/x86/hvm/vmx/x86_32/exits.S       Fri Apr 04 16:25:03 2008 +0100
+++ b/xen/arch/x86/hvm/vmx/x86_32/exits.S       Fri Apr 04 16:25:52 2008 +0100
@@ -129,7 +129,6 @@ ENTRY(vmx_asm_do_vmentry)
 /*vmx_resume:*/
         HVM_RESTORE_ALL_NOSEGREGS
         VMRESUME
-        pushf
         call vm_resume_fail
         ud2
 
@@ -137,7 +136,6 @@ vmx_launch:
         movb $1,VCPU_vmx_launched(%ebx)
         HVM_RESTORE_ALL_NOSEGREGS
         VMLAUNCH
-        pushf
         call vm_launch_fail
         ud2
 
diff -r 271ec82db921 -r b7637c5269d1 xen/arch/x86/hvm/vmx/x86_64/exits.S
--- a/xen/arch/x86/hvm/vmx/x86_64/exits.S       Fri Apr 04 16:25:03 2008 +0100
+++ b/xen/arch/x86/hvm/vmx/x86_64/exits.S       Fri Apr 04 16:25:52 2008 +0100
@@ -148,7 +148,6 @@ ENTRY(vmx_asm_do_vmentry)
 /*vmx_resume:*/
         HVM_RESTORE_ALL_NOSEGREGS
         VMRESUME
-        pushfq
         call vm_resume_fail
         ud2
 
@@ -156,7 +155,6 @@ vmx_launch:
         movb $1,VCPU_vmx_launched(%rbx)
         HVM_RESTORE_ALL_NOSEGREGS
         VMLAUNCH
-        pushfq
         call vm_launch_fail
         ud2
 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.