File 20274-hvm-suspend-insn-retire.patch of Package xen

# HG changeset patch
# User Keir Fraser <keir.fraser@citrix.com>
# Date 1254896491 -3600
# Node ID ff079db21e8d49e9e15083d72a8ac6f6e37bc62d
# Parent  10cfcbef68ee8ff7747e0150d93220c2b832cd08
x86 hvm: Do not incorrectly retire an instruction emulation when a
read/write cycle to qemu is dropped due to guest suspend.

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>

# HG changeset patch
# User Keir Fraser <keir.fraser@citrix.com>
# Date 1254899226 -3600
# Node ID 440d22c01652ed8b22a51adeada1346d35611b77
# Parent  30bfa1d8895daa561e4a3d0fb11b7fabac154fe1
x86 hvm: On failed hvm_send_assist_req(), io emulation state should be
reset to HVMIO_none, as no IO is in flight.

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>

--- a/xen/arch/x86/hvm/emulate.c
+++ b/xen/arch/x86/hvm/emulate.c
@@ -132,8 +132,11 @@ static int hvmemul_do_io(
         curr->arch.hvm_vcpu.io_state = HVMIO_none;
         break;
     case X86EMUL_UNHANDLEABLE:
-        hvm_send_assist_req(curr);
-        rc = (p_data != NULL) ? X86EMUL_RETRY : X86EMUL_OKAY;
+        rc = X86EMUL_RETRY;
+        if ( !hvm_send_assist_req(curr) )
+            curr->arch.hvm_vcpu.io_state = HVMIO_none;
+        else if ( p_data == NULL )
+            rc = X86EMUL_OKAY;
         break;
     default:
         BUG();
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -757,12 +757,12 @@ void hvm_vcpu_down(struct vcpu *v)
     }
 }
 
-void hvm_send_assist_req(struct vcpu *v)
+bool_t hvm_send_assist_req(struct vcpu *v)
 {
     ioreq_t *p;
 
     if ( unlikely(!vcpu_start_shutdown_deferral(v)) )
-        return; /* implicitly bins the i/o operation */
+        return 0; /* implicitly bins the i/o operation */
 
     p = &get_ioreq(v)->vp_ioreq;
     if ( unlikely(p->state != STATE_IOREQ_NONE) )
@@ -770,7 +770,7 @@ void hvm_send_assist_req(struct vcpu *v)
         /* 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(v->domain);
-        return;
+        return 0;
     }
 
     prepare_wait_on_xen_event_channel(v->arch.hvm_vcpu.xen_port);
@@ -781,6 +781,8 @@ void hvm_send_assist_req(struct vcpu *v)
      */
     p->state = STATE_IOREQ_READY;
     notify_via_xen_event_channel(v->arch.hvm_vcpu.xen_port);
+
+    return 1;
 }
 
 void hvm_hlt(unsigned long rflags)
--- a/xen/arch/x86/hvm/io.c
+++ b/xen/arch/x86/hvm/io.c
@@ -168,7 +168,7 @@ void send_invalidate_req(void)
     p->data = ~0UL; /* flush all */
     p->io_count++;
 
-    hvm_send_assist_req(v);
+    (void)hvm_send_assist_req(v);
 }
 
 int handle_mmio(void)
--- a/xen/include/asm-x86/hvm/hvm.h
+++ b/xen/include/asm-x86/hvm/hvm.h
@@ -145,7 +145,7 @@ int hvm_vcpu_cacheattr_init(struct vcpu 
 void hvm_vcpu_cacheattr_destroy(struct vcpu *v);
 void hvm_vcpu_reset_state(struct vcpu *v, uint16_t cs, uint16_t ip);
 
-void hvm_send_assist_req(struct vcpu *v);
+bool_t hvm_send_assist_req(struct vcpu *v);
 
 void hvm_set_guest_tsc(struct vcpu *v, u64 guest_tsc);
 u64 hvm_get_guest_tsc(struct vcpu *v);
openSUSE Build Service is sponsored by