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

[win-pv-devel] [PATCH] Fix WHQL Multiple processor group device test BSOD



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@xxxxxxxxxx>
---
 src/xen/system.c | 31 ++++++++++++++++++-------------
 1 file changed, 18 insertions(+), 13 deletions(-)

diff --git a/src/xen/system.c b/src/xen/system.c
index eb06bec..ea3bc4e 100644
--- a/src/xen/system.c
+++ b/src/xen/system.c
@@ -48,11 +48,10 @@
 #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);
-- 
2.1.1


_______________________________________________
win-pv-devel mailing list
win-pv-devel@xxxxxxxxxxxxxxxxxxxx
http://lists.xenproject.org/cgi-bin/mailman/listinfo/win-pv-devel


 


Rackspace

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