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

Re: [Xen-devel] [BUG] Emulation issues



> -----Original Message-----
[big snip]
> Sorry, missed that in the noise. So, the problem is that there is no 
> in-flight I/O
> even though pio completion is being attempted. Something has got out of
> sync.
> 

I think I understand what may be happening... The code in hvmemul_do_io() 
basically expects to be called either to issue an I/O or to extract info from a 
completed one. However it is being called unconditionally (in the PIO case) out 
of hvm_do_resume, rather than only if the in-flight I/O state has been updated 
to STATE_IORESP_READY.

Can you try this patch (also containing my previous debug patch)?

diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c
index 30acb78..1bc3cc9 100644
--- a/xen/arch/x86/hvm/emulate.c
+++ b/xen/arch/x86/hvm/emulate.c
@@ -145,6 +145,8 @@ static int hvmemul_do_io(
             return X86EMUL_UNHANDLEABLE;
         goto finish_access;
     default:
+        gprintk(XENLOG_ERR, "weird emulation state %u\n",
+                vio->io_req.state);
         return X86EMUL_UNHANDLEABLE;
     }

diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index ec1d797..a476271 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -472,7 +472,6 @@ void hvm_do_resume(struct vcpu *v)
     struct hvm_vcpu_io *vio = &v->arch.hvm_vcpu.hvm_io;
     struct domain *d = v->domain;
     struct hvm_ioreq_server *s;
-    enum hvm_io_completion io_completion;

     check_wakeup_from_wait();

@@ -499,33 +498,38 @@ void hvm_do_resume(struct vcpu *v)
         }
     }

-    io_completion = vio->io_completion;
-    vio->io_completion = HVMIO_no_completion;
-
-    switch ( io_completion )
-    {
-    case HVMIO_no_completion:
-        break;
-    case HVMIO_mmio_completion:
-        handle_mmio();
-        break;
-    case HVMIO_pio_completion:
-        (void)handle_pio(vio->io_req.addr, vio->io_req.size,
-                         vio->io_req.dir);
-        break;
-    case HVMIO_realmode_completion:
+    if ( vio->io_req.state == STATE_IORESP_READY )
     {
-        struct hvm_emulate_ctxt ctxt;
+        enum hvm_io_completion io_completion;

-        hvm_emulate_prepare(&ctxt, guest_cpu_user_regs());
-        vmx_realmode_emulate_one(&ctxt);
-        hvm_emulate_writeback(&ctxt);
+        io_completion = vio->io_completion;
+        vio->io_completion = HVMIO_no_completion;

-        break;
-    }
-    default:
-        ASSERT_UNREACHABLE();
-        break;
+        switch ( io_completion )
+        {
+        case HVMIO_no_completion:
+            break;
+        case HVMIO_mmio_completion:
+            handle_mmio();
+            break;
+        case HVMIO_pio_completion:
+            (void)handle_pio(vio->io_req.addr, vio->io_req.size,
+                             vio->io_req.dir);
+            break;
+        case HVMIO_realmode_completion:
+        {
+            struct hvm_emulate_ctxt ctxt;
+
+            hvm_emulate_prepare(&ctxt, guest_cpu_user_regs());
+            vmx_realmode_emulate_one(&ctxt);
+            hvm_emulate_writeback(&ctxt);
+
+            break;
+        }
+        default:
+            ASSERT_UNREACHABLE();
+            break;
+        }
     }

     if ( unlikely(d->arch.event_write_data) )
@@ -2747,6 +2751,7 @@ int hvm_send_ioreq(struct hvm_ioreq_server *s, ioreq_t 
*proto_p,
         }
     }

+    gprintk(XENLOG_ERR, "unable to contact device model\n");
     return X86EMUL_UNHANDLEABLE;
 }

  Paul
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

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