]> xenbits.xensource.com Git - pvdrivers/win/xenbus.git/commitdiff
Fix WHQL Multiple processor group device test BSOD
authorPaul Durrant <paul.durrant@citrix.com>
Wed, 4 Mar 2015 12:55:50 +0000 (12:55 +0000)
committerPaul Durrant <paul.durrant@citrix.com>
Wed, 4 Mar 2015 12:55:50 +0000 (12:55 +0000)
Some of the fakery done by this test causes a BSOD in the code in the
XEN driver that attempts to build a mapping from Windows CPU index to
Xen vcpu id. Applying this patch to re-work the code slightly fixes the
BSOD and allows the test to pass.

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

index eb06becc1ff2cd41ee128fa5ccdbf949d6fd36b6..ea3bc4e923585800a0b57bd38ae030f8fb55d638 100644 (file)
 #define XEN_SYSTEM_TAG  'TSYS'
 
 typedef struct _SYSTEM_CPU {
+    ULONG   Index;
     CHAR    Manufacturer[13];
     UCHAR   ApicID;
     UCHAR   ProcessorID;
-    KDPC    Dpc;
-    KEVENT  Event;
 } SYSTEM_CPU, *PSYSTEM_CPU;
 
 typedef struct _SYSTEM_CONTEXT {
@@ -343,13 +342,14 @@ SystemCpuInformation(
     )
 {
     PSYSTEM_CONTEXT Context = &SystemContext;
+    PKEVENT         Event = _Context;
     ULONG           Index;
     PSYSTEM_CPU     Cpu;
     ULONG           EBX;
     ULONG           ECX;
     ULONG           EDX;
 
-    UNREFERENCED_PARAMETER(_Context);
+    UNREFERENCED_PARAMETER(Dpc);
     UNREFERENCED_PARAMETER(Argument1);
     UNREFERENCED_PARAMETER(Argument2);
 
@@ -357,7 +357,7 @@ SystemCpuInformation(
     Cpu = Context->Cpu[Index];
 
     ASSERT(Cpu != NULL);
-    ASSERT3P(Dpc, ==, &Cpu->Dpc);
+    ASSERT3U(Cpu->Index, ==, Index);
 
     Info("====> (%u)\n", Index);
 
@@ -376,7 +376,7 @@ SystemCpuInformation(
     Info("APIC ID: %02X\n", Cpu->ApicID);
     Info("PROCESSOR ID: %02X\n", Cpu->ProcessorID);
 
-    KeSetEvent(&Cpu->Event, IO_NO_INCREMENT, FALSE);
+    KeSetEvent(Event, IO_NO_INCREMENT, FALSE);
 
     Info("<==== (%u)\n", Index);
 }
@@ -409,24 +409,28 @@ SystemProcessorChangeCallback(
             break;
         }
 
+        Cpu->Index = Index;
         ASSERT3P(Context->Cpu[Index], ==, NULL);
         Context->Cpu[Index] = Cpu;
         break;
     }
     case KeProcessorAddCompleteNotify: {
         PSYSTEM_CPU Cpu = Context->Cpu[Index];
-        PKDPC       Dpc = &Cpu->Dpc;
-        PKEVENT     Event = &Cpu->Event;
+        KEVENT      Event;
+        KDPC        Dpc;
+
+        ASSERT(Cpu != NULL);
+        ASSERT3U(Cpu->Index, ==, Index);
 
-        KeInitializeDpc(Dpc, SystemCpuInformation, (PVOID)(ULONG_PTR)Index);
-        KeSetImportanceDpc(Dpc, HighImportance);
-        KeSetTargetProcessorDpc(Dpc, (CCHAR)Index);
+        KeInitializeEvent(&Event, NotificationEvent, FALSE);
 
-        KeInitializeEvent(Event, NotificationEvent, FALSE);
+        KeInitializeDpc(&Dpc, SystemCpuInformation, &Event);
+        KeSetImportanceDpc(&Dpc, HighImportance);
+        KeSetTargetProcessorDpc(&Dpc, (CCHAR)Index);
 
-        KeInsertQueueDpc(Dpc, NULL, NULL);
+        KeInsertQueueDpc(&Dpc, NULL, NULL);
 
-        (VOID) KeWaitForSingleObject(Event,
+        (VOID) KeWaitForSingleObject(&Event,
                                      Executive,
                                      KernelMode,
                                      FALSE,
@@ -437,6 +441,7 @@ SystemProcessorChangeCallback(
         PSYSTEM_CPU Cpu = Context->Cpu[Index];
 
         ASSERT(Cpu != NULL);
+        ASSERT3U(Cpu->Index, ==, Index);
 
         Context->Cpu[Index] = NULL;
         __SystemFree(Cpu);