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

[PATCH] Add XEN:BOOT_EMULATED handler


  • To: <win-pv-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Owen Smith <owen.smith@xxxxxxxxxx>
  • Date: Wed, 16 Dec 2020 15:36:10 +0000
  • Authentication-results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: Owen Smith <owen.smith@xxxxxxxxxx>
  • Delivery-date: Wed, 16 Dec 2020 15:36:42 +0000
  • Ironport-sdr: MjCDndiANdKAwxbSfA3e7p4mQOmqqEABnTF+2dL64wF8oZro4YNqV/cnLwHgCP/vqnokrO3Lpx hTAZbG25aaR1Qa4RaDOo7/2/nKypaYkqQr5CRM3AwRRJKJsCdRQ40VWDgXhzcqe/hR+/ZN+FMd n65lmpxl1F/7tf2J5zvHN/mTj42YklNYCN+7rMX1owKd3EXZebqjnG8BGyLjOlYalv8tJi/YF0 O6rhqKIoUqD3m/zKUFMcYEGIKdgHp7ljyd+vdCuNmGBW4otG41AwgcfSglI6w8GnI3zED2AID3 aeA=
  • List-id: Developer list for the Windows PV Drivers subproject <win-pv-devel.lists.xenproject.org>

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@xxxxxxxxxx>
---
 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




 


Rackspace

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