Print this page
MFV: illumos-gate@fd6d41c5025e9fb45a115fc82d86e9983d1e9fd6
9815 Want basic AHCI enclosure services
Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>
Reviewed by: Rob Johnston <rob.johnston@joyent.com>
Reviewed by: Yuri Pankov <yuripv@yuripv.net>
Approved by: Dan McDonald <danmcd@joyent.com>
Author: Robert Mustacchi <rm@joyent.com>
Conflicts:
        usr/src/cmd/Makefile
NEX-5834 panic in sata module while running trim
Reviewed by: Dan Fields <dan.fields@nexenta.com>
Reviewed by: Roman Strashkin <roman.strashkin@nexenta.com>
NEX-4418 SATA inquiry property generation doesn't work as advertised
Reviewed by: Dan McDonald <danmcd@omniti.com>
Reviewed by: Garrett D'Amore <garrett@damore.org>
Reviewed by: Josef 'Jeff' Sipek <josef.sipek@nexenta.com>
1787 SATL fails to handle returned SMART sense data
Reviewed by: Richard Elling <richard.elling@richardelling.com>
Reviewed by: Saso Kiselkov <skiselkov.ml@gmail.com>
Reviewed by: Garrett D'Amore <garrett@damore.org>
Approved by: Robert Mustacchi <rm@joyent.com>
re #12164 Marvell 88SE9128: Appliance hard hangs on boot probing duplicated ahci device

@@ -19,14 +19,13 @@
  * CDDL HEADER END
  */
 
 /*
  * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
- */
-/*
- * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
+ * Copyright 2016 Nexenta Systems, Inc.
  * Copyright 2016 Argo Technologies SA
+ * Copyright (c) 2018, Joyent, Inc.
  */
 
 /*
  * SATA Framework
  * Generic SATA Host Adapter Implementation

@@ -1347,11 +1346,12 @@
                  */
                 return (ndi_devctl_ioctl(dip, cmd, arg, mode, 0));
         }
 
         /* read devctl ioctl data */
-        if (cmd != DEVCTL_AP_CONTROL) {
+        if (cmd != DEVCTL_AP_CONTROL && cmd >= DEVCTL_IOC &&
+            cmd <= DEVCTL_IOC_MAX) {
                 if (ndi_dc_allochdl((void *)arg, &dcp) != NDI_SUCCESS)
                         return (EFAULT);
 
                 if ((comp_port = sata_get_port_num(sata_hba_inst, dcp)) ==
                     -1) {

@@ -1675,13 +1675,17 @@
         } /* End of main IOCTL switch */
 
         if (dcp) {
                 ndi_dc_freehdl(dcp);
         }
-        mutex_enter(&SATA_CPORT_INFO(sata_hba_inst, cport)->cport_mutex);
+
+        if (cmd >= DEVCTL_IOC && cmd <= DEVCTL_IOC_MAX) {
+                mutex_enter(&SATA_CPORT_INFO(sata_hba_inst,
+                    cport)->cport_mutex);
         cportinfo->cport_event_flags &= ~SATA_APCTL_LOCK_PORT_BUSY;
         mutex_exit(&SATA_CPORT_INFO(sata_hba_inst, cport)->cport_mutex);
+        }
 
         return (rv);
 }
 
 

@@ -4843,11 +4847,11 @@
          * The block descriptor size has to be a multiple of 16 bytes.
          */
         bdlen = scsipkt->pkt_cdbp[7];
         bdlen = (bdlen << 8) + scsipkt->pkt_cdbp[8] - paramlen;
         if ((bdlen < 0) || ((bdlen % 16) != 0) ||
-            (bdlen > (bp->b_bcount - paramlen))) {
+            ((bp != NULL) && (bdlen > (bp->b_bcount - paramlen)))) {
                 SATADBG1(SATA_DBG_SCSI_IF, spx->txlt_sata_hba_inst,
                     "sata_txlt_unmap: invalid block descriptor length", NULL);
                 mutex_exit(cport_mutex);
                 return ((sata_txlt_check_condition(spx, KEY_ILLEGAL_REQUEST,
                     SD_SCSI_ASC_INVALID_FIELD_IN_CDB)));