]> xenbits.xensource.com Git - pvdrivers/win/xenbus.git/commitdiff
Avoid ASSERTion failure on migrate/resume
authorPaul Durrant <pdurrant@amazon.com>
Wed, 17 Feb 2021 17:27:19 +0000 (17:27 +0000)
committerPaul Durrant <pdurrant@amazon.com>
Wed, 17 Feb 2021 17:40:24 +0000 (17:40 +0000)
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 <pdurrant@amazon.com>
src/xen/system.c

index f664635119feb41d967a77e5c3c7b979b0f4d7db..ffa41a749282d2d518b07f9d39a4e5f04130ac56 100644 (file)
@@ -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));