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

[Xen-devel] [RFC PATCH V5 08/15] evtchn: add evtchn_extended in struct domain



This field is a bitmap of currently in use extended event channel ABI, which
can have 0 (no extended event channel in use) or 1 bit set. It is manipulated
by hypervisor only, so if anything goes wrong it is a bug.

The default event channel ABI is EVTCHN_EXTENDED_NONE, which means no extended
event channel is used.

Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx>
---
 xen/common/event_channel.c |   18 ++++++++++++++++--
 xen/include/xen/event.h    |   16 +++++++++++++++-
 xen/include/xen/sched.h    |    1 +
 3 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/xen/common/event_channel.c b/xen/common/event_channel.c
index 2f5f3de..4d02fc7 100644
--- a/xen/common/event_channel.c
+++ b/xen/common/event_channel.c
@@ -1162,6 +1162,21 @@ const static struct evtchn_port_ops evtchn_2l_ops = {
     .clear_pending = evtchn_bitmap_clear_pending
 };
 
+void evtchn_set_abi(struct domain *d, uint64_t abi)
+{
+    d->evtchn_extended = abi;
+    /* This must go after setting ABI */
+    d->max_evtchns = max_evtchns(d);
+    switch ( abi )
+    {
+    case EVTCHN_EXTENDED_NONE:
+        d->evtchn_ops = &evtchn_2l_ops;
+        break;
+    default:
+        BUG();
+    }
+}
+
 int evtchn_init(struct domain *d)
 {
     spin_lock_init(&d->event_lock);
@@ -1169,8 +1184,7 @@ int evtchn_init(struct domain *d)
     if ( get_free_port(d) != 0 )
         return -EINVAL;
     evtchn_from_port(d, 0)->state = ECS_RESERVED;
-
-    d->evtchn_ops = &evtchn_2l_ops;
+    evtchn_set_abi(d, EVTCHN_EXTENDED_NONE);
 
 #if MAX_VIRT_CPUS > BITS_PER_LONG
     d->poll_mask = xmalloc_array(unsigned long, BITS_TO_LONGS(MAX_VIRT_CPUS));
diff --git a/xen/include/xen/event.h b/xen/include/xen/event.h
index 0ad34fe..e16fdb6 100644
--- a/xen/include/xen/event.h
+++ b/xen/include/xen/event.h
@@ -14,10 +14,20 @@
 #include <xen/softirq.h>
 #include <asm/bitops.h>
 #include <asm/event.h>
+#include <public/event_channel.h>
 
 static inline unsigned int max_evtchns(struct domain *d)
 {
-    return BITS_PER_EVTCHN_WORD(d) * BITS_PER_EVTCHN_WORD(d);
+    unsigned int ret = 0;
+    switch ( d->evtchn_extended )
+    {
+    case EVTCHN_EXTENDED_NONE:
+        ret = BITS_PER_EVTCHN_WORD(d) * BITS_PER_EVTCHN_WORD(d);
+        break;
+    default:
+        BUG();
+    }
+    return ret;
 }
 
 /*
@@ -130,4 +140,8 @@ int evtchn_bitmap_unmask(unsigned int port);
 
 /* A bitmap of supported extended event channel ABIs */
 extern uint64_t extended_event_channel;
+
+/* Set event channel ABI for a domain */
+void evtchn_set_abi(struct domain *d, uint64_t abi);
+
 #endif /* __XEN_EVENT_H__ */
diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
index f89e9c5..dbb7217 100644
--- a/xen/include/xen/sched.h
+++ b/xen/include/xen/sched.h
@@ -271,6 +271,7 @@ struct domain
     const struct evtchn_port_ops *evtchn_ops;
     spinlock_t       event_lock;
     unsigned int     max_evtchns;
+    unsigned int     evtchn_extended;
 
     struct grant_table *grant_table;
 
-- 
1.7.10.4


_______________________________________________
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®.