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

[win-pv-devel] [PATCH] Fix > 2TB disks


  • To: <win-pv-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Owen Smith <owen.smith@xxxxxxxxxx>
  • Date: Fri, 11 Oct 2019 14:51:10 +0100
  • Authentication-results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=owen.smith@xxxxxxxxxx; spf=Pass smtp.mailfrom=owen.smith@xxxxxxxxxx; spf=None smtp.helo=postmaster@xxxxxxxxxxxxxxx
  • Cc: Owen Smith <owen.smith@xxxxxxxxxx>
  • Delivery-date: Fri, 11 Oct 2019 13:51:49 +0000
  • Ironport-sdr: EGqATKSLYTxnHEW8DzfwgzXFCLbvj85KwbuyxPki7xbPZ8b4IaU9w1COwi/38mzymO8rIWiode FQER90s7f6J2QL9HJ0J/0xtluS6B2OFL7FVtliWcXujB+W/ZNsRjOKRax8liwPbV/Ip2rEHbbn zSujpjFHXA35KE2eUTz0S7QFU4iLEX+r/NcRJj/SJMg/D8rc1kBEjJmKGITYZZfPRRoWNPEo/e ICija1wkLTwPdfhCyVO9MNcIapp9s530zv3t2AVgvTfzILj/EewamoB13RVq1Fs5qndSBGG03E YkQ=
  • List-id: Developer list for the Windows PV Drivers subproject <win-pv-devel.lists.xenproject.org>

In order to determine the size of a disk, Windows will issue a
SCSIOP_READ_CAPACITY. Disks larger than 2TB will respond with a max LBA
of 0xFFFFFFFF, which causes Windows to issue a SCSIOP_READ_CAPACITY16.
The read capacity 16 is passed with a 12 byte buffer to be filled in
using the READ_CAPACITY_DATA_EX structure, not the 16 or 32byte
(depending on packing) READ_CAPACITY16_DATA buffer.
Also adds Error labels to the failure conditions.

Signed-off-by: Owen Smith <owen.smith@xxxxxxxxxx>
---
 src/xenvbd/target.c | 40 +++++++++++++++++++++++++++++++---------
 1 file changed, 31 insertions(+), 9 deletions(-)

diff --git a/src/xenvbd/target.c b/src/xenvbd/target.c
index e322949..4919db2 100644
--- a/src/xenvbd/target.c
+++ b/src/xenvbd/target.c
@@ -545,14 +545,14 @@ TargetReadCapacity(
     Srb->SrbStatus = SRB_STATUS_ERROR;
 
     if (Data == NULL)
-        return;
+        goto fail1;
     RtlZeroMemory(Data, Length);
 
     if (Length < sizeof(READ_CAPACITY_DATA))
-        return;
+        goto fail2;
 
     if (Cdb_PMI(Srb) == 0 && Cdb_LogicalBlock(Srb) != 0)
-        return;
+        goto fail3;
 
     SectorCount = DiskInfo->SectorCount;
     SectorSize = DiskInfo->SectorSize;
@@ -567,6 +567,15 @@ TargetReadCapacity(
 
     Srb->DataTransferLength = sizeof(READ_CAPACITY_DATA);
     Srb->SrbStatus = SRB_STATUS_SUCCESS;
+
+    return;
+
+fail3:
+    Error("fail3\n");
+fail2:
+    Error("fail2\n");
+fail1:
+    Error("fail1\n");
 }
 
 static DECLSPEC_NOINLINE VOID
@@ -587,14 +596,14 @@ TargetReadCapacity16(
     Srb->SrbStatus = SRB_STATUS_ERROR;
 
     if (Data == NULL)
-        return;
+        goto fail1;
     RtlZeroMemory(Data, Length);
 
-    if (Length < sizeof(READ_CAPACITY16_DATA))
-        return;
+    if (Length < sizeof(READ_CAPACITY_DATA_EX))
+        goto fail2;
 
     if (Cdb_PMI(Srb) == 0 && Cdb_LogicalBlock(Srb) != 0)
-        return;
+        goto fail3;
 
     SectorCount = DiskInfo->SectorCount;
     SectorSize = DiskInfo->SectorSize;
@@ -607,10 +616,23 @@ TargetReadCapacity16(
 
     Data->LogicalBlockAddress.QuadPart = _byteswap_uint64(SectorCount - 1);
     Data->BytesPerBlock = _byteswap_ulong(SectorSize);
-    Data->LogicalPerPhysicalExponent = (UCHAR)LogicalPerPhysicalExponent;
 
-    Srb->DataTransferLength = sizeof(READ_CAPACITY16_DATA);
+    if (Length == sizeof(READ_CAPACITY16_DATA))
+        Data->LogicalPerPhysicalExponent = (UCHAR)LogicalPerPhysicalExponent;
+    else
+        Length = sizeof(READ_CAPACITY_DATA_EX);
+
+    Srb->DataTransferLength = Length;
     Srb->SrbStatus = SRB_STATUS_SUCCESS;
+
+    return;
+
+fail3:
+    Error("fail3\n");
+fail2:
+    Error("fail2\n");
+fail1:
+    Error("fail1\n");
 }
 
 static FORCEINLINE VOID
-- 
2.16.2.windows.1


_______________________________________________
win-pv-devel mailing list
win-pv-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/win-pv-devel

 


Rackspace

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