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

Re: [PATCH] Skip uninitialized CPUs


  • To: win-pv-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Paul Durrant <xadimgnik@xxxxxxxxx>
  • Date: Mon, 20 Feb 2023 14:51:55 +0000
  • Delivery-date: Mon, 20 Feb 2023 14:52:03 +0000
  • List-id: Developer list for the Windows PV Drivers subproject <win-pv-devel.lists.xenproject.org>

On 16/02/2023 11:55, Owen Smith wrote:
From: Owen Smith <owen.smith@xxxxxxxxxx>

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@xxxxxxxxxx>
---
  src/xenbus/evtchn_fifo.c | 19 +++++++++----------
  1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/src/xenbus/evtchn_fifo.c b/src/xenbus/evtchn_fifo.c
index a8dab8c..7a74af7 100644
--- a/src/xenbus/evtchn_fifo.c
+++ b/src/xenbus/evtchn_fifo.c
@@ -501,20 +501,21 @@ EvtchnFifoAcquire(
ProcessorCount = KeQueryMaximumProcessorCountEx(ALL_PROCESSOR_GROUPS); - Index = 0;
-    while (Index < ProcessorCount) {
+    for (Index = 0; Index < ProcessorCount; ++Index) {
          unsigned int        vcpu_id;
          PFN_NUMBER          Pfn;
          PHYSICAL_ADDRESS    Address;
+ status = SystemProcessorVcpuId(Index, &vcpu_id);
+        if (status == STATUS_NOT_SUPPORTED)
+            continue;

I think this would probably cause a bug in the loop in the 'fail1' exit below where SystemProcessorVcpuId() is called without checking the return value and Context->ControlBlockMdl[vcpu_id] is assumed to be non-NULL. I can fix this up.

Acked-by: Paul Durrant <paul@xxxxxxx>

+        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 +533,6 @@ EvtchnFifoAcquire(
                    Address.LowPart);
Context->ControlBlockMdl[vcpu_id] = Mdl;
-
-        Index++;
      }
Trace("<====\n");
@@ -546,11 +545,11 @@ done:
  fail3:
      Error("fail3\n");
+ __FreePage(Mdl);
+
  fail2:
      Error("fail2\n");
- __FreePage(Mdl);
-
  fail1:
      Error("fail1 (%08x)\n", status);




 


Rackspace

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