From owner-svn-src-stable-11@freebsd.org Mon Aug 5 00:32:58 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 985D0B5E95; Mon, 5 Aug 2019 00:32:58 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 461zJB3F17z43RH; Mon, 5 Aug 2019 00:32:58 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 50B46BAA7; Mon, 5 Aug 2019 00:32:58 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x750WwJN080602; Mon, 5 Aug 2019 00:32:58 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x750WwOg080601; Mon, 5 Aug 2019 00:32:58 GMT (envelope-from cy@FreeBSD.org) Message-Id: <201908050032.x750WwOg080601@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Mon, 5 Aug 2019 00:32:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r350577 - in stable: 11/sys/contrib/ipfilter/netinet 12/sys/contrib/ipfilter/netinet X-SVN-Group: stable-11 X-SVN-Commit-Author: cy X-SVN-Commit-Paths: in stable: 11/sys/contrib/ipfilter/netinet 12/sys/contrib/ipfilter/netinet X-SVN-Commit-Revision: 350577 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Aug 2019 00:32:58 -0000 Author: cy Date: Mon Aug 5 00:32:57 2019 New Revision: 350577 URL: https://svnweb.freebsd.org/changeset/base/350577 Log: MFC r350548: #include whitespace adjustments. Modified: stable/11/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c Directory Properties: stable/11/ (props changed) Changes in other areas also in this revision: Modified: stable/12/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c Directory Properties: stable/12/ (props changed) Modified: stable/11/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c ============================================================================== --- stable/11/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c Mon Aug 5 00:08:25 2019 (r350576) +++ stable/11/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c Mon Aug 5 00:32:57 2019 (r350577) @@ -28,24 +28,24 @@ static const char rcsid[] = "@(#)$Id$"; #include #include #include -# include -# include +#include +#include #include #include # include #if defined(__FreeBSD_version) #include #endif -# include -# include -# include +#include +#include +#include #include -# include -# include +#include +#include #include -# include -# include +#include +#include #include #include #include @@ -75,7 +75,7 @@ static const char rcsid[] = "@(#)$Id$"; #include "netinet/ip_scan.h" #endif #include "netinet/ip_pool.h" -# include +#include #include #ifdef CSUM_DATA_VALID #include From owner-svn-src-stable-11@freebsd.org Mon Aug 5 07:50:26 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6C71DBC9C3; Mon, 5 Aug 2019 07:50:26 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46290y2CFjz4LmD; Mon, 5 Aug 2019 07:50:26 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2EAE71897E; Mon, 5 Aug 2019 07:50:26 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x757oQwj036824; Mon, 5 Aug 2019 07:50:26 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x757oPVo036820; Mon, 5 Aug 2019 07:50:25 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201908050750.x757oPVo036820@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Mon, 5 Aug 2019 07:50:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r350583 - stable/11/sys/netpfil/ipfw X-SVN-Group: stable-11 X-SVN-Commit-Author: ae X-SVN-Commit-Paths: stable/11/sys/netpfil/ipfw X-SVN-Commit-Revision: 350583 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Aug 2019 07:50:26 -0000 Author: ae Date: Mon Aug 5 07:50:25 2019 New Revision: 350583 URL: https://svnweb.freebsd.org/changeset/base/350583 Log: MFC r350417: Add ipfw_get_action() function to get the pointer to action opcode. ACTION_PTR() returns pointer to the start of rule action section, but rule can keep several rule modifiers like O_LOG, O_TAG and O_ALTQ, and only then real action opcode is stored. ipfw_get_action() function inspects the rule action section, skips all modifiers and returns action opcode. Use this function in ipfw_reset_eaction() and flush_nat_ptrs(). Modified: stable/11/sys/netpfil/ipfw/ip_fw_eaction.c stable/11/sys/netpfil/ipfw/ip_fw_nat.c stable/11/sys/netpfil/ipfw/ip_fw_private.h stable/11/sys/netpfil/ipfw/ip_fw_sockopt.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/netpfil/ipfw/ip_fw_eaction.c ============================================================================== --- stable/11/sys/netpfil/ipfw/ip_fw_eaction.c Mon Aug 5 07:49:02 2019 (r350582) +++ stable/11/sys/netpfil/ipfw/ip_fw_eaction.c Mon Aug 5 07:50:25 2019 (r350583) @@ -377,33 +377,30 @@ ipfw_reset_eaction(struct ip_fw_chain *ch, struct ip_f uint16_t eaction_id, uint16_t default_id, uint16_t instance_id) { ipfw_insn *cmd, *icmd; - int l, cmdlen; + int l; IPFW_UH_WLOCK_ASSERT(ch); IPFW_WLOCK_ASSERT(ch); - cmd = ACTION_PTR(rule); - l = rule->cmd_len - rule->act_ofs; - while (l > 0) { - cmdlen = F_LEN(cmd); - l -= cmdlen; - if (cmd->opcode == O_EXTERNAL_ACTION || l <= 0) - break; - cmd += cmdlen; - } /* * Return if there is not O_EXTERNAL_ACTION or its id is * different. */ + cmd = ipfw_get_action(rule); if (cmd->opcode != O_EXTERNAL_ACTION || cmd->arg1 != eaction_id) return (0); /* * If instance_id is specified, we need to truncate the * rule length. Check if there is O_EXTERNAL_INSTANCE opcode. + * + * NOTE: F_LEN(cmd) must be 1 for O_EXTERNAL_ACTION opcode, + * and rule length should be enough to keep O_EXTERNAL_INSTANCE + * opcode, thus we do check for l > 1. */ - if (instance_id != 0 && l > 0) { - MPASS(cmdlen == 1); + l = rule->cmd + rule->cmd_len - cmd; + if (instance_id != 0 && l > 1) { + MPASS(F_LEN(cmd) == 1); icmd = cmd + 1; if (icmd->opcode != O_EXTERNAL_INSTANCE || icmd->arg1 != instance_id) @@ -415,8 +412,9 @@ ipfw_reset_eaction(struct ip_fw_chain *ch, struct ip_f * opcode. */ EACTION_DEBUG("truncate rule %d: len %u -> %u", - rule->rulenum, rule->cmd_len, rule->cmd_len - l); - rule->cmd_len -= l; + rule->rulenum, rule->cmd_len, + rule->cmd_len - F_LEN(icmd)); + rule->cmd_len -= F_LEN(icmd); MPASS(((uint32_t *)icmd - (uint32_t *)rule->cmd) == rule->cmd_len); } Modified: stable/11/sys/netpfil/ipfw/ip_fw_nat.c ============================================================================== --- stable/11/sys/netpfil/ipfw/ip_fw_nat.c Mon Aug 5 07:49:02 2019 (r350582) +++ stable/11/sys/netpfil/ipfw/ip_fw_nat.c Mon Aug 5 07:50:25 2019 (r350583) @@ -139,13 +139,12 @@ ifaddr_change(void *arg __unused, struct ifnet *ifp) static void flush_nat_ptrs(struct ip_fw_chain *chain, const int ix) { - int i; ipfw_insn_nat *cmd; + int i; IPFW_WLOCK_ASSERT(chain); for (i = 0; i < chain->n_rules; i++) { - cmd = (ipfw_insn_nat *)ACTION_PTR(chain->map[i]); - /* XXX skip log and the like ? */ + cmd = (ipfw_insn_nat *)ipfw_get_action(chain->map[i]); if (cmd->o.opcode == O_NAT && cmd->nat != NULL && (ix < 0 || cmd->nat->id == ix)) cmd->nat = NULL; Modified: stable/11/sys/netpfil/ipfw/ip_fw_private.h ============================================================================== --- stable/11/sys/netpfil/ipfw/ip_fw_private.h Mon Aug 5 07:49:02 2019 (r350582) +++ stable/11/sys/netpfil/ipfw/ip_fw_private.h Mon Aug 5 07:50:25 2019 (r350583) @@ -674,6 +674,7 @@ struct ip_fw *ipfw_alloc_rule(struct ip_fw_chain *chai void ipfw_free_rule(struct ip_fw *rule); int ipfw_match_range(struct ip_fw *rule, ipfw_range_tlv *rt); int ipfw_mark_object_kidx(uint32_t *bmask, uint16_t etlv, uint16_t kidx); +ipfw_insn *ipfw_get_action(struct ip_fw *); typedef int (sopt_handler_f)(struct ip_fw_chain *ch, ip_fw3_opheader *op3, struct sockopt_data *sd); Modified: stable/11/sys/netpfil/ipfw/ip_fw_sockopt.c ============================================================================== --- stable/11/sys/netpfil/ipfw/ip_fw_sockopt.c Mon Aug 5 07:49:02 2019 (r350582) +++ stable/11/sys/netpfil/ipfw/ip_fw_sockopt.c Mon Aug 5 07:50:25 2019 (r350583) @@ -1217,6 +1217,35 @@ move_range(struct ip_fw_chain *chain, ipfw_range_tlv * } /* + * Returns pointer to action instruction, skips all possible rule + * modifiers like O_LOG, O_TAG, O_ALTQ. + */ +ipfw_insn * +ipfw_get_action(struct ip_fw *rule) +{ + ipfw_insn *cmd; + int l, cmdlen; + + cmd = ACTION_PTR(rule); + l = rule->cmd_len - rule->act_ofs; + while (l > 0) { + switch (cmd->opcode) { + case O_ALTQ: + case O_LOG: + case O_TAG: + break; + default: + return (cmd); + } + cmdlen = F_LEN(cmd); + l -= cmdlen; + cmd += cmdlen; + } + panic("%s: rule (%p) has not action opcode", __func__, rule); + return (NULL); +} + +/* * Clear counters for a specific rule. * Normally run under IPFW_UH_RLOCK, but these are idempotent ops * so we only care that rules do not disappear. From owner-svn-src-stable-11@freebsd.org Mon Aug 5 20:21:36 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 30249AC534; Mon, 5 Aug 2019 20:21:36 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 462Tgh05P3z49pf; Mon, 5 Aug 2019 20:21:36 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D8CA92109F; Mon, 5 Aug 2019 20:21:35 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x75KLZpT089163; Mon, 5 Aug 2019 20:21:35 GMT (envelope-from jilles@FreeBSD.org) Received: (from jilles@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x75KLZdD089162; Mon, 5 Aug 2019 20:21:35 GMT (envelope-from jilles@FreeBSD.org) Message-Id: <201908052021.x75KLZdD089162@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jilles set sender to jilles@FreeBSD.org using -f From: Jilles Tjoelker Date: Mon, 5 Aug 2019 20:21:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r350615 - stable/11/usr.bin/printf X-SVN-Group: stable-11 X-SVN-Commit-Author: jilles X-SVN-Commit-Paths: stable/11/usr.bin/printf X-SVN-Commit-Revision: 350615 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Aug 2019 20:21:36 -0000 Author: jilles Date: Mon Aug 5 20:21:35 2019 New Revision: 350615 URL: https://svnweb.freebsd.org/changeset/base/350615 Log: MFC r350425: printf(1): Note that \c only works in %b strings PR: 238313 Modified: stable/11/usr.bin/printf/printf.1 Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/printf/printf.1 ============================================================================== --- stable/11/usr.bin/printf/printf.1 Mon Aug 5 20:20:14 2019 (r350614) +++ stable/11/usr.bin/printf/printf.1 Mon Aug 5 20:21:35 2019 (r350615) @@ -31,7 +31,7 @@ .\" @(#)printf.1 8.1 (Berkeley) 6/6/93 .\" $FreeBSD$ .\" -.Dd April 21, 2014 +.Dd July 29, 2019 .Dt PRINTF 1 .Os .Sh NAME @@ -87,8 +87,6 @@ are as follows: Write a character. .It Cm \eb Write a character. -.It Cm \ec -Ignore remaining characters in this string. .It Cm \ef Write a character. .It Cm \en @@ -289,7 +287,12 @@ The permitted escape sequences are slightly different octal escapes are .Cm \e0 Ns Ar num instead of -.Cm \e Ns Ar num . +.Cm \e Ns Ar num +and that an additional escape sequence +.Cm \ec +stops further output from this +.Nm +invocation. .It Cm n$ Allows reordering of the output according to .Ar argument . From owner-svn-src-stable-11@freebsd.org Mon Aug 5 22:04:17 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4511BAEEBB; Mon, 5 Aug 2019 22:04:17 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 462Wy919tMz4J4l; Mon, 5 Aug 2019 22:04:17 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0AF0E22406; Mon, 5 Aug 2019 22:04:17 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x75M4GYb054897; Mon, 5 Aug 2019 22:04:16 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x75M4Gap054896; Mon, 5 Aug 2019 22:04:16 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201908052204.x75M4Gap054896@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Mon, 5 Aug 2019 22:04:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r350619 - in stable: 11/usr.sbin/bhyve 12/usr.sbin/bhyve X-SVN-Group: stable-11 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: in stable: 11/usr.sbin/bhyve 12/usr.sbin/bhyve X-SVN-Commit-Revision: 350619 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Aug 2019 22:04:17 -0000 Author: jhb Date: Mon Aug 5 22:04:16 2019 New Revision: 350619 URL: https://svnweb.freebsd.org/changeset/base/350619 Log: MFC 350618: Validate guest-supplied length of headers for TSO transmit requests. When transmitting a large TCP packet, the final transmit descriptor includes the length of the protocol headers to be duplicated on each segment. The device model was trusting the guest-supplied value without validating it. A value of zero would result in the guest being able to indirect a garbage pointer on the stack to overwrite arbitrary memory in the bhyve process. A value that was non-zero but too small for the requested parameters resulted in the device model reading and writing values beyond the end of the on-stack buffer used to hold the template header. To fix, validate the supplied length and drop requests to transmit packets that would overflow the header buffer. While here, initialize the header pointer to NULL as a preventive measure so that any access to an unallocated template header crashes they hypervisor deterministically. While here, only read the TCP sequence number if the packet being split is a TCP packet. The e1000 logic supports a segmentation of UDP frames, and while UDP segmentation requires this part of the header to be valid (so there is no buffer overflow), only reading the field when needed is cleaner. admbugs: 918 Reported by: Reno Robert Approved by: so Security: CVE-2019-5609 Modified: stable/11/usr.sbin/bhyve/pci_e82545.c Directory Properties: stable/11/ (props changed) Changes in other areas also in this revision: Modified: stable/12/usr.sbin/bhyve/pci_e82545.c Directory Properties: stable/12/ (props changed) Modified: stable/11/usr.sbin/bhyve/pci_e82545.c ============================================================================== --- stable/11/usr.sbin/bhyve/pci_e82545.c Mon Aug 5 21:39:55 2019 (r350618) +++ stable/11/usr.sbin/bhyve/pci_e82545.c Mon Aug 5 22:04:16 2019 (r350619) @@ -1079,8 +1079,9 @@ e82545_transmit(struct e82545_softc *sc, uint16_t head struct ck_info ckinfo[2]; struct iovec *iov; union e1000_tx_udesc *dsc; - int desc, dtype, len, ntype, iovcnt, tlen, hdrlen, vlen, tcp, tso; + int desc, dtype, len, ntype, iovcnt, tlen, tcp, tso; int mss, paylen, seg, tiovcnt, left, now, nleft, nnow, pv, pvoff; + unsigned hdrlen, vlen; uint32_t tcpsum, tcpseq; uint16_t ipcs, tcpcs, ipid, ohead; @@ -1224,6 +1225,68 @@ e82545_transmit(struct e82545_softc *sc, uint16_t head } else { /* In case of TSO header length provided by software. */ hdrlen = sc->esc_txctx.tcp_seg_setup.fields.hdr_len; + + /* + * Cap the header length at 240 based on 7.2.4.5 of + * the Intel 82576EB (Rev 2.63) datasheet. + */ + if (hdrlen > 240) { + WPRINTF("TSO hdrlen too large: %d\r\n", hdrlen); + goto done; + } + + /* + * If VLAN insertion is requested, ensure the header + * at least holds the amount of data copied during + * VLAN insertion below. + * + * XXX: Realistic packets will include a full Ethernet + * header before the IP header at ckinfo[0].ck_start, + * but this check is sufficient to prevent + * out-of-bounds access below. + */ + if (vlen != 0 && hdrlen < ETHER_ADDR_LEN*2) { + WPRINTF("TSO hdrlen too small for vlan insertion " + "(%d vs %d) -- dropped\r\n", hdrlen, + ETHER_ADDR_LEN*2); + goto done; + } + + /* + * Ensure that the header length covers the used fields + * in the IP and TCP headers as well as the IP and TCP + * checksums. The following fields are accessed below: + * + * Header | Field | Offset | Length + * -------+-------+--------+------- + * IPv4 | len | 2 | 2 + * IPv4 | ID | 4 | 2 + * IPv6 | len | 4 | 2 + * TCP | seq # | 4 | 4 + * TCP | flags | 13 | 1 + * UDP | len | 4 | 4 + */ + if (hdrlen < ckinfo[0].ck_start + 6 || + hdrlen < ckinfo[0].ck_off + 2) { + WPRINTF("TSO hdrlen too small for IP fields (%d) " + "-- dropped\r\n", hdrlen); + goto done; + } + if (sc->esc_txctx.cmd_and_length & E1000_TXD_CMD_TCP) { + if (hdrlen < ckinfo[1].ck_start + 14 || + (ckinfo[1].ck_valid && + hdrlen < ckinfo[1].ck_off + 2)) { + WPRINTF("TSO hdrlen too small for TCP fields " + "(%d) -- dropped\r\n", hdrlen); + goto done; + } + } else { + if (hdrlen < ckinfo[1].ck_start + 8) { + WPRINTF("TSO hdrlen too small for UDP fields " + "(%d) -- dropped\r\n", hdrlen); + goto done; + } + } } /* Allocate, fill and prepend writable header vector. */ @@ -1245,7 +1308,8 @@ e82545_transmit(struct e82545_softc *sc, uint16_t head iovcnt++; iov->iov_base = hdr; iov->iov_len = hdrlen; - } + } else + hdr = NULL; /* Insert VLAN tag. */ if (vlen != 0) { @@ -1287,7 +1351,9 @@ e82545_transmit(struct e82545_softc *sc, uint16_t head DPRINTF("tx %s segmentation offload %d+%d/%d bytes %d iovs\r\n", tcp ? "TCP" : "UDP", hdrlen, paylen, mss, iovcnt); ipid = ntohs(*(uint16_t *)&hdr[ckinfo[0].ck_start + 4]); - tcpseq = ntohl(*(uint32_t *)&hdr[ckinfo[1].ck_start + 4]); + tcpseq = 0; + if (tcp) + tcpseq = ntohl(*(uint32_t *)&hdr[ckinfo[1].ck_start + 4]); ipcs = *(uint16_t *)&hdr[ckinfo[0].ck_off]; tcpcs = 0; if (ckinfo[1].ck_valid) /* Save partial pseudo-header checksum. */ From owner-svn-src-stable-11@freebsd.org Tue Aug 6 12:31:40 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1C6CEC1586; Tue, 6 Aug 2019 12:31:40 +0000 (UTC) (envelope-from slw@zxy.spb.ru) Received: from zxy.spb.ru (zxy.spb.ru [195.70.199.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 462vBy4Pvjz40Wv; Tue, 6 Aug 2019 12:31:38 +0000 (UTC) (envelope-from slw@zxy.spb.ru) Received: from slw by zxy.spb.ru with local (Exim 4.86 (FreeBSD)) (envelope-from ) id 1huych-000NlR-6o; Tue, 06 Aug 2019 15:31:27 +0300 Date: Tue, 6 Aug 2019 15:31:27 +0300 From: Slawa Olhovchenkov To: Baptiste Daroussin Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: Re: svn commit: r350402 - stable/11/cddl/contrib/opensolaris/lib/libzfs/common Message-ID: <20190806123127.GM47119@zxy.spb.ru> References: <201907290823.x6T8NFAu064976@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201907290823.x6T8NFAu064976@repo.freebsd.org> User-Agent: Mutt/1.5.24 (2015-08-30) X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: slw@zxy.spb.ru X-SA-Exim-Scanned: No (on zxy.spb.ru); SAEximRunCond expanded to false X-Rspamd-Queue-Id: 462vBy4Pvjz40Wv X-Spamd-Bar: / Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=none (mx1.freebsd.org: domain of slw@zxy.spb.ru has no SPF policy when checking 195.70.199.98) smtp.mailfrom=slw@zxy.spb.ru X-Spamd-Result: default: False [0.93 / 15.00]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; RCVD_TLS_LAST(0.00)[]; DMARC_NA(0.00)[zxy.spb.ru]; AUTH_NA(1.00)[]; RCPT_COUNT_FIVE(0.00)[5]; NEURAL_SPAM_MEDIUM(0.33)[0.334,0]; IP_SCORE(0.00)[country: RU(0.01)]; NEURAL_HAM_SHORT(-0.46)[-0.461,0]; NEURAL_SPAM_LONG(0.16)[0.161,0]; R_SPF_NA(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:5495, ipnet:195.70.192.0/19, country:RU]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2] X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Aug 2019 12:31:40 -0000 On Mon, Jul 29, 2019 at 08:23:15AM +0000, Baptiste Daroussin wrote: still broken: # ls -l /poudriere/ports/default ls: /poudriere/ports/default: No such file or directory # zfs list NAME USED AVAIL REFER MOUNTPOINT DB 256G 643G 96K /DB DB/var 255G 643G 96K /DB/var DB/var/db 255G 643G 96K /DB/var/db DB/var/db/mysql 255G 643G 255G /var/db/mysql DB/var/db/mysql/MyISAM 96K 643G 96K /var/db/mysql/MyISAM DB/var/db/mysql/innodb-logs 128M 643G 128M /var/db/mysql/innodb-logs zroot 2.94T 551G 112K /ZROOT zroot/ROOT 352M 551G 352M / zroot/home 144K 551G 144K legacy zroot/poudriere 5.41G 551G 128K /poudriere zroot/poudriere/data 608M 551G 608M /poudriere/data zroot/poudriere/jails 2.71G 551G 128K /poudriere/jails zroot/poudriere/jails/10amd64 2.71G 551G 2.71G /poudriere/jails/10amd64 zroot/poudriere/ports 2.10G 551G 96K /poudriere/ports zroot/poudriere/ports/default 2.10G 551G 2.10G /poudriere/ports/default zroot/tmp 6.94G 551G 6.94G /tmp zroot/usr 630G 551G 57.0G /usr zroot/usr/local 543G 551G 543G /usr/local zroot/usr/obj 19.2G 551G 19.2G /usr/obj zroot/usr/ports 4.80G 551G 1.07G /usr/ports zroot/usr/ports/distfiles 3.72G 551G 3.72G /usr/ports/distfiles zroot/usr/ports/packages 7.04M 551G 7.04M /usr/ports/packages zroot/usr/src 5.51G 551G 5.51G /usr/src zroot/var 345G 551G 1.10G /var zroot/var/crash 148K 551G 148K /var/crash zroot/var/db 58.4G 551G 3.92G /var/db zroot/var/db/mysql 54.4G 551G 54.2G /var/db/mysql zroot/var/db/mysql/MyISAM 144K 551G 144K /var/db/mysql/MyISAM zroot/var/db/mysql/innodb-logs 128M 551G 128M /var/db/mysql/innodb-logs zroot/var/db/pkg 69.6M 551G 69.6M /var/db/pkg zroot/var/empty 144K 551G 144K /var/empty zroot/var/log 248G 551G 248G /var/log zroot/var/mail 148K 551G 148K /var/mail zroot/var/run 444K 551G 444K /var/run zroot/var/spool 37.3G 551G 37.3G /var/spool zroot/var/tmp 548K 551G 548K /var/tmp zroot/www 1.98T 551G 160K /www zroot/www/dev0 1.59G 551G 1.59G /www/dev0 zroot/www/dev1 1.48G 551G 1.48G /www/dev1 zroot/www/dev2 1.48G 551G 1.48G /www/dev2 zroot/www/dev3 1.59G 551G 1.59G /www/dev3 zroot/www/dev4 1.49G 551G 1.49G /www/dev4 zroot/www/dev5 1.47G 551G 1.47G /www/dev5 zroot/www/komandirovka 186G 551G 30.9G /www/komandirovka zroot/www/komandirovka_old 1.79T 551G 1.79T /www/komandirovka_old > Author: bapt > Date: Mon Jul 29 08:23:15 2019 > New Revision: 350402 > URL: https://svnweb.freebsd.org/changeset/base/350402 > > Log: > MFC r350358: > > Fix a bug introduced with parallel mounting of zfs > > Incorporate a fix from zol: > https://github.com/zfsonlinux/zfs/commit/ab5036df1ccbe1b18c1ce6160b5829e8039d94ce > > commit log from upstream: > Fix race in parallel mount's thread dispatching algorithm > > Strategy of parallel mount is as follows. > > 1) Initial thread dispatching is to select sets of mount points that > don't have dependencies on other sets, hence threads can/should run > lock-less and shouldn't race with other threads for other sets. Each > thread dispatched corresponds to top level directory which may or may > not have datasets to be mounted on sub directories. > > 2) Subsequent recursive thread dispatching for each thread from 1) > is to mount datasets for each set of mount points. The mount points > within each set have dependencies (i.e. child directories), so child > directories are processed only after parent directory completes. > > The problem is that the initial thread dispatching in > zfs_foreach_mountpoint() can be multi-threaded when it needs to be > single-threaded, and this puts threads under race condition. This race > appeared as mount/unmount issues on ZoL for ZoL having different > timing regarding mount(2) execution due to fork(2)/exec(2) of mount(8). > `zfs unmount -a` which expects proper mount order can't unmount if the > mounts were reordered by the race condition. > > There are currently two known patterns of input list `handles` in > `zfs_foreach_mountpoint(..,handles,..)` which cause the race condition. > > 1) #8833 case where input is `/a /a /a/b` after sorting. > The problem is that libzfs_path_contains() can't correctly handle an > input list with two same top level directories. > There is a race between two POSIX threads A and B, > * ThreadA for "/a" for test1 and "/a/b" > * ThreadB for "/a" for test0/a > and in case of #8833, ThreadA won the race. Two threads were created > because "/a" wasn't considered as `"/a" contains "/a"`. > > 2) #8450 case where input is `/ /var/data /var/data/test` after sorting. > The problem is that libzfs_path_contains() can't correctly handle an > input list containing "/". > There is a race between two POSIX threads A and B, > * ThreadA for "/" and "/var/data/test" > * ThreadB for "/var/data" > and in case of #8450, ThreadA won the race. Two threads were created > because "/var/data" wasn't considered as `"/" contains "/var/data"`. > In other words, if there is (at least one) "/" in the input list, > the initial thread dispatching must be single-threaded since every > directory is a child of "/", meaning they all directly or indirectly > depend on "/". > > In both cases, the first non_descendant_idx() call fails to correctly > determine "path1-contains-path2", and as a result the initial thread > dispatching creates another thread when it needs to be single-threaded. > Fix a conditional in libzfs_path_contains() to consider above two. > > Reviewed-by: Brian Behlendorf > Reviewed by: Sebastien Roy > Signed-off-by: Tomohiro Kusumi > > PR: 237517, 237397, 239243 > Submitted by: Matthew D. Fuller (by email) > > Modified: > stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c > Directory Properties: > stable/11/ (props changed) > > Modified: stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c > ============================================================================== > --- stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c Mon Jul 29 08:14:35 2019 (r350401) > +++ stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c Mon Jul 29 08:23:15 2019 (r350402) > @@ -1281,12 +1281,14 @@ mountpoint_cmp(const void *arga, const void *argb) > } > > /* > - * Reutrn true if path2 is a child of path1 > + * Return true if path2 is a child of path1 or path2 equals path1 or > + * path1 is "/" (path2 is always a child of "/"). > */ > static boolean_t > libzfs_path_contains(const char *path1, const char *path2) > { > - return (strstr(path2, path1) == path2 && path2[strlen(path1)] == '/'); > + return (strcmp(path1, path2) == 0 || strcmp(path1, "/") == 0 || > + (strstr(path2, path1) == path2 && path2[strlen(path1)] == '/')); > } > > > _______________________________________________ > svn-src-all@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/svn-src-all > To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org" From owner-svn-src-stable-11@freebsd.org Tue Aug 6 16:12:43 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D2327C4CAB; Tue, 6 Aug 2019 16:12:43 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4630635Dn8z49xC; Tue, 6 Aug 2019 16:12:43 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 954312E81D; Tue, 6 Aug 2019 16:12:43 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x76GChBE007363; Tue, 6 Aug 2019 16:12:43 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x76GChOd007362; Tue, 6 Aug 2019 16:12:43 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201908061612.x76GChOd007362@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Tue, 6 Aug 2019 16:12:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r350638 - stable/11/contrib/bsnmp/lib X-SVN-Group: stable-11 X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: stable/11/contrib/bsnmp/lib X-SVN-Commit-Revision: 350638 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Aug 2019 16:12:43 -0000 Author: emaste Date: Tue Aug 6 16:12:43 2019 New Revision: 350638 URL: https://svnweb.freebsd.org/changeset/base/350638 Log: MFC r350635: bsnmp: add asn1 message length validation admbugs: 780 Submitted by: Guido Vranken, bz Reported by: Guido Vranken Approved by: so Security: CVE-2019-5610 Modified: stable/11/contrib/bsnmp/lib/asn1.c Directory Properties: stable/11/ (props changed) Modified: stable/11/contrib/bsnmp/lib/asn1.c ============================================================================== --- stable/11/contrib/bsnmp/lib/asn1.c Tue Aug 6 16:11:16 2019 (r350637) +++ stable/11/contrib/bsnmp/lib/asn1.c Tue Aug 6 16:12:43 2019 (r350638) @@ -100,6 +100,11 @@ asn_get_header(struct asn_buf *b, u_char *type, asn_le *len = *b->asn_cptr++; b->asn_len--; } + if (*len > b->asn_len) { + asn_error(b, "len %u exceeding asn_len %u", *len, b->asn_len); + return (ASN_ERR_EOBUF); + } + return (ASN_ERR_OK); } From owner-svn-src-stable-11@freebsd.org Tue Aug 6 17:15:47 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 222E3C606A; Tue, 6 Aug 2019 17:15:47 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4631Vq04rJz4FMx; Tue, 6 Aug 2019 17:15:47 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D87EA2F2F5; Tue, 6 Aug 2019 17:15:46 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x76HFkiK044210; Tue, 6 Aug 2019 17:15:46 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x76HFkgR044209; Tue, 6 Aug 2019 17:15:46 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201908061715.x76HFkgR044209@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Tue, 6 Aug 2019 17:15:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r350650 - stable/11/sys/netinet6 X-SVN-Group: stable-11 X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: stable/11/sys/netinet6 X-SVN-Commit-Revision: 350650 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Aug 2019 17:15:47 -0000 Author: emaste Date: Tue Aug 6 17:15:46 2019 New Revision: 350650 URL: https://svnweb.freebsd.org/changeset/base/350650 Log: MFC r350645: Correct ICMPv6/MLDv2 out-of-bounds memory access Previously the ICMPv6 input path incorrectly handled cases where an MLDv2 listener query packet was internally fragmented across multiple mbufs. admbugs: 921 Submitted by: jtl Reported by: CJD of Apple Approved by: so MFC after: 0 minutes Security: CVE-2019-5608 Modified: stable/11/sys/netinet6/mld6.c Modified: stable/11/sys/netinet6/mld6.c ============================================================================== --- stable/11/sys/netinet6/mld6.c Tue Aug 6 17:14:09 2019 (r350649) +++ stable/11/sys/netinet6/mld6.c Tue Aug 6 17:15:46 2019 (r350650) @@ -137,14 +137,15 @@ static int mld_v2_enqueue_group_record(struct mbufq *, struct in6_multi *, const int, const int, const int, const int); static int mld_v2_input_query(struct ifnet *, const struct ip6_hdr *, - struct mbuf *, const int, const int); + struct mbuf *, struct mldv2_query *, const int, const int); static int mld_v2_merge_state_changes(struct in6_multi *, struct mbufq *); static void mld_v2_process_group_timers(struct mld_ifsoftc *, struct mbufq *, struct mbufq *, struct in6_multi *, const int); static int mld_v2_process_group_query(struct in6_multi *, - struct mld_ifsoftc *mli, int, struct mbuf *, const int); + struct mld_ifsoftc *mli, int, struct mbuf *, + struct mldv2_query *, const int); static int sysctl_mld_gsr(SYSCTL_HANDLER_ARGS); static int sysctl_mld_ifinfo(SYSCTL_HANDLER_ARGS); @@ -794,16 +795,16 @@ mld_v1_update_group(struct in6_multi *inm, const int t * Process a received MLDv2 general, group-specific or * group-and-source-specific query. * - * Assumes that the query header has been pulled up to sizeof(mldv2_query). + * Assumes that mld points to a struct mldv2_query which is stored in + * contiguous memory. * * Return 0 if successful, otherwise an appropriate error code is returned. */ static int mld_v2_input_query(struct ifnet *ifp, const struct ip6_hdr *ip6, - struct mbuf *m, const int off, const int icmp6len) + struct mbuf *m, struct mldv2_query *mld, const int off, const int icmp6len) { struct mld_ifsoftc *mli; - struct mldv2_query *mld; struct in6_multi *inm; uint32_t maxdelay, nsrc, qqi; int is_general_query; @@ -828,8 +829,6 @@ mld_v2_input_query(struct ifnet *ifp, const struct ip6 CTR2(KTR_MLD, "input v2 query on ifp %p(%s)", ifp, if_name(ifp)); - mld = (struct mldv2_query *)(mtod(m, uint8_t *) + off); - maxdelay = ntohs(mld->mld_maxdelay); /* in 1/10ths of a second */ if (maxdelay >= 32768) { maxdelay = (MLD_MRC_MANT(maxdelay) | 0x1000) << @@ -954,7 +953,7 @@ mld_v2_input_query(struct ifnet *ifp, const struct ip6 * group-specific or group-and-source query. */ if (mli->mli_v2_timer == 0 || mli->mli_v2_timer >= timer) - mld_v2_process_group_query(inm, mli, timer, m, off); + mld_v2_process_group_query(inm, mli, timer, m, mld, off); /* XXX Clear embedded scope ID as userland won't expect it. */ in6_clearscope(&mld->mld_addr); @@ -975,9 +974,8 @@ out_locked: */ static int mld_v2_process_group_query(struct in6_multi *inm, struct mld_ifsoftc *mli, - int timer, struct mbuf *m0, const int off) + int timer, struct mbuf *m0, struct mldv2_query *mld, const int off) { - struct mldv2_query *mld; int retval; uint16_t nsrc; @@ -985,7 +983,6 @@ mld_v2_process_group_query(struct in6_multi *inm, stru MLD_LOCK_ASSERT(); retval = 0; - mld = (struct mldv2_query *)(mtod(m0, uint8_t *) + off); switch (inm->in6m_state) { case MLD_NOT_MEMBER: @@ -1005,6 +1002,15 @@ mld_v2_process_group_query(struct in6_multi *inm, stru nsrc = ntohs(mld->mld_numsrc); + /* Length should be checked by calling function. */ + KASSERT((m0->m_flags & M_PKTHDR) == 0 || + m0->m_pkthdr.len >= off + sizeof(struct mldv2_query) + + nsrc * sizeof(struct in6_addr), + ("mldv2 packet is too short: (%d bytes < %zd bytes, m=%p)", + m0->m_pkthdr.len, off + sizeof(struct mldv2_query) + + nsrc * sizeof(struct in6_addr), m0)); + + /* * Deal with group-specific queries upfront. * If any group query is already pending, purge any recorded @@ -1046,28 +1052,20 @@ mld_v2_process_group_query(struct in6_multi *inm, stru * report for those sources. */ if (inm->in6m_nsrc > 0) { - struct mbuf *m; - uint8_t *sp; + struct in6_addr srcaddr; int i, nrecorded; int soff; - m = m0; soff = off + sizeof(struct mldv2_query); nrecorded = 0; for (i = 0; i < nsrc; i++) { - sp = mtod(m, uint8_t *) + soff; - retval = in6m_record_source(inm, - (const struct in6_addr *)sp); + m_copydata(m0, soff, sizeof(struct in6_addr), + (caddr_t)&srcaddr); + retval = in6m_record_source(inm, &srcaddr); if (retval < 0) break; nrecorded += retval; soff += sizeof(struct in6_addr); - if (soff >= m->m_len) { - soff = soff - m->m_len; - m = m->m_next; - if (m == NULL) - break; - } } if (nrecorded > 0) { CTR1(KTR_MLD, @@ -1276,8 +1274,8 @@ mld_input(struct mbuf *m, int off, int icmp6len) if (mld_v1_input_query(ifp, ip6, mld) != 0) return (0); } else if (icmp6len >= sizeof(struct mldv2_query)) { - if (mld_v2_input_query(ifp, ip6, m, off, - icmp6len) != 0) + if (mld_v2_input_query(ifp, ip6, m, + (struct mldv2_query *)mld, off, icmp6len) != 0) return (0); } break; From owner-svn-src-stable-11@freebsd.org Tue Aug 6 22:36:30 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 208B1B0389; Tue, 6 Aug 2019 22:36:30 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4638ct05B1z3HlL; Tue, 6 Aug 2019 22:36:30 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D8D5C2D80; Tue, 6 Aug 2019 22:36:29 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x76MaTjj036392; Tue, 6 Aug 2019 22:36:29 GMT (envelope-from gjb@FreeBSD.org) Received: (from gjb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x76MaTUL036391; Tue, 6 Aug 2019 22:36:29 GMT (envelope-from gjb@FreeBSD.org) Message-Id: <201908062236.x76MaTUL036391@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gjb set sender to gjb@FreeBSD.org using -f From: Glen Barber Date: Tue, 6 Aug 2019 22:36:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r350660 - stable/11/release/doc/share/xml X-SVN-Group: stable-11 X-SVN-Commit-Author: gjb X-SVN-Commit-Paths: stable/11/release/doc/share/xml X-SVN-Commit-Revision: 350660 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Aug 2019 22:36:30 -0000 Author: gjb Date: Tue Aug 6 22:36:29 2019 New Revision: 350660 URL: https://svnweb.freebsd.org/changeset/base/350660 Log: Document EN-19:14, EN-19:15, SA-19:18-21. Sponsored by: Rubicon Communications, LLC (Netgate) Modified: stable/11/release/doc/share/xml/errata.xml stable/11/release/doc/share/xml/security.xml Modified: stable/11/release/doc/share/xml/errata.xml ============================================================================== --- stable/11/release/doc/share/xml/errata.xml Tue Aug 6 21:50:34 2019 (r350659) +++ stable/11/release/doc/share/xml/errata.xml Tue Aug 6 22:36:29 2019 (r350660) @@ -25,6 +25,13 @@ System crash from Intel CPU vulnerability mitigation + + + FreeBSD-EN-19:15.libunwind + 6 August 2019 + Incorrect exception handling + Modified: stable/11/release/doc/share/xml/security.xml ============================================================================== --- stable/11/release/doc/share/xml/security.xml Tue Aug 6 21:50:34 2019 (r350659) +++ stable/11/release/doc/share/xml/security.xml Tue Aug 6 22:36:29 2019 (r350660) @@ -59,6 +59,36 @@ 24 July 2019 Reference count leak + + + FreeBSD-SA-19:18.bzip2 + 6 August 2019 + Multiple vulnerabilities + + + + FreeBSD-SA-19:19.mldv2 + 6 August 2019 + Out-of-bounds memory access + + + + FreeBSD-SA-19:20.bsnmp + 6 August 2019 + Insufficient message length + validation + + + + FreeBSD-SA-19:21.bhyve + 6 August 2019 + Insufficient validation of guest-supplied + data + From owner-svn-src-stable-11@freebsd.org Wed Aug 7 01:03:36 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A88D4B8B0B; Wed, 7 Aug 2019 01:03:36 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 463Ctc3y1yz40ht; Wed, 7 Aug 2019 01:03:36 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 692FE4BE0; Wed, 7 Aug 2019 01:03:36 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x7713aiK025484; Wed, 7 Aug 2019 01:03:36 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7713aY1025483; Wed, 7 Aug 2019 01:03:36 GMT (envelope-from cy@FreeBSD.org) Message-Id: <201908070103.x7713aY1025483@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Wed, 7 Aug 2019 01:03:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r350667 - in stable: 11/sys/contrib/ipfilter/netinet 12/sys/contrib/ipfilter/netinet X-SVN-Group: stable-11 X-SVN-Commit-Author: cy X-SVN-Commit-Paths: in stable: 11/sys/contrib/ipfilter/netinet 12/sys/contrib/ipfilter/netinet X-SVN-Commit-Revision: 350667 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Aug 2019 01:03:36 -0000 Author: cy Date: Wed Aug 7 01:03:35 2019 New Revision: 350667 URL: https://svnweb.freebsd.org/changeset/base/350667 Log: MFC r350567: Returning an uninitialized error is a bad thing. Modified: stable/11/sys/contrib/ipfilter/netinet/mlfk_ipl.c Directory Properties: stable/11/ (props changed) Changes in other areas also in this revision: Modified: stable/12/sys/contrib/ipfilter/netinet/mlfk_ipl.c Directory Properties: stable/12/ (props changed) Modified: stable/11/sys/contrib/ipfilter/netinet/mlfk_ipl.c ============================================================================== --- stable/11/sys/contrib/ipfilter/netinet/mlfk_ipl.c Wed Aug 7 00:53:27 2019 (r350666) +++ stable/11/sys/contrib/ipfilter/netinet/mlfk_ipl.c Wed Aug 7 01:03:35 2019 (r350667) @@ -307,7 +307,7 @@ ipf_modunload() printf("%s unloaded\n", ipfilter_version); - return error; + return (0); } From owner-svn-src-stable-11@freebsd.org Wed Aug 7 01:08:58 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4CBEDB8FE7; Wed, 7 Aug 2019 01:08:58 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 463D0p1J0yz413h; Wed, 7 Aug 2019 01:08:58 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 09F814BE5; Wed, 7 Aug 2019 01:08:58 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x7718vRv025800; Wed, 7 Aug 2019 01:08:57 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7718vpc025799; Wed, 7 Aug 2019 01:08:57 GMT (envelope-from cy@FreeBSD.org) Message-Id: <201908070108.x7718vpc025799@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Wed, 7 Aug 2019 01:08:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r350668 - in stable: 11/sys/contrib/ipfilter/netinet 12/sys/contrib/ipfilter/netinet X-SVN-Group: stable-11 X-SVN-Commit-Author: cy X-SVN-Commit-Paths: in stable: 11/sys/contrib/ipfilter/netinet 12/sys/contrib/ipfilter/netinet X-SVN-Commit-Revision: 350668 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Aug 2019 01:08:58 -0000 Author: cy Date: Wed Aug 7 01:08:57 2019 New Revision: 350668 URL: https://svnweb.freebsd.org/changeset/base/350668 Log: MFC r350568: Resolve ipfilter kld unload issues related to VNET jails. When the ipfilter kld is loaded, used within VNET jail, and unloaded, then subsequent loading, use, and unloading of another packet filters will cause the subsequently loaded netpfil kld's to panic. The scenario is as follows: cd /usr/tests/sys/netpfil/common kldunload ipl kldunload pfsync kldunload ipfw kyua test pass_block kldload ipl kyua test pass_block kldunload ipl kldload pfsync kyua test pass_block kldunload pfsync -- page fault panic occurs here -- Reported by: "Ahsan Barkati" via kp@ Discussed with: kp@ Tested by: kp@ Modified: stable/11/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c stable/11/sys/contrib/ipfilter/netinet/mlfk_ipl.c Directory Properties: stable/11/ (props changed) Changes in other areas also in this revision: Modified: stable/12/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c stable/12/sys/contrib/ipfilter/netinet/mlfk_ipl.c Directory Properties: stable/12/ (props changed) Modified: stable/11/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c ============================================================================== --- stable/11/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c Wed Aug 7 01:03:35 2019 (r350667) +++ stable/11/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c Wed Aug 7 01:08:57 2019 (r350668) @@ -98,7 +98,10 @@ VNET_DEFINE(ipf_main_softc_t, ipfmain) = { # include # include -static eventhandler_tag ipf_arrivetag, ipf_departtag; +VNET_DEFINE_STATIC(eventhandler_tag, ipf_arrivetag); +VNET_DEFINE_STATIC(eventhandler_tag, ipf_departtag); +#define V_ipf_arrivetag VNET(ipf_arrivetag) +#define V_ipf_departtag VNET(ipf_departtag) #if 0 /* * Disable the "cloner" event handler; we are getting interface @@ -108,7 +111,8 @@ static eventhandler_tag ipf_arrivetag, ipf_departtag; * If it turns out to be needed, well need a dedicated event handler * for it to deal with the ifc and the correct vnet. */ -static eventhandler_tag ipf_clonetag; +VNET_DEFINE_STATIC(eventhandler_tag, ipf_clonetag); +#define V_ipf_clonetag VNET(ipf_clonetag) #endif static void ipf_ifevent(void *arg, struct ifnet *ifp); @@ -1384,14 +1388,14 @@ int ipf_pfil_hook(void) { void ipf_event_reg(void) { - ipf_arrivetag = EVENTHANDLER_REGISTER(ifnet_arrival_event, \ + V_ipf_arrivetag = EVENTHANDLER_REGISTER(ifnet_arrival_event, \ ipf_ifevent, NULL, \ EVENTHANDLER_PRI_ANY); - ipf_departtag = EVENTHANDLER_REGISTER(ifnet_departure_event, \ + V_ipf_departtag = EVENTHANDLER_REGISTER(ifnet_departure_event, \ ipf_ifevent, NULL, \ EVENTHANDLER_PRI_ANY); #if 0 - ipf_clonetag = EVENTHANDLER_REGISTER(if_clone_event, ipf_ifevent, \ + V_ipf_clonetag = EVENTHANDLER_REGISTER(if_clone_event, ipf_ifevent, \ NULL, EVENTHANDLER_PRI_ANY); #endif } @@ -1399,15 +1403,15 @@ ipf_event_reg(void) void ipf_event_dereg(void) { - if (ipf_arrivetag != NULL) { - EVENTHANDLER_DEREGISTER(ifnet_arrival_event, ipf_arrivetag); + if (V_ipf_arrivetag != NULL) { + EVENTHANDLER_DEREGISTER(ifnet_arrival_event, V_ipf_arrivetag); } - if (ipf_departtag != NULL) { - EVENTHANDLER_DEREGISTER(ifnet_departure_event, ipf_departtag); + if (V_ipf_departtag != NULL) { + EVENTHANDLER_DEREGISTER(ifnet_departure_event, V_ipf_departtag); } #if 0 - if (ipf_clonetag != NULL) { - EVENTHANDLER_DEREGISTER(if_clone_event, ipf_clonetag); + if (V_ipf_clonetag != NULL) { + EVENTHANDLER_DEREGISTER(if_clone_event, V_ipf_clonetag); } #endif } Modified: stable/11/sys/contrib/ipfilter/netinet/mlfk_ipl.c ============================================================================== --- stable/11/sys/contrib/ipfilter/netinet/mlfk_ipl.c Wed Aug 7 01:03:35 2019 (r350667) +++ stable/11/sys/contrib/ipfilter/netinet/mlfk_ipl.c Wed Aug 7 01:08:57 2019 (r350668) @@ -280,6 +280,10 @@ vnet_ipf_uninit(void) V_ipfmain.ipf_running = -2; ipf_destroy_all(&V_ipfmain); + if (!IS_DEFAULT_VNET(curvnet)) { + ipf_event_dereg(); + (void)ipf_pfil_unhook(); + } } } VNET_SYSUNINIT(vnet_ipf_uninit, SI_SUB_PROTO_FIREWALL, SI_ORDER_THIRD, From owner-svn-src-stable-11@freebsd.org Wed Aug 7 01:34:41 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EB62AB9CC0; Wed, 7 Aug 2019 01:34:41 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 463DZT5zgBz42Zk; Wed, 7 Aug 2019 01:34:41 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C40325166; Wed, 7 Aug 2019 01:34:41 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x771Yfej043643; Wed, 7 Aug 2019 01:34:41 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x771YflI043640; Wed, 7 Aug 2019 01:34:41 GMT (envelope-from cy@FreeBSD.org) Message-Id: <201908070134.x771YflI043640@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Wed, 7 Aug 2019 01:34:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r350669 - stable/11/sys/contrib/ipfilter/netinet X-SVN-Group: stable-11 X-SVN-Commit-Author: cy X-SVN-Commit-Paths: stable/11/sys/contrib/ipfilter/netinet X-SVN-Commit-Revision: 350669 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Aug 2019 01:34:42 -0000 Author: cy Date: Wed Aug 7 01:34:41 2019 New Revision: 350669 URL: https://svnweb.freebsd.org/changeset/base/350669 Log: Revert 350668 from stable/11 only. It is not at the level of VNET support. Modified: stable/11/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c stable/11/sys/contrib/ipfilter/netinet/mlfk_ipl.c Modified: stable/11/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c ============================================================================== --- stable/11/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c Wed Aug 7 01:08:57 2019 (r350668) +++ stable/11/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c Wed Aug 7 01:34:41 2019 (r350669) @@ -98,10 +98,7 @@ VNET_DEFINE(ipf_main_softc_t, ipfmain) = { # include # include -VNET_DEFINE_STATIC(eventhandler_tag, ipf_arrivetag); -VNET_DEFINE_STATIC(eventhandler_tag, ipf_departtag); -#define V_ipf_arrivetag VNET(ipf_arrivetag) -#define V_ipf_departtag VNET(ipf_departtag) +static eventhandler_tag ipf_arrivetag, ipf_departtag; #if 0 /* * Disable the "cloner" event handler; we are getting interface @@ -111,8 +108,7 @@ VNET_DEFINE_STATIC(eventhandler_tag, ipf_departtag); * If it turns out to be needed, well need a dedicated event handler * for it to deal with the ifc and the correct vnet. */ -VNET_DEFINE_STATIC(eventhandler_tag, ipf_clonetag); -#define V_ipf_clonetag VNET(ipf_clonetag) +static eventhandler_tag ipf_clonetag; #endif static void ipf_ifevent(void *arg, struct ifnet *ifp); @@ -1388,14 +1384,14 @@ int ipf_pfil_hook(void) { void ipf_event_reg(void) { - V_ipf_arrivetag = EVENTHANDLER_REGISTER(ifnet_arrival_event, \ + ipf_arrivetag = EVENTHANDLER_REGISTER(ifnet_arrival_event, \ ipf_ifevent, NULL, \ EVENTHANDLER_PRI_ANY); - V_ipf_departtag = EVENTHANDLER_REGISTER(ifnet_departure_event, \ + ipf_departtag = EVENTHANDLER_REGISTER(ifnet_departure_event, \ ipf_ifevent, NULL, \ EVENTHANDLER_PRI_ANY); #if 0 - V_ipf_clonetag = EVENTHANDLER_REGISTER(if_clone_event, ipf_ifevent, \ + ipf_clonetag = EVENTHANDLER_REGISTER(if_clone_event, ipf_ifevent, \ NULL, EVENTHANDLER_PRI_ANY); #endif } @@ -1403,15 +1399,15 @@ ipf_event_reg(void) void ipf_event_dereg(void) { - if (V_ipf_arrivetag != NULL) { - EVENTHANDLER_DEREGISTER(ifnet_arrival_event, V_ipf_arrivetag); + if (ipf_arrivetag != NULL) { + EVENTHANDLER_DEREGISTER(ifnet_arrival_event, ipf_arrivetag); } - if (V_ipf_departtag != NULL) { - EVENTHANDLER_DEREGISTER(ifnet_departure_event, V_ipf_departtag); + if (ipf_departtag != NULL) { + EVENTHANDLER_DEREGISTER(ifnet_departure_event, ipf_departtag); } #if 0 - if (V_ipf_clonetag != NULL) { - EVENTHANDLER_DEREGISTER(if_clone_event, V_ipf_clonetag); + if (ipf_clonetag != NULL) { + EVENTHANDLER_DEREGISTER(if_clone_event, ipf_clonetag); } #endif } Modified: stable/11/sys/contrib/ipfilter/netinet/mlfk_ipl.c ============================================================================== --- stable/11/sys/contrib/ipfilter/netinet/mlfk_ipl.c Wed Aug 7 01:08:57 2019 (r350668) +++ stable/11/sys/contrib/ipfilter/netinet/mlfk_ipl.c Wed Aug 7 01:34:41 2019 (r350669) @@ -280,10 +280,6 @@ vnet_ipf_uninit(void) V_ipfmain.ipf_running = -2; ipf_destroy_all(&V_ipfmain); - if (!IS_DEFAULT_VNET(curvnet)) { - ipf_event_dereg(); - (void)ipf_pfil_unhook(); - } } } VNET_SYSUNINIT(vnet_ipf_uninit, SI_SUB_PROTO_FIREWALL, SI_ORDER_THIRD, From owner-svn-src-stable-11@freebsd.org Thu Aug 8 17:28:55 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BC6EDAC441; Thu, 8 Aug 2019 17:28:55 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 464Fj34Sksz4bM9; Thu, 8 Aug 2019 17:28:55 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 76E7292B; Thu, 8 Aug 2019 17:28:55 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x78HStVu073801; Thu, 8 Aug 2019 17:28:55 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x78HStFw073800; Thu, 8 Aug 2019 17:28:55 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201908081728.x78HStFw073800@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 8 Aug 2019 17:28:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r350762 - stable/11/sys/cam/ctl X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/cam/ctl X-SVN-Commit-Revision: 350762 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Aug 2019 17:28:55 -0000 Author: mav Date: Thu Aug 8 17:28:55 2019 New Revision: 350762 URL: https://svnweb.freebsd.org/changeset/base/350762 Log: MFC r327239 (by manu): ctl: Correct comment in ctl_worker_thread The incoming queue is handled before the RtR one. No functional change. Modified: stable/11/sys/cam/ctl/ctl.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cam/ctl/ctl.c ============================================================================== --- stable/11/sys/cam/ctl/ctl.c Thu Aug 8 17:03:30 2019 (r350761) +++ stable/11/sys/cam/ctl/ctl.c Thu Aug 8 17:28:55 2019 (r350762) @@ -13249,8 +13249,8 @@ ctl_work_thread(void *arg) * We handle the queues in this order: * - ISC * - done queue (to free up resources, unblock other commands) - * - RtR queue * - incoming queue + * - RtR queue * * If those queues are empty, we break out of the loop and * go to sleep. From owner-svn-src-stable-11@freebsd.org Thu Aug 8 17:30:52 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3FE9DAC500; Thu, 8 Aug 2019 17:30:52 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 464FlJ0yCmz4bWd; Thu, 8 Aug 2019 17:30:52 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0397C940; Thu, 8 Aug 2019 17:30:52 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x78HUpSI074923; Thu, 8 Aug 2019 17:30:51 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x78HUpx0074922; Thu, 8 Aug 2019 17:30:51 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201908081730.x78HUpx0074922@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 8 Aug 2019 17:30:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r350763 - stable/11/sys/cam/ata X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/cam/ata X-SVN-Commit-Revision: 350763 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Aug 2019 17:30:52 -0000 Author: mav Date: Thu Aug 8 17:30:51 2019 New Revision: 350763 URL: https://svnweb.freebsd.org/changeset/base/350763 Log: MFC r327577 (by eadler): cam/da: QUIRK: Add 4K quirks for WD Red and Black MHDDs PR: 188685 Modified: stable/11/sys/cam/ata/ata_da.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cam/ata/ata_da.c ============================================================================== --- stable/11/sys/cam/ata/ata_da.c Thu Aug 8 17:28:55 2019 (r350762) +++ stable/11/sys/cam/ata/ata_da.c Thu Aug 8 17:30:51 2019 (r350763) @@ -357,7 +357,12 @@ static struct ada_quirk_entry ada_quirk_table[] = }, { /* WDC Caviar Black Advanced Format (4k) drives */ - { T_DIRECT, SIP_MEDIA_FIXED, "*", "WDC WD??????EX*", "*" }, + { T_DIRECT, SIP_MEDIA_FIXED, "*", "WDC WD????AZEX*", "*" }, + /*quirks*/ADA_Q_4K + }, + { + /* WDC Caviar Black Advanced Format (4k) drives */ + { T_DIRECT, SIP_MEDIA_FIXED, "*", "WDC WD????FZEX*", "*" }, /*quirks*/ADA_Q_4K }, { From owner-svn-src-stable-11@freebsd.org Thu Aug 8 17:55:18 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5F78CAD80C; Thu, 8 Aug 2019 17:55:18 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 464GHV1mnvz4dSV; Thu, 8 Aug 2019 17:55:18 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 201DFE98; Thu, 8 Aug 2019 17:55:18 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x78HtIhq091507; Thu, 8 Aug 2019 17:55:18 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x78HtHVP091506; Thu, 8 Aug 2019 17:55:17 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201908081755.x78HtHVP091506@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 8 Aug 2019 17:55:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r350765 - stable/11/sys/cam/ata X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/cam/ata X-SVN-Commit-Revision: 350765 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Aug 2019 17:55:18 -0000 Author: mav Date: Thu Aug 8 17:55:17 2019 New Revision: 350765 URL: https://svnweb.freebsd.org/changeset/base/350765 Log: MFC r343129 (by gonzo): [ata] Add workaround for KingDian S200 SSD crash on receiving TRIM command - Add ADA_Q_NO_TRIM quirk to be used with the device that falsely advertise TRIM support - Add ADA_Q_NO_TRIM entry for KingDian S200 SSD PR: 222802 Modified: stable/11/sys/cam/ata/ata_da.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cam/ata/ata_da.c ============================================================================== --- stable/11/sys/cam/ata/ata_da.c Thu Aug 8 17:48:07 2019 (r350764) +++ stable/11/sys/cam/ata/ata_da.c Thu Aug 8 17:55:17 2019 (r350765) @@ -116,7 +116,8 @@ typedef enum { ADA_Q_4K = 0x01, ADA_Q_NCQ_TRIM_BROKEN = 0x02, ADA_Q_LOG_BROKEN = 0x04, - ADA_Q_SMR_DM = 0x08 + ADA_Q_SMR_DM = 0x08, + ADA_Q_NO_TRIM = 0x10 } ada_quirks; #define ADA_Q_BIT_STRING \ @@ -124,7 +125,8 @@ typedef enum { "\0014K" \ "\002NCQ_TRIM_BROKEN" \ "\003LOG_BROKEN" \ - "\004SMR_DM" + "\004SMR_DM" \ + "\005NO_TRIM" typedef enum { ADA_CCB_RAHEAD = 0x01, @@ -534,6 +536,14 @@ static struct ada_quirk_entry ada_quirk_table[] = }, { /* + * KingDian S200 60GB P0921B + * Trimming crash the SSD + */ + { T_DIRECT, SIP_MEDIA_FIXED, "*", "KingDian S200 *", "*" }, + /*quirks*/ADA_Q_NO_TRIM + }, + { + /* * Kingston E100 Series SSDs * 4k optimised & trim only works in 4k requests + 4k aligned */ @@ -1803,6 +1813,10 @@ adaregister(struct cam_periph *periph, void *arg) softc->disk->d_flags = DISKFLAG_DIRECT_COMPLETION | DISKFLAG_CANZONE; if (softc->flags & ADA_FLAG_CAN_FLUSHCACHE) softc->disk->d_flags |= DISKFLAG_CANFLUSHCACHE; + /* Device lies about TRIM capability. */ + if ((softc->quirks & ADA_Q_NO_TRIM) && + (softc->flags & ADA_FLAG_CAN_TRIM)) + softc->flags &= ~ADA_FLAG_CAN_TRIM; if (softc->flags & ADA_FLAG_CAN_TRIM) { softc->disk->d_flags |= DISKFLAG_CANDELETE; softc->disk->d_delmaxsize = softc->params.secsize * From owner-svn-src-stable-11@freebsd.org Thu Aug 8 17:56:18 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 62E74AD90B; Thu, 8 Aug 2019 17:56:18 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 464GJf1x1kz4dkZ; Thu, 8 Aug 2019 17:56:18 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 240F0EA8; Thu, 8 Aug 2019 17:56:18 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x78HuILY091678; Thu, 8 Aug 2019 17:56:18 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x78HuHJR091677; Thu, 8 Aug 2019 17:56:17 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201908081756.x78HuHJR091677@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 8 Aug 2019 17:56:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r350767 - in stable/11/sys/cam: ata scsi X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: in stable/11/sys/cam: ata scsi X-SVN-Commit-Revision: 350767 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Aug 2019 17:56:18 -0000 Author: mav Date: Thu Aug 8 17:56:17 2019 New Revision: 350767 URL: https://svnweb.freebsd.org/changeset/base/350767 Log: MFC r343814 (by imp): Add quirk for Sansisk X400 drives Certain versions of Sandisk x400 firmware can hang under extremely heavly load of large I/Os for prolonged periods of time. Newer / current versions work fine, and should be used where possible. Where not possible, this quirk ensures that I/O requests are limited to 128k to avoids the bug, even under extreme load. Since MAXPHYS is 128k, only users with custom kernels are at risk on the older firmware. Once all known users of the older firmware have upgraded, this quirk will be removed. Modified: stable/11/sys/cam/ata/ata_da.c stable/11/sys/cam/scsi/scsi_da.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cam/ata/ata_da.c ============================================================================== --- stable/11/sys/cam/ata/ata_da.c Thu Aug 8 17:55:19 2019 (r350766) +++ stable/11/sys/cam/ata/ata_da.c Thu Aug 8 17:56:17 2019 (r350767) @@ -117,7 +117,8 @@ typedef enum { ADA_Q_NCQ_TRIM_BROKEN = 0x02, ADA_Q_LOG_BROKEN = 0x04, ADA_Q_SMR_DM = 0x08, - ADA_Q_NO_TRIM = 0x10 + ADA_Q_NO_TRIM = 0x10, + ADA_Q_128KB = 0x20 } ada_quirks; #define ADA_Q_BIT_STRING \ @@ -126,7 +127,8 @@ typedef enum { "\002NCQ_TRIM_BROKEN" \ "\003LOG_BROKEN" \ "\004SMR_DM" \ - "\005NO_TRIM" + "\005NO_TRIM" \ + "\006128KB" typedef enum { ADA_CCB_RAHEAD = 0x01, @@ -268,6 +270,11 @@ struct ada_quirk_entry { static struct ada_quirk_entry ada_quirk_table[] = { { + /* Sandisk X400 */ + { T_DIRECT, SIP_MEDIA_FIXED, "*", "SanDisk?SD8SB8U1T00*", "X4162000*" }, + /*quirks*/ADA_Q_128KB + }, + { /* Hitachi Advanced Format (4k) drives */ { T_DIRECT, SIP_MEDIA_FIXED, "*", "Hitachi H??????????E3*", "*" }, /*quirks*/ADA_Q_4K @@ -1808,6 +1815,8 @@ adaregister(struct cam_periph *periph, void *arg) maxio = min(maxio, 65536 * softc->params.secsize); else /* 28bit ATA command limit */ maxio = min(maxio, 256 * softc->params.secsize); + if (softc->quirks & ADA_Q_128KB) + maxio = min(maxio, 128 * 1024); softc->disk->d_maxsize = maxio; softc->disk->d_unit = periph->unit_number; softc->disk->d_flags = DISKFLAG_DIRECT_COMPLETION | DISKFLAG_CANZONE; Modified: stable/11/sys/cam/scsi/scsi_da.c ============================================================================== --- stable/11/sys/cam/scsi/scsi_da.c Thu Aug 8 17:55:19 2019 (r350766) +++ stable/11/sys/cam/scsi/scsi_da.c Thu Aug 8 17:56:17 2019 (r350767) @@ -125,7 +125,8 @@ typedef enum { DA_Q_NO_UNMAP = 0x20, DA_Q_RETRY_BUSY = 0x40, DA_Q_SMR_DM = 0x80, - DA_Q_STRICT_UNMAP = 0x100 + DA_Q_STRICT_UNMAP = 0x100, + DA_Q_128KB = 0x200 } da_quirks; #define DA_Q_BIT_STRING \ @@ -138,7 +139,8 @@ typedef enum { "\006NO_UNMAP" \ "\007RETRY_BUSY" \ "\010SMR_DM" \ - "\011STRICT_UNMAP" + "\011STRICT_UNMAP" \ + "\012128KB" typedef enum { DA_CCB_PROBE_RC = 0x01, @@ -847,6 +849,11 @@ static struct da_quirk_entry da_quirk_table[] = }, /* ATA/SATA devices over SAS/USB/... */ { + /* Sandisk X400 */ + { T_DIRECT, SIP_MEDIA_FIXED, "ATA", "SanDisk SD8SB8U1*", "*" }, + /*quirks*/DA_Q_128KB + }, + { /* Hitachi Advanced Format (4k) drives */ { T_DIRECT, SIP_MEDIA_FIXED, "Hitachi", "H??????????E3*", "*" }, /*quirks*/DA_Q_4K @@ -2612,6 +2619,8 @@ daregister(struct cam_periph *periph, void *arg) softc->maxio = MAXPHYS; /* for safety */ else softc->maxio = cpi.maxio; + if (softc->quirks & DA_Q_128KB) + softc->maxio = min(softc->maxio, 128 * 1024); softc->disk->d_maxsize = softc->maxio; softc->disk->d_unit = periph->unit_number; softc->disk->d_flags = DISKFLAG_DIRECT_COMPLETION | DISKFLAG_CANZONE; From owner-svn-src-stable-11@freebsd.org Thu Aug 8 17:58:15 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A42C9ADA04; Thu, 8 Aug 2019 17:58:15 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 464GLv3vT9z4dt5; Thu, 8 Aug 2019 17:58:15 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 678B9EB1; Thu, 8 Aug 2019 17:58:15 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x78HwFdT091849; Thu, 8 Aug 2019 17:58:15 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x78HwFEI091848; Thu, 8 Aug 2019 17:58:15 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201908081758.x78HwFEI091848@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 8 Aug 2019 17:58:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r350768 - stable/11/sbin/camcontrol X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sbin/camcontrol X-SVN-Commit-Revision: 350768 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Aug 2019 17:58:15 -0000 Author: mav Date: Thu Aug 8 17:58:14 2019 New Revision: 350768 URL: https://svnweb.freebsd.org/changeset/base/350768 Log: MFC r344701 (by smh): Fix incorrect / unused sector_count for identify requests Fix incorrect / unused sector_count for identify requests from camcontrol. Modified: stable/11/sbin/camcontrol/camcontrol.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/camcontrol/camcontrol.c ============================================================================== --- stable/11/sbin/camcontrol/camcontrol.c Thu Aug 8 17:56:17 2019 (r350767) +++ stable/11/sbin/camcontrol/camcontrol.c Thu Aug 8 17:58:14 2019 (r350768) @@ -2125,7 +2125,7 @@ ata_do_identify(struct cam_device *device, int retry_c /*command*/command, /*features*/0, /*lba*/0, - /*sector_count*/(u_int8_t)sizeof(struct ata_params), + /*sector_count*/0, /*data_ptr*/(u_int8_t *)ptr, /*dxfer_len*/sizeof(struct ata_params), /*timeout*/timeout ? timeout : 30 * 1000, @@ -2145,8 +2145,7 @@ ata_do_identify(struct cam_device *device, int retry_c /*command*/retry_command, /*features*/0, /*lba*/0, - /*sector_count*/(u_int8_t) - sizeof(struct ata_params), + /*sector_count*/0, /*data_ptr*/(u_int8_t *)ptr, /*dxfer_len*/sizeof(struct ata_params), /*timeout*/timeout ? timeout : 30 * 1000, From owner-svn-src-stable-11@freebsd.org Thu Aug 8 17:59:04 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CF3DBADAC2; Thu, 8 Aug 2019 17:59:04 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 464GMr59Gfz4f5v; Thu, 8 Aug 2019 17:59:04 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9311FEB7; Thu, 8 Aug 2019 17:59:04 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x78Hx499092083; Thu, 8 Aug 2019 17:59:04 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x78Hx48A092081; Thu, 8 Aug 2019 17:59:04 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201908081759.x78Hx48A092081@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 8 Aug 2019 17:59:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r350769 - stable/11/sbin/camcontrol X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sbin/camcontrol X-SVN-Commit-Revision: 350769 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Aug 2019 17:59:04 -0000 Author: mav Date: Thu Aug 8 17:59:03 2019 New Revision: 350769 URL: https://svnweb.freebsd.org/changeset/base/350769 Log: MFC r345051 (by imp): Add -l to camcontrol readcap. The -l flag sends only the READ CAPACITY (16) sevice action. Normally we send the READ CAPACITY (10) command, and only send RC16 when the capacity is larger than 2TB (since that's the max RC10 can report). However, some badly programmed drives report different numbers for RC10 and RC16. This can be hard to diagnose, but generally there's a "Logical block address out of range" error when RC16 reports a larger number than RC10 and the RC10 number is the correct one. By comparing the output of readcap with and without the -l argmuent, one can determine if there's a mismatch and if the DA_Q_NO_RC16 quirk is needed. Modified: stable/11/sbin/camcontrol/camcontrol.8 stable/11/sbin/camcontrol/camcontrol.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/camcontrol/camcontrol.8 ============================================================================== --- stable/11/sbin/camcontrol/camcontrol.8 Thu Aug 8 17:58:14 2019 (r350768) +++ stable/11/sbin/camcontrol/camcontrol.8 Thu Aug 8 17:59:03 2019 (r350769) @@ -78,6 +78,7 @@ .Op Fl b .Op Fl h .Op Fl H +.Op Fl l .Op Fl N .Op Fl q .Op Fl s @@ -544,6 +545,11 @@ or .Fl b . .It Fl H Print out the device size in human readable (base 10, 1K == 1000) format. +.It Fl l +Skip sending the SCSI READ CAPACITY (10) command. +Send only the SCSI READ CAPACITY (16) service action and report +its results. +When the two do not match, a quirk is needed to resolve the ambiguity. .It Fl N Print out the number of blocks in the device instead of the last logical block. Modified: stable/11/sbin/camcontrol/camcontrol.c ============================================================================== --- stable/11/sbin/camcontrol/camcontrol.c Thu Aug 8 17:58:14 2019 (r350768) +++ stable/11/sbin/camcontrol/camcontrol.c Thu Aug 8 17:59:03 2019 (r350769) @@ -198,7 +198,7 @@ static struct camcontrol_opts option_table[] = { {"load", CAM_CMD_STARTSTOP, CAM_ARG_START_UNIT | CAM_ARG_EJECT, NULL}, {"eject", CAM_CMD_STARTSTOP, CAM_ARG_EJECT, NULL}, {"reportluns", CAM_CMD_REPORTLUNS, CAM_ARG_NONE, "clr:"}, - {"readcapacity", CAM_CMD_READCAP, CAM_ARG_NONE, "bhHNqs"}, + {"readcapacity", CAM_CMD_READCAP, CAM_ARG_NONE, "bhHlNqs"}, {"reprobe", CAM_CMD_REPROBE, CAM_ARG_NONE, NULL}, #endif /* MINIMALISTIC */ {"rescan", CAM_CMD_RESCAN, CAM_ARG_NONE, NULL}, @@ -6947,7 +6947,7 @@ scsireadcapacity(struct cam_device *device, int argc, char *combinedopt, int task_attr, int retry_count, int timeout) { union ccb *ccb; - int blocksizeonly, humanize, numblocks, quiet, sizeonly, baseten; + int blocksizeonly, humanize, numblocks, quiet, sizeonly, baseten, longonly; struct scsi_read_capacity_data rcap; struct scsi_read_capacity_data_long rcaplong; uint64_t maxsector; @@ -6957,6 +6957,7 @@ scsireadcapacity(struct cam_device *device, int argc, blocksizeonly = 0; humanize = 0; + longonly = 0; numblocks = 0; quiet = 0; sizeonly = 0; @@ -6985,6 +6986,9 @@ scsireadcapacity(struct cam_device *device, int argc, humanize++; baseten++; break; + case 'l': + longonly++; + break; case 'N': numblocks++; break; @@ -7027,6 +7031,9 @@ scsireadcapacity(struct cam_device *device, int argc, goto bailout; } + if (longonly != 0) + goto long_only; + scsi_read_capacity(&ccb->csio, /*retries*/ retry_count, /*cbfcnp*/ NULL, @@ -7069,6 +7076,7 @@ scsireadcapacity(struct cam_device *device, int argc, if (maxsector != 0xffffffff) goto do_print; +long_only: scsi_read_capacity_16(&ccb->csio, /*retries*/ retry_count, /*cbfcnp*/ NULL, @@ -9017,7 +9025,7 @@ usage(int printlong) " camcontrol identify [dev_id][generic args] [-v]\n" " camcontrol reportluns [dev_id][generic args] [-c] [-l] [-r report]\n" " camcontrol readcap [dev_id][generic args] [-b] [-h] [-H] [-N]\n" -" [-q] [-s]\n" +" [-q] [-s] [-l]\n" " camcontrol start [dev_id][generic args]\n" " camcontrol stop [dev_id][generic args]\n" " camcontrol load [dev_id][generic args]\n" From owner-svn-src-stable-11@freebsd.org Thu Aug 8 18:00:00 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F14B6ADB5F; Thu, 8 Aug 2019 18:00:00 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 464GNw67cJz4fDL; Thu, 8 Aug 2019 18:00:00 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B5BC6EC2; Thu, 8 Aug 2019 18:00:00 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x78I00I4092249; Thu, 8 Aug 2019 18:00:00 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x78I00Dr092248; Thu, 8 Aug 2019 18:00:00 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201908081800.x78I00Dr092248@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 8 Aug 2019 18:00:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r350770 - stable/11/sbin/camcontrol X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sbin/camcontrol X-SVN-Commit-Revision: 350770 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Aug 2019 18:00:01 -0000 Author: mav Date: Thu Aug 8 18:00:00 2019 New Revision: 350770 URL: https://svnweb.freebsd.org/changeset/base/350770 Log: MFC r345060 (by 0mp): camcontrol.8: Bump date after r345051 Modified: stable/11/sbin/camcontrol/camcontrol.8 Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/camcontrol/camcontrol.8 ============================================================================== --- stable/11/sbin/camcontrol/camcontrol.8 Thu Aug 8 17:59:03 2019 (r350769) +++ stable/11/sbin/camcontrol/camcontrol.8 Thu Aug 8 18:00:00 2019 (r350770) @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 1, 2017 +.Dd March 12, 2019 .Dt CAMCONTROL 8 .Os .Sh NAME From owner-svn-src-stable-11@freebsd.org Thu Aug 8 18:00:37 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BD1C0ADBF4; Thu, 8 Aug 2019 18:00:37 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 464GPd4Cq6z4fM0; Thu, 8 Aug 2019 18:00:37 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 72396EC4; Thu, 8 Aug 2019 18:00:37 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x78I0bD3093129; Thu, 8 Aug 2019 18:00:37 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x78I0b91093128; Thu, 8 Aug 2019 18:00:37 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201908081800.x78I0b91093128@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 8 Aug 2019 18:00:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r350771 - stable/11/sbin/camcontrol X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sbin/camcontrol X-SVN-Commit-Revision: 350771 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Aug 2019 18:00:37 -0000 Author: mav Date: Thu Aug 8 18:00:37 2019 New Revision: 350771 URL: https://svnweb.freebsd.org/changeset/base/350771 Log: MFC r345363 (by imp): Make WD and WDC aliases for HGST. HGST was bought by WDC. Over the years, it has sold different drives branded as HGST, WD or WDC. All of them need the HGST workaround of sending 4k-sized packets (or multiples of 4k). And the ones that don't really need this aren't broken by this change. Submitter is the vendor who has tested these changes on a number of drives. I've simplified it slightly, since we don't need additional vendors for this at this time. Modified: stable/11/sbin/camcontrol/fwdownload.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/camcontrol/fwdownload.c ============================================================================== --- stable/11/sbin/camcontrol/fwdownload.c Thu Aug 8 18:00:00 2019 (r350770) +++ stable/11/sbin/camcontrol/fwdownload.c Thu Aug 8 18:00:37 2019 (r350771) @@ -212,6 +212,10 @@ static struct fw_vendor vendors_list[] = { 0x8000, 0x07, 0x07, 0, 1, FW_TUR_READY, WB_TIMEOUT, FW_TIMEOUT_DEFAULT}, {VENDOR_SMART, "SmrtStor", T_DIRECT, 0x8000, 0x07, 0x07, 0, 1, FW_TUR_READY, WB_TIMEOUT, FW_TIMEOUT_DEFAULT}, + {VENDOR_HGST, "WD", T_DIRECT, + 0x1000, 0x07, 0x07, 1, 0, FW_TUR_READY, WB_TIMEOUT, FW_TIMEOUT_DEFAULT}, + {VENDOR_HGST, "WDC", T_DIRECT, + 0x1000, 0x07, 0x07, 1, 0, FW_TUR_READY, WB_TIMEOUT, FW_TIMEOUT_DEFAULT}, /* * We match any ATA device. This is really just a placeholder, From owner-svn-src-stable-11@freebsd.org Thu Aug 8 18:42:40 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 74283AED09; Thu, 8 Aug 2019 18:42:40 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 464HL83441z4hfm; Thu, 8 Aug 2019 18:42:40 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4A87717BB; Thu, 8 Aug 2019 18:42:40 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x78Igegx021413; Thu, 8 Aug 2019 18:42:40 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x78IgeYv021412; Thu, 8 Aug 2019 18:42:40 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201908081842.x78IgeYv021412@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 8 Aug 2019 18:42:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r350773 - stable/11/sbin/camcontrol X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sbin/camcontrol X-SVN-Commit-Revision: 350773 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Aug 2019 18:42:40 -0000 Author: mav Date: Thu Aug 8 18:42:39 2019 New Revision: 350773 URL: https://svnweb.freebsd.org/changeset/base/350773 Log: MFC r320861 (by ngie): Fix whitespace bugs - Delete trailing whitespace. - Replace 8 single column spaces with hard tabs. - Delete lines with consisting purely of blank space. - Add space between `return` and `(`, per style(9). Special care was taken to not blindly replace 8 single column spaces with tabs; doing so could break tools that do strict string comparisons with camcontrol output. Modified: stable/11/sbin/camcontrol/camcontrol.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/camcontrol/camcontrol.c ============================================================================== --- stable/11/sbin/camcontrol/camcontrol.c Thu Aug 8 18:08:13 2019 (r350772) +++ stable/11/sbin/camcontrol/camcontrol.c Thu Aug 8 18:42:39 2019 (r350773) @@ -375,14 +375,14 @@ getoption(struct camcontrol_opts *table, char *arg, ui *argnum = opts->argnum; *subopt = opts->subopt; if (++num_matches > 1) - return(CC_OR_AMBIGUOUS); + return (CC_OR_AMBIGUOUS); } } if (num_matches > 0) - return(CC_OR_FOUND); + return (CC_OR_FOUND); else - return(CC_OR_NOT_FOUND); + return (CC_OR_NOT_FOUND); } #ifndef MINIMALISTIC @@ -404,7 +404,7 @@ getdevlist(struct cam_device *device) if (cam_send_ccb(device, ccb) < 0) { perror("error getting device list"); cam_freeccb(ccb); - return(1); + return (1); } status[0] = '\0'; @@ -442,7 +442,7 @@ getdevlist(struct cam_device *device) cam_freeccb(ccb); - return(error); + return (error); } #endif /* MINIMALISTIC */ @@ -471,7 +471,7 @@ getdevtree(int argc, char **argv, char *combinedopt) if ((fd = open(XPT_DEVICE, O_RDWR)) == -1) { warn("couldn't open %s", XPT_DEVICE); - return(1); + return (1); } bzero(&ccb, sizeof(union ccb)); @@ -487,7 +487,7 @@ getdevtree(int argc, char **argv, char *combinedopt) if (ccb.cdm.matches == NULL) { warnx("can't malloc memory for matches"); close(fd); - return(1); + return (1); } ccb.cdm.num_matches = 0; @@ -663,7 +663,7 @@ getdevtree(int argc, char **argv, char *combinedopt) close(fd); - return(error); + return (error); } #ifndef MINIMALISTIC @@ -699,7 +699,7 @@ testunitready(struct cam_device *device, int task_attr } cam_freeccb(ccb); - return(1); + return (1); } if ((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) { @@ -718,7 +718,7 @@ testunitready(struct cam_device *device, int task_attr cam_freeccb(ccb); - return(error); + return (error); } static int @@ -768,7 +768,7 @@ scsistart(struct cam_device *device, int startstop, in } cam_freeccb(ccb); - return(1); + return (1); } if ((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) @@ -802,7 +802,7 @@ scsistart(struct cam_device *device, int startstop, in cam_freeccb(ccb); - return(error); + return (error); } int @@ -839,7 +839,7 @@ scsidoinquiry(struct cam_device *device, int argc, cha error = scsiinquiry(device, task_attr, retry_count, timeout); if (error != 0) - return(error); + return (error); if (arglist & CAM_ARG_GET_SERIAL) scsiserial(device, task_attr, retry_count, timeout); @@ -847,7 +847,7 @@ scsidoinquiry(struct cam_device *device, int argc, cha if (arglist & CAM_ARG_GET_XFERRATE) error = camxferrate(device); - return(error); + return (error); } static int @@ -862,7 +862,7 @@ scsiinquiry(struct cam_device *device, int task_attr, if (ccb == NULL) { warnx("couldn't allocate CCB"); - return(1); + return (1); } /* cam_getccb cleans up the header, caller has to zero the payload */ @@ -874,7 +874,7 @@ scsiinquiry(struct cam_device *device, int task_attr, if (inq_buf == NULL) { cam_freeccb(ccb); warnx("can't malloc memory for inquiry\n"); - return(1); + return (1); } bzero(inq_buf, sizeof(*inq_buf)); @@ -937,7 +937,7 @@ scsiinquiry(struct cam_device *device, int task_attr, } cam_freeccb(ccb); - return(1); + return (1); } if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { @@ -953,7 +953,7 @@ scsiinquiry(struct cam_device *device, int task_attr, if (error != 0) { free(inq_buf); - return(error); + return (error); } fprintf(stdout, "%s%d: ", device->device_name, @@ -962,7 +962,7 @@ scsiinquiry(struct cam_device *device, int task_attr, free(inq_buf); - return(0); + return (0); } static int @@ -978,7 +978,7 @@ scsiserial(struct cam_device *device, int task_attr, i if (ccb == NULL) { warnx("couldn't allocate CCB"); - return(1); + return (1); } /* cam_getccb cleans up the header, caller has to zero the payload */ @@ -990,7 +990,7 @@ scsiserial(struct cam_device *device, int task_attr, i if (serial_buf == NULL) { cam_freeccb(ccb); warnx("can't malloc memory for serial number"); - return(1); + return (1); } scsi_inquiry(&ccb->csio, @@ -1020,7 +1020,7 @@ scsiserial(struct cam_device *device, int task_attr, i cam_freeccb(ccb); free(serial_buf); - return(1); + return (1); } if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { @@ -1036,7 +1036,7 @@ scsiserial(struct cam_device *device, int task_attr, i if (error != 0) { free(serial_buf); - return(error); + return (error); } bcopy(serial_buf->serial_num, serial_num, serial_buf->length); @@ -1051,7 +1051,7 @@ scsiserial(struct cam_device *device, int task_attr, i free(serial_buf); - return(0); + return (0); } int @@ -1071,7 +1071,7 @@ camxferrate(struct cam_device *device) if (ccb == NULL) { warnx("couldn't allocate CCB"); - return(1); + return (1); } CCB_CLEAR_ALL_EXCEPT_HDR(&ccb->cts); @@ -1210,13 +1210,13 @@ camxferrate(struct cam_device *device) } } - fprintf(stdout, "\n"); + fprintf(stdout, "\n"); xferrate_bailout: cam_freeccb(ccb); - return(retval); + return (retval); } static void @@ -1239,7 +1239,7 @@ atahpa_print(struct ata_params *parm, u_int64_t hpasiz if (parm->support.command1 & ATA_SUPPORT_PROTECTED) { u_int64_t lba = lbasize48 ? lbasize48 : lbasize; printf("yes %s %ju/%ju\n", (hpasize > lba) ? "yes" : "no ", - lba, hpasize); + lba, hpasize); printf("HPA - Security "); if (parm->support.command1 & ATA_SUPPORT_MAXSECURITY) @@ -3040,8 +3040,7 @@ atasecurity(struct cam_device *device, int retry_count } error = atasecurity_erase(device, ccb, retry_count, - timeout, erase_timeout, &pwd, - quiet); + timeout, erase_timeout, &pwd, quiet); } else { warnx("Can't secure erase (security is disabled)"); error = 1; @@ -3134,7 +3133,7 @@ dorescan_or_reset(int argc, char **argv, int rescan) if (argc < 3) { warnx(must, rescan? "rescan" : "reset"); - return(1); + return (1); } tstr = argv[optind]; @@ -3146,7 +3145,7 @@ dorescan_or_reset(int argc, char **argv, int rescan) rv = parse_btl(argv[optind], &bus, &target, &lun, &arglist); if (rv != 1 && rv != 3) { warnx(must, rescan? "rescan" : "reset"); - return(1); + return (1); } } else { char name[30]; @@ -3254,7 +3253,7 @@ dorescan_or_reset(int argc, char **argv, int rescan) bailout: - return(error); + return (error); } static int @@ -3269,7 +3268,7 @@ rescan_or_reset_bus(path_id_t bus, int rescan) if ((fd = open(XPT_DEVICE, O_RDWR)) < 0) { warnx("error opening transport layer device %s", XPT_DEVICE); warn("%s", XPT_DEVICE); - return(1); + return (1); } ccb = malloc(sizeof(*ccb)); @@ -3434,7 +3433,7 @@ bailout: } free(ccb); - return(retval); + return (retval); } static int @@ -3448,17 +3447,17 @@ scanlun_or_reset_dev(path_id_t bus, target_id_t target if (bus == CAM_BUS_WILDCARD) { warnx("invalid bus number %d", bus); - return(1); + return (1); } if (target == CAM_TARGET_WILDCARD) { warnx("invalid target number %d", target); - return(1); + return (1); } if (lun == CAM_LUN_WILDCARD) { warnx("invalid lun number %jx", (uintmax_t)lun); - return(1); + return (1); } fd = -1; @@ -3470,13 +3469,13 @@ scanlun_or_reset_dev(path_id_t bus, target_id_t target warnx("error opening transport layer device %s\n", XPT_DEVICE); warn("%s", XPT_DEVICE); - return(1); + return (1); } } else { device = cam_open_btl(bus, target, lun, O_RDWR, NULL); if (device == NULL) { warnx("%s", cam_errbuf); - return(1); + return (1); } } @@ -3494,13 +3493,13 @@ scanlun_or_reset_dev(path_id_t bus, target_id_t target if (ioctl(fd, CAMIOCOMMAND, &ccb) < 0) { warn("CAMIOCOMMAND ioctl failed"); close(fd); - return(1); + return (1); } } else { if (cam_send_ccb(device, &ccb) < 0) { warn("error sending XPT_RESET_DEV CCB"); cam_close_device(device); - return(1); + return (1); } } @@ -3517,12 +3516,12 @@ scanlun_or_reset_dev(path_id_t bus, target_id_t target && ((ccb.ccb_h.status & CAM_STATUS_MASK) == CAM_BDR_SENT))) { fprintf(stdout, "%s of %d:%d:%jx was successful\n", scan? "Re-scan" : "Reset", bus, target, (uintmax_t)lun); - return(0); + return (0); } else { fprintf(stdout, "%s of %d:%d:%jx returned error %#x\n", scan? "Re-scan" : "Reset", bus, target, (uintmax_t)lun, ccb.ccb_h.status & CAM_STATUS_MASK); - return(1); + return (1); } } @@ -3754,7 +3753,7 @@ next_batch: error = 1; goto defect_bailout; break; - } + } max_possible_size = (hdr_max / entry_size) * entry_size; num_returned = returned_length / entry_size; @@ -4100,7 +4099,7 @@ defect_bailout: if (ccb != NULL) cam_freeccb(ccb); - return(error); + return (error); } #endif /* MINIMALISTIC */ @@ -4301,7 +4300,7 @@ scsicmd(struct cam_device *device, int argc, char **ar if (ccb == NULL) { warnx("scsicmd: error allocating ccb"); - return(1); + return (1); } CCB_CLEAR_ALL_EXCEPT_HDR(ccb); @@ -4501,7 +4500,7 @@ scsicmd(struct cam_device *device, int argc, char **ar case 3: case 6: case 7: - /* computed by buff_encode_visit */ + /* computed by buff_encode_visit */ break; case 4: cdb_len = 16; @@ -4630,7 +4629,7 @@ scsicmd_bailout: cam_freeccb(ccb); - return(error); + return (error); } static int @@ -4684,7 +4683,7 @@ camdebug(int argc, char **argv, char *combinedopt) if ((fd = open(XPT_DEVICE, O_RDWR)) < 0) { warnx("error opening transport layer device %s", XPT_DEVICE); warn("%s", XPT_DEVICE); - return(1); + return (1); } argc -= optind; argv += optind; @@ -4693,7 +4692,7 @@ camdebug(int argc, char **argv, char *combinedopt) warnx("you must specify \"off\", \"all\" or a bus,"); warnx("bus:target, or bus:target:lun"); close(fd); - return(1); + return (1); } tstr = *argv; @@ -4767,7 +4766,7 @@ camdebug(int argc, char **argv, char *combinedopt) close(fd); } - return(error); + return (error); } static int @@ -4785,7 +4784,7 @@ tagcontrol(struct cam_device *device, int argc, char * if (ccb == NULL) { warnx("tagcontrol: error allocating ccb"); - return(1); + return (1); } while ((c = getopt(argc, argv, combinedopt)) != -1) { @@ -4881,7 +4880,7 @@ tagcontrol(struct cam_device *device, int argc, char * tagcontrol_bailout: cam_freeccb(ccb); - return(retval); + return (retval); } static void @@ -5034,7 +5033,7 @@ get_cpi(struct cam_device *device, struct ccb_pathinq ccb = cam_getccb(device); if (ccb == NULL) { warnx("get_cpi: couldn't allocate CCB"); - return(1); + return (1); } CCB_CLEAR_ALL_EXCEPT_HDR(&ccb->cpi); ccb->ccb_h.func_code = XPT_PATH_INQ; @@ -5057,7 +5056,7 @@ get_cpi(struct cam_device *device, struct ccb_pathinq get_cpi_bailout: cam_freeccb(ccb); - return(retval); + return (retval); } /* @@ -5072,7 +5071,7 @@ get_cgd(struct cam_device *device, struct ccb_getdev * ccb = cam_getccb(device); if (ccb == NULL) { warnx("get_cgd: couldn't allocate CCB"); - return(1); + return (1); } CCB_CLEAR_ALL_EXCEPT_HDR(&ccb->cgd); ccb->ccb_h.func_code = XPT_GDEV_TYPE; @@ -5095,7 +5094,7 @@ get_cgd(struct cam_device *device, struct ccb_getdev * get_cgd_bailout: cam_freeccb(ccb); - return(retval); + return (retval); } /* @@ -5117,7 +5116,7 @@ dev_has_vpd_page(struct cam_device *dev, uint8_t page_ retval = -1; goto bailout; } - + /* cam_getccb cleans up the header, caller has to zero the payload */ CCB_CLEAR_ALL_EXCEPT_HDR(&ccb->csio); @@ -5164,7 +5163,7 @@ dev_has_vpd_page(struct cam_device *dev, uint8_t page_ bailout: if (ccb != NULL) cam_freeccb(ccb); - + return (retval); } @@ -5194,7 +5193,7 @@ get_device_type(struct cam_device *dev, int retry_coun break; /*NOTREACHED*/ default: *devtype = CC_DT_UNKNOWN; - goto bailout; + goto bailout; break; /*NOTREACHED*/ } @@ -5269,7 +5268,7 @@ build_ata_cmd(union ccb *ccb, uint32_t retry_count, ui /*protocol*/ protocol, /*ata_flags*/ ata_flags, /*features*/ features, - /*sector_count*/ sector_count, + /*sector_count*/ sector_count, /*lba*/ lba, /*command*/ command, /*device*/ 0, @@ -5301,7 +5300,7 @@ get_ata_status(struct cam_device *dev, union ccb *ccb, /* * In this case, we have SCSI ATA PASS-THROUGH command, 12 - * or 16 byte, and need to see what + * or 16 byte, and need to see what */ if (ccb->ccb_h.flags & CAM_CDB_POINTER) opcode = ccb->csio.cdb_io.cdb_ptr[0]; @@ -5351,7 +5350,7 @@ get_ata_status(struct cam_device *dev, union ccb *ccb, ((uint64_t)desc->lba_31_24 << 24) | (desc->lba_23_16 << 16) | (desc->lba_15_8 << 8) | - desc->lba_7_0; + desc->lba_7_0; *device = desc->device; *status = desc->status; @@ -5402,7 +5401,7 @@ get_ata_status(struct cam_device *dev, union ccb *ccb, res = &ccb->ataio.res; *error = res->error; *status = res->status; - *device = res->device; + *device = res->device; *count = res->sector_count; *lba = (res->lba_high << 16) | (res->lba_mid << 8) | @@ -5602,7 +5601,7 @@ get_print_cts(struct cam_device *device, int user_sett if (ccb == NULL) { warnx("get_print_cts: error allocating ccb"); - return(1); + return (1); } CCB_CLEAR_ALL_EXCEPT_HDR(&ccb->cts); @@ -5642,7 +5641,7 @@ get_print_cts_bailout: cam_freeccb(ccb); - return(retval); + return (retval); } static int @@ -5665,7 +5664,7 @@ ratecontrol(struct cam_device *device, int task_attr, ccb = cam_getccb(device); if (ccb == NULL) { warnx("ratecontrol: error allocating ccb"); - return(1); + return (1); } while ((c = getopt(argc, argv, combinedopt)) != -1) { switch(c){ @@ -5997,7 +5996,7 @@ ratecontrol(struct cam_device *device, int task_attr, ratecontrol_bailout: cam_freeccb(ccb); - return(retval); + return (retval); } static int @@ -6021,7 +6020,7 @@ scsiformat(struct cam_device *device, int argc, char * if (ccb == NULL) { warnx("scsiformat: error allocating ccb"); - return(1); + return (1); } CCB_CLEAR_ALL_EXCEPT_HDR(&ccb->csio); @@ -6287,7 +6286,7 @@ scsiformat_bailout: cam_freeccb(ccb); - return(error); + return (error); } static int @@ -6316,7 +6315,7 @@ scsisanitize(struct cam_device *device, int argc, char if (ccb == NULL) { warnx("scsisanitize: error allocating ccb"); - return(1); + return (1); } CCB_CLEAR_ALL_EXCEPT_HDR(&ccb->csio); @@ -6697,7 +6696,7 @@ scsisanitize_bailout: free(data_ptr); cam_freeccb(ccb); - return(error); + return (error); } static int @@ -7335,7 +7334,7 @@ smpcmd(struct cam_device *device, int argc, char **arg } else if ((amt_written == 0) && (amt_to_write > 0)) { warnx("only wrote %u bytes out of %u", - response_size - amt_to_write, + response_size - amt_to_write, response_size); } } @@ -7945,7 +7944,7 @@ buildbusdevlist(struct cam_devlist *devlist) if ((fd = open(XPT_DEVICE, O_RDWR)) == -1) { warn("couldn't open %s", XPT_DEVICE); - return(1); + return (1); } bzero(&ccb, sizeof(union ccb)); @@ -7961,7 +7960,7 @@ buildbusdevlist(struct cam_devlist *devlist) if (ccb.cdm.matches == NULL) { warnx("can't malloc memory for matches"); close(fd); - return(1); + return (1); } ccb.cdm.num_matches = 0; ccb.cdm.num_patterns = 2; @@ -8012,7 +8011,7 @@ buildbusdevlist(struct cam_devlist *devlist) case DEV_MATCH_DEVICE: { struct device_match_result *dev_result; - dev_result = + dev_result = &ccb.cdm.matches[i].result.device_result; if (dev_result->flags & @@ -8363,7 +8362,7 @@ smpphylist(struct cam_device *device, int argc, char * fprintf(stdout, "%s%d", item->periph_matches[j].periph_name, item->periph_matches[j].unit_number); - + } fprintf(stdout, ")\n"); } @@ -8565,7 +8564,7 @@ scsigetopcodes(struct cam_device *device, int opcode_s alloc_len += num_opcodes * sizeof(struct scsi_report_supported_opcodes_timeout); } - + if (sa_set != 0) { options |= RSO_OPTIONS_OC_SA; if (show_sa_errors != 0) @@ -8576,7 +8575,7 @@ retry_alloc: if (buf != NULL) { free(buf); buf = NULL; - } + } buf = malloc(alloc_len); if (buf == NULL) { @@ -8613,7 +8612,6 @@ retry_alloc: if (verbosemode != 0) cam_error_print(device, ccb, CAM_ESF_ALL, CAM_EPF_ALL, stderr); - retval = 1; goto bailout; } @@ -9599,167 +9597,167 @@ main(int argc, char **argv) switch(cmdlist) { #ifndef MINIMALISTIC - case CAM_CMD_DEVLIST: - error = getdevlist(cam_dev); - break; - case CAM_CMD_HPA: - error = atahpa(cam_dev, retry_count, timeout, - argc, argv, combinedopt); - break; + case CAM_CMD_DEVLIST: + error = getdevlist(cam_dev); + break; + case CAM_CMD_HPA: + error = atahpa(cam_dev, retry_count, timeout, + argc, argv, combinedopt); + break; #endif /* MINIMALISTIC */ - case CAM_CMD_DEVTREE: - error = getdevtree(argc, argv, combinedopt); - break; + case CAM_CMD_DEVTREE: + error = getdevtree(argc, argv, combinedopt); + break; #ifndef MINIMALISTIC - case CAM_CMD_TUR: - error = testunitready(cam_dev, task_attr, retry_count, - timeout, 0); - break; - case CAM_CMD_INQUIRY: - error = scsidoinquiry(cam_dev, argc, argv, combinedopt, - task_attr, retry_count, timeout); - break; - case CAM_CMD_IDENTIFY: - error = ataidentify(cam_dev, retry_count, timeout); - break; - case CAM_CMD_STARTSTOP: - error = scsistart(cam_dev, arglist & CAM_ARG_START_UNIT, - arglist & CAM_ARG_EJECT, task_attr, - retry_count, timeout); - break; + case CAM_CMD_TUR: + error = testunitready(cam_dev, task_attr, retry_count, + timeout, 0); + break; + case CAM_CMD_INQUIRY: + error = scsidoinquiry(cam_dev, argc, argv, combinedopt, + task_attr, retry_count, timeout); + break; + case CAM_CMD_IDENTIFY: + error = ataidentify(cam_dev, retry_count, timeout); + break; + case CAM_CMD_STARTSTOP: + error = scsistart(cam_dev, arglist & CAM_ARG_START_UNIT, + arglist & CAM_ARG_EJECT, task_attr, + retry_count, timeout); + break; #endif /* MINIMALISTIC */ - case CAM_CMD_RESCAN: - error = dorescan_or_reset(argc, argv, 1); - break; - case CAM_CMD_RESET: - error = dorescan_or_reset(argc, argv, 0); - break; + case CAM_CMD_RESCAN: + error = dorescan_or_reset(argc, argv, 1); + break; + case CAM_CMD_RESET: + error = dorescan_or_reset(argc, argv, 0); + break; #ifndef MINIMALISTIC - case CAM_CMD_READ_DEFECTS: - error = readdefects(cam_dev, argc, argv, combinedopt, - task_attr, retry_count, timeout); - break; - case CAM_CMD_MODE_PAGE: - modepage(cam_dev, argc, argv, combinedopt, - task_attr, retry_count, timeout); - break; - case CAM_CMD_SCSI_CMD: - error = scsicmd(cam_dev, argc, argv, combinedopt, - task_attr, retry_count, timeout); - break; - case CAM_CMD_SMP_CMD: - error = smpcmd(cam_dev, argc, argv, combinedopt, + case CAM_CMD_READ_DEFECTS: + error = readdefects(cam_dev, argc, argv, combinedopt, + task_attr, retry_count, timeout); + break; + case CAM_CMD_MODE_PAGE: + modepage(cam_dev, argc, argv, combinedopt, + task_attr, retry_count, timeout); + break; + case CAM_CMD_SCSI_CMD: + error = scsicmd(cam_dev, argc, argv, combinedopt, + task_attr, retry_count, timeout); + break; + case CAM_CMD_SMP_CMD: + error = smpcmd(cam_dev, argc, argv, combinedopt, + retry_count, timeout); + break; + case CAM_CMD_SMP_RG: + error = smpreportgeneral(cam_dev, argc, argv, + combinedopt, retry_count, + timeout); + break; + case CAM_CMD_SMP_PC: + error = smpphycontrol(cam_dev, argc, argv, combinedopt, + retry_count, timeout); + break; + case CAM_CMD_SMP_PHYLIST: + error = smpphylist(cam_dev, argc, argv, combinedopt, + retry_count, timeout); + break; + case CAM_CMD_SMP_MANINFO: + error = smpmaninfo(cam_dev, argc, argv, combinedopt, + retry_count, timeout); + break; + case CAM_CMD_DEBUG: + error = camdebug(argc, argv, combinedopt); + break; + case CAM_CMD_TAG: + error = tagcontrol(cam_dev, argc, argv, combinedopt); + break; + case CAM_CMD_RATE: + error = ratecontrol(cam_dev, task_attr, retry_count, + timeout, argc, argv, combinedopt); + break; + case CAM_CMD_FORMAT: + error = scsiformat(cam_dev, argc, argv, + combinedopt, task_attr, retry_count, + timeout); + break; + case CAM_CMD_REPORTLUNS: + error = scsireportluns(cam_dev, argc, argv, + combinedopt, task_attr, retry_count, timeout); - break; - case CAM_CMD_SMP_RG: - error = smpreportgeneral(cam_dev, argc, argv, - combinedopt, retry_count, - timeout); - break; - case CAM_CMD_SMP_PC: - error = smpphycontrol(cam_dev, argc, argv, combinedopt, - retry_count, timeout); - break; - case CAM_CMD_SMP_PHYLIST: - error = smpphylist(cam_dev, argc, argv, combinedopt, - retry_count, timeout); - break; - case CAM_CMD_SMP_MANINFO: - error = smpmaninfo(cam_dev, argc, argv, combinedopt, - retry_count, timeout); - break; - case CAM_CMD_DEBUG: - error = camdebug(argc, argv, combinedopt); - break; - case CAM_CMD_TAG: - error = tagcontrol(cam_dev, argc, argv, combinedopt); - break; - case CAM_CMD_RATE: - error = ratecontrol(cam_dev, task_attr, retry_count, - timeout, argc, argv, combinedopt); - break; - case CAM_CMD_FORMAT: - error = scsiformat(cam_dev, argc, argv, - combinedopt, task_attr, retry_count, - timeout); - break; - case CAM_CMD_REPORTLUNS: - error = scsireportluns(cam_dev, argc, argv, - combinedopt, task_attr, - retry_count, timeout); - break; - case CAM_CMD_READCAP: - error = scsireadcapacity(cam_dev, argc, argv, - combinedopt, task_attr, - retry_count, timeout); - break; - case CAM_CMD_IDLE: - case CAM_CMD_STANDBY: - case CAM_CMD_SLEEP: - error = atapm(cam_dev, argc, argv, - combinedopt, retry_count, timeout); - break; - case CAM_CMD_APM: - case CAM_CMD_AAM: - error = ataaxm(cam_dev, argc, argv, - combinedopt, retry_count, timeout); - break; - case CAM_CMD_SECURITY: - error = atasecurity(cam_dev, retry_count, timeout, - argc, argv, combinedopt); - break; - case CAM_CMD_DOWNLOAD_FW: - error = fwdownload(cam_dev, argc, argv, combinedopt, - arglist & CAM_ARG_VERBOSE, task_attr, retry_count, - timeout); - break; - case CAM_CMD_SANITIZE: - error = scsisanitize(cam_dev, argc, argv, - combinedopt, task_attr, - retry_count, timeout); - break; - case CAM_CMD_PERSIST: - error = scsipersist(cam_dev, argc, argv, combinedopt, - task_attr, retry_count, timeout, - arglist & CAM_ARG_VERBOSE, - arglist & CAM_ARG_ERR_RECOVER); - break; - case CAM_CMD_ATTRIB: - error = scsiattrib(cam_dev, argc, argv, combinedopt, - task_attr, retry_count, timeout, - arglist & CAM_ARG_VERBOSE, - arglist & CAM_ARG_ERR_RECOVER); - break; - case CAM_CMD_OPCODES: - error = scsiopcodes(cam_dev, argc, argv, combinedopt, - task_attr, retry_count, timeout, - arglist & CAM_ARG_VERBOSE); - break; - case CAM_CMD_REPROBE: - error = scsireprobe(cam_dev); - break; - case CAM_CMD_ZONE: - error = zone(cam_dev, argc, argv, combinedopt, - task_attr, retry_count, timeout, - arglist & CAM_ARG_VERBOSE); - break; - case CAM_CMD_EPC: - error = epc(cam_dev, argc, argv, combinedopt, - retry_count, timeout, arglist & CAM_ARG_VERBOSE); - break; - case CAM_CMD_TIMESTAMP: - error = timestamp(cam_dev, argc, argv, combinedopt, - task_attr, retry_count, timeout, - arglist & CAM_ARG_VERBOSE); - break; + break; + case CAM_CMD_READCAP: + error = scsireadcapacity(cam_dev, argc, argv, + combinedopt, task_attr, + retry_count, timeout); + break; + case CAM_CMD_IDLE: + case CAM_CMD_STANDBY: + case CAM_CMD_SLEEP: + error = atapm(cam_dev, argc, argv, + combinedopt, retry_count, timeout); + break; + case CAM_CMD_APM: + case CAM_CMD_AAM: + error = ataaxm(cam_dev, argc, argv, + combinedopt, retry_count, timeout); + break; + case CAM_CMD_SECURITY: + error = atasecurity(cam_dev, retry_count, timeout, + argc, argv, combinedopt); + break; + case CAM_CMD_DOWNLOAD_FW: + error = fwdownload(cam_dev, argc, argv, combinedopt, + arglist & CAM_ARG_VERBOSE, task_attr, retry_count, + timeout); + break; + case CAM_CMD_SANITIZE: + error = scsisanitize(cam_dev, argc, argv, + combinedopt, task_attr, + retry_count, timeout); + break; + case CAM_CMD_PERSIST: + error = scsipersist(cam_dev, argc, argv, combinedopt, + task_attr, retry_count, timeout, + arglist & CAM_ARG_VERBOSE, + arglist & CAM_ARG_ERR_RECOVER); + break; + case CAM_CMD_ATTRIB: + error = scsiattrib(cam_dev, argc, argv, combinedopt, + task_attr, retry_count, timeout, + arglist & CAM_ARG_VERBOSE, + arglist & CAM_ARG_ERR_RECOVER); + break; + case CAM_CMD_OPCODES: + error = scsiopcodes(cam_dev, argc, argv, combinedopt, + task_attr, retry_count, timeout, + arglist & CAM_ARG_VERBOSE); + break; + case CAM_CMD_REPROBE: + error = scsireprobe(cam_dev); + break; + case CAM_CMD_ZONE: + error = zone(cam_dev, argc, argv, combinedopt, + task_attr, retry_count, timeout, + arglist & CAM_ARG_VERBOSE); + break; + case CAM_CMD_EPC: + error = epc(cam_dev, argc, argv, combinedopt, + retry_count, timeout, arglist & CAM_ARG_VERBOSE); + break; + case CAM_CMD_TIMESTAMP: + error = timestamp(cam_dev, argc, argv, combinedopt, *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-11@freebsd.org Thu Aug 8 18:48:49 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B787DAF10E; Thu, 8 Aug 2019 18:48:49 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 464HTF4LPnz4jD6; Thu, 8 Aug 2019 18:48:49 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 76A1517CA; Thu, 8 Aug 2019 18:48:49 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x78ImnWa021862; Thu, 8 Aug 2019 18:48:49 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x78Imn7i021860; Thu, 8 Aug 2019 18:48:49 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201908081848.x78Imn7i021860@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 8 Aug 2019 18:48:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r350774 - stable/11/sbin/camcontrol X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sbin/camcontrol X-SVN-Commit-Revision: 350774 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Aug 2019 18:48:49 -0000 Author: mav Date: Thu Aug 8 18:48:48 2019 New Revision: 350774 URL: https://svnweb.freebsd.org/changeset/base/350774 Log: MFC r346594 (by smh): Add ATA power mode support to camcontrol Add the ability to report ATA device power mode with the cmmand 'powermode' to compliment the existing ability to set it using idle, standby and sleep commands. Modified: stable/11/sbin/camcontrol/camcontrol.8 stable/11/sbin/camcontrol/camcontrol.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/camcontrol/camcontrol.8 ============================================================================== --- stable/11/sbin/camcontrol/camcontrol.8 Thu Aug 8 18:42:39 2019 (r350773) +++ stable/11/sbin/camcontrol/camcontrol.8 Thu Aug 8 18:48:48 2019 (r350774) @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 12, 2019 +.Dd April 22, 2019 .Dt CAMCONTROL 8 .Os .Sh NAME @@ -243,6 +243,10 @@ .Op device id .Op generic args .Nm +.Ic powermode +.Op device id +.Op generic args +.Nm .Ic apm .Op device id .Op generic args @@ -1388,6 +1392,8 @@ Value 0 disables timer. Put ATA device into SLEEP state. Note that the only way get device out of this state may be reset. +.It Ic powermode +Report ATA device power mode. .It Ic apm It optional parameter .Pq Fl l Modified: stable/11/sbin/camcontrol/camcontrol.c ============================================================================== --- stable/11/sbin/camcontrol/camcontrol.c Thu Aug 8 18:42:39 2019 (r350773) +++ stable/11/sbin/camcontrol/camcontrol.c Thu Aug 8 18:48:48 2019 (r350774) @@ -104,7 +104,8 @@ typedef enum { CAM_CMD_REPROBE = 0x00000025, CAM_CMD_ZONE = 0x00000026, CAM_CMD_EPC = 0x00000027, - CAM_CMD_TIMESTAMP = 0x00000028 + CAM_CMD_TIMESTAMP = 0x00000028, + CAM_CMD_POWER_MODE = 0x0000002a, } cam_cmdmask; typedef enum { @@ -230,6 +231,7 @@ static struct camcontrol_opts option_table[] = { {"idle", CAM_CMD_IDLE, CAM_ARG_NONE, "t:"}, {"standby", CAM_CMD_STANDBY, CAM_ARG_NONE, "t:"}, {"sleep", CAM_CMD_SLEEP, CAM_ARG_NONE, ""}, + {"powermode", CAM_CMD_POWER_MODE, CAM_ARG_NONE, ""}, {"apm", CAM_CMD_APM, CAM_ARG_NONE, "l:"}, {"aam", CAM_CMD_AAM, CAM_ARG_NONE, "l:"}, {"fwdownload", CAM_CMD_DOWNLOAD_FW, CAM_ARG_NONE, "f:qsy"}, @@ -8384,6 +8386,61 @@ bailout: } static int +atapm_proc_resp(struct cam_device *device, union ccb *ccb) +{ + struct ata_res *res; + + res = &ccb->ataio.res; + if (res->status & ATA_STATUS_ERROR) { + if (arglist & CAM_ARG_VERBOSE) { + cam_error_print(device, ccb, CAM_ESF_ALL, + CAM_EPF_ALL, stderr); + printf("error = 0x%02x, sector_count = 0x%04x, " + "device = 0x%02x, status = 0x%02x\n", + res->error, res->sector_count, + res->device, res->status); + } + + return (1); + } + + if (arglist & CAM_ARG_VERBOSE) { + fprintf(stdout, "%s%d: Raw native check power data:\n", + device->device_name, device->dev_unit_num); + /* res is 4 byte aligned */ + dump_data((uint16_t*)(uintptr_t)res, sizeof(struct ata_res)); + + printf("error = 0x%02x, sector_count = 0x%04x, device = 0x%02x, " + "status = 0x%02x\n", res->error, res->sector_count, + res->device, res->status); + } + + printf("%s%d: ", device->device_name, device->dev_unit_num); + switch (res->sector_count) { + case 0x00: + printf("Standby mode\n"); + break; + case 0x40: + printf("NV Cache Power Mode and the spindle is spun down or spinning down\n"); + break; + case 0x41: + printf("NV Cache Power Mode and the spindle is spun up or spinning up\n"); + break; + case 0x80: + printf("Idle mode\n"); + break; + case 0xff: + printf("Active or Idle mode\n"); + break; + default: + printf("Unknown mode 0x%02x\n", res->sector_count); + break; + } + + return (0); +} + +static int atapm(struct cam_device *device, int argc, char **argv, char *combinedopt, int retry_count, int timeout) { @@ -8391,6 +8448,7 @@ atapm(struct cam_device *device, int argc, char **argv int retval = 0; int t = -1; int c; + u_int8_t ata_flags = 0; u_char cmd, sc; ccb = cam_getccb(device); @@ -8419,6 +8477,10 @@ atapm(struct cam_device *device, int argc, char **argv cmd = ATA_STANDBY_IMMEDIATE; else cmd = ATA_STANDBY_CMD; + } else if (strcmp(argv[1], "powermode") == 0) { + cmd = ATA_CHECK_POWER_MODE; + ata_flags = AP_FLAG_CHK_COND; + t = -1; } else { cmd = ATA_SLEEP; t = -1; @@ -8436,11 +8498,12 @@ atapm(struct cam_device *device, int argc, char **argv else sc = 253; - retval = ata_do_28bit_cmd(device, + retval = ata_do_cmd(device, ccb, /*retries*/retry_count, /*flags*/CAM_DIR_NONE, /*protocol*/AP_PROTO_NON_DATA, + /*ata_flags*/ata_flags, /*tag_action*/MSG_SIMPLE_Q_TAG, /*command*/cmd, /*features*/0, @@ -8452,7 +8515,11 @@ atapm(struct cam_device *device, int argc, char **argv /*quiet*/1); cam_freeccb(ccb); - return (retval); + + if (retval || cmd != ATA_CHECK_POWER_MODE) + return (retval); + + return (atapm_proc_resp(device, ccb)); } static int @@ -9065,6 +9132,7 @@ usage(int printlong) " camcontrol idle [dev_id][generic args][-t time]\n" " camcontrol standby [dev_id][generic args][-t time]\n" " camcontrol sleep [dev_id][generic args]\n" +" camcontrol powermode [dev_id][generic args]\n" " camcontrol apm [dev_id][generic args][-l level]\n" " camcontrol aam [dev_id][generic args][-l level]\n" " camcontrol fwdownload [dev_id][generic args] <-f fw_image> [-q]\n" @@ -9128,6 +9196,7 @@ usage(int printlong) "idle send the ATA IDLE command to the named device\n" "standby send the ATA STANDBY command to the named device\n" "sleep send the ATA SLEEP command to the named device\n" +"powermode send the ATA CHECK POWER MODE command to the named device\n" "fwdownload program firmware of the named device with the given image\n" "security report or send ATA security commands to the named device\n" "persist send the SCSI PERSISTENT RESERVE IN or OUT commands\n" @@ -9694,6 +9763,7 @@ main(int argc, char **argv) case CAM_CMD_IDLE: case CAM_CMD_STANDBY: case CAM_CMD_SLEEP: + case CAM_CMD_POWER_MODE: error = atapm(cam_dev, argc, argv, combinedopt, retry_count, timeout); break; From owner-svn-src-stable-11@freebsd.org Thu Aug 8 18:52:54 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3A285AF4CD; Thu, 8 Aug 2019 18:52:54 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 464HYy0mJMz4jl6; Thu, 8 Aug 2019 18:52:54 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id EFCF8198E; Thu, 8 Aug 2019 18:52:53 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x78Iqrpp027547; Thu, 8 Aug 2019 18:52:53 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x78IqruA027546; Thu, 8 Aug 2019 18:52:53 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201908081852.x78IqruA027546@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 8 Aug 2019 18:52:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r350775 - stable/11/sys/cam/scsi X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/cam/scsi X-SVN-Commit-Revision: 350775 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Aug 2019 18:52:54 -0000 Author: mav Date: Thu Aug 8 18:52:53 2019 New Revision: 350775 URL: https://svnweb.freebsd.org/changeset/base/350775 Log: MFC r348111: Simplify math added in r310524. Should be no functional change. Modified: stable/11/sys/cam/scsi/scsi_all.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cam/scsi/scsi_all.c ============================================================================== --- stable/11/sys/cam/scsi/scsi_all.c Thu Aug 8 18:48:48 2019 (r350774) +++ stable/11/sys/cam/scsi/scsi_all.c Thu Aug 8 18:52:53 2019 (r350775) @@ -3941,7 +3941,7 @@ scsi_set_sense_data_fixed_va(struct scsi_sense_data *s } if (len > sizeof(sense->cmd_spec_info)) { data += len - sizeof(sense->cmd_spec_info); - len -= len - sizeof(sense->cmd_spec_info); + len = sizeof(sense->cmd_spec_info); } bcopy(data, &sense->cmd_spec_info[ sizeof(sense->cmd_spec_info) - len], len); From owner-svn-src-stable-11@freebsd.org Thu Aug 8 21:30:45 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 75601B3930; Thu, 8 Aug 2019 21:30:45 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 464M452YG0z4tkT; Thu, 8 Aug 2019 21:30:45 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 391AB3656; Thu, 8 Aug 2019 21:30:45 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x78LUjcx017848; Thu, 8 Aug 2019 21:30:45 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x78LUjmB017832; Thu, 8 Aug 2019 21:30:45 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201908082130.x78LUjmB017832@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 8 Aug 2019 21:30:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r350783 - stable/11/sys/cam/scsi X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/cam/scsi X-SVN-Commit-Revision: 350783 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Aug 2019 21:30:45 -0000 Author: mav Date: Thu Aug 8 21:30:44 2019 New Revision: 350783 URL: https://svnweb.freebsd.org/changeset/base/350783 Log: MFC r348963 (by imp): Minor white space changes. Remove trailing white space that's crept into this file. Modified: stable/11/sys/cam/scsi/scsi_xpt.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cam/scsi/scsi_xpt.c ============================================================================== --- stable/11/sys/cam/scsi/scsi_xpt.c Thu Aug 8 21:16:15 2019 (r350782) +++ stable/11/sys/cam/scsi/scsi_xpt.c Thu Aug 8 21:30:44 2019 (r350783) @@ -1601,7 +1601,7 @@ probe_device_check: start = strspn(serial_buf->serial_num, " "); slen = serial_buf->length - start; if (slen <= 0) { - /* + /* * SPC5r05 says that an all-space serial * number means no product serial number * is available @@ -2115,7 +2115,7 @@ scsi_scan_bus(struct cam_periph *periph, union ccb *re CAM_GET_LUN(target->luns, 0, first); if (first == 0 && scan_info->lunindex[target_id] == 0) { scan_info->lunindex[target_id]++; - } + } /* * Skip any LUNs that the HBA can't deal with. @@ -2600,7 +2600,7 @@ scsi_dev_advinfo(union ccb *start_ccb) * We fetch extended inquiry data during probe, if * available. We don't allow changing it. */ - if (cdai->flags & CDAI_FLAG_STORE) + if (cdai->flags & CDAI_FLAG_STORE) return; cdai->provsiz = device->ext_inq_len; if (device->ext_inq_len == 0) @@ -2992,7 +2992,7 @@ scsi_dev_async(u_int32_t async_code, struct cam_eb *bu */ if (async_code == AC_SENT_BDR || async_code == AC_BUS_RESET) { - cam_freeze_devq(&newpath); + cam_freeze_devq(&newpath); cam_release_devq(&newpath, RELSIM_RELEASE_AFTER_TIMEOUT, /*reduction*/0, @@ -3052,7 +3052,7 @@ scsi_announce_periph(struct cam_periph *periph) xpt_setup_ccb(&cpi.ccb_h, path, CAM_PRIORITY_NORMAL); cpi.ccb_h.func_code = XPT_PATH_INQ; xpt_action((union ccb *)&cpi); - /* Report connection speed */ + /* Report connection speed */ speed = cpi.base_transfer_speed; freq = 0; if (cts.ccb_h.status == CAM_REQ_CMP && cts.transport == XPORT_SPI) { From owner-svn-src-stable-11@freebsd.org Thu Aug 8 21:31:24 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 33BDEB39B6; Thu, 8 Aug 2019 21:31:24 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 464M4r0ccwz4ttZ; Thu, 8 Aug 2019 21:31:24 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id EBE5637E9; Thu, 8 Aug 2019 21:31:23 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x78LVNVO018719; Thu, 8 Aug 2019 21:31:23 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x78LVNao018718; Thu, 8 Aug 2019 21:31:23 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201908082131.x78LVNao018718@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 8 Aug 2019 21:31:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r350784 - stable/11/sbin/camcontrol X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sbin/camcontrol X-SVN-Commit-Revision: 350784 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Aug 2019 21:31:24 -0000 Author: mav Date: Thu Aug 8 21:31:23 2019 New Revision: 350784 URL: https://svnweb.freebsd.org/changeset/base/350784 Log: MFC r349010 (by imp): Increase the timeout for READ NATIVE MAX READ NATIVE MAX can take longer than a second if the queued NCQ I/Os take longer than a second to drain. Modified: stable/11/sbin/camcontrol/camcontrol.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/camcontrol/camcontrol.c ============================================================================== --- stable/11/sbin/camcontrol/camcontrol.c Thu Aug 8 21:30:44 2019 (r350783) +++ stable/11/sbin/camcontrol/camcontrol.c Thu Aug 8 21:31:23 2019 (r350784) @@ -1892,7 +1892,7 @@ ata_read_native_max(struct cam_device *device, int ret /*sector_count*/0, /*data_ptr*/NULL, /*dxfer_len*/0, - timeout ? timeout : 1000, + timeout ? timeout : 5000, is48bit); if (error) From owner-svn-src-stable-11@freebsd.org Thu Aug 8 21:32:27 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D2FDDB3BA2; Thu, 8 Aug 2019 21:32:27 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 464M634rGyz4v4D; Thu, 8 Aug 2019 21:32:27 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 87DA83836; Thu, 8 Aug 2019 21:32:27 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x78LWRwP022465; Thu, 8 Aug 2019 21:32:27 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x78LWRmR022464; Thu, 8 Aug 2019 21:32:27 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201908082132.x78LWRmR022464@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 8 Aug 2019 21:32:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r350785 - stable/11/sys/cam X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/cam X-SVN-Commit-Revision: 350785 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Aug 2019 21:32:27 -0000 Author: mav Date: Thu Aug 8 21:32:26 2019 New Revision: 350785 URL: https://svnweb.freebsd.org/changeset/base/350785 Log: MFC r349243: Optimize xpt_getattr(). Do not allocate temporary buffer for attributes we are going to return as-is, just make sure to NUL-terminate them. Do not zero temporary 64KB buffer for CDAI_TYPE_SCSI_DEVID, XPT tells us how much data it filled and there are also length fields inside the returned data also. Modified: stable/11/sys/cam/cam_xpt.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cam/cam_xpt.c ============================================================================== --- stable/11/sys/cam/cam_xpt.c Thu Aug 8 21:31:23 2019 (r350784) +++ stable/11/sys/cam/cam_xpt.c Thu Aug 8 21:32:26 2019 (r350785) @@ -1120,6 +1120,7 @@ xpt_getattr(char *buf, size_t len, const char *attr, s cdai.ccb_h.func_code = XPT_DEV_ADVINFO; cdai.flags = CDAI_FLAG_NONE; cdai.bufsiz = len; + cdai.buf = buf; if (!strcmp(attr, "GEOM::ident")) cdai.buftype = CDAI_TYPE_SERIAL_NUM; @@ -1129,14 +1130,14 @@ xpt_getattr(char *buf, size_t len, const char *attr, s strcmp(attr, "GEOM::lunname") == 0) { cdai.buftype = CDAI_TYPE_SCSI_DEVID; cdai.bufsiz = CAM_SCSI_DEVID_MAXLEN; + cdai.buf = malloc(cdai.bufsiz, M_CAMXPT, M_NOWAIT); + if (cdai.buf == NULL) { + ret = ENOMEM; + goto out; + } } else goto out; - cdai.buf = malloc(cdai.bufsiz, M_CAMXPT, M_NOWAIT|M_ZERO); - if (cdai.buf == NULL) { - ret = ENOMEM; - goto out; - } xpt_action((union ccb *)&cdai); /* can only be synchronous */ if ((cdai.ccb_h.status & CAM_DEV_QFRZN) != 0) cam_release_devq(cdai.ccb_h.path, 0, 0, 0, FALSE); @@ -1201,13 +1202,15 @@ xpt_getattr(char *buf, size_t len, const char *attr, s ret = EFAULT; } } else { - ret = 0; - if (strlcpy(buf, cdai.buf, len) >= len) + if (cdai.provsiz < len) { + cdai.buf[cdai.provsiz] = 0; + ret = 0; + } else ret = EFAULT; } out: - if (cdai.buf != NULL) + if ((char *)cdai.buf != buf) free(cdai.buf, M_CAMXPT); return ret; } From owner-svn-src-stable-11@freebsd.org Thu Aug 8 21:33:14 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C11E3B3C2D; Thu, 8 Aug 2019 21:33:14 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 464M6y4g2hz4vJj; Thu, 8 Aug 2019 21:33:14 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 81EC8384B; Thu, 8 Aug 2019 21:33:14 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x78LXECw022582; Thu, 8 Aug 2019 21:33:14 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x78LXECi022581; Thu, 8 Aug 2019 21:33:14 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201908082133.x78LXECi022581@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 8 Aug 2019 21:33:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r350786 - stable/11/sys/cam X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/cam X-SVN-Commit-Revision: 350786 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Aug 2019 21:33:14 -0000 Author: mav Date: Thu Aug 8 21:33:14 2019 New Revision: 350786 URL: https://svnweb.freebsd.org/changeset/base/350786 Log: MFC r349283 (by scottl): Refactor xpt_getattr() to make it more readable. No outwardly visible functional changes, though code flow was modified a bit internally to lessen the need for goto jumps and chained if conditionals. Modified: stable/11/sys/cam/cam_xpt.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cam/cam_xpt.c ============================================================================== --- stable/11/sys/cam/cam_xpt.c Thu Aug 8 21:32:26 2019 (r350785) +++ stable/11/sys/cam/cam_xpt.c Thu Aug 8 21:33:14 2019 (r350786) @@ -1111,6 +1111,7 @@ xpt_getattr(char *buf, size_t len, const char *attr, s { int ret = -1, l, o; struct ccb_dev_advinfo cdai; + struct scsi_vpd_device_id *did; struct scsi_vpd_id_descriptor *idd; xpt_path_assert(path, MA_OWNED); @@ -1143,31 +1144,36 @@ xpt_getattr(char *buf, size_t len, const char *attr, s cam_release_devq(cdai.ccb_h.path, 0, 0, 0, FALSE); if (cdai.provsiz == 0) goto out; - if (cdai.buftype == CDAI_TYPE_SCSI_DEVID) { + switch(cdai.buftype) { + case CDAI_TYPE_SCSI_DEVID: + did = (struct scsi_vpd_device_id *)cdai.buf; if (strcmp(attr, "GEOM::lunid") == 0) { - idd = scsi_get_devid((struct scsi_vpd_device_id *)cdai.buf, - cdai.provsiz, scsi_devid_is_lun_naa); + idd = scsi_get_devid(did, cdai.provsiz, + scsi_devid_is_lun_naa); if (idd == NULL) - idd = scsi_get_devid((struct scsi_vpd_device_id *)cdai.buf, - cdai.provsiz, scsi_devid_is_lun_eui64); + idd = scsi_get_devid(did, cdai.provsiz, + scsi_devid_is_lun_eui64); if (idd == NULL) - idd = scsi_get_devid((struct scsi_vpd_device_id *)cdai.buf, - cdai.provsiz, scsi_devid_is_lun_uuid); + idd = scsi_get_devid(did, cdai.provsiz, + scsi_devid_is_lun_uuid); if (idd == NULL) - idd = scsi_get_devid((struct scsi_vpd_device_id *)cdai.buf, - cdai.provsiz, scsi_devid_is_lun_md5); + idd = scsi_get_devid(did, cdai.provsiz, + scsi_devid_is_lun_md5); } else idd = NULL; + if (idd == NULL) - idd = scsi_get_devid((struct scsi_vpd_device_id *)cdai.buf, - cdai.provsiz, scsi_devid_is_lun_t10); + idd = scsi_get_devid(did, cdai.provsiz, + scsi_devid_is_lun_t10); if (idd == NULL) - idd = scsi_get_devid((struct scsi_vpd_device_id *)cdai.buf, - cdai.provsiz, scsi_devid_is_lun_name); + idd = scsi_get_devid(did, cdai.provsiz, + scsi_devid_is_lun_name); if (idd == NULL) - goto out; + break; + ret = 0; - if ((idd->proto_codeset & SVPD_ID_CODESET_MASK) == SVPD_ID_CODESET_ASCII) { + if ((idd->proto_codeset & SVPD_ID_CODESET_MASK) == + SVPD_ID_CODESET_ASCII) { if (idd->length < len) { for (l = 0; l < idd->length; l++) buf[l] = idd->identifier[l] ? @@ -1175,38 +1181,46 @@ xpt_getattr(char *buf, size_t len, const char *attr, s buf[l] = 0; } else ret = EFAULT; - } else if ((idd->proto_codeset & SVPD_ID_CODESET_MASK) == SVPD_ID_CODESET_UTF8) { + break; + } + if ((idd->proto_codeset & SVPD_ID_CODESET_MASK) == + SVPD_ID_CODESET_UTF8) { l = strnlen(idd->identifier, idd->length); if (l < len) { bcopy(idd->identifier, buf, l); buf[l] = 0; } else ret = EFAULT; - } else if ((idd->id_type & SVPD_ID_TYPE_MASK) == SVPD_ID_TYPE_UUID - && idd->identifier[0] == 0x10) { - if ((idd->length - 2) * 2 + 4 < len) { - for (l = 2, o = 0; l < idd->length; l++) { - if (l == 6 || l == 8 || l == 10 || l == 12) - o += sprintf(buf + o, "-"); - o += sprintf(buf + o, "%02x", - idd->identifier[l]); - } - } else + break; + } + if ((idd->id_type & SVPD_ID_TYPE_MASK) == + SVPD_ID_TYPE_UUID && idd->identifier[0] == 0x10) { + if ((idd->length - 2) * 2 + 4 >= len) { ret = EFAULT; - } else { - if (idd->length * 2 < len) { - for (l = 0; l < idd->length; l++) - sprintf(buf + l * 2, "%02x", - idd->identifier[l]); - } else - ret = EFAULT; + break; + } + for (l = 2, o = 0; l < idd->length; l++) { + if (l == 6 || l == 8 || l == 10 || l == 12) + o += sprintf(buf + o, "-"); + o += sprintf(buf + o, "%02x", + idd->identifier[l]); + } + break; } - } else { + if (idd->length * 2 < len) { + for (l = 0; l < idd->length; l++) + sprintf(buf + l * 2, "%02x", + idd->identifier[l]); + } else + ret = EFAULT; + break; + default: if (cdai.provsiz < len) { cdai.buf[cdai.provsiz] = 0; ret = 0; } else ret = EFAULT; + break; } out: From owner-svn-src-stable-11@freebsd.org Thu Aug 8 21:33:51 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4F0D1B3CB1; Thu, 8 Aug 2019 21:33:51 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 464M7g1Q6rz4vQq; Thu, 8 Aug 2019 21:33:51 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 12246384C; Thu, 8 Aug 2019 21:33:51 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x78LXoXg022674; Thu, 8 Aug 2019 21:33:50 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x78LXoD3022673; Thu, 8 Aug 2019 21:33:50 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201908082133.x78LXoD3022673@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 8 Aug 2019 21:33:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r350787 - stable/11/sys/cam/ctl X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/cam/ctl X-SVN-Commit-Revision: 350787 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Aug 2019 21:33:51 -0000 Author: mav Date: Thu Aug 8 21:33:50 2019 New Revision: 350787 URL: https://svnweb.freebsd.org/changeset/base/350787 Log: MFC r349246: SPC-3 and up require some UAs to be returned as fixed. Modified: stable/11/sys/cam/ctl/ctl_error.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cam/ctl/ctl_error.c ============================================================================== --- stable/11/sys/cam/ctl/ctl_error.c Thu Aug 8 21:33:14 2019 (r350786) +++ stable/11/sys/cam/ctl/ctl_error.c Thu Aug 8 21:33:50 2019 (r350787) @@ -79,6 +79,12 @@ ctl_set_sense_data_va(struct scsi_sense_data *sense_da */ if (sense_format == SSD_TYPE_NONE) { /* + * SPC-3 and up require some UAs to be returned as fixed. + */ + if (asc == 0x29 || (asc == 0x2A && ascq == 0x01)) + sense_format = SSD_TYPE_FIXED; + else + /* * If the format isn't specified, we only return descriptor * sense if the LUN exists and descriptor sense is turned * on for that LUN. From owner-svn-src-stable-11@freebsd.org Thu Aug 8 21:37:27 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id AFFDAB3D7D; Thu, 8 Aug 2019 21:37:27 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 464MCq48vRz4vZR; Thu, 8 Aug 2019 21:37:27 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6BE9C3871; Thu, 8 Aug 2019 21:37:27 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x78LbRDq022912; Thu, 8 Aug 2019 21:37:27 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x78LbRK5022911; Thu, 8 Aug 2019 21:37:27 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201908082137.x78LbRK5022911@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 8 Aug 2019 21:37:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r350788 - stable/11/sys/cam/scsi X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/cam/scsi X-SVN-Commit-Revision: 350788 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Aug 2019 21:37:27 -0000 Author: mav Date: Thu Aug 8 21:37:26 2019 New Revision: 350788 URL: https://svnweb.freebsd.org/changeset/base/350788 Log: MFC r349284: Make ELEMENT INDEX validation more strict. SES specifications tell: "The Additional Element Status descriptors shall be in the same order as the status elements in the Enclosure Status diagnostic page". It allows us to question ELEMENT INDEX that is lower then values we already processed. There are many SAS2 enclosures with this kind of problem. While there, add more specific error messages for cases when ELEMENT INDEX is obviously wrong. Also skip elements with INVALID bit set. Modified: stable/11/sys/cam/scsi/scsi_enc_ses.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cam/scsi/scsi_enc_ses.c ============================================================================== --- stable/11/sys/cam/scsi/scsi_enc_ses.c Thu Aug 8 21:33:50 2019 (r350787) +++ stable/11/sys/cam/scsi/scsi_enc_ses.c Thu Aug 8 21:37:26 2019 (r350788) @@ -1679,7 +1679,6 @@ ses_process_elm_addlstatus(enc_softc_t *enc, struct en struct ses_iterator iter, titer; int eip; int err; - int ignore_index = 0; int length; int offset; enc_cache_t *enc_cache; @@ -1750,7 +1749,7 @@ ses_process_elm_addlstatus(enc_softc_t *enc, struct en elm_hdr = (struct ses_elm_addlstatus_base_hdr *)&buf[offset]; eip = ses_elm_addlstatus_eip(elm_hdr); - if (eip && !ignore_index) { + if (eip) { struct ses_elm_addlstatus_eip_hdr *eip_hdr; int expected_index, index; ses_elem_index_type_t index_type; @@ -1763,17 +1762,44 @@ ses_process_elm_addlstatus(enc_softc_t *enc, struct en index_type = SES_ELEM_INDEX_INDIVIDUAL; expected_index = iter.individual_element_index; } + if (eip_hdr->element_index < expected_index) { + ENC_VLOG(enc, "%s: provided %selement index " + "%d is lower then expected %d\n", + __func__, (eip_hdr->byte2 & + SES_ADDL_EIP_EIIOE) ? "global " : "", + eip_hdr->element_index, expected_index); + goto badindex; + } titer = iter; telement = ses_iter_seek_to(&titer, eip_hdr->element_index, index_type); - if (telement != NULL && - (ses_typehasaddlstatus(enc, titer.type_index) != - TYPE_ADDLSTATUS_NONE || - titer.type_index > ELMTYP_SAS_CONN)) { + if (telement == NULL) { + ENC_VLOG(enc, "%s: provided %selement index " + "%d does not exist\n", __func__, + (eip_hdr->byte2 & SES_ADDL_EIP_EIIOE) ? + "global " : "", eip_hdr->element_index); + goto badindex; + } + if (ses_typehasaddlstatus(enc, titer.type_index) == + TYPE_ADDLSTATUS_NONE) { + ENC_VLOG(enc, "%s: provided %selement index " + "%d can't have additional status\n", + __func__, + (eip_hdr->byte2 & SES_ADDL_EIP_EIIOE) ? + "global " : "", eip_hdr->element_index); +badindex: + /* + * If we expected mandatory element, we may + * guess it was just a wrong index and we may + * use the status. If element was optional, + * then we have no idea where status belongs. + */ + if (status_type == TYPE_ADDLSTATUS_OPTIONAL) + break; + } else { iter = titer; element = telement; - } else - ignore_index = 1; + } if (eip_hdr->byte2 & SES_ADDL_EIP_EIIOE) index = iter.global_element_index; @@ -1795,35 +1821,41 @@ ses_process_elm_addlstatus(enc_softc_t *enc, struct en "type element index=%d, offset=0x%x, " "byte0=0x%x, length=0x%x\n", __func__, iter.global_element_index, iter.type_index, - iter.type_element_index, offset, elmpriv->addl.hdr->byte0, - elmpriv->addl.hdr->length); + iter.type_element_index, offset, elm_hdr->byte0, + elm_hdr->length); /* Skip to after the length field */ offset += sizeof(struct ses_elm_addlstatus_base_hdr); /* Make sure the descriptor is within bounds */ - if ((offset + elmpriv->addl.hdr->length) > length) { + if ((offset + elm_hdr->length) > length) { ENC_VLOG(enc, "Element %d Beyond End " "of Additional Element Status Descriptors\n", iter.global_element_index); break; } + /* Skip elements marked as invalid. */ + if (ses_elm_addlstatus_invalid(elm_hdr)) { + offset += elm_hdr->length; + continue; + } + /* Advance to the protocol data, skipping eip bytes if needed */ offset += (eip * SES_EIP_HDR_EXTRA_LEN); - proto_info_len = elmpriv->addl.hdr->length + proto_info_len = elm_hdr->length - (eip * SES_EIP_HDR_EXTRA_LEN); /* Errors in this block are ignored as they are non-fatal */ - switch(ses_elm_addlstatus_proto(elmpriv->addl.hdr)) { + switch(ses_elm_addlstatus_proto(elm_hdr)) { case SPSP_PROTO_FC: - if (elmpriv->addl.hdr->length == 0) + if (elm_hdr->length == 0) break; ses_get_elm_addlstatus_fc(enc, enc_cache, &buf[offset], proto_info_len); break; case SPSP_PROTO_SAS: - if (elmpriv->addl.hdr->length <= 2) + if (elm_hdr->length <= 2) break; ses_get_elm_addlstatus_sas(enc, enc_cache, &buf[offset], @@ -1834,7 +1866,7 @@ ses_process_elm_addlstatus(enc_softc_t *enc, struct en default: ENC_VLOG(enc, "Element %d: Unknown Additional Element " "Protocol 0x%x\n", iter.global_element_index, - ses_elm_addlstatus_proto(elmpriv->addl.hdr)); + ses_elm_addlstatus_proto(elm_hdr)); break; } From owner-svn-src-stable-11@freebsd.org Thu Aug 8 21:38:14 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BBF84B3E01; Thu, 8 Aug 2019 21:38:14 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 464MDk4YRYz4vhq; Thu, 8 Aug 2019 21:38:14 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7E0283879; Thu, 8 Aug 2019 21:38:14 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x78LcEeZ023002; Thu, 8 Aug 2019 21:38:14 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x78LcEK1023001; Thu, 8 Aug 2019 21:38:14 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201908082138.x78LcEK1023001@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 8 Aug 2019 21:38:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r350789 - stable/11/sys/cam/scsi X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/cam/scsi X-SVN-Commit-Revision: 350789 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Aug 2019 21:38:14 -0000 Author: mav Date: Thu Aug 8 21:38:13 2019 New Revision: 350789 URL: https://svnweb.freebsd.org/changeset/base/350789 Log: MFC r349287: Remove ancient SCSI-2/3 mentioning. Modified: stable/11/sys/cam/scsi/scsi_enc.c stable/11/sys/cam/scsi/scsi_enc_internal.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cam/scsi/scsi_enc.c ============================================================================== --- stable/11/sys/cam/scsi/scsi_enc.c Thu Aug 8 21:37:26 2019 (r350788) +++ stable/11/sys/cam/scsi/scsi_enc.c Thu Aug 8 21:38:13 2019 (r350789) @@ -683,14 +683,8 @@ enc_type(struct ccb_getdev *cgd) buflen = min(sizeof(cgd->inq_data), SID_ADDITIONAL_LENGTH(&cgd->inq_data)); - if ((iqd[0] & 0x1f) == T_ENCLOSURE) { - if ((iqd[2] & 0x7) > 2) { - return (ENC_SES); - } else { - return (ENC_SES_SCSI2); - } - return (ENC_NONE); - } + if ((iqd[0] & 0x1f) == T_ENCLOSURE) + return (ENC_SES); #ifdef SES_ENABLE_PASSTHROUGH if ((iqd[6] & 0x40) && (iqd[2] & 0x7) >= 2) { @@ -926,7 +920,6 @@ enc_ctor(struct cam_periph *periph, void *arg) switch (enc->enc_type) { case ENC_SES: - case ENC_SES_SCSI2: case ENC_SES_PASSTHROUGH: case ENC_SEMB_SES: err = ses_softc_init(enc); @@ -1015,17 +1008,14 @@ enc_ctor(struct cam_periph *periph, void *arg) case ENC_NONE: tname = "No ENC device"; break; - case ENC_SES_SCSI2: - tname = "SCSI-2 ENC Device"; - break; case ENC_SES: - tname = "SCSI-3 ENC Device"; + tname = "SES Device"; break; case ENC_SES_PASSTHROUGH: - tname = "ENC Passthrough Device"; + tname = "SES Passthrough Device"; break; case ENC_SAFT: - tname = "SAF-TE Compliant Device"; + tname = "SAF-TE Device"; break; case ENC_SEMB_SES: tname = "SEMB SES Device"; Modified: stable/11/sys/cam/scsi/scsi_enc_internal.h ============================================================================== --- stable/11/sys/cam/scsi/scsi_enc_internal.h Thu Aug 8 21:37:26 2019 (r350788) +++ stable/11/sys/cam/scsi/scsi_enc_internal.h Thu Aug 8 21:38:13 2019 (r350789) @@ -53,10 +53,8 @@ typedef struct enc_element { typedef enum { ENC_NONE, - ENC_SES_SCSI2, ENC_SES, ENC_SES_PASSTHROUGH, - ENC_SEN, ENC_SAFT, ENC_SEMB_SES, ENC_SEMB_SAFT From owner-svn-src-stable-11@freebsd.org Thu Aug 8 21:38:54 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4CB2EB3E79; Thu, 8 Aug 2019 21:38:54 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 464MFV1B8mz4vpw; Thu, 8 Aug 2019 21:38:54 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E448F387A; Thu, 8 Aug 2019 21:38:53 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x78LcrEv023084; Thu, 8 Aug 2019 21:38:53 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x78LcrqS023082; Thu, 8 Aug 2019 21:38:53 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201908082138.x78LcrqS023082@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 8 Aug 2019 21:38:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r350790 - stable/11/sys/cam/scsi X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/cam/scsi X-SVN-Commit-Revision: 350790 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Aug 2019 21:38:54 -0000 Author: mav Date: Thu Aug 8 21:38:53 2019 New Revision: 350790 URL: https://svnweb.freebsd.org/changeset/base/350790 Log: MFC r349292: Decouple enc/ses verbosity from bootverbose. I don't want to be regularly notified that my enclosure violates standards until there is some real problem I want to debug. Modified: stable/11/sys/cam/scsi/scsi_enc.c stable/11/sys/cam/scsi/scsi_enc_internal.h stable/11/sys/cam/scsi/scsi_enc_safte.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cam/scsi/scsi_enc.c ============================================================================== --- stable/11/sys/cam/scsi/scsi_enc.c Thu Aug 8 21:38:13 2019 (r350789) +++ stable/11/sys/cam/scsi/scsi_enc.c Thu Aug 8 21:38:53 2019 (r350790) @@ -80,6 +80,14 @@ static enctyp enc_type(struct ccb_getdev *); SYSCTL_NODE(_kern_cam, OID_AUTO, enc, CTLFLAG_RD, 0, "CAM Enclosure Services driver"); +#if defined(DEBUG) || defined(ENC_DEBUG) +int enc_verbose = 1; +#else +int enc_verbose = 0; +#endif +SYSCTL_INT(_kern_cam_enc, OID_AUTO, verbose, CTLFLAG_RWTUN, + &enc_verbose, 0, "Enable verbose logging"); + static struct periph_driver encdriver = { enc_init, "ses", TAILQ_HEAD_INITIALIZER(encdriver.units), /* generation */ 0 Modified: stable/11/sys/cam/scsi/scsi_enc_internal.h ============================================================================== --- stable/11/sys/cam/scsi/scsi_enc_internal.h Thu Aug 8 21:38:13 2019 (r350789) +++ stable/11/sys/cam/scsi/scsi_enc_internal.h Thu Aug 8 21:38:53 2019 (r350790) @@ -34,6 +34,8 @@ #ifndef __SCSI_ENC_INTERNAL_H__ #define __SCSI_ENC_INTERNAL_H__ +#include + typedef struct enc_element { uint32_t enctype : 8, /* enclosure type */ @@ -199,6 +201,9 @@ enc_softc_init_t ses_softc_init; /* SAF-TE interface */ enc_softc_init_t safte_softc_init; +SYSCTL_DECL(_kern_cam_enc); +extern int enc_verbose; + /* Helper macros */ MALLOC_DECLARE(M_SCSIENC); #define ENC_CFLAGS CAM_RETRY_SELTO @@ -211,7 +216,7 @@ MALLOC_DECLARE(M_SCSIENC); #else #define ENC_DLOG if (0) enc_log #endif -#define ENC_VLOG if (bootverbose) enc_log +#define ENC_VLOG if (enc_verbose) enc_log #define ENC_MALLOC(amt) malloc(amt, M_SCSIENC, M_NOWAIT) #define ENC_MALLOCZ(amt) malloc(amt, M_SCSIENC, M_ZERO|M_NOWAIT) /* Cast away const avoiding GCC warnings. */ Modified: stable/11/sys/cam/scsi/scsi_enc_safte.c ============================================================================== --- stable/11/sys/cam/scsi/scsi_enc_safte.c Thu Aug 8 21:38:13 2019 (r350789) +++ stable/11/sys/cam/scsi/scsi_enc_safte.c Thu Aug 8 21:38:53 2019 (r350790) @@ -225,7 +225,6 @@ static char *safte_2little = "Too Little Data Returned } int emulate_array_devices = 1; -SYSCTL_DECL(_kern_cam_enc); SYSCTL_INT(_kern_cam_enc, OID_AUTO, emulate_array_devices, CTLFLAG_RWTUN, &emulate_array_devices, 0, "Emulate Array Devices for SAF-TE"); From owner-svn-src-stable-11@freebsd.org Thu Aug 8 21:43:01 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 44D8FB40DD; Thu, 8 Aug 2019 21:43:01 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 464MLF14D8z3C1y; Thu, 8 Aug 2019 21:43:01 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E112D3AC2; Thu, 8 Aug 2019 21:43:00 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x78Lh0QV028993; Thu, 8 Aug 2019 21:43:00 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x78Lh0VZ028992; Thu, 8 Aug 2019 21:43:00 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201908082143.x78Lh0VZ028992@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 8 Aug 2019 21:43:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r350791 - stable/11/sys/dev/ahci X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/dev/ahci X-SVN-Commit-Revision: 350791 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Aug 2019 21:43:01 -0000 Author: mav Date: Thu Aug 8 21:43:00 2019 New Revision: 350791 URL: https://svnweb.freebsd.org/changeset/base/350791 Log: MFC r336760 (by luporl): Fixed endianess issue in AHCI driver There were some bits that were being set in cmd_flags (a field of AHCI's command list structure) after cmd_flags was converted to little endian. On a big endian host, such as PowerPC, this would set the wrong bits. This was preventing AHCI driver from working on these hosts. Modified: stable/11/sys/dev/ahci/ahci.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/ahci/ahci.c ============================================================================== --- stable/11/sys/dev/ahci/ahci.c Thu Aug 8 21:38:53 2019 (r350790) +++ stable/11/sys/dev/ahci/ahci.c Thu Aug 8 21:43:00 2019 (r350791) @@ -1528,6 +1528,7 @@ ahci_execute_transaction(struct ahci_slot *slot) int fis_size, i, softreset; uint8_t *fis = ch->dma.rfis + 0x40; uint8_t val; + uint16_t cmd_flags; /* Get a piece of the workspace for this request */ ctp = (struct ahci_cmd_tab *) @@ -1541,12 +1542,12 @@ ahci_execute_transaction(struct ahci_slot *slot) /* Setup the command list entry */ clp = (struct ahci_cmd_list *) (ch->dma.work + AHCI_CL_OFFSET + (AHCI_CL_SIZE * slot->slot)); - clp->cmd_flags = htole16( + cmd_flags = (ccb->ccb_h.flags & CAM_DIR_OUT ? AHCI_CMD_WRITE : 0) | (ccb->ccb_h.func_code == XPT_SCSI_IO ? (AHCI_CMD_ATAPI | AHCI_CMD_PREFETCH) : 0) | (fis_size / sizeof(u_int32_t)) | - (port << 12)); + (port << 12); clp->prd_length = htole16(slot->dma.nsegs); /* Special handling for Soft Reset command. */ if ((ccb->ccb_h.func_code == XPT_ATA_IO) && @@ -1557,7 +1558,7 @@ ahci_execute_transaction(struct ahci_slot *slot) ahci_stop(ch); ahci_clo(ch); ahci_start(ch, 0); - clp->cmd_flags |= AHCI_CMD_RESET | AHCI_CMD_CLR_BUSY; + cmd_flags |= AHCI_CMD_RESET | AHCI_CMD_CLR_BUSY; } else { softreset = 2; /* Prepare FIS receive area for check. */ @@ -1567,6 +1568,7 @@ ahci_execute_transaction(struct ahci_slot *slot) } else softreset = 0; clp->bytecount = 0; + clp->cmd_flags = htole16(cmd_flags); clp->cmd_table_phys = htole64(ch->dma.work_bus + AHCI_CT_OFFSET + (AHCI_CT_SIZE * slot->slot)); bus_dmamap_sync(ch->dma.work_tag, ch->dma.work_map, From owner-svn-src-stable-11@freebsd.org Thu Aug 8 21:44:38 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 34899B4170; Thu, 8 Aug 2019 21:44:38 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 464MN60KlXz3C9S; Thu, 8 Aug 2019 21:44:38 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E115B3AD4; Thu, 8 Aug 2019 21:44:37 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x78LiboX029149; Thu, 8 Aug 2019 21:44:37 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x78Lib09029148; Thu, 8 Aug 2019 21:44:37 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201908082144.x78Lib09029148@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 8 Aug 2019 21:44:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r350792 - stable/11/sys/dev/ahci X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/dev/ahci X-SVN-Commit-Revision: 350792 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Aug 2019 21:44:38 -0000 Author: mav Date: Thu Aug 8 21:44:37 2019 New Revision: 350792 URL: https://svnweb.freebsd.org/changeset/base/350792 Log: MFC r340092 (by imp): Implement ability to turn on/off PHYs for AHCI devices. As part of Chuck's work on fixing kernel crashes caused by disk I/O errors, it is useful to be able to trigger various kinds of errors. This patch allows causing an AHCI-attached disk to disappear, by having the driver keep the PHY disabled when the driver would otherwise enable the PHY. It also allows making the disk reappear by having the driver go back to setting the PHY enable/disable state as it normal would and simulating the hardware event that causes a bus rescan. Modified: stable/11/sys/dev/ahci/ahci.c stable/11/sys/dev/ahci/ahci.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/ahci/ahci.c ============================================================================== --- stable/11/sys/dev/ahci/ahci.c Thu Aug 8 21:43:00 2019 (r350791) +++ stable/11/sys/dev/ahci/ahci.c Thu Aug 8 21:44:37 2019 (r350792) @@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -78,6 +79,8 @@ static void ahci_stop(struct ahci_channel *ch); static void ahci_clo(struct ahci_channel *ch); static void ahci_start_fr(struct ahci_channel *ch); static void ahci_stop_fr(struct ahci_channel *ch); +static int ahci_phy_check_events(struct ahci_channel *ch, u_int32_t serr); +static uint32_t ahci_ch_detval(struct ahci_channel *ch, uint32_t val); static int ahci_sata_connect(struct ahci_channel *ch); static int ahci_sata_phy_reset(struct ahci_channel *ch); @@ -98,6 +101,13 @@ static MALLOC_DEFINE(M_AHCI, "AHCI driver", "AHCI driv #define RECOVERY_REQUEST_SENSE 2 #define recovery_slot spriv_field1 +static uint32_t +ahci_ch_detval(struct ahci_channel *ch, uint32_t val) +{ + + return ch->disablephy ? ATA_SC_DET_DISABLE : val; +} + int ahci_ctlr_setup(device_t dev) { @@ -662,11 +672,38 @@ ahci_ch_probe(device_t dev) } static int +ahci_ch_disablephy_proc(SYSCTL_HANDLER_ARGS) +{ + struct ahci_channel *ch; + int error, value; + + ch = arg1; + value = ch->disablephy; + error = sysctl_handle_int(oidp, &value, 0, req); + if (error != 0 || req->newptr == NULL || (value != 0 && value != 1)) + return (error); + + mtx_lock(&ch->mtx); + ch->disablephy = value; + if (value) { + ahci_ch_deinit(ch->dev); + } else { + ahci_ch_init(ch->dev); + ahci_phy_check_events(ch, ATA_SE_PHY_CHANGED | ATA_SE_EXCHANGED); + } + mtx_unlock(&ch->mtx); + + return (0); +} + +static int ahci_ch_attach(device_t dev) { struct ahci_controller *ctlr = device_get_softc(device_get_parent(dev)); struct ahci_channel *ch = device_get_softc(dev); struct cam_devq *devq; + struct sysctl_ctx_list *ctx; + struct sysctl_oid *tree; int rid, error, i, sata_rev = 0; u_int32_t version; @@ -784,6 +821,11 @@ ahci_ch_attach(device_t dev) ahci_ch_pm, ch); } mtx_unlock(&ch->mtx); + ctx = device_get_sysctl_ctx(dev); + tree = device_get_sysctl_tree(dev); + SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "disable_phy", + CTLFLAG_RW | CTLTYPE_UINT, ch, 0, ahci_ch_disablephy_proc, "IU", + "Disable PHY"); return (0); err3: @@ -2494,7 +2536,7 @@ static int ahci_sata_phy_reset(struct ahci_channel *ch) { int sata_rev; - uint32_t val; + uint32_t val, detval; if (ch->listening) { val = ATA_INL(ch->r_mem, AHCI_P_CMD); @@ -2511,12 +2553,14 @@ ahci_sata_phy_reset(struct ahci_channel *ch) val = ATA_SC_SPD_SPEED_GEN3; else val = 0; + detval = ahci_ch_detval(ch, ATA_SC_DET_RESET); ATA_OUTL(ch->r_mem, AHCI_P_SCTL, - ATA_SC_DET_RESET | val | + detval | val | ATA_SC_IPM_DIS_PARTIAL | ATA_SC_IPM_DIS_SLUMBER); DELAY(1000); + detval = ahci_ch_detval(ch, ATA_SC_DET_IDLE); ATA_OUTL(ch->r_mem, AHCI_P_SCTL, - ATA_SC_DET_IDLE | val | ((ch->pm_level > 0) ? 0 : + detval | val | ((ch->pm_level > 0) ? 0 : (ATA_SC_IPM_DIS_PARTIAL | ATA_SC_IPM_DIS_SLUMBER))); if (!ahci_sata_connect(ch)) { if (ch->caps & AHCI_CAP_SSS) { Modified: stable/11/sys/dev/ahci/ahci.h ============================================================================== --- stable/11/sys/dev/ahci/ahci.h Thu Aug 8 21:43:00 2019 (r350791) +++ stable/11/sys/dev/ahci/ahci.h Thu Aug 8 21:44:37 2019 (r350792) @@ -459,6 +459,8 @@ struct ahci_channel { struct mtx_padalign mtx; /* state lock */ STAILQ_HEAD(, ccb_hdr) doneq; /* queue of completed CCBs */ int batch; /* doneq is in use */ + + int disablephy; /* keep PHY disabled */ }; struct ahci_enclosure { From owner-svn-src-stable-11@freebsd.org Thu Aug 8 21:46:39 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 47999B422B; Thu, 8 Aug 2019 21:46:39 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 464MQR1sy8z3CJS; Thu, 8 Aug 2019 21:46:39 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 071F13ADF; Thu, 8 Aug 2019 21:46:39 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x78LkdCs029316; Thu, 8 Aug 2019 21:46:39 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x78LkbUq029306; Thu, 8 Aug 2019 21:46:37 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201908082146.x78LkbUq029306@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 8 Aug 2019 21:46:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r350793 - in stable/11/sys: cam/scsi dev/ahci X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: in stable/11/sys: cam/scsi dev/ahci X-SVN-Commit-Revision: 350793 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Aug 2019 21:46:39 -0000 Author: mav Date: Thu Aug 8 21:46:36 2019 New Revision: 350793 URL: https://svnweb.freebsd.org/changeset/base/350793 Log: MFC r349321: Improve AHCI Enclosure Management and SES interoperation. Since SES specs do not define mechanism to map enclosure slots to SATA disks, AHCI EM code I written many years ago appeared quite useless, that always bugged me. I was thinking whether it was a good idea, but if LSI HBAs do that, why I shouldn't? This change introduces simple non-standard mechanism for the mapping into both AHCI EM and SES code, that makes AHCI EM on capable controllers (most of Intel's) a first-class SES citizen, allowing it to report disk physical path to GEOM, show devices inserted into each enclosure slot in `sesutil map` and `getencstat`, control locate and fault LEDs for specific devices with `sesutil locate adaX on` and `sesutil fault adaX on`, etc. I've successfully tested this on Supermicro X10DRH-i motherboard connected with sideband cable of its S-SATA Mini-SAS connector to SAS815TQ backplane. It can indicate with LEDs Locate, Fault and Rebuild/Remap SES statuses for each disk identical to real SES of Supermicro SAS2 backplanes. Modified: stable/11/sys/cam/scsi/scsi_all.c stable/11/sys/cam/scsi/scsi_enc.c stable/11/sys/cam/scsi/scsi_enc.h stable/11/sys/cam/scsi/scsi_enc_internal.h stable/11/sys/cam/scsi/scsi_enc_safte.c stable/11/sys/cam/scsi/scsi_enc_ses.c stable/11/sys/cam/scsi/scsi_ses.h stable/11/sys/dev/ahci/ahci.c stable/11/sys/dev/ahci/ahci.h stable/11/sys/dev/ahci/ahciem.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cam/scsi/scsi_all.c ============================================================================== --- stable/11/sys/cam/scsi/scsi_all.c Thu Aug 8 21:44:37 2019 (r350792) +++ stable/11/sys/cam/scsi/scsi_all.c Thu Aug 8 21:46:36 2019 (r350793) @@ -5559,6 +5559,7 @@ scsi_devid_is_naa_ieee_reg(uint8_t *bufp) { struct scsi_vpd_id_descriptor *descr; struct scsi_vpd_id_naa_basic *naa; + int n; descr = (struct scsi_vpd_id_descriptor *)bufp; naa = (struct scsi_vpd_id_naa_basic *)descr->identifier; @@ -5566,7 +5567,8 @@ scsi_devid_is_naa_ieee_reg(uint8_t *bufp) return 0; if (descr->length < sizeof(struct scsi_vpd_id_naa_ieee_reg)) return 0; - if ((naa->naa >> SVPD_ID_NAA_NAA_SHIFT) != SVPD_ID_NAA_IEEE_REG) + n = naa->naa >> SVPD_ID_NAA_NAA_SHIFT; + if (n != SVPD_ID_NAA_LOCAL_REG && n != SVPD_ID_NAA_IEEE_REG) return 0; return 1; } Modified: stable/11/sys/cam/scsi/scsi_enc.c ============================================================================== --- stable/11/sys/cam/scsi/scsi_enc.c Thu Aug 8 21:44:37 2019 (r350792) +++ stable/11/sys/cam/scsi/scsi_enc.c Thu Aug 8 21:46:36 2019 (r350793) @@ -88,6 +88,9 @@ int enc_verbose = 0; SYSCTL_INT(_kern_cam_enc, OID_AUTO, verbose, CTLFLAG_RWTUN, &enc_verbose, 0, "Enable verbose logging"); +const char *elm_type_names[] = ELM_TYPE_NAMES; +CTASSERT(nitems(elm_type_names) - 1 == ELMTYP_LAST); + static struct periph_driver encdriver = { enc_init, "ses", TAILQ_HEAD_INITIALIZER(encdriver.units), /* generation */ 0 @@ -239,13 +242,19 @@ enc_async(void *callback_arg, uint32_t code, struct ca struct enc_softc *softc; softc = (struct enc_softc *)periph->softc; - if (xpt_path_path_id(periph->path) != path_id - || softc == NULL - || (softc->enc_flags & ENC_FLAG_INITIALIZED) - == 0 - || softc->enc_vec.device_found == NULL) + + /* Check this SEP is ready. */ + if (softc == NULL || (softc->enc_flags & + ENC_FLAG_INITIALIZED) == 0 || + softc->enc_vec.device_found == NULL) continue; + /* Check this SEP may manage this device. */ + if (xpt_path_path_id(periph->path) != path_id && + (softc->enc_type != ENC_SEMB_SES || + cgd->protocol != PROTO_ATA)) + continue; + softc->enc_vec.device_found(softc); } xpt_unlock_buses(); @@ -439,7 +448,7 @@ enc_ioctl(struct cdev *dev, u_long cmd, caddr_t arg_ad encioc_element_t kelm; kelm.elm_idx = i; kelm.elm_subenc_id = cache->elm_map[i].subenclosure; - kelm.elm_type = cache->elm_map[i].enctype; + kelm.elm_type = cache->elm_map[i].elm_type; error = copyout(&kelm, &uelm[i], sizeof(kelm)); if (error) break; Modified: stable/11/sys/cam/scsi/scsi_enc.h ============================================================================== --- stable/11/sys/cam/scsi/scsi_enc.h Thu Aug 8 21:44:37 2019 (r350792) +++ stable/11/sys/cam/scsi/scsi_enc.h Thu Aug 8 21:46:36 2019 (r350793) @@ -118,9 +118,41 @@ typedef enum { ELMTYP_SCSI_INI = 0x15, ELMTYP_SUBENC = 0x16, ELMTYP_ARRAY_DEV = 0x17, - ELMTYP_SAS_EXP = 0x18, /* SAS expander */ - ELMTYP_SAS_CONN = 0x19 /* SAS connector */ + ELMTYP_SAS_EXP = 0x18, /* SAS Expander */ + ELMTYP_SAS_CONN = 0x19, /* SAS Connector */ + ELMTYP_LAST = ELMTYP_SAS_CONN } elm_type_t; + +#define ELM_TYPE_NAMES { \ + "Unspecified", \ + "Device Slot", \ + "Power Supply", \ + "Cooling", \ + "Temperature Sensors", \ + "Door", \ + "Audible alarm", \ + "Enclosure Services Controller Electronics", \ + "SCC Controller Electronics", \ + "Nonvolatile Cache", \ + "Invalid Operation Reason", \ + "Uninterruptible Power Supply", \ + "Display", \ + "Key Pad Entry", \ + "Enclosure", \ + "SCSI Port/Transceiver", \ + "Language", \ + "Communication Port", \ + "Voltage Sensor", \ + "Current Sensor", \ + "SCSI Target Port", \ + "SCSI Initiator Port", \ + "Simple Subenclosure", \ + "Array Device Slot", \ + "SAS Expander", \ + "SAS Connector" \ +} + +extern const char *elm_type_names[]; typedef struct encioc_element { /* Element Index */ Modified: stable/11/sys/cam/scsi/scsi_enc_internal.h ============================================================================== --- stable/11/sys/cam/scsi/scsi_enc_internal.h Thu Aug 8 21:44:37 2019 (r350792) +++ stable/11/sys/cam/scsi/scsi_enc_internal.h Thu Aug 8 21:46:36 2019 (r350793) @@ -37,16 +37,12 @@ #include typedef struct enc_element { - uint32_t - enctype : 8, /* enclosure type */ - subenclosure : 8, /* subenclosure id */ - svalid : 1, /* enclosure information valid */ - overall_status_elem: 1,/* - * This object represents generic - * status about all objects of this - * type. - */ - priv : 14; /* private data, per object */ + uint8_t elm_idx; /* index of element */ + uint8_t elm_type; /* element type */ + uint8_t subenclosure; /* subenclosure id */ + uint8_t type_elm_idx; /* index of element within type */ + uint8_t svalid; /* enclosure information valid */ + uint16_t priv; /* private data, per object */ uint8_t encstat[4]; /* state && stats */ uint8_t *physical_path; /* Device physical path data. */ u_int physical_path_len; /* Length of device path data. */ Modified: stable/11/sys/cam/scsi/scsi_enc_safte.c ============================================================================== --- stable/11/sys/cam/scsi/scsi_enc_safte.c Thu Aug 8 21:44:37 2019 (r350792) +++ stable/11/sys/cam/scsi/scsi_enc_safte.c Thu Aug 8 21:46:36 2019 (r350793) @@ -299,21 +299,21 @@ safte_process_config(enc_softc_t *enc, struct enc_fsm_ * in later fetches of status. */ for (i = 0; i < cfg->Nfans; i++) - enc->enc_cache.elm_map[r++].enctype = ELMTYP_FAN; + enc->enc_cache.elm_map[r++].elm_type = ELMTYP_FAN; cfg->pwroff = (uint8_t) r; for (i = 0; i < cfg->Npwr; i++) - enc->enc_cache.elm_map[r++].enctype = ELMTYP_POWER; + enc->enc_cache.elm_map[r++].elm_type = ELMTYP_POWER; for (i = 0; i < cfg->DoorLock; i++) - enc->enc_cache.elm_map[r++].enctype = ELMTYP_DOORLOCK; + enc->enc_cache.elm_map[r++].elm_type = ELMTYP_DOORLOCK; if (cfg->Nspkrs > 0) - enc->enc_cache.elm_map[r++].enctype = ELMTYP_ALARM; + enc->enc_cache.elm_map[r++].elm_type = ELMTYP_ALARM; for (i = 0; i < cfg->Ntherm; i++) - enc->enc_cache.elm_map[r++].enctype = ELMTYP_THERM; + enc->enc_cache.elm_map[r++].elm_type = ELMTYP_THERM; for (i = 0; i <= cfg->Ntstats; i++) - enc->enc_cache.elm_map[r++].enctype = ELMTYP_THERM; + enc->enc_cache.elm_map[r++].elm_type = ELMTYP_THERM; cfg->slotoff = (uint8_t) r; for (i = 0; i < cfg->Nslots; i++) - enc->enc_cache.elm_map[r++].enctype = + enc->enc_cache.elm_map[r++].elm_type = emulate_array_devices ? ELMTYP_ARRAY_DEV : ELMTYP_DEVICE; @@ -503,7 +503,7 @@ safte_process_status(enc_softc_t *enc, struct enc_fsm_ */ for (i = 0; i < cfg->Nslots; i++) { SAFT_BAIL(r, xfer_len); - if (cache->elm_map[cfg->slotoff + i].enctype == ELMTYP_DEVICE) + if (cache->elm_map[cfg->slotoff + i].elm_type == ELMTYP_DEVICE) cache->elm_map[cfg->slotoff + i].encstat[1] = buf[r]; r++; } @@ -676,7 +676,7 @@ safte_process_slotstatus(enc_softc_t *enc, struct enc_ oid = cfg->slotoff; for (r = i = 0; i < cfg->Nslots; i++, r += 4) { SAFT_BAIL(r+3, xfer_len); - if (cache->elm_map[oid].enctype == ELMTYP_ARRAY_DEV) + if (cache->elm_map[oid].elm_type == ELMTYP_ARRAY_DEV) cache->elm_map[oid].encstat[1] = 0; cache->elm_map[oid].encstat[2] &= SESCTL_RQSID; cache->elm_map[oid].encstat[3] = 0; @@ -703,7 +703,7 @@ safte_process_slotstatus(enc_softc_t *enc, struct enc_ cache->elm_map[oid].encstat[3] |= SESCTL_RQSFLT; if (buf[r+0] & 0x40) cache->elm_map[oid].encstat[0] |= SESCTL_PRDFAIL; - if (cache->elm_map[oid].enctype == ELMTYP_ARRAY_DEV) { + if (cache->elm_map[oid].elm_type == ELMTYP_ARRAY_DEV) { if (buf[r+0] & 0x01) cache->elm_map[oid].encstat[1] |= 0x80; if (buf[r+0] & 0x04) @@ -769,7 +769,7 @@ safte_fill_control_request(enc_softc_t *enc, struct en } else { ep = &enc->enc_cache.elm_map[idx]; - switch (ep->enctype) { + switch (ep->elm_type) { case ELMTYP_DEVICE: case ELMTYP_ARRAY_DEV: switch (cfg->current_request_stage) { @@ -779,7 +779,7 @@ safte_fill_control_request(enc_softc_t *enc, struct en ep->priv |= 0x40; if (req->elm_stat[3] & SESCTL_RQSFLT) ep->priv |= 0x02; - if (ep->enctype == ELMTYP_ARRAY_DEV) { + if (ep->elm_type == ELMTYP_ARRAY_DEV) { if (req->elm_stat[1] & 0x01) ep->priv |= 0x200; if (req->elm_stat[1] & 0x02) @@ -968,7 +968,7 @@ safte_process_control_request(enc_softc_t *enc, struct if (idx == SES_SETSTATUS_ENC_IDX) type = -1; else - type = enc->enc_cache.elm_map[idx].enctype; + type = enc->enc_cache.elm_map[idx].elm_type; if (type == ELMTYP_DEVICE || type == ELMTYP_ARRAY_DEV) enc_update_request(enc, SAFTE_UPDATE_READSLOTSTATUS); else Modified: stable/11/sys/cam/scsi/scsi_enc_ses.c ============================================================================== --- stable/11/sys/cam/scsi/scsi_enc_ses.c Thu Aug 8 21:44:37 2019 (r350792) +++ stable/11/sys/cam/scsi/scsi_enc_ses.c Thu Aug 8 21:46:36 2019 (r350793) @@ -100,6 +100,7 @@ typedef struct ses_addl_status { union { union ses_fcobj_hdr *fc; union ses_elm_sas_hdr *sas; + struct ses_elm_ata_hdr *ata; } proto_hdr; union ses_addl_data proto_data; /* array sizes stored in header */ } ses_add_status_t; @@ -823,14 +824,6 @@ ses_devids_iter(enc_softc_t *enc, enc_element_t *elm, elmpriv = elm->elm_private; addl = &(elmpriv->addl); - /* - * Don't assume this object has additional status information, or - * that it is a SAS device, or that it is a device slot device. - */ - if (addl->hdr == NULL || addl->proto_hdr.sas == NULL - || addl->proto_data.sasdev_phys == NULL) - return; - devid_record_size = SVPD_DEVICE_ID_DESC_HDR_LEN + sizeof(struct scsi_vpd_id_naa_ieee_reg); for (i = 0; i < addl->proto_hdr.sas->base_hdr.num_phys; i++) { @@ -948,11 +941,40 @@ static void ses_paths_iter(enc_softc_t *enc, enc_element_t *elm, ses_path_callback_t *callback, void *callback_arg) { - ses_path_iter_args_t args; + ses_element_t *elmpriv; + struct ses_addl_status *addl; - args.callback = callback; - args.callback_arg = callback_arg; - ses_devids_iter(enc, elm, ses_path_iter_devid_callback, &args); + elmpriv = elm->elm_private; + addl = &(elmpriv->addl); + + if (addl->hdr == NULL) + return; + + if (addl->proto_hdr.sas != NULL && + addl->proto_data.sasdev_phys != NULL) { + ses_path_iter_args_t args; + + args.callback = callback; + args.callback_arg = callback_arg; + ses_devids_iter(enc, elm, ses_path_iter_devid_callback, &args); + } else if (addl->proto_hdr.ata != NULL) { + struct cam_path *path; + struct ccb_getdev cgd; + + if (xpt_create_path(&path, /*periph*/NULL, + scsi_4btoul(addl->proto_hdr.ata->bus), + scsi_4btoul(addl->proto_hdr.ata->target), 0) + != CAM_REQ_CMP) + return; + + xpt_setup_ccb(&cgd.ccb_h, path, CAM_PRIORITY_NORMAL); + cgd.ccb_h.func_code = XPT_GDEV_TYPE; + xpt_action((union ccb *)&cgd); + if (cgd.ccb_h.status == CAM_REQ_CMP) + callback(enc, elm, path, callback_arg); + + xpt_free_path(path); + } } /** @@ -1057,6 +1079,10 @@ ses_set_physpath(enc_softc_t *enc, enc_element_t *elm, ret = EIO; devid = NULL; + elmpriv = elm->elm_private; + if (elmpriv->addl.hdr == NULL) + goto out; + /* * Assemble the components of the physical path starting with * the device ID of the enclosure itself. @@ -1089,7 +1115,6 @@ ses_set_physpath(enc_softc_t *enc, enc_element_t *elm, scsi_8btou64(idd->identifier), iter->type_index, iter->type_element_index); /* Append the element descriptor if one exists */ - elmpriv = elm->elm_private; if (elmpriv->descr != NULL && elmpriv->descr_len > 0) { sbuf_cat(&sb, "/elmdesc@"); for (i = 0, c = elmpriv->descr; i < elmpriv->descr_len; @@ -1455,9 +1480,10 @@ ses_process_config(enc_softc_t *enc, struct enc_fsm_st iter.global_element_index, iter.type_index, nelm, iter.type_element_index); thdr = ses_cache->ses_types[iter.type_index].hdr; + element->elm_idx = iter.global_element_index; + element->elm_type = thdr->etype_elm_type; element->subenclosure = thdr->etype_subenc; - element->enctype = thdr->etype_elm_type; - element->overall_status_elem = iter.type_element_index == 0; + element->type_elm_idx = iter.type_element_index; element->elm_private = malloc(sizeof(ses_element_t), M_SCSIENC, M_WAITOK|M_ZERO); ENC_DLOG(enc, "%s: creating elmpriv %d(%d,%d) subenc %d " @@ -1661,6 +1687,8 @@ static int ses_get_elm_addlstatus_fc(enc_softc_t *, en uint8_t *, int); static int ses_get_elm_addlstatus_sas(enc_softc_t *, enc_cache_t *, uint8_t *, int, int, int, int); +static int ses_get_elm_addlstatus_ata(enc_softc_t *, enc_cache_t *, uint8_t *, + int, int, int, int); /** * \brief Parse the additional status element data for each object. @@ -1816,7 +1844,6 @@ badindex: } } elmpriv = element->elm_private; - elmpriv->addl.hdr = elm_hdr; ENC_DLOG(enc, "%s: global element index=%d, type index=%d " "type element index=%d, offset=0x%x, " "byte0=0x%x, length=0x%x\n", __func__, @@ -1840,6 +1867,7 @@ badindex: offset += elm_hdr->length; continue; } + elmpriv->addl.hdr = elm_hdr; /* Advance to the protocol data, skipping eip bytes if needed */ offset += (eip * SES_EIP_HDR_EXTRA_LEN); @@ -1863,6 +1891,13 @@ badindex: eip, iter.type_index, iter.global_element_index); break; + case SPSP_PROTO_ATA: + ses_get_elm_addlstatus_ata(enc, enc_cache, + &buf[offset], + proto_info_len, + eip, iter.type_index, + iter.global_element_index); + break; default: ENC_VLOG(enc, "Element %d: Unknown Additional Element " "Protocol 0x%x\n", iter.global_element_index, @@ -2191,18 +2226,16 @@ ses_get_elm_addlstatus_fc(enc_softc_t *enc, enc_cache_ } #define SES_PRINT_PORTS(p, type) do { \ - sbuf_printf(sbp, " %s(", type); \ - if (((p) & SES_SASOBJ_DEV_PHY_PROTOMASK) == 0) \ - sbuf_printf(sbp, " None"); \ - else { \ + if (((p) & SES_SASOBJ_DEV_PHY_PROTOMASK) != 0) { \ + sbuf_printf(sbp, " %s (", type); \ if ((p) & SES_SASOBJ_DEV_PHY_SMP) \ sbuf_printf(sbp, " SMP"); \ if ((p) & SES_SASOBJ_DEV_PHY_STP) \ sbuf_printf(sbp, " STP"); \ if ((p) & SES_SASOBJ_DEV_PHY_SSP) \ sbuf_printf(sbp, " SSP"); \ + sbuf_printf(sbp, " )"); \ } \ - sbuf_printf(sbp, " )"); \ } while(0) /** @@ -2212,11 +2245,10 @@ ses_get_elm_addlstatus_fc(enc_softc_t *enc, enc_cache_ * \param sesname SES device name associated with the object. * \param sbp Sbuf to print to. * \param obj The object to print the data for. - * \param periph_name Peripheral string associated with the object. */ static void ses_print_addl_data_sas_type0(char *sesname, struct sbuf *sbp, - enc_element_t *obj, char *periph_name) + enc_element_t *obj) { int i; ses_element_t *elmpriv; @@ -2225,16 +2257,12 @@ ses_print_addl_data_sas_type0(char *sesname, struct sb elmpriv = obj->elm_private; addl = &(elmpriv->addl); - if (addl->proto_hdr.sas == NULL) - return; - sbuf_printf(sbp, "%s: %s: SAS Device Slot Element:", - sesname, periph_name); - sbuf_printf(sbp, " %d Phys", addl->proto_hdr.sas->base_hdr.num_phys); + sbuf_printf(sbp, ", SAS Slot: %d%s phys", + addl->proto_hdr.sas->base_hdr.num_phys, + ses_elm_sas_type0_not_all_phys(addl->proto_hdr.sas) ? "+" : ""); if (ses_elm_addlstatus_eip(addl->hdr)) - sbuf_printf(sbp, " at Slot %d", + sbuf_printf(sbp, " at slot %d", addl->proto_hdr.sas->type0_eip.dev_slot_num); - if (ses_elm_sas_type0_not_all_phys(addl->proto_hdr.sas)) - sbuf_printf(sbp, ", Not All Phys"); sbuf_printf(sbp, "\n"); if (addl->proto_data.sasdev_phys == NULL) return; @@ -2245,9 +2273,8 @@ ses_print_addl_data_sas_type0(char *sesname, struct sb /* Spec says all other fields are specific values */ sbuf_printf(sbp, " SATA device\n"); else { - sbuf_printf(sbp, " SAS device type %d id %d\n", + sbuf_printf(sbp, " SAS device type %d phy %d", ses_elm_sas_dev_phy_dev_type(phy), phy->phy_id); - sbuf_printf(sbp, "%s: phy %d: protocols:", sesname, i); SES_PRINT_PORTS(phy->initiator_ports, "Initiator"); SES_PRINT_PORTS(phy->target_ports, "Target"); sbuf_printf(sbp, "\n"); @@ -2261,32 +2288,16 @@ ses_print_addl_data_sas_type0(char *sesname, struct sb #undef SES_PRINT_PORTS /** - * \brief Report whether a given enclosure object is an expander. - * - * \param enc SES softc associated with object. - * \param obj Enclosure object to report for. - * - * \return 1 if true, 0 otherwise. - */ -static int -ses_obj_is_expander(enc_softc_t *enc, enc_element_t *obj) -{ - return (obj->enctype == ELMTYP_SAS_EXP); -} - -/** * \brief Print the additional element status data for this object, for SAS * type 1 objects. See SES2 r20 Sections 6.1.13.3.3 and 6.1.13.3.4. * - * \param enc SES enclosure, needed for type identification. * \param sesname SES device name associated with the object. * \param sbp Sbuf to print to. * \param obj The object to print the data for. - * \param periph_name Peripheral string associated with the object. */ static void -ses_print_addl_data_sas_type1(enc_softc_t *enc, char *sesname, - struct sbuf *sbp, enc_element_t *obj, char *periph_name) +ses_print_addl_data_sas_type1(char *sesname, struct sbuf *sbp, + enc_element_t *obj) { int i, num_phys; ses_element_t *elmpriv; @@ -2296,12 +2307,10 @@ ses_print_addl_data_sas_type1(enc_softc_t *enc, char * elmpriv = obj->elm_private; addl = &(elmpriv->addl); - if (addl->proto_hdr.sas == NULL) - return; - sbuf_printf(sbp, "%s: %s: SAS ", sesname, periph_name); - if (ses_obj_is_expander(enc, obj)) { + sbuf_printf(sbp, ", SAS "); + if (obj->elm_type == ELMTYP_SAS_EXP) { num_phys = addl->proto_hdr.sas->base_hdr.num_phys; - sbuf_printf(sbp, "Expander: %d Phys", num_phys); + sbuf_printf(sbp, "Expander: %d phys", num_phys); if (addl->proto_data.sasexp_phys == NULL) return; for (i = 0;i < num_phys;i++) { @@ -2312,7 +2321,7 @@ ses_print_addl_data_sas_type1(enc_softc_t *enc, char * } } else { num_phys = addl->proto_hdr.sas->base_hdr.num_phys; - sbuf_printf(sbp, "Port: %d Phys", num_phys); + sbuf_printf(sbp, "Port: %d phys", num_phys); if (addl->proto_data.sasport_phys == NULL) return; for (i = 0;i < num_phys;i++) { @@ -2328,6 +2337,24 @@ ses_print_addl_data_sas_type1(enc_softc_t *enc, char * } /** + * \brief Print the additional element status data for this object, for + * ATA objects. + * + * \param sbp Sbuf to print to. + * \param obj The object to print the data for. + */ +static void +ses_print_addl_data_ata(struct sbuf *sbp, enc_element_t *obj) +{ + ses_element_t *elmpriv = obj->elm_private; + struct ses_addl_status *addl = &elmpriv->addl; + struct ses_elm_ata_hdr *ata = addl->proto_hdr.ata; + + sbuf_printf(sbp, ", SATA Slot: scbus%d target %d\n", + scsi_4btoul(ata->bus), scsi_4btoul(ata->target)); +} + +/** * \brief Print the additional element status data for this object. * * \param enc SES softc associated with the object. @@ -2358,27 +2385,45 @@ ses_print_addl_data(enc_softc_t *enc, enc_element_t *o sbuf_printf(&sesname, "%s%d", enc->periph->periph_name, enc->periph->unit_number); sbuf_finish(&sesname); + sbuf_printf(&out, "%s: %s in ", sbuf_data(&sesname), sbuf_data(&name)); if (elmpriv->descr != NULL) - sbuf_printf(&out, "%s: %s: Element descriptor: '%s'\n", - sbuf_data(&sesname), sbuf_data(&name), elmpriv->descr); + sbuf_printf(&out, "'%s'", elmpriv->descr); + else { + if (obj->elm_type <= ELMTYP_LAST) + sbuf_cat(&out, elm_type_names[obj->elm_type]); + else + sbuf_printf(&out, "", obj->elm_type); + sbuf_printf(&out, " %d", obj->type_elm_idx); + if (obj->subenclosure != 0) + sbuf_printf(&out, " of subenc %d", obj->subenclosure); + } switch(ses_elm_addlstatus_proto(addl->hdr)) { + case SPSP_PROTO_FC: + goto noaddl; /* stubbed for now */ case SPSP_PROTO_SAS: + if (addl->proto_hdr.sas == NULL) + goto noaddl; switch(ses_elm_sas_descr_type(addl->proto_hdr.sas)) { case SES_SASOBJ_TYPE_SLOT: ses_print_addl_data_sas_type0(sbuf_data(&sesname), - &out, obj, sbuf_data(&name)); + &out, obj); break; case SES_SASOBJ_TYPE_OTHER: - ses_print_addl_data_sas_type1(enc, sbuf_data(&sesname), - &out, obj, sbuf_data(&name)); + ses_print_addl_data_sas_type1(sbuf_data(&sesname), + &out, obj); break; default: - break; + goto noaddl; } break; - case SPSP_PROTO_FC: /* stubbed for now */ + case SPSP_PROTO_ATA: + if (addl->proto_hdr.ata == NULL) + goto noaddl; + ses_print_addl_data_ata(&out, obj); break; default: +noaddl: + sbuf_cat(&out, "\n"); break; } sbuf_finish(&out); @@ -2483,7 +2528,7 @@ ses_get_elm_addlstatus_sas_type1(enc_softc_t *enc, enc goto out; /* Process expanders differently from other type1 cases */ - if (ses_obj_is_expander(enc, obj)) { + if (obj->elm_type == ELMTYP_SAS_EXP) { offset += sizeof(struct ses_elm_sas_type1_expander_hdr); physz = addl->proto_hdr.sas->base_hdr.num_phys * sizeof(struct ses_elm_sas_expander_phy); @@ -2586,6 +2631,53 @@ ses_get_elm_addlstatus_sas(enc_softc_t *enc, enc_cache err = ENODEV; break; } + +out: + return (err); +} + +/** + * \brief Update the softc with the additional element status data for this + * object, for ATA objects. + * + * \param enc SES softc to be updated. + * \param buf The additional element status response buffer. + * \param bufsiz Size of the response buffer. + * \param eip The EIP bit value. + * \param tidx Type index for this object. + * \param nobj Number of objects attached to the SES softc. + * + * \return 0 on success, errno otherwise. + */ +static int +ses_get_elm_addlstatus_ata(enc_softc_t *enc, enc_cache_t *enc_cache, + uint8_t *buf, int bufsiz, int eip, int tidx, + int nobj) +{ + int err; + ses_cache_t *ses_cache; + + if (bufsiz < sizeof(struct ses_elm_ata_hdr)) { + err = EIO; + goto out; + } + + ses_cache = enc_cache->private; + switch(ses_cache->ses_types[tidx].hdr->etype_elm_type) { + case ELMTYP_DEVICE: + case ELMTYP_ARRAY_DEV: + break; + default: + ENC_VLOG(enc, "Element %d has Additional Status, " + "invalid for SES element type 0x%x\n", nobj, + ses_cache->ses_types[tidx].hdr->etype_elm_type); + err = ENODEV; + goto out; + } + + ((ses_element_t *)enc_cache->elm_map[nobj].elm_private) + ->addl.proto_hdr.ata = (struct ses_elm_ata_hdr *)buf; + err = 0; out: return (err); Modified: stable/11/sys/cam/scsi/scsi_ses.h ============================================================================== --- stable/11/sys/cam/scsi/scsi_ses.h Thu Aug 8 21:44:37 2019 (r350792) +++ stable/11/sys/cam/scsi/scsi_ses.h Thu Aug 8 21:46:36 2019 (r350793) @@ -2179,15 +2179,27 @@ struct ses_status_page_hdr { #define SESCTL_DISABLE 0x20 #define SESCTL_RSTSWAP 0x10 - -/* Control bits, Device Elements, byte 2 */ -#define SESCTL_DRVLCK 0x40 /* "DO NOT REMOVE" */ +/* Control bits, Array Device Slot Elements, byte 1 */ +#define SESCTL_RQSOK 0x80 /* RQST OK */ +#define SESCTL_RQSRSV 0x40 /* RQST RSVD DEVICE */ +#define SESCTL_RQSSPR 0x20 /* RQST HOT SPARE */ +#define SESCTL_RQSCCH 0x10 /* RQST CONS CHECK */ +#define SESCTL_RQSCRA 0x08 /* RQST IN CRIT ARRAY */ +#define SESCTL_RQSFAA 0x04 /* RQST IN FAILED ARRAY */ +#define SESCTL_RQSRR 0x02 /* RQST REBUI/REMAP */ +#define SESCTL_RQSRRA 0x01 /* RQST R/R ABORT */ +/* Control bits, [Array] Device Slot Elements, byte 2 */ +#define SESCTL_RQSACT 0x80 /* RQST ACTIVE */ +#define SESCTL_DRVLCK 0x40 /* DO NOT REMOVE */ +#define SESCTL_RQSMSN 0x10 /* RQST MISSING */ #define SESCTL_RQSINS 0x08 /* RQST INSERT */ #define SESCTL_RQSRMV 0x04 /* RQST REMOVE */ #define SESCTL_RQSID 0x02 /* RQST IDENT */ -/* Control bits, Device Elements, byte 3 */ +/* Control bits, [Array] Device Slot Elements, byte 3 */ #define SESCTL_RQSFLT 0x20 /* RQST FAULT */ #define SESCTL_DEVOFF 0x10 /* DEVICE OFF */ +#define SESCTL_ENBYPA 0x08 /* ENABLE BYP A */ +#define SESCTL_ENBYPB 0x04 /* ENABLE BYP B */ /* Control bits, Generic, byte 3 */ #define SESCTL_RQSTFAIL 0x40 @@ -2396,6 +2408,17 @@ union ses_elm_sas_hdr { }; int ses_elm_sas_type0_not_all_phys(union ses_elm_sas_hdr *); int ses_elm_sas_descr_type(union ses_elm_sas_hdr *); + +/* + * This structure for SPSP_PROTO_ATA is not defined by SES specs, + * but purely my own design to make AHCI EM interoperate with SES. + * Since no other software I know can talk to SEMB, and we do not + * expose this this outside, it should be safe to do what we want. + */ +struct ses_elm_ata_hdr { + uint8_t bus[4]; + uint8_t target[4]; +}; struct ses_elm_addlstatus_base_hdr { uint8_t byte0; Modified: stable/11/sys/dev/ahci/ahci.c ============================================================================== --- stable/11/sys/dev/ahci/ahci.c Thu Aug 8 21:44:37 2019 (r350792) +++ stable/11/sys/dev/ahci/ahci.c Thu Aug 8 21:46:36 2019 (r350793) @@ -184,6 +184,7 @@ ahci_attach(device_t dev) ctlr->ccc = 0; resource_int_value(device_get_name(dev), device_get_unit(dev), "ccc", &ctlr->ccc); + mtx_init(&ctlr->ch_mtx, "AHCI channels lock", NULL, MTX_DEF); /* Setup our own memory management for channels. */ ctlr->sc_iomem.rm_start = rman_get_start(ctlr->r_mem); @@ -376,6 +377,7 @@ ahci_detach(device_t dev) /* Free memory. */ rman_fini(&ctlr->sc_iomem); ahci_free_mem(dev); + mtx_destroy(&ctlr->ch_mtx); return (0); } @@ -663,6 +665,50 @@ ahci_get_dma_tag(device_t dev, device_t child) return (ctlr->dma_tag); } +void +ahci_attached(device_t dev, struct ahci_channel *ch) +{ + struct ahci_controller *ctlr = device_get_softc(dev); + + mtx_lock(&ctlr->ch_mtx); + ctlr->ch[ch->unit] = ch; + mtx_unlock(&ctlr->ch_mtx); +} + +void +ahci_detached(device_t dev, struct ahci_channel *ch) +{ + struct ahci_controller *ctlr = device_get_softc(dev); + + mtx_lock(&ctlr->ch_mtx); + mtx_lock(&ch->mtx); + ctlr->ch[ch->unit] = NULL; + mtx_unlock(&ch->mtx); + mtx_unlock(&ctlr->ch_mtx); +} + +struct ahci_channel * +ahci_getch(device_t dev, int n) +{ + struct ahci_controller *ctlr = device_get_softc(dev); + struct ahci_channel *ch; + + KASSERT(n >= 0 && n < AHCI_MAX_PORTS, ("Bad channel number %d", n)); + mtx_lock(&ctlr->ch_mtx); + ch = ctlr->ch[n]; + if (ch != NULL) + mtx_lock(&ch->mtx); + mtx_unlock(&ctlr->ch_mtx); + return (ch); +} + +void +ahci_putch(struct ahci_channel *ch) +{ + + mtx_unlock(&ch->mtx); +} + static int ahci_ch_probe(device_t dev) { @@ -821,6 +867,7 @@ ahci_ch_attach(device_t dev) ahci_ch_pm, ch); } mtx_unlock(&ch->mtx); + ahci_attached(device_get_parent(dev), ch); ctx = device_get_sysctl_ctx(dev); tree = device_get_sysctl_tree(dev); SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "disable_phy", @@ -846,6 +893,7 @@ ahci_ch_detach(device_t dev) { struct ahci_channel *ch = device_get_softc(dev); + ahci_detached(device_get_parent(dev), ch); mtx_lock(&ch->mtx); xpt_async(AC_LOST_DEVICE, ch->path, NULL); /* Forget about reset. */ Modified: stable/11/sys/dev/ahci/ahci.h ============================================================================== --- stable/11/sys/dev/ahci/ahci.h Thu Aug 8 21:44:37 2019 (r350792) +++ stable/11/sys/dev/ahci/ahci.h Thu Aug 8 21:46:36 2019 (r350793) @@ -521,6 +521,8 @@ struct ahci_controller { void *argument; } interrupt[AHCI_MAX_PORTS]; void (*ch_start)(struct ahci_channel *); + struct mtx ch_mtx; /* Lock for attached channels */ + struct ahci_channel *ch[AHCI_MAX_PORTS]; /* Attached channels */ }; enum ahci_err_type { @@ -648,6 +650,12 @@ bus_dma_tag_t ahci_get_dma_tag(device_t dev, device_t int ahci_ctlr_reset(device_t dev); int ahci_ctlr_setup(device_t dev); void ahci_free_mem(device_t dev); + +/* Functions to allow AHCI EM to access other channels. */ +void ahci_attached(device_t dev, struct ahci_channel *ch); +void ahci_detached(device_t dev, struct ahci_channel *ch); +struct ahci_channel * ahci_getch(device_t dev, int n); +void ahci_putch(struct ahci_channel *ch); extern devclass_t ahci_devclass; Modified: stable/11/sys/dev/ahci/ahciem.c ============================================================================== --- stable/11/sys/dev/ahci/ahciem.c Thu Aug 8 21:44:37 2019 (r350792) +++ stable/11/sys/dev/ahci/ahciem.c Thu Aug 8 21:46:36 2019 (r350793) @@ -292,14 +292,14 @@ ahci_em_setleds(device_t dev, int c) enc = device_get_softc(dev); val = 0; - if (enc->status[c][2] & 0x80) /* Activity */ + if (enc->status[c][2] & SESCTL_RQSACT) /* Activity */ val |= (1 << 0); - if (enc->status[c][2] & SESCTL_RQSID) /* Identification */ + if (enc->status[c][1] & SESCTL_RQSRR) /* Rebuild */ + val |= (1 << 6) | (1 << 3); + else if (enc->status[c][2] & SESCTL_RQSID) /* Identification */ val |= (1 << 3); else if (enc->status[c][3] & SESCTL_RQSFLT) /* Fault */ val |= (1 << 6); - else if (enc->status[c][1] & 0x02) /* Rebuild */ - val |= (1 << 6) | (1 << 3); timeout = 10000; while (ATA_INL(enc->r_memc, 0) & (AHCI_EM_TM | AHCI_EM_RST) && @@ -364,9 +364,12 @@ static void ahci_em_emulate_ses_on_led(device_t dev, union ccb *ccb) { struct ahci_enclosure *enc; + struct ahci_channel *ch; struct ses_status_page *page; struct ses_status_array_dev_slot *ads, *ads0; struct ses_elm_desc_hdr *elmd; + struct ses_elm_addlstatus_eip_hdr *elma; + struct ses_elm_ata_hdr *elmb; uint8_t *buf; int i; @@ -389,7 +392,7 @@ ahci_em_emulate_ses_on_led(device_t dev, union ccb *cc strncpy(&buf[3], device_get_nameunit(dev), 7); strncpy(&buf[10], "AHCI ", SID_VENDOR_SIZE); strncpy(&buf[18], "SGPIO Enclosure ", SID_PRODUCT_SIZE); - strncpy(&buf[34], "1.00", SID_REVISION_SIZE); + strncpy(&buf[34], "2.00", SID_REVISION_SIZE); strncpy(&buf[39], "0001", 4); strncpy(&buf[43], "S-E-S ", 6); strncpy(&buf[49], "2.00", 4); @@ -401,14 +404,15 @@ ahci_em_emulate_ses_on_led(device_t dev, union ccb *cc page = (struct ses_status_page *)buf; if (ccb->ataio.cmd.lba_low == 0x02 && ccb->ataio.cmd.features == 0x00 && - ccb->ataio.cmd.sector_count >= 2) { + ccb->ataio.cmd.sector_count >= 3) { bzero(buf, ccb->ataio.dxfer_len); page->hdr.page_code = 0; - scsi_ulto2b(4, page->hdr.length); - buf[4] = 0; - buf[5] = 1; - buf[6] = 2; - buf[7] = 7; + scsi_ulto2b(5, page->hdr.length); + buf[4] = 0x00; + buf[5] = 0x01; + buf[6] = 0x02; + buf[7] = 0x07; + buf[8] = 0x0a; ccb->ccb_h.status = CAM_REQ_CMP; goto out; } @@ -416,26 +420,30 @@ ahci_em_emulate_ses_on_led(device_t dev, union ccb *cc /* SEMB RECEIVE DIAGNOSTIC RESULT (1) */ if (ccb->ataio.cmd.lba_low == 0x02 && ccb->ataio.cmd.features == 0x01 && - ccb->ataio.cmd.sector_count >= 13) { + ccb->ataio.cmd.sector_count >= 16) { struct ses_enc_desc *ed; struct ses_elm_type_desc *td; bzero(buf, ccb->ataio.dxfer_len); page->hdr.page_code = 0x01; - scsi_ulto2b(4 + 4 + 36 + 4, page->hdr.length); + scsi_ulto2b(4 + sizeof(*ed) + sizeof(*td) + 11, + page->hdr.length); ed = (struct ses_enc_desc *)&buf[8]; ed->byte0 = 0x11; ed->subenc_id = 0; ed->num_types = 1; ed->length = 36; + ed->logical_id[0] = 0x30; /* NAA Locally Assigned. */ + strncpy(&ed->logical_id[1], device_get_nameunit(dev), 7); strncpy(ed->vendor_id, "AHCI ", SID_VENDOR_SIZE); strncpy(ed->product_id, "SGPIO Enclosure ", SID_PRODUCT_SIZE); - strncpy(ed->product_rev, " ", SID_REVISION_SIZE); + strncpy(ed->product_rev, "2.00", SID_REVISION_SIZE); td = (struct ses_elm_type_desc *)ses_enc_desc_next(ed); td->etype_elm_type = 0x17; td->etype_maxelt = enc->channels; td->etype_subenc = 0; - td->etype_txt_len = 0; + td->etype_txt_len = 11; + snprintf((char *)(td + 1), 12, "Drive Slots"); ccb->ccb_h.status = CAM_REQ_CMP; goto out; } @@ -451,10 +459,22 @@ ahci_em_emulate_ses_on_led(device_t dev, union ccb *cc for (i = 0; i < enc->channels; i++) { ads = &page->elements[i + 1].array_dev_slot; memcpy(ads, enc->status[i], 4); - ads->common.bytes[0] |= - (enc->ichannels & (1 << i)) ? - SES_OBJSTAT_UNKNOWN : - SES_OBJSTAT_NOTINSTALLED; + ch = ahci_getch(device_get_parent(dev), i); + if (ch == NULL) { + ads->common.bytes[0] |= SES_OBJSTAT_UNKNOWN; + continue; + } + if (ch->pm_present) + ads->common.bytes[0] |= SES_OBJSTAT_UNKNOWN; + else if (ch->devices) + ads->common.bytes[0] |= SES_OBJSTAT_OK; + else if (ch->disablephy) + ads->common.bytes[0] |= SES_OBJSTAT_NOTAVAIL; + else + ads->common.bytes[0] |= SES_OBJSTAT_NOTINSTALLED; + if (ch->disablephy) + ads->common.bytes[3] |= SESCTL_DEVOFF; + ahci_putch(ch); } ccb->ccb_h.status = CAM_REQ_CMP; goto out; @@ -469,21 +489,21 @@ ahci_em_emulate_ses_on_led(device_t dev, union ccb *cc ads = &page->elements[i + 1].array_dev_slot; if (ads->common.bytes[0] & SESCTL_CSEL) { enc->status[i][0] = 0; - enc->status[i][1] = - ads->bytes[0] & 0x02; - enc->status[i][2] = - ads->bytes[1] & (0x80 | SESCTL_RQSID); - enc->status[i][3] = - ads->bytes[2] & SESCTL_RQSFLT; + enc->status[i][1] = ads->bytes[0] & + SESCTL_RQSRR; + enc->status[i][2] = ads->bytes[1] & + (SESCTL_RQSACT | SESCTL_RQSID); + enc->status[i][3] = ads->bytes[2] & + SESCTL_RQSFLT; ahci_em_setleds(dev, i); } else if (ads0->common.bytes[0] & SESCTL_CSEL) { enc->status[i][0] = 0; - enc->status[i][1] = - ads0->bytes[0] & 0x02; - enc->status[i][2] = - ads0->bytes[1] & (0x80 | SESCTL_RQSID); - enc->status[i][3] = - ads0->bytes[2] & SESCTL_RQSFLT; + enc->status[i][1] = ads0->bytes[0] & + SESCTL_RQSRR; + enc->status[i][2] = ads0->bytes[1] & + (SESCTL_RQSACT | SESCTL_RQSID); + enc->status[i][3] = ads0->bytes[2] & + SESCTL_RQSFLT; ahci_em_setleds(dev, i); } } @@ -494,15 +514,48 @@ ahci_em_emulate_ses_on_led(device_t dev, union ccb *cc /* SEMB RECEIVE DIAGNOSTIC RESULT (7) */ if (ccb->ataio.cmd.lba_low == 0x02 && ccb->ataio.cmd.features == 0x07 && - ccb->ataio.cmd.sector_count >= (3 + 3 * enc->channels)) { + ccb->ataio.cmd.sector_count >= (6 + 3 * enc->channels)) { bzero(buf, ccb->ataio.dxfer_len); page->hdr.page_code = 0x07; - scsi_ulto2b(4 + 4 + 12 * enc->channels, + scsi_ulto2b(4 + 15 + 11 * enc->channels, page->hdr.length); + elmd = (struct ses_elm_desc_hdr *)&buf[8]; + scsi_ulto2b(11, elmd->length); + snprintf((char *)(elmd + 1), 12, "Drive Slots"); + for (i = 0; i < enc->channels; i++) { + elmd = (struct ses_elm_desc_hdr *)&buf[8 + 15 + 11 * i]; + scsi_ulto2b(7, elmd->length); + snprintf((char *)(elmd + 1), 8, "Slot %02d", i); + } + ccb->ccb_h.status = CAM_REQ_CMP; + goto out; + } + + /* SEMB RECEIVE DIAGNOSTIC RESULT (a) */ + if (ccb->ataio.cmd.lba_low == 0x02 && + ccb->ataio.cmd.features == 0x0a && + ccb->ataio.cmd.sector_count >= (2 + 3 * enc->channels)) { + bzero(buf, ccb->ataio.dxfer_len); + page->hdr.page_code = 0x0a; + scsi_ulto2b(4 + (sizeof(*elma) + sizeof(*elmb)) * enc->channels, page->hdr.length); for (i = 0; i < enc->channels; i++) { - elmd = (struct ses_elm_desc_hdr *)&buf[8 + 4 + 12 * i]; - scsi_ulto2b(8, elmd->length); - snprintf((char *)(elmd + 1), 9, "SLOT %03d", i); + elma = (struct ses_elm_addlstatus_eip_hdr *)&buf[ + 8 + (sizeof(*elma) + sizeof(*elmb)) * i]; + elma->base.byte0 = 0x10 | SPSP_PROTO_ATA; + elma->base.length = 2 + sizeof(*elmb); + elma->byte2 = 0x01; + elma->element_index = 1 + i; + ch = ahci_getch(device_get_parent(dev), i); + if (ch == NULL) { + elma->base.byte0 |= 0x80; + continue; + } + if (ch->devices == 0 || ch->pm_present) + elma->base.byte0 |= 0x80; *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-11@freebsd.org Thu Aug 8 21:47:41 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3743DB4370; Thu, 8 Aug 2019 21:47:41 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 464MRd0gwYz3CWZ; Thu, 8 Aug 2019 21:47:41 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id ED0D73AE2; Thu, 8 Aug 2019 21:47:40 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x78LledB029522; Thu, 8 Aug 2019 21:47:40 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x78Lle42029521; Thu, 8 Aug 2019 21:47:40 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201908082147.x78Lle42029521@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 8 Aug 2019 21:47:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r350794 - stable/11/sys/cam/ata X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/cam/ata X-SVN-Commit-Revision: 350794 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Aug 2019 21:47:41 -0000 Author: mav Date: Thu Aug 8 21:47:40 2019 New Revision: 350794 URL: https://svnweb.freebsd.org/changeset/base/350794 Log: MFC r349339 (by imp): Go ahead and completely fix the ata_params before calling the veto function. This breaks nothing that uses it in the tree since ata_params is ignored in storvsc_ada_probe_veto which is the only in-tree consumer. Modified: stable/11/sys/cam/ata/ata_xpt.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cam/ata/ata_xpt.c ============================================================================== --- stable/11/sys/cam/ata/ata_xpt.c Thu Aug 8 21:46:36 2019 (r350793) +++ stable/11/sys/cam/ata/ata_xpt.c Thu Aug 8 21:47:40 2019 (r350794) @@ -884,22 +884,14 @@ noerror: int16_t *ptr; int veto = 0; + /* + * Convert to host byte order, and fix the strings. + */ ident_buf = &softc->ident_data; for (ptr = (int16_t *)ident_buf; ptr < (int16_t *)ident_buf + sizeof(struct ata_params)/2; ptr++) { *ptr = le16toh(*ptr); } - - /* - * Allow others to veto this ATA disk attachment. This - * is mainly used by VMs, whose disk controllers may - * share the disks with the simulated ATA controllers. - */ - EVENTHANDLER_INVOKE(ada_probe_veto, path, ident_buf, &veto); - if (veto) { - goto device_fail; - } - if (strncmp(ident_buf->model, "FX", 2) && strncmp(ident_buf->model, "NEC", 3) && strncmp(ident_buf->model, "Pioneer", 7) && @@ -914,6 +906,17 @@ noerror: ata_bpack(ident_buf->revision, ident_buf->revision, sizeof(ident_buf->revision)); ata_btrim(ident_buf->serial, sizeof(ident_buf->serial)); ata_bpack(ident_buf->serial, ident_buf->serial, sizeof(ident_buf->serial)); + + /* + * Allow others to veto this ATA disk attachment. This + * is mainly used by VMs, whose disk controllers may + * share the disks with the simulated ATA controllers. + */ + EVENTHANDLER_INVOKE(ada_probe_veto, path, ident_buf, &veto); + if (veto) { + goto device_fail; + } + /* Device may need spin-up before IDENTIFY become valid. */ if ((ident_buf->specconf == 0x37c8 || ident_buf->specconf == 0x738c) && From owner-svn-src-stable-11@freebsd.org Thu Aug 8 21:54:32 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 919F8B46C1; Thu, 8 Aug 2019 21:54:32 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 464MbX2mfzz3CyX; Thu, 8 Aug 2019 21:54:32 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3DF663CB4; Thu, 8 Aug 2019 21:54:32 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x78LsWK8035268; Thu, 8 Aug 2019 21:54:32 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x78LsVf6035267; Thu, 8 Aug 2019 21:54:31 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201908082154.x78LsVf6035267@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 8 Aug 2019 21:54:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r350795 - stable/11/sbin/camcontrol X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sbin/camcontrol X-SVN-Commit-Revision: 350795 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Aug 2019 21:54:32 -0000 Author: mav Date: Thu Aug 8 21:54:31 2019 New Revision: 350795 URL: https://svnweb.freebsd.org/changeset/base/350795 Log: MFC r349964 (by imp): Add device type NVME and device type MMCSD to get_device_type For completeness, add nvme and mmc/sd devices to the list of device types we know. Modified: stable/11/sbin/camcontrol/camcontrol.c stable/11/sbin/camcontrol/camcontrol.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/camcontrol/camcontrol.c ============================================================================== --- stable/11/sbin/camcontrol/camcontrol.c Thu Aug 8 21:47:40 2019 (r350794) +++ stable/11/sbin/camcontrol/camcontrol.c Thu Aug 8 21:54:31 2019 (r350795) @@ -5193,6 +5193,10 @@ get_device_type(struct cam_device *dev, int retry_coun *devtype = CC_DT_ATA; goto bailout; break; /*NOTREACHED*/ + case PROTO_NVME: + *devtype = CC_DT_NVME; + goto bailout; + break; /*NOTREACHED*/ default: *devtype = CC_DT_UNKNOWN; goto bailout; Modified: stable/11/sbin/camcontrol/camcontrol.h ============================================================================== --- stable/11/sbin/camcontrol/camcontrol.h Thu Aug 8 21:47:40 2019 (r350794) +++ stable/11/sbin/camcontrol/camcontrol.h Thu Aug 8 21:54:31 2019 (r350795) @@ -44,6 +44,8 @@ typedef enum { CC_DT_SCSI, CC_DT_ATA_BEHIND_SCSI, CC_DT_ATA, + CC_DT_NVME, + CC_DT_MMCSD, CC_DT_UNKNOWN } camcontrol_devtype; From owner-svn-src-stable-11@freebsd.org Thu Aug 8 21:55:50 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B47BAB4765; Thu, 8 Aug 2019 21:55:50 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 464Md24PZnz3D5x; Thu, 8 Aug 2019 21:55:50 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7A1873CB5; Thu, 8 Aug 2019 21:55:50 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x78LtoDB035421; Thu, 8 Aug 2019 21:55:50 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x78LtnGR035416; Thu, 8 Aug 2019 21:55:49 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201908082155.x78LtnGR035416@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 8 Aug 2019 21:55:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r350796 - stable/11/sbin/camcontrol X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sbin/camcontrol X-SVN-Commit-Revision: 350796 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Aug 2019 21:55:50 -0000 Author: mav Date: Thu Aug 8 21:55:49 2019 New Revision: 350796 URL: https://svnweb.freebsd.org/changeset/base/350796 Log: MFC r350008 (by imp): Use the more proper term of SATL instead of ATA_BEHIND_SCSI. Most people know SAS attached SATA devices by the name SAT or SATL (with the latter being a little more common). Change the device type ATA_BEHIND_SCSI to SATL since it's more specific and meaningful. Modified: stable/11/sbin/camcontrol/camcontrol.c stable/11/sbin/camcontrol/camcontrol.h stable/11/sbin/camcontrol/epc.c stable/11/sbin/camcontrol/fwdownload.c stable/11/sbin/camcontrol/zone.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/camcontrol/camcontrol.c ============================================================================== --- stable/11/sbin/camcontrol/camcontrol.c Thu Aug 8 21:54:31 2019 (r350795) +++ stable/11/sbin/camcontrol/camcontrol.c Thu Aug 8 21:55:49 2019 (r350796) @@ -5214,7 +5214,7 @@ get_device_type(struct cam_device *dev, int retry_coun retval = dev_has_vpd_page(dev, SVPD_ATA_INFORMATION, retry_count, timeout, verbosemode); if (retval == 1) - *devtype = CC_DT_ATA_BEHIND_SCSI; + *devtype = CC_DT_SATL; else *devtype = CC_DT_SCSI; Modified: stable/11/sbin/camcontrol/camcontrol.h ============================================================================== --- stable/11/sbin/camcontrol/camcontrol.h Thu Aug 8 21:54:31 2019 (r350795) +++ stable/11/sbin/camcontrol/camcontrol.h Thu Aug 8 21:55:49 2019 (r350796) @@ -42,7 +42,7 @@ typedef enum { typedef enum { CC_DT_NONE, CC_DT_SCSI, - CC_DT_ATA_BEHIND_SCSI, + CC_DT_SATL, CC_DT_ATA, CC_DT_NVME, CC_DT_MMCSD, Modified: stable/11/sbin/camcontrol/epc.c ============================================================================== --- stable/11/sbin/camcontrol/epc.c Thu Aug 8 21:54:31 2019 (r350795) +++ stable/11/sbin/camcontrol/epc.c Thu Aug 8 21:55:49 2019 (r350796) @@ -767,7 +767,7 @@ epc(struct cam_device *device, int argc, char **argv, switch (devtype) { case CC_DT_ATA: - case CC_DT_ATA_BEHIND_SCSI: + case CC_DT_SATL: break; default: warnx("The epc subcommand only works with ATA protocol " Modified: stable/11/sbin/camcontrol/fwdownload.c ============================================================================== --- stable/11/sbin/camcontrol/fwdownload.c Thu Aug 8 21:54:31 2019 (r350795) +++ stable/11/sbin/camcontrol/fwdownload.c Thu Aug 8 21:55:49 2019 (r350796) @@ -694,7 +694,7 @@ fw_check_device_ready(struct cam_device *dev, camcontr /*sense_len*/ SSD_FULL_SIZE, /*timeout*/ 5000); break; - case CC_DT_ATA_BEHIND_SCSI: + case CC_DT_SATL: case CC_DT_ATA: { retval = build_ata_cmd(ccb, /*retries*/ 1, @@ -853,7 +853,7 @@ fw_download_img(struct cam_device *cam_dev, struct fw_ timeout ? timeout : WB_TIMEOUT); /* timeout*/ break; case CC_DT_ATA: - case CC_DT_ATA_BEHIND_SCSI: { + case CC_DT_SATL: { uint32_t off; off = (uint32_t)(pkt_ptr - buf); @@ -969,7 +969,7 @@ fwdownload(struct cam_device *device, int argc, char * errx(1, "Unable to determine device type"); if ((devtype == CC_DT_ATA) - || (devtype == CC_DT_ATA_BEHIND_SCSI)) { + || (devtype == CC_DT_SATL)) { ccb = cam_getccb(device); if (ccb == NULL) { warnx("couldn't allocate CCB"); Modified: stable/11/sbin/camcontrol/zone.c ============================================================================== --- stable/11/sbin/camcontrol/zone.c Thu Aug 8 21:54:31 2019 (r350795) +++ stable/11/sbin/camcontrol/zone.c Thu Aug 8 21:55:49 2019 (r350796) @@ -466,7 +466,7 @@ restart_report: /*timeout*/ timeout ? timeout : 60000); break; case CC_DT_ATA: - case CC_DT_ATA_BEHIND_SCSI: { + case CC_DT_SATL: { uint8_t command = 0; uint8_t protocol = 0; uint16_t features = 0, sector_count = 0; @@ -558,7 +558,7 @@ restart_report: /*timeout*/ timeout ? timeout : 60000); break; case CC_DT_ATA: - case CC_DT_ATA_BEHIND_SCSI: { + case CC_DT_SATL: { uint8_t command = 0; uint8_t protocol = 0; uint16_t features = 0, sector_count = 0; From owner-svn-src-stable-11@freebsd.org Thu Aug 8 22:03:02 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C60EEB4A53; Thu, 8 Aug 2019 22:03:02 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 464MnL4rQRz3DX9; Thu, 8 Aug 2019 22:03:02 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 87C3D3E6C; Thu, 8 Aug 2019 22:03:02 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x78M32RN041132; Thu, 8 Aug 2019 22:03:02 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x78M32EZ041130; Thu, 8 Aug 2019 22:03:02 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201908082203.x78M32EZ041130@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 8 Aug 2019 22:03:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r350797 - stable/11/sbin/camcontrol X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sbin/camcontrol X-SVN-Commit-Revision: 350797 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Aug 2019 22:03:02 -0000 Author: mav Date: Thu Aug 8 22:03:01 2019 New Revision: 350797 URL: https://svnweb.freebsd.org/changeset/base/350797 Log: MFC r350018 (by imp): Implement a devtype command. List the device's protocol. The returned value is one of the following: ata direct attach ATA or SATA device satl a SATA device attached via SAS scsi A parallel SCSI or SAS nvme A direct attached NVMe device mmcsd A MMC or SD attached device Modified: stable/11/sbin/camcontrol/camcontrol.8 stable/11/sbin/camcontrol/camcontrol.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/camcontrol/camcontrol.8 ============================================================================== --- stable/11/sbin/camcontrol/camcontrol.8 Thu Aug 8 21:55:49 2019 (r350796) +++ stable/11/sbin/camcontrol/camcontrol.8 Thu Aug 8 22:03:01 2019 (r350797) @@ -353,6 +353,9 @@ .Op generic args .Ao Fl r Oo Ns Fl f Ar format | Fl m | Fl U Oc | Fl s Ao Fl f Ar format Fl T Ar time | Fl U Ac Ac .Nm +.Ic devtype +.Op device id +.Nm .Ic help .Sh DESCRIPTION The @@ -2515,6 +2518,26 @@ option. .It Fl U Set the timestamp to the host system's time in UTC. .El +.El +.It Ic devtype +Print out the device type for specified device. +.Bl -tag -width 10n +.It ata +An ATA device attached directly to an ATA controller +.It satl +An SATA device attached behind a SAS controller via SCSI-ATA Translation Layer (SATL) +.It scsi +A SCSI device +.It nvme +An directly attached NVMe device +.It mmcsd +An MMC or SD device attached via a mmcsd bus +.It none +No device type reported +.It unknown +Device type is unknown +.It illegal +A programming error occurred .El .It Ic help Print out verbose usage information. Modified: stable/11/sbin/camcontrol/camcontrol.c ============================================================================== --- stable/11/sbin/camcontrol/camcontrol.c Thu Aug 8 21:55:49 2019 (r350796) +++ stable/11/sbin/camcontrol/camcontrol.c Thu Aug 8 22:03:01 2019 (r350797) @@ -106,6 +106,7 @@ typedef enum { CAM_CMD_EPC = 0x00000027, CAM_CMD_TIMESTAMP = 0x00000028, CAM_CMD_POWER_MODE = 0x0000002a, + CAM_CMD_DEVTYPE = 0x0000002b, } cam_cmdmask; typedef enum { @@ -219,6 +220,7 @@ static struct camcontrol_opts option_table[] = { {"defectlist", CAM_CMD_READ_DEFECTS, CAM_ARG_NONE, readdefect_opts}, #endif /* MINIMALISTIC */ {"devlist", CAM_CMD_DEVTREE, CAM_ARG_NONE, "-b"}, + {"devtype", CAM_CMD_DEVTYPE, CAM_ARG_NONE, ""}, #ifndef MINIMALISTIC {"periphlist", CAM_CMD_DEVLIST, CAM_ARG_NONE, NULL}, {"modepage", CAM_CMD_MODE_PAGE, CAM_ARG_NONE, "bdelm:P:"}, @@ -267,6 +269,16 @@ struct cam_devlist { static cam_cmdmask cmdlist; static cam_argmask arglist; +static const char *devtype_names[] = { + "none", + "scsi", + "satl", + "ata", + "nvme", + "mmcsd", + "unknown", +}; + camcontrol_optret getoption(struct camcontrol_opts *table, char *arg, uint32_t *cmdnum, cam_argmask *argnum, const char **subopt); @@ -274,6 +286,7 @@ camcontrol_optret getoption(struct camcontrol_opts *ta static int getdevlist(struct cam_device *device); #endif /* MINIMALISTIC */ static int getdevtree(int argc, char **argv, char *combinedopt); +static int getdevtype(struct cam_device *device); #ifndef MINIMALISTIC static int testunitready(struct cam_device *device, int task_attr, int retry_count, int timeout, int quiet); @@ -668,6 +681,24 @@ getdevtree(int argc, char **argv, char *combinedopt) return (error); } +static int +getdevtype(struct cam_device *cam_dev) +{ + camcontrol_devtype dt; + int error; + + /* + * Get the device type and report it, request no I/O be done to do this. + */ + error = get_device_type(cam_dev, -1, 0, 0, &dt); + if (error != 0 || dt < CC_DT_NONE || dt > CC_DT_UNKNOWN) { + fprintf(stdout, "illegal\n"); + return (1); + } + fprintf(stdout, "%s\n", devtype_names[dt]); + return (0); +} + #ifndef MINIMALISTIC static int testunitready(struct cam_device *device, int task_attr, int retry_count, @@ -5178,7 +5209,7 @@ get_device_type(struct cam_device *dev, int retry_coun int verbosemode, camcontrol_devtype *devtype) { struct ccb_getdev cgd; - int retval = 0; + int retval; retval = get_cgd(dev, &cgd); if (retval != 0) @@ -5203,21 +5234,34 @@ get_device_type(struct cam_device *dev, int retry_coun break; /*NOTREACHED*/ } - /* - * Check for the ATA Information VPD page (0x89). If this is an - * ATA device behind a SCSI to ATA translation layer, this VPD page - * should be present. - * - * If that VPD page isn't present, or we get an error back from the - * INQUIRY command, we'll just treat it as a normal SCSI device. - */ - retval = dev_has_vpd_page(dev, SVPD_ATA_INFORMATION, retry_count, - timeout, verbosemode); - if (retval == 1) - *devtype = CC_DT_SATL; - else - *devtype = CC_DT_SCSI; - + if (retry_count == -1) { + /* + * For a retry count of -1, used only the cached data to avoid + * I/O to the drive. Sending the identify command to the drive + * can cause issues for SATL attachaed drives since identify is + * not an NCQ command. + */ + if (cgd.ident_data.config != 0) + *devtype = CC_DT_SATL; + else + *devtype = CC_DT_SCSI; + } else { + /* + * Check for the ATA Information VPD page (0x89). If this is an + * ATA device behind a SCSI to ATA translation layer (SATL), + * this VPD page should be present. + * + * If that VPD page isn't present, or we get an error back from + * the INQUIRY command, we'll just treat it as a normal SCSI + * device. + */ + retval = dev_has_vpd_page(dev, SVPD_ATA_INFORMATION, retry_count, + timeout, verbosemode); + if (retval == 1) + *devtype = CC_DT_SATL; + else + *devtype = CC_DT_SCSI; + } retval = 0; bailout: @@ -9162,6 +9206,7 @@ usage(int printlong) " [-S power_src] [-T timer]\n" " camcontrol timestamp [dev_id][generic_args] <-r [-f format|-m|-U]>|\n" " <-s <-f format -T time | -U >>\n" +" camcontrol devtype [dev_id]\n" " \n" #endif /* MINIMALISTIC */ " camcontrol help\n"); @@ -9209,6 +9254,7 @@ usage(int printlong) "zone manage Zoned Block (Shingled) devices\n" "epc send ATA Extended Power Conditions commands\n" "timestamp report or set the device's timestamp\n" +"devtype report the type of device\n" "help this message\n" "Device Identifiers:\n" "bus:target specify the bus and target, lun defaults to 0\n" @@ -9680,6 +9726,9 @@ main(int argc, char **argv) #endif /* MINIMALISTIC */ case CAM_CMD_DEVTREE: error = getdevtree(argc, argv, combinedopt); + break; + case CAM_CMD_DEVTYPE: + error = getdevtype(cam_dev); break; #ifndef MINIMALISTIC case CAM_CMD_TUR: From owner-svn-src-stable-11@freebsd.org Thu Aug 8 22:03:36 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F36C9B4ACF; Thu, 8 Aug 2019 22:03:36 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 464Mp067wCz3DfL; Thu, 8 Aug 2019 22:03:36 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B5A7D3E6D; Thu, 8 Aug 2019 22:03:36 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x78M3asG041213; Thu, 8 Aug 2019 22:03:36 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x78M3ar9041212; Thu, 8 Aug 2019 22:03:36 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201908082203.x78M3ar9041212@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 8 Aug 2019 22:03:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r350798 - stable/11/sbin/camcontrol X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sbin/camcontrol X-SVN-Commit-Revision: 350798 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Aug 2019 22:03:37 -0000 Author: mav Date: Thu Aug 8 22:03:36 2019 New Revision: 350798 URL: https://svnweb.freebsd.org/changeset/base/350798 Log: MFC r350020 (by imp): Use a different approach to range check. gcc hates dt < CC_DT_NONE since it can never be true when dt is an unsigned type. Since that's a compiler choice and may be affected by weird stuff, instead use (unsigned)dt > CC_DT_UNKNOWN to test for bounds error since that will work regardless of the signedness of dt. Modified: stable/11/sbin/camcontrol/camcontrol.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/camcontrol/camcontrol.c ============================================================================== --- stable/11/sbin/camcontrol/camcontrol.c Thu Aug 8 22:03:01 2019 (r350797) +++ stable/11/sbin/camcontrol/camcontrol.c Thu Aug 8 22:03:36 2019 (r350798) @@ -691,7 +691,7 @@ getdevtype(struct cam_device *cam_dev) * Get the device type and report it, request no I/O be done to do this. */ error = get_device_type(cam_dev, -1, 0, 0, &dt); - if (error != 0 || dt < CC_DT_NONE || dt > CC_DT_UNKNOWN) { + if (error != 0 || (unsigned)dt > CC_DT_UNKNOWN) { fprintf(stdout, "illegal\n"); return (1); } From owner-svn-src-stable-11@freebsd.org Thu Aug 8 22:05:40 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0B315B4C09; Thu, 8 Aug 2019 22:05:40 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 464MrM5v5Vz3DpD; Thu, 8 Aug 2019 22:05:39 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A85773E85; Thu, 8 Aug 2019 22:05:39 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x78M5d8x041433; Thu, 8 Aug 2019 22:05:39 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x78M5dhE041432; Thu, 8 Aug 2019 22:05:39 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201908082205.x78M5dhE041432@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 8 Aug 2019 22:05:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r350799 - stable/11/sys/sys X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/sys X-SVN-Commit-Revision: 350799 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Aug 2019 22:05:40 -0000 Author: mav Date: Thu Aug 8 22:05:39 2019 New Revision: 350799 URL: https://svnweb.freebsd.org/changeset/base/350799 Log: MFC r312212 (by cem): Fix a minor typo (Seiral) Modified: stable/11/sys/sys/ata.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/sys/ata.h ============================================================================== --- stable/11/sys/sys/ata.h Thu Aug 8 22:03:36 2019 (r350798) +++ stable/11/sys/sys/ata.h Thu Aug 8 22:05:39 2019 (r350799) @@ -693,7 +693,7 @@ struct atapi_sense { #define ATA_IDL_ATA_STRINGS 0x05 /* ATA Strings */ #define ATA_IDL_SECURITY 0x06 /* Security */ #define ATA_IDL_PARALLEL_ATA 0x07 /* Parallel ATA */ -#define ATA_IDL_SERIAL_ATA 0x08 /* Seiral ATA */ +#define ATA_IDL_SERIAL_ATA 0x08 /* Serial ATA */ #define ATA_IDL_ZDI 0x09 /* Zoned Device Information */ struct ata_gp_log_dir { From owner-svn-src-stable-11@freebsd.org Thu Aug 8 22:06:40 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id AFB17B4EB6; Thu, 8 Aug 2019 22:06:40 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 464MsX4C7lz3F62; Thu, 8 Aug 2019 22:06:40 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7177F3E88; Thu, 8 Aug 2019 22:06:40 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x78M6ero041680; Thu, 8 Aug 2019 22:06:40 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x78M6ek7041679; Thu, 8 Aug 2019 22:06:40 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201908082206.x78M6ek7041679@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 8 Aug 2019 22:06:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r350800 - stable/11/sys/sys X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/sys X-SVN-Commit-Revision: 350800 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Aug 2019 22:06:40 -0000 Author: mav Date: Thu Aug 8 22:06:40 2019 New Revision: 350800 URL: https://svnweb.freebsd.org/changeset/base/350800 Log: MFC r348376 (by rpokala): Add bits related to SANITIZE, SED, and form-factor to (struct ata_params) Based on ATA-ACS-4, recognize several bit-fields related to the ATA SANITIZE feature-set, Self-Encrypting Drives, and form-factor identification. As part of this change, the name of word 48 of (struct ata_params) is being changed. The previous name, "usedmovsd" does not appear to be related to the previous definition of the word ("double-word IO supported"). The word was defined that way in ATA-1 (1994), but it was marked "Reserved" (meaning "unused, but might be used in the future") in ATA-2 (1996). It stayed that way until ATA-8 (2008), which re-defined it as implemented in this change. The field is not used in-tree. Modified: stable/11/sys/sys/ata.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/sys/ata.h ============================================================================== --- stable/11/sys/sys/ata.h Thu Aug 8 22:05:39 2019 (r350799) +++ stable/11/sys/sys/ata.h Thu Aug 8 22:06:40 2019 (r350800) @@ -64,7 +64,8 @@ struct ata_params { /*023*/ u_int8_t revision[8]; /* firmware revision */ /*027*/ u_int8_t model[40]; /* model name */ /*047*/ u_int16_t sectors_intr; /* sectors per interrupt */ -/*048*/ u_int16_t usedmovsd; /* double word read/write? */ +/*048*/ u_int16_t tcg; /* Trusted Computing Group */ +#define ATA_SUPPORT_TCG 0x0001 /*049*/ u_int16_t capabilities1; #define ATA_SUPPORT_DMA 0x0100 #define ATA_SUPPORT_LBA 0x0200 @@ -90,6 +91,10 @@ struct ata_params { /*057*/ u_int16_t current_size_1; /*058*/ u_int16_t current_size_2; /*059*/ u_int16_t multi; +#define ATA_SUPPORT_BLOCK_ERASE_EXT 0x8000 +#define ATA_SUPPORT_OVERWRITE_EXT 0x4000 +#define ATA_SUPPORT_CRYPTO_SCRAMBLE_EXT 0x2000 +#define ATA_SUPPORT_SANITIZE 0x1000 #define ATA_MULTI_VALID 0x0100 /*060*/ u_int16_t lba_size_1; @@ -105,6 +110,7 @@ struct ata_params { /*069*/ u_int16_t support3; #define ATA_SUPPORT_RZAT 0x0020 #define ATA_SUPPORT_DRAT 0x4000 +#define ATA_ENCRYPTS_ALL_USER_DATA 0x0010 /* Self-encrypting drive */ #define ATA_SUPPORT_ZONE_MASK 0x0003 #define ATA_SUPPORT_ZONE_NR 0x0000 #define ATA_SUPPORT_ZONE_HOST_AWARE 0x0001 @@ -257,7 +263,19 @@ struct ata_params { /*162*/ u_int16_t cfa_kms_support; /*163*/ u_int16_t cfa_trueide_modes; /*164*/ u_int16_t cfa_memory_modes; - u_int16_t reserved165[4]; + u_int16_t reserved165[3]; +/*168*/ u_int16_t form_factor; +#define ATA_FORM_FACTOR_MASK 0x000f +#define ATA_FORM_FACTOR_NOT_REPORTED 0x0000 +#define ATA_FORM_FACTOR_5_25 0x0001 +#define ATA_FORM_FACTOR_3_5 0x0002 +#define ATA_FORM_FACTOR_2_5 0x0003 +#define ATA_FORM_FACTOR_1_8 0x0004 +#define ATA_FORM_FACTOR_SUB_1_8 0x0005 +#define ATA_FORM_FACTOR_MSATA 0x0006 +#define ATA_FORM_FACTOR_M_2 0x0007 +#define ATA_FORM_FACTOR_MICRO_SSD 0x0008 +#define ATA_FORM_FACTOR_C_FAST 0x0009 /*169*/ u_int16_t support_dsm; #define ATA_SUPPORT_DSM_TRIM 0x0001 u_int16_t reserved170[6]; From owner-svn-src-stable-11@freebsd.org Thu Aug 8 22:08:56 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2A795B5054; Thu, 8 Aug 2019 22:08:56 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 464Mw80tlzz3FFf; Thu, 8 Aug 2019 22:08:56 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 14F2B3E89; Thu, 8 Aug 2019 22:08:56 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x78M8uYo041846; Thu, 8 Aug 2019 22:08:56 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x78M8tZm041843; Thu, 8 Aug 2019 22:08:55 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201908082208.x78M8tZm041843@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 8 Aug 2019 22:08:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r350801 - in stable/11: sbin/camcontrol sys/cam/ata sys/sys X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: in stable/11: sbin/camcontrol sys/cam/ata sys/sys X-SVN-Commit-Revision: 350801 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Aug 2019 22:08:56 -0000 Author: mav Date: Thu Aug 8 22:08:54 2019 New Revision: 350801 URL: https://svnweb.freebsd.org/changeset/base/350801 Log: MFC r350149: Add Accessible Max Address Configuration support to camcontrol. AMA replaced HPA in ACS-3 specification. It allows to limit size of the disk alike to HPA, but declares inaccessible data as indeterminate. One of its practical use cases is to under-provision SATA SSDs for better reliability and performance. While there, fix HPA Security detection/reporting. Relnotes: yes Modified: stable/11/sbin/camcontrol/camcontrol.8 stable/11/sbin/camcontrol/camcontrol.c stable/11/sys/cam/ata/ata_all.c stable/11/sys/sys/ata.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/camcontrol/camcontrol.8 ============================================================================== --- stable/11/sbin/camcontrol/camcontrol.8 Thu Aug 8 22:06:40 2019 (r350800) +++ stable/11/sbin/camcontrol/camcontrol.8 Thu Aug 8 22:08:54 2019 (r350801) @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 22, 2019 +.Dd July 19, 2019 .Dt CAMCONTROL 8 .Os .Sh NAME @@ -292,6 +292,13 @@ .Op Fl U Ar pwd .Op Fl y .Nm +.Ic ama +.Op device id +.Op generic args +.Op Fl f +.Op Fl q +.Op Fl s Ar max_sectors +.Nm .Ic persist .Op device id .Op generic args @@ -1599,6 +1606,40 @@ without prompting for confirmation .Pp The password for all HPA commands is limited to 32 characters, longer passwords will fail. +.It Ic ama +Update or report Accessible Max Address Configuration. +By default +.Nm +will print out the Accessible Max Address Configuration support and associated +settings of the device. +The +.Ic ama +command takes several optional arguments: +.Bl -tag -width 0n +.It Fl f +.Pp +Freeze the Accessible Max Address Configuration of the specified device. +.Pp +After command completion any other commands that update the configuration +shall be command aborted. +Frozen mode is disabled by power-off. +.It Fl q +.Pp +Be quiet, do not print any status messages. +.It Fl s Ar max_sectors +.Pp +Configures the maximum user accessible sectors of the device. +This will change the number of sectors the device reports. +.Pp +.Em WARNING! WARNING! WARNING! +.Pp +Changing the max sectors of a device using this option will make the data on +the device beyond the specified value indeterminate. +.Pp +Only one successful +.Fl s Ar max_sectors +call can be made without a power-on reset of the device. +.El .It Ic fwdownload Program firmware of the named .Tn SCSI Modified: stable/11/sbin/camcontrol/camcontrol.c ============================================================================== --- stable/11/sbin/camcontrol/camcontrol.c Thu Aug 8 22:06:40 2019 (r350800) +++ stable/11/sbin/camcontrol/camcontrol.c Thu Aug 8 22:08:54 2019 (r350801) @@ -107,6 +107,7 @@ typedef enum { CAM_CMD_TIMESTAMP = 0x00000028, CAM_CMD_POWER_MODE = 0x0000002a, CAM_CMD_DEVTYPE = 0x0000002b, + CAM_CMD_AMA = 0x0000002c, } cam_cmdmask; typedef enum { @@ -239,6 +240,7 @@ static struct camcontrol_opts option_table[] = { {"fwdownload", CAM_CMD_DOWNLOAD_FW, CAM_ARG_NONE, "f:qsy"}, {"security", CAM_CMD_SECURITY, CAM_ARG_NONE, "d:e:fh:k:l:qs:T:U:y"}, {"hpa", CAM_CMD_HPA, CAM_ARG_NONE, "Pflp:qs:U:y"}, + {"ama", CAM_CMD_AMA, CAM_ARG_NONE, "fqs:"}, {"persist", CAM_CMD_PERSIST, CAM_ARG_NONE, "ai:I:k:K:o:ps:ST:U"}, {"attrib", CAM_CMD_ATTRIB, CAM_ARG_NONE, "a:ce:F:p:r:s:T:w:V:"}, {"opcodes", CAM_CMD_OPCODES, CAM_ARG_NONE, "No:s:T"}, @@ -358,6 +360,8 @@ static int atasecurity(struct cam_device *device, int int argc, char **argv, char *combinedopt); static int atahpa(struct cam_device *device, int retry_count, int timeout, int argc, char **argv, char *combinedopt); +static int ataama(struct cam_device *device, int retry_count, int timeout, + int argc, char **argv, char *combinedopt); static int scsiprintoneopcode(struct cam_device *device, int req_opcode, int sa_set, int req_sa, uint8_t *buf, uint32_t valid_len); @@ -1275,8 +1279,9 @@ atahpa_print(struct ata_params *parm, u_int64_t hpasiz lba, hpasize); printf("HPA - Security "); - if (parm->support.command1 & ATA_SUPPORT_MAXSECURITY) - printf("yes\n"); + if (parm->support.command2 & ATA_SUPPORT_MAXSECURITY) + printf("yes %s\n", (parm->enabled.command2 & + ATA_SUPPORT_MAXSECURITY) ? "yes" : "no "); else printf("no\n"); } else { @@ -1284,6 +1289,32 @@ atahpa_print(struct ata_params *parm, u_int64_t hpasiz } } +static void +ataama_print(struct ata_params *parm, u_int64_t nativesize, int header) +{ + u_int32_t lbasize = (u_int32_t)parm->lba_size_1 | + ((u_int32_t)parm->lba_size_2 << 16); + + u_int64_t lbasize48 = ((u_int64_t)parm->lba_size48_1) | + ((u_int64_t)parm->lba_size48_2 << 16) | + ((u_int64_t)parm->lba_size48_3 << 32) | + ((u_int64_t)parm->lba_size48_4 << 48); + + if (header) { + printf("\nFeature " + "Support Enabled Value\n"); + } + + printf("Accessible Max Address Config "); + if (parm->support2 & ATA_SUPPORT_AMAX_ADDR) { + u_int64_t lba = lbasize48 ? lbasize48 : lbasize; + printf("yes %s %ju/%ju\n", + (nativesize > lba) ? "yes" : "no ", lba, nativesize); + } else { + printf("no\n"); + } +} + static int atasata(struct ata_params *parm) { @@ -2110,7 +2141,95 @@ atahpa_freeze_lock(struct cam_device *device, int retr return atahpa_proc_resp(device, ccb, is48bit, NULL); } +static int +ata_get_native_max(struct cam_device *device, int retry_count, + u_int32_t timeout, union ccb *ccb, + u_int64_t *nativesize) +{ + int error; + error = ata_do_cmd(device, + ccb, + retry_count, + /*flags*/CAM_DIR_NONE, + /*protocol*/AP_PROTO_NON_DATA | AP_EXTEND, + /*ata_flags*/AP_FLAG_CHK_COND, + /*tag_action*/MSG_SIMPLE_Q_TAG, + /*command*/ATA_AMAX_ADDR, + /*features*/ATA_AMAX_ADDR_GET, + /*lba*/0, + /*sector_count*/0, + /*data_ptr*/NULL, + /*dxfer_len*/0, + timeout ? timeout : 30 * 1000, + /*force48bit*/1); + + if (error) + return (error); + + return atahpa_proc_resp(device, ccb, /*is48bit*/1, nativesize); +} + +static int +ataama_set(struct cam_device *device, int retry_count, + u_int32_t timeout, union ccb *ccb, u_int64_t maxsize) +{ + int error; + + /* lba's are zero indexed so the max lba is requested max - 1 */ + if (maxsize) + maxsize--; + + error = ata_do_cmd(device, + ccb, + retry_count, + /*flags*/CAM_DIR_NONE, + /*protocol*/AP_PROTO_NON_DATA | AP_EXTEND, + /*ata_flags*/AP_FLAG_CHK_COND, + /*tag_action*/MSG_SIMPLE_Q_TAG, + /*command*/ATA_AMAX_ADDR, + /*features*/ATA_AMAX_ADDR_SET, + /*lba*/maxsize, + /*sector_count*/0, + /*data_ptr*/NULL, + /*dxfer_len*/0, + timeout ? timeout : 30 * 1000, + /*force48bit*/1); + + if (error) + return (error); + + return atahpa_proc_resp(device, ccb, /*is48bit*/1, NULL); +} + +static int +ataama_freeze(struct cam_device *device, int retry_count, + u_int32_t timeout, union ccb *ccb) +{ + int error; + + error = ata_do_cmd(device, + ccb, + retry_count, + /*flags*/CAM_DIR_NONE, + /*protocol*/AP_PROTO_NON_DATA | AP_EXTEND, + /*ata_flags*/AP_FLAG_CHK_COND, + /*tag_action*/MSG_SIMPLE_Q_TAG, + /*command*/ATA_AMAX_ADDR, + /*features*/ATA_AMAX_ADDR_FREEZE, + /*lba*/0, + /*sector_count*/0, + /*data_ptr*/NULL, + /*dxfer_len*/0, + timeout ? timeout : 30 * 1000, + /*force48bit*/1); + + if (error) + return (error); + + return atahpa_proc_resp(device, ccb, /*is48bit*/1, NULL); +} + int ata_do_identify(struct cam_device *device, int retry_count, int timeout, union ccb *ccb, struct ata_params** ident_bufp) @@ -2241,7 +2360,7 @@ ataidentify(struct cam_device *device, int retry_count { union ccb *ccb; struct ata_params *ident_buf; - u_int64_t hpasize; + u_int64_t hpasize, nativesize; if ((ccb = cam_getccb(device)) == NULL) { warnx("couldn't allocate CCB"); @@ -2262,12 +2381,22 @@ ataidentify(struct cam_device *device, int retry_count } else { hpasize = 0; } + if (ident_buf->support2 & ATA_SUPPORT_AMAX_ADDR) { + if (ata_get_native_max(device, retry_count, timeout, ccb, + &nativesize) != 0) { + cam_freeccb(ccb); + return (1); + } + } else { + nativesize = 0; + } printf("%s%d: ", device->device_name, device->dev_unit_num); ata_print_ident(ident_buf); camxferrate(device); atacapprint(ident_buf); atahpa_print(ident_buf, hpasize, 0); + ataama_print(ident_buf, nativesize, 0); free(ident_buf); cam_freeccb(ccb); @@ -2757,7 +2886,7 @@ atahpa(struct cam_device *device, int retry_count, int return (1); } - if (security && !(ident_buf->support.command1 & ATA_SUPPORT_MAXSECURITY)) { + if (security && !(ident_buf->support.command2 & ATA_SUPPORT_MAXSECURITY)) { warnx("HPA Security is not supported by this device"); cam_freeccb(ccb); free(ident_buf); @@ -2786,7 +2915,7 @@ atahpa(struct cam_device *device, int retry_count, int if (error == 0) { error = atahpa_set_max(device, retry_count, timeout, ccb, is48bit, maxsize, persist); - if (error == 0) { + if (error == 0 && quiet == 0) { /* redo identify to get new lba values */ error = ata_do_identify(device, retry_count, timeout, ccb, @@ -2799,28 +2928,28 @@ atahpa(struct cam_device *device, int retry_count, int case ATA_HPA_ACTION_SET_PWD: error = atahpa_password(device, retry_count, timeout, ccb, is48bit, &pwd); - if (error == 0) + if (error == 0 && quiet == 0) printf("HPA password has been set\n"); break; case ATA_HPA_ACTION_LOCK: error = atahpa_lock(device, retry_count, timeout, ccb, is48bit); - if (error == 0) + if (error == 0 && quiet == 0) printf("HPA has been locked\n"); break; case ATA_HPA_ACTION_UNLOCK: error = atahpa_unlock(device, retry_count, timeout, ccb, is48bit, &pwd); - if (error == 0) + if (error == 0 && quiet == 0) printf("HPA has been unlocked\n"); break; case ATA_HPA_ACTION_FREEZE_LOCK: error = atahpa_freeze_lock(device, retry_count, timeout, ccb, is48bit); - if (error == 0) + if (error == 0 && quiet == 0) printf("HPA has been frozen\n"); break; @@ -2834,7 +2963,128 @@ atahpa(struct cam_device *device, int retry_count, int return (error); } +enum { + ATA_AMA_ACTION_PRINT, + ATA_AMA_ACTION_SET_MAX, + ATA_AMA_ACTION_FREEZE_LOCK +}; + static int +ataama(struct cam_device *device, int retry_count, int timeout, + int argc, char **argv, char *combinedopt) +{ + union ccb *ccb; + struct ata_params *ident_buf; + struct ccb_getdev cgd; + int error, quiet, c, action, actions; + u_int64_t nativesize, maxsize; + + actions = 0; + quiet = 0; + maxsize = 0; + + /* default action is to print AMA information */ + action = ATA_AMA_ACTION_PRINT; + + while ((c = getopt(argc, argv, combinedopt)) != -1) { + switch(c){ + case 's': + action = ATA_AMA_ACTION_SET_MAX; + maxsize = strtoumax(optarg, NULL, 0); + actions++; + break; + + case 'f': + action = ATA_AMA_ACTION_FREEZE_LOCK; + actions++; + break; + + case 'q': + quiet++; + break; + } + } + + if (actions > 1) { + warnx("too many AMA actions specified"); + return (1); + } + + if (get_cgd(device, &cgd) != 0) { + warnx("couldn't get CGD"); + return (1); + } + + ccb = cam_getccb(device); + if (ccb == NULL) { + warnx("couldn't allocate CCB"); + return (1); + } + + error = ata_do_identify(device, retry_count, timeout, ccb, &ident_buf); + if (error != 0) { + cam_freeccb(ccb); + return (1); + } + + if (quiet == 0) { + printf("%s%d: ", device->device_name, device->dev_unit_num); + ata_print_ident(ident_buf); + camxferrate(device); + } + + if (action == ATA_AMA_ACTION_PRINT) { + error = ata_get_native_max(device, retry_count, timeout, ccb, + &nativesize); + if (error == 0) + ataama_print(ident_buf, nativesize, 1); + + cam_freeccb(ccb); + free(ident_buf); + return (error); + } + + if (!(ident_buf->support2 & ATA_SUPPORT_AMAX_ADDR)) { + warnx("Accessible Max Address is not supported by this device"); + cam_freeccb(ccb); + free(ident_buf); + return (1); + } + + switch(action) { + case ATA_AMA_ACTION_SET_MAX: + error = ata_get_native_max(device, retry_count, timeout, ccb, + &nativesize); + if (error == 0) { + error = ataama_set(device, retry_count, timeout, + ccb, maxsize); + if (error == 0 && quiet == 0) { + /* redo identify to get new lba values */ + error = ata_do_identify(device, retry_count, + timeout, ccb, &ident_buf); + ataama_print(ident_buf, nativesize, 1); + } + } + break; + + case ATA_AMA_ACTION_FREEZE_LOCK: + error = ataama_freeze(device, retry_count, timeout, + ccb); + if (error == 0 && quiet == 0) + printf("Accessible Max Address has been frozen\n"); + break; + + default: + errx(1, "Option currently not supported"); + } + + cam_freeccb(ccb); + free(ident_buf); + + return (error); +} + +static int atasecurity(struct cam_device *device, int retry_count, int timeout, int argc, char **argv, char *combinedopt) { @@ -9191,6 +9441,7 @@ usage(int printlong) " [-U ] [-y]\n" " camcontrol hpa [dev_id][generic args] [-f] [-l] [-P] [-p pwd]\n" " [-q] [-s max_sectors] [-U pwd] [-y]\n" +" camcontrol ama [dev_id][generic args] [-f] [-q] [-s max_sectors]\n" " camcontrol persist [dev_id][generic args] <-i action|-o action>\n" " [-a][-I tid][-k key][-K sa_key][-p][-R rtp]\n" " [-s scope][-S][-T type][-U]\n" @@ -9391,6 +9642,11 @@ usage(int printlong) " device\n" "-U pwd unlock the HPA configuration of the device\n" "-y don't ask any questions\n" +"ama arguments:\n" +"-f freeze the AMA configuration of the device\n" +"-q be quiet, do not print any status messages\n" +"-s sectors configures the maximum user accessible sectors of the\n" +" device\n" "persist arguments:\n" "-i action specify read_keys, read_reservation, report_cap, or\n" " read_full_status\n" @@ -9721,6 +9977,10 @@ main(int argc, char **argv) break; case CAM_CMD_HPA: error = atahpa(cam_dev, retry_count, timeout, + argc, argv, combinedopt); + break; + case CAM_CMD_AMA: + error = ataama(cam_dev, retry_count, timeout, argc, argv, combinedopt); break; #endif /* MINIMALISTIC */ Modified: stable/11/sys/cam/ata/ata_all.c ============================================================================== --- stable/11/sys/cam/ata/ata_all.c Thu Aug 8 22:06:40 2019 (r350800) +++ stable/11/sys/cam/ata/ata_all.c Thu Aug 8 22:08:54 2019 (r350801) @@ -182,7 +182,13 @@ ata_op_string(struct ata_cmd *cmd) return ("SEP_ATTN"); case 0x70: return ("SEEK"); case 0x77: return ("SET_DATE_TIME_EXT"); - case 0x78: return ("ACCESSIBLE_MAX_ADDRESS_CONFIGURATION"); + case 0x78: + switch (cmd->features) { + case 0x00: return ("GET_NATIVE_MAX_ADDRESS_EXT"); + case 0x01: return ("SET_ACCESSIBLE_MAX_ADDRESS_EXT"); + case 0x02: return ("FREEZE_ACCESSIBLE_MAX_ADDRESS_EXT"); + } + return ("ACCESSIBLE_MAX_ADDRESS_CONFIGURATION"); case 0x7C: return ("REMOVE_ELEMENT_AND_TRUNCATE"); case 0x87: return ("CFA_TRANSLATE_SECTOR"); case 0x90: return ("EXECUTE_DEVICE_DIAGNOSTIC"); Modified: stable/11/sys/sys/ata.h ============================================================================== --- stable/11/sys/sys/ata.h Thu Aug 8 22:06:40 2019 (r350800) +++ stable/11/sys/sys/ata.h Thu Aug 8 22:08:54 2019 (r350801) @@ -240,12 +240,15 @@ struct ata_params { #define ATA_SUPPORT_FREEFALL 0x0020 #define ATA_SUPPORT_SENSE_REPORT 0x0040 #define ATA_SUPPORT_EPC 0x0080 +#define ATA_SUPPORT_AMAX_ADDR 0x0100 +#define ATA_SUPPORT_DSN 0x0200 /*120*/ u_int16_t enabled2; #define ATA_ENABLED_WRITEREADVERIFY 0x0002 #define ATA_ENABLED_WRITEUNCORREXT 0x0004 #define ATA_ENABLED_FREEFALL 0x0020 #define ATA_ENABLED_SENSE_REPORT 0x0040 #define ATA_ENABLED_EPC 0x0080 +#define ATA_ENABLED_DSN 0x0200 u_int16_t reserved121[6]; /*127*/ u_int16_t removable_status; /*128*/ u_int16_t security_status; @@ -434,6 +437,10 @@ struct ata_params { #define ATA_RFPDMA_ZAC_MGMT_IN 0x02 /* NCQ ZAC mgmt in w/data */ #define ATA_SEP_ATTN 0x67 /* SEP request */ #define ATA_SEEK 0x70 /* seek */ +#define ATA_AMAX_ADDR 0x78 /* Accessible Max Address */ +#define ATA_AMAX_ADDR_GET 0x00 /* GET NATIVE MAX ADDRESS EXT */ +#define ATA_AMAX_ADDR_SET 0x01 /* SET ACCESSIBLE MAX ADDRESS EXT */ +#define ATA_AMAX_ADDR_FREEZE 0x02 /* FREEZE ACCESSIBLE MAX ADDRESS EXT */ #define ATA_ZAC_MANAGEMENT_OUT 0x9f /* ZAC management out */ #define ATA_ZM_CLOSE_ZONE 0x01 /* close zone */ #define ATA_ZM_FINISH_ZONE 0x02 /* finish zone */ From owner-svn-src-stable-11@freebsd.org Thu Aug 8 22:09:33 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 44E9EB5107; Thu, 8 Aug 2019 22:09:33 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 464Mws16tzz3FRY; Thu, 8 Aug 2019 22:09:33 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0A0D33E94; Thu, 8 Aug 2019 22:09:33 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x78M9Wds041934; Thu, 8 Aug 2019 22:09:32 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x78M9Wm2041933; Thu, 8 Aug 2019 22:09:32 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201908082209.x78M9Wm2041933@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 8 Aug 2019 22:09:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r350802 - stable/11/sbin/camcontrol X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sbin/camcontrol X-SVN-Commit-Revision: 350802 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Aug 2019 22:09:33 -0000 Author: mav Date: Thu Aug 8 22:09:32 2019 New Revision: 350802 URL: https://svnweb.freebsd.org/changeset/base/350802 Log: MFC r350150: Properly report ACS revisions alike to kernel. Modified: stable/11/sbin/camcontrol/camcontrol.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/camcontrol/camcontrol.c ============================================================================== --- stable/11/sbin/camcontrol/camcontrol.c Thu Aug 8 22:08:54 2019 (r350801) +++ stable/11/sbin/camcontrol/camcontrol.c Thu Aug 8 22:09:32 2019 (r350802) @@ -1330,6 +1330,7 @@ atasata(struct ata_params *parm) static void atacapprint(struct ata_params *parm) { + const char *proto; u_int32_t lbasize = (u_int32_t)parm->lba_size_1 | ((u_int32_t)parm->lba_size_2 << 16); @@ -1340,7 +1341,19 @@ atacapprint(struct ata_params *parm) printf("\n"); printf("protocol "); - printf("ATA/ATAPI-%d", ata_version(parm->version_major)); + proto = (parm->config == ATA_PROTO_CFA) ? "CFA" : + (parm->config & ATA_PROTO_ATAPI) ? "ATAPI" : "ATA"; + if (ata_version(parm->version_major) == 0) { + printf("%s", proto); + } else if (ata_version(parm->version_major) <= 7) { + printf("%s-%d", proto, + ata_version(parm->version_major)); + } else if (ata_version(parm->version_major) == 8) { + printf("%s8-ACS", proto); + } else { + printf("ACS-%d %s", + ata_version(parm->version_major) - 7, proto); + } if (parm->satacapabilities && parm->satacapabilities != 0xffff) { if (parm->satacapabilities & ATA_SATA_GEN3) printf(" SATA 3.x\n"); From owner-svn-src-stable-11@freebsd.org Thu Aug 8 22:11:02 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id AEBA3B5250; Thu, 8 Aug 2019 22:11:02 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 464MyZ4D4qz3Fdf; Thu, 8 Aug 2019 22:11:02 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 71DA83FF6; Thu, 8 Aug 2019 22:11:02 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x78MB2Zc042127; Thu, 8 Aug 2019 22:11:02 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x78MB2Nl042125; Thu, 8 Aug 2019 22:11:02 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201908082211.x78MB2Nl042125@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 8 Aug 2019 22:11:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r350803 - stable/11/sbin/camcontrol X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sbin/camcontrol X-SVN-Commit-Revision: 350803 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Aug 2019 22:11:02 -0000 Author: mav Date: Thu Aug 8 22:11:01 2019 New Revision: 350803 URL: https://svnweb.freebsd.org/changeset/base/350803 Log: MFC r350214: Unify BTL parsing for `camcontrol debug` and `reset`. This makes `camcontrol debug` also allow peripheral device specification. While there, make BTL parser more strict and switch from strtok() to strsep(). Modified: stable/11/sbin/camcontrol/camcontrol.8 stable/11/sbin/camcontrol/camcontrol.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/camcontrol/camcontrol.8 ============================================================================== --- stable/11/sbin/camcontrol/camcontrol.8 Thu Aug 8 22:09:32 2019 (r350802) +++ stable/11/sbin/camcontrol/camcontrol.8 Thu Aug 8 22:11:01 2019 (r350803) @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 19, 2019 +.Dd July 22, 2019 .Dt CAMCONTROL 8 .Os .Sh NAME @@ -185,7 +185,7 @@ .Op Fl X .Op Fl c .Op Fl p -.Aq all|off|bus Ns Op :target Ns Op :lun +.Aq all | off | device id | bus Ns Op :target Ns Op :lun .Nm .Ic tags .Op device id Modified: stable/11/sbin/camcontrol/camcontrol.c ============================================================================== --- stable/11/sbin/camcontrol/camcontrol.c Thu Aug 8 22:09:32 2019 (r350802) +++ stable/11/sbin/camcontrol/camcontrol.c Thu Aug 8 22:11:01 2019 (r350803) @@ -3376,6 +3376,66 @@ atasecurity(struct cam_device *device, int retry_count #endif /* MINIMALISTIC */ /* + * Convert periph name into a bus, target and lun. + * + * Returns the number of parsed components, or 0. + */ +static int +parse_btl_name(char *tstr, path_id_t *bus, target_id_t *target, lun_id_t *lun, + cam_argmask *arglst) +{ + int fd; + union ccb ccb; + + bzero(&ccb, sizeof(ccb)); + ccb.ccb_h.func_code = XPT_GDEVLIST; + if (cam_get_device(tstr, ccb.cgdl.periph_name, + sizeof(ccb.cgdl.periph_name), &ccb.cgdl.unit_number) == -1) { + warnx("%s", cam_errbuf); + return (0); + } + + /* + * Attempt to get the passthrough device. This ioctl will + * fail if the device name is null, if the device doesn't + * exist, or if the passthrough driver isn't in the kernel. + */ + if ((fd = open(XPT_DEVICE, O_RDWR)) == -1) { + warn("Unable to open %s", XPT_DEVICE); + return (0); + } + if (ioctl(fd, CAMGETPASSTHRU, &ccb) == -1) { + warn("Unable to find bus:target:lun for device %s%d", + ccb.cgdl.periph_name, ccb.cgdl.unit_number); + close(fd); + return (0); + } + close(fd); + if ((ccb.ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { + const struct cam_status_entry *entry; + + entry = cam_fetch_status_entry(ccb.ccb_h.status); + warnx("Unable to find bus:target_lun for device %s%d, " + "CAM status: %s (%#x)", + ccb.cgdl.periph_name, ccb.cgdl.unit_number, + entry ? entry->status_text : "Unknown", + ccb.ccb_h.status); + return (0); + } + + /* + * The kernel fills in the bus/target/lun. We don't + * need the passthrough device name and unit number since + * we aren't going to open it. + */ + *bus = ccb.ccb_h.path_id; + *target = ccb.ccb_h.target_id; + *lun = ccb.ccb_h.target_lun; + *arglst |= CAM_ARG_BUS | CAM_ARG_TARGET | CAM_ARG_LUN; + return (3); +} + +/* * Parse out a bus, or a bus, target and lun in the following * format: * bus @@ -3388,25 +3448,43 @@ static int parse_btl(char *tstr, path_id_t *bus, target_id_t *target, lun_id_t *lun, cam_argmask *arglst) { - char *tmpstr; + char *tmpstr, *end; int convs = 0; + *bus = CAM_BUS_WILDCARD; + *target = CAM_TARGET_WILDCARD; + *lun = CAM_LUN_WILDCARD; + while (isspace(*tstr) && (*tstr != '\0')) tstr++; - tmpstr = (char *)strtok(tstr, ":"); + if (strncasecmp(tstr, "all", strlen("all")) == 0) { + arglist |= CAM_ARG_BUS; + return (1); + } + + if (!isdigit(*tstr)) + return (parse_btl_name(tstr, bus, target, lun, arglst)); + + tmpstr = strsep(&tstr, ":"); if ((tmpstr != NULL) && (*tmpstr != '\0')) { - *bus = strtol(tmpstr, NULL, 0); + *bus = strtol(tmpstr, &end, 0); + if (*end != '\0') + return (0); *arglst |= CAM_ARG_BUS; convs++; - tmpstr = (char *)strtok(NULL, ":"); + tmpstr = strsep(&tstr, ":"); if ((tmpstr != NULL) && (*tmpstr != '\0')) { - *target = strtol(tmpstr, NULL, 0); + *target = strtol(tmpstr, &end, 0); + if (*end != '\0') + return (0); *arglst |= CAM_ARG_TARGET; convs++; - tmpstr = (char *)strtok(NULL, ":"); + tmpstr = strsep(&tstr, ":"); if ((tmpstr != NULL) && (*tmpstr != '\0')) { - *lun = strtol(tmpstr, NULL, 0); + *lun = strtoll(tmpstr, &end, 0); + if (*end != '\0') + return (0); *arglst |= CAM_ARG_LUN; convs++; } @@ -3420,7 +3498,7 @@ static int dorescan_or_reset(int argc, char **argv, int rescan) { static const char must[] = - "you must specify \"all\", a bus, or a bus:target:lun to %s"; + "you must specify \"all\", a bus, a bus:target:lun or periph to %s"; int rv, error = 0; path_id_t bus = CAM_BUS_WILDCARD; target_id_t target = CAM_TARGET_WILDCARD; @@ -3437,118 +3515,19 @@ dorescan_or_reset(int argc, char **argv, int rescan) tstr++; if (strncasecmp(tstr, "all", strlen("all")) == 0) arglist |= CAM_ARG_BUS; - else if (isdigit(*tstr)) { + else { rv = parse_btl(argv[optind], &bus, &target, &lun, &arglist); if (rv != 1 && rv != 3) { - warnx(must, rescan? "rescan" : "reset"); + warnx(must, rescan ? "rescan" : "reset"); return (1); } - } else { - char name[30]; - int unit; - int fd = -1; - union ccb ccb; - - /* - * Note that resetting or rescanning a device used to - * require a bus or bus:target:lun. This is because the - * device in question may not exist and you're trying to - * get the controller to rescan to find it. It may also be - * because the device is hung / unresponsive, and opening - * an unresponsive device is not desireable. - * - * It can be more convenient to reference a device by - * peripheral name and unit number, though, and it is - * possible to get the bus:target:lun for devices that - * currently exist in the EDT. So this can work for - * devices that we want to reset, or devices that exist - * that we want to rescan, but not devices that do not - * exist yet. - * - * So, we are careful here to look up the bus/target/lun - * for the device the user wants to operate on, specified - * by peripheral instance (e.g. da0, pass32) without - * actually opening that device. The process is similar to - * what cam_lookup_pass() does, except that we don't - * actually open the passthrough driver instance in the end. - */ - - if (cam_get_device(tstr, name, sizeof(name), &unit) == -1) { - warnx("%s", cam_errbuf); - error = 1; - goto bailout; - } - - if ((fd = open(XPT_DEVICE, O_RDWR)) == -1) { - warn("Unable to open %s", XPT_DEVICE); - error = 1; - goto bailout; - } - - bzero(&ccb, sizeof(ccb)); - - /* - * The function code isn't strictly necessary for the - * GETPASSTHRU ioctl. - */ - ccb.ccb_h.func_code = XPT_GDEVLIST; - - /* - * These two are necessary for the GETPASSTHRU ioctl to - * work. - */ - strlcpy(ccb.cgdl.periph_name, name, - sizeof(ccb.cgdl.periph_name)); - ccb.cgdl.unit_number = unit; - - /* - * Attempt to get the passthrough device. This ioctl will - * fail if the device name is null, if the device doesn't - * exist, or if the passthrough driver isn't in the kernel. - */ - if (ioctl(fd, CAMGETPASSTHRU, &ccb) == -1) { - warn("Unable to find bus:target:lun for device %s%d", - name, unit); - error = 1; - close(fd); - goto bailout; - } - if ((ccb.ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { - const struct cam_status_entry *entry; - - entry = cam_fetch_status_entry(ccb.ccb_h.status); - warnx("Unable to find bus:target_lun for device %s%d, " - "CAM status: %s (%#x)", name, unit, - entry ? entry->status_text : "Unknown", - ccb.ccb_h.status); - error = 1; - close(fd); - goto bailout; - } - - /* - * The kernel fills in the bus/target/lun. We don't - * need the passthrough device name and unit number since - * we aren't going to open it. - */ - bus = ccb.ccb_h.path_id; - target = ccb.ccb_h.target_id; - lun = ccb.ccb_h.target_lun; - - arglist |= CAM_ARG_BUS | CAM_ARG_TARGET | CAM_ARG_LUN; - - close(fd); } - if ((arglist & CAM_ARG_BUS) - && (arglist & CAM_ARG_TARGET) - && (arglist & CAM_ARG_LUN)) + if (arglist & CAM_ARG_LUN) error = scanlun_or_reset_dev(bus, target, lun, rescan); else error = rescan_or_reset_bus(bus, rescan); -bailout: - return (error); } @@ -4935,9 +4914,9 @@ camdebug(int argc, char **argv, char *combinedopt) path_id_t bus = CAM_BUS_WILDCARD; target_id_t target = CAM_TARGET_WILDCARD; lun_id_t lun = CAM_LUN_WILDCARD; - char *tstr, *tmpstr = NULL; + char *tstr; union ccb ccb; - int error = 0; + int error = 0, rv; bzero(&ccb, sizeof(union ccb)); @@ -4976,23 +4955,16 @@ camdebug(int argc, char **argv, char *combinedopt) } } - if ((fd = open(XPT_DEVICE, O_RDWR)) < 0) { - warnx("error opening transport layer device %s", XPT_DEVICE); - warn("%s", XPT_DEVICE); - return (1); - } argc -= optind; argv += optind; if (argc <= 0) { warnx("you must specify \"off\", \"all\" or a bus,"); - warnx("bus:target, or bus:target:lun"); - close(fd); + warnx("bus:target, bus:target:lun or periph"); return (1); } tstr = *argv; - while (isspace(*tstr) && (*tstr != '\0')) tstr++; @@ -5001,66 +4973,54 @@ camdebug(int argc, char **argv, char *combinedopt) arglist &= ~(CAM_ARG_DEBUG_INFO|CAM_ARG_DEBUG_PERIPH| CAM_ARG_DEBUG_TRACE|CAM_ARG_DEBUG_SUBTRACE| CAM_ARG_DEBUG_XPT|CAM_ARG_DEBUG_PROBE); - } else if (strncmp(tstr, "all", 3) != 0) { - tmpstr = (char *)strtok(tstr, ":"); - if ((tmpstr != NULL) && (*tmpstr != '\0')){ - bus = strtol(tmpstr, NULL, 0); - arglist |= CAM_ARG_BUS; - tmpstr = (char *)strtok(NULL, ":"); - if ((tmpstr != NULL) && (*tmpstr != '\0')){ - target = strtol(tmpstr, NULL, 0); - arglist |= CAM_ARG_TARGET; - tmpstr = (char *)strtok(NULL, ":"); - if ((tmpstr != NULL) && (*tmpstr != '\0')){ - lun = strtol(tmpstr, NULL, 0); - arglist |= CAM_ARG_LUN; - } - } - } else { - error = 1; + } else { + rv = parse_btl(tstr, &bus, &target, &lun, &arglist); + if (rv < 1) { warnx("you must specify \"all\", \"off\", or a bus,"); - warnx("bus:target, or bus:target:lun to debug"); + warnx("bus:target, bus:target:lun or periph to debug"); + return (1); } } - if (error == 0) { + if ((fd = open(XPT_DEVICE, O_RDWR)) < 0) { + warnx("error opening transport layer device %s", XPT_DEVICE); + warn("%s", XPT_DEVICE); + return (1); + } - ccb.ccb_h.func_code = XPT_DEBUG; - ccb.ccb_h.path_id = bus; - ccb.ccb_h.target_id = target; - ccb.ccb_h.target_lun = lun; + ccb.ccb_h.func_code = XPT_DEBUG; + ccb.ccb_h.path_id = bus; + ccb.ccb_h.target_id = target; + ccb.ccb_h.target_lun = lun; - if (ioctl(fd, CAMIOCOMMAND, &ccb) == -1) { - warn("CAMIOCOMMAND ioctl failed"); + if (ioctl(fd, CAMIOCOMMAND, &ccb) == -1) { + warn("CAMIOCOMMAND ioctl failed"); + error = 1; + } else { + if ((ccb.ccb_h.status & CAM_STATUS_MASK) == + CAM_FUNC_NOTAVAIL) { + warnx("CAM debugging not available"); + warnx("you need to put options CAMDEBUG in" + " your kernel config file!"); error = 1; - } - - if (error == 0) { - if ((ccb.ccb_h.status & CAM_STATUS_MASK) == - CAM_FUNC_NOTAVAIL) { - warnx("CAM debugging not available"); - warnx("you need to put options CAMDEBUG in" - " your kernel config file!"); - error = 1; - } else if ((ccb.ccb_h.status & CAM_STATUS_MASK) != - CAM_REQ_CMP) { - warnx("XPT_DEBUG CCB failed with status %#x", - ccb.ccb_h.status); - error = 1; + } else if ((ccb.ccb_h.status & CAM_STATUS_MASK) != + CAM_REQ_CMP) { + warnx("XPT_DEBUG CCB failed with status %#x", + ccb.ccb_h.status); + error = 1; + } else { + if (ccb.cdbg.flags == CAM_DEBUG_NONE) { + fprintf(stderr, + "Debugging turned off\n"); } else { - if (ccb.cdbg.flags == CAM_DEBUG_NONE) { - fprintf(stderr, - "Debugging turned off\n"); - } else { - fprintf(stderr, - "Debugging enabled for " - "%d:%d:%jx\n", - bus, target, (uintmax_t)lun); - } + fprintf(stderr, + "Debugging enabled for " + "%d:%d:%jx\n", + bus, target, (uintmax_t)lun); } } - close(fd); } + close(fd); return (error); } @@ -9429,7 +9389,7 @@ usage(int printlong) " camcontrol smpphylist [dev_id][generic args][-l][-q]\n" " camcontrol smpmaninfo [dev_id][generic args][-l]\n" " camcontrol debug [-I][-P][-T][-S][-X][-c]\n" -" \n" +" \n" " camcontrol tags [dev_id][generic args] [-N tags] [-q] [-v]\n" " camcontrol negotiate [dev_id][generic args] [-a][-c]\n" " [-D ][-M mode][-O offset]\n" From owner-svn-src-stable-11@freebsd.org Thu Aug 8 22:16:24 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 47026B548A; Thu, 8 Aug 2019 22:16:24 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 464N4m1sf7z3G18; Thu, 8 Aug 2019 22:16:24 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 06EFE4085; Thu, 8 Aug 2019 22:16:24 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x78MGO79048031; Thu, 8 Aug 2019 22:16:24 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x78MGKAk048013; Thu, 8 Aug 2019 22:16:20 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201908082216.x78MGKAk048013@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 8 Aug 2019 22:16:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r350804 - in stable/11/sys: cam cam/ata cam/nvme cam/scsi dev/hyperv/storvsc X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: in stable/11/sys: cam cam/ata cam/nvme cam/scsi dev/hyperv/storvsc X-SVN-Commit-Revision: 350804 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Aug 2019 22:16:24 -0000 Author: mav Date: Thu Aug 8 22:16:19 2019 New Revision: 350804 URL: https://svnweb.freebsd.org/changeset/base/350804 Log: MFC r326645 (by imp): Define xpt_path_inq. This provides a nice wrarpper around the XPT_PATH_INQ ccb creation and calling. Modified: stable/11/sys/cam/ata/ata_da.c stable/11/sys/cam/ata/ata_xpt.c stable/11/sys/cam/cam_periph.c stable/11/sys/cam/cam_xpt.c stable/11/sys/cam/cam_xpt.h stable/11/sys/cam/nvme/nvme_da.c stable/11/sys/cam/nvme/nvme_xpt.c stable/11/sys/cam/scsi/scsi_cd.c stable/11/sys/cam/scsi/scsi_ch.c stable/11/sys/cam/scsi/scsi_da.c stable/11/sys/cam/scsi/scsi_pass.c stable/11/sys/cam/scsi/scsi_pt.c stable/11/sys/cam/scsi/scsi_sa.c stable/11/sys/cam/scsi/scsi_sg.c stable/11/sys/cam/scsi/scsi_target.c stable/11/sys/cam/scsi/scsi_xpt.c stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cam/ata/ata_da.c ============================================================================== --- stable/11/sys/cam/ata/ata_da.c Thu Aug 8 22:11:01 2019 (r350803) +++ stable/11/sys/cam/ata/ata_da.c Thu Aug 8 22:16:19 2019 (r350804) @@ -1751,10 +1751,7 @@ adaregister(struct cam_periph *periph, void *arg) else softc->quirks = ADA_Q_NONE; - bzero(&cpi, sizeof(cpi)); - xpt_setup_ccb(&cpi.ccb_h, periph->path, CAM_PRIORITY_NONE); - cpi.ccb_h.func_code = XPT_PATH_INQ; - xpt_action((union ccb *)&cpi); + xpt_path_inq(&cpi, periph->path); TASK_INIT(&softc->sysctl_task, 0, adasysctlinit, periph); Modified: stable/11/sys/cam/ata/ata_xpt.c ============================================================================== --- stable/11/sys/cam/ata/ata_xpt.c Thu Aug 8 22:11:01 2019 (r350803) +++ stable/11/sys/cam/ata/ata_xpt.c Thu Aug 8 22:16:19 2019 (r350804) @@ -994,10 +994,7 @@ noerror: if (path->device->mintags != 0 && path->bus->sim->max_tagged_dev_openings != 0) { /* Check if the SIM does not want queued commands. */ - bzero(&cpi, sizeof(cpi)); - xpt_setup_ccb(&cpi.ccb_h, path, CAM_PRIORITY_NONE); - cpi.ccb_h.func_code = XPT_PATH_INQ; - xpt_action((union ccb *)&cpi); + xpt_path_inq(&cpi, path); if (cpi.ccb_h.status == CAM_REQ_CMP && (cpi.hba_inquiry & PI_TAG_ABLE)) { /* Report SIM which tags are allowed. */ @@ -1400,10 +1397,7 @@ ata_scan_bus(struct cam_periph *periph, union ccb *req xpt_done(request_ccb); return; } - xpt_setup_ccb(&work_ccb->ccb_h, request_ccb->ccb_h.path, - request_ccb->ccb_h.pinfo.priority); - work_ccb->ccb_h.func_code = XPT_PATH_INQ; - xpt_action(work_ccb); + xpt_path_inq(&work_ccb->cpi, request_ccb->ccb_h.path); if (work_ccb->ccb_h.status != CAM_REQ_CMP) { request_ccb->ccb_h.status = work_ccb->ccb_h.status; xpt_free_ccb(work_ccb); @@ -1558,10 +1552,7 @@ ata_scan_lun(struct cam_periph *periph, struct cam_pat CAM_DEBUG(path, CAM_DEBUG_TRACE, ("xpt_scan_lun\n")); - xpt_setup_ccb(&cpi.ccb_h, path, CAM_PRIORITY_NONE); - cpi.ccb_h.func_code = XPT_PATH_INQ; - xpt_action((union ccb *)&cpi); - + xpt_path_inq(&cpi, path); if (cpi.ccb_h.status != CAM_REQ_CMP) { if (request_ccb != NULL) { request_ccb->ccb_h.status = cpi.ccb_h.status; @@ -1670,9 +1661,7 @@ ata_device_transport(struct cam_path *path) struct ata_params *ident_buf = NULL; /* Get transport information from the SIM */ - xpt_setup_ccb(&cpi.ccb_h, path, CAM_PRIORITY_NONE); - cpi.ccb_h.func_code = XPT_PATH_INQ; - xpt_action((union ccb *)&cpi); + xpt_path_inq(&cpi, path); path->device->transport = cpi.transport; if ((path->device->flags & CAM_DEV_INQUIRY_DATA_VALID) != 0) @@ -1967,9 +1956,7 @@ ata_set_transfer_settings(struct ccb_trans_settings *c scsi = &cts->proto_specific.scsi; else scsi = NULL; - xpt_setup_ccb(&cpi.ccb_h, path, CAM_PRIORITY_NONE); - cpi.ccb_h.func_code = XPT_PATH_INQ; - xpt_action((union ccb *)&cpi); + xpt_path_inq(&cpi, path); /* Sanity checking */ if ((cpi.hba_inquiry & PI_TAG_ABLE) == 0 @@ -2101,9 +2088,7 @@ ata_announce_periph(struct cam_periph *periph) if ((cts.ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) return; /* Ask the SIM for its base transfer speed */ - xpt_setup_ccb(&cpi.ccb_h, path, CAM_PRIORITY_NORMAL); - cpi.ccb_h.func_code = XPT_PATH_INQ; - xpt_action((union ccb *)&cpi); + xpt_path_inq(&cpi, path); /* Report connection speed */ speed = cpi.base_transfer_speed; if (cts.ccb_h.status == CAM_REQ_CMP && cts.transport == XPORT_ATA) { Modified: stable/11/sys/cam/cam_periph.c ============================================================================== --- stable/11/sys/cam/cam_periph.c Thu Aug 8 22:11:01 2019 (r350803) +++ stable/11/sys/cam/cam_periph.c Thu Aug 8 22:16:19 2019 (r350804) @@ -738,9 +738,7 @@ camperiphfree(struct cam_periph *periph) arg = &ccb; break; case AC_PATH_REGISTERED: - ccb.ccb_h.func_code = XPT_PATH_INQ; - xpt_setup_ccb(&ccb.ccb_h, periph->path, CAM_PRIORITY_NORMAL); - xpt_action(&ccb); + xpt_path_inq(&ccb.cpi, periph->path); arg = &ccb; break; default: Modified: stable/11/sys/cam/cam_xpt.c ============================================================================== --- stable/11/sys/cam/cam_xpt.c Thu Aug 8 22:11:01 2019 (r350803) +++ stable/11/sys/cam/cam_xpt.c Thu Aug 8 22:16:19 2019 (r350804) @@ -2491,9 +2491,7 @@ xptsetasyncbusfunc(struct cam_eb *bus, void *arg) CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD); xpt_path_lock(&path); - xpt_setup_ccb(&cpi.ccb_h, &path, CAM_PRIORITY_NORMAL); - cpi.ccb_h.func_code = XPT_PATH_INQ; - xpt_action((union ccb *)&cpi); + xpt_path_inq(&cpi, &path); csa->callback(csa->callback_arg, AC_PATH_REGISTERED, &path, &cpi); @@ -3937,9 +3935,7 @@ xpt_bus_register(struct cam_sim *sim, device_t parent, return (CAM_RESRC_UNAVAIL); } - xpt_setup_ccb(&cpi.ccb_h, path, CAM_PRIORITY_NORMAL); - cpi.ccb_h.func_code = XPT_PATH_INQ; - xpt_action((union ccb *)&cpi); + xpt_path_inq(&cpi, path); if (cpi.ccb_h.status == CAM_REQ_CMP) { struct xpt_xport **xpt; Modified: stable/11/sys/cam/cam_xpt.h ============================================================================== --- stable/11/sys/cam/cam_xpt.h Thu Aug 8 22:11:01 2019 (r350803) +++ stable/11/sys/cam/cam_xpt.h Thu Aug 8 22:16:19 2019 (r350804) @@ -32,6 +32,12 @@ #ifndef _CAM_CAM_XPT_H #define _CAM_CAM_XPT_H 1 +#ifdef _KERNEL +#include +#include +#endif + + /* Forward Declarations */ union ccb; struct cam_periph; @@ -134,6 +140,20 @@ void xpt_copy_path(struct cam_path *new_path, struct cam_path *path); void xpt_release_path(struct cam_path *path); + +/* + * Perform a path inquiry at the request priority. The bzero may be + * unnecessary. + */ +static inline void +xpt_path_inq(struct ccb_pathinq *cpi, struct cam_path *path) +{ + + bzero(cpi, sizeof(*cpi)); + xpt_setup_ccb(&cpi->ccb_h, path, CAM_PRIORITY_NORMAL); + cpi->ccb_h.func_code = XPT_PATH_INQ; + xpt_action((union ccb *)cpi); +} #endif /* _KERNEL */ Modified: stable/11/sys/cam/nvme/nvme_da.c ============================================================================== --- stable/11/sys/cam/nvme/nvme_da.c Thu Aug 8 22:11:01 2019 (r350803) +++ stable/11/sys/cam/nvme/nvme_da.c Thu Aug 8 22:16:19 2019 (r350804) @@ -716,10 +716,7 @@ ndaregister(struct cam_periph *periph, void *arg) softc->quirks = NDA_Q_NONE; - bzero(&cpi, sizeof(cpi)); - xpt_setup_ccb(&cpi.ccb_h, periph->path, CAM_PRIORITY_NONE); - cpi.ccb_h.func_code = XPT_PATH_INQ; - xpt_action((union ccb *)&cpi); + xpt_path_inq(&cpi, periph->path); TASK_INIT(&softc->sysctl_task, 0, ndasysctlinit, periph); Modified: stable/11/sys/cam/nvme/nvme_xpt.c ============================================================================== --- stable/11/sys/cam/nvme/nvme_xpt.c Thu Aug 8 22:11:01 2019 (r350803) +++ stable/11/sys/cam/nvme/nvme_xpt.c Thu Aug 8 22:16:19 2019 (r350804) @@ -364,9 +364,7 @@ nvme_scan_lun(struct cam_periph *periph, struct cam_pa CAM_DEBUG(path, CAM_DEBUG_TRACE, ("nvme_scan_lun\n")); - xpt_setup_ccb(&cpi.ccb_h, path, CAM_PRIORITY_NONE); - cpi.ccb_h.func_code = XPT_PATH_INQ; - xpt_action((union ccb *)&cpi); + xpt_path_inq(&cpi, path); if (cpi.ccb_h.status != CAM_REQ_CMP) { if (request_ccb != NULL) { @@ -457,9 +455,7 @@ nvme_device_transport(struct cam_path *path) /* XXX get data from nvme namespace and other info ??? */ /* Get transport information from the SIM */ - xpt_setup_ccb(&cpi.ccb_h, path, CAM_PRIORITY_NONE); - cpi.ccb_h.func_code = XPT_PATH_INQ; - xpt_action((union ccb *)&cpi); + xpt_path_inq(&cpi, path); path->device->transport = cpi.transport; path->device->transport_version = cpi.transport_version; @@ -628,9 +624,7 @@ nvme_announce_periph(struct cam_periph *periph) if ((cts.ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) return; /* Ask the SIM for its base transfer speed */ - xpt_setup_ccb(&cpi.ccb_h, path, CAM_PRIORITY_NORMAL); - cpi.ccb_h.func_code = XPT_PATH_INQ; - xpt_action((union ccb *)&cpi); + xpt_path_inq(&cpi, periph->path); /* XXX NVME STUFF HERE */ printf("\n"); } Modified: stable/11/sys/cam/scsi/scsi_cd.c ============================================================================== --- stable/11/sys/cam/scsi/scsi_cd.c Thu Aug 8 22:11:01 2019 (r350803) +++ stable/11/sys/cam/scsi/scsi_cd.c Thu Aug 8 22:16:19 2019 (r350804) @@ -587,10 +587,7 @@ cdregister(struct cam_periph *periph, void *arg) softc->quirks = CD_Q_NONE; /* Check if the SIM does not want 6 byte commands */ - bzero(&cpi, sizeof(cpi)); - xpt_setup_ccb(&cpi.ccb_h, periph->path, CAM_PRIORITY_NORMAL); - cpi.ccb_h.func_code = XPT_PATH_INQ; - xpt_action((union ccb *)&cpi); + xpt_path_inq(&cpi, periph->path); if (cpi.ccb_h.status == CAM_REQ_CMP && (cpi.hba_misc & PIM_NO_6_BYTE)) softc->quirks |= CD_Q_10_BYTE_ONLY; Modified: stable/11/sys/cam/scsi/scsi_ch.c ============================================================================== --- stable/11/sys/cam/scsi/scsi_ch.c Thu Aug 8 22:11:01 2019 (r350803) +++ stable/11/sys/cam/scsi/scsi_ch.c Thu Aug 8 22:16:19 2019 (r350804) @@ -402,10 +402,7 @@ chregister(struct cam_periph *periph, void *arg) if (cgd->inq_data.version <= SCSI_REV_2) softc->quirks |= CH_Q_NO_DVCID; - bzero(&cpi, sizeof(cpi)); - xpt_setup_ccb(&cpi.ccb_h, periph->path, CAM_PRIORITY_NORMAL); - cpi.ccb_h.func_code = XPT_PATH_INQ; - xpt_action((union ccb *)&cpi); + xpt_path_inq(&cpi, periph->path); /* * Changers don't have a blocksize, and obviously don't support Modified: stable/11/sys/cam/scsi/scsi_da.c ============================================================================== --- stable/11/sys/cam/scsi/scsi_da.c Thu Aug 8 22:11:01 2019 (r350803) +++ stable/11/sys/cam/scsi/scsi_da.c Thu Aug 8 22:16:19 2019 (r350804) @@ -2517,10 +2517,7 @@ daregister(struct cam_periph *periph, void *arg) softc->quirks = DA_Q_NONE; /* Check if the SIM does not want 6 byte commands */ - bzero(&cpi, sizeof(cpi)); - xpt_setup_ccb(&cpi.ccb_h, periph->path, CAM_PRIORITY_NORMAL); - cpi.ccb_h.func_code = XPT_PATH_INQ; - xpt_action((union ccb *)&cpi); + xpt_path_inq(&cpi, periph->path); if (cpi.ccb_h.status == CAM_REQ_CMP && (cpi.hba_misc & PIM_NO_6_BYTE)) softc->quirks |= DA_Q_NO_6_BYTE; Modified: stable/11/sys/cam/scsi/scsi_pass.c ============================================================================== --- stable/11/sys/cam/scsi/scsi_pass.c Thu Aug 8 22:11:01 2019 (r350803) +++ stable/11/sys/cam/scsi/scsi_pass.c Thu Aug 8 22:16:19 2019 (r350804) @@ -589,10 +589,7 @@ passregister(struct cam_periph *periph, void *arg) softc->io_zone_size = MAXPHYS; knlist_init_mtx(&softc->read_select.si_note, cam_periph_mtx(periph)); - bzero(&cpi, sizeof(cpi)); - xpt_setup_ccb(&cpi.ccb_h, periph->path, CAM_PRIORITY_NORMAL); - cpi.ccb_h.func_code = XPT_PATH_INQ; - xpt_action((union ccb *)&cpi); + xpt_path_inq(&cpi, periph->path); if (cpi.maxio == 0) softc->maxio = DFLTPHYS; /* traditional default */ Modified: stable/11/sys/cam/scsi/scsi_pt.c ============================================================================== --- stable/11/sys/cam/scsi/scsi_pt.c Thu Aug 8 22:11:01 2019 (r350803) +++ stable/11/sys/cam/scsi/scsi_pt.c Thu Aug 8 22:16:19 2019 (r350804) @@ -275,10 +275,7 @@ ptctor(struct cam_periph *periph, void *arg) periph->softc = softc; - bzero(&cpi, sizeof(cpi)); - xpt_setup_ccb(&cpi.ccb_h, periph->path, CAM_PRIORITY_NORMAL); - cpi.ccb_h.func_code = XPT_PATH_INQ; - xpt_action((union ccb *)&cpi); + xpt_path_inq(&cpi, periph->path); cam_periph_unlock(periph); Modified: stable/11/sys/cam/scsi/scsi_sa.c ============================================================================== --- stable/11/sys/cam/scsi/scsi_sa.c Thu Aug 8 22:11:01 2019 (r350803) +++ stable/11/sys/cam/scsi/scsi_sa.c Thu Aug 8 22:16:19 2019 (r350804) @@ -2425,10 +2425,7 @@ saregister(struct cam_periph *periph, void *arg) softc->flags |= SA_FLAG_PROTECT_SUPP; } - bzero(&cpi, sizeof(cpi)); - xpt_setup_ccb(&cpi.ccb_h, periph->path, CAM_PRIORITY_NORMAL); - cpi.ccb_h.func_code = XPT_PATH_INQ; - xpt_action((union ccb *)&cpi); + xpt_path_inq(&cpi, periph->path); /* * The SA driver supports a blocksize, but we don't know the Modified: stable/11/sys/cam/scsi/scsi_sg.c ============================================================================== --- stable/11/sys/cam/scsi/scsi_sg.c Thu Aug 8 22:11:01 2019 (r350803) +++ stable/11/sys/cam/scsi/scsi_sg.c Thu Aug 8 22:16:19 2019 (r350804) @@ -322,10 +322,7 @@ sgregister(struct cam_periph *periph, void *arg) TAILQ_INIT(&softc->rdwr_done); periph->softc = softc; - bzero(&cpi, sizeof(cpi)); - xpt_setup_ccb(&cpi.ccb_h, periph->path, CAM_PRIORITY_NORMAL); - cpi.ccb_h.func_code = XPT_PATH_INQ; - xpt_action((union ccb *)&cpi); + xpt_path_inq(&cpi, periph->path); if (cpi.maxio == 0) softc->maxio = DFLTPHYS; /* traditional default */ Modified: stable/11/sys/cam/scsi/scsi_target.c ============================================================================== --- stable/11/sys/cam/scsi/scsi_target.c Thu Aug 8 22:11:01 2019 (r350803) +++ stable/11/sys/cam/scsi/scsi_target.c Thu Aug 8 22:16:19 2019 (r350804) @@ -391,9 +391,7 @@ targenable(struct targ_softc *softc, struct cam_path * return (CAM_LUN_ALRDY_ENA); /* Make sure SIM supports target mode */ - xpt_setup_ccb(&cpi.ccb_h, path, CAM_PRIORITY_NORMAL); - cpi.ccb_h.func_code = XPT_PATH_INQ; - xpt_action((union ccb *)&cpi); + xpt_path_inq(&cpi, path); status = cpi.ccb_h.status & CAM_STATUS_MASK; if (status != CAM_REQ_CMP) { printf("pathinq failed, status %#x\n", status); Modified: stable/11/sys/cam/scsi/scsi_xpt.c ============================================================================== --- stable/11/sys/cam/scsi/scsi_xpt.c Thu Aug 8 22:11:01 2019 (r350803) +++ stable/11/sys/cam/scsi/scsi_xpt.c Thu Aug 8 22:16:19 2019 (r350804) @@ -697,9 +697,7 @@ probeschedule(struct cam_periph *periph) softc = (probe_softc *)periph->softc; ccb = (union ccb *)TAILQ_FIRST(&softc->request_ccbs); - xpt_setup_ccb(&cpi.ccb_h, periph->path, CAM_PRIORITY_NONE); - cpi.ccb_h.func_code = XPT_PATH_INQ; - xpt_action((union ccb *)&cpi); + xpt_path_inq(&cpi, periph->path); /* * If a device has gone away and another device, or the same one, Modified: stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c ============================================================================== --- stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Thu Aug 8 22:11:01 2019 (r350803) +++ stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Thu Aug 8 22:16:19 2019 (r350804) @@ -2350,10 +2350,7 @@ storvsc_ada_probe_veto(void *arg __unused, struct cam_ if (path->device->protocol == PROTO_ATA) { struct ccb_pathinq cpi; - bzero(&cpi, sizeof(cpi)); - xpt_setup_ccb(&cpi.ccb_h, path, CAM_PRIORITY_NONE); - cpi.ccb_h.func_code = XPT_PATH_INQ; - xpt_action((union ccb *)&cpi); + xpt_path_inq(&cpi, path); if (cpi.ccb_h.status == CAM_REQ_CMP && cpi.hba_vendor == PCI_VENDOR_INTEL && cpi.hba_device == PCI_PRODUCT_PIIX4) { From owner-svn-src-stable-11@freebsd.org Thu Aug 8 22:17:42 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1AC6EB5528; Thu, 8 Aug 2019 22:17:42 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 464N6F6PD8z3G8t; Thu, 8 Aug 2019 22:17:41 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BCE194091; Thu, 8 Aug 2019 22:17:41 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x78MHfwl048144; Thu, 8 Aug 2019 22:17:41 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x78MHfij048142; Thu, 8 Aug 2019 22:17:41 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201908082217.x78MHfij048142@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 8 Aug 2019 22:17:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r350805 - stable/11/sys/cam/ata X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/cam/ata X-SVN-Commit-Revision: 350805 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Aug 2019 22:17:42 -0000 Author: mav Date: Thu Aug 8 22:17:41 2019 New Revision: 350805 URL: https://svnweb.freebsd.org/changeset/base/350805 Log: MFC r350233: Make CAM ATA stack handle disk resizes. While for ATA disks resize is even more rare situation than for SCSI, it may happen in case of HPA or AMA being used. Make ATA XPT report minor IDENTIFY DATA change to upper layers with AC_GETDEV_CHANGED, and ada(4) periph driver handle that event, recalculating all the disk properties and signalling resize to GEOM. Since ATA has no mechanism of UNIT ATTENTIONs, like SCSI, it has no way to detect that something has changed. That is why this functionality depends on explicit reprobe via XPT_REPROBE_LUN call. Relnotes: yes Modified: stable/11/sys/cam/ata/ata_da.c stable/11/sys/cam/ata/ata_xpt.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cam/ata/ata_da.c ============================================================================== --- stable/11/sys/cam/ata/ata_da.c Thu Aug 8 22:16:19 2019 (r350804) +++ stable/11/sys/cam/ata/ata_da.c Thu Aug 8 22:17:41 2019 (r350805) @@ -246,8 +246,9 @@ struct ada_softc { int periodic_read_error; int periodic_read_count; #endif - struct disk_params params; - struct disk *disk; + struct ccb_pathinq cpi; + struct disk_params params; + struct disk *disk; struct task sysctl_task; struct sysctl_ctx_list sysctl_ctx; struct sysctl_oid *sysctl_tree; @@ -798,6 +799,8 @@ static void adasysctlinit(void *context, int pending) static int adagetattr(struct bio *bp); static void adasetflags(struct ada_softc *softc, struct ccb_getdev *cgd); +static void adasetgeom(struct ada_softc *softc, + struct ccb_getdev *cgd); static periph_ctor_t adaregister; static void ada_dsmtrim(struct ada_softc *softc, struct bio *bp, struct ccb_ataio *ataio); @@ -813,8 +816,6 @@ static void adadone(struct cam_periph *periph, union ccb *done_ccb); static int adaerror(union ccb *ccb, u_int32_t cam_flags, u_int32_t sense_flags); -static void adagetparams(struct cam_periph *periph, - struct ccb_getdev *cgd); static timeout_t adasendorderedtag; static void adashutdown(void *arg, int howto); static void adasuspend(void *arg); @@ -1317,9 +1318,11 @@ adaasync(void *callback_arg, u_int32_t code, xpt_action((union ccb *)&cgd); /* - * Set/clear support flags based on the new Identify data. + * Update our information based on the new Identify data. */ adasetflags(softc, &cgd); + adasetgeom(softc, &cgd); + disk_resize(softc->disk, M_NOWAIT); cam_periph_async(periph, code, path, arg); break; @@ -1639,7 +1642,8 @@ adasetflags(struct ada_softc *softc, struct ccb_getdev softc->flags &= ~ADA_FLAG_CAN_NCQ; if ((cgd->ident_data.support_dsm & ATA_SUPPORT_DSM_TRIM) && - (cgd->inq_flags & SID_DMA)) { + (cgd->inq_flags & SID_DMA) && + (softc->quirks & ADA_Q_NO_TRIM) == 0) { softc->flags |= ADA_FLAG_CAN_TRIM; softc->trim_max_ranges = TRIM_MAX_RANGES; if (cgd->ident_data.max_dsm_blocks != 0) { @@ -1707,12 +1711,10 @@ static cam_status adaregister(struct cam_periph *periph, void *arg) { struct ada_softc *softc; - struct ccb_pathinq cpi; struct ccb_getdev *cgd; char announce_buf[80]; struct disk_params *dp; caddr_t match; - u_int maxio; int quirks; cgd = (struct ccb_getdev *)arg; @@ -1738,6 +1740,7 @@ adaregister(struct cam_periph *periph, void *arg) } periph->softc = softc; + xpt_path_inq(&softc->cpi, periph->path); /* * See if this device has any quirks. @@ -1751,8 +1754,6 @@ adaregister(struct cam_periph *periph, void *arg) else softc->quirks = ADA_Q_NONE; - xpt_path_inq(&cpi, periph->path); - TASK_INIT(&softc->sysctl_task, 0, adasysctlinit, periph); /* @@ -1778,6 +1779,8 @@ adaregister(struct cam_periph *periph, void *arg) * Set support flags based on the Identify data and quirks. */ adasetflags(softc, cgd); + if (softc->cpi.hba_misc & PIM_ATA_EXT) + softc->flags |= ADA_FLAG_PIM_ATA_EXT; /* Disable queue sorting for non-rotational media by default. */ if (cgd->ident_data.media_rotation_rate == ATA_RATE_NON_ROTATING) { @@ -1786,14 +1789,13 @@ adaregister(struct cam_periph *periph, void *arg) softc->rotating = 1; } cam_iosched_set_sort_queue(softc->cam_iosched, softc->rotating ? -1 : 0); - adagetparams(periph, cgd); softc->disk = disk_alloc(); - softc->disk->d_rotation_rate = cgd->ident_data.media_rotation_rate; + adasetgeom(softc, cgd); softc->disk->d_devstat = devstat_new_entry(periph->periph_name, periph->unit_number, softc->params.secsize, DEVSTAT_ALL_SUPPORTED, DEVSTAT_TYPE_DIRECT | - XPORT_DEVSTAT_TYPE(cpi.transport), + XPORT_DEVSTAT_TYPE(softc->cpi.transport), DEVSTAT_PRIORITY_DISK); softc->disk->d_open = adaopen; softc->disk->d_close = adaclose; @@ -1803,70 +1805,8 @@ adaregister(struct cam_periph *periph, void *arg) softc->disk->d_gone = adadiskgonecb; softc->disk->d_name = "ada"; softc->disk->d_drv1 = periph; - maxio = cpi.maxio; /* Honor max I/O size of SIM */ - if (maxio == 0) - maxio = DFLTPHYS; /* traditional default */ - else if (maxio > MAXPHYS) - maxio = MAXPHYS; /* for safety */ - if (softc->flags & ADA_FLAG_CAN_48BIT) - maxio = min(maxio, 65536 * softc->params.secsize); - else /* 28bit ATA command limit */ - maxio = min(maxio, 256 * softc->params.secsize); - if (softc->quirks & ADA_Q_128KB) - maxio = min(maxio, 128 * 1024); - softc->disk->d_maxsize = maxio; softc->disk->d_unit = periph->unit_number; - softc->disk->d_flags = DISKFLAG_DIRECT_COMPLETION | DISKFLAG_CANZONE; - if (softc->flags & ADA_FLAG_CAN_FLUSHCACHE) - softc->disk->d_flags |= DISKFLAG_CANFLUSHCACHE; - /* Device lies about TRIM capability. */ - if ((softc->quirks & ADA_Q_NO_TRIM) && - (softc->flags & ADA_FLAG_CAN_TRIM)) - softc->flags &= ~ADA_FLAG_CAN_TRIM; - if (softc->flags & ADA_FLAG_CAN_TRIM) { - softc->disk->d_flags |= DISKFLAG_CANDELETE; - softc->disk->d_delmaxsize = softc->params.secsize * - ATA_DSM_RANGE_MAX * - softc->trim_max_ranges; - } else if ((softc->flags & ADA_FLAG_CAN_CFA) && - !(softc->flags & ADA_FLAG_CAN_48BIT)) { - softc->disk->d_flags |= DISKFLAG_CANDELETE; - softc->disk->d_delmaxsize = 256 * softc->params.secsize; - } else - softc->disk->d_delmaxsize = maxio; - if ((cpi.hba_misc & PIM_UNMAPPED) != 0) { - softc->disk->d_flags |= DISKFLAG_UNMAPPED_BIO; - softc->unmappedio = 1; - } - if (cpi.hba_misc & PIM_ATA_EXT) - softc->flags |= ADA_FLAG_PIM_ATA_EXT; - strlcpy(softc->disk->d_descr, cgd->ident_data.model, - MIN(sizeof(softc->disk->d_descr), sizeof(cgd->ident_data.model))); - strlcpy(softc->disk->d_ident, cgd->ident_data.serial, - MIN(sizeof(softc->disk->d_ident), sizeof(cgd->ident_data.serial))); - softc->disk->d_hba_vendor = cpi.hba_vendor; - softc->disk->d_hba_device = cpi.hba_device; - softc->disk->d_hba_subvendor = cpi.hba_subvendor; - softc->disk->d_hba_subdevice = cpi.hba_subdevice; - softc->disk->d_sectorsize = softc->params.secsize; - softc->disk->d_mediasize = (off_t)softc->params.sectors * - softc->params.secsize; - if (ata_physical_sector_size(&cgd->ident_data) != - softc->params.secsize) { - softc->disk->d_stripesize = - ata_physical_sector_size(&cgd->ident_data); - softc->disk->d_stripeoffset = (softc->disk->d_stripesize - - ata_logical_sector_offset(&cgd->ident_data)) % - softc->disk->d_stripesize; - } else if (softc->quirks & ADA_Q_4K) { - softc->disk->d_stripesize = 4096; - softc->disk->d_stripeoffset = 0; - } - softc->disk->d_fwsectors = softc->params.secs_per_track; - softc->disk->d_fwheads = softc->params.heads; - ata_disk_firmware_geom_adjust(softc->disk); - /* * Acquire a reference to the periph before we register with GEOM. * We'll release this reference once GEOM calls us back (via @@ -3366,16 +3306,17 @@ adaerror(union ccb *ccb, u_int32_t cam_flags, u_int32_ } static void -adagetparams(struct cam_periph *periph, struct ccb_getdev *cgd) +adasetgeom(struct ada_softc *softc, struct ccb_getdev *cgd) { - struct ada_softc *softc = (struct ada_softc *)periph->softc; struct disk_params *dp = &softc->params; u_int64_t lbasize48; u_int32_t lbasize; + u_int maxio, d_flags; dp->secsize = ata_logical_sector_size(&cgd->ident_data); if ((cgd->ident_data.atavalid & ATA_FLAG_54_58) && - cgd->ident_data.current_heads && cgd->ident_data.current_sectors) { + cgd->ident_data.current_heads != 0 && + cgd->ident_data.current_sectors != 0) { dp->heads = cgd->ident_data.current_heads; dp->secs_per_track = cgd->ident_data.current_sectors; dp->cylinders = cgd->ident_data.cylinders; @@ -3403,6 +3344,60 @@ adagetparams(struct cam_periph *periph, struct ccb_get if ((cgd->ident_data.support.command2 & ATA_SUPPORT_ADDRESS48) && lbasize48 > ATA_MAX_28BIT_LBA) dp->sectors = lbasize48; + + maxio = softc->cpi.maxio; /* Honor max I/O size of SIM */ + if (maxio == 0) + maxio = DFLTPHYS; /* traditional default */ + else if (maxio > MAXPHYS) + maxio = MAXPHYS; /* for safety */ + if (softc->flags & ADA_FLAG_CAN_48BIT) + maxio = min(maxio, 65536 * softc->params.secsize); + else /* 28bit ATA command limit */ + maxio = min(maxio, 256 * softc->params.secsize); + if (softc->quirks & ADA_Q_128KB) + maxio = min(maxio, 128 * 1024); + softc->disk->d_maxsize = maxio; + d_flags = DISKFLAG_DIRECT_COMPLETION | DISKFLAG_CANZONE; + if (softc->flags & ADA_FLAG_CAN_FLUSHCACHE) + d_flags |= DISKFLAG_CANFLUSHCACHE; + if (softc->flags & ADA_FLAG_CAN_TRIM) { + d_flags |= DISKFLAG_CANDELETE; + softc->disk->d_delmaxsize = softc->params.secsize * + ATA_DSM_RANGE_MAX * softc->trim_max_ranges; + } else if ((softc->flags & ADA_FLAG_CAN_CFA) && + !(softc->flags & ADA_FLAG_CAN_48BIT)) { + d_flags |= DISKFLAG_CANDELETE; + softc->disk->d_delmaxsize = 256 * softc->params.secsize; + } else + softc->disk->d_delmaxsize = maxio; + if ((softc->cpi.hba_misc & PIM_UNMAPPED) != 0) { + d_flags |= DISKFLAG_UNMAPPED_BIO; + softc->unmappedio = 1; + } + softc->disk->d_flags = d_flags; + strlcpy(softc->disk->d_descr, cgd->ident_data.model, + MIN(sizeof(softc->disk->d_descr), sizeof(cgd->ident_data.model))); + strlcpy(softc->disk->d_ident, cgd->ident_data.serial, + MIN(sizeof(softc->disk->d_ident), sizeof(cgd->ident_data.serial))); + + softc->disk->d_sectorsize = softc->params.secsize; + softc->disk->d_mediasize = (off_t)softc->params.sectors * + softc->params.secsize; + if (ata_physical_sector_size(&cgd->ident_data) != + softc->params.secsize) { + softc->disk->d_stripesize = + ata_physical_sector_size(&cgd->ident_data); + softc->disk->d_stripeoffset = (softc->disk->d_stripesize - + ata_logical_sector_offset(&cgd->ident_data)) % + softc->disk->d_stripesize; + } else if (softc->quirks & ADA_Q_4K) { + softc->disk->d_stripesize = 4096; + softc->disk->d_stripeoffset = 0; + } + softc->disk->d_fwsectors = softc->params.secs_per_track; + softc->disk->d_fwheads = softc->params.heads; + ata_disk_firmware_geom_adjust(softc->disk); + softc->disk->d_rotation_rate = cgd->ident_data.media_rotation_rate; } static void Modified: stable/11/sys/cam/ata/ata_xpt.c ============================================================================== --- stable/11/sys/cam/ata/ata_xpt.c Thu Aug 8 22:16:19 2019 (r350804) +++ stable/11/sys/cam/ata/ata_xpt.c Thu Aug 8 22:17:41 2019 (r350805) @@ -332,6 +332,7 @@ probestart(struct cam_periph *periph, union ccb *start probe_softc *softc; struct cam_path *path; struct ata_params *ident_buf; + u_int oif; CAM_DEBUG(start_ccb->ccb_h.path, CAM_DEBUG_TRACE, ("probestart\n")); @@ -371,7 +372,7 @@ probestart(struct cam_periph *periph, union ccb *start /*data_ptr*/(u_int8_t *)&softc->ident_data, /*dxfer_len*/sizeof(softc->ident_data), 30 * 1000); - if (periph->path->device->protocol == PROTO_ATA) + if (path->device->protocol == PROTO_ATA) ata_28bit_cmd(ataio, ATA_ATA_IDENTIFY, 0, 0, 0); else ata_28bit_cmd(ataio, ATA_ATAPI_IDENTIFY, 0, 0, 0); @@ -407,7 +408,7 @@ probestart(struct cam_periph *periph, union ccb *start if (cts.xport_specific.sata.valid & CTS_SATA_VALID_MODE) mode = cts.xport_specific.sata.mode; } - if (periph->path->device->protocol == PROTO_ATA) { + if (path->device->protocol == PROTO_ATA) { if (ata_dma == 0 && (mode == 0 || mode > ATA_PIO_MAX)) mode = ATA_PIO_MAX; } else { @@ -447,11 +448,13 @@ negotiate: if (mode != wantmode) goto negotiate; /* Remember what transport thinks about DMA. */ + oif = path->device->inq_flags; if (mode < ATA_DMA) path->device->inq_flags &= ~SID_DMA; else path->device->inq_flags |= SID_DMA; - xpt_async(AC_GETDEV_CHANGED, path, NULL); + if (path->device->inq_flags != oif) + xpt_async(AC_GETDEV_CHANGED, path, NULL); cam_fill_ataio(ataio, 1, probedone, @@ -504,11 +507,13 @@ negotiate: break; case PROBE_SETAN: /* Remember what transport thinks about AEN. */ + oif = path->device->inq_flags; if (softc->caps & CTS_SATA_CAPS_H_AN) path->device->inq_flags |= SID_AEN; else path->device->inq_flags &= ~SID_AEN; - xpt_async(AC_GETDEV_CHANGED, path, NULL); + if (path->device->inq_flags != oif) + xpt_async(AC_GETDEV_CHANGED, path, NULL); cam_fill_ataio(ataio, 1, probedone, @@ -627,7 +632,7 @@ negotiate: { u_int inquiry_len; struct scsi_inquiry_data *inq_buf = - &periph->path->device->inq_data; + &path->device->inq_data; if (softc->action == PROBE_INQUIRY) inquiry_len = SHORT_INQUIRY_LENGTH; @@ -732,8 +737,8 @@ probedone(struct cam_periph *periph, union ccb *done_c struct cam_path *path; cam_status status; u_int32_t priority; - u_int caps; - int changed = 1, found = 1; + u_int caps, oif; + int changed, found = 1; static const uint8_t fake_device_id_hdr[8] = {0, SVPD_DEVICE_ID, 0, 12, SVPD_ID_CODESET_BINARY, SVPD_ID_TYPE_NAA, 0, 8}; @@ -928,23 +933,32 @@ noerror: goto out; } ident_buf = &path->device->ident_data; + + /* Check that it is the same device as we know. */ if ((periph->path->device->flags & CAM_DEV_UNCONFIGURED) == 0) { - /* Check that it is the same device. */ if (bcmp(softc->ident_data.model, ident_buf->model, sizeof(ident_buf->model)) || - bcmp(softc->ident_data.revision, ident_buf->revision, - sizeof(ident_buf->revision)) || bcmp(softc->ident_data.serial, ident_buf->serial, sizeof(ident_buf->serial))) { - /* Device changed. */ + /* The device was replaced. */ + changed = 2; xpt_async(AC_LOST_DEVICE, path, NULL); + } else if (bcmp(&softc->ident_data, ident_buf, + sizeof(*ident_buf))) { + /* The device is the same, but has changed. */ + changed = 1; } else { - bcopy(&softc->ident_data, ident_buf, sizeof(struct ata_params)); + /* Nothing has changed. */ changed = 0; } + } else { + /* This is a new device. */ + changed = 2; } - if (changed) { + + if (changed != 0) bcopy(&softc->ident_data, ident_buf, sizeof(struct ata_params)); + if (changed == 2) { /* Clean up from previous instance of this device */ if (path->device->serial_num != NULL) { free(path->device->serial_num, M_CAMXPT); @@ -981,10 +995,10 @@ noerror: ata_bswap(path->device->device_id + 8, 8); } } - path->device->flags |= CAM_DEV_IDENTIFY_DATA_VALID; - xpt_async(AC_GETDEV_CHANGED, path, NULL); } + if (changed == 1) + xpt_async(AC_GETDEV_CHANGED, path, NULL); if (ident_buf->satacapabilities & ATA_SUPPORT_NCQ) { path->device->mintags = 2; path->device->maxtags = @@ -1008,7 +1022,7 @@ noerror: } } ata_device_transport(path); - if (changed) + if (changed == 2) proberequestdefaultnegotiation(periph); PROBE_SET_ACTION(softc, PROBE_SETMODE); xpt_release_ccb(done_ccb); @@ -1064,6 +1078,7 @@ noerror: * capability information is not provided or transport is * SATA, we take support for granted. */ + oif = path->device->inq_flags; if (!(path->device->inq_flags & SID_DMA) || (path->device->transport == XPORT_ATA && (cts.xport_specific.ata.valid & CTS_ATA_VALID_CAPS) && @@ -1071,6 +1086,8 @@ noerror: path->device->inq_flags &= ~SID_DMA48; else path->device->inq_flags |= SID_DMA48; + if (path->device->inq_flags != oif) + xpt_async(AC_GETDEV_CHANGED, path, NULL); /* Store result to SIM. */ bzero(&cts, sizeof(cts)); xpt_setup_ccb(&cts.ccb_h, path, CAM_PRIORITY_NONE); @@ -1241,6 +1258,7 @@ notsata: else caps = 0; /* Remember what transport thinks about AEN. */ + oif = path->device->inq_flags; if ((caps & CTS_SATA_CAPS_H_AN) && path->device->protocol != PROTO_ATA) path->device->inq_flags |= SID_AEN; else @@ -1254,7 +1272,6 @@ notsata: cts.xport_specific.sata.valid = CTS_SATA_VALID_CAPS; xpt_action((union ccb *)&cts); softc->caps = caps; - xpt_async(AC_GETDEV_CHANGED, path, NULL); if (periph->path->device->flags & CAM_DEV_UNCONFIGURED) { path->device->flags &= ~CAM_DEV_UNCONFIGURED; xpt_acquire_device(path->device); @@ -1262,6 +1279,8 @@ notsata: xpt_action(done_ccb); xpt_async(AC_FOUND_DEVICE, path, done_ccb); } else { + if (path->device->inq_flags != oif) + xpt_async(AC_GETDEV_CHANGED, path, NULL); done_ccb->ccb_h.func_code = XPT_GDEV_TYPE; xpt_action(done_ccb); xpt_async(AC_SCSI_AEN, path, done_ccb); @@ -1274,12 +1293,14 @@ notsata: /* Check that it is the same device. */ if (bcmp(&softc->ident_data, ident_buf, 53)) { /* Device changed. */ + changed = 2; xpt_async(AC_LOST_DEVICE, path, NULL); } else { bcopy(&softc->ident_data, ident_buf, sizeof(struct ata_params)); changed = 0; } - } + } else + changed = 2; if (changed) { bcopy(&softc->ident_data, ident_buf, sizeof(struct ata_params)); /* Clean up from previous instance of this device */ From owner-svn-src-stable-11@freebsd.org Thu Aug 8 22:19:44 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 94E1CB55B5; Thu, 8 Aug 2019 22:19:44 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 464N8c386vz3GHB; Thu, 8 Aug 2019 22:19:44 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3069A4092; Thu, 8 Aug 2019 22:19:44 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x78MJiUh048288; Thu, 8 Aug 2019 22:19:44 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x78MJhnV048287; Thu, 8 Aug 2019 22:19:43 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201908082219.x78MJhnV048287@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 8 Aug 2019 22:19:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r350806 - stable/11/sbin/camcontrol X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sbin/camcontrol X-SVN-Commit-Revision: 350806 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Aug 2019 22:19:44 -0000 Author: mav Date: Thu Aug 8 22:19:43 2019 New Revision: 350806 URL: https://svnweb.freebsd.org/changeset/base/350806 Log: MFC r350257: Make `camcontrol hpa` and `camcontrol ama` trigger reprobe. This makes OS automatically see the disk's new disk size. Modified: stable/11/sbin/camcontrol/camcontrol.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/camcontrol/camcontrol.c ============================================================================== --- stable/11/sbin/camcontrol/camcontrol.c Thu Aug 8 22:17:41 2019 (r350805) +++ stable/11/sbin/camcontrol/camcontrol.c Thu Aug 8 22:19:43 2019 (r350806) @@ -301,6 +301,7 @@ static int scsiserial(struct cam_device *device, int t #endif /* MINIMALISTIC */ static int parse_btl(char *tstr, path_id_t *bus, target_id_t *target, lun_id_t *lun, cam_argmask *arglst); +static int reprobe(struct cam_device *device); static int dorescan_or_reset(int argc, char **argv, int rescan); static int rescan_or_reset_bus(path_id_t bus, int rescan); static int scanlun_or_reset_dev(path_id_t bus, target_id_t target, @@ -370,7 +371,6 @@ static int scsiprintopcodes(struct cam_device *device, static int scsiopcodes(struct cam_device *device, int argc, char **argv, char *combinedopt, int task_attr, int retry_count, int timeout, int verbose); -static int scsireprobe(struct cam_device *device); #endif /* MINIMALISTIC */ #ifndef min @@ -2934,6 +2934,8 @@ atahpa(struct cam_device *device, int retry_count, int timeout, ccb, &ident_buf); atahpa_print(ident_buf, hpasize, 1); + /* Hint CAM to reprobe the device. */ + reprobe(device); } } break; @@ -3076,6 +3078,8 @@ ataama(struct cam_device *device, int retry_count, int error = ata_do_identify(device, retry_count, timeout, ccb, &ident_buf); ataama_print(ident_buf, nativesize, 1); + /* Hint CAM to reprobe the device. */ + reprobe(device); } } break; @@ -9313,7 +9317,7 @@ bailout: #endif /* MINIMALISTIC */ static int -scsireprobe(struct cam_device *device) +reprobe(struct cam_device *device) { union ccb *ccb; int retval = 0; @@ -9325,7 +9329,7 @@ scsireprobe(struct cam_device *device) return (1); } - CCB_CLEAR_ALL_EXCEPT_HDR(&ccb->csio); + CCB_CLEAR_ALL_EXCEPT_HDR(ccb); ccb->ccb_h.func_code = XPT_REPROBE_LUN; @@ -10090,7 +10094,7 @@ main(int argc, char **argv) arglist & CAM_ARG_VERBOSE); break; case CAM_CMD_REPROBE: - error = scsireprobe(cam_dev); + error = reprobe(cam_dev); break; case CAM_CMD_ZONE: error = zone(cam_dev, argc, argv, combinedopt, From owner-svn-src-stable-11@freebsd.org Thu Aug 8 22:20:16 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 552E2B563F; Thu, 8 Aug 2019 22:20:16 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 464N9D2H2bz3GSP; Thu, 8 Aug 2019 22:20:16 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2F9A94096; Thu, 8 Aug 2019 22:20:16 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x78MKGk8048413; Thu, 8 Aug 2019 22:20:16 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x78MKFut048407; Thu, 8 Aug 2019 22:20:15 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201908082220.x78MKFut048407@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 8 Aug 2019 22:20:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r350807 - in stable/11: sbin/camcontrol sys/cam/ata sys/cam/scsi sys/sys X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: in stable/11: sbin/camcontrol sys/cam/ata sys/cam/scsi sys/sys X-SVN-Commit-Revision: 350807 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Aug 2019 22:20:16 -0000 Author: mav Date: Thu Aug 8 22:20:15 2019 New Revision: 350807 URL: https://svnweb.freebsd.org/changeset/base/350807 Log: MFC r350331: Make `camcontrol sanitize` support also ATA devices. ATA sanitize is functionally identical to SCSI, just uses different initiation commands and status reporting mechanism. While there, make kernel better handle sanitize commands and statuses. Modified: stable/11/sbin/camcontrol/camcontrol.8 stable/11/sbin/camcontrol/camcontrol.c stable/11/sys/cam/ata/ata_all.c stable/11/sys/cam/scsi/scsi_all.c stable/11/sys/sys/ata.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/camcontrol/camcontrol.8 ============================================================================== --- stable/11/sbin/camcontrol/camcontrol.8 Thu Aug 8 22:19:43 2019 (r350806) +++ stable/11/sbin/camcontrol/camcontrol.8 Thu Aug 8 22:20:15 2019 (r350807) @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 22, 2019 +.Dd July 25, 2019 .Dt CAMCONTROL 8 .Os .Sh NAME @@ -1276,13 +1276,11 @@ will not be asked about the timeout if a timeout is sp command line. .El .It Ic sanitize -Issue the -.Tn SCSI -SANITIZE command to the named device. +Issue the SANITIZE command to the named device. .Pp .Em WARNING! WARNING! WARNING! .Pp -ALL data in the cache and on the disk will be destroyed or made inaccessible. +ALL data on the disk will be destroyed or made inaccessible. Recovery of the data is not possible. Use extreme caution when issuing this command. .Pp Modified: stable/11/sbin/camcontrol/camcontrol.c ============================================================================== --- stable/11/sbin/camcontrol/camcontrol.c Thu Aug 8 22:19:43 2019 (r350806) +++ stable/11/sbin/camcontrol/camcontrol.c Thu Aug 8 22:20:15 2019 (r350807) @@ -346,7 +346,7 @@ static int ratecontrol(struct cam_device *device, int static int scsiformat(struct cam_device *device, int argc, char **argv, char *combinedopt, int task_attr, int retry_count, int timeout); -static int scsisanitize(struct cam_device *device, int argc, char **argv, +static int sanitize(struct cam_device *device, int argc, char **argv, char *combinedopt, int task_attr, int retry_count, int timeout); static int scsireportluns(struct cam_device *device, int argc, char **argv, @@ -1595,6 +1595,19 @@ atacapprint(struct ata_params *parm) } else { printf("no\n"); } + printf("Sanitize "); + if (parm->multi & ATA_SUPPORT_SANITIZE) { + printf("yes\t\t%s%s%s\n", + parm->multi & ATA_SUPPORT_BLOCK_ERASE_EXT ? "block, " : "", + parm->multi & ATA_SUPPORT_OVERWRITE_EXT ? "overwrite, " : "", + parm->multi & ATA_SUPPORT_CRYPTO_SCRAMBLE_EXT ? "crypto" : ""); + printf("Sanitize - commands allowed %s\n", + parm->multi & ATA_SUPPORT_SANITIZE_ALLOWED ? "yes" : "no"); + printf("Sanitize - antifreeze lock %s\n", + parm->multi & ATA_SUPPORT_ANTIFREEZE_LOCK_EXT ? "yes" : "no"); + } else { + printf("no\n"); + } } static int @@ -1841,6 +1854,11 @@ ata_do_cmd(struct cam_device *device, union ccb *ccb, res->lba_high_exp = res_pass16->lba_high_exp; res->sector_count = res_pass16->sector_count; res->sector_count_exp = res_pass16->sector_count_exp; + ccb->ccb_h.status &= ~CAM_STATUS_MASK; + if (res->status & ATA_STATUS_ERROR) + ccb->ccb_h.status |= CAM_ATA_STATUS_ERROR; + else + ccb->ccb_h.status |= CAM_REQ_CMP; } return (error); @@ -2329,12 +2347,6 @@ ata_do_identify(struct cam_device *device, int retry_c error = 0; } - if (arglist & CAM_ARG_VERBOSE) { - fprintf(stdout, "%s%d: Raw identify data:\n", - device->device_name, device->dev_unit_num); - dump_data(ptr, sizeof(struct ata_params)); - } - /* check for invalid (all zero) response */ if (error != 0) { warnx("Invalid identify response detected"); @@ -2385,6 +2397,12 @@ ataidentify(struct cam_device *device, int retry_count return (1); } + if (arglist & CAM_ARG_VERBOSE) { + printf("%s%d: Raw identify data:\n", + device->device_name, device->dev_unit_num); + dump_data((void*)ident_buf, sizeof(struct ata_params)); + } + if (ident_buf->support.command1 & ATA_SUPPORT_PROTECTED) { if (ata_read_native_max(device, retry_count, timeout, ccb, ident_buf, &hpasize) != 0) { @@ -6567,15 +6585,184 @@ scsiformat_bailout: } static int -scsisanitize(struct cam_device *device, int argc, char **argv, +sanitize_wait_ata(struct cam_device *device, union ccb *ccb, int quiet) +{ + struct ata_res *res; + int retval; + cam_status status; + u_int val, perc; + + do { + retval = ata_do_cmd(device, + ccb, + /*retries*/1, + /*flags*/CAM_DIR_NONE, + /*protocol*/AP_PROTO_NON_DATA | AP_EXTEND, + /*ata_flags*/AP_FLAG_CHK_COND, + /*tag_action*/MSG_SIMPLE_Q_TAG, + /*command*/ATA_SANITIZE, + /*features*/0x00, /* SANITIZE STATUS EXT */ + /*lba*/0, + /*sector_count*/0, + /*data_ptr*/NULL, + /*dxfer_len*/0, + /*timeout*/10000, + /*is48bit*/1); + if (retval < 0) { + warn("error sending CAMIOCOMMAND ioctl"); + if (arglist & CAM_ARG_VERBOSE) { + cam_error_print(device, ccb, CAM_ESF_ALL, + CAM_EPF_ALL, stderr); + } + return (1); + } + + status = ccb->ccb_h.status & CAM_STATUS_MASK; + if (status == CAM_REQ_CMP) { + res = &ccb->ataio.res; + if (res->sector_count_exp & 0x40) { + if (quiet == 0) { + val = (res->lba_mid << 8) + res->lba_low; + perc = 10000 * val; + fprintf(stdout, + "Sanitizing: %u.%02u%% (%d/%d)\r", + (perc / (0x10000 * 100)), + ((perc / 0x10000) % 100), + val, 0x10000); + fflush(stdout); + } + sleep(1); + } else if ((res->sector_count_exp & 0x80) == 0) { + warnx("Sanitize complete with an error. "); + return (1); + } else + break; + + } else if (status != CAM_REQ_CMP && status != CAM_REQUEUE_REQ) { + warnx("Unexpected CAM status %#x", status); + if (arglist & CAM_ARG_VERBOSE) + cam_error_print(device, ccb, CAM_ESF_ALL, + CAM_EPF_ALL, stderr); + return (1); + } + } while (1); + return (0); +} + +static int +sanitize_wait_scsi(struct cam_device *device, union ccb *ccb, int task_attr, int quiet) +{ + int warnings = 0, retval; + cam_status status; + u_int val, perc; + + do { + CCB_CLEAR_ALL_EXCEPT_HDR(&ccb->csio); + + /* + * There's really no need to do error recovery or + * retries here, since we're just going to sit in a + * loop and wait for the device to finish sanitizing. + */ + scsi_test_unit_ready(&ccb->csio, + /* retries */ 0, + /* cbfcnp */ NULL, + /* tag_action */ task_attr, + /* sense_len */ SSD_FULL_SIZE, + /* timeout */ 5000); + + /* Disable freezing the device queue */ + ccb->ccb_h.flags |= CAM_DEV_QFRZDIS; + + retval = cam_send_ccb(device, ccb); + + /* + * If we get an error from the ioctl, bail out. SCSI + * errors are expected. + */ + if (retval < 0) { + warn("error sending CAMIOCOMMAND ioctl"); + if (arglist & CAM_ARG_VERBOSE) { + cam_error_print(device, ccb, CAM_ESF_ALL, + CAM_EPF_ALL, stderr); + } + return (1); + } + + status = ccb->ccb_h.status & CAM_STATUS_MASK; + if ((status == CAM_SCSI_STATUS_ERROR) && + ((ccb->ccb_h.status & CAM_AUTOSNS_VALID) != 0)) { + struct scsi_sense_data *sense; + int error_code, sense_key, asc, ascq; + + sense = &ccb->csio.sense_data; + scsi_extract_sense_len(sense, ccb->csio.sense_len - + ccb->csio.sense_resid, &error_code, &sense_key, + &asc, &ascq, /*show_errors*/ 1); + + /* + * According to the SCSI-3 spec, a drive that is in the + * middle of a sanitize should return NOT READY with an + * ASC of "logical unit not ready, sanitize in + * progress". The sense key specific bytes will then + * be a progress indicator. + */ + if ((sense_key == SSD_KEY_NOT_READY) + && (asc == 0x04) && (ascq == 0x1b)) { + uint8_t sks[3]; + + if ((scsi_get_sks(sense, ccb->csio.sense_len - + ccb->csio.sense_resid, sks) == 0) + && (quiet == 0)) { + val = scsi_2btoul(&sks[1]); + perc = 10000 * val; + fprintf(stdout, + "Sanitizing: %u.%02u%% (%d/%d)\r", + (perc / (0x10000 * 100)), + ((perc / 0x10000) % 100), + val, 0x10000); + fflush(stdout); + } else if ((quiet == 0) && (++warnings <= 1)) { + warnx("Unexpected SCSI Sense Key " + "Specific value returned " + "during sanitize:"); + scsi_sense_print(device, &ccb->csio, + stderr); + warnx("Unable to print status " + "information, but sanitze will " + "proceed."); + warnx("will exit when sanitize is " + "complete"); + } + sleep(1); + } else { + warnx("Unexpected SCSI error during sanitize"); + cam_error_print(device, ccb, CAM_ESF_ALL, + CAM_EPF_ALL, stderr); + return (1); + } + + } else if (status != CAM_REQ_CMP && status != CAM_REQUEUE_REQ) { + warnx("Unexpected CAM status %#x", status); + if (arglist & CAM_ARG_VERBOSE) + cam_error_print(device, ccb, CAM_ESF_ALL, + CAM_EPF_ALL, stderr); + return (1); + } + } while ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP); + return (0); +} + +static int +sanitize(struct cam_device *device, int argc, char **argv, char *combinedopt, int task_attr, int retry_count, int timeout) { union ccb *ccb; u_int8_t action = 0; int c; int ycount = 0, quiet = 0; - int error = 0, retval = 0; - int use_timeout = 10800 * 1000; + int error = 0; + int use_timeout; int immediate = 1; int invert = 0; int passes = 0; @@ -6584,14 +6771,25 @@ scsisanitize(struct cam_device *device, int argc, char const char *pattern = NULL; u_int8_t *data_ptr = NULL; u_int32_t dxfer_len = 0; - u_int8_t byte2 = 0; - int num_warnings = 0; + uint8_t byte2; + uint16_t feature, count; + uint64_t lba; int reportonly = 0; + camcontrol_devtype dt; + /* + * Get the device type, request no I/O be done to do this. + */ + error = get_device_type(device, -1, 0, 0, &dt); + if (error != 0 || (unsigned)dt > CC_DT_UNKNOWN) { + warnx("sanitize: can't get device type"); + return (1); + } + ccb = cam_getccb(device); if (ccb == NULL) { - warnx("scsisanitize: error allocating ccb"); + warnx("sanitize: error allocating ccb"); return (1); } @@ -6612,7 +6810,7 @@ scsisanitize(struct cam_device *device, int argc, char warnx("invalid service operation \"%s\"", optarg); error = 1; - goto scsisanitize_bailout; + goto sanitize_bailout; } break; case 'c': @@ -6620,7 +6818,7 @@ scsisanitize(struct cam_device *device, int argc, char if (passes < 1 || passes > 31) { warnx("invalid passes value %d", passes); error = 1; - goto scsisanitize_bailout; + goto sanitize_bailout; } break; case 'I': @@ -6639,7 +6837,9 @@ scsisanitize(struct cam_device *device, int argc, char reportonly = 1; break; case 'w': - immediate = 0; + /* ATA supports only immediate commands. */ + if (dt == CC_DT_SCSI) + immediate = 0; break; case 'y': ycount++; @@ -6653,7 +6853,7 @@ scsisanitize(struct cam_device *device, int argc, char if (action == 0) { warnx("an action is required"); error = 1; - goto scsisanitize_bailout; + goto sanitize_bailout; } else if (action == SSZ_SERVICE_ACTION_OVERWRITE) { struct scsi_sanitize_parameter_list *pl; struct stat sb; @@ -6662,43 +6862,43 @@ scsisanitize(struct cam_device *device, int argc, char if (pattern == NULL) { warnx("overwrite action requires -P argument"); error = 1; - goto scsisanitize_bailout; + goto sanitize_bailout; } fd = open(pattern, O_RDONLY); if (fd < 0) { warn("cannot open pattern file %s", pattern); error = 1; - goto scsisanitize_bailout; + goto sanitize_bailout; } if (fstat(fd, &sb) < 0) { warn("cannot stat pattern file %s", pattern); error = 1; - goto scsisanitize_bailout; + goto sanitize_bailout; } sz = sb.st_size; if (sz > SSZPL_MAX_PATTERN_LENGTH) { warnx("pattern file size exceeds maximum value %d", SSZPL_MAX_PATTERN_LENGTH); error = 1; - goto scsisanitize_bailout; + goto sanitize_bailout; } dxfer_len = sizeof(*pl) + sz; data_ptr = calloc(1, dxfer_len); if (data_ptr == NULL) { warnx("cannot allocate parameter list buffer"); error = 1; - goto scsisanitize_bailout; + goto sanitize_bailout; } amt = read(fd, data_ptr + sizeof(*pl), sz); if (amt < 0) { warn("cannot read pattern file"); error = 1; - goto scsisanitize_bailout; + goto sanitize_bailout; } else if (amt != sz) { warnx("short pattern file read"); error = 1; - goto scsisanitize_bailout; + goto sanitize_bailout; } pl = (struct scsi_sanitize_parameter_list *)data_ptr; @@ -6724,7 +6924,7 @@ scsisanitize(struct cam_device *device, int argc, char warnx("%s argument only valid with overwrite " "operation", arg); error = 1; - goto scsisanitize_bailout; + goto sanitize_bailout; } } @@ -6732,26 +6932,41 @@ scsisanitize(struct cam_device *device, int argc, char fprintf(stdout, "You are about to REMOVE ALL DATA from the " "following device:\n"); - error = scsidoinquiry(device, argc, argv, combinedopt, - task_attr, retry_count, timeout); + if (dt == CC_DT_SCSI) { + error = scsidoinquiry(device, argc, argv, combinedopt, + task_attr, retry_count, timeout); + } else if (dt == CC_DT_ATA || dt == CC_DT_SATL) { + struct ata_params *ident_buf; + error = ata_do_identify(device, retry_count, timeout, + ccb, &ident_buf); + if (error == 0) { + printf("%s%d: ", device->device_name, + device->dev_unit_num); + ata_print_ident(ident_buf); + free(ident_buf); + } + } else + error = 1; if (error != 0) { - warnx("scsisanitize: error sending inquiry"); - goto scsisanitize_bailout; + warnx("sanitize: error sending inquiry"); + goto sanitize_bailout; } } if (ycount == 0) { if (!get_confirmation()) { error = 1; - goto scsisanitize_bailout; + goto sanitize_bailout; } } if (timeout != 0) use_timeout = timeout; + else + use_timeout = (immediate ? 10 : 10800) * 1000; - if (quiet == 0) { + if (immediate == 0 && quiet == 0) { fprintf(stdout, "Current sanitize timeout is %d seconds\n", use_timeout / 1000); } @@ -6761,8 +6976,7 @@ scsisanitize(struct cam_device *device, int argc, char * timeout on the command line, ask them if they want the current * timeout. */ - if ((ycount == 0) - && (timeout == 0)) { + if (immediate == 0 && ycount == 0 && timeout == 0) { char str[1024]; int new_timeout = 0; @@ -6782,33 +6996,76 @@ scsisanitize(struct cam_device *device, int argc, char } } - byte2 = action; - if (ause != 0) - byte2 |= SSZ_UNRESTRICTED_EXIT; - if (immediate != 0) - byte2 |= SSZ_IMMED; + if (dt == CC_DT_SCSI) { + byte2 = action; + if (ause != 0) + byte2 |= SSZ_UNRESTRICTED_EXIT; + if (immediate != 0) + byte2 |= SSZ_IMMED; + scsi_sanitize(&ccb->csio, + /* retries */ retry_count, + /* cbfcnp */ NULL, + /* tag_action */ task_attr, + /* byte2 */ byte2, + /* control */ 0, + /* data_ptr */ data_ptr, + /* dxfer_len */ dxfer_len, + /* sense_len */ SSD_FULL_SIZE, + /* timeout */ use_timeout); - scsi_sanitize(&ccb->csio, - /* retries */ retry_count, - /* cbfcnp */ NULL, - /* tag_action */ task_attr, - /* byte2 */ byte2, - /* control */ 0, - /* data_ptr */ data_ptr, - /* dxfer_len */ dxfer_len, - /* sense_len */ SSD_FULL_SIZE, - /* timeout */ use_timeout); + ccb->ccb_h.flags |= CAM_DEV_QFRZDIS; + if (arglist & CAM_ARG_ERR_RECOVER) + ccb->ccb_h.flags |= CAM_PASS_ERR_RECOVER; + if (cam_send_ccb(device, ccb) < 0) { + warn("error sending sanitize command"); + error = 1; + goto sanitize_bailout; + } + } else if (dt == CC_DT_ATA || dt == CC_DT_SATL) { + if (action == SSZ_SERVICE_ACTION_OVERWRITE) { + feature = 0x14; /* OVERWRITE EXT */ + lba = 0x4F5700000000 | scsi_4btoul(data_ptr + 4); + count = (passes == 0) ? 1 : (passes >= 16) ? 0 : passes; + if (invert) + count |= 0x80; /* INVERT PATTERN */ + if (ause) + count |= 0x10; /* FAILURE MODE */ + } else if (action == SSZ_SERVICE_ACTION_BLOCK_ERASE) { + feature = 0x12; /* BLOCK ERASE EXT */ + lba = 0x0000426B4572; + count = 0; + if (ause) + count |= 0x10; /* FAILURE MODE */ + } else if (action == SSZ_SERVICE_ACTION_CRYPTO_ERASE) { + feature = 0x11; /* CRYPTO SCRAMBLE EXT */ + lba = 0x000043727970; + count = 0; + if (ause) + count |= 0x10; /* FAILURE MODE */ + } else if (action == SSZ_SERVICE_ACTION_EXIT_MODE_FAILURE) { + feature = 0x00; /* SANITIZE STATUS EXT */ + lba = 0; + count = 1; /* CLEAR SANITIZE OPERATION FAILED */ + } else { + error = 1; + goto sanitize_bailout; + } - /* Disable freezing the device queue */ - ccb->ccb_h.flags |= CAM_DEV_QFRZDIS; - - if (arglist & CAM_ARG_ERR_RECOVER) - ccb->ccb_h.flags |= CAM_PASS_ERR_RECOVER; - - if (cam_send_ccb(device, ccb) < 0) { - warn("error sending sanitize command"); - error = 1; - goto scsisanitize_bailout; + error = ata_do_cmd(device, + ccb, + retry_count, + /*flags*/CAM_DIR_NONE, + /*protocol*/AP_PROTO_NON_DATA | AP_EXTEND, + /*ata_flags*/AP_FLAG_CHK_COND, + /*tag_action*/MSG_SIMPLE_Q_TAG, + /*command*/ATA_SANITIZE, + /*features*/feature, + /*lba*/lba, + /*sector_count*/count, + /*data_ptr*/NULL, + /*dxfer_len*/0, + /*timeout*/ use_timeout, + /*is48bit*/1); } if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { @@ -6836,7 +7093,7 @@ scsisanitize(struct cam_device *device, int argc, char CAM_EPF_ALL, stderr); } error = 1; - goto scsisanitize_bailout; + goto sanitize_bailout; } /* @@ -6849,124 +7106,20 @@ scsisanitize(struct cam_device *device, int argc, char if (quiet == 0) { fprintf(stdout, "Sanitize Complete\n"); } - goto scsisanitize_bailout; + goto sanitize_bailout; } doreport: - do { - cam_status status; + if (dt == CC_DT_SCSI) { + error = sanitize_wait_scsi(device, ccb, task_attr, quiet); + } else if (dt == CC_DT_ATA || dt == CC_DT_SATL) { + error = sanitize_wait_ata(device, ccb, quiet); + } else + error = 1; + if (error == 0 && quiet == 0) + fprintf(stdout, "Sanitize Complete \n"); - CCB_CLEAR_ALL_EXCEPT_HDR(&ccb->csio); - - /* - * There's really no need to do error recovery or - * retries here, since we're just going to sit in a - * loop and wait for the device to finish sanitizing. - */ - scsi_test_unit_ready(&ccb->csio, - /* retries */ 0, - /* cbfcnp */ NULL, - /* tag_action */ task_attr, - /* sense_len */ SSD_FULL_SIZE, - /* timeout */ 5000); - - /* Disable freezing the device queue */ - ccb->ccb_h.flags |= CAM_DEV_QFRZDIS; - - retval = cam_send_ccb(device, ccb); - - /* - * If we get an error from the ioctl, bail out. SCSI - * errors are expected. - */ - if (retval < 0) { - warn("error sending CAMIOCOMMAND ioctl"); - if (arglist & CAM_ARG_VERBOSE) { - cam_error_print(device, ccb, CAM_ESF_ALL, - CAM_EPF_ALL, stderr); - } - error = 1; - goto scsisanitize_bailout; - } - - status = ccb->ccb_h.status & CAM_STATUS_MASK; - - if ((status != CAM_REQ_CMP) - && (status == CAM_SCSI_STATUS_ERROR) - && ((ccb->ccb_h.status & CAM_AUTOSNS_VALID) != 0)) { - struct scsi_sense_data *sense; - int error_code, sense_key, asc, ascq; - - sense = &ccb->csio.sense_data; - scsi_extract_sense_len(sense, ccb->csio.sense_len - - ccb->csio.sense_resid, &error_code, &sense_key, - &asc, &ascq, /*show_errors*/ 1); - - /* - * According to the SCSI-3 spec, a drive that is in the - * middle of a sanitize should return NOT READY with an - * ASC of "logical unit not ready, sanitize in - * progress". The sense key specific bytes will then - * be a progress indicator. - */ - if ((sense_key == SSD_KEY_NOT_READY) - && (asc == 0x04) && (ascq == 0x1b)) { - uint8_t sks[3]; - - if ((scsi_get_sks(sense, ccb->csio.sense_len - - ccb->csio.sense_resid, sks) == 0) - && (quiet == 0)) { - int val; - u_int64_t percentage; - - val = scsi_2btoul(&sks[1]); - percentage = 10000 * val; - - fprintf(stdout, - "\rSanitizing: %ju.%02u %% " - "(%d/%d) done", - (uintmax_t)(percentage / - (0x10000 * 100)), - (unsigned)((percentage / - 0x10000) % 100), - val, 0x10000); - fflush(stdout); - } else if ((quiet == 0) - && (++num_warnings <= 1)) { - warnx("Unexpected SCSI Sense Key " - "Specific value returned " - "during sanitize:"); - scsi_sense_print(device, &ccb->csio, - stderr); - warnx("Unable to print status " - "information, but sanitze will " - "proceed."); - warnx("will exit when sanitize is " - "complete"); - } - sleep(1); - } else { - warnx("Unexpected SCSI error during sanitize"); - cam_error_print(device, ccb, CAM_ESF_ALL, - CAM_EPF_ALL, stderr); - error = 1; - goto scsisanitize_bailout; - } - - } else if (status != CAM_REQ_CMP) { - warnx("Unexpected CAM status %#x", status); - if (arglist & CAM_ARG_VERBOSE) - cam_error_print(device, ccb, CAM_ESF_ALL, - CAM_EPF_ALL, stderr); - error = 1; - goto scsisanitize_bailout; - } - } while((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP); - - if (quiet == 0) - fprintf(stdout, "\nSanitize Complete\n"); - -scsisanitize_bailout: +sanitize_bailout: if (fd >= 0) close(fd); if (data_ptr != NULL) @@ -10072,9 +10225,8 @@ main(int argc, char **argv) timeout); break; case CAM_CMD_SANITIZE: - error = scsisanitize(cam_dev, argc, argv, - combinedopt, task_attr, - retry_count, timeout); + error = sanitize(cam_dev, argc, argv, combinedopt, task_attr, + retry_count, timeout); break; case CAM_CMD_PERSIST: error = scsipersist(cam_dev, argc, argv, combinedopt, Modified: stable/11/sys/cam/ata/ata_all.c ============================================================================== --- stable/11/sys/cam/ata/ata_all.c Thu Aug 8 22:19:43 2019 (r350806) +++ stable/11/sys/cam/ata/ata_all.c Thu Aug 8 22:20:15 2019 (r350807) @@ -213,7 +213,16 @@ ata_op_string(struct ata_cmd *cmd) return ("SMART"); case 0xb1: return ("DEVICE CONFIGURATION"); case 0xb2: return ("SET_SECTOR_CONFIGURATION_EXT"); - case 0xb4: return ("SANITIZE_DEVICE"); + case 0xb4: + switch(cmd->features) { + case 0x00: return ("SANITIZE_STATUS_EXT"); + case 0x11: return ("CRYPTO_SCRAMBLE_EXT"); + case 0x12: return ("BLOCK_ERASE_EXT"); + case 0x14: return ("OVERWRITE_EXT"); + case 0x20: return ("SANITIZE_FREEZE_LOCK_EXT"); + case 0x40: return ("SANITIZE_ANTIFREEZE_LOCK_EXT"); + } + return ("SANITIZE_DEVICE"); case 0xc0: return ("CFA_ERASE"); case 0xc4: return ("READ_MUL"); case 0xc5: return ("WRITE_MUL"); Modified: stable/11/sys/cam/scsi/scsi_all.c ============================================================================== --- stable/11/sys/cam/scsi/scsi_all.c Thu Aug 8 22:19:43 2019 (r350806) +++ stable/11/sys/cam/scsi/scsi_all.c Thu Aug 8 22:20:15 2019 (r350807) @@ -377,7 +377,7 @@ static struct op_table_entry scsi_op_codes[] = { { 0x40, D | T | L | P | W | R | O | M | S | C, "CHANGE DEFINITION" }, /* 41 O WRITE SAME(10) */ { 0x41, D, "WRITE SAME(10)" }, - /* 42 O UNMAP */ + /* 42 O UNMAP */ { 0x42, D, "UNMAP" }, /* 42 O READ SUB-CHANNEL */ { 0x42, R, "READ SUB-CHANNEL" }, @@ -392,7 +392,8 @@ static struct op_table_entry scsi_op_codes[] = { { 0x46, R, "GET CONFIGURATION" }, /* 47 O PLAY AUDIO MSF */ { 0x47, R, "PLAY AUDIO MSF" }, - /* 48 */ + /* 48 O SANITIZE */ + { 0x48, D, "SANITIZE" }, /* 49 */ /* 4A M GET EVENT STATUS NOTIFICATION */ { 0x4A, R, "GET EVENT STATUS NOTIFICATION" }, @@ -1160,7 +1161,7 @@ static struct asc_table_entry asc_table[] = { { SST(0x04, 0x1A, SS_RDEF, /* XXX TBD */ "Logical unit not ready, START/STOP UNIT command in progress") }, /* D B */ - { SST(0x04, 0x1B, SS_RDEF, /* XXX TBD */ + { SST(0x04, 0x1B, SS_WAIT | EBUSY, "Logical unit not ready, sanitize in progress") }, /* DT MAEB */ { SST(0x04, 0x1C, SS_RDEF, /* XXX TBD */ @@ -1451,7 +1452,7 @@ static struct asc_table_entry asc_table[] = { { SST(0x11, 0x14, SS_RDEF, /* XXX TBD */ "Read error - LBA marked bad by application client") }, /* D */ - { SST(0x11, 0x15, SS_RDEF, /* XXX TBD */ + { SST(0x11, 0x15, SS_FATAL | EIO, "Write after sanitize required") }, /* D W O BK */ { SST(0x12, 0x00, SS_RDEF, @@ -2062,7 +2063,7 @@ static struct asc_table_entry asc_table[] = { { SST(0x31, 0x02, SS_RDEF, /* XXX TBD */ "Zoned formatting failed due to spare linking") }, /* D B */ - { SST(0x31, 0x03, SS_RDEF, /* XXX TBD */ + { SST(0x31, 0x03, SS_FATAL | EIO, "SANITIZE command failed") }, /* D W O BK */ { SST(0x32, 0x00, SS_RDEF, Modified: stable/11/sys/sys/ata.h ============================================================================== --- stable/11/sys/sys/ata.h Thu Aug 8 22:19:43 2019 (r350806) +++ stable/11/sys/sys/ata.h Thu Aug 8 22:20:15 2019 (r350807) @@ -95,6 +95,8 @@ struct ata_params { #define ATA_SUPPORT_OVERWRITE_EXT 0x4000 #define ATA_SUPPORT_CRYPTO_SCRAMBLE_EXT 0x2000 #define ATA_SUPPORT_SANITIZE 0x1000 +#define ATA_SUPPORT_SANITIZE_ALLOWED 0x0800 +#define ATA_SUPPORT_ANTIFREEZE_LOCK_EXT 0x0400 #define ATA_MULTI_VALID 0x0100 /*060*/ u_int16_t lba_size_1; @@ -452,6 +454,7 @@ struct ata_params { #define ATA_ATAPI_IDENTIFY 0xa1 /* get ATAPI params*/ #define ATA_SERVICE 0xa2 /* service command */ #define ATA_SMART_CMD 0xb0 /* SMART command */ +#define ATA_SANITIZE 0xb4 /* sanitize device */ #define ATA_CFA_ERASE 0xc0 /* CFA erase */ #define ATA_READ_MUL 0xc4 /* read multi */ #define ATA_WRITE_MUL 0xc5 /* write multi */ From owner-svn-src-stable-11@freebsd.org Sat Aug 10 00:02:46 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7FD71ADBCD; Sat, 10 Aug 2019 00:02:46 +0000 (UTC) (envelope-from jtl@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4652P22ZXrz4CYh; Sat, 10 Aug 2019 00:02:46 +0000 (UTC) (envelope-from jtl@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 38E2F1D843; Sat, 10 Aug 2019 00:02:46 +0000 (UTC) (envelope-from jtl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x7A02kcr069069; Sat, 10 Aug 2019 00:02:46 GMT (envelope-from jtl@FreeBSD.org) Received: (from jtl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7A02k0x069068; Sat, 10 Aug 2019 00:02:46 GMT (envelope-from jtl@FreeBSD.org) Message-Id: <201908100002.x7A02k0x069068@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jtl set sender to jtl@FreeBSD.org using -f From: "Jonathan T. Looney" Date: Sat, 10 Aug 2019 00:02:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r350829 - stable/11/sys/kern X-SVN-Group: stable-11 X-SVN-Commit-Author: jtl X-SVN-Commit-Paths: stable/11/sys/kern X-SVN-Commit-Revision: 350829 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Aug 2019 00:02:46 -0000 Author: jtl Date: Sat Aug 10 00:02:45 2019 New Revision: 350829 URL: https://svnweb.freebsd.org/changeset/base/350829 Log: MFC r350815: In m_pulldown(), before trying to prepend bytes to the subsequent mbuf, ensure that the subsequent mbuf contains the remainder of the bytes the caller sought. If this is not the case, fall through to the code which gathers the bytes in a new mbuf. This fixes a bug where m_pulldown() could fail to gather all the desired bytes into consecutive memory. PR: 238787 Approved by: so (emaste) Modified: stable/11/sys/kern/uipc_mbuf2.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/kern/uipc_mbuf2.c ============================================================================== --- stable/11/sys/kern/uipc_mbuf2.c Sat Aug 10 00:01:25 2019 (r350828) +++ stable/11/sys/kern/uipc_mbuf2.c Sat Aug 10 00:02:45 2019 (r350829) @@ -214,7 +214,7 @@ m_pulldown(struct mbuf *m, int off, int len, int *offp goto ok; } if ((off == 0 || offp) && M_LEADINGSPACE(n->m_next) >= hlen - && writable) { + && writable && n->m_next->m_len >= tlen) { n->m_next->m_data -= hlen; n->m_next->m_len += hlen; bcopy(mtod(n, caddr_t) + off, mtod(n->m_next, caddr_t), hlen); From owner-svn-src-stable-11@freebsd.org Sat Aug 10 08:34:03 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 76329B6A3E; Sat, 10 Aug 2019 08:34:03 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 465Fkz2Z1Gz4Y0K; Sat, 10 Aug 2019 08:34:03 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 39B8123380; Sat, 10 Aug 2019 08:34:03 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x7A8Y32l070842; Sat, 10 Aug 2019 08:34:03 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7A8Y27i070841; Sat, 10 Aug 2019 08:34:02 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201908100834.x7A8Y27i070841@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sat, 10 Aug 2019 08:34:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r350834 - stable/11/sys/amd64/vmm/io X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/11/sys/amd64/vmm/io X-SVN-Commit-Revision: 350834 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Aug 2019 08:34:03 -0000 Author: kib Date: Sat Aug 10 08:34:02 2019 New Revision: 350834 URL: https://svnweb.freebsd.org/changeset/base/350834 Log: MFC r350560: bhyve: Ignore MSI/MSI-X interrupts sent to non-active vCPUs in physical destination mode. Modified: stable/11/sys/amd64/vmm/io/vlapic.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/amd64/vmm/io/vlapic.c ============================================================================== --- stable/11/sys/amd64/vmm/io/vlapic.c Sat Aug 10 08:29:23 2019 (r350833) +++ stable/11/sys/amd64/vmm/io/vlapic.c Sat Aug 10 08:34:02 2019 (r350834) @@ -836,7 +836,8 @@ vlapic_calcdest(struct vm *vm, cpuset_t *dmask, uint32 */ CPU_ZERO(dmask); vcpuid = vm_apicid2vcpuid(vm, dest); - if (vcpuid < vm_get_maxcpus(vm)) + amask = vm_active_cpus(vm); + if (vcpuid < vm_get_maxcpus(vm) && CPU_ISSET(vcpuid, &amask)) CPU_SET(vcpuid, dmask); } else { /* From owner-svn-src-stable-11@freebsd.org Sat Aug 10 08:34:57 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B31C7B6AC8; Sat, 10 Aug 2019 08:34:57 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 465Fm14Q6Fz4Y6M; Sat, 10 Aug 2019 08:34:57 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 79A2823381; Sat, 10 Aug 2019 08:34:57 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x7A8YvG7070935; Sat, 10 Aug 2019 08:34:57 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7A8YuNA070930; Sat, 10 Aug 2019 08:34:56 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201908100834.x7A8YuNA070930@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sat, 10 Aug 2019 08:34:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r350835 - stable/11/share/man/man3 X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/11/share/man/man3 X-SVN-Commit-Revision: 350835 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Aug 2019 08:34:57 -0000 Author: kib Date: Sat Aug 10 08:34:56 2019 New Revision: 350835 URL: https://svnweb.freebsd.org/changeset/base/350835 Log: MFC r350683, r350684: Clarify the robustness guarantees. Modified: stable/11/share/man/man3/pthread_cond_wait.3 stable/11/share/man/man3/pthread_mutex_consistent.3 stable/11/share/man/man3/pthread_mutex_lock.3 stable/11/share/man/man3/pthread_mutex_timedlock.3 stable/11/share/man/man3/pthread_mutex_trylock.3 Directory Properties: stable/11/ (props changed) Modified: stable/11/share/man/man3/pthread_cond_wait.3 ============================================================================== --- stable/11/share/man/man3/pthread_cond_wait.3 Sat Aug 10 08:34:02 2019 (r350834) +++ stable/11/share/man/man3/pthread_cond_wait.3 Sat Aug 10 08:34:56 2019 (r350835) @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 17, 2018 +.Dd August 7, 2019 .Dt PTHREAD_COND_WAIT 3 .Os .Sh NAME @@ -78,8 +78,8 @@ was not locked by the calling thread. .It Bq Er EOWNERDEAD The argument .Fa mutex -points to a robust mutex and the previous owning thread terminated -while holding the mutex lock. +points to a robust mutex and the process containing the previous owning +thread terminated while holding the mutex lock. The lock was granted to the caller and it is up to the new owner to make the state consistent. .It Bq Er ENOTRECOVERABLE Modified: stable/11/share/man/man3/pthread_mutex_consistent.3 ============================================================================== --- stable/11/share/man/man3/pthread_mutex_consistent.3 Sat Aug 10 08:34:02 2019 (r350834) +++ stable/11/share/man/man3/pthread_mutex_consistent.3 Sat Aug 10 08:34:56 2019 (r350835) @@ -41,9 +41,9 @@ .Ft int .Fn pthread_mutex_consistent "pthread_mutex_t *mutex" .Sh DESCRIPTION -If the thread owning a robust mutex terminates while holding the -mutex, the mutex becomes inconsistent and the next thread that -acquires the mutex lock is notified of the state by the return value +If the process containing the thread owning a robust mutex terminates +while holding the mutex, the mutex becomes inconsistent and the next thread +that acquires the mutex lock is notified of the state by the return value .Er EOWNERDEAD . In this case, the mutex does not become normally usable again until the state is marked consistent. Modified: stable/11/share/man/man3/pthread_mutex_lock.3 ============================================================================== --- stable/11/share/man/man3/pthread_mutex_lock.3 Sat Aug 10 08:34:02 2019 (r350834) +++ stable/11/share/man/man3/pthread_mutex_lock.3 Sat Aug 10 08:34:56 2019 (r350835) @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 29, 2016 +.Dd August 7, 2019 .Dt PTHREAD_MUTEX_LOCK 3 .Os .Sh NAME @@ -66,8 +66,8 @@ A deadlock would occur if the thread blocked waiting f .It Bq Er EOWNERDEAD The argument .Fa mutex -points to a robust mutex and the previous owning thread terminated -while holding the mutex lock. +points to a robust mutex and the process containing the previous owning +thread terminated while holding the mutex lock. The lock was granted to the caller and it is up to the new owner to make the state consistent. .It Bq Er ENOTRECOVERABLE Modified: stable/11/share/man/man3/pthread_mutex_timedlock.3 ============================================================================== --- stable/11/share/man/man3/pthread_mutex_timedlock.3 Sat Aug 10 08:34:02 2019 (r350834) +++ stable/11/share/man/man3/pthread_mutex_timedlock.3 Sat Aug 10 08:34:56 2019 (r350835) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 17, 2018 +.Dd August 7, 2019 .Dt PTHREAD_MUTEX_TIMEDLOCK 3 .Os .Sh NAME @@ -92,8 +92,8 @@ The current thread already owns the .It Bq Er EOWNERDEAD The argument .Fa mutex -points to a robust mutex and the previous owning thread terminated -while holding the mutex lock. +points to a robust mutex and the process containing the previous owning +thread terminated while holding the mutex lock. The lock was granted to the caller and it is up to the new owner to make the state consistent. .It Bq Er ENOTRECOVERABLE Modified: stable/11/share/man/man3/pthread_mutex_trylock.3 ============================================================================== --- stable/11/share/man/man3/pthread_mutex_trylock.3 Sat Aug 10 08:34:02 2019 (r350834) +++ stable/11/share/man/man3/pthread_mutex_trylock.3 Sat Aug 10 08:34:56 2019 (r350835) @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 29, 2016 +.Dd August 7, 2019 .Dt PTHREAD_MUTEX_TRYLOCK 3 .Os .Sh NAME @@ -67,8 +67,8 @@ is already locked. .It Bq Er EOWNERDEAD The argument .Fa mutex -points to a robust mutex and the previous owning thread terminated -while holding the mutex lock. +points to a robust mutex and the process containing the previous owning +thread terminated while holding the mutex lock. The lock was granted to the caller and it is up to the new owner to make the state consistent. .It Bq Er ENOTRECOVERABLE From owner-svn-src-stable-11@freebsd.org Sat Aug 10 17:17:37 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C72E6C111E; Sat, 10 Aug 2019 17:17:37 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 465TM54yKnz3x2H; Sat, 10 Aug 2019 17:17:37 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8BA6C10C5; Sat, 10 Aug 2019 17:17:37 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x7AHHbD2076923; Sat, 10 Aug 2019 17:17:37 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7AHHblA076921; Sat, 10 Aug 2019 17:17:37 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201908101717.x7AHHblA076921@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sat, 10 Aug 2019 17:17:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r350839 - in stable/11/sys/amd64: amd64 include X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: in stable/11/sys/amd64: amd64 include X-SVN-Commit-Revision: 350839 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Aug 2019 17:17:37 -0000 Author: kib Date: Sat Aug 10 17:17:36 2019 New Revision: 350839 URL: https://svnweb.freebsd.org/changeset/base/350839 Log: MFC r350561: amd64: Streamline exceptions and interrupts handlers. Modified: stable/11/sys/amd64/amd64/exception.S stable/11/sys/amd64/include/asmacros.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/amd64/amd64/exception.S ============================================================================== --- stable/11/sys/amd64/amd64/exception.S Sat Aug 10 17:14:35 2019 (r350838) +++ stable/11/sys/amd64/amd64/exception.S Sat Aug 10 17:17:36 2019 (r350839) @@ -106,14 +106,31 @@ MCOUNT_LABEL(btrap) /* Traps that we leave interrupts disabled for. */ .macro TRAP_NOEN l, trapno - PTI_ENTRY \l,X\l + PTI_ENTRY \l,\l\()_pti_k,\l\()_pti_u +\l\()_pti_k: + subq $TF_RIP,%rsp + movl $\trapno,TF_TRAPNO(%rsp) + movq $0,TF_ADDR(%rsp) + movq $0,TF_ERR(%rsp) + jmp alltraps_noen_k +\l\()_pti_u: + subq $TF_RIP,%rsp + movl $\trapno,TF_TRAPNO(%rsp) + movq $0,TF_ADDR(%rsp) + movq $0,TF_ERR(%rsp) + jmp alltraps_noen_u + .globl X\l .type X\l,@function -X\l: subq $TF_RIP,%rsp - movl $\trapno,TF_TRAPNO(%rsp) - movq $0,TF_ADDR(%rsp) - movq $0,TF_ERR(%rsp) - jmp alltraps_noen +X\l: + subq $TF_RIP,%rsp + movl $\trapno,TF_TRAPNO(%rsp) + movq $0,TF_ADDR(%rsp) + movq $0,TF_ERR(%rsp) + testb $SEL_RPL_MASK,TF_CS(%rsp) + jz alltraps_noen_k + swapgs + jmp alltraps_noen_u .endm TRAP_NOEN bpt, T_BPTFLT @@ -123,15 +140,31 @@ X\l: subq $TF_RIP,%rsp /* Regular traps; The cpu does not supply tf_err for these. */ .macro TRAP l, trapno - PTI_ENTRY \l,X\l + PTI_ENTRY \l,\l\()_pti_k,\l\()_pti_u +\l\()_pti_k: + subq $TF_RIP,%rsp + movl $\trapno,TF_TRAPNO(%rsp) + movq $0,TF_ADDR(%rsp) + movq $0,TF_ERR(%rsp) + jmp alltraps_k +\l\()_pti_u: + subq $TF_RIP,%rsp + movl $\trapno,TF_TRAPNO(%rsp) + movq $0,TF_ADDR(%rsp) + movq $0,TF_ERR(%rsp) + jmp alltraps_u + .globl X\l .type X\l,@function X\l: - subq $TF_RIP,%rsp - movl $\trapno,TF_TRAPNO(%rsp) - movq $0,TF_ADDR(%rsp) - movq $0,TF_ERR(%rsp) - jmp alltraps + subq $TF_RIP,%rsp + movl $\trapno,TF_TRAPNO(%rsp) + movq $0,TF_ADDR(%rsp) + movq $0,TF_ERR(%rsp) + testb $SEL_RPL_MASK,TF_CS(%rsp) + jz alltraps_k + swapgs + jmp alltraps_u .endm TRAP div, T_DIVIDE @@ -146,42 +179,62 @@ X\l: /* This group of traps have tf_err already pushed by the cpu. */ .macro TRAP_ERR l, trapno - PTI_ENTRY \l,X\l,has_err=1 + PTI_ENTRY \l,\l\()_pti_k,\l\()_pti_u,has_err=1 +\l\()_pti_k: + subq $TF_ERR,%rsp + movl $\trapno,TF_TRAPNO(%rsp) + movq $0,TF_ADDR(%rsp) + jmp alltraps_k +\l\()_pti_u: + subq $TF_ERR,%rsp + movl $\trapno,TF_TRAPNO(%rsp) + movq $0,TF_ADDR(%rsp) + jmp alltraps_u .globl X\l .type X\l,@function X\l: - subq $TF_ERR,%rsp - movl $\trapno,TF_TRAPNO(%rsp) - movq $0,TF_ADDR(%rsp) - jmp alltraps + subq $TF_ERR,%rsp + movl $\trapno,TF_TRAPNO(%rsp) + movq $0,TF_ADDR(%rsp) + testb $SEL_RPL_MASK,TF_CS(%rsp) + jz alltraps_k + swapgs + jmp alltraps_u .endm TRAP_ERR tss, T_TSSFLT TRAP_ERR align, T_ALIGNFLT /* - * alltraps entry point. Use swapgs if this is the first time in the - * kernel from userland. Reenable interrupts if they were enabled - * before the trap. This approximates SDT_SYS386TGT on the i386 port. + * alltraps_u/k entry points. + * SWAPGS must be already performed by prologue, + * if this is the first time in the kernel from userland. + * Reenable interrupts if they were enabled before the trap. + * This approximates SDT_SYS386TGT on the i386 port. */ SUPERALIGN_TEXT - .globl alltraps - .type alltraps,@function -alltraps: + .globl alltraps_u + .type alltraps_u,@function +alltraps_u: movq %rdi,TF_RDI(%rsp) - testb $SEL_RPL_MASK,TF_CS(%rsp) /* Did we come from kernel? */ - jz 1f /* already running with kernel GS.base */ - swapgs + movq %rdx,TF_RDX(%rsp) + movq %rax,TF_RAX(%rsp) + movq %rcx,TF_RCX(%rsp) movq PCPU(CURPCB),%rdi andl $~PCB_FULL_IRET,PCB_FLAGS(%rdi) -1: SAVE_SEGS + call handle_ibrs_entry + jmp alltraps_save_segs + SUPERALIGN_TEXT + .globl alltraps_k + .type alltraps_k,@function +alltraps_k: + movq %rdi,TF_RDI(%rsp) movq %rdx,TF_RDX(%rsp) movq %rax,TF_RAX(%rsp) movq %rcx,TF_RCX(%rsp) - testb $SEL_RPL_MASK,TF_CS(%rsp) - jz 2f - call handle_ibrs_entry -2: testl $PSL_I,TF_RFLAGS(%rsp) +alltraps_save_segs: + SAVE_SEGS + testl $PSL_I,TF_RFLAGS(%rsp) jz alltraps_pushregs_no_rax sti alltraps_pushregs_no_rax: @@ -233,21 +286,26 @@ calltrap: jmp doreti /* Handle any pending ASTs */ /* - * alltraps_noen entry point. Unlike alltraps above, we want to - * leave the interrupts disabled. This corresponds to - * SDT_SYS386IGT on the i386 port. + * alltraps_noen_u/k entry points. + * Again, SWAPGS must be already performed by prologue, if needed. + * Unlike alltraps above, we want to leave the interrupts disabled. + * This corresponds to SDT_SYS386IGT on the i386 port. */ SUPERALIGN_TEXT - .globl alltraps_noen - .type alltraps_noen,@function -alltraps_noen: + .globl alltraps_noen_u + .type alltraps_noen_u,@function +alltraps_noen_u: movq %rdi,TF_RDI(%rsp) - testb $SEL_RPL_MASK,TF_CS(%rsp) /* Did we come from kernel? */ - jz 1f /* already running with kernel GS.base */ - swapgs movq PCPU(CURPCB),%rdi andl $~PCB_FULL_IRET,PCB_FLAGS(%rdi) -1: SAVE_SEGS + jmp alltraps_noen_save_segs + SUPERALIGN_TEXT + .globl alltraps_noen_k + .type alltraps_noen_k,@function +alltraps_noen_k: + movq %rdi,TF_RDI(%rsp) +alltraps_noen_save_segs: + SAVE_SEGS movq %rdx,TF_RDX(%rsp) movq %rax,TF_RAX(%rsp) movq %rcx,TF_RCX(%rsp) @@ -294,8 +352,8 @@ IDTVEC(dblfault) ALIGN_TEXT IDTVEC(page_pti) - testb $SEL_RPL_MASK,PTI_CS-2*8(%rsp) - jz Xpage + testb $SEL_RPL_MASK,PTI_CS-PTI_ERR(%rsp) + jz page_k swapgs pushq %rax movq %cr3,%rax @@ -303,25 +361,31 @@ IDTVEC(page_pti) cmpq $~0,PCPU(UCR3) jne 1f popq %rax - jmp 2f + jmp page_u 1: pushq %rdx PTI_UUENTRY has_err=1 -2: subq $TF_ERR,%rsp - movq %rdi,TF_RDI(%rsp) - movq %rax,TF_RAX(%rsp) - movq %rdx,TF_RDX(%rsp) - movq %rcx,TF_RCX(%rsp) jmp page_u + ALIGN_TEXT IDTVEC(page) + testb $SEL_RPL_MASK,TF_CS-TF_ERR(%rsp) /* Did we come from kernel? */ + jnz page_u_swapgs /* already running with kernel GS.base */ +page_k: subq $TF_ERR,%rsp movq %rdi,TF_RDI(%rsp) /* free up GP registers */ movq %rax,TF_RAX(%rsp) movq %rdx,TF_RDX(%rsp) movq %rcx,TF_RCX(%rsp) - testb $SEL_RPL_MASK,TF_CS(%rsp) /* Did we come from kernel? */ - jz page_cr2 /* already running with kernel GS.base */ + jmp page_cr2 + ALIGN_TEXT +page_u_swapgs: swapgs -page_u: movq PCPU(CURPCB),%rdi +page_u: + subq $TF_ERR,%rsp + movq %rdi,TF_RDI(%rsp) + movq %rax,TF_RAX(%rsp) + movq %rdx,TF_RDX(%rsp) + movq %rcx,TF_RCX(%rsp) + movq PCPU(CURPCB),%rdi andl $~PCB_FULL_IRET,PCB_FLAGS(%rdi) movq PCPU(SAVED_UCR3),%rax movq %rax,PCB_SAVED_UCR3(%rdi) Modified: stable/11/sys/amd64/include/asmacros.h ============================================================================== --- stable/11/sys/amd64/include/asmacros.h Sat Aug 10 17:14:35 2019 (r350838) +++ stable/11/sys/amd64/include/asmacros.h Sat Aug 10 17:17:36 2019 (r350839) @@ -202,17 +202,16 @@ 1: .endm - .macro PTI_ENTRY name, cont, has_err=0 + .macro PTI_ENTRY name, contk, contu, has_err=0 ALIGN_TEXT .globl X\name\()_pti .type X\name\()_pti,@function X\name\()_pti: - /* %rax, %rdx and possibly err not yet pushed */ - testb $SEL_RPL_MASK,PTI_CS-(2+1-\has_err)*8(%rsp) - jz \cont + /* %rax, %rdx, and possibly err are not yet pushed */ + testb $SEL_RPL_MASK,PTI_CS-PTI_ERR-((1-\has_err)*8)(%rsp) + jz \contk PTI_UENTRY \has_err - swapgs - jmp \cont + jmp \contu .endm .macro PTI_INTRENTRY vec_name From owner-svn-src-stable-11@freebsd.org Sat Aug 10 23:08:36 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A5F79A8793; Sat, 10 Aug 2019 23:08:36 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 465d843mW5z4KN5; Sat, 10 Aug 2019 23:08:36 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 62BF352A2; Sat, 10 Aug 2019 23:08:36 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x7AN8aPZ091684; Sat, 10 Aug 2019 23:08:36 GMT (envelope-from mckusick@FreeBSD.org) Received: (from mckusick@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7AN8aXK091682; Sat, 10 Aug 2019 23:08:36 GMT (envelope-from mckusick@FreeBSD.org) Message-Id: <201908102308.x7AN8aXK091682@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mckusick set sender to mckusick@FreeBSD.org using -f From: Kirk McKusick Date: Sat, 10 Aug 2019 23:08:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r350852 - in stable/11/sbin: fsck_ffs newfs X-SVN-Group: stable-11 X-SVN-Commit-Author: mckusick X-SVN-Commit-Paths: in stable/11/sbin: fsck_ffs newfs X-SVN-Commit-Revision: 350852 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Aug 2019 23:08:36 -0000 Author: mckusick Date: Sat Aug 10 23:08:35 2019 New Revision: 350852 URL: https://svnweb.freebsd.org/changeset/base/350852 Log: MFC of 350682 Correct first superblock backup location in fsck_ffs.8. Modified: stable/11/sbin/fsck_ffs/fsck_ffs.8 stable/11/sbin/newfs/newfs.8 Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/fsck_ffs/fsck_ffs.8 ============================================================================== --- stable/11/sbin/fsck_ffs/fsck_ffs.8 Sat Aug 10 23:06:52 2019 (r350851) +++ stable/11/sbin/fsck_ffs/fsck_ffs.8 Sat Aug 10 23:08:35 2019 (r350852) @@ -29,7 +29,7 @@ .\" @(#)fsck.8 8.4 (Berkeley) 5/9/95 .\" $FreeBSD$ .\" -.Dd May 3, 2019 +.Dd August 10, 2019 .Dt FSCK_FFS 8 .Os .Sh NAME @@ -153,7 +153,7 @@ exits without attempting any further cleaning. Use the block specified immediately after the flag as the super block for the file system. An alternate super block is usually located at block 32 for UFS1, -and block 160 for UFS2. +and block 192 for UFS2. .Pp See the .Fl N Modified: stable/11/sbin/newfs/newfs.8 ============================================================================== --- stable/11/sbin/newfs/newfs.8 Sat Aug 10 23:06:52 2019 (r350851) +++ stable/11/sbin/newfs/newfs.8 Sat Aug 10 23:08:35 2019 (r350852) @@ -113,6 +113,9 @@ for more details on how to set this option. .It Fl b Ar block-size The block size of the file system, in bytes. It must be a power of 2. +.\" If changing the default block size and it causes the default +.\" fragment size to change, be sure to update the location of +.\" the first backup superblock on the fsck_ffs.8 manual page. The default size is 32768 bytes, and the smallest allowable size is 4096 bytes. The optimal block:fragment ratio is 8:1. @@ -145,6 +148,9 @@ ranging in value between .Ar blocksize Ns /8 and .Ar blocksize . +.\" If changing the default fragment size or it changes because of a +.\" change to the default block size, be sure to update the location +.\" of the first backup superblock on the fsck_ffs.8 manual page. The default is 4096 bytes. .It Fl g Ar avgfilesize The expected average file size for the file system.