]> xenbits.xensource.com Git - pvdrivers/win/xenbus.git/commitdiff
Don't use a stack based DPC structure in the System per-CPU code
authorPaul Durrant <paul.durrant@citrix.com>
Thu, 26 Mar 2015 13:43:01 +0000 (13:43 +0000)
committerPaul Durrant <paul.durrant@citrix.com>
Thu, 26 Mar 2015 13:43:01 +0000 (13:43 +0000)
Whilst this is believed to be safe, there is no documentation to say that
Windows does not make use of the DPC structure after the DPC routine has
completed. Instead, make the DPC structure part of the per-CPU structure.

Also fix an ASSERT on the per-CPU array pointer not being NULLed.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
src/xen/system.c

index a602d8b8406af8bbb02faa87d5ae7a6746f9c233..f7be9637c4c93137d185b85c0486a17cd4f2de66 100644 (file)
@@ -49,6 +49,7 @@
 #define XEN_SYSTEM_TAG  'TSYS'
 
 typedef struct _SYSTEM_PROCESSOR {
+    KDPC    Dpc;
     CHAR    Manufacturer[13];
     UCHAR   ApicID;
     UCHAR   ProcessorID;
@@ -343,7 +344,7 @@ SystemProcessorInformation(
     )
 {
     PSYSTEM_CONTEXT     Context = &SystemContext;
-    PKEVENT             Event = _Context;
+    PKEVENT             Event = Argument1;
     ULONG               Index;
     PROCESSOR_NUMBER    ProcNumber;
     PSYSTEM_PROCESSOR   Processor;
@@ -352,7 +353,7 @@ SystemProcessorInformation(
     ULONG               EDX;
 
     UNREFERENCED_PARAMETER(Dpc);
-    UNREFERENCED_PARAMETER(Argument1);
+    UNREFERENCED_PARAMETER(_Context);
     UNREFERENCED_PARAMETER(Argument2);
 
     Index = KeGetCurrentProcessorNumberEx(&ProcNumber);
@@ -438,18 +439,20 @@ SystemProcessorChangeCallback(
         break;
     }
     case KeProcessorAddCompleteNotify: {
+        PSYSTEM_PROCESSOR   Processor;
         KEVENT              Event;
-        KDPC                Dpc;
 
         ASSERT3U(Index, <, Context->ProcessorCount);
 
+        Processor = &Context->Processor[Index];
+
         KeInitializeEvent(&Event, NotificationEvent, FALSE);
 
-        KeInitializeDpc(&Dpc, SystemProcessorInformation, &Event);
-        KeSetImportanceDpc(&Dpc, HighImportance);
-        KeSetTargetProcessorDpcEx(&Dpc, &ProcNumber);
+        KeInitializeDpc(&Processor->Dpc, SystemProcessorInformation, NULL);
+        KeSetImportanceDpc(&Processor->Dpc, HighImportance);
+        KeSetTargetProcessorDpcEx(&Processor->Dpc, &ProcNumber);
 
-        KeInsertQueueDpc(&Dpc, NULL, NULL);
+        KeInsertQueueDpc(&Processor->Dpc, &Event, NULL);
 
         (VOID) KeWaitForSingleObject(&Event,
                                      Executive,
@@ -507,6 +510,7 @@ SystemDeregisterProcessorChangeCallback(
     Context->ProcessorChangeHandle = NULL;
 
     __SystemFree(Context->Processor);
+    Context->Processor = NULL;
     Context->ProcessorCount = 0;
 }