From: Paul Durrant Date: Thu, 26 Mar 2015 13:43:01 +0000 (+0000) Subject: Don't use a stack based DPC structure in the System per-CPU code X-Git-Tag: 8.1.0-rc1~35 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=38f686931b4e1513d95a7d0bd0ea5ca805068f5c;p=pvdrivers%2Fwin%2Fxenbus.git Don't use a stack based DPC structure in the System per-CPU code 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 --- diff --git a/src/xen/system.c b/src/xen/system.c index a602d8b..f7be963 100644 --- a/src/xen/system.c +++ b/src/xen/system.c @@ -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; }