From: Paul Durrant Date: Wed, 17 Feb 2021 17:27:19 +0000 (+0000) Subject: Avoid ASSERTion failure on migrate/resume X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=b9fd7a0f69de5afae686f704e58c8b346949451e;p=pvdrivers%2Fwin%2Fxenbus.git Avoid ASSERTion failure on migrate/resume After commit ed57f5f6367f ("Make vcpu_info registration conditional on number of vCPUs") it is no longer certain that SystemProcessorRegisterVcpuInfo() will be called during boot and indeed it was modified to ASSERT that the 'RegisterVcpuInfo' flag in SYSTEM_CONTEXT is TRUE. Unfortunately this means that the (now erroneously) unconditional call to SystemProcessorRegisterVcpuInfo() in SuspendEarly() may fail the ASSERTion. This patch fixes the problem by allowing SystemProcessorRegisterVcpuInfo() to be called unconditionally and simply having it exit early if the 'RegisterVcpuInfo' flag is not set. SystemProcessorDeregisterVcpuInfo() is also similarly modified for consistency. Signed-off-by: Paul Durrant --- diff --git a/src/xen/system.c b/src/xen/system.c index f664635..ffa41a7 100644 --- a/src/xen/system.c +++ b/src/xen/system.c @@ -695,7 +695,8 @@ SystemProcessorRegisterVcpuInfo( PUCHAR MdlMappedSystemVa; NTSTATUS status; - ASSERT(Context->RegisterVcpuInfo); + if (!Context->RegisterVcpuInfo) + goto done; status = STATUS_UNSUCCESSFUL; if (Cpu >= Context->ProcessorCount) @@ -742,6 +743,7 @@ SystemProcessorRegisterVcpuInfo( Address.HighPart, Address.LowPart); +done: return STATUS_SUCCESS; fail2: @@ -764,7 +766,8 @@ SystemProcessorDeregisterVcpuInfo( PSYSTEM_CONTEXT Context = &SystemContext; PSYSTEM_PROCESSOR Processor = &Context->Processor[Cpu]; - ASSERT(Context->RegisterVcpuInfo); + if (!Context->RegisterVcpuInfo) + return; Processor->Vcpu = NULL; Processor->Registered = NULL; @@ -805,11 +808,9 @@ SystemProcessorDpc( SystemProcessorInitialize(Cpu); - if (Context->RegisterVcpuInfo) { - status = SystemProcessorRegisterVcpuInfo(Cpu, FALSE); - if (!NT_SUCCESS(status)) - goto fail1; - } + status = SystemProcessorRegisterVcpuInfo(Cpu, FALSE); + if (!NT_SUCCESS(status)) + goto fail1; Info("<==== (%u:%u)\n", ProcNumber.Group, ProcNumber.Number); @@ -990,9 +991,7 @@ SystemDeregisterProcessorChangeCallback( for (Cpu = 0; Cpu < Context->ProcessorCount; Cpu++) { PSYSTEM_PROCESSOR Processor = &Context->Processor[Cpu]; - if (Context->RegisterVcpuInfo) - SystemProcessorDeregisterVcpuInfo(Cpu); - + SystemProcessorDeregisterVcpuInfo(Cpu); SystemProcessorTeardown(Cpu); RtlZeroMemory(&Processor->Dpc, sizeof (KDPC));