From win-pv-devel-bounces@lists.xenproject.org Tue Dec 01 12:42:34 2020
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 01 Dec 2020 12:42:34 +0000
Received: from list by lists.xenproject.org with outflank-mailman.41934.75472 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1kk4zK-0008Qn-5h; Tue, 01 Dec 2020 12:42:34 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 41934.75472; Tue, 01 Dec 2020 12:42:34 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1kk4zK-0008Qg-1p; Tue, 01 Dec 2020 12:42:34 +0000
Received: by outflank-mailman (input) for mailman id 41934;
 Tue, 01 Dec 2020 12:42:33 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>) id 1kk4zI-0008Pr-VQ
 for win-pv-devel@lists.xenproject.org; Tue, 01 Dec 2020 12:42:32 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1kk4zI-0003Zn-Og; Tue, 01 Dec 2020 12:42:32 +0000
Received: from host86-183-162-145.range86-183.btcentralplus.com
 ([86.183.162.145] helo=CBG-R90WXYV0.home)
 by xenbits.xenproject.org with esmtpsa
 (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1kk4zI-0004Pe-FW; Tue, 01 Dec 2020 12:42:32 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From;
	 bh=/9OpmiMlflL3yMtzobrmVNUG8j95HH/nexEdap/Bsg4=; b=gMW35twoOsFlNrKo1NIzIb/TO
	Gz1R1eMjFJL6X2Xpti2J4hhHJnhKBuwW0Bguj+BLQiL9M87AXiGChST90D2F84GOXK8VJJ8e+NCug
	QlSs9V9R/8zMcdDDKLWaYmKOkC0ytfnjm8SoXNXZbyfiEEgO3tBqCox6gVZzAyKZ9P03w=;
From: Paul Durrant <paul@xen.org>
To: win-pv-devel@lists.xenproject.org
Cc: Paul Durrant <pdurrant@amazon.com>
Subject: [PATCH xenbus 2/7] s/Index/Cpu in the SYSTEM code where 'Index' relates to a processor
Date: Tue,  1 Dec 2020 12:42:20 +0000
Message-Id: <20201201124225.1118-3-paul@xen.org>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20201201124225.1118-1-paul@xen.org>
References: <20201201124225.1118-1-paul@xen.org>

From: Paul Durrant <pdurrant@amazon.com>

This is a purely cosmetic patch. No functional change.

Signed-off-by: Paul Durrant <pdurrant@amazon.com>
---
 include/xen.h    |  2 +-
 src/xen/system.c | 30 +++++++++++++++---------------
 2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/include/xen.h b/include/xen.h
index 31e95da6fc22..89f68867ad5f 100644
--- a/include/xen.h
+++ b/include/xen.h
@@ -457,7 +457,7 @@ SystemProcessorCount(
 XEN_API
 NTSTATUS
 SystemVirtualCpuIndex(
-    IN  ULONG           Index,
+    IN  ULONG           Cpu,
     OUT unsigned int    *vcpu_id
     );
 
diff --git a/src/xen/system.c b/src/xen/system.c
index 5a8ba16a6660..8219c86f8321 100644
--- a/src/xen/system.c
+++ b/src/xen/system.c
@@ -578,7 +578,7 @@ SystemProcessorInformation(
 {
     PSYSTEM_CONTEXT     Context = &SystemContext;
     PKEVENT             Event = Argument1;
-    ULONG               Index;
+    ULONG               Cpu;
     PROCESSOR_NUMBER    ProcNumber;
     PSYSTEM_PROCESSOR   Processor;
     ULONG               EAX;
@@ -590,12 +590,12 @@ SystemProcessorInformation(
     UNREFERENCED_PARAMETER(_Context);
     UNREFERENCED_PARAMETER(Argument2);
 
-    Index = KeGetCurrentProcessorNumberEx(&ProcNumber);
-    ASSERT3U(Index, <, Context->ProcessorCount);
+    Cpu = KeGetCurrentProcessorNumberEx(&ProcNumber);
+    ASSERT3U(Cpu, <, Context->ProcessorCount);
 
-    Processor = &Context->Processor[Index];
+    Processor = &Context->Processor[Cpu];
 
-    if (Index == 0) {
+    if (Cpu == 0) {
         CHAR    Signature[13];
 
         RtlZeroMemory(Signature, sizeof (Signature));
@@ -642,14 +642,14 @@ SystemProcessorChangeCallback(
 {
     PSYSTEM_CONTEXT                             Context = &SystemContext;
     PROCESSOR_NUMBER                            ProcNumber;
-    ULONG                                       Index;
+    ULONG                                       Cpu;
     NTSTATUS                                    status;
 
     UNREFERENCED_PARAMETER(Argument);
 
-    Index = Change->NtNumber;
+    Cpu = Change->NtNumber;
 
-    status = KeGetProcessorNumberFromIndex(Index, &ProcNumber);
+    status = KeGetProcessorNumberFromIndex(Cpu, &ProcNumber);
     ASSERT(NT_SUCCESS(status));
 
     Trace("====> (%u:%u:%s)\n",
@@ -662,10 +662,10 @@ SystemProcessorChangeCallback(
         PSYSTEM_PROCESSOR   Processor;
         ULONG               ProcessorCount;
 
-        if (Index < Context->ProcessorCount)
+        if (Cpu < Context->ProcessorCount)
             break;
 
-        ProcessorCount = Index + 1;
+        ProcessorCount = Cpu + 1;
         Processor = __SystemAllocate(sizeof (SYSTEM_PROCESSOR) *
                                      ProcessorCount);
 
@@ -692,9 +692,9 @@ SystemProcessorChangeCallback(
         PSYSTEM_PROCESSOR   Processor;
         KEVENT              Event;
 
-        ASSERT3U(Index, <, Context->ProcessorCount);
+        ASSERT3U(Cpu, <, Context->ProcessorCount);
 
-        Processor = &Context->Processor[Index];
+        Processor = &Context->Processor[Cpu];
 
         KeInitializeEvent(&Event, NotificationEvent, FALSE);
 
@@ -1069,16 +1069,16 @@ SystemProcessorCount(
 XEN_API
 NTSTATUS
 SystemVirtualCpuIndex(
-    IN  ULONG           Index,
+    IN  ULONG           Cpu,
     OUT unsigned int    *vcpu_id
     )
 {
     PSYSTEM_CONTEXT     Context = &SystemContext;
-    PSYSTEM_PROCESSOR   Processor = &Context->Processor[Index];
+    PSYSTEM_PROCESSOR   Processor = &Context->Processor[Cpu];
     NTSTATUS            status;
 
     status = STATUS_UNSUCCESSFUL;
-    if (Index >= __SystemProcessorCount())
+    if (Cpu >= __SystemProcessorCount())
         goto fail1;
 
     *vcpu_id = Processor->ProcessorID;
-- 
2.17.1



From win-pv-devel-bounces@lists.xenproject.org Tue Dec 01 12:42:35 2020
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 01 Dec 2020 12:42:35 +0000
Received: from list by lists.xenproject.org with outflank-mailman.41936.75480 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1kk4zL-0008S7-7t; Tue, 01 Dec 2020 12:42:35 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 41936.75480; Tue, 01 Dec 2020 12:42:35 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1kk4zL-0008S0-4k; Tue, 01 Dec 2020 12:42:35 +0000
Received: by outflank-mailman (input) for mailman id 41936;
 Tue, 01 Dec 2020 12:42:34 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>) id 1kk4zK-0008RG-7A
 for win-pv-devel@lists.xenproject.org; Tue, 01 Dec 2020 12:42:34 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1kk4zJ-0003Zv-Vo; Tue, 01 Dec 2020 12:42:33 +0000
Received: from host86-183-162-145.range86-183.btcentralplus.com
 ([86.183.162.145] helo=CBG-R90WXYV0.home)
 by xenbits.xenproject.org with esmtpsa
 (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1kk4zJ-0004Pe-NS; Tue, 01 Dec 2020 12:42:33 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From;
	 bh=lHj4a5Ir0bEWAbRSYrN31eIgTQB/nhHPTOxUhBmsazM=; b=Bz3FU40fbZ2QnzSEVLaI+BpHS
	Vwx6Y0gO+pstycq3PdtazM4eD332RTaIdtJe3FPH7ir0HHNc55ZgvL6blDQAA+WN1TZur8YRz0ggQ
	u03axcQMQMrnvYjWN3aTbUreZcpCanM2B9Qc3LOymtr44qLvfFplljvSujUyycYHKmXXA=;
From: Paul Durrant <paul@xen.org>
To: win-pv-devel@lists.xenproject.org
Cc: Paul Durrant <pdurrant@amazon.com>
Subject: [PATCH xenbus 4/7] Introduce DriverGet/PutNamedPages()
Date: Tue,  1 Dec 2020 12:42:22 +0000
Message-Id: <20201201124225.1118-5-paul@xen.org>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20201201124225.1118-1-paul@xen.org>
References: <20201201124225.1118-1-paul@xen.org>

From: Paul Durrant <pdurrant@amazon.com>

A subsequent patch will need a mechanism to allocate memory that persists
for the lifetime of the VM. Because it is possible for the XEN.SYS module
can be unloaded, references to the PFNs of the allocated buffer are stored
under a volatile registry key such that they can be re-discovered if XEN.SYS
is re-loaded.

DriverGetNamedPages() will either allocate or discover PFNs and wrap them in
an MDL which is then mapped and passed back to the caller.
DriverPutNamedPages() will unmap the PFNs but not free them (since they
will have been written into the registry by DriverGetNamedPages()).

NOTE: There is also a whitespace fix in the call to RegistryCreateSubKey()
      for the 'ParametersKey' in driver.c.

Signed-off-by: Paul Durrant <pdurrant@amazon.com>
---
 src/xen/driver.c | 355 ++++++++++++++++++++++++++++++++++++++++++++---
 src/xen/driver.h |  11 ++
 2 files changed, 349 insertions(+), 17 deletions(-)

diff --git a/src/xen/driver.c b/src/xen/driver.c
index 9e4a18ef7dfd..4670539b488a 100644
--- a/src/xen/driver.c
+++ b/src/xen/driver.c
@@ -33,6 +33,7 @@
 
 #include <ntddk.h>
 #include <procgrp.h>
+#include <ntstrsafe.h>
 #include <xen.h>
 
 #include "registry.h"
@@ -47,6 +48,7 @@
 #include "bug_check.h"
 #include "dbg_print.h"
 #include "assert.h"
+#include "util.h"
 #include "version.h"
 
 #define DEFAULT_XEN_LOG_LEVEL   LOG_LEVEL_CRITICAL
@@ -59,12 +61,31 @@ typedef struct _XEN_DRIVER {
     PLOG_DISPOSITION    XenDisposition;
     PLOG_DISPOSITION    QemuDisposition;
     HANDLE              UnplugKey;
+    HANDLE              MemoryKey;
 } XEN_DRIVER, *PXEN_DRIVER;
 
 static XEN_DRIVER   Driver;
 
+#define XEN_DRIVER_TAG  'VIRD'
+
 extern PULONG   InitSafeBootMode;
 
+static FORCEINLINE PVOID
+__DriverAllocate(
+    IN  ULONG   Length
+    )
+{
+    return __AllocatePoolWithTag(NonPagedPool, Length, XEN_DRIVER_TAG);
+}
+
+static FORCEINLINE VOID
+__DriverFree(
+    IN  PVOID   Buffer
+    )
+{
+    __FreePoolWithTag(Buffer, XEN_DRIVER_TAG);
+}
+
 static FORCEINLINE BOOLEAN
 __DriverSafeMode(
     VOID
@@ -97,6 +118,284 @@ DriverGetUnplugKey(
     return __DriverGetUnplugKey();
 }
 
+static FORCEINLINE VOID
+__DriverSetMemoryKey(
+    IN  HANDLE  Key
+    )
+{
+    Driver.MemoryKey = Key;
+}
+
+static FORCEINLINE HANDLE
+__DriverGetMemoryKey(
+    VOID
+    )
+{
+    return Driver.MemoryKey;
+}
+
+#define MAXNAMELEN 128
+
+static FORCEINLINE NTSTATUS
+__DriverSetPfnArray(
+    IN  PCHAR       Name,
+    IN  ULONG       Count,
+    IN  PFN_NUMBER  PfnArray[]
+    )
+{
+    HANDLE          Key = __DriverGetMemoryKey();
+    LONG            Index;
+    NTSTATUS        status;
+
+    Index = 0;
+    while (Index < (LONG)Count) {
+        CHAR    ValueName[MAXNAMELEN];
+        PVOID   Value;
+        ULONG   Length;
+
+        status = RtlStringCbPrintfA(ValueName,
+                                    MAXNAMELEN,
+                                    "%s_%u",
+                                    Name,
+                                    Index);
+        ASSERT(NT_SUCCESS(status));
+
+        Value = &PfnArray[Index];
+        Length = sizeof (PFN_NUMBER);
+
+        status = RegistryUpdateBinaryValue(Key,
+                                           ValueName,
+                                           Value,
+                                           Length);
+        if (!NT_SUCCESS(status))
+            goto fail1;
+
+        Info("%s %p\n", ValueName, (PVOID)PfnArray[Index]);
+
+        Index++;
+    }
+
+    return STATUS_SUCCESS;
+
+fail1:
+    Error("fail1 (%08x)\n", status);
+
+    while (--Index >= 0) {
+        CHAR    ValueName[MAXNAMELEN];
+
+        status = RtlStringCbPrintfA(ValueName,
+                                    MAXNAMELEN,
+                                    "%s_%u",
+                                    Name,
+                                    Index);
+        ASSERT(NT_SUCCESS(status));
+
+        (VOID) RegistryDeleteValue(Key, ValueName);
+    }
+
+    return status;
+}
+
+static FORCEINLINE NTSTATUS
+__DriverAllocatePfnArray(
+    IN  PCHAR           Name,
+    IN  ULONG           Count,
+    OUT PFN_NUMBER      PfnArray[]
+    )
+{
+    PHYSICAL_ADDRESS    LowAddress;
+    PHYSICAL_ADDRESS    HighAddress;
+    LARGE_INTEGER       SkipBytes;
+    SIZE_T              TotalBytes;
+    PMDL                Mdl;
+    NTSTATUS            status;
+
+    LowAddress.QuadPart = 0ull;
+    HighAddress.QuadPart = ~0ull;
+    SkipBytes.QuadPart = 0ull;
+    TotalBytes = PAGE_SIZE * Count;
+
+    Mdl = MmAllocatePagesForMdlEx(LowAddress,
+                                  HighAddress,
+                                  SkipBytes,
+                                  TotalBytes,
+                                  MmCached,
+                                  MM_ALLOCATE_FULLY_REQUIRED);
+
+    status = STATUS_NO_MEMORY;
+    if (Mdl == NULL)
+        goto fail1;
+
+    if (Mdl->ByteCount < TotalBytes)
+        goto fail2;
+
+    ASSERT((Mdl->MdlFlags & (MDL_MAPPED_TO_SYSTEM_VA |
+                             MDL_PARTIAL_HAS_BEEN_MAPPED |
+                             MDL_PARTIAL |
+                             MDL_PARENT_MAPPED_SYSTEM_VA |
+                             MDL_SOURCE_IS_NONPAGED_POOL |
+                             MDL_IO_SPACE)) == 0);
+
+    status = __DriverSetPfnArray(Name, Count, MmGetMdlPfnArray(Mdl));
+    if (!NT_SUCCESS(status))
+        goto fail3;
+
+    RtlCopyMemory(PfnArray, MmGetMdlPfnArray(Mdl), sizeof (PFN_NUMBER) * Count);
+
+    ExFreePool(Mdl);
+
+    return STATUS_SUCCESS;
+
+fail3:
+    Error("fail3\n");
+
+fail2:
+    Error("fail2\n");
+
+    MmFreePagesFromMdl(Mdl);
+    ExFreePool(Mdl);
+
+fail1:
+    Error("fail1 (%08x)\n", status);
+
+    return status;
+}
+
+static FORCEINLINE NTSTATUS
+__DriverGetPfnArray(
+    IN  PCHAR       Name,
+    IN  ULONG       Count,
+    OUT PFN_NUMBER  PfnArray[]
+    )
+{
+    HANDLE          Key = __DriverGetMemoryKey();
+    ULONG           Index;
+    NTSTATUS        status;
+
+    for (Index = 0; Index < Count; Index++) {
+        CHAR    ValueName[MAXNAMELEN];
+        PVOID   Value;
+        ULONG   Length;
+
+        status = RtlStringCbPrintfA(ValueName,
+                                    MAXNAMELEN,
+                                    "%s_%u",
+                                    Name,
+                                    Index);
+        ASSERT(NT_SUCCESS(status));
+
+        status = RegistryQueryBinaryValue(Key,
+                                          ValueName,
+                                          &Value,
+                                          &Length);
+        if (!NT_SUCCESS(status))
+            goto fail1;
+
+        status = STATUS_UNSUCCESSFUL;
+        if (Length != sizeof (PFN_NUMBER))
+            goto fail2;
+
+        PfnArray[Index] = *(PPFN_NUMBER)Value;
+
+        RegistryFreeBinaryValue(Value);
+
+        Info("%s %p\n", Name, (PVOID)PfnArray[Index]);
+    }
+
+    return STATUS_SUCCESS;
+
+fail2:
+    Error("fail2\n");
+
+fail1:
+    Error("fail1 (%08x)\n", status);
+
+    return status;
+}
+
+PMDL
+DriverGetNamedPages(
+    IN  PCHAR   Name,
+    IN  ULONG   Count
+    )
+{
+    ULONG       Size;
+    PMDL        Mdl;
+    PUCHAR      MdlMappedSystemVa;
+    NTSTATUS    status;
+
+    Size = sizeof (MDL) + (sizeof (PFN_NUMBER) * Count);
+    Mdl = __DriverAllocate(Size);
+
+    status = STATUS_NO_MEMORY;
+    if (Mdl == NULL)
+        goto fail1;
+
+#pragma warning(push)
+#pragma warning(disable:28145) // modifying struct MDL
+
+    Mdl->Size = (USHORT)Size;
+    Mdl->MdlFlags = MDL_PAGES_LOCKED;
+    Mdl->ByteCount = PAGE_SIZE * Count;
+
+#pragma warning(pop)
+
+    status = __DriverGetPfnArray(Name, Count, MmGetMdlPfnArray(Mdl));
+    if (!NT_SUCCESS(status)) {
+        if (status == STATUS_OBJECT_NAME_NOT_FOUND)
+            status = __DriverAllocatePfnArray(Name, Count,
+                                              MmGetMdlPfnArray(Mdl));
+
+        if (!NT_SUCCESS(status))
+            goto fail2;
+    }
+
+    MdlMappedSystemVa = MmMapLockedPagesSpecifyCache(Mdl,
+                                                     KernelMode,
+                                                     MmCached,
+                                                     NULL,
+                                                     FALSE,
+                                                     NormalPagePriority);
+
+    status = STATUS_UNSUCCESSFUL;
+    if (MdlMappedSystemVa == NULL)
+        goto fail3;
+
+    Mdl->StartVa = PAGE_ALIGN(MdlMappedSystemVa);
+
+    return Mdl;
+
+fail3:
+    Error("fail3\n");
+
+fail2:
+    Error("fail2\n");
+
+    __DriverFree(Mdl);
+
+fail1:
+    Error("fail1 (%08x)\n", status);
+
+    return NULL;
+}
+
+VOID
+DriverPutNamedPages(
+    IN  PMDL    Mdl
+    )
+{
+    PUCHAR	    MdlMappedSystemVa;
+
+    ASSERT(Mdl->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA);
+    MdlMappedSystemVa = Mdl->MappedSystemVa;
+
+    MmUnmapLockedPages(MdlMappedSystemVa, Mdl);
+
+    // DO NOT FREE PAGES
+
+    __DriverFree(Mdl);
+}
+
 XEN_API
 NTSTATUS
 XenTouch(
@@ -173,8 +472,9 @@ DllInitialize(
     )
 {
     HANDLE              ServiceKey;
-    HANDLE              UnplugKey;
     HANDLE              ParametersKey;
+    HANDLE              UnplugKey;
+    HANDLE              MemoryKey;
     LOG_LEVEL           LogLevel;
     NTSTATUS            status;
 
@@ -198,9 +498,9 @@ DllInitialize(
         goto fail3;
 
     status = RegistryCreateSubKey(ServiceKey,
-                                "Parameters",
-                                REG_OPTION_NON_VOLATILE,
-                                &ParametersKey);
+                                  "Parameters",
+                                  REG_OPTION_NON_VOLATILE,
+                                  &ParametersKey);
     if (!NT_SUCCESS(status))
         goto fail4;
 
@@ -249,31 +549,40 @@ DllInitialize(
 
     __DriverSetUnplugKey(UnplugKey);
 
+    status = RegistryCreateSubKey(ServiceKey,
+                                  "Memory",
+                                  REG_OPTION_VOLATILE,
+                                  &MemoryKey);
+    if (!NT_SUCCESS(status))
+        goto fail6;
+
+    __DriverSetMemoryKey(MemoryKey);
+
     HypercallInitialize();
 
     status = AcpiInitialize();
     if (!NT_SUCCESS(status))
-        goto fail6;
+        goto fail7;
 
     status = SystemInitialize();
     if (!NT_SUCCESS(status))
-        goto fail7;
+        goto fail8;
 
     status = BugCheckInitialize();
     if (!NT_SUCCESS(status))
-        goto fail8;
+        goto fail9;
 
     status = ModuleInitialize();
     if (!NT_SUCCESS(status))
-        goto fail9;
+        goto fail10;
 
     status = ProcessInitialize();
     if (!NT_SUCCESS(status))
-        goto fail10;
+        goto fail11;
 
     status = UnplugInitialize();
     if (!NT_SUCCESS(status))
-        goto fail11;
+        goto fail12;
 
     RegistryCloseKey(ParametersKey);
 
@@ -283,36 +592,42 @@ DllInitialize(
 
     return STATUS_SUCCESS;
 
+fail12:
+    Error("fail12\n");
+
+    ProcessTeardown();
+
 fail11:
     Error("fail11\n");
 
-    ProcessTeardown();
+    ModuleTeardown();
 
 fail10:
     Error("fail10\n");
 
-    ModuleTeardown();
+    BugCheckTeardown();
 
 fail9:
     Error("fail9\n");
 
-    BugCheckTeardown();
+    SystemTeardown();
 
 fail8:
     Error("fail8\n");
 
-    SystemTeardown();
+    AcpiTeardown();
 
 fail7:
     Error("fail7\n");
 
-    AcpiTeardown();
+    HypercallTeardown();
+
+    RegistryCloseKey(MemoryKey);
+    __DriverSetMemoryKey(NULL);
 
 fail6:
     Error("fail6\n");
 
-    HypercallTeardown();
-
     RegistryCloseKey(UnplugKey);
     __DriverSetUnplugKey(NULL);
 
@@ -355,6 +670,7 @@ DllUnload(
     VOID
     )
 {
+    HANDLE  MemoryKey;
     HANDLE  UnplugKey;
 
     Trace("====>\n");
@@ -373,6 +689,11 @@ DllUnload(
 
     HypercallTeardown();
 
+    MemoryKey = __DriverGetMemoryKey();
+
+    RegistryCloseKey(MemoryKey);
+    __DriverSetMemoryKey(NULL);
+
     UnplugKey = __DriverGetUnplugKey();
 
     RegistryCloseKey(UnplugKey);
diff --git a/src/xen/driver.h b/src/xen/driver.h
index c4f7a6fb6f6d..8c39735147c6 100644
--- a/src/xen/driver.h
+++ b/src/xen/driver.h
@@ -37,4 +37,15 @@ DriverGetUnplugKey(
     VOID
     );
 
+extern PMDL
+DriverGetNamedPages(
+    IN  PCHAR   Name,
+    IN  ULONG   Count
+    );
+
+extern VOID
+DriverPutNamedPages(
+    IN  PMDL    Mdl
+    );
+
 #endif  // _XEN_DRIVER_H
-- 
2.17.1



From win-pv-devel-bounces@lists.xenproject.org Tue Dec 01 12:42:34 2020
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 01 Dec 2020 12:42:34 +0000
Received: from list by lists.xenproject.org with outflank-mailman.41935.75476 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1kk4zK-0008R6-9H; Tue, 01 Dec 2020 12:42:34 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 41935.75476; Tue, 01 Dec 2020 12:42:34 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1kk4zK-0008Qs-3G; Tue, 01 Dec 2020 12:42:34 +0000
Received: by outflank-mailman (input) for mailman id 41935;
 Tue, 01 Dec 2020 12:42:33 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>) id 1kk4zJ-0008Qb-Iu
 for win-pv-devel@lists.xenproject.org; Tue, 01 Dec 2020 12:42:33 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1kk4zJ-0003Zr-Ay; Tue, 01 Dec 2020 12:42:33 +0000
Received: from host86-183-162-145.range86-183.btcentralplus.com
 ([86.183.162.145] helo=CBG-R90WXYV0.home)
 by xenbits.xenproject.org with esmtpsa
 (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1kk4zJ-0004Pe-3E; Tue, 01 Dec 2020 12:42:33 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From;
	 bh=fUDHy/80Zg+HIuIyKi9PkS0AnSlrHO3639P5XwhtUkQ=; b=tevRuJ0FocLo7Kglvf1wKb09g
	SdvQTCj2GLyCQbii2rXl4DuJxstIzH60+MUDqprkg0cDbEl17wFDX/fi06PurNStgb37IZ36glfMY
	6vDNnuvuiJ1XsvXkkGDiU6dldmJjta4Mgu30/n7Zk3OTwinyE39matbK7hTZyTF8RkF48=;
From: Paul Durrant <paul@xen.org>
To: win-pv-devel@lists.xenproject.org
Cc: Paul Durrant <pdurrant@amazon.com>
Subject: [PATCH xenbus 3/7] Generalize per-processor DPC in SYSTEM
Date: Tue,  1 Dec 2020 12:42:21 +0000
Message-Id: <20201201124225.1118-4-paul@xen.org>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20201201124225.1118-1-paul@xen.org>
References: <20201201124225.1118-1-paul@xen.org>

From: Paul Durrant <pdurrant@amazon.com>

The DPC is currently used only for acquiring and display per-processor
information but a subsequent patch will also use the DPC for another purpose.
Hence this patch creates a general SystemProcessorDpc() call-back that then
calls a slightly modified SystemProcessorInformation() (which is renamed
SystemProcessorInitialize()) to fulfil the original purpose.

This patch also adds a mechanism for the per-processor DPCs to pass back
a status code to the main initialization code such that it can be aborted if
any of them fail. A new SystemProcessorTeardown() function is added to do
cleanup, and hence we can verify the SYSTEM_PROCESSOR structures are zeroed
in SystemDeregisterProcessorChangeCallback().

Currently no failure is possible during SystemProcessorDpc() but this will
change with the addition of a subsequent patch.

NOTE: __SystemProcessorCount() is relocated earlier in system.c as it now
      needs to be called by SystemDeregisterProcessorChangeCallback(). It
      is relocated earlier than strictly necessary for this, but
      subsequent patches will do further function relocation and add additonal
      funcrtions that also rely on __SystemProcessorCount() being in its new
      position.

Signed-off-by: Paul Durrant <pdurrant@amazon.com>
---
 src/xen/system.c | 179 +++++++++++++++++++++++++++++++++++------------
 1 file changed, 133 insertions(+), 46 deletions(-)

diff --git a/src/xen/system.c b/src/xen/system.c
index 8219c86f8321..7bd7cb381f38 100644
--- a/src/xen/system.c
+++ b/src/xen/system.c
@@ -49,10 +49,12 @@
 #define XEN_SYSTEM_TAG  'TSYS'
 
 typedef struct _SYSTEM_PROCESSOR {
-    KDPC    Dpc;
-    CHAR    Manufacturer[13];
-    UCHAR   ApicID;
-    UCHAR   ProcessorID;
+    KDPC        Dpc;
+    CHAR        Manufacturer[13];
+    UCHAR       ApicID;
+    UCHAR       ProcessorID;
+    NTSTATUS    Status;
+    KEVENT      Event;
 } SYSTEM_PROCESSOR, *PSYSTEM_PROCESSOR;
 
 typedef struct _SYSTEM_WATCHDOG {
@@ -562,37 +564,18 @@ done:
     Info("<====\n");
 }
 
-static
-_Function_class_(KDEFERRED_ROUTINE)
-_IRQL_requires_max_(DISPATCH_LEVEL)
-_IRQL_requires_min_(DISPATCH_LEVEL)
-_IRQL_requires_(DISPATCH_LEVEL)
-_IRQL_requires_same_
-VOID
-SystemProcessorInformation(
-    IN  PKDPC           Dpc,
-    IN  PVOID           _Context,
-    IN  PVOID           Argument1,
-    IN  PVOID           Argument2
+static VOID
+SystemProcessorInitialize(
+    IN  ULONG           Cpu
     )
 {
     PSYSTEM_CONTEXT     Context = &SystemContext;
-    PKEVENT             Event = Argument1;
-    ULONG               Cpu;
-    PROCESSOR_NUMBER    ProcNumber;
     PSYSTEM_PROCESSOR   Processor;
     ULONG               EAX;
     ULONG               EBX;
     ULONG               ECX;
     ULONG               EDX;
 
-    UNREFERENCED_PARAMETER(Dpc);
-    UNREFERENCED_PARAMETER(_Context);
-    UNREFERENCED_PARAMETER(Argument2);
-
-    Cpu = KeGetCurrentProcessorNumberEx(&ProcNumber);
-    ASSERT3U(Cpu, <, Context->ProcessorCount);
-
     Processor = &Context->Processor[Cpu];
 
     if (Cpu == 0) {
@@ -609,8 +592,6 @@ SystemProcessorInformation(
             SystemViridianInformation(EAX - 0x40000000);
     }
 
-    Info("====> (%u:%u)\n", ProcNumber.Group, ProcNumber.Number);
-
     __CpuId(0, NULL, &EBX, &ECX, &EDX);
 
     RtlCopyMemory(&Processor->Manufacturer[0], &EBX, sizeof (ULONG));
@@ -625,10 +606,73 @@ SystemProcessorInformation(
     Info("Manufacturer: %s\n", Processor->Manufacturer);
     Info("APIC ID: %02X\n", Processor->ApicID);
     Info("PROCESSOR ID: %02X\n", Processor->ProcessorID);
+}
+
+static VOID
+SystemProcessorTeardown(
+    IN  ULONG           Cpu
+    )
+{
+    PSYSTEM_CONTEXT     Context = &SystemContext;
+    PSYSTEM_PROCESSOR   Processor;
 
-    KeSetEvent(Event, IO_NO_INCREMENT, FALSE);
+    Processor = &Context->Processor[Cpu];
+
+    Processor->ProcessorID = 0;
+    Processor->ApicID = 0;
+    RtlZeroMemory(Processor->Manufacturer, sizeof (Processor->Manufacturer));
+}
+
+static FORCEINLINE ULONG
+__SystemProcessorCount(
+    VOID
+    )
+{
+    PSYSTEM_CONTEXT     Context = &SystemContext;
+
+    KeMemoryBarrier();
+
+    return Context->ProcessorCount;
+}
+
+static
+_Function_class_(KDEFERRED_ROUTINE)
+_IRQL_requires_max_(DISPATCH_LEVEL)
+_IRQL_requires_min_(DISPATCH_LEVEL)
+_IRQL_requires_(DISPATCH_LEVEL)
+_IRQL_requires_same_
+VOID
+SystemProcessorDpc(
+    IN  PKDPC           Dpc,
+    IN  PVOID           _Context,
+    IN  PVOID           Argument1,
+    IN  PVOID           Argument2
+    )
+{
+    PSYSTEM_CONTEXT     Context = &SystemContext;
+    ULONG               Cpu;
+    PROCESSOR_NUMBER    ProcNumber;
+    PSYSTEM_PROCESSOR   Processor;
+
+    UNREFERENCED_PARAMETER(Dpc);
+    UNREFERENCED_PARAMETER(_Context);
+    UNREFERENCED_PARAMETER(Argument1);
+    UNREFERENCED_PARAMETER(Argument2);
+
+    Cpu = KeGetCurrentProcessorNumberEx(&ProcNumber);
+    ASSERT3U(Cpu, <, Context->ProcessorCount);
+
+    Processor = &Context->Processor[Cpu];
+    Processor->Status = STATUS_UNSUCCESSFUL;
+
+    Info("====> (%u:%u)\n", ProcNumber.Group, ProcNumber.Number);
+
+    SystemProcessorInitialize(Cpu);
 
     Info("<==== (%u:%u)\n", ProcNumber.Group, ProcNumber.Number);
+
+    Processor->Status = STATUS_SUCCESS;
+    KeSetEvent(&Processor->Event, IO_NO_INCREMENT, FALSE);
 }
 
 static
@@ -690,21 +734,24 @@ SystemProcessorChangeCallback(
     }
     case KeProcessorAddCompleteNotify: {
         PSYSTEM_PROCESSOR   Processor;
-        KEVENT              Event;
 
         ASSERT3U(Cpu, <, Context->ProcessorCount);
 
         Processor = &Context->Processor[Cpu];
 
-        KeInitializeEvent(&Event, NotificationEvent, FALSE);
+        KeInitializeEvent(&Processor->Event, NotificationEvent, FALSE);
 
-        KeInitializeDpc(&Processor->Dpc, SystemProcessorInformation, NULL);
+        KeInitializeDpc(&Processor->Dpc, SystemProcessorDpc, NULL);
         KeSetImportanceDpc(&Processor->Dpc, HighImportance);
         KeSetTargetProcessorDpcEx(&Processor->Dpc, &ProcNumber);
 
-        KeInsertQueueDpc(&Processor->Dpc, &Event, NULL);
+        KeInsertQueueDpc(&Processor->Dpc, NULL, NULL);
 
-        (VOID) KeWaitForSingleObject(&Event,
+        //
+        // Wait for the DPC to avoid log lines from multiple processor
+        // initializations from being interleaved.
+        //
+        (VOID) KeWaitForSingleObject(&Processor->Event,
                                      Executive,
                                      KernelMode,
                                      FALSE,
@@ -758,10 +805,23 @@ SystemDeregisterProcessorChangeCallback(
     )
 {
     PSYSTEM_CONTEXT Context = &SystemContext;
+    ULONG           Cpu;
 
     KeDeregisterProcessorChangeCallback(Context->ProcessorChangeHandle);
     Context->ProcessorChangeHandle = NULL;
 
+    for (Cpu = 0; Cpu < __SystemProcessorCount(); Cpu++) {
+        PSYSTEM_PROCESSOR   Processor = &Context->Processor[Cpu];
+
+        SystemProcessorTeardown(Cpu);
+
+        RtlZeroMemory(&Processor->Dpc, sizeof (KDPC));
+        RtlZeroMemory(&Processor->Event, sizeof (KEVENT));
+        Processor->Status = 0;
+
+        ASSERT(IsZeroMemory(Processor, sizeof (SYSTEM_PROCESSOR)));
+    }
+
     __SystemFree(Context->Processor);
     Context->Processor = NULL;
     Context->ProcessorCount = 0;
@@ -964,6 +1024,38 @@ fail1:
     return status;
 }
 
+static NTSTATUS
+SystemCheckProcessors(
+    VOID
+    )
+{
+    PSYSTEM_CONTEXT Context = &SystemContext;
+    ULONG           Cpu;
+    NTSTATUS        status;
+
+    for (Cpu = 0; Cpu < __SystemProcessorCount(); Cpu++)
+    {
+        PSYSTEM_PROCESSOR   Processor = &Context->Processor[Cpu];
+
+        (VOID) KeWaitForSingleObject(&Processor->Event,
+                                     Executive,
+                                     KernelMode,
+                                     FALSE,
+                                     NULL);
+
+        status = Processor->Status;
+        if (!NT_SUCCESS(status))
+            goto fail1;
+    }
+
+    return STATUS_SUCCESS;
+
+fail1:
+    Error("fail1 (%08x)\n", status);
+
+    return status;
+}
+
 NTSTATUS
 SystemInitialize(
     VOID
@@ -1007,8 +1099,15 @@ SystemInitialize(
     if (!NT_SUCCESS(status))
         goto fail8;
 
+    status = SystemCheckProcessors();
+    if (!NT_SUCCESS(status))
+        goto fail9;
+
     return STATUS_SUCCESS;
 
+fail9:
+    Error("fail9\n");
+
 fail8:
     Error("fail8\n");
 
@@ -1045,18 +1144,6 @@ fail1:
     return status;
 }
 
-static FORCEINLINE ULONG
-__SystemProcessorCount(
-    VOID
-    )
-{
-    PSYSTEM_CONTEXT     Context = &SystemContext;
-
-    KeMemoryBarrier();
-
-    return Context->ProcessorCount;
-}
-
 XEN_API
 ULONG
 SystemProcessorCount(
-- 
2.17.1



From win-pv-devel-bounces@lists.xenproject.org Tue Dec 01 12:42:35 2020
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 01 Dec 2020 12:42:35 +0000
Received: from list by lists.xenproject.org with outflank-mailman.41933.75468 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1kk4zJ-0008QM-6C; Tue, 01 Dec 2020 12:42:33 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 41933.75468; Tue, 01 Dec 2020 12:42:33 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1kk4zJ-0008Q1-0B; Tue, 01 Dec 2020 12:42:33 +0000
Received: by outflank-mailman (input) for mailman id 41933;
 Tue, 01 Dec 2020 12:42:32 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>) id 1kk4zI-0008Pj-DL
 for win-pv-devel@lists.xenproject.org; Tue, 01 Dec 2020 12:42:32 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1kk4zI-0003Zj-4b; Tue, 01 Dec 2020 12:42:32 +0000
Received: from host86-183-162-145.range86-183.btcentralplus.com
 ([86.183.162.145] helo=CBG-R90WXYV0.home)
 by xenbits.xenproject.org with esmtpsa
 (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1kk4zH-0004Pe-SC; Tue, 01 Dec 2020 12:42:32 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From;
	 bh=p+EExFAsgty1/me2pmq1KoN6Aq5cbmNAKWbw8CWHYHQ=; b=CQKyW4Ow9+1lk4D2V1VhY3ubj
	2PnWAoCmpej9mxHzUeMqXbgGpoKWpFXXsw7IQqfnK43lJi2m38yIX3jnyCi7xM8VvPefdl8kJ+WJj
	anr3Ft6Rw5Wp/U2MWf85YlinPrQcgkRPDq52O/uLVAd45Pz2EZTAXWrvmFoqPCd+o2sI0=;
From: Paul Durrant <paul@xen.org>
To: win-pv-devel@lists.xenproject.org
Cc: Paul Durrant <pdurrant@amazon.com>
Subject: [PATCH xenbus 1/7] Move HypercallInitialize() earlier
Date: Tue,  1 Dec 2020 12:42:19 +0000
Message-Id: <20201201124225.1118-2-paul@xen.org>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20201201124225.1118-1-paul@xen.org>
References: <20201201124225.1118-1-paul@xen.org>

From: Paul Durrant <pdurrant@amazon.com>

A subsequent patch will add code called from SystemInitialize() that will need
to make hypercalls.

NOTE: There is a missing code to AcpiTeardown() in DllUnload() which is
      also fixed by this patch.

Signed-off-by: Paul Durrant <pdurrant@amazon.com>
---
 src/xen/driver.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/xen/driver.c b/src/xen/driver.c
index fe638d74b147..9e4a18ef7dfd 100644
--- a/src/xen/driver.c
+++ b/src/xen/driver.c
@@ -249,6 +249,8 @@ DllInitialize(
 
     __DriverSetUnplugKey(UnplugKey);
 
+    HypercallInitialize();
+
     status = AcpiInitialize();
     if (!NT_SUCCESS(status))
         goto fail6;
@@ -257,8 +259,6 @@ DllInitialize(
     if (!NT_SUCCESS(status))
         goto fail7;
 
-    HypercallInitialize();
-
     status = BugCheckInitialize();
     if (!NT_SUCCESS(status))
         goto fail8;
@@ -298,8 +298,6 @@ fail9:
 
     BugCheckTeardown();
 
-    HypercallTeardown();
-
 fail8:
     Error("fail8\n");
 
@@ -313,6 +311,8 @@ fail7:
 fail6:
     Error("fail6\n");
 
+    HypercallTeardown();
+
     RegistryCloseKey(UnplugKey);
     __DriverSetUnplugKey(NULL);
 
@@ -367,10 +367,12 @@ DllUnload(
 
     BugCheckTeardown();
 
-    HypercallTeardown();
-
     SystemTeardown();
 
+    AcpiTeardown();
+
+    HypercallTeardown();
+
     UnplugKey = __DriverGetUnplugKey();
 
     RegistryCloseKey(UnplugKey);
-- 
2.17.1



From win-pv-devel-bounces@lists.xenproject.org Tue Dec 01 12:42:34 2020
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 01 Dec 2020 12:42:34 +0000
Received: from list by lists.xenproject.org with outflank-mailman.41932.75464 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1kk4zJ-0008Px-28; Tue, 01 Dec 2020 12:42:33 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 41932.75464; Tue, 01 Dec 2020 12:42:33 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1kk4zI-0008Po-V2; Tue, 01 Dec 2020 12:42:32 +0000
Received: by outflank-mailman (input) for mailman id 41932;
 Tue, 01 Dec 2020 12:42:31 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>) id 1kk4zH-0008Pe-Sb
 for win-pv-devel@lists.xenproject.org; Tue, 01 Dec 2020 12:42:31 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1kk4zH-0003ZX-H2; Tue, 01 Dec 2020 12:42:31 +0000
Received: from host86-183-162-145.range86-183.btcentralplus.com
 ([86.183.162.145] helo=CBG-R90WXYV0.home)
 by xenbits.xenproject.org with esmtpsa
 (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1kk4zH-0004Pe-8B; Tue, 01 Dec 2020 12:42:31 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Message-Id:Date:Subject:Cc:To:From;
	bh=wGq+hdD9buovxxvm376W0VC6x9EHhNzXtuSAD6/O+0g=; b=uovWnelCMa5cnBm98LEXMnalpJ
	SimQOqFAjKnp1fm3805tjGJ56Fjq3lerimJIIapZgt+tqx19gW9OJB4quRcYEEAV18RnyL5x4e/lM
	oZ5z79PwunI2oQZiS3+iSMMP1EuPEyF6srBl+AJVm92ctTp8pWHC5iWsWrJbmhqgCZn0=;
From: Paul Durrant <paul@xen.org>
To: win-pv-devel@lists.xenproject.org
Cc: Paul Durrant <pdurrant@amazon.com>
Subject: [PATCH xenbus 0/7] Register memory for vcpu_info structures
Date: Tue,  1 Dec 2020 12:42:18 +0000
Message-Id: <20201201124225.1118-1-paul@xen.org>
X-Mailer: git-send-email 2.17.1

From: Paul Durrant <pdurrant@amazon.com>

This is necessary to allow 2-level event channels to function correctly
(i.e. allow binding) across more than 32 CPUs (XEN_LEGACY_MAX_VCPUS).

Paul Durrant (7):
  Move HypercallInitialize() earlier
  s/Index/Cpu in the SYSTEM code where 'Index' relates to a processor
  Generalize per-processor DPC in SYSTEM
  Introduce DriverGet/PutNamedPages()
  Re-work the code in sync.c to provide per-CPU 'early' and 'late'
    callbacks...
  Add a new helper function to make VCPUOP_register_vcpu_info hypercalls
  Register memory for struct vcpu_info

 include/xen.h            |  27 ++-
 src/xen/driver.c         | 361 +++++++++++++++++++++++++++++++--
 src/xen/driver.h         |  11 +
 src/xen/system.c         | 421 +++++++++++++++++++++++++++++++--------
 src/xen/vcpu.c           |  38 ++++
 src/xenbus/evtchn.c      |   8 +-
 src/xenbus/evtchn_2l.c   |   7 +-
 src/xenbus/evtchn_fifo.c |   8 +-
 src/xenbus/fdo.c         |   4 +-
 src/xenbus/shared_info.c |  52 +++--
 src/xenbus/suspend.c     | 111 +++++++----
 src/xenbus/sync.c        |  45 ++++-
 src/xenbus/sync.h        |  10 +-
 vs2015/xen/xen.vcxproj   |   2 +-
 vs2017/xen/xen.vcxproj   |   2 +-
 vs2019/xen/xen.vcxproj   |   2 +-
 16 files changed, 928 insertions(+), 181 deletions(-)

-- 
2.17.1



From win-pv-devel-bounces@lists.xenproject.org Tue Dec 01 12:42:36 2020
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 01 Dec 2020 12:42:36 +0000
Received: from list by lists.xenproject.org with outflank-mailman.41938.75487 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1kk4zM-0008Ta-Dq; Tue, 01 Dec 2020 12:42:36 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 41938.75487; Tue, 01 Dec 2020 12:42:36 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1kk4zM-0008TD-8I; Tue, 01 Dec 2020 12:42:36 +0000
Received: by outflank-mailman (input) for mailman id 41938;
 Tue, 01 Dec 2020 12:42:35 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>) id 1kk4zL-0008ST-AV
 for win-pv-devel@lists.xenproject.org; Tue, 01 Dec 2020 12:42:35 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1kk4zL-0003a3-6P; Tue, 01 Dec 2020 12:42:35 +0000
Received: from host86-183-162-145.range86-183.btcentralplus.com
 ([86.183.162.145] helo=CBG-R90WXYV0.home)
 by xenbits.xenproject.org with esmtpsa
 (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1kk4zK-0004Pe-V1; Tue, 01 Dec 2020 12:42:35 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From;
	 bh=pFSlUruqxRWHeawCqGLIlQVY2cbf4Fu3RBBu89zl3yI=; b=ZsKAs9cnM6O8E/pjOTTvZKQ0a
	EJLNEu+x4qo+N+w1/DKzTwQ6fr395sVhj2fm3UwaCevV+devcgSB4J0SKiyvwZFXOpGkpNq8m4fKg
	Wv6Bp52qo0hpRTu8gdwQy8FZlLZkmMVjFxovD5dGWHWo974q/USMxiyrTt/HQLJnzngAw=;
From: Paul Durrant <paul@xen.org>
To: win-pv-devel@lists.xenproject.org
Cc: Paul Durrant <pdurrant@amazon.com>
Subject: [PATCH xenbus 6/7] Add a new helper function to make VCPUOP_register_vcpu_info hypercalls
Date: Tue,  1 Dec 2020 12:42:24 +0000
Message-Id: <20201201124225.1118-7-paul@xen.org>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20201201124225.1118-1-paul@xen.org>
References: <20201201124225.1118-1-paul@xen.org>

From: Paul Durrant <pdurrant@amazon.com>

Signed-off-by: Paul Durrant <pdurrant@amazon.com>
---
 include/xen.h  |  9 +++++++++
 src/xen/vcpu.c | 38 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+)

diff --git a/include/xen.h b/include/xen.h
index 89f68867ad5f..8fb55c753c55 100644
--- a/include/xen.h
+++ b/include/xen.h
@@ -495,4 +495,13 @@ VcpuSetPeriodicTimer(
     IN  PLARGE_INTEGER  Period
     );
 
+__checkReturn
+XEN_API
+NTSTATUS
+VcpuRegisterVcpuInfo(
+    IN  unsigned int                vcpu_id,
+    IN  PFN_NUMBER                  Pfn,
+    IN  ULONG                       Offset
+    );
+
 #endif  // _XEN_H
diff --git a/src/xen/vcpu.c b/src/xen/vcpu.c
index a1881cf37b0c..552b3b330878 100644
--- a/src/xen/vcpu.c
+++ b/src/xen/vcpu.c
@@ -80,3 +80,41 @@ fail1:
 
     return status;
 }
+
+__checkReturn
+XEN_API
+NTSTATUS
+VcpuRegisterVcpuInfo(
+    IN  unsigned int                vcpu_id,
+    IN  PFN_NUMBER                  Pfn,
+    IN  ULONG                       Offset
+    )
+{
+    struct vcpu_register_vcpu_info  op;
+    LONG_PTR                        rc;
+    NTSTATUS                        status;
+
+    op.mfn = (xen_pfn_t)Pfn;
+    op.offset = Offset;
+    op.rsvd = 0;
+
+    //
+    // NOTE: This has to be called on the CPU with the matching vcpu_id
+    //       otherwise Xen will fail the hypercall with -EINVAL.
+    //
+
+    rc = VcpuOp(VCPUOP_register_vcpu_info, vcpu_id, &op);
+
+    if (rc < 0) {
+        ERRNO_TO_STATUS(-rc, status);
+        goto fail1;
+    }
+
+    return STATUS_SUCCESS;
+
+fail1:
+    Error("fail1 (%08x)\n", status);
+
+    return status;
+
+}
-- 
2.17.1



From win-pv-devel-bounces@lists.xenproject.org Tue Dec 01 12:42:36 2020
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 01 Dec 2020 12:42:36 +0000
Received: from list by lists.xenproject.org with outflank-mailman.41937.75488 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1kk4zM-0008T9-Ew; Tue, 01 Dec 2020 12:42:36 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 41937.75488; Tue, 01 Dec 2020 12:42:36 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1kk4zM-0008T0-6i; Tue, 01 Dec 2020 12:42:36 +0000
Received: by outflank-mailman (input) for mailman id 41937;
 Tue, 01 Dec 2020 12:42:34 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>) id 1kk4zK-0008Ro-SA
 for win-pv-devel@lists.xenproject.org; Tue, 01 Dec 2020 12:42:34 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1kk4zK-0003Zz-Ij; Tue, 01 Dec 2020 12:42:34 +0000
Received: from host86-183-162-145.range86-183.btcentralplus.com
 ([86.183.162.145] helo=CBG-R90WXYV0.home)
 by xenbits.xenproject.org with esmtpsa
 (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1kk4zK-0004Pe-Ay; Tue, 01 Dec 2020 12:42:34 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From;
	 bh=ad87lxKdC34MYYYgxco29mNxZwyIpa24bFsnRJWOSWc=; b=shUh81J+kzq3DUWAE3vGmzb7y
	KdB3dC/gI+jiCgbtK0WfYZH1TbFJdD9J69Kfv91C0FFJQpt4u1gKiDD+PEZMdzFZhcCM663Tbaxkc
	l2RBKo7RQ5ylqrb9faOJi4wtlWiu08Iof3yhTuIcjY1XJn7nzGh1fOUVJ6x2tCjzs7nb4=;
From: Paul Durrant <paul@xen.org>
To: win-pv-devel@lists.xenproject.org
Cc: Paul Durrant <pdurrant@amazon.com>
Subject: [PATCH xenbus 5/7] Re-work the code in sync.c to provide per-CPU 'early' and 'late' callbacks...
Date: Tue,  1 Dec 2020 12:42:23 +0000
Message-Id: <20201201124225.1118-6-paul@xen.org>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20201201124225.1118-1-paul@xen.org>
References: <20201201124225.1118-1-paul@xen.org>

From: Paul Durrant <pdurrant@amazon.com>

... and then use these to drive the XENBUS_SUSPEND callbacks, rather than them
being called directly from SuspendTrigger().

Since the clients of the XENBUS_SUSPEND interface only expect one invocation
of each callback, rather then one per-CPU, they are only invoked from the
sync.c callback for CPU 0. A subsequent patch will introduce a function that
must be called from the 'early' callback for each CPU.

NOTE: The call to KeGetCurrentProcessorNumberEx() made in SyncRelease() is
      relocated to __SyncRelease(), as that is the place where the CPU index
      is actually used.

Signed-off-by: Paul Durrant <pdurrant@amazon.com>
---
 src/xenbus/suspend.c | 106 ++++++++++++++++++++++++++++---------------
 src/xenbus/sync.c    |  45 +++++++++++++++---
 src/xenbus/sync.h    |  10 +++-
 3 files changed, 118 insertions(+), 43 deletions(-)

diff --git a/src/xenbus/suspend.c b/src/xenbus/suspend.c
index 5667e8446176..77752b00d490 100644
--- a/src/xenbus/suspend.c
+++ b/src/xenbus/suspend.c
@@ -51,6 +51,7 @@ struct _XENBUS_SUSPEND_CONTEXT {
     PXENBUS_FDO                 Fdo;
     KSPIN_LOCK                  Lock;
     LONG                        References;
+    BOOLEAN                     Success;
     ULONG                       Count;
     LIST_ENTRY                  EarlyList;
     LIST_ENTRY                  LateList;
@@ -180,6 +181,73 @@ __SuspendLogTimers(
               PerformanceFrequency.LowPart);
 }
 
+static VOID
+SuspendEarly(
+    IN  PVOID               Argument,
+    IN  ULONG               Cpu
+    )
+{
+    PXENBUS_SUSPEND_CONTEXT Context = Argument;
+    PLIST_ENTRY             ListEntry;
+
+    LogPrintf(LOG_LEVEL_INFO,
+              "SUSPEND: EARLY (%u)\n", Cpu);
+
+    if (!Context->Success || Cpu != 0)
+        return;
+
+    //
+    // No lock is required here as the VM is single-threaded with interrupts
+    // disabled.
+    //
+
+    Context->Count++;
+
+    HypercallPopulate();
+
+    UnplugDevices();
+
+    for (ListEntry = Context->EarlyList.Flink;
+         ListEntry != &Context->EarlyList;
+         ListEntry = ListEntry->Flink) {
+        PXENBUS_SUSPEND_CALLBACK  Callback;
+
+        Callback = CONTAINING_RECORD(ListEntry,
+                                     XENBUS_SUSPEND_CALLBACK,
+                                     ListEntry);
+        Callback->Function(Callback->Argument);
+    }
+}
+
+static VOID
+SuspendLate(
+    IN  PVOID               Argument,
+    IN  ULONG               Cpu
+    )
+{
+    PXENBUS_SUSPEND_CONTEXT Context = Argument;
+    PLIST_ENTRY             ListEntry;
+
+    LogPrintf(LOG_LEVEL_INFO,
+              "SUSPEND: LATE (%u)\n", Cpu);
+
+    if (!Context->Success || Cpu != 0)
+        return;
+
+    // No lock is required here as the VM is single-threaded
+
+    for (ListEntry = Context->LateList.Flink;
+         ListEntry != &Context->LateList;
+         ListEntry = ListEntry->Flink) {
+        PXENBUS_SUSPEND_CALLBACK  Callback;
+
+        Callback = CONTAINING_RECORD(ListEntry,
+                                     XENBUS_SUSPEND_CALLBACK,
+                                     ListEntry);
+        Callback->Function(Callback->Argument);
+    }
+}
+
 NTSTATUS
 #pragma prefast(suppress:28167) // Function changes IRQL
 SuspendTrigger(
@@ -195,7 +263,7 @@ SuspendTrigger(
     LogPrintf(LOG_LEVEL_INFO,
               "SUSPEND: ====>\n");
 
-    SyncCapture();
+    SyncCapture(Context, SuspendEarly, SuspendLate);
     SyncDisableInterrupts();
 
     __SuspendLogTimers("PRE-SUSPEND");
@@ -209,43 +277,9 @@ SuspendTrigger(
 
     __SuspendLogTimers("POST-SUSPEND");
 
-    if (NT_SUCCESS(status)) {
-        PLIST_ENTRY ListEntry;
-
-        Context->Count++;
-
-        HypercallPopulate();
-
-        UnplugDevices();
-
-        for (ListEntry = Context->EarlyList.Flink;
-             ListEntry != &Context->EarlyList;
-             ListEntry = ListEntry->Flink) {
-            PXENBUS_SUSPEND_CALLBACK  Callback;
-
-            Callback = CONTAINING_RECORD(ListEntry, XENBUS_SUSPEND_CALLBACK, ListEntry);
-            Callback->Function(Callback->Argument);
-        }
-    }
+    Context->Success = NT_SUCCESS(status) ? TRUE : FALSE;
 
     SyncEnableInterrupts();
-
-    // No lock is required here as the VM is single-threaded until
-    // SyncRelease() is called.
-
-    if (NT_SUCCESS(status)) {
-        PLIST_ENTRY ListEntry;
-
-        for (ListEntry = Context->LateList.Flink;
-             ListEntry != &Context->LateList;
-             ListEntry = ListEntry->Flink) {
-            PXENBUS_SUSPEND_CALLBACK  Callback;
-
-            Callback = CONTAINING_RECORD(ListEntry, XENBUS_SUSPEND_CALLBACK, ListEntry);
-            Callback->Function(Callback->Argument);
-        }
-    }
-
     SyncRelease();
 
     LogPrintf(LOG_LEVEL_INFO, "SUSPEND: <====\n");
diff --git a/src/xenbus/sync.c b/src/xenbus/sync.c
index 661aabe54a0d..615eca84c460 100644
--- a/src/xenbus/sync.c
+++ b/src/xenbus/sync.c
@@ -86,6 +86,9 @@ typedef struct  _SYNC_PROCESSOR {
 } SYNC_PROCESSOR, *PSYNC_PROCESSOR;
 
 typedef struct  _SYNC_CONTEXT {
+    PVOID               Argument;
+    SYNC_CALLBACK       Early;
+    SYNC_CALLBACK       Late;
     ULONG               Sequence;
     LONG                ProcessorCount;
     LONG                CompletionCount;
@@ -108,10 +111,13 @@ __SyncAcquire(
 
 static FORCEINLINE VOID
 __SyncRelease(
-    IN  LONG    Index
+    VOID
     )
 {
-    LONG        Old;
+    LONG    Old;
+    LONG    Index;
+
+    Index = KeGetCurrentProcessorNumberEx(NULL);
 
     Old = InterlockedExchange(&SyncOwner, -1);
     ASSERT3U(Old, ==, Index);
@@ -145,6 +151,9 @@ SyncWorker(
 
     InterruptsDisabled = FALSE;
     Index = KeGetCurrentProcessorNumberEx(&ProcNumber);
+
+    ASSERT(SyncOwner >= 0 && Index != (ULONG)SyncOwner);
+
     Processor = &Context->Processor[Index];
 
     Trace("====> (%u:%u)\n", ProcNumber.Group, ProcNumber.Number);
@@ -153,8 +162,12 @@ SyncWorker(
     for (;;) {
         ULONG   Sequence;
 
-        if (Processor->Exit)
+        if (Processor->Exit) {
+            if (Context->Late != NULL)
+                Context->Late(Context->Argument, Index);
+
             break;
+        }
 
         if (Processor->DisableInterrupts == InterruptsDisabled) {
             _mm_pause();
@@ -210,6 +223,9 @@ SyncWorker(
         } else {
             InterruptsDisabled = FALSE;
 
+            if (Context->Early != NULL)
+                Context->Early(Context->Argument, Index);
+
             _enable();
 
 #pragma prefast(suppress:28138) // Use constant rather than variable
@@ -236,7 +252,9 @@ __drv_maxIRQL(DISPATCH_LEVEL)
 __drv_raisesIRQL(DISPATCH_LEVEL)
 VOID
 SyncCapture(
-    VOID
+    IN  PVOID           Argument OPTIONAL,
+    IN  SYNC_CALLBACK   Early OPTIONAL,
+    IN  SYNC_CALLBACK   Late OPTIONAL
     )
 {
     PSYNC_CONTEXT       Context = SyncContext;
@@ -257,6 +275,10 @@ SyncCapture(
 
     ASSERT(IsZeroMemory(Context, PAGE_SIZE));
 
+    Context->Argument = Argument;
+    Context->Early = Early;
+    Context->Late = Late;
+
     Context->Sequence++;
     Context->CompletionCount = 0;
 
@@ -304,6 +326,8 @@ SyncDisableInterrupts(
 
     Trace("====>\n");
 
+    ASSERT(SyncOwner >= 0);
+
     Context->Sequence++;
     Context->CompletionCount = 0;
 
@@ -368,6 +392,11 @@ SyncEnableInterrupts(
     KIRQL           Irql;
     LONG            Index;
 
+    ASSERT(SyncOwner >= 0);
+
+    if (Context->Early != NULL)
+        Context->Early(Context->Argument, SyncOwner);
+
     _enable();
 
     Irql = KeGetCurrentIrql();
@@ -409,6 +438,11 @@ SyncRelease(
 
     Trace("====>\n");
 
+    ASSERT(SyncOwner >= 0);
+
+    if (Context->Late != NULL)
+        Context->Late(Context->Argument, SyncOwner);
+
     Context->Sequence++;
     Context->CompletionCount = 0;
 
@@ -429,8 +463,7 @@ SyncRelease(
 
     RtlZeroMemory(Context, PAGE_SIZE);
 
-    Index = KeGetCurrentProcessorNumberEx(NULL);
-    __SyncRelease(Index);
+    __SyncRelease();
 
     Trace("<====\n");
 }
diff --git a/src/xenbus/sync.h b/src/xenbus/sync.h
index affbf0f9f0d5..c4b172107513 100644
--- a/src/xenbus/sync.h
+++ b/src/xenbus/sync.h
@@ -34,12 +34,20 @@
 
 #include <ntddk.h>
 
+typedef VOID
+(*SYNC_CALLBACK)(
+    IN  PVOID   Arguement,
+    IN  ULONG   Cpu
+    );
+
 extern
 __drv_maxIRQL(DISPATCH_LEVEL)
 __drv_raisesIRQL(DISPATCH_LEVEL)
 VOID
 SyncCapture(
-    VOID
+    IN  PVOID           Argument OPTIONAL,
+    IN  SYNC_CALLBACK   Early OPTIONAL,
+    IN  SYNC_CALLBACK   Late OPTIONAL
     );
 
 extern
-- 
2.17.1



From win-pv-devel-bounces@lists.xenproject.org Tue Dec 01 12:42:37 2020
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 01 Dec 2020 12:42:37 +0000
Received: from list by lists.xenproject.org with outflank-mailman.41939.75492 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1kk4zN-0008V7-ED; Tue, 01 Dec 2020 12:42:37 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 41939.75492; Tue, 01 Dec 2020 12:42:37 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1kk4zN-0008V1-Aj; Tue, 01 Dec 2020 12:42:37 +0000
Received: by outflank-mailman (input) for mailman id 41939;
 Tue, 01 Dec 2020 12:42:36 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>) id 1kk4zM-0008Ss-39
 for win-pv-devel@lists.xenproject.org; Tue, 01 Dec 2020 12:42:36 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1kk4zL-0003a7-RT; Tue, 01 Dec 2020 12:42:35 +0000
Received: from host86-183-162-145.range86-183.btcentralplus.com
 ([86.183.162.145] helo=CBG-R90WXYV0.home)
 by xenbits.xenproject.org with esmtpsa
 (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1kk4zL-0004Pe-Ie; Tue, 01 Dec 2020 12:42:35 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From;
	 bh=Hi73YPCgfiKzWjcdlKyWAY2oPxt8VaZkKmDiIURWZfU=; b=gbJte4bIwgstVK5EZgOgAau5/
	cEJrug/G3qDy8wH0MOfl+sKfApnAK26rjKIGtXZqKn6lUZfI8Vg1QZTLA/wwXfQuYBvSVjVS6s4U8
	Fgsh8qKKkpeVYcejqCWg75H2VnAvFcD1HF8szpAy2boL2aRXp7wvL6IC7pzm9dp8QfVfs=;
From: Paul Durrant <paul@xen.org>
To: win-pv-devel@lists.xenproject.org
Cc: Paul Durrant <pdurrant@amazon.com>
Subject: [PATCH xenbus 7/7] Register memory for struct vcpu_info
Date: Tue,  1 Dec 2020 12:42:25 +0000
Message-Id: <20201201124225.1118-8-paul@xen.org>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20201201124225.1118-1-paul@xen.org>
References: <20201201124225.1118-1-paul@xen.org>

From: Paul Durrant <pdurrant@amazon.com>

This must only be done once for each vCPU in the lifetime of the VM. The
PFNs of the allocated memory are therefore saved in the registry such that
they can be recovered if XEN.SYS is unloaded and re-loaded.

References to the legacy vcpu_info structures embedded in the shared_info are
replaced and the limit of XEN_LEGACY_MAX_VCPUS is removed from the 2-level
event channel implementation.

NOTE: SystemVirtualCpuIndex() is also renamed to SystemProcessorVcpuId()
      for consistency, and it is co-located with the new
      SystemProcessorVcpuInfo() function.
      It is also necessary to disable warning C4146 (unary minus operator
      applied to unsigned type) in xen.vcxproj as this is done by the
      P2ROUNDUP() macro.

Signed-off-by: Paul Durrant <pdurrant@amazon.com>
---
 include/xen.h            |  16 ++-
 src/xen/system.c         | 224 +++++++++++++++++++++++++++++++++++----
 src/xenbus/evtchn.c      |   8 +-
 src/xenbus/evtchn_2l.c   |   7 +-
 src/xenbus/evtchn_fifo.c |   8 +-
 src/xenbus/fdo.c         |   4 +-
 src/xenbus/shared_info.c |  52 +++++----
 src/xenbus/suspend.c     |   7 +-
 vs2015/xen/xen.vcxproj   |   2 +-
 vs2017/xen/xen.vcxproj   |   2 +-
 vs2019/xen/xen.vcxproj   |   2 +-
 11 files changed, 268 insertions(+), 64 deletions(-)

diff --git a/include/xen.h b/include/xen.h
index 8fb55c753c55..674c285fe9f0 100644
--- a/include/xen.h
+++ b/include/xen.h
@@ -456,11 +456,25 @@ SystemProcessorCount(
 
 XEN_API
 NTSTATUS
-SystemVirtualCpuIndex(
+SystemProcessorVcpuId(
     IN  ULONG           Cpu,
     OUT unsigned int    *vcpu_id
     );
 
+XEN_API
+NTSTATUS
+SystemProcessorVcpuInfo(
+    IN  ULONG       Cpu,
+    OUT vcpu_info_t **vcpu_info
+    );
+
+XEN_API
+NTSTATUS
+SystemProcessorRegisterVcpuInfo(
+    IN  ULONG   Cpu,
+    IN  BOOLEAN Force
+    );
+
 XEN_API
 PHYSICAL_ADDRESS
 SystemMaximumPhysicalAddress(
diff --git a/src/xen/system.c b/src/xen/system.c
index 7bd7cb381f38..14de3a2de015 100644
--- a/src/xen/system.c
+++ b/src/xen/system.c
@@ -45,6 +45,7 @@
 #include "dbg_print.h"
 #include "assert.h"
 #include "util.h"
+#include "driver.h"
 
 #define XEN_SYSTEM_TAG  'TSYS'
 
@@ -55,6 +56,8 @@ typedef struct _SYSTEM_PROCESSOR {
     UCHAR       ProcessorID;
     NTSTATUS    Status;
     KEVENT      Event;
+    vcpu_info_t *Vcpu;
+    PBOOLEAN    Registered;
 } SYSTEM_PROCESSOR, *PSYSTEM_PROCESSOR;
 
 typedef struct _SYSTEM_WATCHDOG {
@@ -72,6 +75,7 @@ typedef struct _SYSTEM_CONTEXT {
     PHYSICAL_ADDRESS    MaximumPhysicalAddress;
     BOOLEAN             RealTimeIsUniversal;
     SYSTEM_WATCHDOG     Watchdog;
+    PMDL                Mdl;
 } SYSTEM_CONTEXT, *PSYSTEM_CONTEXT;
 
 static SYSTEM_CONTEXT   SystemContext;
@@ -635,6 +639,139 @@ __SystemProcessorCount(
     return Context->ProcessorCount;
 }
 
+XEN_API
+NTSTATUS
+SystemProcessorVcpuId(
+    IN  ULONG           Cpu,
+    OUT unsigned int    *vcpu_id
+    )
+{
+    PSYSTEM_CONTEXT     Context = &SystemContext;
+    PSYSTEM_PROCESSOR   Processor = &Context->Processor[Cpu];
+    NTSTATUS            status;
+
+    status = STATUS_UNSUCCESSFUL;
+    if (Cpu >= __SystemProcessorCount())
+        goto fail1;
+
+    *vcpu_id = Processor->ProcessorID;
+    return STATUS_SUCCESS;
+
+fail1:
+    return status;
+}
+
+XEN_API
+NTSTATUS
+SystemProcessorVcpuInfo(
+    IN  ULONG           Cpu,
+    OUT vcpu_info_t     **Vcpu
+    )
+{
+    PSYSTEM_CONTEXT     Context = &SystemContext;
+    PSYSTEM_PROCESSOR   Processor = &Context->Processor[Cpu];
+    NTSTATUS            status;
+
+    status = STATUS_UNSUCCESSFUL;
+    if (Cpu >= __SystemProcessorCount())
+        goto fail1;
+
+    ASSERT(*Processor->Registered);
+    *Vcpu = Processor->Vcpu;
+
+    return STATUS_SUCCESS;
+
+fail1:
+    return status;
+}
+
+XEN_API
+NTSTATUS
+SystemProcessorRegisterVcpuInfo(
+    IN  ULONG           Cpu,
+    IN  BOOLEAN         Force
+    )
+{
+    PSYSTEM_CONTEXT     Context = &SystemContext;
+    PSYSTEM_PROCESSOR   Processor = &Context->Processor[Cpu];
+    PMDL                Mdl = Context->Mdl;
+    ULONG               Offset;
+    PFN_NUMBER          Pfn;
+    PHYSICAL_ADDRESS    Address;
+    PUCHAR              MdlMappedSystemVa;
+    NTSTATUS            status;
+
+    status = STATUS_UNSUCCESSFUL;
+    if (Cpu >= __SystemProcessorCount())
+        goto fail1;
+
+    ASSERT(Mdl->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA);
+    MdlMappedSystemVa = Mdl->MappedSystemVa;
+
+    Offset = sizeof (vcpu_info_t) * HVM_MAX_VCPUS;
+    Offset += sizeof (BOOLEAN) * Cpu;
+
+    Processor->Registered = (PBOOLEAN)(MdlMappedSystemVa + Offset);
+
+    Offset = sizeof (vcpu_info_t) * Cpu;
+
+    Processor->Vcpu = (vcpu_info_t *)(MdlMappedSystemVa + Offset);
+
+    Pfn = MmGetMdlPfnArray(Context->Mdl)[Offset >> PAGE_SHIFT];
+    Offset = Offset & (PAGE_SIZE - 1);
+
+    if (!*Processor->Registered || Force) {
+        unsigned int    vcpu_id;
+
+        status = SystemProcessorVcpuId(Cpu, &vcpu_id);
+        ASSERT(NT_SUCCESS(status));
+
+        status = VcpuRegisterVcpuInfo(vcpu_id, Pfn, Offset);
+        if (!NT_SUCCESS(status))
+            goto fail2;
+
+        LogPrintf(LOG_LEVEL_INFO,
+                  "XEN: REGISTER vcpu_info[%u]\n",
+                  Cpu);
+
+        *Processor->Registered = TRUE;
+    }
+
+    Address.QuadPart = (ULONGLONG)Pfn << PAGE_SHIFT;
+    Address.QuadPart += Offset;
+
+    LogPrintf(LOG_LEVEL_INFO,
+              "XEN: vcpu_info[%u] @ %08x.%08x\n",
+              Cpu,
+              Address.HighPart,
+              Address.LowPart);
+
+    return STATUS_SUCCESS;
+
+fail2:
+    Error("fail2\n");
+
+    Processor->Vcpu = NULL;
+    Processor->Registered = NULL;
+
+fail1:
+    Error("fail1 (%08x)\n", status);
+
+    return status;
+}
+
+static VOID
+SystemProcessorDeregisterVcpuInfo(
+    IN  ULONG           Cpu
+    )
+{
+    PSYSTEM_CONTEXT     Context = &SystemContext;
+    PSYSTEM_PROCESSOR   Processor = &Context->Processor[Cpu];
+
+    Processor->Vcpu = NULL;
+    Processor->Registered = NULL;
+}
+
 static
 _Function_class_(KDEFERRED_ROUTINE)
 _IRQL_requires_max_(DISPATCH_LEVEL)
@@ -653,6 +790,7 @@ SystemProcessorDpc(
     ULONG               Cpu;
     PROCESSOR_NUMBER    ProcNumber;
     PSYSTEM_PROCESSOR   Processor;
+    NTSTATUS            status;
 
     UNREFERENCED_PARAMETER(Dpc);
     UNREFERENCED_PARAMETER(_Context);
@@ -669,10 +807,22 @@ SystemProcessorDpc(
 
     SystemProcessorInitialize(Cpu);
 
+    status = SystemProcessorRegisterVcpuInfo(Cpu, FALSE);
+    if (!NT_SUCCESS(status))
+        goto fail1;
+
     Info("<==== (%u:%u)\n", ProcNumber.Group, ProcNumber.Number);
 
     Processor->Status = STATUS_SUCCESS;
     KeSetEvent(&Processor->Event, IO_NO_INCREMENT, FALSE);
+
+    return;
+
+fail1:
+    Error("fail1 (%08x)\n", status);
+
+    Processor->Status = status;
+    KeSetEvent(&Processor->Event, IO_NO_INCREMENT, FALSE);
 }
 
 static
@@ -772,6 +922,44 @@ SystemProcessorChangeCallback(
           ProcessorChangeName(Change->State));
 }
 
+static NTSTATUS
+SystemAllocateVcpuInfo(
+    VOID
+    )
+{
+    PSYSTEM_CONTEXT Context = &SystemContext;
+    ULONG           Size;
+    NTSTATUS        status;
+
+    Size = sizeof (vcpu_info_t) * HVM_MAX_VCPUS;
+    Size += sizeof (BOOLEAN) * HVM_MAX_VCPUS;
+    Size = P2ROUNDUP(Size, PAGE_SIZE);
+
+    Context->Mdl = DriverGetNamedPages("VCPU_INFO", Size >> PAGE_SHIFT);
+
+    status = STATUS_NO_MEMORY;
+    if (Context->Mdl == NULL)
+        goto fail1;
+
+    return STATUS_SUCCESS;
+
+fail1:
+    Error("fail1 (%08x)\n", status);
+
+    return status;
+}
+
+static VOID
+SystemFreeVcpuInfo(
+    VOID
+    )
+{
+    PSYSTEM_CONTEXT Context = &SystemContext;
+
+    DriverPutNamedPages(Context->Mdl);
+    Context->Mdl = NULL;
+}
+
 static NTSTATUS
 SystemRegisterProcessorChangeCallback(
     VOID
@@ -781,18 +969,27 @@ SystemRegisterProcessorChangeCallback(
     PVOID           Handle;
     NTSTATUS        status;
 
+    status = SystemAllocateVcpuInfo();
+    if (!NT_SUCCESS(status))
+        goto fail1;
+
     Handle = KeRegisterProcessorChangeCallback(SystemProcessorChangeCallback,
                                                NULL,
                                                KE_PROCESSOR_CHANGE_ADD_EXISTING);
 
     status = STATUS_UNSUCCESSFUL;
     if (Handle == NULL)
-        goto fail1;
+        goto fail2;
 
     Context->ProcessorChangeHandle = Handle;
 
     return STATUS_SUCCESS;
 
+fail2:
+    Error("fail2\n");
+
+    SystemFreeVcpuInfo();
+
 fail1:
     Error("fail1 (%08x)\n", status);
 
@@ -813,6 +1010,7 @@ SystemDeregisterProcessorChangeCallback(
     for (Cpu = 0; Cpu < __SystemProcessorCount(); Cpu++) {
         PSYSTEM_PROCESSOR   Processor = &Context->Processor[Cpu];
 
+        SystemProcessorDeregisterVcpuInfo(Cpu);
         SystemProcessorTeardown(Cpu);
 
         RtlZeroMemory(&Processor->Dpc, sizeof (KDPC));
@@ -825,6 +1023,8 @@ SystemDeregisterProcessorChangeCallback(
     __SystemFree(Context->Processor);
     Context->Processor = NULL;
     Context->ProcessorCount = 0;
+
+    SystemFreeVcpuInfo();
 }
 
 static NTSTATUS
@@ -1153,28 +1353,6 @@ SystemProcessorCount(
     return __SystemProcessorCount();
 }
 
-XEN_API
-NTSTATUS
-SystemVirtualCpuIndex(
-    IN  ULONG           Cpu,
-    OUT unsigned int    *vcpu_id
-    )
-{
-    PSYSTEM_CONTEXT     Context = &SystemContext;
-    PSYSTEM_PROCESSOR   Processor = &Context->Processor[Cpu];
-    NTSTATUS            status;
-
-    status = STATUS_UNSUCCESSFUL;
-    if (Cpu >= __SystemProcessorCount())
-        goto fail1;
-
-    *vcpu_id = Processor->ProcessorID;
-    return STATUS_SUCCESS;
-
-fail1:
-    return status;
-}
-
 XEN_API
 PHYSICAL_ADDRESS
 SystemMaximumPhysicalAddress(
diff --git a/src/xenbus/evtchn.c b/src/xenbus/evtchn.c
index 662ca038fc31..55c16b73212a 100644
--- a/src/xenbus/evtchn.c
+++ b/src/xenbus/evtchn.c
@@ -283,7 +283,7 @@ EvtchnOpenVirq(
     if (!Processor->UpcallEnabled && Cpu != 0)
         goto fail1;
 
-    status = SystemVirtualCpuIndex(Cpu, &vcpu_id);
+    status = SystemProcessorVcpuId(Cpu, &vcpu_id);
     ASSERT(NT_SUCCESS(status));
 
     status = EventChannelBindVirq(Index, vcpu_id, &LocalPort);
@@ -768,7 +768,7 @@ EvtchnBind(
 
     LocalPort = Channel->LocalPort;
 
-    status = SystemVirtualCpuIndex(Cpu, &vcpu_id);
+    status = SystemProcessorVcpuId(Cpu, &vcpu_id);
     ASSERT(NT_SUCCESS(status));
 
     status = EventChannelBindVirtualCpu(LocalPort, vcpu_id);
@@ -1290,7 +1290,7 @@ EvtchnInterruptEnable(
         if (Processor->Interrupt == NULL)
             continue;
 
-        status = SystemVirtualCpuIndex(Cpu, &vcpu_id);
+        status = SystemProcessorVcpuId(Cpu, &vcpu_id);
         ASSERT(NT_SUCCESS(status));
 
         Vector = FdoGetInterruptVector(Context->Fdo, Processor->Interrupt);
@@ -1349,7 +1349,7 @@ EvtchnInterruptDisable(
         if (!Processor->UpcallEnabled)
             continue;
 
-        status = SystemVirtualCpuIndex(Cpu, &vcpu_id);
+        status = SystemProcessorVcpuId(Cpu, &vcpu_id);
         ASSERT(NT_SUCCESS(status));
 
         (VOID) HvmSetEvtchnUpcallVector(vcpu_id, 0);
diff --git a/src/xenbus/evtchn_2l.c b/src/xenbus/evtchn_2l.c
index a869e150df29..99a37798932b 100644
--- a/src/xenbus/evtchn_2l.c
+++ b/src/xenbus/evtchn_2l.c
@@ -72,12 +72,9 @@ EvtchnTwoLevelIsProcessorEnabled(
     )
 {
     UNREFERENCED_PARAMETER(_Context);
+    UNREFERENCED_PARAMETER(Index);
 
-    //
-    // We currently rely on using the vcpu_info array that is embedded
-    // in the shared_info.
-    //
-    return (Index < XEN_LEGACY_MAX_VCPUS) ? TRUE : FALSE;
+    return TRUE;
 }
 
 static BOOLEAN
diff --git a/src/xenbus/evtchn_fifo.c b/src/xenbus/evtchn_fifo.c
index c08e664041c6..475f99de10d7 100644
--- a/src/xenbus/evtchn_fifo.c
+++ b/src/xenbus/evtchn_fifo.c
@@ -289,7 +289,7 @@ EvtchnFifoIsProcessorEnabled(
     unsigned int                    vcpu_id;
     NTSTATUS                        status;
     
-    status = SystemVirtualCpuIndex(Index, &vcpu_id);
+    status = SystemProcessorVcpuId(Index, &vcpu_id);
     if (!NT_SUCCESS(status))
         return FALSE;
 
@@ -364,7 +364,7 @@ EvtchnFifoPoll(
 
     DoneSomething = FALSE;
 
-    status = SystemVirtualCpuIndex(Index, &vcpu_id);
+    status = SystemProcessorVcpuId(Index, &vcpu_id);
     if (!NT_SUCCESS(status))
         goto done;
 
@@ -510,7 +510,7 @@ EvtchnFifoAcquire(
         if (Mdl == NULL)
             goto fail1;
 
-        status = SystemVirtualCpuIndex(Index, &vcpu_id);
+        status = SystemProcessorVcpuId(Index, &vcpu_id);
         ASSERT(NT_SUCCESS(status));
 
         Pfn = MmGetMdlPfnArray(Mdl)[0];
@@ -552,7 +552,7 @@ fail1:
     while (--Index >= 0) {
         unsigned int    vcpu_id;
 
-        (VOID) SystemVirtualCpuIndex(Index, &vcpu_id);
+        (VOID) SystemProcessorVcpuId(Index, &vcpu_id);
 
         Mdl = Context->ControlBlockMdl[vcpu_id];
         Context->ControlBlockMdl[vcpu_id] = NULL;
diff --git a/src/xenbus/fdo.c b/src/xenbus/fdo.c
index 9db968de0247..9944ef6d5c0e 100644
--- a/src/xenbus/fdo.c
+++ b/src/xenbus/fdo.c
@@ -2850,7 +2850,7 @@ __FdoVirqDestroy(
         unsigned int    vcpu_id;
         NTSTATUS        status;
 
-        status = SystemVirtualCpuIndex(Virq->Cpu, &vcpu_id);
+        status = SystemProcessorVcpuId(Virq->Cpu, &vcpu_id);
         ASSERT(NT_SUCCESS(status));
 
         (VOID) VcpuSetPeriodicTimer(vcpu_id, NULL);
@@ -2904,7 +2904,7 @@ __FdoVirqCreate(
     if (Type == VIRQ_TIMER) {
         LARGE_INTEGER   Period;
 
-        status = SystemVirtualCpuIndex(Cpu, &vcpu_id);
+        status = SystemProcessorVcpuId(Cpu, &vcpu_id);
         ASSERT(NT_SUCCESS(status));
 
         BUG_ON(Fdo->Watchdog == 0);
diff --git a/src/xenbus/shared_info.c b/src/xenbus/shared_info.c
index 473088c18c93..6aefb81cd284 100644
--- a/src/xenbus/shared_info.c
+++ b/src/xenbus/shared_info.c
@@ -155,23 +155,23 @@ SharedInfoEvtchnMaskAll(
 
 static BOOLEAN
 SharedInfoUpcallPending(
-    IN  PINTERFACE              Interface,
-    IN  ULONG                   Index
+    IN  PINTERFACE  Interface,
+    IN  ULONG       Index
     )
 {
-    PXENBUS_SHARED_INFO_CONTEXT Context = Interface->Context;
-    shared_info_t               *Shared = Context->Shared;
-    unsigned int                vcpu_id;
-    UCHAR                       Pending;
-    NTSTATUS                    status;
+    vcpu_info_t     *vcpu_info;
+    UCHAR           Pending;
+    NTSTATUS        status;
 
-    status = SystemVirtualCpuIndex(Index, &vcpu_id);
+    UNREFERENCED_PARAMETER(Interface);
+
+    status = SystemProcessorVcpuInfo(Index, &vcpu_info);
     if (!NT_SUCCESS(status))
         return FALSE;
 
     KeMemoryBarrier();
 
-    Pending = _InterlockedExchange8((CHAR *)&Shared->vcpu_info[vcpu_id].evtchn_upcall_pending, 0);
+    Pending = _InterlockedExchange8((CHAR *)&vcpu_info->evtchn_upcall_pending, 0);
 
     return (Pending != 0) ? TRUE : FALSE;
 }
@@ -187,6 +187,7 @@ SharedInfoEvtchnPoll(
     PXENBUS_SHARED_INFO_CONTEXT     Context = Interface->Context;
     shared_info_t                   *Shared = Context->Shared;
     unsigned int                    vcpu_id;
+    vcpu_info_t                     *vcpu_info;
     ULONG                           Port;
     ULONG_PTR                       SelectorMask;
     BOOLEAN                         DoneSomething;
@@ -194,13 +195,17 @@ SharedInfoEvtchnPoll(
 
     DoneSomething = FALSE;
 
-    status = SystemVirtualCpuIndex(Index, &vcpu_id);
+    status = SystemProcessorVcpuId(Index, &vcpu_id);
+    if (!NT_SUCCESS(status))
+        goto done;
+
+    status = SystemProcessorVcpuInfo(Index, &vcpu_info);
     if (!NT_SUCCESS(status))
         goto done;
 
     KeMemoryBarrier();
 
-    SelectorMask = (ULONG_PTR)InterlockedExchangePointer((PVOID *)&Shared->vcpu_info[vcpu_id].evtchn_pending_sel, (PVOID)0);
+    SelectorMask = (ULONG_PTR)InterlockedExchangePointer((PVOID *)&vcpu_info->evtchn_pending_sel, (PVOID)0);
 
     KeMemoryBarrier();
 
@@ -320,6 +325,7 @@ SharedInfoGetTime(
 
     PXENBUS_SHARED_INFO_CONTEXT Context = Interface->Context;
     shared_info_t               *Shared;
+    vcpu_info_t                 *vcpu_info;
     ULONG                       WcVersion;
     ULONG                       TimeVersion;
     ULONGLONG                   Seconds;
@@ -331,16 +337,20 @@ SharedInfoGetTime(
     CHAR                        TscShift;
     TIME_FIELDS                 TimeFields;
     KIRQL                       Irql;
+    NTSTATUS                    status;
 
     // Make sure we don't suspend
     KeRaiseIrql(DISPATCH_LEVEL, &Irql);
 
     Shared = Context->Shared;
 
+    status = SystemProcessorVcpuInfo(0, &vcpu_info);
+    ASSERT(NT_SUCCESS(status));
+
     // Loop until we can read a consistent set of values from the same update
     do {
         WcVersion = Shared->wc_version;
-        TimeVersion = Shared->vcpu_info[0].time.version;
+        TimeVersion = vcpu_info->time.version;
         KeMemoryBarrier();
 
         // Wallclock time at system time zero (guest boot or resume)
@@ -348,21 +358,21 @@ SharedInfoGetTime(
         NanoSeconds = Shared->wc_nsec;
 
         // Cached time in nanoseconds since guest boot
-        SystemTime = Shared->vcpu_info[0].time.system_time;
+        SystemTime = vcpu_info->time.system_time;
 
         // Timestamp counter value when these time values were last updated
-        Timestamp = Shared->vcpu_info[0].time.tsc_timestamp;
+        Timestamp = vcpu_info->time.tsc_timestamp;
 
         // Timestamp modifiers
-        TscShift = Shared->vcpu_info[0].time.tsc_shift;
-        TscSystemMul = Shared->vcpu_info[0].time.tsc_to_system_mul;
+        TscShift = vcpu_info->time.tsc_shift;
+        TscSystemMul = vcpu_info->time.tsc_to_system_mul;
         KeMemoryBarrier();
 
     // Version is incremented to indicate update in progress.
     // LSB of version is set if update in progress.
     // Version is incremented again once update has completed.
     } while (Shared->wc_version != WcVersion ||
-             Shared->vcpu_info[0].time.version != TimeVersion ||
+             vcpu_info->time.version != TimeVersion ||
              (WcVersion & 1) ||
              (TimeVersion & 1));
 
@@ -491,10 +501,10 @@ SharedInfoDebugCallback(
              Index < KeQueryActiveProcessorCountEx(ALL_PROCESSOR_GROUPS);
              Index++) {
             PROCESSOR_NUMBER    ProcNumber;
-            unsigned int        vcpu_id;
+            vcpu_info_t         *vcpu_info;
             NTSTATUS            status;
 
-            status = SystemVirtualCpuIndex(Index, &vcpu_id);
+            status = SystemProcessorVcpuInfo(Index, &vcpu_info);
             if (!NT_SUCCESS(status))
                 continue;
 
@@ -506,7 +516,7 @@ SharedInfoDebugCallback(
                          "CPU %u:%u: PENDING: %s\n",
                          ProcNumber.Group,
                          ProcNumber.Number,
-                         Shared->vcpu_info[vcpu_id].evtchn_upcall_pending ?
+                         vcpu_info->evtchn_upcall_pending ?
                          "TRUE" :
                          "FALSE");
 
@@ -515,7 +525,7 @@ SharedInfoDebugCallback(
                          "CPU %u:%u: SELECTOR MASK: %p\n",
                          ProcNumber.Group,
                          ProcNumber.Number,
-                         (PVOID)Shared->vcpu_info[vcpu_id].evtchn_pending_sel);
+                         (PVOID)vcpu_info->evtchn_pending_sel);
         }
 
         for (Selector = 0; Selector < XENBUS_SHARED_INFO_EVTCHN_SELECTOR_COUNT; Selector += 4) {
diff --git a/src/xenbus/suspend.c b/src/xenbus/suspend.c
index 77752b00d490..f058a4f1edfc 100644
--- a/src/xenbus/suspend.c
+++ b/src/xenbus/suspend.c
@@ -193,7 +193,7 @@ SuspendEarly(
     LogPrintf(LOG_LEVEL_INFO,
               "SUSPEND: EARLY (%u)\n", Cpu);
 
-    if (!Context->Success || Cpu != 0)
+    if (!Context->Success)
         return;
 
     //
@@ -203,6 +203,11 @@ SuspendEarly(
 
     Context->Count++;
 
+    SystemProcessorRegisterVcpuInfo(Cpu, TRUE);
+
+    if (Cpu != 0)
+        return;
+
     HypercallPopulate();
 
     UnplugDevices();
diff --git a/vs2015/xen/xen.vcxproj b/vs2015/xen/xen.vcxproj
index 65be5010f451..3280f4b39e95 100644
--- a/vs2015/xen/xen.vcxproj
+++ b/vs2015/xen/xen.vcxproj
@@ -23,7 +23,7 @@
       <AdditionalIncludeDirectories>$(WindowsSdkDir)\include\km;..\..\include;..\..\include\xen;..\..\src\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>PROJECT=$(ProjectName);POOL_NX_OPTIN=1;NT_PROCESSOR_GROUPS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <WarningLevel>EnableAllWarnings</WarningLevel>
-      <DisableSpecificWarnings>4464;4711;4548;4820;4668;4255;6001;6054;28196;30030;30029;%(DisableSpecificWarnings)</DisableSpecificWarnings>
+      <DisableSpecificWarnings>4146;4464;4711;4548;4820;4668;4255;6001;6054;28196;30030;30029;%(DisableSpecificWarnings)</DisableSpecificWarnings>
       <MultiProcessorCompilation>true</MultiProcessorCompilation>
       <EnablePREfast>true</EnablePREfast>
     </ClCompile>
diff --git a/vs2017/xen/xen.vcxproj b/vs2017/xen/xen.vcxproj
index 9fec76255ca3..7f4dce944988 100644
--- a/vs2017/xen/xen.vcxproj
+++ b/vs2017/xen/xen.vcxproj
@@ -24,7 +24,7 @@
       <PreprocessorDefinitions>PROJECT=$(ProjectName);POOL_NX_OPTIN=1;NT_PROCESSOR_GROUPS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <IntrinsicFunctions>true</IntrinsicFunctions>
       <WarningLevel>EnableAllWarnings</WarningLevel>
-      <DisableSpecificWarnings>4464;4711;4770;4548;4820;4668;4255;5045;6001;6054;28196;30030;30029;%(DisableSpecificWarnings)</DisableSpecificWarnings>
+      <DisableSpecificWarnings>4146;4464;4711;4770;4548;4820;4668;4255;5045;6001;6054;28196;30030;30029;%(DisableSpecificWarnings)</DisableSpecificWarnings>
       <MultiProcessorCompilation>true</MultiProcessorCompilation>
       <EnablePREfast>true</EnablePREfast>
     </ClCompile>
diff --git a/vs2019/xen/xen.vcxproj b/vs2019/xen/xen.vcxproj
index 56de3d25b6ea..39b5bda87eb6 100644
--- a/vs2019/xen/xen.vcxproj
+++ b/vs2019/xen/xen.vcxproj
@@ -24,7 +24,7 @@
       <PreprocessorDefinitions>PROJECT=$(ProjectName);POOL_NX_OPTIN=1;NT_PROCESSOR_GROUPS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <IntrinsicFunctions>true</IntrinsicFunctions>
       <WarningLevel>EnableAllWarnings</WarningLevel>
-      <DisableSpecificWarnings>4464;4711;4770;4548;4820;4668;4255;5045;6001;6054;26451;28196;30030;30029;%(DisableSpecificWarnings)</DisableSpecificWarnings>
+      <DisableSpecificWarnings>4146;4464;4711;4770;4548;4820;4668;4255;5045;6001;6054;26451;28196;30030;30029;%(DisableSpecificWarnings)</DisableSpecificWarnings>
       <MultiProcessorCompilation>true</MultiProcessorCompilation>
       <EnablePREfast>true</EnablePREfast>
     </ClCompile>
-- 
2.17.1



From win-pv-devel-bounces@lists.xenproject.org Tue Dec 01 13:39:31 2020
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 01 Dec 2020 13:39:31 +0000
Received: from list by lists.xenproject.org with outflank-mailman.42033.75574 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1kk5sQ-0005dw-7b; Tue, 01 Dec 2020 13:39:30 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 42033.75574; Tue, 01 Dec 2020 13:39:30 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1kk5sQ-0005do-4Y; Tue, 01 Dec 2020 13:39:30 +0000
Received: by outflank-mailman (input) for mailman id 42033;
 Tue, 01 Dec 2020 13:39:28 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>) id 1kk5sO-0005dj-CY
 for win-pv-devel@lists.xenproject.org; Tue, 01 Dec 2020 13:39:28 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1kk5sN-0004lE-W3; Tue, 01 Dec 2020 13:39:27 +0000
Received: from host86-183-162-145.range86-183.btcentralplus.com
 ([86.183.162.145] helo=CBG-R90WXYV0.home)
 by xenbits.xenproject.org with esmtpsa
 (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1kk5sN-0001Ow-Qg; Tue, 01 Dec 2020 13:39:27 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Message-Id:Date:Subject:Cc:To:From;
	bh=0UcPf2orDNjz3qucAomKIH3bjHbtqspptIFJHR2cWHk=; b=MxXcD0iur/eaQre1n/1RLWUrli
	7LWUj9t9v0rQvwvPihg97KkIyNDd9cQQZ6i91uA2MpMlBi/aUHHMahjCF96d6NHyHDVUx+gZpKRs2
	+J6h1Hd5ej2V2rv3V32vKNiUhMTuDdWbXdsO6b8DhL6x7mYnNcUuJoMaW+QQYkCj98eo=;
From: Paul Durrant <paul@xen.org>
To: win-pv-devel@lists.xenproject.org
Cc: Paul Durrant <pdurrant@amazon.com>
Subject: [PATCH xenvif] Don't assume queue numbers can't be larger than 99
Date: Tue,  1 Dec 2020 13:39:24 +0000
Message-Id: <20201201133924.1255-1-paul@xen.org>
X-Mailer: git-send-email 2.17.1

From: Paul Durrant <pdurrant@amazon.com>

The theoretical maximum number of receiver or transmitter queues is limited at
the number of vCPUs in the VM, and this can be as many as 128 (limited by
Xen).

Signed-off-by: Paul Durrant <pdurrant@amazon.com>
---
 src/xenvif/frontend.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/xenvif/frontend.c b/src/xenvif/frontend.c
index ffd611120adf..30de494d2484 100644
--- a/src/xenvif/frontend.c
+++ b/src/xenvif/frontend.c
@@ -283,7 +283,7 @@ FrontendFormatPath(
     NTSTATUS                status;
 
     Length = (ULONG)(strlen(__FrontendGetPath(Frontend)) +
-                     strlen("/queue-XX") +
+                     strlen("/queue-XXX") +
                      1) * sizeof (CHAR);
 
     Path = __FrontendAllocate(Length);
-- 
2.17.1



From win-pv-devel-bounces@lists.xenproject.org Tue Dec 01 23:05:39 2020
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 01 Dec 2020 23:05:39 +0000
Received: from list by lists.xenproject.org with outflank-mailman.42340.76102 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1kkEiH-0003FC-LQ; Tue, 01 Dec 2020 23:05:37 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 42340.76102; Tue, 01 Dec 2020 23:05:37 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1kkEiH-0003F3-IA; Tue, 01 Dec 2020 23:05:37 +0000
Received: by outflank-mailman (input) for mailman id 42340;
 Tue, 01 Dec 2020 23:05:35 +0000
Received: from winpvdrvbuild.xenproject.org ([162.242.160.44])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul.durrant@xenproject.org>) id 1kkEiF-0003Ey-Li
 for win-pv-devel@lists.xenproject.org; Tue, 01 Dec 2020 23:05:35 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
Date: Tue, 1 Dec 2020 23:05:37 +0000 (UTC)
From: paul.durrant@xenproject.org
To: win-pv-devel@lists.xenproject.org
Message-ID: <15592862.11.1606863938317.JavaMail.WINPVDRVBUILD$@winpvdrvbuild>
Subject: XENVIF-master - Build #183 - Successful
MIME-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_10_29954327.1606863937911"
X-Jenkins-Job: XENVIF-master
X-Jenkins-Result: SUCCESS


------=_Part_10_29954327.1606863937911
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit

The build system has completed build #183.

Check console output at https://winpvdrvbuild.xenproject.org:8080/job/XENVIF-master/183/console to view the results.
------=_Part_10_29954327.1606863937911--


From win-pv-devel-bounces@lists.xenproject.org Thu Dec 03 08:48:59 2020
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 03 Dec 2020 08:48:59 +0000
Received: from list by lists.xenproject.org with outflank-mailman.43180.77674 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1kkkIL-0006Ax-BD; Thu, 03 Dec 2020 08:48:57 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 43180.77674; Thu, 03 Dec 2020 08:48:57 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1kkkIL-0006Ap-8D; Thu, 03 Dec 2020 08:48:57 +0000
Received: by outflank-mailman (input) for mailman id 43180;
 Thu, 03 Dec 2020 08:48:55 +0000
Received: from winpvdrvbuild.xenproject.org ([162.242.160.44])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul.durrant@xenproject.org>) id 1kkkIJ-0006Ah-Fb
 for win-pv-devel@lists.xenproject.org; Thu, 03 Dec 2020 08:48:55 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
Date: Thu, 3 Dec 2020 08:48:57 +0000 (UTC)
From: paul.durrant@xenproject.org
To: win-pv-devel@lists.xenproject.org
Message-ID: <31743160.13.1606985339129.JavaMail.WINPVDRVBUILD$@winpvdrvbuild>
Subject: XENBUS-master - Build #211 - Successful
MIME-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_12_24210489.1606985337176"
X-Jenkins-Job: XENBUS-master
X-Jenkins-Result: SUCCESS


------=_Part_12_24210489.1606985337176
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit

The build system has completed build #211.

Check console output at https://winpvdrvbuild.xenproject.org:8080/job/XENBUS-master/211/console to view the results.
------=_Part_12_24210489.1606985337176--


From win-pv-devel-bounces@lists.xenproject.org Fri Dec 04 20:17:13 2020
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 04 Dec 2020 20:17:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.45055.80528 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1klHVv-00057E-6L; Fri, 04 Dec 2020 20:17:11 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 45055.80528; Fri, 04 Dec 2020 20:17:11 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1klHVv-000575-3A; Fri, 04 Dec 2020 20:17:11 +0000
Received: by outflank-mailman (input) for mailman id 45055;
 Fri, 04 Dec 2020 20:17:09 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>) id 1klHVt-000570-Lw
 for win-pv-devel@lists.xenproject.org; Fri, 04 Dec 2020 20:17:09 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1klHVt-0003Yy-CP; Fri, 04 Dec 2020 20:17:09 +0000
Received: from host86-183-162-145.range86-183.btcentralplus.com
 ([86.183.162.145] helo=CBG-R90WXYV0.home)
 by xenbits.xenproject.org with esmtpsa
 (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1klHVt-0006Pw-3F; Fri, 04 Dec 2020 20:17:09 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Message-Id:Date:Subject:Cc:To:From;
	bh=npdm63HckQztv44jSAJ4PdkR4xP6+4/VYugFHU3bCpg=; b=LoQe+t6lG+HSqw+twd+dUib5+k
	fvY9wluET+WVCH1dU7hxxUxIHLrX4SCOH7wSHlRg2cDjWEoslrCchnPZ0k7VIKdC37K3tlOynwAjY
	qCx04eTXWFRmEoYaAjqxKwJy72FCOhNsMfaH+sNtGC9BUdzFQGASKTfCwHdtSNo0WAng=;
From: Paul Durrant <paul@xen.org>
To: win-pv-devel@lists.xenproject.org
Cc: Paul Durrant <pdurrant@amazon.com>
Subject: [PATCH xenbus] Make sure the interrupt handler for each vCPU is run...
Date: Fri,  4 Dec 2020 20:17:05 +0000
Message-Id: <20201204201705.11435-1-paul@xen.org>
X-Mailer: git-send-email 2.17.1

From: Paul Durrant <pdurrant@amazon.com>

... after enabling event channel delivery.

New versions of Xen have this sequence in their map_vcpu_info() function:

    /*
     * Mark everything as being pending just to make sure nothing gets
     * lost.  The domain will get a spurious event, but it can cope.
     */
    if ( !has_32bit_shinfo(d) )
        write_atomic(&new_info->native.evtchn_pending_sel, ~0);
    else
        write_atomic(&vcpu_info(v, evtchn_pending_sel), ~0);
    vcpu_mark_events_pending(v);

whereas older versions code this differently:

    /*
     * Mark everything as being pending just to make sure nothing gets
     * lost.  The domain will get a spurious event, but it can cope.
     */
    vcpu_info(v, evtchn_upcall_pending) = 1;
    for ( i = 0; i < BITS_PER_EVTCHN_WORD(d); i++ )
        set_bit(i, &vcpu_info(v, evtchn_pending_sel));

The crucial difference is that in the older variant there is no call to
vcpu_mark_events_pending() which means that, for an HVM guest at least,
the upcall function that clears 'evtchn_upcall_pending' does not get
run and hence no events will be received on that vCPU.

This patch makes sure the upcall function for each vCPU is run at least once
thereby ensuring that 'evtchn_upcall_pending' is cleared.

NOTE: The patch also adds a 'Count' to each XENBUS_INTERRUPT object,
      incremented each time the interrupt is triggred, and emits a log line
      when the value transitions from zero.

Signed-off-by: Paul Durrant <pdurrant@amazon.com>
---
 src/xenbus/evtchn.c | 9 +++++++++
 src/xenbus/fdo.c    | 7 +++++++
 2 files changed, 16 insertions(+)

diff --git a/src/xenbus/evtchn.c b/src/xenbus/evtchn.c
index 55c16b73212a..d0702686aeea 100644
--- a/src/xenbus/evtchn.c
+++ b/src/xenbus/evtchn.c
@@ -1269,6 +1269,7 @@ EvtchnInterruptEnable(
 {
     ULONG                       Cpu;
     ULONG                       Line;
+    KIRQL                       Irql;
     NTSTATUS                    status;
 
     Trace("====>\n");
@@ -1312,6 +1313,10 @@ EvtchnInterruptEnable(
              ProcNumber.Number,
              Vector);
         Processor->UpcallEnabled = TRUE;
+
+        Irql = FdoAcquireInterruptLock(Context->Fdo, Processor->Interrupt);
+        (VOID) EvtchnInterruptCallback(NULL, Processor);
+        FdoReleaseInterruptLock(Context->Fdo, Processor->Interrupt, Irql);
     }
 
 line:
@@ -1322,6 +1327,10 @@ line:
 
     Info("CALLBACK VIA (Vector = %u)\n", Line);
 
+    Irql = FdoAcquireInterruptLock(Context->Fdo, Context->Interrupt);
+    (VOID) EvtchnInterruptCallback(NULL, &Context->Processor[0]);
+    FdoReleaseInterruptLock(Context->Fdo, Context->Interrupt, Irql);
+
     Trace("<====\n");
 }
 
diff --git a/src/xenbus/fdo.c b/src/xenbus/fdo.c
index 9944ef6d5c0e..21de8678c959 100644
--- a/src/xenbus/fdo.c
+++ b/src/xenbus/fdo.c
@@ -78,6 +78,7 @@ struct _XENBUS_INTERRUPT {
     ULONG               Line;
     PKSERVICE_ROUTINE   Callback;
     PVOID               Argument;
+    ULONG               Count;
 };
 
 typedef struct _XENBUS_VIRQ {
@@ -2212,6 +2213,12 @@ FdoInterruptCallback(
     if (Interrupt->Callback == NULL)
         return FALSE;
 
+    if (Interrupt->Count++ == 0)
+        LogPrintf(LOG_LEVEL_INFO,
+                  "XENBUS: %u:%u INTERRUPT\n",
+                  Interrupt->ProcNumber.Group,
+                  Interrupt->ProcNumber.Number);
+
     return Interrupt->Callback(InterruptObject,
                                Interrupt->Argument);
 }
-- 
2.17.1



From win-pv-devel-bounces@lists.xenproject.org Mon Dec 07 16:00:43 2020
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 07 Dec 2020 16:00:43 +0000
Received: from list by lists.xenproject.org with outflank-mailman.46791.82945 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1kmIwK-0007up-HI; Mon, 07 Dec 2020 16:00:40 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 46791.82945; Mon, 07 Dec 2020 16:00:40 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1kmIwK-0007ui-EV; Mon, 07 Dec 2020 16:00:40 +0000
Received: by outflank-mailman (input) for mailman id 46791;
 Mon, 07 Dec 2020 15:54:47 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=Ob4x=FL=ainfosec.com=davisc@srs-us1.protection.inumbo.net>)
 id 1kmIqc-0006Yx-VP
 for win-pv-devel@lists.xenproject.org; Mon, 07 Dec 2020 15:54:47 +0000
Received: from USG02-BN3-obe.outbound.protection.office365.us (unknown
 [23.103.208.67]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 95ff2f90-965f-4b41-b5b9-9c39dcece81c;
 Mon, 07 Dec 2020 15:54:44 +0000 (UTC)
Received: from DM3P110MB0556.NAMP110.PROD.OUTLOOK.COM (2001:489a:200:414::15)
 by DM3P110MB0412.NAMP110.PROD.OUTLOOK.COM (2001:489a:200:412::13)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.21; Mon, 7 Dec
 2020 15:54:41 +0000
Received: from DM3P110MB0556.NAMP110.PROD.OUTLOOK.COM
 ([fe80::295a:f8cd:9c62:66db]) by DM3P110MB0556.NAMP110.PROD.OUTLOOK.COM
 ([fe80::295a:f8cd:9c62:66db%6]) with mapi id 15.20.3632.021; Mon, 7 Dec 2020
 15:54:41 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 95ff2f90-965f-4b41-b5b9-9c39dcece81c
ARC-Seal: i=1; a=rsa-sha256; s=arcselector5401; d=microsoft.com; cv=none;
 b=RF3BubvGkAE2Xj2B6WhqdpEL+A3sWcY7nMGK307B5gS1Qrm4qPY4xD94UMpC9u23SyhKEvX3FO1XX4rO54vnlukyV0UVPl3aDs0g3vZ3c51jWJzOXpNgFHaVAtQNKia+VcGnRoeDo2aIHmcd7xb+n01WEWuM5c+SCnJmXOuT6DOribmKesBFNXj+WOaPCDfLDpFWk25QtAUAeUy9Zrzn0TBOtpUNBFzk88zMOJEbwAlTtrKcpH5MpZ2d1m1aBfW3T7yAii4AOZelnauEVvPvGeyGZOjXgSK0JUU/rnwlfuj8fLErd1lXWFw1Tr+tudGC81+2urlNQvuUCKUe9rA7Ag==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;
 s=arcselector5401;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=R08ckE8gB/y9Weyb7GuHmfyTgmIpEjjNIERDXPOP1RA=;
 b=RiiHifdltKsNUHw/CJIoi5WSZ6pUHHJWXMrKPKl/tvEXWx+okBKPW0a6xh26izjZCqF+8OvdYYsh84cuIC7pa9Ra1X5P2oAjJzMUk6FvIv5D7AFsF8Yzu0UeBJdYu8EULlNvSdbhp+lmbjoPUpu7mUstWqskk/yjc5Bbs5b942pYKYN32+xLFwntxWo4LUIS+3UGN1dUm0sNsofqh7IIYpTxR9zSgYG4DwDK4n/o3JIoJk08RTO85CzPZO+Uh9ZrJmgta5zP2tcm5uaxsKEp7u6YYx2RTopnN7ly8Iff351dxYGR9bV/rh/HR9hpKbSmdbGRybo//VUBeRNekTiouA==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass
 smtp.mailfrom=ainfosec.com; dmarc=pass action=none header.from=ainfosec.com;
 dkim=pass header.d=ainfosec.com; arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=ainfosec.onmicrosoft.com; s=selector1-ainfosec-onmicrosoft-com;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=R08ckE8gB/y9Weyb7GuHmfyTgmIpEjjNIERDXPOP1RA=;
 b=PbNo/KohsWL4AzJnz7EMAKOVLkkpNU7iwk2xMeDAnW2K8mJM7GEMPB36Rp+ppljWtxIDnvH87hJ7pwIRdGJYb0eno5y4q1C6PSC3+PcLgblXe0VPkRIcgDlhiufyN+dbDULgNVKWOnM/3hq6bS/pMQr/Sfud6cYEdP8m5WqTebo=
From: Connor Davis <davisc@ainfosec.com>
To: "win-pv-devel@lists.xenproject.org" <win-pv-devel@lists.xenproject.org>
Subject: xennet HLK certification
Thread-Topic: xennet HLK certification
Thread-Index: AdbMrq1zX5bqO/2LS2OFoFjWCYSCeg==
Date: Mon, 7 Dec 2020 15:54:41 +0000
Message-ID:
 <DM3P110MB0556FF903C5BD2712C88E3A6A5CE0@DM3P110MB0556.NAMP110.PROD.OUTLOOK.COM>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
authentication-results: lists.xenproject.org; dkim=none (message not signed)
 header.d=none;lists.xenproject.org; dmarc=none action=none
 header.from=ainfosec.com;
x-originating-ip: [50.208.12.62]
x-ms-publictraffictype: Email
x-ms-office365-filtering-correlation-id: b1572cc6-9664-4a5e-651e-08d89ac868ff
x-ms-traffictypediagnostic: DM3P110MB0412:
x-microsoft-antispam-prvs:
 <DM3P110MB0412E308A99A760F93EBBFACA5CE0@DM3P110MB0412.NAMP110.PROD.OUTLOOK.COM>
x-ms-oob-tlc-oobclassifiers: OLM:8882;
x-ms-exchange-senderadcheck: 1
x-microsoft-antispam: BCL:0;
x-forefront-antispam-report:
 CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM3P110MB0556.NAMP110.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(4636009)(366004)(86362001)(186003)(8676002)(5660300002)(6506007)(71200400001)(64756008)(66446008)(498600001)(66476007)(4744005)(66946007)(83380400001)(55016002)(52536014)(8936002)(6916009)(3480700007)(2906002)(7696005)(7116003)(9686003)(26005)(45080400002)(66556008)(33656002)(76116006);DIR:OUT;SFP:1101;
x-ms-exchange-transport-forked: True
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-OriginatorOrg: ainfosec.com
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: DM3P110MB0556.NAMP110.PROD.OUTLOOK.COM
X-MS-Exchange-CrossTenant-Network-Message-Id: b1572cc6-9664-4a5e-651e-08d89ac868ff
X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Dec 2020 15:54:41.7630
 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 82614573-95ee-4948-be35-3c0a8fc6ff9c
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM3P110MB0412

Hi All,

My team has modified xen{bus,vif,iface,net} drivers that we have been testi=
ng with the 1909-compatible HLK, and
the only test that is failing is NDISTest 6.5 PM_Requirements. It is compla=
ining that xennet doesn't support
No-Pause-On-Suspend. After poking around the Microsoft docs, it seems No-Pa=
use-On-Suspend isn't available
until NDIS 6.3, and xennet uses NDIS 6.1.

Have you all seen this issue before? If so, is there a workaround for getti=
ng the test to pass? Or perhaps it's best to
bump xennet's NDIS version and implement No-Pause-On-Suspend?

Thanks,
Connor Davis


From win-pv-devel-bounces@lists.xenproject.org Mon Dec 07 16:08:23 2020
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 07 Dec 2020 16:08:23 +0000
Received: from list by lists.xenproject.org with outflank-mailman.46811.82965 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1kmJ3l-0008MI-Ha; Mon, 07 Dec 2020 16:08:21 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 46811.82965; Mon, 07 Dec 2020 16:08:21 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1kmJ3l-0008MB-Eh; Mon, 07 Dec 2020 16:08:21 +0000
Received: by outflank-mailman (input) for mailman id 46811;
 Mon, 07 Dec 2020 16:08:20 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=e0y+=FL=gmail.com=xadimgnik@srs-us1.protection.inumbo.net>)
 id 1kmJ3k-0008M6-9L
 for win-pv-devel@lists.xenproject.org; Mon, 07 Dec 2020 16:08:20 +0000
Received: from mail-wm1-x331.google.com (unknown [2a00:1450:4864:20::331])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id efa4ea11-6d96-4e6b-9894-9e8364c60433;
 Mon, 07 Dec 2020 16:08:19 +0000 (UTC)
Received: by mail-wm1-x331.google.com with SMTP id x22so11871890wmc.5
 for <win-pv-devel@lists.xenproject.org>; Mon, 07 Dec 2020 08:08:19 -0800 (PST)
Received: from CBGR90WXYV0 (host86-183-162-145.range86-183.btcentralplus.com.
 [86.183.162.145])
 by smtp.gmail.com with ESMTPSA id m2sm14424911wml.34.2020.12.07.08.08.15
 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128);
 Mon, 07 Dec 2020 08:08:16 -0800 (PST)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: efa4ea11-6d96-4e6b-9894-9e8364c60433
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=from:reply-to:to:references:in-reply-to:subject:date:message-id
         :mime-version:content-transfer-encoding:content-language
         :thread-index;
        bh=i1Kq1Jx/v+EyC5nRBfYhRh3/48c9naA5Ntm1666lLFU=;
        b=dFqEOM7L9hMWkOuFyRXPk0uT4ds7k3jjKWu5jaSNn9Sv7GAS+chqgz57LEvuUrQSyh
         xfCHKRBQaSVBN5vBSZ1aHKqxZqwe5jd3cp0fiePXSvC2ZWl09wHdPSoMZ0AHKVf8JX1u
         3gBzl/bbo9gN6SccsaDuzOw+GMgyiwo6XVDjMfhKWPWOw6KbGvQJmLIOEUafi6SBOBcR
         MfS+WrWGfDg6Bi+32OL+yvbAHaeSLFiVMl4mRGPwfUiChSfjyN5r5vtOxVwjiaXu2bjx
         LYB+7xsusxc69V2POojX4t0Twzfbv6kECuxZmZU9TW6dYdTBM000xhBWV2KNp+nxyQ29
         X3zg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:from:reply-to:to:references:in-reply-to:subject
         :date:message-id:mime-version:content-transfer-encoding
         :content-language:thread-index;
        bh=i1Kq1Jx/v+EyC5nRBfYhRh3/48c9naA5Ntm1666lLFU=;
        b=ilU3fxREyQM7BdC+p1ciCRDPEpyAJvIhX0Shx0r/pdmIIqIRtOySBoK1VfIHULejxz
         unFbBvo0LOPEzPQOm4/MqkUmYPrDjdnaunClW0KLB6xqEpCOAhsl4Xp2U2NQ7ZGgOAT/
         1fEBYwxT1kCkJvQgM0hkK4g4mQCsi8PkWS4glaeaAWYR31UmpM58Vo+mnYIhx7kgaFHu
         OBcLC2cID8Dx7dYJfNhRD8cxiNS5GN9yTkhaz5aEprKjU7U+9H8ewBj+uY7OJbSV5Mkr
         Olociu9HpyKDi7scgopWmuhh3DZfLZcBKYjMqxIvV4XldVZtHnc3BUnH4wmTAxMfVzq/
         hRrw==
X-Gm-Message-State: AOAM532O4mbN3i75rfO/I5SSqFYop0lFfgVCfvQBszZtEMQMEyx6+QeK
	ezDT57A5vNcCuoyrbvOjeLP27dyNFpwRFA==
X-Google-Smtp-Source: ABdhPJwFtDri/z/cjqqrAVrV7hwbH7dY1zASrItaBtBEN7gnP6aYA3IXYBQl/ipmAyt52VdZm/Yo4w==
X-Received: by 2002:a7b:cd91:: with SMTP id y17mr19278054wmj.5.1607357298748;
        Mon, 07 Dec 2020 08:08:18 -0800 (PST)
From: Paul Durrant <xadimgnik@gmail.com>
X-Google-Original-From: "Paul Durrant" <paul@xen.org>
Reply-To: <paul@xen.org>
To: "'Connor Davis'" <davisc@ainfosec.com>,
	<win-pv-devel@lists.xenproject.org>
References: <DM3P110MB0556FF903C5BD2712C88E3A6A5CE0@DM3P110MB0556.NAMP110.PROD.OUTLOOK.COM>
In-Reply-To: <DM3P110MB0556FF903C5BD2712C88E3A6A5CE0@DM3P110MB0556.NAMP110.PROD.OUTLOOK.COM>
Subject: RE: xennet HLK certification
Date: Mon, 7 Dec 2020 16:08:15 -0000
Message-ID: <0d2501d6ccb3$2bc80770$83581650$@xen.org>
MIME-Version: 1.0
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: 7bit
X-Mailer: Microsoft Outlook 16.0
Content-Language: en-gb
Thread-Index: AQGeyITbl+ECYyIRpaqhOONFxidaG6pb06iA

> -----Original Message-----
> From: win-pv-devel <win-pv-devel-bounces@lists.xenproject.org> On Behalf Of Connor Davis
> Sent: 07 December 2020 15:55
> To: win-pv-devel@lists.xenproject.org
> Subject: xennet HLK certification
> 
> Hi All,
> 
> My team has modified xen{bus,vif,iface,net} drivers that we have been testing with the 1909-compatible
> HLK, and
> the only test that is failing is NDISTest 6.5 PM_Requirements. It is complaining that xennet doesn't
> support
> No-Pause-On-Suspend. After poking around the Microsoft docs, it seems No-Pause-On-Suspend isn't
> available
> until NDIS 6.3, and xennet uses NDIS 6.1.
> 
> Have you all seen this issue before? If so, is there a workaround for getting the test to pass? Or
> perhaps it's best to
> bump xennet's NDIS version and implement No-Pause-On-Suspend?
> 

Hi Connor,

  Been a while since I've run HLK tests myself but IIRC there was a filter for the test failure, or you may need an exception. That
said, if you're happy to bump up the NDIS version and fix any compat issues then that would certainly be welcome. 6.4 has support
for receive segment coalescing so that would help legitimize something we've been doing for a long time :-)

  Cheers,

    Paul



From win-pv-devel-bounces@lists.xenproject.org Mon Dec 07 16:44:12 2020
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 07 Dec 2020 16:44:12 +0000
Received: from list by lists.xenproject.org with outflank-mailman.46836.83019 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1kmJcS-0004HI-Ad; Mon, 07 Dec 2020 16:44:12 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 46836.83019; Mon, 07 Dec 2020 16:44:12 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1kmJcS-0004HB-7n; Mon, 07 Dec 2020 16:44:12 +0000
Received: by outflank-mailman (input) for mailman id 46836;
 Mon, 07 Dec 2020 16:36:36 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=Ob4x=FL=ainfosec.com=davisc@srs-us1.protection.inumbo.net>)
 id 1kmJV6-0003CQ-Fi
 for win-pv-devel@lists.xenproject.org; Mon, 07 Dec 2020 16:36:36 +0000
Received: from USG02-CY1-obe.outbound.protection.office365.us (unknown
 [2001:489a:2202:d::62d])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 7c622178-bf4e-4c8c-a11e-8f60e89e497c;
 Mon, 07 Dec 2020 16:36:32 +0000 (UTC)
Received: from DM3P110MB0556.NAMP110.PROD.OUTLOOK.COM (2001:489a:200:414::15)
 by DM3P110MB0457.NAMP110.PROD.OUTLOOK.COM (2001:489a:200:412::22)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.21; Mon, 7 Dec
 2020 16:36:29 +0000
Received: from DM3P110MB0556.NAMP110.PROD.OUTLOOK.COM
 ([fe80::295a:f8cd:9c62:66db]) by DM3P110MB0556.NAMP110.PROD.OUTLOOK.COM
 ([fe80::295a:f8cd:9c62:66db%6]) with mapi id 15.20.3632.021; Mon, 7 Dec 2020
 16:36:29 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 7c622178-bf4e-4c8c-a11e-8f60e89e497c
ARC-Seal: i=1; a=rsa-sha256; s=arcselector5401; d=microsoft.com; cv=none;
 b=elH6SivJZGEPaOQC21OI4PijFkiu3GFr2g74oqu0Xc+/SM3ANALO5lbIui7rgvnH7KtX/GxId+9MWPlz7477DbJmOn/owZNH+4Fqr/nuVUIMzZ8Jei1ji0WNlZn4mJLcWx+F22Si/+7/9q5uY8XDRDo++SY1DAneHfUz/A70m/XKBY4Hz1EsuCPVOZuuj0/q5Bj2fxs4KBuBAY9UAqo8J5XAMV2s8vcJz7BXr5NxAj2cudpUNe6JmfB+utyfek/x68sHYaj4ElbJONG/i4hdsKv/dhCnRKNt7HVmdZOnCOoB1C8AZsB9hcpaIXNnHCcT9RvtyF5kRWszE8FolhTo0A==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;
 s=arcselector5401;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=H+5hVM65q9Ps3BrlJRGt5wRlojY9UdYX8doMiG7yPLI=;
 b=OgZrBcvs1Mr8useWWzH3X6+Xk4/xqWNRdfZQ3lU8pGyjVoa10uQvjbnWMpkaBkqkNzlFMUAhpJFCWDg8qH36N3p8QqxzXLl0WQX2KfTylmbYF+CBMrrg5MdPc4d14pWFhu6KruNC8FCiqbcJLwF6aEgzaOC71Etjv3kIOoFIXwTE7MI+6ZVUP5/qooaYAQkqrVOnu9xE0ETh4CBvbDuxOTHwlLOOzEoRaz/K1894tMZ8C1lri4iU4Vs5k5b+h7+CQ2uxofSYa4ndJg/2vnzt8MVXrlJdc/VtyR1tPkQvG7vtOpZ4Hw885k66idxiadadV6FN1WQNGeJ3ZyI53cSzLA==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass
 smtp.mailfrom=ainfosec.com; dmarc=pass action=none header.from=ainfosec.com;
 dkim=pass header.d=ainfosec.com; arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=ainfosec.onmicrosoft.com; s=selector1-ainfosec-onmicrosoft-com;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=H+5hVM65q9Ps3BrlJRGt5wRlojY9UdYX8doMiG7yPLI=;
 b=l6l3j7zu/AIKJSkoo0v0QBnBvDlzCnBA2yBIHgGLwsPNi0FfNJ+4ZRjJOPXBHlsV/s5NIxSTWAifFKZg7F2decY/T1uJ2tdHYPSS8Q6022YLB9RZOLftwsJC9zfx64Y0R2WJOi8tSMuYJezqUKR/d2fyUDz3KxfBva5dWDdwxcw=
From: Connor Davis <davisc@ainfosec.com>
To: "paul@xen.org" <paul@xen.org>, "win-pv-devel@lists.xenproject.org"
	<win-pv-devel@lists.xenproject.org>
Subject: RE: xennet HLK certification
Thread-Topic: xennet HLK certification
Thread-Index: AdbMrq1zX5bqO/2LS2OFoFjWCYSCegABH3CAAADsPkA=
Date: Mon, 7 Dec 2020 16:36:29 +0000
Message-ID:
 <DM3P110MB0556446B23B1737528A73315A5CE0@DM3P110MB0556.NAMP110.PROD.OUTLOOK.COM>
References:
 <DM3P110MB0556FF903C5BD2712C88E3A6A5CE0@DM3P110MB0556.NAMP110.PROD.OUTLOOK.COM>
 <0d2501d6ccb3$2bc80770$83581650$@xen.org>
In-Reply-To: <0d2501d6ccb3$2bc80770$83581650$@xen.org>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
authentication-results: xen.org; dkim=none (message not signed)
 header.d=none;xen.org; dmarc=none action=none header.from=ainfosec.com;
x-originating-ip: [50.208.12.62]
x-ms-publictraffictype: Email
x-ms-office365-filtering-correlation-id: 5a0b1c28-2f80-48f9-0154-08d89ace3fe6
x-ms-traffictypediagnostic: DM3P110MB0457:
x-microsoft-antispam-prvs:
 <DM3P110MB0457392A0F1CC42127A2E786A5CE0@DM3P110MB0457.NAMP110.PROD.OUTLOOK.COM>
x-ms-oob-tlc-oobclassifiers: OLM:8273;
x-ms-exchange-senderadcheck: 1
x-microsoft-antispam: BCL:0;
x-forefront-antispam-report:
 CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM3P110MB0556.NAMP110.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(4636009)(366004)(8936002)(8676002)(186003)(64756008)(83380400001)(2906002)(66476007)(45080400002)(66446008)(76116006)(52536014)(33656002)(53546011)(3480700007)(7696005)(66556008)(86362001)(9686003)(26005)(71200400001)(110136005)(5660300002)(6506007)(66946007)(55016002)(7116003)(498600001);DIR:OUT;SFP:1101;
x-ms-exchange-transport-forked: True
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-OriginatorOrg: ainfosec.com
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: DM3P110MB0556.NAMP110.PROD.OUTLOOK.COM
X-MS-Exchange-CrossTenant-Network-Message-Id: 5a0b1c28-2f80-48f9-0154-08d89ace3fe6
X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Dec 2020 16:36:29.7084
 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 82614573-95ee-4948-be35-3c0a8fc6ff9c
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM3P110MB0457



> -----Original Message-----
> From: Paul Durrant <xadimgnik@gmail.com>
> Sent: Monday, December 7, 2020 9:08 AM
> To: Connor Davis <davisc@ainfosec.com>; win-pv-devel@lists.xenproject.org
> Subject: RE: xennet HLK certification
>=20
> Notice: This message originated outside of ainfosec.com
>=20
>=20
>=20
> > -----Original Message-----
> > From: win-pv-devel <win-pv-devel-bounces@lists.xenproject.org> On Behal=
f Of Connor Davis
> > Sent: 07 December 2020 15:55
> > To: win-pv-devel@lists.xenproject.org
> > Subject: xennet HLK certification
> >
> > Hi All,
> >
> > My team has modified xen{bus,vif,iface,net} drivers that we have been t=
esting with the 1909-compatible
> > HLK, and
> > the only test that is failing is NDISTest 6.5 PM_Requirements. It is co=
mplaining that xennet doesn't
> > support
> > No-Pause-On-Suspend. After poking around the Microsoft docs, it seems N=
o-Pause-On-Suspend isn't
> > available
> > until NDIS 6.3, and xennet uses NDIS 6.1.
> >
> > Have you all seen this issue before? If so, is there a workaround for g=
etting the test to pass? Or
> > perhaps it's best to
> > bump xennet's NDIS version and implement No-Pause-On-Suspend?
> >
>=20
> Hi Connor,
>=20
>   Been a while since I've run HLK tests myself but IIRC there was a filte=
r for the test failure, or you may need an exception. That
> said, if you're happy to bump up the NDIS version and fix any compat issu=
es then that would certainly be welcome. 6.4 has
> support
> for receive segment coalescing so that would help legitimize something we=
've been doing for a long time :-)
>=20
>   Cheers,
>=20
>     Paul

I applied the latest filters, but it's still failing. In the short term we =
may go for the
exception, but I would expect next year we will work on bumping the version=
 up.
We may get to it this year, but the holidays create some doubt there.

Thanks,
Connor Davis


From win-pv-devel-bounces@lists.xenproject.org Mon Dec 07 17:35:26 2020
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 07 Dec 2020 17:35:26 +0000
Received: from list by lists.xenproject.org with outflank-mailman.46889.83071 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1kmKQ1-0001N6-4O; Mon, 07 Dec 2020 17:35:25 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 46889.83071; Mon, 07 Dec 2020 17:35:25 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1kmKQ1-0001My-1A; Mon, 07 Dec 2020 17:35:25 +0000
Received: by outflank-mailman (input) for mailman id 46889;
 Mon, 07 Dec 2020 17:35:24 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=e0y+=FL=gmail.com=xadimgnik@srs-us1.protection.inumbo.net>)
 id 1kmKQ0-0001Mt-A6
 for win-pv-devel@lists.xenproject.org; Mon, 07 Dec 2020 17:35:24 +0000
Received: from mail-wm1-x32d.google.com (unknown [2a00:1450:4864:20::32d])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 0d85d622-cdd8-462b-96e8-a06c37c4ce48;
 Mon, 07 Dec 2020 17:35:23 +0000 (UTC)
Received: by mail-wm1-x32d.google.com with SMTP id a3so14424362wmb.5
 for <win-pv-devel@lists.xenproject.org>; Mon, 07 Dec 2020 09:35:23 -0800 (PST)
Received: from CBGR90WXYV0 (host86-183-162-145.range86-183.btcentralplus.com.
 [86.183.162.145])
 by smtp.gmail.com with ESMTPSA id c9sm16144342wrp.73.2020.12.07.09.35.21
 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128);
 Mon, 07 Dec 2020 09:35:21 -0800 (PST)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 0d85d622-cdd8-462b-96e8-a06c37c4ce48
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=from:reply-to:to:references:in-reply-to:subject:date:message-id
         :mime-version:content-transfer-encoding:content-language
         :thread-index;
        bh=cwPADPfvjlO6zAbjiPZWBdhBJ5OIV98SXynrraB+Pc0=;
        b=Orv7w2twhmWtj55ay5RAlbO34PzkjxSYh/Z9p0KDj7s1kkEyu3lvkeceXmCNVHN3kH
         CSvE5FQRQTtt/mqB2cl5s91+QYwxDPT3PhQsu3ZRgE3VPpQVExdQBtT6aALu11loDSNX
         ZvRn+go4Er3yWr5Wm8QWm8udJTl5kJQWXPZAyM0aNLYzfRVs3zVWonoQJ8P7XeBO9Mmf
         7rHnCas+4cl/Ss69uyGb1yL3WARHCyyFIPxnAkNlrvB1nvcJQapeUjK8r6pge7zeL6kl
         YswuOQoYFkNiuaIY/N+IrrSDVkAGSaoX7nLWderH3KryGu4S6E4PeMRdp6H06mC+ddW2
         ANyg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:from:reply-to:to:references:in-reply-to:subject
         :date:message-id:mime-version:content-transfer-encoding
         :content-language:thread-index;
        bh=cwPADPfvjlO6zAbjiPZWBdhBJ5OIV98SXynrraB+Pc0=;
        b=OTIeF8Qn52UT3wQqmPOOx9p+NgP8ZXdqzs4AEWK2g9PBnOojB7MeTIPyrCmruTnaZX
         qZB3DNoM06CzyCk4pk2Pcwk6Y5Thkvs6Wk8EqEsIpNSag4330NoT4dKUB4364HCu9EPt
         wpwoq+ORyLPlZGxb7lmeN2iadP1fAGuoKmboFm62MB8exBx7DexzOIkaDQJCxhrrRUhW
         PSG0WE+51lyhVMh1RmFln9SATmuf50ilTkJj+BMMTRrhF7EjKICOXxs414nsxBZyixOu
         IwcBTPcezj0Mnq8rp7ds0qeeU5/Br4PkqxBFHOL2+DN52AYOF2upsJD66Y+ViKItFXHw
         SQ8w==
X-Gm-Message-State: AOAM532xFUCo4x57ZbwKBA5vJYA5eAfP+OIqBgf3U5nKBHv4uWklC+b8
	776OC8AGaagWVOcqlej6slYMVln2+bVTmw==
X-Google-Smtp-Source: ABdhPJyawnUbMmoBVySRJZYpUOHt+E3+qoB/tvfjljpuyb5wAuW5rmjFVWwSGfg1gTuZDLOlmcCQ9A==
X-Received: by 2002:a05:600c:313:: with SMTP id q19mr19410580wmd.126.1607362522496;
        Mon, 07 Dec 2020 09:35:22 -0800 (PST)
From: Paul Durrant <xadimgnik@gmail.com>
X-Google-Original-From: "Paul Durrant" <paul@xen.org>
Reply-To: <paul@xen.org>
To: "'Connor Davis'" <davisc@ainfosec.com>,
	<win-pv-devel@lists.xenproject.org>
References: <DM3P110MB0556FF903C5BD2712C88E3A6A5CE0@DM3P110MB0556.NAMP110.PROD.OUTLOOK.COM> <0d2501d6ccb3$2bc80770$83581650$@xen.org> <DM3P110MB0556446B23B1737528A73315A5CE0@DM3P110MB0556.NAMP110.PROD.OUTLOOK.COM>
In-Reply-To: <DM3P110MB0556446B23B1737528A73315A5CE0@DM3P110MB0556.NAMP110.PROD.OUTLOOK.COM>
Subject: RE: xennet HLK certification
Date: Mon, 7 Dec 2020 17:35:21 -0000
Message-ID: <0d2d01d6ccbf$56aee290$040ca7b0$@xen.org>
MIME-Version: 1.0
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: 7bit
X-Mailer: Microsoft Outlook 16.0
Content-Language: en-gb
Thread-Index: AQGeyITbl+ECYyIRpaqhOONFxidaGwJUqaYrAgMhjsCqOS6sIA==

> -----Original Message-----
> From: Connor Davis <davisc@ainfosec.com>
> Sent: 07 December 2020 16:36
> To: paul@xen.org; win-pv-devel@lists.xenproject.org
> Subject: RE: xennet HLK certification
> 
> 
> 
> > -----Original Message-----
> > From: Paul Durrant <xadimgnik@gmail.com>
> > Sent: Monday, December 7, 2020 9:08 AM
> > To: Connor Davis <davisc@ainfosec.com>; win-pv-devel@lists.xenproject.org
> > Subject: RE: xennet HLK certification
> >
> > Notice: This message originated outside of ainfosec.com
> >
> >
> >
> > > -----Original Message-----
> > > From: win-pv-devel <win-pv-devel-bounces@lists.xenproject.org> On Behalf Of Connor Davis
> > > Sent: 07 December 2020 15:55
> > > To: win-pv-devel@lists.xenproject.org
> > > Subject: xennet HLK certification
> > >
> > > Hi All,
> > >
> > > My team has modified xen{bus,vif,iface,net} drivers that we have been testing with the 1909-
> compatible
> > > HLK, and
> > > the only test that is failing is NDISTest 6.5 PM_Requirements. It is complaining that xennet
> doesn't
> > > support
> > > No-Pause-On-Suspend. After poking around the Microsoft docs, it seems No-Pause-On-Suspend isn't
> > > available
> > > until NDIS 6.3, and xennet uses NDIS 6.1.
> > >
> > > Have you all seen this issue before? If so, is there a workaround for getting the test to pass? Or
> > > perhaps it's best to
> > > bump xennet's NDIS version and implement No-Pause-On-Suspend?
> > >
> >
> > Hi Connor,
> >
> >   Been a while since I've run HLK tests myself but IIRC there was a filter for the test failure, or
> you may need an exception. That
> > said, if you're happy to bump up the NDIS version and fix any compat issues then that would
> certainly be welcome. 6.4 has
> > support
> > for receive segment coalescing so that would help legitimize something we've been doing for a long
> time :-)
> >
> >   Cheers,
> >
> >     Paul
> 
> I applied the latest filters, but it's still failing. In the short term we may go for the
> exception, but I would expect next year we will work on bumping the version up.
> We may get to it this year, but the holidays create some doubt there.

Great... I look forward to patches :-)

Cheers,

  Paul

> 
> Thanks,
> Connor Davis



From win-pv-devel-bounces@lists.xenproject.org Wed Dec 09 13:29:14 2020
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 09 Dec 2020 13:29:14 +0000
Received: from list by lists.xenproject.org with outflank-mailman.48256.85326 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1kmzWr-0000lC-3E; Wed, 09 Dec 2020 13:29:13 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 48256.85326; Wed, 09 Dec 2020 13:29:13 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1kmzWq-0000l1-Vy; Wed, 09 Dec 2020 13:29:12 +0000
Received: by outflank-mailman (input) for mailman id 48256;
 Wed, 09 Dec 2020 13:29:12 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=WCbu=FN=citrix.com=owen.smith@srs-us1.protection.inumbo.net>)
 id 1kmzWq-0000iH-0t
 for win-pv-devel@lists.xenproject.org; Wed, 09 Dec 2020 13:29:12 +0000
Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 3db95ff8-318b-405b-be35-f2ba5ffd1aba;
 Wed, 09 Dec 2020 13:29:07 +0000 (UTC)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 3db95ff8-318b-405b-be35-f2ba5ffd1aba
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple;
  d=citrix.com; s=securemail; t=1607520547;
  h=from:to:cc:subject:date:message-id:mime-version:
   content-transfer-encoding;
  bh=bQYUs8rLOWyYHzhEpLdcoXy0eXbF2wLTvq/JSpEOgIo=;
  b=HMGOfA581lZOk3XwCEFdy39Ifz4UX0Bj2zYe2PXX/L3/2DnyLKp5GssR
   sHo5zN78Eb0HWhLLPfSvnwrLsoX8Oct+4iWvc0Y1UFGdGujOaHdsBGqAb
   jCQ7/1B5RF846JnvTxej1bvWgRNGEj62l4rUN6An0GvyfKD7zIyoGX0Z5
   4=;
Authentication-Results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
IronPort-SDR: pd4gNcqosgDE2Zo/Nd6a+W+lciIY3r7L530IQ7e36rzNlPKpE/IUynKd5HKggl7QOfmLpIYBQU
 Oe/X7stfmTFnlB1Ly/TliCfow+YNX7807fmrKbCs3a/Ox9S2Ch192aIoIBM0ErEC7e0M3pgiWA
 y57DGm+KJt7los9rAeAd+CJ96cXRpWOdJ3dgl9rSPgZeYlSfSKPIHRHu+vhd5B5W53CyjYMdm9
 3wBLOKi05SgpEEJ2w98LZVAyMCIMYDx1Ae8IHfpCJbbAuw8rmhupkb6y3BSQKctKuBl0D9XD0X
 Za0=
X-SBRS: 5.2
X-MesageID: 32825880
X-Ironport-Server: esa3.hc3370-68.iphmx.com
X-Remote-IP: 162.221.158.21
X-Policy: $RELAYED
IronPort-HdrOrdr: A9a23:EuEX2Kij6k87lyZrcO+bZMs6OHBQX/t13DAbvn1ZSRFFG/Gwve
 rGppUm/DXzjyscX2xlpMuJP7OOTWiZ2Zl+54QQOrnKZniAhEKDKoZ+4Yz+hwDxAiGWzJ8l6Y
 5Me7VzYeeAbmRSot395GCDfOoI5Pmi3OSWifzFz3FrJDsaD51IywtiEA6UHglXaWB9dPgEPa
 GR7MZGuDasEE5/Bq/QaxU4dtPOusHRk9beaQMGbiRXjjWmty+i67LxDnGjvis2bjUn+9kf2F
 mAtwT446m52svLryPh/mrY2ZRaibLd49FIbfbstuEeLDLwhgG0IJl7U7qZszwv5O2p4lAmkN
 7Dyi1QWPhb4XXXY22zvF/xyxDtuQxekkPKxFeEjRLY0K/EbT0gDc4pv+1kWx/U8VApst050K
 8j5RP6i7NSDRfN2Dvw/MLJURYCrDvRnVM4neQej2NSXOIlAdc7x+FywGpPHIodByW/8Yg7EY
 BVfafhzexLelCXZW2xhAlS6cGrN05cIj6WBkwLusmYyFFt7RVE83c=
X-IronPort-AV: E=Sophos;i="5.78,405,1599537600"; 
   d="scan'208";a="32825880"
From: Owen Smith <owen.smith@citrix.com>
To: <win-pv-devel@lists.xenproject.org>
CC: Owen Smith <owen.smith@citrix.com>
Subject: [PATCH 1/2] Refactor monitor.c
Date: Wed, 9 Dec 2020 13:28:46 +0000
Message-ID: <20201209132847.203615-1-owen.smith@citrix.com>
X-Mailer: git-send-email 2.27.0
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain

- Split reboot question from statement
- Move GetDisplayName to seperate function call

Signed-off-by: Owen Smith <owen.smith@citrix.com>
---
 src/monitor/monitor.c | 155 ++++++++++++++++++++++++++++++------------
 src/xenbus.inf        |   4 +-
 2 files changed, 114 insertions(+), 45 deletions(-)

diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index 3cf33ce..07bf8c1 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -59,6 +59,7 @@ typedef struct _MONITOR_CONTEXT {
     HKEY                    RequestKey;
     PTCHAR                  Title;
     PTCHAR                  Text;
+    PTCHAR                  Question;
     BOOL                    RebootPending;
 } MONITOR_CONTEXT, *PMONITOR_CONTEXT;
 
@@ -348,36 +349,20 @@ GetPromptTimeout(
     return Value;
 }
 
-static VOID
-PromptForReboot(
+static PTCHAR
+GetDisplayName(
     IN PTCHAR           DriverName
     )
 {
-    PMONITOR_CONTEXT    Context = &MonitorContext;
-    PTCHAR              Title;
-    DWORD               TitleLength;
     HRESULT             Result;
     TCHAR               ServiceKeyName[MAX_PATH];
     HKEY                ServiceKey;
     DWORD               MaxValueLength;
+    DWORD               Type;
     DWORD               DisplayNameLength;
     PTCHAR              DisplayName;
-    DWORD               Type;
-    PTCHAR              Description;
-    PTCHAR              Text;
-    DWORD               TextLength;
-    PWTS_SESSION_INFO   SessionInfo;
-    DWORD               Count;
-    DWORD               Index;
-    BOOL                Success;
     HRESULT             Error;
 
-    Log("====> (%s)", DriverName);
-
-    Title = Context->Title;
-    TitleLength = (DWORD)((_tcslen(Context->Title) +
-                           1) * sizeof (TCHAR));
-
     Result = StringCbPrintf(ServiceKeyName,
                             MAX_PATH,
                             SERVICES_KEY "\\%s",
@@ -433,6 +418,68 @@ PromptForReboot(
         goto fail5;
     }
 
+    RegCloseKey(ServiceKey);
+
+    return DisplayName;
+
+fail5:
+    Log("fail5");
+
+fail4:
+    Log("fail4");
+
+    free(DisplayName);
+
+fail3:
+    Log("fail3");
+
+fail2:
+    Log("fail2");
+
+    RegCloseKey(ServiceKey);
+
+fail1:
+    Error = GetLastError();
+
+    {
+        PTCHAR  Message;
+        Message = GetErrorMessage(Error);
+        Log("fail1 (%s)", Message);
+        LocalFree(Message);
+    }
+
+    return NULL;
+}
+
+static VOID
+PromptForReboot(
+    IN PTCHAR           DriverName
+    )
+{
+    PMONITOR_CONTEXT    Context = &MonitorContext;
+    HRESULT             Result;
+    PTCHAR              Title;
+    DWORD               TitleLength;
+    PTCHAR              DisplayName;
+    PTCHAR              Description;
+    PTCHAR              Text;
+    DWORD               TextLength;
+    PWTS_SESSION_INFO   SessionInfo;
+    DWORD               Count;
+    DWORD               Index;
+    BOOL                Success;
+    HRESULT             Error;
+
+    Log("====> (%s)", DriverName);
+
+    Title = Context->Title;
+    TitleLength = (DWORD)((_tcslen(Context->Title) +
+                           1) * sizeof (TCHAR));
+
+    DisplayName = GetDisplayName(DriverName);
+    if (DisplayName == NULL)
+        goto fail1;
+
     Description = _tcsrchr(DisplayName, ';');
     if (Description == NULL)
         Description = DisplayName;
@@ -442,17 +489,20 @@ PromptForReboot(
     TextLength = (DWORD)((_tcslen(Description) +
                           1 + // ' '
                           _tcslen(Context->Text) +
+                          1 + // ' '
+                          _tcslen(Context->Question) +
                           1) * sizeof (TCHAR));
 
     Text = calloc(1, TextLength);
     if (Text == NULL)
-        goto fail6;
+        goto fail2;
 
     Result = StringCbPrintf(Text,
                             TextLength,
-                            TEXT("%s %s"),
+                            TEXT("%s %s %s"),
                             Description,
-                            Context->Text);
+                            Context->Text,
+                            Context->Question);
     assert(SUCCEEDED(Result));
 
     Success = WTSEnumerateSessions(WTS_CURRENT_SERVER_HANDLE,
@@ -461,7 +511,7 @@ PromptForReboot(
                                    &SessionInfo,
                                    &Count);
     if (!Success)
-        goto fail7;
+        goto fail3;
 
     for (Index = 0; Index < Count; Index++) {
         DWORD                   SessionId = SessionInfo[Index].SessionId;
@@ -492,7 +542,7 @@ PromptForReboot(
                                  TRUE);
 
         if (!Success)
-            goto fail8;
+            goto fail4;
 
         Context->RebootPending = TRUE;
 
@@ -506,30 +556,14 @@ PromptForReboot(
 
     free(DisplayName);
 
-    RegCloseKey(ServiceKey);
-
     Log("<====");
 
     return;
 
-fail8:
-    Log("fail8");
-
-    WTSFreeMemory(SessionInfo);
-
-fail7:
-    Log("fail7");
-
-fail6:
-    Log("fail6");
-
-fail5:
-    Log("fail5");
-
 fail4:
     Log("fail4");
 
-    free(DisplayName);
+    WTSFreeMemory(SessionInfo);
 
 fail3:
     Log("fail3");
@@ -537,7 +571,7 @@ fail3:
 fail2:
     Log("fail2");
 
-    RegCloseKey(ServiceKey);
+    free(DisplayName);
 
 fail1:
     Error = GetLastError();
@@ -862,6 +896,7 @@ GetDialogParameters(
     DWORD               MaxValueLength;
     DWORD               TitleLength;
     DWORD               TextLength;
+    DWORD               QuestionLength;
     DWORD               Type;
     HRESULT             Error;
 
@@ -926,8 +961,41 @@ GetDialogParameters(
         goto fail7;
     }
 
+    QuestionLength = MaxValueLength + sizeof (TCHAR);
+
+    Context->Question = calloc(1, QuestionLength);
+    if (Context == NULL)
+        goto fail8;
+
+    Error = RegQueryValueEx(Context->ParametersKey,
+                            "DialogQuestion",
+                            NULL,
+                            &Type,
+                            (LPBYTE)Context->Question,
+                            &QuestionLength);
+    if (Error != ERROR_SUCCESS) {
+        SetLastError(Error);
+        goto fail9;
+    }
+
+    if (Type != REG_SZ) {
+        SetLastError(ERROR_BAD_FORMAT);
+        goto fail10;
+    }
+
     return TRUE;
 
+fail10:
+    Log("fail10");
+
+fail9:
+    Log("fail9");
+
+    free(Context->Question);
+
+fail8:
+    Log("fail8");
+
 fail7:
     Log("fail7");
 
@@ -963,8 +1031,6 @@ fail1:
     return FALSE;
 }
 
-
-
 VOID WINAPI
 MonitorMain(
     _In_    DWORD       argc,
@@ -1080,6 +1146,7 @@ MonitorMain(
 done:
     (VOID) RegDeleteTree(Context->RequestKey, NULL);
 
+    free(Context->Question);
     free(Context->Text);
     free(Context->Title);
     CloseHandle(Context->RequestKey);
diff --git a/src/xenbus.inf b/src/xenbus.inf
index bf3f0a1..f9a5475 100644
--- a/src/xenbus.inf
+++ b/src/xenbus.inf
@@ -134,6 +134,7 @@ HKR,"Parameters",,0x00000010
 HKR,"Parameters","RequestKey",0x00000000,%RequestKey%
 HKR,"Parameters","DialogTitle",0x00000000,%DialogTitle%
 HKR,"Parameters","DialogText",0x00000000,%DialogText%
+HKR,"Parameters","DialogQuestion",0x00000000,%DialogQuestion%
 
 [Monitor_EventLog]
 AddReg=Monitor_EventLog_AddReg
@@ -159,7 +160,8 @@ MonitorName="@PRODUCT_NAME@ PV Driver Monitor"
 MonitorDesc="Provides support for @PRODUCT_NAME@ PV drivers"
 RequestKey="SYSTEM\CurrentControlSet\Services\xenbus_monitor\Request"
 DialogTitle="@PRODUCT_NAME@"
-DialogText="needs to restart the system to complete installation. Press 'Yes' to restart the system now or 'No' if you plan to restart the system later."
+DialogText="needs to restart the system to complete installation."
+DialogQuestion="Press 'Yes' to restart the system now or 'No' if you plan to restart the system later."
 
 SERVICE_BOOT_START=0x0 
 SERVICE_SYSTEM_START=0x1 
-- 
2.28.0.windows.1



From win-pv-devel-bounces@lists.xenproject.org Wed Dec 09 13:29:18 2020
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 09 Dec 2020 13:29:18 +0000
Received: from list by lists.xenproject.org with outflank-mailman.48257.85329 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1kmzWw-0000nH-4N; Wed, 09 Dec 2020 13:29:18 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 48257.85329; Wed, 09 Dec 2020 13:29:18 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1kmzWw-0000nA-1M; Wed, 09 Dec 2020 13:29:18 +0000
Received: by outflank-mailman (input) for mailman id 48257;
 Wed, 09 Dec 2020 13:29:17 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=WCbu=FN=citrix.com=owen.smith@srs-us1.protection.inumbo.net>)
 id 1kmzWv-0000iH-0s
 for win-pv-devel@lists.xenproject.org; Wed, 09 Dec 2020 13:29:17 +0000
Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id b24505aa-5485-4462-aa9b-7aac3eb29f64;
 Wed, 09 Dec 2020 13:29:11 +0000 (UTC)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: b24505aa-5485-4462-aa9b-7aac3eb29f64
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple;
  d=citrix.com; s=securemail; t=1607520550;
  h=from:to:cc:subject:date:message-id:in-reply-to:
   references:mime-version:content-transfer-encoding;
  bh=+4j4OxWjWy5bR7SCIM3QJ4Jj2h9wdRPXYUkURPjYDVM=;
  b=TOcxwISM0EVcQEWq9rmjSyufZ9SOfai3RVcdV7xyOhHXmmJLDSx0zkE4
   a3jTceRKdAd5+OATNBLTZvmljhHL/Ge6Y06xG/q8aUQc7P+EGtMlsrJ9P
   1VOaNQGg0c47+NkYYDo4l2Dx71uJazf/maZQu6VxCEUunIHYIYra3ZYxU
   M=;
Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
IronPort-SDR: ldwI4YF/0LygZoX63hxdjeSCloEfPSYjcVe0SBuSOj5pb49ugQHSH1td3Md1NxxkCHEVbULwU1
 gjpl4VXH0ynqr9FiKaJVwG/46AHOiwmB6RrR4n2bIOrxh6eUK8F2qiJ4Ixhod5zihFpi7hxyCb
 IhGZOUH420srx6tr2j77TUzEsl+3MFgT0DoAYhbcCuAiCEbaY0hWjsNpZIdHwNrqXSHMFnWWog
 8VAMJN0BpbBa7RhGVE+SnLfgZlI0gl75KHgGBj+cVSfeIYkXrYfu+6fweav6+zhZ7Ls0qC5w3t
 QGw=
X-SBRS: 5.2
X-MesageID: 33190892
X-Ironport-Server: esa1.hc3370-68.iphmx.com
X-Remote-IP: 162.221.158.21
X-Policy: $RELAYED
IronPort-HdrOrdr: A9a23:Aix1DawfVwScKqZ0iWfaKrPxw+skLtp033Aq2lEZdDV+WKWj+f
 yGtvIdyBPylXItQ3kmg9+NI+2tRnnb+J5z7+AqTNGfdSPhv3alK5wn0Jv6z1TbalXD38NUyK
 sISchDIfLqC1wSt6rHySm+V+0t2dyWtJ2v7N2uqktFaSFPR+Ve4xxiCgCde3cGIzVuIZYiDp
 KT6o5milObCBcqR/+2DHUEQOTPzuej/PmNDCIuPBIp5BKDijml8tfBYnyl9ywTTi9VxvMa+X
 XF+jaJn5mLie2xyRPXygbojqh+pd2J8LR+Lf3JrsAULzn24zzYBrhccriJijA5sYiTwVwh+e
 Ojnz4rOcNv53TNOnyvqRz21AX6lDoo4XnuyViX6EGTx/DRTjQ8FsZHmMZFYgLUgnBQxO1U3a
 pX0wui16Z/AgjHmE3Gi+TgVxYvjUaspGpnjOh7tQ07baIbZKVKpYISuENZea1wfx7S7IAiHK
 1wANrH5PBQGGnqCEzxpWVkzNyyUnlbJH7vKSJuhuWP3zdbh3x/xUcDrfZv+kso754hV4JCo/
 3NL6UArsA2cuYNcal/CO0dKPHXNkXRR3v3X166MBDiHKEDN2mlke+U3IkI
X-IronPort-AV: E=Sophos;i="5.78,405,1599537600"; 
   d="scan'208";a="33190892"
From: Owen Smith <owen.smith@citrix.com>
To: <win-pv-devel@lists.xenproject.org>
CC: Owen Smith <owen.smith@citrix.com>
Subject: [PATCH 2/2] Add AutoReboot capability
Date: Wed, 9 Dec 2020 13:28:47 +0000
Message-ID: <20201209132847.203615-2-owen.smith@citrix.com>
X-Mailer: git-send-email 2.27.0
In-Reply-To: <20201209132847.203615-1-owen.smith@citrix.com>
References: <20201209132847.203615-1-owen.smith@citrix.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain

Setting HKLM\System\CCS\Services\xenbus_monitor\AutoReboot to non-zero
will allow xenbus_monitor to trigger a reboot when another driver
requests a reboot. AutoReboot is set to the maximum number of reboots
to perform. Auto reboots display a message with a 60 second timeout.

This setting can be used to allow headless/unmonitored VMs to complete
the neccessary number of reboots to return to PV disks/networks. Without
this capability its possible to update the driver on a parent device,
which may prompt for a reboot. After this reboot, its likely that
emulated devices are used whilst drivers are rebound to the device
nodes. This can leave headless/unmonitored VMs in a state where emulated
devices are in use with a pending reboot. If network settings have been
changed for PV devices (e.g. static IP addressing), then the VM may not
be accessible over RDP or similar connections.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
---
 src/monitor/monitor.c | 133 ++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 129 insertions(+), 4 deletions(-)

diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index 07bf8c1..5d58be4 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -301,7 +301,8 @@ WTSStateName(
 
 static VOID
 DoReboot(
-    VOID
+    IN PTCHAR   Message,
+    IN DWORD    Timeout
     )
 {
     Log("waiting for pending install events...");
@@ -312,8 +313,8 @@ DoReboot(
 
 #pragma prefast(suppress:28159)
     (VOID) InitiateSystemShutdownEx(NULL,
-                                    NULL,
-                                    0,
+                                    Message,
+                                    Timeout,
                                     TRUE,
                                     TRUE,
                                     SHTDN_REASON_MAJOR_OPERATINGSYSTEM |
@@ -451,6 +452,125 @@ fail1:
     return NULL;
 }
 
+static BOOL
+TryAutoReboot(
+    IN PTCHAR           DriverName
+    )
+{
+    PMONITOR_CONTEXT    Context = &MonitorContext;
+    HRESULT             Result;
+    DWORD               Type;
+    DWORD               AutoReboot;
+    DWORD               RebootCount;
+    DWORD               Length;
+    PTCHAR              DisplayName;
+    PTCHAR              Description;
+    PTCHAR              Text;
+    DWORD               TextLength;
+    HRESULT             Error;
+
+    Length = sizeof (DWORD);
+
+    Error = RegQueryValueEx(Context->ParametersKey,
+                            "AutoReboot",
+                            NULL,
+                            &Type,
+                            (LPBYTE)&AutoReboot,
+                            &Length);
+    if (Error != ERROR_SUCCESS ||
+        Type != REG_DWORD)
+        AutoReboot = 0;
+
+    if (AutoReboot == 0)
+        goto done;
+
+    Length = sizeof (DWORD);
+
+    Error = RegQueryValueEx(Context->ParametersKey,
+                            "RebootCount",
+                            NULL,
+                            &Type,
+                            (LPBYTE)&RebootCount,
+                            &Length);
+    if (Error != ERROR_SUCCESS ||
+        Type != REG_DWORD)
+        RebootCount = 0;
+
+    if (RebootCount >= AutoReboot)
+        goto done;
+
+    Log("AutoRebooting (reboot %u of %u)\n",
+        RebootCount,
+        AutoReboot);
+
+    ++RebootCount;
+
+    (VOID) RegSetValueEx(Context->ParametersKey,
+                         "RebootCount",
+                         0,
+                         REG_DWORD,
+                         (const BYTE*)&RebootCount,
+                         (DWORD) sizeof(DWORD));
+
+    (VOID) RegFlushKey(Context->ParametersKey);
+
+    Context->RebootPending = TRUE;
+
+    DisplayName = GetDisplayName(DriverName);
+    if (DisplayName == NULL)
+        goto fail1;
+
+    Description = _tcsrchr(DisplayName, ';');
+    if (Description == NULL)
+        Description = DisplayName;
+    else
+        Description++;
+
+    TextLength = (DWORD)((_tcslen(Description) +
+                          1 + // ' '
+                          _tcslen(Context->Text) +
+                          1) * sizeof (TCHAR));
+
+    Text = calloc(1, TextLength);
+    if (Text == NULL)
+        goto fail2;
+
+    Result = StringCbPrintf(Text,
+                            TextLength,
+                            TEXT("%s %s"),
+                            Description,
+                            Context->Text);
+    assert(SUCCEEDED(Result));
+
+    free(DisplayName);
+
+    DoReboot(Text, 60);
+
+    free(Text);
+
+    return TRUE;
+
+done:
+    return FALSE;
+
+fail2:
+    Log("fail2");
+
+    free(DisplayName);
+
+fail1:
+    Error = GetLastError();
+
+    {
+        PTCHAR  Message;
+        Message = GetErrorMessage(Error);
+        Log("fail1 (%s)", Message);
+        LocalFree(Message);
+    }
+
+    return FALSE;
+}
+
 static VOID
 PromptForReboot(
     IN PTCHAR           DriverName
@@ -476,6 +596,10 @@ PromptForReboot(
     TitleLength = (DWORD)((_tcslen(Context->Title) +
                            1) * sizeof (TCHAR));
 
+    // AutoReboot is set, DoReboot has been called
+    if (TryAutoReboot(DriverName))
+        goto done;
+
     DisplayName = GetDisplayName(DriverName);
     if (DisplayName == NULL)
         goto fail1;
@@ -547,7 +671,7 @@ PromptForReboot(
         Context->RebootPending = TRUE;
 
         if (Response == IDYES || Response == IDTIMEOUT)
-            DoReboot();
+            DoReboot(NULL, 0);
 
         break;
     }
@@ -556,6 +680,7 @@ PromptForReboot(
 
     free(DisplayName);
 
+done:
     Log("<====");
 
     return;
-- 
2.28.0.windows.1



From win-pv-devel-bounces@lists.xenproject.org Thu Dec 10 09:12:56 2020
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 10 Dec 2020 09:12:56 +0000
Received: from list by lists.xenproject.org with outflank-mailman.49017.86726 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1knI0L-0002iZ-TZ; Thu, 10 Dec 2020 09:12:53 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 49017.86726; Thu, 10 Dec 2020 09:12:53 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1knI0L-0002iS-Qg; Thu, 10 Dec 2020 09:12:53 +0000
Received: by outflank-mailman (input) for mailman id 49017;
 Thu, 10 Dec 2020 09:12:51 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=e+LE=FO=gmail.com=xadimgnik@srs-us1.protection.inumbo.net>)
 id 1knI0J-0002iN-SW
 for win-pv-devel@lists.xenproject.org; Thu, 10 Dec 2020 09:12:51 +0000
Received: from mail-wr1-x432.google.com (unknown [2a00:1450:4864:20::432])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 73ddd696-5f67-48b5-bf64-97d68d2d57d2;
 Thu, 10 Dec 2020 09:12:51 +0000 (UTC)
Received: by mail-wr1-x432.google.com with SMTP id t4so4629304wrr.12
 for <win-pv-devel@lists.xenproject.org>; Thu, 10 Dec 2020 01:12:51 -0800 (PST)
Received: from CBGR90WXYV0 (host86-183-162-145.range86-183.btcentralplus.com.
 [86.183.162.145])
 by smtp.gmail.com with ESMTPSA id b83sm7824551wmd.48.2020.12.10.01.12.49
 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128);
 Thu, 10 Dec 2020 01:12:49 -0800 (PST)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 73ddd696-5f67-48b5-bf64-97d68d2d57d2
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=from:reply-to:to:references:in-reply-to:subject:date:message-id
         :mime-version:content-transfer-encoding:content-language
         :thread-index;
        bh=VRuaj5Sik+4r5f24qI1TkVGpfmJwaONhx66imEqUt/k=;
        b=RX72fdsYpFamNAISKSFfnai3TWrx0Y6CqCT+VSNlBKxDE+MWFvLIKLiur/inBvIehU
         KaL0OLBywbqF7IKIztqILgWTQ6VGsPE63cSQM7WU+y2K3CdObDj66sjfHL0xgB55SAVG
         IbNwHmDXVzTr/w7lzLrzouqoeebv8jkwFrUNsRKaJ10m3rzY0nsNVJ4C8y0QZ15vVM6t
         7QxUJ8daSxiKmVrf9QfX9kZtLohktuIvIfaoxRM68exXhkUEzgww0JIc5LzZQ1Kj8ICv
         amiMk/thXspn76X9JSyWtA+El9eujVx2CCV4nhhxZM1lhi9qyIe5UflCaSb3Jp7DYZ2O
         32ag==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:from:reply-to:to:references:in-reply-to:subject
         :date:message-id:mime-version:content-transfer-encoding
         :content-language:thread-index;
        bh=VRuaj5Sik+4r5f24qI1TkVGpfmJwaONhx66imEqUt/k=;
        b=S7zdEiCBhrHVddqqI0sTg4iwBLQaUoBmZpMZ5FxtZpxRNz7ryFARVmkEz9GcWxwXG1
         y73ygzjpAeU+cjCAo/f7rxVLVmsM//XIzg2HinfCjnm2bR9sBuKWtk5iHhQU5T93IzoC
         qWh7vcRrMHu3ChFMPf8X7sUstM1FZ2wyMKIA8bKaXxRtyyJfndJ9EWq6rHC+2q9lOke4
         bidN9ijP/JmxchhEYabXwien7EmGupah6sJ4cm07WMg4umcLJgjUQFSE6PT7Y/0MeFf0
         sKJIEaeknuFy+1zb48nVx6NHqunc5cYfMaCwyO2z73jhv4ncEMq8LLE7kx+mVu2HMYFd
         2o+w==
X-Gm-Message-State: AOAM532I/iRPl9yNKnr6TOSmkXsVOZEKBRrsg7Iku93b4wa+72lf7qvU
	6+Ie0S72V94Xcr1insJOlZM=
X-Google-Smtp-Source: ABdhPJwfyxfvo1yFP6JRLKepKlBMYIXNP5TYgKTXBqq4C8gplReo/aqmJidYWDrKoaOqtivE6CkKvg==
X-Received: by 2002:a5d:4b4c:: with SMTP id w12mr7000808wrs.402.1607591570341;
        Thu, 10 Dec 2020 01:12:50 -0800 (PST)
From: Paul Durrant <xadimgnik@gmail.com>
X-Google-Original-From: "Paul Durrant" <paul@xen.org>
Reply-To: <paul@xen.org>
To: "'Owen Smith'" <owen.smith@citrix.com>,
	<win-pv-devel@lists.xenproject.org>
References: <20201209132847.203615-1-owen.smith@citrix.com>
In-Reply-To: <20201209132847.203615-1-owen.smith@citrix.com>
Subject: RE: [EXTERNAL] [PATCH 1/2] Refactor monitor.c
Date: Thu, 10 Dec 2020 09:12:48 -0000
Message-ID: <002501d6ced4$a1c41860$e54c4920$@xen.org>
MIME-Version: 1.0
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: 7bit
X-Mailer: Microsoft Outlook 16.0
Content-Language: en-gb
Thread-Index: AQIDzDwIAZrgV3ZQvP4ZBK6zSOGEkamWEJ8Q

> -----Original Message-----
> From: win-pv-devel <win-pv-devel-bounces@lists.xenproject.org> On Behalf Of Owen Smith
> Sent: 09 December 2020 13:29
> To: win-pv-devel@lists.xenproject.org
> Cc: Owen Smith <owen.smith@citrix.com>
> Subject: [EXTERNAL] [PATCH 1/2] Refactor monitor.c
> 
> - Split reboot question from statement
> - Move GetDisplayName to seperate function call
> 
> Signed-off-by: Owen Smith <owen.smith@citrix.com>

Acked-by: Paul Durrant <paul@xen.org>



From win-pv-devel-bounces@lists.xenproject.org Thu Dec 10 09:16:37 2020
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 10 Dec 2020 09:16:37 +0000
Received: from list by lists.xenproject.org with outflank-mailman.49024.86729 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1knI3x-0002ox-7L; Thu, 10 Dec 2020 09:16:37 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 49024.86729; Thu, 10 Dec 2020 09:16:37 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1knI3x-0002oq-4T; Thu, 10 Dec 2020 09:16:37 +0000
Received: by outflank-mailman (input) for mailman id 49024;
 Thu, 10 Dec 2020 09:16:36 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=e+LE=FO=gmail.com=xadimgnik@srs-us1.protection.inumbo.net>)
 id 1knI3w-0002ol-RX
 for win-pv-devel@lists.xenproject.org; Thu, 10 Dec 2020 09:16:36 +0000
Received: from mail-wr1-x432.google.com (unknown [2a00:1450:4864:20::432])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 03449289-db6c-430e-a73d-9d1b5bf48ea8;
 Thu, 10 Dec 2020 09:16:35 +0000 (UTC)
Received: by mail-wr1-x432.google.com with SMTP id r14so4662826wrn.0
 for <win-pv-devel@lists.xenproject.org>; Thu, 10 Dec 2020 01:16:35 -0800 (PST)
Received: from CBGR90WXYV0 (host86-183-162-145.range86-183.btcentralplus.com.
 [86.183.162.145])
 by smtp.gmail.com with ESMTPSA id d8sm7950795wrp.44.2020.12.10.01.16.34
 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128);
 Thu, 10 Dec 2020 01:16:34 -0800 (PST)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 03449289-db6c-430e-a73d-9d1b5bf48ea8
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=from:reply-to:to:references:in-reply-to:subject:date:message-id
         :mime-version:content-transfer-encoding:content-language
         :thread-index;
        bh=gn5tg9udYHadav6OlRt2xNuJb/W3IR5/GE7PGEMVsEU=;
        b=A1NvY+haNOr2Mhxg558JvEiEPQxGoFWVt3l3sIZEu9r67eyeei7NahUBEqYkAYWrRI
         UsbL6GgWIF/SkMac9ixxe+WA6DhnFKLarfzAB6cERzHCEj8xGi3Hrhqekl3LNGnjUH9h
         YGB8QJpuAiUHrRtZffUCSaRia4MKJPxRjZxNTdPpDmBBWn4Ez1Vv3yaX6693Anr73JSH
         EdhLCH8kUt0ESFCVIWndJ2ebzT3tc7Czc5vJGpVCP7py+mgV8VK/eF0umdIbVGqo0HI2
         WK0ut7zZ2KjqAivvvXl25o+KMSBBruZCR7Y9wP5QhdNDYV5z0O1yaoKcVz6ICyVRnqMi
         ocgQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:from:reply-to:to:references:in-reply-to:subject
         :date:message-id:mime-version:content-transfer-encoding
         :content-language:thread-index;
        bh=gn5tg9udYHadav6OlRt2xNuJb/W3IR5/GE7PGEMVsEU=;
        b=QhKElObZwqTLArCkjxReqLEkf/8FCWLQmk0ssreyJzLOJPbiVwulQAuLMDHDEcs4xP
         2QOpp9B5F7qJomrMSG4F6vawwWV2O8VU9K4xwJEqueoH+1jcy7AwAemH0wcmDCfE+rGE
         loozAmkWeqvjCi3tBbNU5nUPng9SdKUGIC/2XqLV1+7VRCJIaq9CEMIZ4R6V04P53rqJ
         MI/neXVWvJSe6x5X+GTfwdwtSf2pwdnTNUQDHM4mXVF0qVM49GWw6B3pdQQrBNgk7/QE
         AdNsPwc0E1/w7h0SOV9R+VjlxuL+CWPmJIGgysVi6KsBmPgqZP1ntcKCA9TGZlNwkkRz
         K/2Q==
X-Gm-Message-State: AOAM531TUDT7U1p+zUOf1waM+BET/4JIHQ1DoAXbY0DHK1cNRYuTWfUi
	qHZm7E36Wifx5ZrC3rtqVOUv3h2a20Q=
X-Google-Smtp-Source: ABdhPJzToBRSvQtrfsH3FW6mfbvpPcRxBPmw6dcRQ+yul3M+5TFZYZ8DqTpKNlCNS6wdznyqBNMXvQ==
X-Received: by 2002:a5d:51c4:: with SMTP id n4mr6967321wrv.67.1607591795037;
        Thu, 10 Dec 2020 01:16:35 -0800 (PST)
From: Paul Durrant <xadimgnik@gmail.com>
X-Google-Original-From: "Paul Durrant" <paul@xen.org>
Reply-To: <paul@xen.org>
To: "'Owen Smith'" <owen.smith@citrix.com>,
	<win-pv-devel@lists.xenproject.org>
References: <20201209132847.203615-1-owen.smith@citrix.com> <20201209132847.203615-2-owen.smith@citrix.com>
In-Reply-To: <20201209132847.203615-2-owen.smith@citrix.com>
Subject: RE: [EXTERNAL] [PATCH 2/2] Add AutoReboot capability
Date: Thu, 10 Dec 2020 09:16:33 -0000
Message-ID: <002601d6ced5$27d03240$777096c0$@xen.org>
MIME-Version: 1.0
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: 7bit
X-Mailer: Microsoft Outlook 16.0
Content-Language: en-gb
Thread-Index: AQIDzDwIAZrgV3ZQvP4ZBK6zSOGEkQLRjK2WqX+Ea1A=

> -----Original Message-----
> From: win-pv-devel <win-pv-devel-bounces@lists.xenproject.org> On Behalf Of Owen Smith
> Sent: 09 December 2020 13:29
> To: win-pv-devel@lists.xenproject.org
> Cc: Owen Smith <owen.smith@citrix.com>
> Subject: [EXTERNAL] [PATCH 2/2] Add AutoReboot capability
> 
> Setting HKLM\System\CCS\Services\xenbus_monitor\AutoReboot to non-zero
> will allow xenbus_monitor to trigger a reboot when another driver
> requests a reboot. AutoReboot is set to the maximum number of reboots
> to perform. Auto reboots display a message with a 60 second timeout.
> 
> This setting can be used to allow headless/unmonitored VMs to complete
> the neccessary number of reboots to return to PV disks/networks. Without
> this capability its possible to update the driver on a parent device,
> which may prompt for a reboot. After this reboot, its likely that
> emulated devices are used whilst drivers are rebound to the device
> nodes. This can leave headless/unmonitored VMs in a state where emulated
> devices are in use with a pending reboot. If network settings have been
> changed for PV devices (e.g. static IP addressing), then the VM may not
> be accessible over RDP or similar connections.
> 
> Signed-off-by: Owen Smith <owen.smith@citrix.com>
> ---
>  src/monitor/monitor.c | 133 ++++++++++++++++++++++++++++++++++++++++--
>  1 file changed, 129 insertions(+), 4 deletions(-)
> 
> diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
> index 07bf8c1..5d58be4 100644
> --- a/src/monitor/monitor.c
> +++ b/src/monitor/monitor.c
> @@ -301,7 +301,8 @@ WTSStateName(
> 
>  static VOID
>  DoReboot(
> -    VOID
> +    IN PTCHAR   Message,
> +    IN DWORD    Timeout
>      )
>  {
>      Log("waiting for pending install events...");
> @@ -312,8 +313,8 @@ DoReboot(
> 
>  #pragma prefast(suppress:28159)
>      (VOID) InitiateSystemShutdownEx(NULL,
> -                                    NULL,
> -                                    0,
> +                                    Message,
> +                                    Timeout,
>                                      TRUE,
>                                      TRUE,
>                                      SHTDN_REASON_MAJOR_OPERATINGSYSTEM |
> @@ -451,6 +452,125 @@ fail1:
>      return NULL;
>  }
> 
> +static BOOL
> +TryAutoReboot(
> +    IN PTCHAR           DriverName
> +    )
> +{
> +    PMONITOR_CONTEXT    Context = &MonitorContext;
> +    HRESULT             Result;
> +    DWORD               Type;
> +    DWORD               AutoReboot;
> +    DWORD               RebootCount;
> +    DWORD               Length;
> +    PTCHAR              DisplayName;
> +    PTCHAR              Description;
> +    PTCHAR              Text;
> +    DWORD               TextLength;
> +    HRESULT             Error;
> +
> +    Length = sizeof (DWORD);
> +
> +    Error = RegQueryValueEx(Context->ParametersKey,
> +                            "AutoReboot",
> +                            NULL,
> +                            &Type,
> +                            (LPBYTE)&AutoReboot,
> +                            &Length);
> +    if (Error != ERROR_SUCCESS ||
> +        Type != REG_DWORD)
> +        AutoReboot = 0;
> +
> +    if (AutoReboot == 0)
> +        goto done;
> +
> +    Length = sizeof (DWORD);
> +
> +    Error = RegQueryValueEx(Context->ParametersKey,
> +                            "RebootCount",
> +                            NULL,
> +                            &Type,
> +                            (LPBYTE)&RebootCount,
> +                            &Length);
> +    if (Error != ERROR_SUCCESS ||
> +        Type != REG_DWORD)
> +        RebootCount = 0;
> +
> +    if (RebootCount >= AutoReboot)
> +        goto done;
> +
> +    Log("AutoRebooting (reboot %u of %u)\n",
> +        RebootCount,
> +        AutoReboot);
> +
> +    ++RebootCount;
> +
> +    (VOID) RegSetValueEx(Context->ParametersKey,
> +                         "RebootCount",
> +                         0,
> +                         REG_DWORD,
> +                         (const BYTE*)&RebootCount,
> +                         (DWORD) sizeof(DWORD));
> +

I can't see anything that zeroes/deletes this once there are no more pending reboots. Is there something else that does this, or am
I just missing something?

  Paul



From win-pv-devel-bounces@lists.xenproject.org Tue Dec 15 12:28:02 2020
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 15 Dec 2020 12:28:02 +0000
Received: from list by lists.xenproject.org with outflank-mailman.53266.92939 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1kp9Qv-000803-49; Tue, 15 Dec 2020 12:28:01 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 53266.92939; Tue, 15 Dec 2020 12:28:01 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1kp9Qv-0007zw-19; Tue, 15 Dec 2020 12:28:01 +0000
Received: by outflank-mailman (input) for mailman id 53266;
 Tue, 15 Dec 2020 12:27:59 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=24j/=FT=citrix.com=owen.smith@srs-us1.protection.inumbo.net>)
 id 1kp9Qt-0007zf-OT
 for win-pv-devel@lists.xenproject.org; Tue, 15 Dec 2020 12:27:59 +0000
Received: from esa6.hc3370-68.iphmx.com (unknown [216.71.155.175])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id a5dd801d-4e2b-4f55-bc45-72794df4e035;
 Tue, 15 Dec 2020 12:27:54 +0000 (UTC)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: a5dd801d-4e2b-4f55-bc45-72794df4e035
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple;
  d=citrix.com; s=securemail; t=1608035274;
  h=from:to:subject:date:message-id:references:in-reply-to:
   content-transfer-encoding:mime-version;
  bh=24jR0BtsurEPQQJ5vWoroePg+o+B9VR5onDuXK/ULPk=;
  b=KvbjiU3sVjikXGr0X/7ZsFDCDMoiFz6AFJiWzEDoxbZwAPigi/GLQfbP
   p3eGrfVqA8g5FOXcpGFuiq8G18wSmbyzbmXN8ORXWs7vktM04wTOpp8yY
   TCup/5KQy/iP0NVL/m3cAS8UPtc7SJUyPm6R3jiPN88OipQtahkEVlPAe
   c=;
Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
IronPort-SDR: rj8F0NIQYiXU0Wv99bDTvKjgqUAxcVpqvuHXO263td2UWdfCD9JOvFHT9Y31CSVEoi5h9Ed8EG
 gzytfSHkz0DF1PpdF2zjlH5EgZUmsp2NsAC+deuRr7qKCnM9vQZgxJVTxb1UOMf2DhsBVAO5+T
 Ekz+1M9yVW22IuAiHzeRrcqtfco7U40NE0s4O9B5pWJyfM682WiBFpRnozYqWxK3ibLhZW/7U6
 uNtuZWSCEcuUBTX9H3C6jBeAPzmFOsDyeET0hRHaCez/wZlLxhMEfe4e7t3SIn98NJ21OTsvjU
 A7w=
X-SBRS: 5.2
X-MesageID: 33476905
X-Ironport-Server: esa6.hc3370-68.iphmx.com
X-Remote-IP: 162.221.158.21
X-Policy: $RELAYED
X-IronPort-AV: E=Sophos;i="5.78,421,1599537600"; 
   d="scan'208";a="33476905"
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
 b=FnZlrvuz4nO2BUhC7BoZu0Jr5cA92E7jvZQdUySu53po3XCrkWX84U3IdF6A3xmK63EXnbigtDYYHv1wqpfpl5BF6sCem4qfFCeQ/TE34gPdRapjniiF5WZeTNXO/WxQeW6GBMFPysku57ElxU33bmPM15hb/wESHjeVnNjIta3dZBOsypKFuThPMk3I/J4PMLK3PPKN83nKlR9hevy1yiadn68UEFHNnxr59oxVnVcPj8gkix/HFL6VcP8gIUG967GKP1s3Eb7bMi2lq9QjVbATTzQYGqRQGYgYYKUzj8tOMcI8izlh2odlsqReyM06UwCPIdG+8Z9NEOdTrkwWPg==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;
 s=arcselector9901;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=WZi3lUzLpDY/bR3iim86PyOJi7QMTC4+XLns8I45qx4=;
 b=K0AnxKYu3GcFaRYwX54BSU++a1dc8n7pvOHm8q7n8adJDpNVm2OvDvHyeXJ7dgynSVryuatdyu1+Px+sAbLhXH4J73YzmClukZ0LqMg1RCfsPuY9k6CJHcXjTgUs2JX1Gn0dRCqwJsMwBpMLyENqTxe7pqe3NbIQL1UXRCeOu2Pk7WXgZhXyzzK3+AW7ChKqAJlCSI4ddiRwXTU3R1Tvdo8Vik6rEiChk+uyEXCX1PW7AxX/xQLhrudgpK6mpnz0bgKujL283q79tteRKrDhAMjEb4gUc4WAym/NgTf1lR0JMY5R1sXge738C0+OEid7TGd49wQ9iWxr40A/dElvxA==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass
 smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com;
 dkim=pass header.d=citrix.com; arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=citrix.onmicrosoft.com; s=selector2-citrix-onmicrosoft-com;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=WZi3lUzLpDY/bR3iim86PyOJi7QMTC4+XLns8I45qx4=;
 b=P5vlfGOwcCmRmNvJF6W8qJU+YPh5J8TDr1F8iPBkyINUZRhvrWPb06/WCTIOdEy0T6J+GCmzXM4xyvqFH8b8alXRoTg54zK1va8T8QLiJKXXZ7MINqR2y1uV84lh3iPltaOOZEwi8wwNpTBzq1m2z+Ggm98yGtpNny+V5f+5YCs=
From: Owen Smith <owen.smith@citrix.com>
To: "paul@xen.org" <paul@xen.org>, "win-pv-devel@lists.xenproject.org"
	<win-pv-devel@lists.xenproject.org>
Subject: RE: [EXTERNAL] [PATCH 2/2] Add AutoReboot capability
Thread-Topic: [EXTERNAL] [PATCH 2/2] Add AutoReboot capability
Thread-Index: AQHWzi9L5KGEbcyAdUuRKTe9dtkh+KnwDe+AgAgQ52A=
Date: Tue, 15 Dec 2020 12:27:49 +0000
Message-ID: <BYAPR03MB4551B1E3ED8B0ED886BF3FC3FEC60@BYAPR03MB4551.namprd03.prod.outlook.com>
References: <20201209132847.203615-1-owen.smith@citrix.com>
 <20201209132847.203615-2-owen.smith@citrix.com>
 <002601d6ced5$27d03240$777096c0$@xen.org>
In-Reply-To: <002601d6ced5$27d03240$777096c0$@xen.org>
Accept-Language: en-GB, en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
x-ms-publictraffictype: Email
x-ms-office365-filtering-correlation-id: 4531be95-daa2-4099-4502-08d8a0f4d64b
x-ms-traffictypediagnostic: BY5PR03MB5046:
x-microsoft-antispam-prvs: <BY5PR03MB5046633B51DB567782E8F2E6FEC60@BY5PR03MB5046.namprd03.prod.outlook.com>
x-ms-oob-tlc-oobclassifiers: OLM:7219;
x-ms-exchange-senderadcheck: 1
x-microsoft-antispam: BCL:0;
x-microsoft-antispam-message-info: Bpc7Ns9v2zwjOZ8bWz52w+KlRblWx5UcEba2H3gw+Th9y68M9+iNg2k9TydH+UMDH9Tq11fbOn4TeMeIBoyRI4/lsedAvb8X9SMScvvR0RDX5eKnKXpshplep4v5uqMipNsKBqpV6wMVk0p5cw5n8r2POfpwqBSyMcW+7sGggSj0E6GSYYkC+63YctVHb45uZG0ExH445MNQm7CHm5KQ1dfSdBWorBaieeoApg9Tn8l4lpvdqPMl0hkiulR5iKlKFx3iH5qp61yhVR15F3NVoGj38DPCRZ2kdob869cQ9rhuarMHKTQAHPI89yaTg5dcu1cbt19a+sZ9t+w2ffP/5A==
x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR03MB4551.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(376002)(136003)(366004)(346002)(86362001)(66476007)(508600001)(83380400001)(64756008)(7696005)(55016002)(33656002)(66556008)(66446008)(8676002)(6506007)(76116006)(66574015)(8936002)(53546011)(110136005)(52536014)(44832011)(66946007)(186003)(5660300002)(71200400001)(9686003)(2906002)(26005);DIR:OUT;SFP:1101;
x-ms-exchange-antispam-messagedata: =?us-ascii?Q?ge7lptJFzvzpQEBQlMFNoGRIF2he0IfUGUMUFTmNwupxn85JeC32v/NdDU97?=
 =?us-ascii?Q?atKXlGaObsi1Yk9yXFAbqmbDdz3Mepgt64+eewQY4KqALxuy1fjnBLB4b1bJ?=
 =?us-ascii?Q?ataergcWUmOOSP9C7G8zehmQ3qlpmunK3cOlHMAOAZcxs75vQdTsb+h27j/E?=
 =?us-ascii?Q?Gyz/aawkfOYkB153MPfbwBCfeWN7hBrNLu3eHKZQYWDtspEWBZ5Z2q9S4LQs?=
 =?us-ascii?Q?6xrMqH5f95i1bF3vtn3rq1ak4wmlpR9mW7MOCiBECYxGq5wpBnIAfoZ3948B?=
 =?us-ascii?Q?jL8F+bY2HCjngXJ4rriMhwiQE8xwGOZpC6QqwOwRGNXxrm+KvDaSrIbs9CUG?=
 =?us-ascii?Q?b0ytnL1lxlklYaUCfRYeFfYBXeLDucBSXOk8Yspy9qCkHQNueRbP2M5RUVcD?=
 =?us-ascii?Q?ZKlAqjbPG2gjkYCGNND5qYIJ49sX922gnZAWXWrRBUmm+S5MqAtmZijaX/vs?=
 =?us-ascii?Q?R2MpmTCWatoxLb0KJQN14akROW+HOr9Qybs1CIAgjzAfgu26g2ljWt5/LdB3?=
 =?us-ascii?Q?yAYJOCDZtzaJb2f0hvEtXFbvQp6/42utyLvk6MoYFKREtwn4tJas0oBIkPdm?=
 =?us-ascii?Q?eTMozgPgKeKsPxu19jw/+MAMNU7S6dxlCHVcInDsbJm2Fxt7S5tq4OtSQK3R?=
 =?us-ascii?Q?BwDHYfdY3dzHUkQfntMxZe4/FZTCgJ/MrcEv6unp4SZvKymKA4xs3RObv18s?=
 =?us-ascii?Q?5uO31Welb+ct98Cs8/BA8FyWNEt7pCw68VQdNeALdtr6QI9dKMMqNE3oFb3Q?=
 =?us-ascii?Q?qaY8pfzG66kXePf7Z3viD3ppHGMJUpmTd3kFdA80xKzDtATAwF7D2KoxiOrR?=
 =?us-ascii?Q?nTQJWblAc5JSGUZwJafhgfBCYTl/SW9QgKHmasNlu0pUuqOsqYdczmE2yYbn?=
 =?us-ascii?Q?KCJD/jpXBkmUhDtV/pu8Tnlj1daXmG7q0n79wXRI+W7CAen7CMGHFfDaVBJD?=
 =?us-ascii?Q?LCGk0ONAHUU96deLX7Rd+Fb6r8tU306RT/SwDMqHZgQ=3D?=
x-ms-exchange-transport-forked: True
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: BYAPR03MB4551.namprd03.prod.outlook.com
X-MS-Exchange-CrossTenant-Network-Message-Id: 4531be95-daa2-4099-4502-08d8a0f4d64b
X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Dec 2020 12:27:49.8777
 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 335836de-42ef-43a2-b145-348c2ee9ca5b
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-CrossTenant-userprincipalname: hVOjzQXR7QfwbL4vIMKCP59dgMhb3hX32vvAviPmdaDk97ZEvl5r+Stcjwc9Dh47MsKOpa3RALEmyPnLM8isZQ==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR03MB5046
X-OriginatorOrg: citrix.com



> -----Original Message-----
> From: Paul Durrant <xadimgnik@gmail.com>
> Sent: 10 December 2020 09:17
> To: Owen Smith <owen.smith@citrix.com>; win-pv-devel@lists.xenproject.org
> Subject: RE: [EXTERNAL] [PATCH 2/2] Add AutoReboot capability
>=20
> [CAUTION - EXTERNAL EMAIL] DO NOT reply, click links, or open attachments
> unless you have verified the sender and know the content is safe.
>=20
> > -----Original Message-----
> > From: win-pv-devel <win-pv-devel-bounces@lists.xenproject.org> On
> > Behalf Of Owen Smith
> > Sent: 09 December 2020 13:29
> > To: win-pv-devel@lists.xenproject.org
> > Cc: Owen Smith <owen.smith@citrix.com>
> > Subject: [EXTERNAL] [PATCH 2/2] Add AutoReboot capability
> >
> > Setting HKLM\System\CCS\Services\xenbus_monitor\AutoReboot to non-zero
> > will allow xenbus_monitor to trigger a reboot when another driver
> > requests a reboot. AutoReboot is set to the maximum number of reboots
> > to perform. Auto reboots display a message with a 60 second timeout.
> >
> > This setting can be used to allow headless/unmonitored VMs to complete
> > the neccessary number of reboots to return to PV disks/networks.
> > Without this capability its possible to update the driver on a parent
> > device, which may prompt for a reboot. After this reboot, its likely
> > that emulated devices are used whilst drivers are rebound to the
> > device nodes. This can leave headless/unmonitored VMs in a state where
> > emulated devices are in use with a pending reboot. If network settings
> > have been changed for PV devices (e.g. static IP addressing), then the
> > VM may not be accessible over RDP or similar connections.
> >
> > Signed-off-by: Owen Smith <owen.smith@citrix.com>
> > ---
> >  src/monitor/monitor.c | 133
> > ++++++++++++++++++++++++++++++++++++++++--
> >  1 file changed, 129 insertions(+), 4 deletions(-)
> >
> > diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c index
> > 07bf8c1..5d58be4 100644
> > --- a/src/monitor/monitor.c
> > +++ b/src/monitor/monitor.c
> > @@ -301,7 +301,8 @@ WTSStateName(
> >
> >  static VOID
> >  DoReboot(
> > -    VOID
> > +    IN PTCHAR   Message,
> > +    IN DWORD    Timeout
> >      )
> >  {
> >      Log("waiting for pending install events..."); @@ -312,8 +313,8 @@
> > DoReboot(
> >
> >  #pragma prefast(suppress:28159)
> >      (VOID) InitiateSystemShutdownEx(NULL,
> > -                                    NULL,
> > -                                    0,
> > +                                    Message,
> > +                                    Timeout,
> >                                      TRUE,
> >                                      TRUE,
> >
> > SHTDN_REASON_MAJOR_OPERATINGSYSTEM | @@ -451,6 +452,125 @@
> fail1:
> >      return NULL;
> >  }
> >
> > +static BOOL
> > +TryAutoReboot(
> > +    IN PTCHAR           DriverName
> > +    )
> > +{
> > +    PMONITOR_CONTEXT    Context =3D &MonitorContext;
> > +    HRESULT             Result;
> > +    DWORD               Type;
> > +    DWORD               AutoReboot;
> > +    DWORD               RebootCount;
> > +    DWORD               Length;
> > +    PTCHAR              DisplayName;
> > +    PTCHAR              Description;
> > +    PTCHAR              Text;
> > +    DWORD               TextLength;
> > +    HRESULT             Error;
> > +
> > +    Length =3D sizeof (DWORD);
> > +
> > +    Error =3D RegQueryValueEx(Context->ParametersKey,
> > +                            "AutoReboot",
> > +                            NULL,
> > +                            &Type,
> > +                            (LPBYTE)&AutoReboot,
> > +                            &Length);
> > +    if (Error !=3D ERROR_SUCCESS ||
> > +        Type !=3D REG_DWORD)
> > +        AutoReboot =3D 0;
> > +
> > +    if (AutoReboot =3D=3D 0)
> > +        goto done;
> > +
> > +    Length =3D sizeof (DWORD);
> > +
> > +    Error =3D RegQueryValueEx(Context->ParametersKey,
> > +                            "RebootCount",
> > +                            NULL,
> > +                            &Type,
> > +                            (LPBYTE)&RebootCount,
> > +                            &Length);
> > +    if (Error !=3D ERROR_SUCCESS ||
> > +        Type !=3D REG_DWORD)
> > +        RebootCount =3D 0;
> > +
> > +    if (RebootCount >=3D AutoReboot)
> > +        goto done;
> > +
> > +    Log("AutoRebooting (reboot %u of %u)\n",
> > +        RebootCount,
> > +        AutoReboot);
> > +
> > +    ++RebootCount;
> > +
> > +    (VOID) RegSetValueEx(Context->ParametersKey,
> > +                         "RebootCount",
> > +                         0,
> > +                         REG_DWORD,
> > +                         (const BYTE*)&RebootCount,
> > +                         (DWORD) sizeof(DWORD));
> > +
>=20
> I can't see anything that zeroes/deletes this once there are no more pend=
ing
> reboots. Is there something else that does this, or am I just missing som=
ething?
>=20
>   Paul
>=20

It seems I missed clearing the value. Patch incoming shortly

Owen



From win-pv-devel-bounces@lists.xenproject.org Tue Dec 15 12:58:51 2020
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 15 Dec 2020 12:58:51 +0000
Received: from list by lists.xenproject.org with outflank-mailman.53950.93535 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1kp9uj-0001NE-Cn; Tue, 15 Dec 2020 12:58:49 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 53950.93535; Tue, 15 Dec 2020 12:58:49 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1kp9uj-0001N7-9w; Tue, 15 Dec 2020 12:58:49 +0000
Received: by outflank-mailman (input) for mailman id 53950;
 Tue, 15 Dec 2020 12:58:47 +0000
Received: from all-amaz-eas1.inumbo.com ([34.197.232.57]
 helo=us1-amaz-eas2.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=24j/=FT=citrix.com=owen.smith@srs-us1.protection.inumbo.net>)
 id 1kp9Yq-0000nw-Jl
 for win-pv-devel@lists.xenproject.org; Tue, 15 Dec 2020 12:36:12 +0000
Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id bca4eaf2-77f4-4f09-a291-c5346df2b435;
 Tue, 15 Dec 2020 12:33:32 +0000 (UTC)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: bca4eaf2-77f4-4f09-a291-c5346df2b435
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple;
  d=citrix.com; s=securemail; t=1608035612;
  h=from:to:cc:subject:date:message-id:mime-version:
   content-transfer-encoding;
  bh=utG/V+/m4d6EbqWwHbYXUhtTz1cYm6SkWqLTRSe1cdI=;
  b=A35pfoGJLlMcC1WxARvvtCMiuSe1CaNkSU9oU8rqg5QmcMlFYprh869B
   rEqxXrYbyH2BHDbGOn7tXOIplOYfaEPGmzZMGnehTPqxjHOGAZaFlUiCd
   cj4Nym0JRbUnGigVq8nUjdahLyryNNMv6QlfcY/R49ANcQbvquGh8YljO
   Y=;
Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
IronPort-SDR: 7H3Y1hLBJ0qRdt/m67vCAUtIqP3FojZ/jE47FX9bjz3vXq+ppDYTuYkPHm86gKWSRQ0cdhqS/u
 ssMrJ90zWp98BO9DtOmF13MJQmkxYccd1+84C7vWM4h3AnIPxrgbJnrkLD4EtXS0LZVcyz7wzs
 hFnOtRMKdsC5/bJ588lXij7nesU1LcF5VKzNcyog/6z5hVBMork8KgGo/dhKZEUiqgOyZnJ2lp
 FEm6L/Z6vydFcA+IQgVxUWYBDqt0UUzSbiMdLEgwAMdBYsYSpFiIhjFWGyf6zBE851ACQ5v+ae
 d28=
X-SBRS: 5.2
X-MesageID: 33588752
X-Ironport-Server: esa1.hc3370-68.iphmx.com
X-Remote-IP: 162.221.158.21
X-Policy: $RELAYED
X-IronPort-AV: E=Sophos;i="5.78,421,1599537600"; 
   d="scan'208";a="33588752"
From: Owen Smith <owen.smith@citrix.com>
To: <win-pv-devel@lists.xenproject.org>
CC: Owen Smith <owen.smith@citrix.com>
Subject: [PATCH] Reset "RebootCount" when no reboot requested.
Date: Tue, 15 Dec 2020 12:33:06 +0000
Message-ID: <20201215123306.2324069-1-owen.smith@citrix.com>
X-Mailer: git-send-email 2.27.0
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain

Signed-off-by: Owen Smith <owen.smith@citrix.com>
---
 src/monitor/monitor.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index 5d58be4..7d8689f 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -797,6 +797,11 @@ loop:
         RegCloseKey(SubKey);
     }
 
+    Error = RegDeleteValue(Context->ParametersKey,
+                           "RebootCount");
+    if (Error == ERROR_SUCCESS)
+        (VOID) RegFlushKey(Context->ParametersKey);
+
     goto done;
 
 found:
-- 
2.28.0.windows.1



From win-pv-devel-bounces@lists.xenproject.org Tue Dec 15 13:21:24 2020
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 15 Dec 2020 13:21:24 +0000
Received: from list by lists.xenproject.org with outflank-mailman.54074.93610 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1kpAGZ-0004wl-AO; Tue, 15 Dec 2020 13:21:23 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 54074.93610; Tue, 15 Dec 2020 13:21:23 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1kpAGZ-0004we-7d; Tue, 15 Dec 2020 13:21:23 +0000
Received: by outflank-mailman (input) for mailman id 54074;
 Tue, 15 Dec 2020 13:21:21 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=xZ6N=FT=gmail.com=xadimgnik@srs-us1.protection.inumbo.net>)
 id 1kpAGX-0004wX-Lh
 for win-pv-devel@lists.xenproject.org; Tue, 15 Dec 2020 13:21:21 +0000
Received: from mail-wm1-x335.google.com (unknown [2a00:1450:4864:20::335])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 677743ea-deb7-4e7c-9b70-595d6a953482;
 Tue, 15 Dec 2020 13:21:20 +0000 (UTC)
Received: by mail-wm1-x335.google.com with SMTP id 190so6627304wmz.0
 for <win-pv-devel@lists.xenproject.org>; Tue, 15 Dec 2020 05:21:20 -0800 (PST)
Received: from CBGR90WXYV0
 (host109-146-187-221.range109-146.btcentralplus.com. [109.146.187.221])
 by smtp.gmail.com with ESMTPSA id s63sm40650772wms.18.2020.12.15.05.21.19
 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128);
 Tue, 15 Dec 2020 05:21:19 -0800 (PST)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 677743ea-deb7-4e7c-9b70-595d6a953482
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=from:reply-to:to:references:in-reply-to:subject:date:message-id
         :mime-version:content-transfer-encoding:content-language
         :thread-index;
        bh=MdC7cu4RH6e5DtEmx1EqSMiyJahhE2TrUD+6dQT3xT0=;
        b=eMvFRZnSKrT2vUi/WYEFkdV+BHxGnDwW36Db+nRiErljXTq0Yj5mRXRYNC4CpSTSyk
         xdcbUFFdsGTIHRGnWwM9/Wq3hmDo1yj82G0zTIngz4QGsroLl6oTBKSA3lNGBn/efjiI
         XU/O0dyOkWP1bP7HpVsVaNo3ArjfmOIyDZwgpO83zAX3crZW/GHIDqd7+BnyqOtViFDl
         hvn4mpmGlk2MXh0UCahUPviGE3VRYMhy7KtLk6KUgrz6UtKMdnbmbznjUKgmdgqQr0Yb
         94VGWrnVbjycnGF1sAAzp2MCb9y8sjloLJHamIIXORI/NVxO/zJ3sAiqbSFoqb8ysc+e
         pUQQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:from:reply-to:to:references:in-reply-to:subject
         :date:message-id:mime-version:content-transfer-encoding
         :content-language:thread-index;
        bh=MdC7cu4RH6e5DtEmx1EqSMiyJahhE2TrUD+6dQT3xT0=;
        b=Hr1pYFZOZK+fe7VSAl9F0ikzYJpn5ub5ImYpAsXtqQJCrYwq+wVH/l2wbRSrhJ2lY6
         xvCyIb3yhFbVb1ZTW1W4D8hNCx6q6T7Fien++Lbw2pJzWXy90nWYGy004p6cFVJagvtM
         FsH2D9RaXo9z7fc4Y0FNAjXM1t3BpTBkjXOBrQDRQUyKAUgXUS1c50kUHxCcWJBEAGHi
         /3nW35PXOqbCDlnBL+B36JR5qZIbCZhWS+w4lrxqN77K+C1z4sKm9BGPNx/tTwIIhi0I
         VPpeUVdhf25PeZNwKlXFlueOGaiZcPjROwXSHbWUaQHTgCPW1doyVg2UwUe4JjQHtjsu
         yM4A==
X-Gm-Message-State: AOAM532UWpxraOLVHVhFticT1QJwHxLT41hFsrn6rG2LreVHolZB/9ct
	1+pAMil8jpXNFJ1Z9kwYfGg=
X-Google-Smtp-Source: ABdhPJzYynijpi+d4STwIX4LvO8NyCp0Kks+i4XW2wt/isP66a3bl6dc7m/t9OfBiR4rZiyFCzTckw==
X-Received: by 2002:a1c:491:: with SMTP id 139mr32295243wme.81.1608038480035;
        Tue, 15 Dec 2020 05:21:20 -0800 (PST)
From: Paul Durrant <xadimgnik@gmail.com>
X-Google-Original-From: "Paul Durrant" <paul@xen.org>
Reply-To: <paul@xen.org>
To: "'Owen Smith'" <owen.smith@citrix.com>,
	<win-pv-devel@lists.xenproject.org>
References: <20201215123306.2324069-1-owen.smith@citrix.com>
In-Reply-To: <20201215123306.2324069-1-owen.smith@citrix.com>
Subject: RE: [PATCH] Reset "RebootCount" when no reboot requested.
Date: Tue, 15 Dec 2020 13:21:18 -0000
Message-ID: <00ee01d6d2e5$2cd2bb00$86783100$@xen.org>
MIME-Version: 1.0
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: 7bit
X-Mailer: Microsoft Outlook 16.0
Content-Language: en-gb
Thread-Index: AQINjyk5wujEsISRgj4N0wsO6wxcuqmKq9WA

> -----Original Message-----
> From: win-pv-devel <win-pv-devel-bounces@lists.xenproject.org> On Behalf Of Owen Smith
> Sent: 15 December 2020 12:33
> To: win-pv-devel@lists.xenproject.org
> Cc: Owen Smith <owen.smith@citrix.com>
> Subject: [PATCH] Reset "RebootCount" when no reboot requested.
> 
> Signed-off-by: Owen Smith <owen.smith@citrix.com>

Could you fold this into patch #2 of your series? I have not applied it yet.

  Paul

> ---
>  src/monitor/monitor.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
> index 5d58be4..7d8689f 100644
> --- a/src/monitor/monitor.c
> +++ b/src/monitor/monitor.c
> @@ -797,6 +797,11 @@ loop:
>          RegCloseKey(SubKey);
>      }
> 
> +    Error = RegDeleteValue(Context->ParametersKey,
> +                           "RebootCount");
> +    if (Error == ERROR_SUCCESS)
> +        (VOID) RegFlushKey(Context->ParametersKey);
> +
>      goto done;
> 
>  found:
> --
> 2.28.0.windows.1
> 




From win-pv-devel-bounces@lists.xenproject.org Tue Dec 15 16:39:28 2020
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 15 Dec 2020 16:39:28 +0000
Received: from list by lists.xenproject.org with outflank-mailman.54605.95087 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1kpDME-0000Bi-M9; Tue, 15 Dec 2020 16:39:26 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 54605.95087; Tue, 15 Dec 2020 16:39:26 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1kpDME-0000Bb-JJ; Tue, 15 Dec 2020 16:39:26 +0000
Received: by outflank-mailman (input) for mailman id 54605;
 Tue, 15 Dec 2020 16:39:24 +0000
Received: from all-amaz-eas1.inumbo.com ([34.197.232.57]
 helo=us1-amaz-eas2.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=24j/=FT=citrix.com=owen.smith@srs-us1.protection.inumbo.net>)
 id 1kpDMC-0000AF-Qo
 for win-pv-devel@lists.xenproject.org; Tue, 15 Dec 2020 16:39:24 +0000
Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id a28a3676-dd13-42d5-a7dd-a56ba2361101;
 Tue, 15 Dec 2020 16:39:19 +0000 (UTC)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: a28a3676-dd13-42d5-a7dd-a56ba2361101
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple;
  d=citrix.com; s=securemail; t=1608050358;
  h=from:to:cc:subject:date:message-id:mime-version:
   content-transfer-encoding;
  bh=kVf5WDEtgJOsSj9Zyq2iLPliOViDuTwikn1oZDBFBU8=;
  b=YTmvkKRMvrUUC5jsrUCIuoTWtl+QysKthzeJCs7ZiW0PhaB6Cjufnu5P
   GtwZPWcuueMUxaNcznw3LZjJQEoFyvo5ya0C9Wpx//1TqiGfm6wHRYZnz
   GeNEFwB5PkBlU6fWxU/rOuq615DIHTDV8bwLSbAaR9H2DFFC4taJA34To
   A=;
Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
IronPort-SDR: uS1Rzeo5Jw8uK9WvuSjzCK7SEAn7HHAMZwioQzvBIWV8OhClIrRC1di/CIgchPNx9T/Y7171RH
 AsyXrNVpP0IIK23aweEPhaWqAWMa0smFNxT6LBcGhBHv/afugJPfdVVQQ+1lykkn388dH47lyO
 adWmSaXxWDnToCCxwk91Fkn+wp8OFi6wbstJLovLNVSeR/sKt/JbgTMrmRqxsXXhdmliGTvq/v
 dEt5hPhTbc0Qo8Pg2GVW7OegP/RxxwDxaLi+7x+QPbxRwH5R7DaG9jTZ56elip/c43eE0/1GBo
 n64=
X-SBRS: 5.2
X-MesageID: 34488397
X-Ironport-Server: esa4.hc3370-68.iphmx.com
X-Remote-IP: 162.221.158.21
X-Policy: $RELAYED
X-IronPort-AV: E=Sophos;i="5.78,421,1599537600"; 
   d="scan'208";a="34488397"
From: Owen Smith <owen.smith@citrix.com>
To: <win-pv-devel@lists.xenproject.org>
CC: Owen Smith <owen.smith@citrix.com>
Subject: [PATCH v2] Add AutoReboot capability
Date: Tue, 15 Dec 2020 16:29:07 +0000
Message-ID: <20201215162907.2384532-1-owen.smith@citrix.com>
X-Mailer: git-send-email 2.27.0
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain

Setting HKLM\System\CCS\Services\xenbus_monitor\AutoReboot to non-zero
will allow xenbus_monitor to trigger a reboot when another driver
requests a reboot. AutoReboot is set to the maximum number of reboots
to perform. Auto reboots display a message with a 60 second timeout.

This setting can be used to allow headless/unmonitored VMs to complete
the neccessary number of reboots to return to PV disks/networks. Without
this capability its possible to update the driver on a parent device,
which may prompt for a reboot. After this reboot, its likely that
emulated devices are used whilst drivers are rebound to the device
nodes. This can leave headless/unmonitored VMs in a state where emulated
devices are in use with a pending reboot. If network settings have been
changed for PV devices (e.g. static IP addressing), then the VM may not
be accessible over RDP or similar connections.

RebootCount is cleared when no pending required reboots are detected.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
---
 src/monitor/monitor.c | 138 ++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 134 insertions(+), 4 deletions(-)

diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index 07bf8c1..7d8689f 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -301,7 +301,8 @@ WTSStateName(
 
 static VOID
 DoReboot(
-    VOID
+    IN PTCHAR   Message,
+    IN DWORD    Timeout
     )
 {
     Log("waiting for pending install events...");
@@ -312,8 +313,8 @@ DoReboot(
 
 #pragma prefast(suppress:28159)
     (VOID) InitiateSystemShutdownEx(NULL,
-                                    NULL,
-                                    0,
+                                    Message,
+                                    Timeout,
                                     TRUE,
                                     TRUE,
                                     SHTDN_REASON_MAJOR_OPERATINGSYSTEM |
@@ -451,6 +452,125 @@ fail1:
     return NULL;
 }
 
+static BOOL
+TryAutoReboot(
+    IN PTCHAR           DriverName
+    )
+{
+    PMONITOR_CONTEXT    Context = &MonitorContext;
+    HRESULT             Result;
+    DWORD               Type;
+    DWORD               AutoReboot;
+    DWORD               RebootCount;
+    DWORD               Length;
+    PTCHAR              DisplayName;
+    PTCHAR              Description;
+    PTCHAR              Text;
+    DWORD               TextLength;
+    HRESULT             Error;
+
+    Length = sizeof (DWORD);
+
+    Error = RegQueryValueEx(Context->ParametersKey,
+                            "AutoReboot",
+                            NULL,
+                            &Type,
+                            (LPBYTE)&AutoReboot,
+                            &Length);
+    if (Error != ERROR_SUCCESS ||
+        Type != REG_DWORD)
+        AutoReboot = 0;
+
+    if (AutoReboot == 0)
+        goto done;
+
+    Length = sizeof (DWORD);
+
+    Error = RegQueryValueEx(Context->ParametersKey,
+                            "RebootCount",
+                            NULL,
+                            &Type,
+                            (LPBYTE)&RebootCount,
+                            &Length);
+    if (Error != ERROR_SUCCESS ||
+        Type != REG_DWORD)
+        RebootCount = 0;
+
+    if (RebootCount >= AutoReboot)
+        goto done;
+
+    Log("AutoRebooting (reboot %u of %u)\n",
+        RebootCount,
+        AutoReboot);
+
+    ++RebootCount;
+
+    (VOID) RegSetValueEx(Context->ParametersKey,
+                         "RebootCount",
+                         0,
+                         REG_DWORD,
+                         (const BYTE*)&RebootCount,
+                         (DWORD) sizeof(DWORD));
+
+    (VOID) RegFlushKey(Context->ParametersKey);
+
+    Context->RebootPending = TRUE;
+
+    DisplayName = GetDisplayName(DriverName);
+    if (DisplayName == NULL)
+        goto fail1;
+
+    Description = _tcsrchr(DisplayName, ';');
+    if (Description == NULL)
+        Description = DisplayName;
+    else
+        Description++;
+
+    TextLength = (DWORD)((_tcslen(Description) +
+                          1 + // ' '
+                          _tcslen(Context->Text) +
+                          1) * sizeof (TCHAR));
+
+    Text = calloc(1, TextLength);
+    if (Text == NULL)
+        goto fail2;
+
+    Result = StringCbPrintf(Text,
+                            TextLength,
+                            TEXT("%s %s"),
+                            Description,
+                            Context->Text);
+    assert(SUCCEEDED(Result));
+
+    free(DisplayName);
+
+    DoReboot(Text, 60);
+
+    free(Text);
+
+    return TRUE;
+
+done:
+    return FALSE;
+
+fail2:
+    Log("fail2");
+
+    free(DisplayName);
+
+fail1:
+    Error = GetLastError();
+
+    {
+        PTCHAR  Message;
+        Message = GetErrorMessage(Error);
+        Log("fail1 (%s)", Message);
+        LocalFree(Message);
+    }
+
+    return FALSE;
+}
+
 static VOID
 PromptForReboot(
     IN PTCHAR           DriverName
@@ -476,6 +596,10 @@ PromptForReboot(
     TitleLength = (DWORD)((_tcslen(Context->Title) +
                            1) * sizeof (TCHAR));
 
+    // AutoReboot is set, DoReboot has been called
+    if (TryAutoReboot(DriverName))
+        goto done;
+
     DisplayName = GetDisplayName(DriverName);
     if (DisplayName == NULL)
         goto fail1;
@@ -547,7 +671,7 @@ PromptForReboot(
         Context->RebootPending = TRUE;
 
         if (Response == IDYES || Response == IDTIMEOUT)
-            DoReboot();
+            DoReboot(NULL, 0);
 
         break;
     }
@@ -556,6 +680,7 @@ PromptForReboot(
 
     free(DisplayName);
 
+done:
     Log("<====");
 
     return;
@@ -672,6 +797,11 @@ loop:
         RegCloseKey(SubKey);
     }
 
+    Error = RegDeleteValue(Context->ParametersKey,
+                           "RebootCount");
+    if (Error == ERROR_SUCCESS)
+        (VOID) RegFlushKey(Context->ParametersKey);
+
     goto done;
 
 found:
-- 
2.28.0.windows.1



From win-pv-devel-bounces@lists.xenproject.org Wed Dec 16 15:36:42 2020
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 16 Dec 2020 15:36:42 +0000
Received: from list by lists.xenproject.org with outflank-mailman.55301.96368 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1kpYr1-0007nh-TE; Wed, 16 Dec 2020 15:36:39 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 55301.96368; Wed, 16 Dec 2020 15:36:39 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1kpYr1-0007na-QI; Wed, 16 Dec 2020 15:36:39 +0000
Received: by outflank-mailman (input) for mailman id 55301;
 Wed, 16 Dec 2020 15:36:39 +0000
Received: from all-amaz-eas1.inumbo.com ([34.197.232.57]
 helo=us1-amaz-eas2.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=G4Hh=FU=citrix.com=owen.smith@srs-us1.protection.inumbo.net>)
 id 1kpYr1-0007nV-4k
 for win-pv-devel@lists.xenproject.org; Wed, 16 Dec 2020 15:36:39 +0000
Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id 54830ea4-8fdf-427e-ace4-a692e058dbee;
 Wed, 16 Dec 2020 15:36:37 +0000 (UTC)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 54830ea4-8fdf-427e-ace4-a692e058dbee
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple;
  d=citrix.com; s=securemail; t=1608132995;
  h=from:to:cc:subject:date:message-id:mime-version:
   content-transfer-encoding;
  bh=kJweFHUQsnFcQkZ1+O4zoEia4abI+hFQdEF0dq8UiB8=;
  b=FF5hKBPxhPVhGdoOMF/owzNO2WWzhBx4QGul9Yojg6KqRh1ycFaCfkmE
   VwHfuipXndsKKIDpukc8qDlj0kSlBinKfjUVwyJXj12mlv34rQnIXhI6+
   iQgZfs23Yx3gpWRMCp/Mf80TmAGs98TxLJ1hOssnfBu92cFnTBx3nl6hk
   Q=;
Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
IronPort-SDR: MjCDndiANdKAwxbSfA3e7p4mQOmqqEABnTF+2dL64wF8oZro4YNqV/cnLwHgCP/vqnokrO3Lpx
 hTAZbG25aaR1Qa4RaDOo7/2/nKypaYkqQr5CRM3AwRRJKJsCdRQ40VWDgXhzcqe/hR+/ZN+FMd
 n65lmpxl1F/7tf2J5zvHN/mTj42YklNYCN+7rMX1owKd3EXZebqjnG8BGyLjOlYalv8tJi/YF0
 O6rhqKIoUqD3m/zKUFMcYEGIKdgHp7ljyd+vdCuNmGBW4otG41AwgcfSglI6w8GnI3zED2AID3
 aeA=
X-SBRS: 5.2
X-MesageID: 33703861
X-Ironport-Server: esa1.hc3370-68.iphmx.com
X-Remote-IP: 162.221.158.21
X-Policy: $RELAYED
X-IronPort-AV: E=Sophos;i="5.78,424,1599537600"; 
   d="scan'208";a="33703861"
From: Owen Smith <owen.smith@citrix.com>
To: <win-pv-devel@lists.xenproject.org>
CC: Owen Smith <owen.smith@citrix.com>
Subject: [PATCH] Add XEN:BOOT_EMULATED handler
Date: Wed, 16 Dec 2020 15:36:10 +0000
Message-ID: <20201216153610.2798028-1-owen.smith@citrix.com>
X-Mailer: git-send-email 2.27.0
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain

If XEN:BOOT_EMULATED=TRUE is in the system start options, xen.sys will
issue an unplug for only the AUX disks (by writing 0x0004 instead of
0x0001 to port 0x10 during the unplug), this leads to a target being
created for the boot disk which will not be used (due to an emulated
device being present). The non-functioning target will request a reboot
to resolve this, which will return to the current state and request
another reboot.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
---
 src/xenvbd/adapter.c | 40 ++++++++++++++++++++++++++++++++++++++++
 src/xenvbd/adapter.h |  5 +++++
 src/xenvbd/target.c  |  3 +++
 3 files changed, 48 insertions(+)

diff --git a/src/xenvbd/adapter.c b/src/xenvbd/adapter.c
index 721c97f..941587a 100644
--- a/src/xenvbd/adapter.c
+++ b/src/xenvbd/adapter.c
@@ -89,6 +89,7 @@ struct _XENVBD_ADAPTER {
     PXENVBD_THREAD              ScanThread;
     KEVENT                      ScanEvent;
     PXENBUS_STORE_WATCH         ScanWatch;
+    BOOLEAN                     BootEmulated;
 
     ULONG                       BuildIo;
     ULONG                       StartIo;
@@ -412,6 +413,14 @@ AdapterIsTargetEmulated(
     return Emulated;
 }
 
+BOOLEAN
+AdapterBootEmulated(
+    IN  PXENVBD_ADAPTER Adapter
+    )
+{
+    return Adapter->BootEmulated;
+}
+
 static FORCEINLINE VOID
 __AdapterEnumerate(
     IN  PXENVBD_ADAPTER Adapter,
@@ -1179,6 +1188,32 @@ AdapterReleaseLock(
     KeReleaseSpinLockFromDpcLevel(&Adapter->Lock);
 }
 
+static FORCEINLINE VOID
+__AdapterSetBootEmulated(
+    IN  PXENVBD_ADAPTER Adapter
+    )
+{
+    CHAR                Key[] = "XEN:BOOT_EMULATED=";
+    PANSI_STRING        Option;
+    PCHAR               Value;
+    NTSTATUS            status;
+
+    Adapter->BootEmulated = FALSE;
+
+    status = RegistryQuerySystemStartOption(Key, &Option);
+    if (!NT_SUCCESS(status))
+        return;
+
+    Value = Option->Buffer + sizeof (Key) - 1;
+
+    if (strcmp(Value, "TRUE") == 0)
+        Adapter->BootEmulated = TRUE;
+    else if (strcmp(Value, "FALSE") != 0)
+        Warning("UNRECOGNIZED VALUE OF %s: %s\n", Key, Value);
+
+    RegistryFreeSzValue(Option);
+}
+
 __drv_requiresIRQL(PASSIVE_LEVEL)
 static NTSTATUS
 __AdapterQueryInterface(
@@ -1356,6 +1391,8 @@ AdapterInitialize(
     if (!NT_SUCCESS(status))
         goto fail10;
 
+    __AdapterSetBootEmulated(Adapter);
+
     status = ThreadCreate(AdapterScanThread,
                           Adapter,
                           &Adapter->ScanThread);
@@ -1377,6 +1414,7 @@ fail12:
     Adapter->ScanThread = NULL;
 fail11:
     Error("fail11\n");
+    Adapter->BootEmulated = FALSE;
     XENBUS_CACHE(Destroy,
                  &Adapter->CacheInterface,
                  Adapter->BounceCache);
@@ -1462,6 +1500,8 @@ AdapterTeardown(
         TargetDestroy(Target);
     }
 
+    Adapter->BootEmulated = FALSE;
+
     XENBUS_CACHE(Destroy,
                  &Adapter->CacheInterface,
                  Adapter->BounceCache);
diff --git a/src/xenvbd/adapter.h b/src/xenvbd/adapter.h
index 354699b..c6057ff 100644
--- a/src/xenvbd/adapter.h
+++ b/src/xenvbd/adapter.h
@@ -67,6 +67,11 @@ AdapterIsTargetEmulated(
     IN  ULONG           TargetId
     );
 
+extern BOOLEAN
+AdapterBootEmulated(
+    IN  PXENVBD_ADAPTER Adapter
+    );
+
 extern VOID
 AdapterCompleteSrb(
     IN  PXENVBD_ADAPTER Adapter,
diff --git a/src/xenvbd/target.c b/src/xenvbd/target.c
index 839860c..7935fa0 100644
--- a/src/xenvbd/target.c
+++ b/src/xenvbd/target.c
@@ -1377,6 +1377,9 @@ TargetCreate(
     if (TargetId >= XENVBD_MAX_TARGETS)
         return STATUS_RETRY;
 
+    if (TargetId == 0 && AdapterBootEmulated(Adapter))
+        return STATUS_UNSUCCESSFUL;
+
     if (AdapterIsTargetEmulated(Adapter, TargetId))
         return STATUS_RETRY;
 
-- 
2.28.0.windows.1



From win-pv-devel-bounces@lists.xenproject.org Thu Dec 17 14:40:01 2020
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 17 Dec 2020 14:40:01 +0000
Received: from list by lists.xenproject.org with outflank-mailman.55944.97604 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1kpuRj-0005pu-Kj; Thu, 17 Dec 2020 14:39:59 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 55944.97604; Thu, 17 Dec 2020 14:39:59 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1kpuRj-0005pn-Hy; Thu, 17 Dec 2020 14:39:59 +0000
Received: by outflank-mailman (input) for mailman id 55944;
 Thu, 17 Dec 2020 14:39:58 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=epRl=FV=gmail.com=xadimgnik@srs-us1.protection.inumbo.net>)
 id 1kpuRi-0005ph-FD
 for win-pv-devel@lists.xenproject.org; Thu, 17 Dec 2020 14:39:58 +0000
Received: from mail-wm1-x334.google.com (unknown [2a00:1450:4864:20::334])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 4b1290f8-dcb6-44be-8117-ef31352aa53f;
 Thu, 17 Dec 2020 14:39:57 +0000 (UTC)
Received: by mail-wm1-x334.google.com with SMTP id v14so5767503wml.1
 for <win-pv-devel@lists.xenproject.org>; Thu, 17 Dec 2020 06:39:57 -0800 (PST)
Received: from CBGR90WXYV0 (host86-166-98-87.range86-166.btcentralplus.com.
 [86.166.98.87])
 by smtp.gmail.com with ESMTPSA id 125sm7698923wmc.27.2020.12.17.06.39.55
 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128);
 Thu, 17 Dec 2020 06:39:56 -0800 (PST)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 4b1290f8-dcb6-44be-8117-ef31352aa53f
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=from:reply-to:to:subject:date:message-id:mime-version
         :content-transfer-encoding:content-language:thread-index;
        bh=5+LRYTLV8HlnhKsFonqKFBLKcrGljKK+XURWefYMxzg=;
        b=mogEcOK72pmv+mSDA434BsSBunpQ0c4wLBAWPsoiHvZwBYVVedTmnSEHqC4WYPvUSn
         Er5aPgELjWfR5djgJ0Oq01HHWpksVca7M914Onn27DP2Gfn+/4FvwfLW70UBy/yFQ1d7
         NKQi3UMAGxL9H5DrvOYK6HykLfUNdhBfqZjSAiPRkVpi364nSVpAVfoWNcNs3hr0ovDv
         /t12rLns7IZ9x9eMc0YrlT0DCRjx8JXuSfOpfUtnEGmX6RcI7SNY7XAN2XbRwVAPniFU
         52itequCYS5GGSNkx1WjMpJWu8WnxI6tJOE1THkcdpGRzpi3TAPsa+OXVUUeaYhlKbQw
         CP9g==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:from:reply-to:to:subject:date:message-id
         :mime-version:content-transfer-encoding:content-language
         :thread-index;
        bh=5+LRYTLV8HlnhKsFonqKFBLKcrGljKK+XURWefYMxzg=;
        b=WVbosECA9UQ+WBwu66knjs71GTwNRY0+4Dx5j75piGAJJOQikBbZe/b8f5mCm6IxgR
         TlQyrguxe6C0/cELKTkC3p3zu/BRor1Ynuy6ppt+15h9D1jVm0fnOXrwrI8gvrSpbGHq
         mzfKdGBkACUvG5af9cuttCfAYrtyE34xrCi07nx7n5rFdoo27U13wkv75gZBmxze59FY
         aLuDODVl4qc95kmU8wA1BL/gZF038oCLRRPUSiFEIkuf/do0Zp93NOwVjS9sNKzn+p35
         5ee98TzTmrNy4zOEfZ5p5gh2SWYtPzD493ji8uYuPYhbYrQLn8rgzJdkLOCDnjovCc8L
         w0tw==
X-Gm-Message-State: AOAM533wECcxo0AG5YDG74wzuTudYcM6v8lIV1fWA+ncLaXNj3/ozyr6
	jMJHMNlhoDWZ4AmkmZr6O7U=
X-Google-Smtp-Source: ABdhPJxKxxIN5A8IWCjVVYgDpN8JvI2cvTbkrzwc1ZLQ4JqHA1k1Z7IG+ttTqSuARCA6phngseMaSA==
X-Received: by 2002:a1c:2182:: with SMTP id h124mr8901636wmh.25.1608215996775;
        Thu, 17 Dec 2020 06:39:56 -0800 (PST)
From: Paul Durrant <xadimgnik@gmail.com>
X-Google-Original-From: "Paul Durrant" <paul@xen.org>
Reply-To: <paul@xen.org>
To: "'Owen Smith'" <owen.smith@citrix.com>,
	<win-pv-devel@lists.xenproject.org>
Subject: RE: [PATCH v2] Add AutoReboot capability
Date: Thu, 17 Dec 2020 14:39:55 -0000
Message-ID: <02f001d6d482$7cfc8810$76f59830$@xen.org>
MIME-Version: 1.0
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: 7bit
X-Mailer: Microsoft Outlook 16.0
Content-Language: en-gb
Thread-Index: AdbUgmHU58xnU/jaTLuMJvsQMGn4mg==

> -----Original Message-----
> From: win-pv-devel <win-pv-devel-bounces@lists.xenproject.org> On Behalf Of Owen Smith
> Sent: 15 December 2020 16:29
> To: win-pv-devel@lists.xenproject.org
> Cc: Owen Smith <owen.smith@citrix.com>
> Subject: [PATCH v2] Add AutoReboot capability
> 
> Setting HKLM\System\CCS\Services\xenbus_monitor\AutoReboot to non-zero
> will allow xenbus_monitor to trigger a reboot when another driver
> requests a reboot. AutoReboot is set to the maximum number of reboots
> to perform. Auto reboots display a message with a 60 second timeout.
> 
> This setting can be used to allow headless/unmonitored VMs to complete
> the neccessary number of reboots to return to PV disks/networks. Without
> this capability its possible to update the driver on a parent device,
> which may prompt for a reboot. After this reboot, its likely that
> emulated devices are used whilst drivers are rebound to the device
> nodes. This can leave headless/unmonitored VMs in a state where emulated
> devices are in use with a pending reboot. If network settings have been
> changed for PV devices (e.g. static IP addressing), then the VM may not
> be accessible over RDP or similar connections.
> 
> RebootCount is cleared when no pending required reboots are detected.
> 
> Signed-off-by: Owen Smith <owen.smith@citrix.com>

Acked-by: Paul Durrant <paul@xen.org>



From win-pv-devel-bounces@lists.xenproject.org Thu Dec 17 15:20:43 2020
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 17 Dec 2020 15:20:43 +0000
Received: from list by lists.xenproject.org with outflank-mailman.55955.97608 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1kpv57-0001u6-JN; Thu, 17 Dec 2020 15:20:41 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 55955.97608; Thu, 17 Dec 2020 15:20:41 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1kpv57-0001tz-GW; Thu, 17 Dec 2020 15:20:41 +0000
Received: by outflank-mailman (input) for mailman id 55955;
 Thu, 17 Dec 2020 15:20:40 +0000
Received: from winpvdrvbuild.xenproject.org ([162.242.160.44])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul.durrant@xenproject.org>) id 1kpv55-0001tn-Sr
 for win-pv-devel@lists.xenproject.org; Thu, 17 Dec 2020 15:20:40 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
Date: Thu, 17 Dec 2020 15:20:22 +0000 (UTC)
From: paul.durrant@xenproject.org
To: win-pv-devel@lists.xenproject.org
Message-ID: <26600860.1.1608218424684.JavaMail.WINPVDRVBUILD$@winpvdrvbuild>
Subject: XENBUS-master - Build #212 - Successful
MIME-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_0_13413147.1608218422684"
X-Jenkins-Job: XENBUS-master
X-Jenkins-Result: SUCCESS


------=_Part_0_13413147.1608218422684
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit

The build system has completed build #212.

Check console output at https://winpvdrvbuild.xenproject.org:8080/job/XENBUS-master/212/console to view the results.
------=_Part_0_13413147.1608218422684--


From win-pv-devel-bounces@lists.xenproject.org Thu Dec 17 18:03:03 2020
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 17 Dec 2020 18:03:03 +0000
Received: from list by lists.xenproject.org with outflank-mailman.56086.97917 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1kpxcD-0003gt-94; Thu, 17 Dec 2020 18:03:01 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 56086.97917; Thu, 17 Dec 2020 18:03:01 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1kpxcD-0003gl-6B; Thu, 17 Dec 2020 18:03:01 +0000
Received: by outflank-mailman (input) for mailman id 56086;
 Thu, 17 Dec 2020 18:03:00 +0000
Received: from winpvdrvbuild.xenproject.org ([162.242.160.44])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul.durrant@xenproject.org>) id 1kpxcC-0003gg-D7
 for win-pv-devel@lists.xenproject.org; Thu, 17 Dec 2020 18:03:00 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
Date: Thu, 17 Dec 2020 18:02:44 +0000 (UTC)
From: paul.durrant@xenproject.org
To: win-pv-devel@lists.xenproject.org
Message-ID: <14364379.3.1608228164768.JavaMail.WINPVDRVBUILD$@winpvdrvbuild>
Subject: XENVBD-master - Build #151 - Successful
MIME-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_2_13327057.1608228164502"
X-Jenkins-Job: XENVBD-master
X-Jenkins-Result: SUCCESS


------=_Part_2_13327057.1608228164502
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit

The build system has completed build #151.

Check console output at https://winpvdrvbuild.xenproject.org:8080/job/XENVBD-master/151/console to view the results.
------=_Part_2_13327057.1608228164502--


From win-pv-devel-bounces@lists.xenproject.org Thu Dec 17 19:09:08 2020
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 17 Dec 2020 19:09:08 +0000
Received: from list by lists.xenproject.org with outflank-mailman.56104.97965 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1kpye9-0001SC-Ud; Thu, 17 Dec 2020 19:09:05 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 56104.97965; Thu, 17 Dec 2020 19:09:05 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1kpye9-0001S5-Rh; Thu, 17 Dec 2020 19:09:05 +0000
Received: by outflank-mailman (input) for mailman id 56104;
 Thu, 17 Dec 2020 18:51:18 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=5wc1=FV=ainfosec.com=davisc@srs-us1.protection.inumbo.net>)
 id 1kpyMw-0000Cl-Eu
 for win-pv-devel@lists.xenproject.org; Thu, 17 Dec 2020 18:51:18 +0000
Received: from USG02-BN3-obe.outbound.protection.office365.us (unknown
 [2001:489a:2202:c::616])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id c134c742-1294-49f5-ab12-4832fc4f4a4a;
 Thu, 17 Dec 2020 18:51:15 +0000 (UTC)
Received: from SN5P110MB0462.NAMP110.PROD.OUTLOOK.COM (2001:489a:200:41a::23)
 by SN5P110MB0541.NAMP110.PROD.OUTLOOK.COM (2001:489a:200:41c::8) with
 Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.21; Thu, 17 Dec
 2020 18:51:12 +0000
Received: from SN5P110MB0462.NAMP110.PROD.OUTLOOK.COM
 ([fe80::c981:9e09:4368:d764]) by SN5P110MB0462.NAMP110.PROD.OUTLOOK.COM
 ([fe80::c981:9e09:4368:d764%10]) with mapi id 15.20.3632.037; Thu, 17 Dec
 2020 18:51:12 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: c134c742-1294-49f5-ab12-4832fc4f4a4a
ARC-Seal: i=1; a=rsa-sha256; s=arcselector5401; d=microsoft.com; cv=none;
 b=qRZzIHPlN0VKxmcOY5JniqxcHBhytBcCnUCDK1hvL5rbtmSDsR529wZodUPL4egXcWV38KkxA23gh1MA816QBX4acmURtiXrAaBVV4k/y+gQMuC8sEosj3emf0+/5ZdLG6sa1Q8lNkRAUclJSYiQleouQ/t5wKvL4nnI2G6fDYs8YN0ISXAgNu5n2ClQSRy0sn4Vyb5/PeBC327nUjEwGtfRH1XVANx/8Filo6Fj0VMpminzPZcIrygrzvSQY7dwP6FTMQSXs4StnW8/UcPJFLResZtgpMVVM1+8CdeSs6y5O5Kwz60apnLsFRZvd+MW2IFkmPMCh+y3pQb0mGpJMQ==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;
 s=arcselector5401;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=CIShu8TLXPGqWS7quoThvQ5ab8GyiGcTfAaJY8YxafU=;
 b=v2FNmF67hscdCAT8tMgIHlI8Hjj4L97MWrGw/gLgbgYUTbOmInMjVVvqz1MF/HSY7kx+MC+tU2zicVDCuZbRUWqZu87IUcRT8hB4u8hoI/fAbD8jUEE1cMgqcxdzJvgTCu/9TowEDvQhFnrq17o7Dc1JAeKt4Dx1JjYQZOxfPukt/tt96MkdKgyLRs+Kg9u0kiWxxLfixJdihRqt7k1MglsRdOZPjHKxcR2vruoiQ58lA5UPS1ISVw/1YwtNcK7wPL7/BdsdP9LlTnnnY+r1yMwmDaNMGvH0FNnMA0Jmqt6r6yGKBaNC8MInrO1sZcjuCRM+7iOPpy/dD4Z3fcFz7Q==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass
 smtp.mailfrom=ainfosec.com; dmarc=pass action=none header.from=ainfosec.com;
 dkim=pass header.d=ainfosec.com; arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=ainfosec.onmicrosoft.com; s=selector1-ainfosec-onmicrosoft-com;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=CIShu8TLXPGqWS7quoThvQ5ab8GyiGcTfAaJY8YxafU=;
 b=URb3KHriR/FXiFXT1D2Xj7gHM701xesFRsP/Ym8JC2nRQKW959E7FlqEdQpHkXNlJL1jGzhAnqEqbrJ0js0RHK9VjwHyJrvgSeNXRgaArJHbM4hkQKC6c8DlqzzAGjm1GQ+qFkgxMBmVNmDYmcEyiqhuJbhv5+Ey2in8Q0qT1Y4=
From: Connor Davis <davisc@ainfosec.com>
To: "win-pv-devel@lists.xenproject.org" <win-pv-devel@lists.xenproject.org>
Subject: Booting Issue
Thread-Topic: Booting Issue
Thread-Index: AdbUpI5Rm7k9sI/tTaOFm5DW5RKKkg==
Date: Thu, 17 Dec 2020 18:51:12 +0000
Message-ID:
 <SN5P110MB0462958DC888DF379BDE9CDAA5C40@SN5P110MB0462.NAMP110.PROD.OUTLOOK.COM>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
authentication-results: lists.xenproject.org; dkim=none (message not signed)
 header.d=none;lists.xenproject.org; dmarc=none action=none
 header.from=ainfosec.com;
x-originating-ip: [50.237.4.186]
x-ms-publictraffictype: Email
x-ms-office365-filtering-correlation-id: 7e12dc27-1b1d-47b7-ab92-08d8a2bcb98f
x-ms-traffictypediagnostic: SN5P110MB0541:
x-microsoft-antispam-prvs:
 <SN5P110MB0541BBA1719F99D80A1818A7A5C40@SN5P110MB0541.NAMP110.PROD.OUTLOOK.COM>
x-ms-oob-tlc-oobclassifiers: OLM:8273;
x-ms-exchange-senderadcheck: 1
x-microsoft-antispam: BCL:0;
x-forefront-antispam-report:
 CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN5P110MB0462.NAMP110.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(4636009)(366004)(66556008)(66446008)(66476007)(66946007)(64756008)(8936002)(7116003)(5660300002)(52536014)(9686003)(6506007)(76116006)(498600001)(8676002)(26005)(71200400001)(55016002)(186003)(86362001)(83380400001)(4744005)(3480700007)(6916009)(33656002)(7696005)(2906002);DIR:OUT;SFP:1101;
x-ms-exchange-transport-forked: True
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-OriginatorOrg: ainfosec.com
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: SN5P110MB0462.NAMP110.PROD.OUTLOOK.COM
X-MS-Exchange-CrossTenant-Network-Message-Id: 7e12dc27-1b1d-47b7-ab92-08d8a2bcb98f
X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Dec 2020 18:51:12.1927
 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 82614573-95ee-4948-be35-3c0a8fc6ff9c
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN5P110MB0541

Hi All,

What is the expected behavior wrt Windows booting up if the Xen platform PC=
I device isn't present
after a previous run where the PV drivers loaded and ran correctly with the=
 platform device present?
On my system it is currently preventing Windows from booting.

Another possibly related issue is occasionally an update will cause Windows=
 to complain that
a boot critical file is missing, usually pointing to xenbus.sys. Is there a=
 way to tell Windows that
the PV drivers are not boot critical so that Windows will continue booting =
even if it doesn't load
the PV drivers properly?

Thanks,
Connor


From win-pv-devel-bounces@lists.xenproject.org Thu Dec 17 19:14:38 2020
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 17 Dec 2020 19:14:38 +0000
Received: from list by lists.xenproject.org with outflank-mailman.56117.97970 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1kpyjV-0002N9-DZ; Thu, 17 Dec 2020 19:14:37 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 56117.97970; Thu, 17 Dec 2020 19:14:37 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1kpyjV-0002N2-A4; Thu, 17 Dec 2020 19:14:37 +0000
Received: by outflank-mailman (input) for mailman id 56117;
 Thu, 17 Dec 2020 19:14:36 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=epRl=FV=gmail.com=xadimgnik@srs-us1.protection.inumbo.net>)
 id 1kpyjU-0002Mx-3m
 for win-pv-devel@lists.xenproject.org; Thu, 17 Dec 2020 19:14:36 +0000
Received: from mail-wm1-x329.google.com (unknown [2a00:1450:4864:20::329])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id e44362f3-ddf4-4755-8940-bcd2a01be015;
 Thu, 17 Dec 2020 19:14:35 +0000 (UTC)
Received: by mail-wm1-x329.google.com with SMTP id x22so6498572wmc.5
 for <win-pv-devel@lists.xenproject.org>; Thu, 17 Dec 2020 11:14:35 -0800 (PST)
Received: from CBGR90WXYV0 (host86-166-98-87.range86-166.btcentralplus.com.
 [86.166.98.87])
 by smtp.gmail.com with ESMTPSA id r7sm5095287wmh.2.2020.12.17.11.14.33
 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128);
 Thu, 17 Dec 2020 11:14:33 -0800 (PST)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: e44362f3-ddf4-4755-8940-bcd2a01be015
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=from:reply-to:to:references:in-reply-to:subject:date:message-id
         :mime-version:content-transfer-encoding:content-language
         :thread-index;
        bh=/awjvKYY2OYbsqpy12IlrY5oeX17jPZm+SGvbmm8qW4=;
        b=nun34pc8Bi6swlALesnrjzudBcqOx57UI4pasNj03jh8knvF7UTBmtwqAgdlbCHCOM
         jsyzQn5o6zOVywGeiBpUaixmpbzQ3+bVmn0CQEPKcvSjzbSi6YayOYqMsdo1f7oMwITt
         +11STRWN+H/4IH6i3cp4AcU4a0L9v2PTG11T2BcBWX/JaIUGHZ+I5ror20t8MX/iFugN
         ORlaXezBCGYdlYYE6AUM/brkTUkdzPLGfkSjvU+aOw76cKo0JcDblsF7ojD8LafpeSNl
         yCyoC35numb6CRxbMiY4BsuE8Pwy5lAj4zTkHp0TiRzNKf0dax4yY6PfAHIrTxRkfiLU
         crkA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:from:reply-to:to:references:in-reply-to:subject
         :date:message-id:mime-version:content-transfer-encoding
         :content-language:thread-index;
        bh=/awjvKYY2OYbsqpy12IlrY5oeX17jPZm+SGvbmm8qW4=;
        b=oYTcHqpp2AsLlkfWfTDFNmeZX12cSM3Tv2x1C4hwPAGa/kO11sYFtImfafgcrSPRWS
         fzoEH/ijqxSwhKZGsbuVb2ZepNPEf0nkNmBpEtq4A3Mk7NcnSRPKFl+FowtbyTWQEhoF
         EdCqxoS4UMivxqG7L6Cx55SCDZrcVU2TyQVpIgGFqgcyX+Hu/5Xq0uH8EOosrxLZA6eJ
         fJn3CKgI+lnPieSCzTWHgiOcBmM34FaiBVdqz5yize9h1EmEAt4rrBQuP97oS7QfO34N
         tgyap+6ixX4gGgptFP1VD9EnLA4zAb+S8aUcUapLcWHb/CwhZMA0EgR6YhG51QyuwTH5
         9PRQ==
X-Gm-Message-State: AOAM531KC++SXFlsad+Y8ppMVWkcB6zqwDoA6F6QnlRgahXyrVzZP9V9
	mNL3Q8Pge+jPsb1BgC6CVlvTiP41UUE=
X-Google-Smtp-Source: ABdhPJwTNcj7hSfxtKWQ2js2D3p7GdOiKK+SJBx8IaCPLUPaurZo6O8ZoGWvz9qQUO4G+560wWD4ZA==
X-Received: by 2002:a1c:1d08:: with SMTP id d8mr760849wmd.159.1608232474334;
        Thu, 17 Dec 2020 11:14:34 -0800 (PST)
From: Paul Durrant <xadimgnik@gmail.com>
X-Google-Original-From: "Paul Durrant" <paul@xen.org>
Reply-To: <paul@xen.org>
To: "'Connor Davis'" <davisc@ainfosec.com>,
	<win-pv-devel@lists.xenproject.org>
References: <SN5P110MB0462958DC888DF379BDE9CDAA5C40@SN5P110MB0462.NAMP110.PROD.OUTLOOK.COM>
In-Reply-To: <SN5P110MB0462958DC888DF379BDE9CDAA5C40@SN5P110MB0462.NAMP110.PROD.OUTLOOK.COM>
Subject: RE: Booting Issue
Date: Thu, 17 Dec 2020 19:14:33 -0000
Message-ID: <030a01d6d4a8$da511730$8ef34590$@xen.org>
MIME-Version: 1.0
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: 7bit
X-Mailer: Microsoft Outlook 16.0
Content-Language: en-gb
Thread-Index: AQG3hOvW8pcGVtyOTIsM3NlH5iyIMKo6RqnA

> -----Original Message-----
> From: win-pv-devel <win-pv-devel-bounces@lists.xenproject.org> On Behalf Of Connor Davis
> Sent: 17 December 2020 18:51
> To: win-pv-devel@lists.xenproject.org
> Subject: Booting Issue
> 
> Hi All,
> 
> What is the expected behavior wrt Windows booting up if the Xen platform PCI device isn't present
> after a previous run where the PV drivers loaded and ran correctly with the platform device present?
> On my system it is currently preventing Windows from booting.

Hi Connor,

  What is *supposed* to happen is that the XENFILT driver detects the absence of the PCI to which XENBUS is bound and prevents
emulated devices from being unplugged, which should allow the boot to continue.

> 
> Another possibly related issue is occasionally an update will cause Windows to complain that
> a boot critical file is missing, usually pointing to xenbus.sys. Is there a way to tell Windows that
> the PV drivers are not boot critical so that Windows will continue booting even if it doesn't load
> the PV drivers properly?
> 

  Not seen that before... perhaps it's a new 'feature' of Windows. XENBUS would be considered boot critical as it is the parent of
XENVBD which, on the previous boot, was presumably hosting the system disk. This will need some investigation unfortunately. What
version of Windows are you running? 10, Server 2019?

  Cheers,

    Paul



From win-pv-devel-bounces@lists.xenproject.org Fri Dec 18 09:22:02 2020
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 18 Dec 2020 09:22:02 +0000
Received: from list by lists.xenproject.org with outflank-mailman.56127.98783 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1kqBxY-0006c0-Ho; Fri, 18 Dec 2020 09:22:00 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 56127.98783; Fri, 18 Dec 2020 09:22:00 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1kqBxY-0006bt-Eq; Fri, 18 Dec 2020 09:22:00 +0000
Received: by outflank-mailman (input) for mailman id 56127;
 Thu, 17 Dec 2020 19:26:09 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=5wc1=FV=ainfosec.com=davisc@srs-us1.protection.inumbo.net>)
 id 1kpyuf-0003Ur-Et
 for win-pv-devel@lists.xenproject.org; Thu, 17 Dec 2020 19:26:09 +0000
Received: from USG02-BN3-obe.outbound.protection.office365.us (unknown
 [2001:489a:2202:c::60d])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 592f817f-5eb9-40d8-9ddf-8f5c7695d2f2;
 Thu, 17 Dec 2020 19:26:01 +0000 (UTC)
Received: from SN5P110MB0462.NAMP110.PROD.OUTLOOK.COM (2001:489a:200:41a::23)
 by SN5P110MB0464.NAMP110.PROD.OUTLOOK.COM (2001:489a:200:41b::8) with
 Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.21; Thu, 17 Dec
 2020 19:25:58 +0000
Received: from SN5P110MB0462.NAMP110.PROD.OUTLOOK.COM
 ([fe80::c981:9e09:4368:d764]) by SN5P110MB0462.NAMP110.PROD.OUTLOOK.COM
 ([fe80::c981:9e09:4368:d764%10]) with mapi id 15.20.3632.037; Thu, 17 Dec
 2020 19:25:58 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 592f817f-5eb9-40d8-9ddf-8f5c7695d2f2
ARC-Seal: i=1; a=rsa-sha256; s=arcselector5401; d=microsoft.com; cv=none;
 b=WmWjMksW6gvnhztr5sGceQmKLg3sYRSAgjOQTvGd0NAUkfB0g8AFGgBCGqzFNQCi1KlDfa1oeK1m9iHpy68fEetvC7lEHOm6uoVwjOGxyiPfNf0OopFSxTlFnQzbvwE7QBVQHhfxnxyMISaz0kXnZarJV66enJpNvaUhtZIZWDGAVL+KVaQ4SWCL3vKzuaKjg8BEPJ5wM/dES74mYqe2z9tYT1N9RlajDRTdM3oVmdJdck8vi7y4ySGCWkgF6LAdF8TYVtEDTPIKZb/RYWxfDubr2BS8YIKzKgE6vqMwWOb5oQPE4Y9L5YjOoVXCNFlVs4hdwl+AQYJJn/bqWW8CGg==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;
 s=arcselector5401;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=K8sMTMVQAIZPSy7J2sc1XVLI5S319WjGUc2DWlCGbl4=;
 b=bTMbFVSAAP5MWGZk6Nz7CC/Qwz34wKm9z8H7c3H9ffS/iREJNy+mrq23iOtS4JDqW6kglHE3NIlP4dAsVt/hHLK6eQ2LkMTugOaVKSQh6uar1afu9Yq5rGsQOzKHulfvg3sSFsJZHdu6MgwIprUzzmsAwPnlGPYNTQhNBXUDHswDc39DI/NuwUHxru1QsD0u1K9j+SVDnidmhaMwporFacG2T9Ao3R31y9WhQcqCciOIzeGUBBOMDxFibk7Cw/8W4tmPVeLNskRe0kKKzRtya7JCpsnjaFm0e8aFslgfGroQiILFjoeVsqmgYytzTK7zSang2oqJfIMBK5Pm6Pk4pQ==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass
 smtp.mailfrom=ainfosec.com; dmarc=pass action=none header.from=ainfosec.com;
 dkim=pass header.d=ainfosec.com; arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=ainfosec.onmicrosoft.com; s=selector1-ainfosec-onmicrosoft-com;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=K8sMTMVQAIZPSy7J2sc1XVLI5S319WjGUc2DWlCGbl4=;
 b=Hpw0gsyiDdiDBzgH+/MnXRx6BEMwmAmibpLuvUOeQlu07KOf5pg82JJQFJaaFQv8Vr78WtJNHn7LJqKIQgYH0se7w0/1hJGetI2bGJ0eXPTmPo1EHLNHqiy4m1WCcP7gP5UB5gJyjr0nA7ssYCAZ03d0I8R0mQQxx5aScTqyJiQ=
From: Connor Davis <davisc@ainfosec.com>
To: "paul@xen.org" <paul@xen.org>, "win-pv-devel@lists.xenproject.org"
	<win-pv-devel@lists.xenproject.org>
CC: Christopher Pelloux <pellouxc@ainfosec.com>
Subject: RE: Booting Issue
Thread-Topic: Booting Issue
Thread-Index: AdbUpI5Rm7k9sI/tTaOFm5DW5RKKkgABEueAAAAl7cA=
Date: Thu, 17 Dec 2020 19:25:58 +0000
Message-ID:
 <SN5P110MB0462E17A8308898C3FB4703EA5C40@SN5P110MB0462.NAMP110.PROD.OUTLOOK.COM>
References:
 <SN5P110MB0462958DC888DF379BDE9CDAA5C40@SN5P110MB0462.NAMP110.PROD.OUTLOOK.COM>
 <030a01d6d4a8$da511730$8ef34590$@xen.org>
In-Reply-To: <030a01d6d4a8$da511730$8ef34590$@xen.org>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
authentication-results: xen.org; dkim=none (message not signed)
 header.d=none;xen.org; dmarc=none action=none header.from=ainfosec.com;
x-originating-ip: [50.237.4.186]
x-ms-publictraffictype: Email
x-ms-office365-filtering-correlation-id: 55d520d2-926f-493a-89d8-08d8a2c194ff
x-ms-traffictypediagnostic: SN5P110MB0464:
x-ms-exchange-transport-forked: True
x-microsoft-antispam-prvs:
 <SN5P110MB0464CF0AE34E1AC912EE4BA4A5C40@SN5P110MB0464.NAMP110.PROD.OUTLOOK.COM>
x-ms-oob-tlc-oobclassifiers: OLM:10000;
x-ms-exchange-senderadcheck: 1
x-microsoft-antispam: BCL:0;
x-forefront-antispam-report:
 CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN5P110MB0462.NAMP110.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(4636009)(366004)(83380400001)(5660300002)(86362001)(107886003)(8676002)(7116003)(33656002)(9686003)(2906002)(8936002)(52536014)(110136005)(498600001)(64756008)(6506007)(7696005)(55016002)(66446008)(4326008)(66556008)(3480700007)(71200400001)(53546011)(26005)(66476007)(186003)(66946007)(76116006);DIR:OUT;SFP:1101;
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-OriginatorOrg: ainfosec.com
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: SN5P110MB0462.NAMP110.PROD.OUTLOOK.COM
X-MS-Exchange-CrossTenant-Network-Message-Id: 55d520d2-926f-493a-89d8-08d8a2c194ff
X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Dec 2020 19:25:58.4218
 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 82614573-95ee-4948-be35-3c0a8fc6ff9c
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN5P110MB0464



> -----Original Message-----
> From: Paul Durrant <xadimgnik@gmail.com>
> Sent: Thursday, December 17, 2020 12:15 PM
> To: Connor Davis <davisc@ainfosec.com>; win-pv-devel@lists.xenproject.org
> Subject: RE: Booting Issue
>=20
> Notice: This message originated outside of ainfosec.com
>=20
>=20
>=20
> > -----Original Message-----
> > From: win-pv-devel <win-pv-devel-bounces@lists.xenproject.org> On Behal=
f Of Connor Davis
> > Sent: 17 December 2020 18:51
> > To: win-pv-devel@lists.xenproject.org
> > Subject: Booting Issue
> >
> > Hi All,
> >
> > What is the expected behavior wrt Windows booting up if the Xen platfor=
m PCI device isn't present
> > after a previous run where the PV drivers loaded and ran correctly with=
 the platform device present?
> > On my system it is currently preventing Windows from booting.
>=20
> Hi Connor,
>=20
>   What is *supposed* to happen is that the XENFILT driver detects the abs=
ence of the PCI to which XENBUS is bound and prevents
> emulated devices from being unplugged, which should allow the boot to con=
tinue.
>=20
> >
> > Another possibly related issue is occasionally an update will cause Win=
dows to complain that
> > a boot critical file is missing, usually pointing to xenbus.sys. Is the=
re a way to tell Windows that
> > the PV drivers are not boot critical so that Windows will continue boot=
ing even if it doesn't load
> > the PV drivers properly?
> >
>=20
>   Not seen that before... perhaps it's a new 'feature' of Windows. XENBUS=
 would be considered boot critical as it is the parent of
> XENVBD which, on the previous boot, was presumably hosting the system dis=
k. This will need some investigation unfortunately. What
> version of Windows are you running? 10, Server 2019?

I'm currently testing Windows 10 1909. One major caveat here: we are runnin=
g Windows on top of MicroV, which implements the
subset of the Xen interface to boot and run the PV drivers (sidenote: we ho=
pe to start open sourcing and upstreaming this work next year).
The only devices that are not given to Windows are network devices; those a=
re passed through to Linux service VMs. So Windows has
complete control over the disk. In fact, xenvbd.sys is never installed - we=
 are only using xenbus, xeniface, xenvif, and xennet.

>=20
>   Cheers,
>=20
>     Paul

Thanks,
Connor


