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

[PATCH xenbus 8/8] Add XENBUS_SHARED_INFO method to check whether event upcalls are supported



From: Paul Durrant <pdurrant@xxxxxxxxxx>

Upcalls can only be supported on a vCPU that has a vcpu_info structure
available to Xen; that is one with a vcpu_id < XEN_LEGACY_MAX_VCPUS (32) or
one that has explicitly registered a vcpu_info. This is determined during
SharedInfoAcquire() but the information needs to be avalable to the code in
evtchn.c. Hence this patch adds a new 'UpcallSupported' method to
XENBUS_SHARED_INFO (consequently bumping the interface version to 3).

Signed-off-by: Paul Durrant <pdurrant@xxxxxxxxxx>
---
 include/revision.h              |  3 ++-
 include/shared_info_interface.h | 30 ++++++++++++++++++++--
 src/xenbus/evtchn.c             | 19 +++-----------
 src/xenbus/shared_info.c        | 44 +++++++++++++++++++++++++++++++++
 4 files changed, 78 insertions(+), 18 deletions(-)

diff --git a/include/revision.h b/include/revision.h
index fe4661b42082..d507e60373a4 100644
--- a/include/revision.h
+++ b/include/revision.h
@@ -55,6 +55,7 @@
     DEFINE_REVISION(0x09000005,  1,  2,  8,  1,  2,  1,  2,  4,  1,  1,  1), \
     DEFINE_REVISION(0x09000006,  1,  3,  8,  1,  2,  1,  2,  4,  1,  1,  1), \
     DEFINE_REVISION(0x09000007,  1,  3,  8,  1,  2,  1,  2,  4,  1,  1,  2), \
-    DEFINE_REVISION(0x09000008,  1,  3,  9,  1,  2,  1,  2,  4,  1,  1,  2)
+    DEFINE_REVISION(0x09000008,  1,  3,  9,  1,  2,  1,  2,  4,  1,  1,  2), \
+    DEFINE_REVISION(0x09000008,  1,  4,  9,  1,  2,  1,  2,  4,  1,  1,  2)
 
 #endif  // _REVISION_H
diff --git a/include/shared_info_interface.h b/include/shared_info_interface.h
index f99bcb634cdd..27910b020a8e 100644
--- a/include/shared_info_interface.h
+++ b/include/shared_info_interface.h
@@ -60,6 +60,15 @@ typedef VOID
     IN  PINTERFACE  Interface
     );
 
+/*! \typedef XENBUS_SHARED_INFO_UPCALL_SUPPORTED
+    \brief Private method for EVTCHN inerface
+*/
+typedef BOOLEAN
+(*XENBUS_SHARED_INFO_UPCALL_SUPPORTED)(
+    IN  PINTERFACE  Interface,
+    IN  ULONG       Index
+    );
+
 /*! \typedef XENBUS_SHARED_INFO_UPCALL_PENDING
     \brief Private method for EVTCHN inerface
 */
@@ -168,7 +177,24 @@ struct _XENBUS_SHARED_INFO_INTERFACE_V3 {
     XENBUS_SHARED_INFO_GET_TIME         SharedInfoGetTime;
 };
 
-typedef struct _XENBUS_SHARED_INFO_INTERFACE_V3 XENBUS_SHARED_INFO_INTERFACE, 
*PXENBUS_SHARED_INFO_INTERFACE;
+/*! \struct _XENBUS_SHARED_INFO_INTERFACE_V4
+    \brief SHARED_INFO interface version 4
+    \ingroup interfaces
+*/
+struct _XENBUS_SHARED_INFO_INTERFACE_V4 {
+    INTERFACE                           Interface;
+    XENBUS_SHARED_INFO_ACQUIRE          SharedInfoAcquire;
+    XENBUS_SHARED_INFO_RELEASE          SharedInfoRelease;
+    XENBUS_SHARED_INFO_UPCALL_SUPPORTED SharedInfoUpcallSupported;
+    XENBUS_SHARED_INFO_UPCALL_PENDING   SharedInfoUpcallPending;
+    XENBUS_SHARED_INFO_EVTCHN_POLL      SharedInfoEvtchnPoll;
+    XENBUS_SHARED_INFO_EVTCHN_ACK       SharedInfoEvtchnAck;
+    XENBUS_SHARED_INFO_EVTCHN_MASK      SharedInfoEvtchnMask;
+    XENBUS_SHARED_INFO_EVTCHN_UNMASK    SharedInfoEvtchnUnmask;
+    XENBUS_SHARED_INFO_GET_TIME         SharedInfoGetTime;
+};
+
+typedef struct _XENBUS_SHARED_INFO_INTERFACE_V4 XENBUS_SHARED_INFO_INTERFACE, 
*PXENBUS_SHARED_INFO_INTERFACE;
 
 /*! \def XENBUS_SHARED_INFO
     \brief Macro at assist in method invocation
@@ -179,6 +205,6 @@ typedef struct _XENBUS_SHARED_INFO_INTERFACE_V3 
XENBUS_SHARED_INFO_INTERFACE, *P
 #endif  // _WINDLL
 
 #define XENBUS_SHARED_INFO_INTERFACE_VERSION_MIN    2
-#define XENBUS_SHARED_INFO_INTERFACE_VERSION_MAX    3
+#define XENBUS_SHARED_INFO_INTERFACE_VERSION_MAX    4
 
 #endif  // _XENBUS_SHARED_INFO_H
diff --git a/src/xenbus/evtchn.c b/src/xenbus/evtchn.c
index cb0e8e54fb29..8942cdf30f81 100644
--- a/src/xenbus/evtchn.c
+++ b/src/xenbus/evtchn.c
@@ -1512,21 +1512,10 @@ EvtchnIsProcessorEnabled(
     IN  ULONG                       Cpu
     )
 {
-    vcpu_info_t                     *Vcpu;
-    NTSTATUS                        status;
-
-    status = SystemProcessorVcpuInfo(Cpu, &Vcpu);
-    if (!NT_SUCCESS(status)) {
-        unsigned int    vcpu_id;
-
-        ASSERT(status == STATUS_NOT_SUPPORTED);
-
-        status = SystemProcessorVcpuId(Cpu, &vcpu_id);
-        ASSERT(NT_SUCCESS(status));
-
-        if (vcpu_id >= XEN_LEGACY_MAX_VCPUS)
-            return FALSE;
-    }
+    if (!XENBUS_SHARED_INFO(UpcallSupported,
+                            &Context->SharedInfoInterface,
+                            Cpu))
+        return FALSE;
 
     return XENBUS_EVTCHN_ABI(IsProcessorEnabled,
                              &Context->EvtchnAbi,
diff --git a/src/xenbus/shared_info.c b/src/xenbus/shared_info.c
index 984ee6ff0417..9f119791a03a 100644
--- a/src/xenbus/shared_info.c
+++ b/src/xenbus/shared_info.c
@@ -160,6 +160,20 @@ SharedInfoEvtchnMaskAll(
     }
 }
 
+static BOOLEAN
+SharedInfoUpcallSupported(
+    IN  PINTERFACE                  Interface,
+    IN  ULONG                       Index
+    )
+{
+    PXENBUS_SHARED_INFO_CONTEXT     Context = Interface->Context;
+    PXENBUS_SHARED_INFO_PROCESSOR   Processor = &Context->Processor[Index];
+
+    ASSERT3U(Index, <, Context->ProcessorCount);
+
+    return (Processor->Vcpu != NULL) ? TRUE : FALSE;
+}
+
 static BOOLEAN
 SharedInfoUpcallPending(
     IN  PINTERFACE                  Interface,
@@ -795,6 +809,19 @@ static struct _XENBUS_SHARED_INFO_INTERFACE_V3 
SharedInfoInterfaceVersion3 = {
     SharedInfoGetTime
 };
                      
+static struct _XENBUS_SHARED_INFO_INTERFACE_V4 SharedInfoInterfaceVersion4 = {
+    { sizeof (struct _XENBUS_SHARED_INFO_INTERFACE_V4), 4, NULL, NULL, NULL },
+    SharedInfoAcquire,
+    SharedInfoRelease,
+    SharedInfoUpcallSupported,
+    SharedInfoUpcallPending,
+    SharedInfoEvtchnPoll,
+    SharedInfoEvtchnAck,
+    SharedInfoEvtchnMask,
+    SharedInfoEvtchnUnmask,
+    SharedInfoGetTime
+};
+
 NTSTATUS
 SharedInfoInitialize(
     IN  PXENBUS_FDO                 Fdo,
@@ -886,6 +913,23 @@ SharedInfoGetInterface(
         status = STATUS_SUCCESS;
         break;
     }
+    case 4: {
+        struct _XENBUS_SHARED_INFO_INTERFACE_V4 *SharedInfoInterface;
+
+        SharedInfoInterface = (struct _XENBUS_SHARED_INFO_INTERFACE_V4 
*)Interface;
+
+        status = STATUS_BUFFER_OVERFLOW;
+        if (Size < sizeof (struct _XENBUS_SHARED_INFO_INTERFACE_V4))
+            break;
+
+        *SharedInfoInterface = SharedInfoInterfaceVersion4;
+
+        ASSERT3U(Interface->Version, ==, Version);
+        Interface->Context = Context;
+
+        status = STATUS_SUCCESS;
+        break;
+    }
     default:
         status = STATUS_NOT_SUPPORTED;
         break;
-- 
2.17.1




 


Rackspace

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