win-pvdrivers

changeset 708:d7ad5ed2732f 0.10.0.143

Fix a problem with sign extension when the sector number is >0x7FFFFFFF
Add SCSIOP_VERIFY16 support.
author James Harper <james.harper@bendigoit.com.au>
date Fri Dec 11 12:23:20 2009 +1100 (2009-12-11)
parents 206cef08872a
children f94910bc765a
files xenvbd/xenvbd.c
line diff
     1.1 --- a/xenvbd/xenvbd.c	Tue Dec 08 21:44:54 2009 +1100
     1.2 +++ b/xenvbd/xenvbd.c	Fri Dec 11 12:23:20 2009 +1100
     1.3 @@ -278,10 +278,10 @@ decode_cdb_length(PSCSI_REQUEST_BLOCK sr
     1.4    {
     1.5    case SCSIOP_READ:
     1.6    case SCSIOP_WRITE:
     1.7 -    return (srb->Cdb[7] << 8) | srb->Cdb[8];
     1.8 +    return ((ULONG)(UCHAR)srb->Cdb[7] << 8) | (ULONG)(UCHAR)srb->Cdb[8];
     1.9    case SCSIOP_READ16:
    1.10    case SCSIOP_WRITE16:
    1.11 -    return (srb->Cdb[10] << 24) | (srb->Cdb[11] << 16) | (srb->Cdb[12] << 8) | srb->Cdb[13];    
    1.12 +    return ((ULONG)(UCHAR)srb->Cdb[10] << 24) | ((ULONG)(UCHAR)srb->Cdb[11] << 16) | ((ULONG)(UCHAR)srb->Cdb[12] << 8) | (ULONG)(UCHAR)srb->Cdb[13];    
    1.13    default:
    1.14      return 0;
    1.15    }
    1.16 @@ -296,14 +296,14 @@ decode_cdb_sector(PSCSI_REQUEST_BLOCK sr
    1.17    {
    1.18    case SCSIOP_READ:
    1.19    case SCSIOP_WRITE:
    1.20 -    sector = (srb->Cdb[2] << 24) | (srb->Cdb[3] << 16) | (srb->Cdb[4] << 8) | srb->Cdb[5];
    1.21 +    sector = ((ULONG)(UCHAR)srb->Cdb[2] << 24) | ((ULONG)(UCHAR)srb->Cdb[3] << 16) | ((ULONG)(UCHAR)srb->Cdb[4] << 8) | (ULONG)(UCHAR)srb->Cdb[5];
    1.22      break;
    1.23    case SCSIOP_READ16:
    1.24    case SCSIOP_WRITE16:
    1.25 -    sector = ((ULONGLONG)srb->Cdb[2] << 56) | ((ULONGLONG)srb->Cdb[3] << 48)
    1.26 -           | ((ULONGLONG)srb->Cdb[4] << 40) | ((ULONGLONG)srb->Cdb[5] << 32)
    1.27 -           | ((ULONGLONG)srb->Cdb[6] << 24) | ((ULONGLONG)srb->Cdb[7] << 16)
    1.28 -           | ((ULONGLONG)srb->Cdb[8] << 8) | ((ULONGLONG)srb->Cdb[9]);
    1.29 +    sector = ((ULONGLONG)(UCHAR)srb->Cdb[2] << 56) | ((ULONGLONG)(UCHAR)srb->Cdb[3] << 48)
    1.30 +           | ((ULONGLONG)(UCHAR)srb->Cdb[4] << 40) | ((ULONGLONG)(UCHAR)srb->Cdb[5] << 32)
    1.31 +           | ((ULONGLONG)(UCHAR)srb->Cdb[6] << 24) | ((ULONGLONG)(UCHAR)srb->Cdb[7] << 16)
    1.32 +           | ((ULONGLONG)(UCHAR)srb->Cdb[8] << 8) | ((ULONGLONG)(UCHAR)srb->Cdb[9]);
    1.33      //KdPrint((__DRIVER_NAME "     sector_number = %d (high) %d (low)\n", (ULONG)(sector >> 32), (ULONG)sector));
    1.34      break;
    1.35    default:
    1.36 @@ -1123,6 +1123,7 @@ XenVbd_HwScsiStartIo(PVOID DeviceExtensi
    1.37        XenVbd_PutSrbOnRing(xvdd, Srb);
    1.38        break;
    1.39      case SCSIOP_VERIFY:
    1.40 +    case SCSIOP_VERIFY16:
    1.41        // Should we do more here?
    1.42        if (dump_mode)
    1.43          KdPrint((__DRIVER_NAME "     Command = VERIFY\n"));