hvm: introduce HVM_PARAM_BUFIOREQ_EVTCHN
authorStefano Stabellini <stefano.stabellini@eu.citrix.com>
Wed, 16 Nov 2011 15:17:37 +0000 (15:17 +0000)
committerStefano Stabellini <stefano.stabellini@eu.citrix.com>
Wed, 16 Nov 2011 15:17:37 +0000 (15:17 +0000)
Introduce an event channel for buffered io event notifications,
advertise the port number using an hvm param.  This way the device
model is not forced to check the buffered io page for data several
times a second for the entire life of the VM (buffered io is mostly
used for stdvga emulation in Xen that is switched off after the guest
goes into graphical mode).

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
xen/arch/x86/hvm/hvm.c
xen/arch/x86/hvm/io.c
xen/include/public/hvm/params.h

index b118195c9451755aae22f171450f9171f11e0807..29452a2daf538b4a23623745189ed2f95e069e15 100644 (file)
@@ -985,6 +985,16 @@ int hvm_vcpu_initialise(struct vcpu *v)
 
     /* Register ioreq event channel. */
     v->arch.hvm_vcpu.xen_port = rc;
+
+    if ( v->vcpu_id == 0 )
+    {
+        /* Create bufioreq event channel. */
+        rc = alloc_unbound_xen_event_channel(v, 0);
+        if ( rc < 0 )
+            goto fail2;
+        v->domain->arch.hvm_domain.params[HVM_PARAM_BUFIOREQ_EVTCHN] = rc;
+    }
+
     spin_lock(&v->domain->arch.hvm_domain.ioreq.lock);
     if ( v->domain->arch.hvm_domain.ioreq.va != NULL )
         get_ioreq(v)->vp_eport = v->arch.hvm_vcpu.xen_port;
@@ -3597,6 +3607,9 @@ long do_hvm_op(unsigned long op, XEN_GUEST_HANDLE(void) arg)
                         if ( rc == 0 )
                             rc = nestedhvm_vcpu_initialise(v);
                 break;
+            case HVM_PARAM_BUFIOREQ_EVTCHN:
+                rc = -EINVAL;
+                break;
             }
 
             if ( rc == 0 ) 
index 7ebefc7460d5fd088ac43df2e3d8f2ed6f4a7ccb..41a2edea5047c488ffcce9aae3957c837d63498f 100644 (file)
@@ -118,6 +118,8 @@ int hvm_buffered_io_send(ioreq_t *p)
     wmb();
     pg->write_pointer += qw ? 2 : 1;
 
+    notify_via_xen_event_channel(v->domain,
+            v->domain->arch.hvm_domain.params[HVM_PARAM_BUFIOREQ_EVTCHN]);
     spin_unlock(&iorp->lock);
     
     return 1;
index 1c5a1a996434c2c4cedebb0b7830656009a69909..6699788eae9b40d1848d5cf01cb9ae1bdd3418de 100644 (file)
@@ -52,6 +52,7 @@
 #define HVM_PARAM_IOREQ_PFN    5
 
 #define HVM_PARAM_BUFIOREQ_PFN 6
+#define HVM_PARAM_BUFIOREQ_EVTCHN 26
 
 #ifdef __ia64__
 
 /* Boolean: Enable nestedhvm (hvm only) */
 #define HVM_PARAM_NESTEDHVM    24
 
-#define HVM_NR_PARAMS          26
+#define HVM_NR_PARAMS          27
 
 #endif /* __XEN_PUBLIC_HVM_PARAMS_H__ */