]> xenbits.xensource.com Git - pvdrivers/win/xenbus.git/commitdiff
Skip uninitialized CPUs
authorOwen Smith <owen.smith@citrix.com>
Thu, 16 Feb 2023 11:55:45 +0000 (11:55 +0000)
committerPaul Durrant <pdurrant@amazon.com>
Mon, 20 Feb 2023 15:22:03 +0000 (15:22 +0000)
EvtchnFifoAcquire() will loop through all CPUs to call EVTCHNOP_init_control.
Skip any CPUs that are not initialized, which is indicated by
SystemProcessorVcpuId() failing, instead of failing the Acquire operation.

This is primarily an issue when KeQueryMaximumProcessorCountEx() returns
a different value to KeQueryActiveProcessorCountEx(), or the system
processor callback has not been called with KeProcessorAddCompleteNotify
for that CPU.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
Fix up error path that also calls SystemProcessorVcpuId().

Signed-off-by: Paul Durrant <pdurrant@amazon.com>
src/xenbus/evtchn_fifo.c

index a8dab8ca66845bc1e9675fb0bef7e523f71530e3..88b810a9d49a662d8831d934162c61d20b106dbd 100644 (file)
@@ -507,14 +507,20 @@ EvtchnFifoAcquire(
         PFN_NUMBER          Pfn;
         PHYSICAL_ADDRESS    Address;
 
+        status = SystemProcessorVcpuId(Index, &vcpu_id);
+
+        Index++;
+
+        if (status == STATUS_NOT_SUPPORTED)
+            continue;
+
+        if (!NT_SUCCESS(status))
+            goto fail1;
+
         Mdl = __AllocatePage();
 
         status = STATUS_NO_MEMORY;
         if (Mdl == NULL)
-            goto fail1;
-
-        status = SystemProcessorVcpuId(Index, &vcpu_id);
-        if (!NT_SUCCESS(status))
             goto fail2;
 
         Pfn = MmGetMdlPfnArray(Mdl)[0];
@@ -532,8 +538,6 @@ EvtchnFifoAcquire(
                   Address.LowPart);
 
         Context->ControlBlockMdl[vcpu_id] = Mdl;
-
-        Index++;
     }
 
     Trace("<====\n");
@@ -546,11 +550,11 @@ done:
 fail3:
     Error("fail3\n");
 
+    __FreePage(Mdl);
+
 fail2:
     Error("fail2\n");
 
-    __FreePage(Mdl);
-
 fail1:
     Error("fail1 (%08x)\n", status);
 
@@ -559,7 +563,11 @@ fail1:
     while (--Index >= 0) {
         unsigned int    vcpu_id;
 
-        (VOID) SystemProcessorVcpuId(Index, &vcpu_id);
+        status = SystemProcessorVcpuId(Index, &vcpu_id);
+        if (status == STATUS_NOT_SUPPORTED)
+            continue;
+
+        BUG_ON(!NT_SUCCESS(status));
 
         Mdl = Context->ControlBlockMdl[vcpu_id];
         Context->ControlBlockMdl[vcpu_id] = NULL;