From owner-svn-src-stable-12@freebsd.org Sun Aug 25 00:55:42 2019 Return-Path: Delivered-To: svn-src-stable-12@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 8D201D09DE; Sun, 25 Aug 2019 00:55:42 +0000 (UTC) (envelope-from eugen@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 46GGsB3CvNz4M7R; Sun, 25 Aug 2019 00:55:42 +0000 (UTC) (envelope-from eugen@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 50D3CD9F8; Sun, 25 Aug 2019 00:55:42 +0000 (UTC) (envelope-from eugen@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x7P0tgBp064243; Sun, 25 Aug 2019 00:55:42 GMT (envelope-from eugen@FreeBSD.org) Received: (from eugen@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7P0tgam064242; Sun, 25 Aug 2019 00:55:42 GMT (envelope-from eugen@FreeBSD.org) Message-Id: <201908250055.x7P0tgam064242@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: eugen set sender to eugen@FreeBSD.org using -f From: Eugene Grosbein Date: Sun, 25 Aug 2019 00:55:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r351465 - stable/12/release/picobsd/tinyware/simple_httpd X-SVN-Group: stable-12 X-SVN-Commit-Author: eugen X-SVN-Commit-Paths: stable/12/release/picobsd/tinyware/simple_httpd X-SVN-Commit-Revision: 351465 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-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Aug 2019 00:55:42 -0000 Author: eugen Date: Sun Aug 25 00:55:41 2019 New Revision: 351465 URL: https://svnweb.freebsd.org/changeset/base/351465 Log: MFC r351179: simple_httpd was not buildable for some time due to multiple missing "static" keywords and -Werror,-Wmissing-variable-declarations This change adds needed "static" so it builds again with WARNS?=6 No functional changes. Modified: stable/12/release/picobsd/tinyware/simple_httpd/simple_httpd.c Directory Properties: stable/12/ (props changed) Modified: stable/12/release/picobsd/tinyware/simple_httpd/simple_httpd.c ============================================================================== --- stable/12/release/picobsd/tinyware/simple_httpd/simple_httpd.c Sat Aug 24 22:07:38 2019 (r351464) +++ stable/12/release/picobsd/tinyware/simple_httpd/simple_httpd.c Sun Aug 25 00:55:41 2019 (r351465) @@ -48,33 +48,33 @@ #include #include -int http_port = 80; -int daemonize = 1; -int verbose = 0; -int http_sock, con_sock; +static int http_port = 80; +static int daemonize = 1; +static int verbose = 0; +static int http_sock, con_sock; -const char *fetch_mode = NULL; -char homedir[100]; -char logfile[80]; -char *adate(void); -void init_servconnection(void); -void http_date(void); -void http_output(const char *html); -void http_request(void); -void log_line(char *req); -void wait_connection(void); +static const char *fetch_mode = NULL; +static char homedir[100]; +static char logfile[80]; +static char *adate(void); +static void init_servconnection(void); +static void http_date(void); +static void http_output(const char *html); +static void http_request(void); +static void log_line(char *req); +static void wait_connection(void); -struct hostent *hst; -struct sockaddr_in source; +static struct hostent *hst; +static struct sockaddr_in source; /* HTTP basics */ static char httpd_server_ident[] = "Server: FreeBSD/PicoBSD simple_httpd 1.1\r"; static char http_200[] = "HTTP/1.0 200 OK\r"; -const char *default_mime_type = "application/octet-stream"; +static const char *default_mime_type = "application/octet-stream"; -const char *mime_type[][2] = { +static const char *mime_type[][2] = { { "txt", "text/plain" }, { "htm", "text/html" }, { "html", "text/html" }, @@ -83,7 +83,7 @@ const char *mime_type[][2] = { { "mp3", "audio/mpeg" } }; -const int mime_type_max = sizeof(mime_type) / sizeof(mime_type[0]) - 1; +static const int mime_type_max = sizeof(mime_type) / sizeof(mime_type[0]) - 1; /* Two parts, HTTP Header and then HTML */ static const char *http_404[2] = @@ -101,7 +101,7 @@ This server only supports GET and HEAD requests.\n Delivered-To: svn-src-stable-12@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 43A21D0EAD; Sun, 25 Aug 2019 01:09:32 +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 46GH9818fbz4Mvk; Sun, 25 Aug 2019 01:09:32 +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 094E4DBE1; Sun, 25 Aug 2019 01:09:32 +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 x7P19VT6070520; Sun, 25 Aug 2019 01:09:31 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7P19VPW070519; Sun, 25 Aug 2019 01:09:31 GMT (envelope-from cy@FreeBSD.org) Message-Id: <201908250109.x7P19VPW070519@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Sun, 25 Aug 2019 01:09:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r351468 - in stable: 10/sys/contrib/ipfilter/netinet 11/sys/contrib/ipfilter/netinet 12/sys/contrib/ipfilter/netinet X-SVN-Group: stable-12 X-SVN-Commit-Author: cy X-SVN-Commit-Paths: in stable: 10/sys/contrib/ipfilter/netinet 11/sys/contrib/ipfilter/netinet 12/sys/contrib/ipfilter/netinet X-SVN-Commit-Revision: 351468 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-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Aug 2019 01:09:32 -0000 Author: cy Date: Sun Aug 25 01:09:31 2019 New Revision: 351468 URL: https://svnweb.freebsd.org/changeset/base/351468 Log: MFC r351380: Specifying array sizes for fully initialized tables at compile time is redundant. Modified: stable/12/sys/contrib/ipfilter/netinet/fil.c Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Modified: stable/10/sys/contrib/ipfilter/netinet/fil.c stable/11/sys/contrib/ipfilter/netinet/fil.c Directory Properties: stable/10/ (props changed) stable/11/ (props changed) Modified: stable/12/sys/contrib/ipfilter/netinet/fil.c ============================================================================== --- stable/12/sys/contrib/ipfilter/netinet/fil.c Sun Aug 25 01:05:01 2019 (r351467) +++ stable/12/sys/contrib/ipfilter/netinet/fil.c Sun Aug 25 01:09:31 2019 (r351468) @@ -194,7 +194,7 @@ static int ppsratecheck(struct timeval *, int *, int) * hand side to allow for binary searching of the array and include a trailer * with a 0 for the bitmask for linear searches to easily find the end with. */ -static const struct optlist ipopts[20] = { +static const struct optlist ipopts[] = { { IPOPT_NOP, 0x000001 }, { IPOPT_RR, 0x000002 }, { IPOPT_ZSU, 0x000004 }, @@ -235,7 +235,7 @@ static const struct optlist ip6exthdr[] = { /* * bit values for identifying presence of individual IP security options */ -static const struct optlist secopt[8] = { +static const struct optlist secopt[] = { { IPSO_CLASS_RES4, 0x01 }, { IPSO_CLASS_TOPS, 0x02 }, { IPSO_CLASS_SECR, 0x04 }, From owner-svn-src-stable-12@freebsd.org Sun Aug 25 04:56:35 2019 Return-Path: Delivered-To: svn-src-stable-12@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 444F4D521E; Sun, 25 Aug 2019 04:56:35 +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 46GNC714vbz4X5Z; Sun, 25 Aug 2019 04:56:35 +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 06C5F1862B; Sun, 25 Aug 2019 04:56:35 +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 x7P4uYjp006486; Sun, 25 Aug 2019 04:56:34 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7P4uYr1006484; Sun, 25 Aug 2019 04:56:34 GMT (envelope-from cy@FreeBSD.org) Message-Id: <201908250456.x7P4uYr1006484@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Sun, 25 Aug 2019 04:56:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r351470 - in stable: 11/sys/contrib/ipfilter/netinet 12/sys/contrib/ipfilter/netinet X-SVN-Group: stable-12 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: 351470 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-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Aug 2019 04:56:35 -0000 Author: cy Date: Sun Aug 25 04:56:33 2019 New Revision: 351470 URL: https://svnweb.freebsd.org/changeset/base/351470 Log: MFC r350880: r272552 applied the patch from ipfilter upstream fil.c r1.129 to fix broken ipfilter rule matches (upstream bug #554). The upstream patch was incomplete, it resolved all but one rule compare issue. The issue fixed here is when "{to, reply-to, dup-to} interface" are used in conjuncion with "on interface". The match was only made if the on keyword was specified in the same order in each case referencing the same rule. This commit fixes this. The reason for this is that interface name strings and comment keyword comments are stored in a a variable length field starting at fr_names in the frentry struct. These strings are placed into this variable length in the order they are encountered by ipf_y.y and indexed through index pointers in fr_ifnames, fr_comment or one of the frdest struct fd_name fields. (Three frdest structs are within frentry.) Order matters and this patch takes this into account. While in here it was discovered that though ipfilter is designed to pport multiple interface specifiations per rule (up to four), this undocumented (the man page makes no mention of it) feature does not work. A todo is to fix the multiple interfaces feature at a later date. To understand the design decision as to why only four were intended, it is suspected that the decision was made because Sun workstations and PCs rarely if ever exceeded four NICs at the time, this is not true in 2019. PR: 238796 Reported by: WHR Modified: stable/12/sys/contrib/ipfilter/netinet/fil.c stable/12/sys/contrib/ipfilter/netinet/ip_fil.h Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Modified: stable/11/sys/contrib/ipfilter/netinet/fil.c stable/11/sys/contrib/ipfilter/netinet/ip_fil.h Directory Properties: stable/11/ (props changed) Modified: stable/12/sys/contrib/ipfilter/netinet/fil.c ============================================================================== --- stable/12/sys/contrib/ipfilter/netinet/fil.c Sun Aug 25 02:38:45 2019 (r351469) +++ stable/12/sys/contrib/ipfilter/netinet/fil.c Sun Aug 25 04:56:33 2019 (r351470) @@ -4418,6 +4418,28 @@ ipf_matchicmpqueryreply(v, ic, icmp, rev) } +/* + * IFNAMES are located in the variable length field starting at + * frentry.fr_names. As pointers within the struct cannot be passed + * to the kernel from ipf(8), an offset is used. An offset of -1 means it + * is unused (invalid). If it is used (valid) it is an offset to the + * character string of an interface name or a comment. The following + * macros will assist those who follow to understand the code. + */ +#define IPF_IFNAME_VALID(_a) (_a != -1) +#define IPF_IFNAME_INVALID(_a) (_a == -1) +#define IPF_IFNAMES_DIFFERENT(_a) \ + !((IPF_IFNAME_INVALID(fr1->_a) && \ + IPF_IFNAME_INVALID(fr2->_a)) || \ + (IPF_IFNAME_VALID(fr1->_a) && \ + IPF_IFNAME_VALID(fr2->_a) && \ + !strcmp(FR_NAME(fr1, _a), FR_NAME(fr2, _a)))) +#define IPF_FRDEST_DIFFERENT(_a) \ + (memcmp(&fr1->_a.fd_addr, &fr2->_a.fd_addr, \ + offsetof(frdest_t, fd_name) - offsetof(frdest_t, fd_addr)) || \ + IPF_IFNAMES_DIFFERENT(_a.fd_name)) + + /* ------------------------------------------------------------------------ */ /* Function: ipf_rule_compare */ /* Parameters: fr1(I) - first rule structure to compare */ @@ -4430,22 +4452,50 @@ ipf_matchicmpqueryreply(v, ic, icmp, rev) static int ipf_rule_compare(frentry_t *fr1, frentry_t *fr2) { + int i; + if (fr1->fr_cksum != fr2->fr_cksum) return (1); if (fr1->fr_size != fr2->fr_size) return (2); if (fr1->fr_dsize != fr2->fr_dsize) return (3); - if (bcmp((char *)&fr1->fr_func, (char *)&fr2->fr_func, FR_CMPSIZ(fr1)) + if (bcmp((char *)&fr1->fr_func, (char *)&fr2->fr_func, FR_CMPSIZ) != 0) return (4); + /* + * XXX: There is still a bug here as different rules with the + * the same interfaces but in a different order will compare + * differently. But since multiple interfaces in a rule doesn't + * work anyway a simple straightforward compare is performed + * here. Ultimately frentry_t creation will need to be + * revisited in ipf_y.y. While the other issue, recognition + * of only the first interface in a list of interfaces will + * need to be separately addressed along with why only four. + */ + for (i = 0; i < FR_NUM(fr1->fr_ifnames); i++) { + /* + * XXX: It's either the same index or uninitialized. + * We assume this because multiple interfaces + * referenced by the same rule doesn't work anyway. + */ + if (IPF_IFNAMES_DIFFERENT(fr_ifnames[i])) + return(5); + } + + if (IPF_FRDEST_DIFFERENT(fr_tif)) + return (6); + if (IPF_FRDEST_DIFFERENT(fr_rif)) + return (7); + if (IPF_FRDEST_DIFFERENT(fr_dif)) + return (8); if (!fr1->fr_data && !fr2->fr_data) return (0); /* move along, nothing to see here */ if (fr1->fr_data && fr2->fr_data) { if (bcmp(fr1->fr_caddr, fr2->fr_caddr, fr1->fr_dsize) == 0) return (0); /* same */ } - return (5); + return (9); } Modified: stable/12/sys/contrib/ipfilter/netinet/ip_fil.h ============================================================================== --- stable/12/sys/contrib/ipfilter/netinet/ip_fil.h Sun Aug 25 02:38:45 2019 (r351469) +++ stable/12/sys/contrib/ipfilter/netinet/ip_fil.h Sun Aug 25 04:56:33 2019 (r351470) @@ -735,12 +735,9 @@ typedef struct frentry { u_char fr_icode; /* return ICMP code */ int fr_group; /* group to which this rule belongs */ int fr_grhead; /* group # which this rule starts */ - int fr_ifnames[4]; int fr_isctag; int fr_rpc; /* XID Filtering */ ipftag_t fr_nattag; - frdest_t fr_tifs[2]; /* "to"/"reply-to" interface */ - frdest_t fr_dif; /* duplicate packet interface */ /* * These are all options related to stateful filtering */ @@ -750,6 +747,12 @@ typedef struct frentry { int fr_icmphead; /* ICMP group for state options */ u_int fr_age[2]; /* non-TCP state timeouts */ /* + * These are compared separately. + */ + int fr_ifnames[4]; + frdest_t fr_tifs[2]; /* "to"/"reply-to" interface */ + frdest_t fr_dif; /* duplicate packet interface */ + /* * How big is the name buffer at the end? */ int fr_namelen; @@ -827,9 +830,10 @@ typedef struct frentry { #define FR_NOLOGTAG 0 -#define FR_CMPSIZ(_f) ((_f)->fr_size - \ - offsetof(struct frentry, fr_func)) +#define FR_CMPSIZ (offsetof(struct frentry, fr_ifnames) - \ + offsetof(struct frentry, fr_func)) #define FR_NAME(_f, _n) (_f)->fr_names + (_f)->_n +#define FR_NUM(_a) (sizeof(_a) / sizeof(*_a)) /* From owner-svn-src-stable-12@freebsd.org Sun Aug 25 06:14:01 2019 Return-Path: Delivered-To: svn-src-stable-12@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 91D37D6637; Sun, 25 Aug 2019 06:14:01 +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 46GPwT39vZz4b1n; Sun, 25 Aug 2019 06:14:01 +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 4EFEF194A1; Sun, 25 Aug 2019 06:14:01 +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 x7P6E1dl052896; Sun, 25 Aug 2019 06:14:01 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7P6E0gR052894; Sun, 25 Aug 2019 06:14:00 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201908250614.x7P6E0gR052894@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sun, 25 Aug 2019 06:14:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r351473 - in stable/12: share/man/man9 sys/i386/include X-SVN-Group: stable-12 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: in stable/12: share/man/man9 sys/i386/include X-SVN-Commit-Revision: 351473 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-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Aug 2019 06:14:01 -0000 Author: kib Date: Sun Aug 25 06:14:00 2019 New Revision: 351473 URL: https://svnweb.freebsd.org/changeset/base/351473 Log: MFC r351190: i386: Implement atomic_load_64(9) and atomic_store_64(9). Modified: stable/12/share/man/man9/atomic.9 stable/12/sys/i386/include/atomic.h Directory Properties: stable/12/ (props changed) Modified: stable/12/share/man/man9/atomic.9 ============================================================================== --- stable/12/share/man/man9/atomic.9 Sun Aug 25 05:13:15 2019 (r351472) +++ stable/12/share/man/man9/atomic.9 Sun Aug 25 06:14:00 2019 (r351473) @@ -23,7 +23,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 22, 2017 +.Dd August 18, 2019 .Dt ATOMIC 9 .Os .Sh NAME @@ -478,7 +478,7 @@ and do not have any variants with memory barriers at t .Pp The type .Dq Li 64 -is currently not implemented for any of the atomic operations on the +is currently not implemented for some of the atomic operations on the .Tn arm , .Tn i386 , and Modified: stable/12/sys/i386/include/atomic.h ============================================================================== --- stable/12/sys/i386/include/atomic.h Sun Aug 25 05:13:15 2019 (r351472) +++ stable/12/sys/i386/include/atomic.h Sun Aug 25 06:14:00 2019 (r351473) @@ -891,6 +891,8 @@ u_long atomic_swap_long(volatile u_long *p, u_long v); #define atomic_add_rel_64 atomic_add_64 #define atomic_subtract_acq_64 atomic_subtract_64 #define atomic_subtract_rel_64 atomic_subtract_64 +#define atomic_load_64 atomic_load_acq_64 +#define atomic_store_64 atomic_store_rel_64 /* Operations on pointers. */ #define atomic_set_ptr(p, v) \ From owner-svn-src-stable-12@freebsd.org Sun Aug 25 06:19:53 2019 Return-Path: Delivered-To: svn-src-stable-12@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 5CE66D670F; Sun, 25 Aug 2019 06:19:53 +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 46GQ3F06n2z4b97; Sun, 25 Aug 2019 06:19:53 +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 D3383194A3; Sun, 25 Aug 2019 06:19:52 +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 x7P6JqFf053201; Sun, 25 Aug 2019 06:19:52 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7P6Jq1m053198; Sun, 25 Aug 2019 06:19:52 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201908250619.x7P6Jq1m053198@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sun, 25 Aug 2019 06:19:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r351474 - in stable/12/sys: compat/linux kern vm X-SVN-Group: stable-12 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: in stable/12/sys: compat/linux kern vm X-SVN-Commit-Revision: 351474 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-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Aug 2019 06:19:53 -0000 Author: kib Date: Sun Aug 25 06:19:51 2019 New Revision: 351474 URL: https://svnweb.freebsd.org/changeset/base/351474 Log: MFC r351194: Change locking requirements for VOP_UNSET_TEXT(). Modified: stable/12/sys/compat/linux/linux_misc.c stable/12/sys/kern/vnode_if.src stable/12/sys/vm/vm_map.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/compat/linux/linux_misc.c ============================================================================== --- stable/12/sys/compat/linux/linux_misc.c Sun Aug 25 06:14:00 2019 (r351473) +++ stable/12/sys/compat/linux/linux_misc.c Sun Aug 25 06:19:51 2019 (r351474) @@ -494,8 +494,13 @@ cleanup: locked = false; VOP_CLOSE(vp, FREAD, td->td_ucred, td); } - if (textset) + if (textset) { + if (!locked) { + locked = true; + VOP_LOCK(vp, LK_SHARED | LK_RETRY); + } VOP_UNSET_TEXT_CHECKED(vp); + } if (locked) VOP_UNLOCK(vp, 0); Modified: stable/12/sys/kern/vnode_if.src ============================================================================== --- stable/12/sys/kern/vnode_if.src Sun Aug 25 06:14:00 2019 (r351473) +++ stable/12/sys/kern/vnode_if.src Sun Aug 25 06:19:51 2019 (r351474) @@ -695,7 +695,7 @@ vop_set_text { }; -%% vop_unset_text vp = = = +%% vop_unset_text vp L L L vop_unset_text { IN struct vnode *vp; Modified: stable/12/sys/vm/vm_map.c ============================================================================== --- stable/12/sys/vm/vm_map.c Sun Aug 25 06:14:00 2019 (r351473) +++ stable/12/sys/vm/vm_map.c Sun Aug 25 06:19:51 2019 (r351474) @@ -546,12 +546,20 @@ vm_map_entry_set_vnode_text(vm_map_entry_t entry, bool "entry %p, object %p, add %d", entry, object, add)); } if (vp != NULL) { - if (add) + if (add) { VOP_SET_TEXT_CHECKED(vp); - else + VM_OBJECT_RUNLOCK(object); + } else { + vhold(vp); + VM_OBJECT_RUNLOCK(object); + vn_lock(vp, LK_SHARED | LK_RETRY); VOP_UNSET_TEXT_CHECKED(vp); + VOP_UNLOCK(vp, 0); + vdrop(vp); + } + } else { + VM_OBJECT_RUNLOCK(object); } - VM_OBJECT_RUNLOCK(object); } static void From owner-svn-src-stable-12@freebsd.org Sun Aug 25 06:22:15 2019 Return-Path: Delivered-To: svn-src-stable-12@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 1F351D67E4; Sun, 25 Aug 2019 06:22:15 +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 46GQ5y75Bwz4bV9; Sun, 25 Aug 2019 06:22:14 +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 D64AD19663; Sun, 25 Aug 2019 06:22:14 +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 x7P6MEAT058758; Sun, 25 Aug 2019 06:22:14 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7P6ME5w058754; Sun, 25 Aug 2019 06:22:14 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201908250622.x7P6ME5w058754@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sun, 25 Aug 2019 06:22:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r351475 - in stable/12/sys: fs/tmpfs kern sys X-SVN-Group: stable-12 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: in stable/12/sys: fs/tmpfs kern sys X-SVN-Commit-Revision: 351475 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-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Aug 2019 06:22:15 -0000 Author: kib Date: Sun Aug 25 06:22:13 2019 New Revision: 351475 URL: https://svnweb.freebsd.org/changeset/base/351475 Log: MFC r351195: Fix an issue with executing tmpfs binary. Modified: stable/12/sys/fs/tmpfs/tmpfs_vfsops.c stable/12/sys/kern/vfs_default.c stable/12/sys/sys/mount.h stable/12/sys/sys/vnode.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/fs/tmpfs/tmpfs_vfsops.c ============================================================================== --- stable/12/sys/fs/tmpfs/tmpfs_vfsops.c Sun Aug 25 06:19:51 2019 (r351474) +++ stable/12/sys/fs/tmpfs/tmpfs_vfsops.c Sun Aug 25 06:22:13 2019 (r351475) @@ -504,7 +504,8 @@ tmpfs_mount(struct mount *mp) MNT_ILOCK(mp); mp->mnt_flag |= MNT_LOCAL; - mp->mnt_kern_flag |= MNTK_LOOKUP_SHARED | MNTK_EXTENDED_SHARED; + mp->mnt_kern_flag |= MNTK_LOOKUP_SHARED | MNTK_EXTENDED_SHARED | + MNTK_TEXT_REFS; MNT_IUNLOCK(mp); mp->mnt_data = tmp; Modified: stable/12/sys/kern/vfs_default.c ============================================================================== --- stable/12/sys/kern/vfs_default.c Sun Aug 25 06:19:51 2019 (r351474) +++ stable/12/sys/kern/vfs_default.c Sun Aug 25 06:22:13 2019 (r351475) @@ -1068,6 +1068,7 @@ int vop_stdset_text(struct vop_set_text_args *ap) { struct vnode *vp; + struct mount *mp; int error; vp = ap->a_vp; @@ -1075,6 +1076,17 @@ vop_stdset_text(struct vop_set_text_args *ap) if (vp->v_writecount > 0) { error = ETXTBSY; } else { + /* + * If requested by fs, keep a use reference to the + * vnode until the last text reference is released. + */ + mp = vp->v_mount; + if (mp != NULL && (mp->mnt_kern_flag & MNTK_TEXT_REFS) != 0 && + vp->v_writecount == 0) { + vp->v_iflag |= VI_TEXT_REF; + vrefl(vp); + } + vp->v_writecount--; error = 0; } @@ -1087,16 +1099,25 @@ vop_stdunset_text(struct vop_unset_text_args *ap) { struct vnode *vp; int error; + bool last; vp = ap->a_vp; + last = false; VI_LOCK(vp); if (vp->v_writecount < 0) { + if ((vp->v_iflag & VI_TEXT_REF) != 0 && + vp->v_writecount == -1) { + last = true; + vp->v_iflag &= ~VI_TEXT_REF; + } vp->v_writecount++; error = 0; } else { error = EINVAL; } VI_UNLOCK(vp); + if (last) + vunref(vp); return (error); } Modified: stable/12/sys/sys/mount.h ============================================================================== --- stable/12/sys/sys/mount.h Sun Aug 25 06:19:51 2019 (r351474) +++ stable/12/sys/sys/mount.h Sun Aug 25 06:22:13 2019 (r351475) @@ -398,6 +398,7 @@ void __mnt_vnode_markerfree_active(struct vno #define MNTK_MARKER 0x00001000 #define MNTK_UNMAPPED_BUFS 0x00002000 #define MNTK_USES_BCACHE 0x00004000 /* FS uses the buffer cache. */ +#define MNTK_TEXT_REFS 0x00008000 /* Keep use ref for text */ #define MNTK_NOASYNC 0x00800000 /* disable async */ #define MNTK_UNMOUNT 0x01000000 /* unmount in progress */ #define MNTK_MWAIT 0x02000000 /* waiting for unmount to finish */ Modified: stable/12/sys/sys/vnode.h ============================================================================== --- stable/12/sys/sys/vnode.h Sun Aug 25 06:19:51 2019 (r351474) +++ stable/12/sys/sys/vnode.h Sun Aug 25 06:22:13 2019 (r351475) @@ -233,6 +233,7 @@ struct xvnode { * VI_DOOMED is doubly protected by the interlock and vnode lock. Both * are required for writing but the status may be checked with either. */ +#define VI_TEXT_REF 0x0001 /* Text ref grabbed use ref */ #define VI_MOUNT 0x0020 /* Mount in progress */ #define VI_DOOMED 0x0080 /* This vnode is being recycled */ #define VI_FREE 0x0100 /* This vnode is on the freelist */ From owner-svn-src-stable-12@freebsd.org Sun Aug 25 13:36:22 2019 Return-Path: Delivered-To: svn-src-stable-12@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 2E1DCE0131; Sun, 25 Aug 2019 13:36:22 +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 46Gbkt0RCNz3yGG; Sun, 25 Aug 2019 13:36:22 +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 E4C251E48E; Sun, 25 Aug 2019 13:36:21 +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 x7PDaLwU013881; Sun, 25 Aug 2019 13:36:21 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7PDaLwd013878; Sun, 25 Aug 2019 13:36:21 GMT (envelope-from cy@FreeBSD.org) Message-Id: <201908251336.x7PDaLwd013878@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Sun, 25 Aug 2019 13:36:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r351479 - in stable: 11/sys/contrib/ipfilter/netinet 12/sys/contrib/ipfilter/netinet X-SVN-Group: stable-12 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: 351479 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-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Aug 2019 13:36:22 -0000 Author: cy Date: Sun Aug 25 13:36:20 2019 New Revision: 351479 URL: https://svnweb.freebsd.org/changeset/base/351479 Log: MFC r350881: Calculate the number interface array elements using the new FR_NUM macro instead of the hard-coded value of 4. This is a precursor to increasing the number of interfaces speficied in "on {interface, ..., interface}". Note that though this feature is coded in ipf_y.y, it is partially supported in the ipfilter kld, meaning it does not work yet (and is yet to be documented in ipf.5 too). Modified: stable/12/sys/contrib/ipfilter/netinet/fil.c stable/12/sys/contrib/ipfilter/netinet/ip_state.c Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Modified: stable/11/sys/contrib/ipfilter/netinet/fil.c stable/11/sys/contrib/ipfilter/netinet/ip_state.c Directory Properties: stable/11/ (props changed) Modified: stable/12/sys/contrib/ipfilter/netinet/fil.c ============================================================================== --- stable/12/sys/contrib/ipfilter/netinet/fil.c Sun Aug 25 13:26:06 2019 (r351478) +++ stable/12/sys/contrib/ipfilter/netinet/fil.c Sun Aug 25 13:36:20 2019 (r351479) @@ -4023,7 +4023,7 @@ ipf_synclist(softc, fr, ifp) /* * Lookup all the interface names that are part of the rule. */ - for (i = 0; i < 4; i++) { + for (i = 0; i < FR_NUM(fr->fr_ifas); i++) { if ((ifp != NULL) && (fr->fr_ifas[i] != ifp)) continue; if (fr->fr_ifnames[i] == -1) Modified: stable/12/sys/contrib/ipfilter/netinet/ip_state.c ============================================================================== --- stable/12/sys/contrib/ipfilter/netinet/ip_state.c Sun Aug 25 13:26:06 2019 (r351478) +++ stable/12/sys/contrib/ipfilter/netinet/ip_state.c Sun Aug 25 13:36:20 2019 (r351479) @@ -975,7 +975,7 @@ ipf_state_putent(softc, softs, data) /* * Look up all the interface names in the rule. */ - for (i = 0; i < 4; i++) { + for (i = 0; i < FR_NUM(fr->fr_ifnames); i++) { if (fr->fr_ifnames[i] == -1) { fr->fr_ifas[i] = NULL; continue; @@ -985,7 +985,7 @@ ipf_state_putent(softc, softs, data) fr->fr_family); } - for (i = 0; i < 4; i++) { + for (i = 0; i < FR_NUM(isn->is_ifname); i++) { name = isn->is_ifname[i]; isn->is_ifp[i] = ipf_resolvenic(softc, name, isn->is_v); @@ -1076,7 +1076,7 @@ ipf_state_insert(softc, is, rev) /* * Look up all the interface names in the state entry. */ - for (i = 0; i < 4; i++) { + for (i = 0; i < FR_NUM(is->is_ifp); i++) { if (is->is_ifp[i] != NULL) continue; is->is_ifp[i] = ipf_resolvenic(softc, is->is_ifname[i], @@ -3574,7 +3574,7 @@ ipf_state_sync(softc, ifp) /* * Look up all the interface names in the state entry. */ - for (i = 0; i < 4; i++) { + for (i = 0; i < FR_NUM(is->is_ifp); i++) { if (ifp == NULL || ifp == is->is_ifp[i]) is->is_ifp[i] = ipf_resolvenic(softc, is->is_ifname[i], From owner-svn-src-stable-12@freebsd.org Mon Aug 26 08:06:19 2019 Return-Path: Delivered-To: svn-src-stable-12@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 9A79CD3FD4; Mon, 26 Aug 2019 08:06:19 +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 46H4Mb3dbZz447J; Mon, 26 Aug 2019 08:06:19 +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 5E33C2ED2; Mon, 26 Aug 2019 08:06:19 +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 x7Q86JMa083526; Mon, 26 Aug 2019 08:06:19 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7Q86Jcg083525; Mon, 26 Aug 2019 08:06:19 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201908260806.x7Q86Jcg083525@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Mon, 26 Aug 2019 08:06:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r351503 - stable/12/tests/sys/kern X-SVN-Group: stable-12 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/12/tests/sys/kern X-SVN-Commit-Revision: 351503 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-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Aug 2019 08:06:19 -0000 Author: kib Date: Mon Aug 26 08:06:18 2019 New Revision: 351503 URL: https://svnweb.freebsd.org/changeset/base/351503 Log: MFC r351210: sys.kern.pdeathsig.signal_delivered_ptrace: fix debugger detach PR: 237657 Modified: stable/12/tests/sys/kern/pdeathsig.c Directory Properties: stable/12/ (props changed) Modified: stable/12/tests/sys/kern/pdeathsig.c ============================================================================== --- stable/12/tests/sys/kern/pdeathsig.c Mon Aug 26 06:41:17 2019 (r351502) +++ stable/12/tests/sys/kern/pdeathsig.c Mon Aug 26 08:06:18 2019 (r351503) @@ -305,7 +305,9 @@ ATF_TC_BODY(signal_delivered_ptrace, tc) WSTOPSIG(status)); assert(rc == 0); - ptrace(PT_DETACH, c_pid, 0, 0); + waitpid(c_pid, &status, 0); + if (!WIFEXITED(status)) + ptrace(PT_DETACH, c_pid, 0, 0); _exit(0); } From owner-svn-src-stable-12@freebsd.org Mon Aug 26 08:07:10 2019 Return-Path: Delivered-To: svn-src-stable-12@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 E9B5DD405A; Mon, 26 Aug 2019 08:07:10 +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 46H4NZ5pgWz44Fm; Mon, 26 Aug 2019 08:07:10 +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 A8F9B2EDB; Mon, 26 Aug 2019 08:07:10 +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 x7Q87A5M083644; Mon, 26 Aug 2019 08:07:10 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7Q87AUW083643; Mon, 26 Aug 2019 08:07:10 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201908260807.x7Q87AUW083643@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Mon, 26 Aug 2019 08:07:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r351504 - stable/12/tests/sys/kern X-SVN-Group: stable-12 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/12/tests/sys/kern X-SVN-Commit-Revision: 351504 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-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Aug 2019 08:07:11 -0000 Author: kib Date: Mon Aug 26 08:07:10 2019 New Revision: 351504 URL: https://svnweb.freebsd.org/changeset/base/351504 Log: MFC r351211: sys.kern.pdeathsig.signal_delivered_ptrace: fix startup. PR: 237657 Modified: stable/12/tests/sys/kern/pdeathsig.c Directory Properties: stable/12/ (props changed) Modified: stable/12/tests/sys/kern/pdeathsig.c ============================================================================== --- stable/12/tests/sys/kern/pdeathsig.c Mon Aug 26 08:06:18 2019 (r351503) +++ stable/12/tests/sys/kern/pdeathsig.c Mon Aug 26 08:07:10 2019 (r351504) @@ -229,6 +229,7 @@ ATF_TC_BODY(signal_delivered_ptrace, tc) int rc; int pipe_ca[2]; int pipe_db[2]; + int pipe_cd[2]; char buffer; int status; @@ -236,6 +237,8 @@ ATF_TC_BODY(signal_delivered_ptrace, tc) ATF_REQUIRE(rc == 0); rc = pipe(pipe_db); ATF_REQUIRE(rc == 0); + rc = pipe(pipe_cd); + assert(rc == 0); rc = fork(); ATF_REQUIRE(rc != -1); @@ -263,6 +266,9 @@ ATF_TC_BODY(signal_delivered_ptrace, tc) rc = procctl(P_PID, 0, PROC_PDEATHSIG_CTL, &signum); assert(rc == 0); + rc = write(pipe_cd[1], "x", 1); + assert(rc == 1); + /* wait for B to die and signal us... */ signum = 0xdeadbeef; rc = sigwait(&sigset, &signum); @@ -292,6 +298,9 @@ ATF_TC_BODY(signal_delivered_ptrace, tc) rc = ptrace(PT_CONTINUE, c_pid, (caddr_t) 1, 0); assert(rc == 0); + + rc = read(pipe_cd[0], &buffer, 1); + assert(rc == 1); /* tell B that we're ready for it to exit now */ rc = write(pipe_db[1], ".", 1); From owner-svn-src-stable-12@freebsd.org Mon Aug 26 09:29:15 2019 Return-Path: Delivered-To: svn-src-stable-12@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 9291AD5AE1; Mon, 26 Aug 2019 09:29:15 +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 46H6CH3B0Pz48Jm; Mon, 26 Aug 2019 09:29:15 +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 4A69F3FA0; Mon, 26 Aug 2019 09:29:15 +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 x7Q9TFio031703; Mon, 26 Aug 2019 09:29:15 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7Q9TF12031702; Mon, 26 Aug 2019 09:29:15 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201908260929.x7Q9TF12031702@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Mon, 26 Aug 2019 09:29:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r351507 - stable/12/sys/kern X-SVN-Group: stable-12 X-SVN-Commit-Author: ae X-SVN-Commit-Paths: stable/12/sys/kern X-SVN-Commit-Revision: 351507 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-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Aug 2019 09:29:15 -0000 Author: ae Date: Mon Aug 26 09:29:14 2019 New Revision: 351507 URL: https://svnweb.freebsd.org/changeset/base/351507 Log: MFC r351214: Use TAILQ_FOREACH_SAFE() macro to avoid use after free in soclose(). PR: 239893 Modified: stable/12/sys/kern/uipc_socket.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/kern/uipc_socket.c ============================================================================== --- stable/12/sys/kern/uipc_socket.c Mon Aug 26 08:08:15 2019 (r351506) +++ stable/12/sys/kern/uipc_socket.c Mon Aug 26 09:29:14 2019 (r351507) @@ -1131,9 +1131,9 @@ drop: so->so_state |= SS_NOFDREF; sorele(so); if (listening) { - struct socket *sp; + struct socket *sp, *tsp; - TAILQ_FOREACH(sp, &lqueue, so_list) { + TAILQ_FOREACH_SAFE(sp, &lqueue, so_list, tsp) { SOCK_LOCK(sp); if (sp->so_count == 0) { SOCK_UNLOCK(sp); From owner-svn-src-stable-12@freebsd.org Mon Aug 26 15:21:30 2019 Return-Path: Delivered-To: svn-src-stable-12@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 2A972DE209; Mon, 26 Aug 2019 15:21:30 +0000 (UTC) (envelope-from markj@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 46HG1k0HDyz4Y5L; Mon, 26 Aug 2019 15:21:30 +0000 (UTC) (envelope-from markj@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 DF0968088; Mon, 26 Aug 2019 15:21:29 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x7QFLTv3047526; Mon, 26 Aug 2019 15:21:29 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7QFLTcG047525; Mon, 26 Aug 2019 15:21:29 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201908261521.x7QFLTcG047525@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Mon, 26 Aug 2019 15:21:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r351510 - stable/12/cddl/contrib/opensolaris/cmd/lockstat X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/12/cddl/contrib/opensolaris/cmd/lockstat X-SVN-Commit-Revision: 351510 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-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Aug 2019 15:21:30 -0000 Author: markj Date: Mon Aug 26 15:21:29 2019 New Revision: 351510 URL: https://svnweb.freebsd.org/changeset/base/351510 Log: MFC r351359: Fix inverted predicates for sx lock hold events in lockstat(1). Modified: stable/12/cddl/contrib/opensolaris/cmd/lockstat/lockstat.c Directory Properties: stable/12/ (props changed) Modified: stable/12/cddl/contrib/opensolaris/cmd/lockstat/lockstat.c ============================================================================== --- stable/12/cddl/contrib/opensolaris/cmd/lockstat/lockstat.c Mon Aug 26 10:18:19 2019 (r351509) +++ stable/12/cddl/contrib/opensolaris/cmd/lockstat/lockstat.c Mon Aug 26 15:21:29 2019 (r351510) @@ -206,10 +206,10 @@ static ls_event_info_t g_event_info[LS_MAX_EVENTS] = { "lockstat:::rw-release", "arg1 == 1", "lockstat:::rw-acquire" }, { 'H', "Lock", "SX shared hold", "nsec", - "lockstat:::sx-release", "arg1 == 0", + "lockstat:::sx-release", "arg1 == 1", "lockstat:::sx-acquire" }, { 'H', "Lock", "SX exclusive hold", "nsec", - "lockstat:::sx-release", "arg1 == 1", + "lockstat:::sx-release", "arg1 == 0", "lockstat:::sx-acquire" }, { 'H', "Lock", "Unknown event (type 38)", "units" }, { 'H', "Lock", "Unknown event (type 39)", "units" }, From owner-svn-src-stable-12@freebsd.org Mon Aug 26 17:34:09 2019 Return-Path: Delivered-To: svn-src-stable-12@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 AE460E1337; Mon, 26 Aug 2019 17:34:09 +0000 (UTC) (envelope-from kevans@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 46HJyn48dCz3DPV; Mon, 26 Aug 2019 17:34:09 +0000 (UTC) (envelope-from kevans@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 705129942; Mon, 26 Aug 2019 17:34:09 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x7QHY9sd027010; Mon, 26 Aug 2019 17:34:09 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7QHY85Z027008; Mon, 26 Aug 2019 17:34:08 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201908261734.x7QHY85Z027008@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Mon, 26 Aug 2019 17:34:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r351515 - in stable: 11/stand 11/stand/i386/boot2 11/stand/libsa 12/stand 12/stand/i386/boot2 12/stand/libsa X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable: 11/stand 11/stand/i386/boot2 11/stand/libsa 12/stand 12/stand/i386/boot2 12/stand/libsa X-SVN-Commit-Revision: 351515 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-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Aug 2019 17:34:09 -0000 Author: kevans Date: Mon Aug 26 17:34:07 2019 New Revision: 351515 URL: https://svnweb.freebsd.org/changeset/base/351515 Log: MFC r351119, r351135-r351136, r351412: stand xtoolchain-llvm90 fixes r351119: stand: push LIBC_SRC up into defs.mk Other parts of stand/ that don't use libsa will need to grab bits from libc shortly. Push LIBC_SRC up to defs.mk in advance of this so that they can use it, and rename it to LIBCSRC to match the convention of the rest of the *SRC variables in this file. r351135: stand: boot2: fix build with xtoolchain-llvm90 ufsread.c grows a dependency on __ashldi3 with llvm90. Grab ashldi3.c out of compiler-rt rather than trying to link against libsa (for now). -Wno-missing-prototypes is necessary to compile ashldi3.c standalone. r351136: stand: gptboot: fix build with xtoolchain-llvm90 ufsread.c grows a dependency on __ashldi3 with llvm90. For gptboot, just start pulling in ashldi3.c ashrdi3.c lshrdi3.c into libsa for all archs as the number of archs requiring one or more of them keeps growing. qdivrem.c and quad.h can be trivially kicked out of libsa if we start pulling these from compiler-rt as qdivrem was only used to implement umoddi3, divdi3, moddi3 (also in qdivrem.c). r351412: stand: boot2: fix amd64-xtoolchain-gcc build -Wno-missing-declarations is the GCC equivalent of -Wno-missing-prototypes... this was overlooked in r351135. Deleted: stable/12/stand/libsa/qdivrem.c stable/12/stand/libsa/quad.h Modified: stable/12/stand/defs.mk stable/12/stand/i386/boot2/Makefile stable/12/stand/libsa/Makefile Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Deleted: stable/11/stand/libsa/qdivrem.c stable/11/stand/libsa/quad.h Modified: stable/11/stand/defs.mk stable/11/stand/i386/boot2/Makefile stable/11/stand/libsa/Makefile Directory Properties: stable/11/ (props changed) Modified: stable/12/stand/defs.mk ============================================================================== --- stable/12/stand/defs.mk Mon Aug 26 17:27:36 2019 (r351514) +++ stable/12/stand/defs.mk Mon Aug 26 17:34:07 2019 (r351515) @@ -29,6 +29,7 @@ SASRC= ${BOOTSRC}/libsa SYSDIR= ${SRCTOP}/sys UBOOTSRC= ${BOOTSRC}/uboot ZFSSRC= ${SASRC}/zfs +LIBCSRC= ${SRCTOP}/lib/libc BOOTOBJ= ${OBJTOP}/stand Modified: stable/12/stand/i386/boot2/Makefile ============================================================================== --- stable/12/stand/i386/boot2/Makefile Mon Aug 26 17:27:36 2019 (r351514) +++ stable/12/stand/i386/boot2/Makefile Mon Aug 26 17:34:07 2019 (r351515) @@ -78,7 +78,12 @@ boot2.ldr: boot2.bin: boot2.out ${OBJCOPY} -S -O binary boot2.out ${.TARGET} -boot2.out: ${BTXCRT} boot2.o sio.o +# For __ashldi3 +.PATH: ${SRCTOP}/contrib/compiler-rt/lib/builtins +CFLAGS.ashldi3.c= -Wno-missing-prototypes -Wno-missing-declarations +CLEANFILES+= ashldi3.o + +boot2.out: ${BTXCRT} boot2.o sio.o ashldi3.o ${LD} ${LD_FLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC} SRCS= boot2.c boot2.h Modified: stable/12/stand/libsa/Makefile ============================================================================== --- stable/12/stand/libsa/Makefile Mon Aug 26 17:27:36 2019 (r351514) +++ stable/12/stand/libsa/Makefile Mon Aug 26 17:34:07 2019 (r351515) @@ -9,7 +9,6 @@ .include LIBSA_CPUARCH?=${MACHINE_CPUARCH} -LIBC_SRC= ${SRCTOP}/lib/libc LIB?= sa @@ -21,20 +20,20 @@ SRCS+= gzguts.h zutil.h __main.c abort.c assert.c bcd. # private (pruned) versions of libc string functions SRCS+= strcasecmp.c -.PATH: ${LIBC_SRC}/net +.PATH: ${LIBCSRC}/net SRCS+= ntoh.c # string functions from libc -.PATH: ${LIBC_SRC}/string +.PATH: ${LIBCSRC}/string SRCS+= bcmp.c bcopy.c bzero.c ffs.c fls.c \ memccpy.c memchr.c memcmp.c memcpy.c memmove.c memset.c \ - qdivrem.c strcat.c strchr.c strcmp.c strcpy.c stpcpy.c stpncpy.c \ + strcat.c strchr.c strcmp.c strcpy.c stpcpy.c stpncpy.c \ strcspn.c strlcat.c strlcpy.c strlen.c strncat.c strncmp.c strncpy.c \ strnlen.c strpbrk.c strrchr.c strsep.c strspn.c strstr.c strtok.c swab.c # stdlib functions from libc -.PATH: ${LIBC_SRC}/stdlib +.PATH: ${LIBCSRC}/stdlib SRCS+= abs.c strtol.c strtoll.c strtoul.c strtoull.c # common boot code @@ -42,7 +41,7 @@ SRCS+= abs.c strtol.c strtoll.c strtoul.c strtoull.c SRCS+= subr_boot.c .if ${MACHINE_CPUARCH} == "arm" -.PATH: ${LIBC_SRC}/arm/gen +.PATH: ${LIBCSRC}/arm/gen # Do not generate movt/movw, because the relocation fixup for them does not # translate to the -Bsymbolic -pie format required by self_reloc() in loader(8). @@ -54,36 +53,30 @@ CFLAGS.clang+= -mno-movt .endif CFLAGS.clang+= -mfpu=none -# Compiler support functions -.PATH: ${SRCTOP}/contrib/compiler-rt/lib/builtins/ -# __clzsi2 and ctzsi2 for various builtin functions -SRCS+= clzsi2.c ctzsi2.c -# Divide and modulus functions called by the compiler -SRCS+= divmoddi4.c divmodsi4.c divdi3.c divsi3.c moddi3.c modsi3.c -SRCS+= udivmoddi4.c udivmodsi4.c udivdi3.c udivsi3.c umoddi3.c umodsi3.c - .PATH: ${SRCTOP}/contrib/compiler-rt/lib/builtins/arm/ SRCS+= aeabi_idivmod.S aeabi_ldivmod.S aeabi_uidivmod.S aeabi_uldivmod.S SRCS+= aeabi_memcmp.S aeabi_memcpy.S aeabi_memmove.S aeabi_memset.S .endif .if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "riscv" -.PATH: ${LIBC_SRC}/${MACHINE_CPUARCH}/gen +.PATH: ${LIBCSRC}/${MACHINE_CPUARCH}/gen .endif -.if ${MACHINE_CPUARCH} == "powerpc" -.PATH: ${LIBC_SRC}/quad +# Compiler support functions +.PATH: ${SRCTOP}/contrib/compiler-rt/lib/builtins/ +# __clzsi2 and ctzsi2 for various builtin functions +SRCS+= clzsi2.c ctzsi2.c +# Divide and modulus functions called by the compiler +SRCS+= divmoddi4.c divmodsi4.c divdi3.c divsi3.c moddi3.c modsi3.c +SRCS+= udivmoddi4.c udivmodsi4.c udivdi3.c udivsi3.c umoddi3.c umodsi3.c SRCS+= ashldi3.c ashrdi3.c lshrdi3.c + +.if ${MACHINE_CPUARCH} == "powerpc" SRCS+= syncicache.c .endif -.if ${MACHINE_CPUARCH} == "mips" -.PATH: ${LIBC_SRC}/quad -SRCS+= ashldi3.c ashrdi3.c lshrdi3.c -.endif - # uuid functions from libc -.PATH: ${LIBC_SRC}/uuid +.PATH: ${LIBCSRC}/uuid SRCS+= uuid_create_nil.c uuid_equal.c uuid_from_string.c uuid_is_nil.c uuid_to_string.c # _setjmp/_longjmp From owner-svn-src-stable-12@freebsd.org Mon Aug 26 18:57:30 2019 Return-Path: Delivered-To: svn-src-stable-12@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 21669E2C04; Mon, 26 Aug 2019 18:57:30 +0000 (UTC) (envelope-from vmaffione@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 46HLpy05Gvz3JdR; Mon, 26 Aug 2019 18:57:30 +0000 (UTC) (envelope-from vmaffione@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 D9EABA895; Mon, 26 Aug 2019 18:57:29 +0000 (UTC) (envelope-from vmaffione@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x7QIvTEr074221; Mon, 26 Aug 2019 18:57:29 GMT (envelope-from vmaffione@FreeBSD.org) Received: (from vmaffione@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7QIvTL4074220; Mon, 26 Aug 2019 18:57:29 GMT (envelope-from vmaffione@FreeBSD.org) Message-Id: <201908261857.x7QIvTL4074220@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: vmaffione set sender to vmaffione@FreeBSD.org using -f From: Vincenzo Maffione Date: Mon, 26 Aug 2019 18:57:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r351517 - stable/12/share/man/man4 X-SVN-Group: stable-12 X-SVN-Commit-Author: vmaffione X-SVN-Commit-Paths: stable/12/share/man/man4 X-SVN-Commit-Revision: 351517 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-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Aug 2019 18:57:30 -0000 Author: vmaffione Date: Mon Aug 26 18:57:29 2019 New Revision: 351517 URL: https://svnweb.freebsd.org/changeset/base/351517 Log: MFC r351221 link ptnet(4) man page to the build system Reported by: kevans Reviewed by: kevans, bcr Differential Revision: https://reviews.freebsd.org/D21312 Modified: stable/12/share/man/man4/Makefile Directory Properties: stable/12/ (props changed) Modified: stable/12/share/man/man4/Makefile ============================================================================== --- stable/12/share/man/man4/Makefile Mon Aug 26 17:54:19 2019 (r351516) +++ stable/12/share/man/man4/Makefile Mon Aug 26 18:57:29 2019 (r351517) @@ -425,6 +425,7 @@ MAN= aac.4 \ psm.4 \ pst.4 \ pt.4 \ + ptnet.4 \ pts.4 \ pty.4 \ puc.4 \ @@ -706,6 +707,7 @@ MLINKS+=pcm.4 snd.4 \ pcm.4 sound.4 MLINKS+=pcn.4 if_pcn.4 MLINKS+=pms.4 pmspcv.4 +MLINKS+=ptnet.4 if_ptnet.4 MLINKS+=ral.4 if_ral.4 MLINKS+=re.4 if_re.4 MLINKS+=rl.4 if_rl.4 From owner-svn-src-stable-12@freebsd.org Tue Aug 27 00:29:30 2019 Return-Path: Delivered-To: svn-src-stable-12@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 CEFD3C167A; Tue, 27 Aug 2019 00:29:30 +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 46HVB259jMz45Sl; Tue, 27 Aug 2019 00:29:30 +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 93499E6A5; Tue, 27 Aug 2019 00:29:30 +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 x7R0TUCn068033; Tue, 27 Aug 2019 00:29:30 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7R0TUQx068032; Tue, 27 Aug 2019 00:29:30 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201908270029.x7R0TUQx068032@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Tue, 27 Aug 2019 00:29:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r351523 - in stable: 11/sys/netinet 12/sys/netinet X-SVN-Group: stable-12 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: in stable: 11/sys/netinet 12/sys/netinet X-SVN-Commit-Revision: 351523 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-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Aug 2019 00:29:30 -0000 Author: jhb Date: Tue Aug 27 00:29:30 2019 New Revision: 351523 URL: https://svnweb.freebsd.org/changeset/base/351523 Log: MFC 349474: Reject attempts to register a TCP stack being unloaded. Modified: stable/12/sys/netinet/tcp_subr.c Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Modified: stable/11/sys/netinet/tcp_subr.c Directory Properties: stable/11/ (props changed) Modified: stable/12/sys/netinet/tcp_subr.c ============================================================================== --- stable/12/sys/netinet/tcp_subr.c Tue Aug 27 00:01:56 2019 (r351522) +++ stable/12/sys/netinet/tcp_subr.c Tue Aug 27 00:29:30 2019 (r351523) @@ -813,8 +813,12 @@ register_tcp_functions_as_names(struct tcp_function_bl } } + if (blk->tfb_flags & TCP_FUNC_BEING_REMOVED) { + *num_names = 0; + return (EINVAL); + } + refcount_init(&blk->tfb_refcnt, 0); - blk->tfb_flags = 0; blk->tfb_id = atomic_fetchadd_int(&next_tcp_stack_id, 1); for (i = 0; i < *num_names; i++) { n = malloc(sizeof(struct tcp_function), M_TCPFUNCTIONS, wait); From owner-svn-src-stable-12@freebsd.org Tue Aug 27 03:05:58 2019 Return-Path: Delivered-To: svn-src-stable-12@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 6BA48C68EE; Tue, 27 Aug 2019 03:05:58 +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 46HYfZ29z2z4G1f; Tue, 27 Aug 2019 03:05:58 +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 2DBD6184F4; Tue, 27 Aug 2019 03:05:58 +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 x7R35vw8064195; Tue, 27 Aug 2019 03:05:57 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7R35vlN064194; Tue, 27 Aug 2019 03:05:57 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201908270305.x7R35vlN064194@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Tue, 27 Aug 2019 03:05:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r351526 - stable/12/sys/kern X-SVN-Group: stable-12 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/12/sys/kern X-SVN-Commit-Revision: 351526 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-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Aug 2019 03:05:58 -0000 Author: mav Date: Tue Aug 27 03:05:57 2019 New Revision: 351526 URL: https://svnweb.freebsd.org/changeset/base/351526 Log: MFC r351348 (by markj): Modify pipe_poll() to properly check for pending direct writes. With r349546, it is a responsibility of the writer to clear PIPE_DIRECTW after pinned data has been read. In particular, once a reader has drained this data, there is a small window where the pipe is empty but PIPE_DIRECTW is set. pipe_poll() was using the presence of PIPE_DIRECTW to determine whether to return POLLIN, so in this window it would claim that data was available to read when this was not the case. Fix this by modifying several checks for PIPE_DIRECTW to instead look at the number of residual bytes in data pinned by a direct writer. In some cases we really do want to check for PIPE_DIRECTW, since the presence of this flag indicates that any attempt to write to the pipe will block on the existing direct writer. Modified: stable/12/sys/kern/sys_pipe.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/kern/sys_pipe.c ============================================================================== --- stable/12/sys/kern/sys_pipe.c Tue Aug 27 01:40:38 2019 (r351525) +++ stable/12/sys/kern/sys_pipe.c Tue Aug 27 03:05:57 2019 (r351526) @@ -711,11 +711,9 @@ pipe_read(struct file *fp, struct uio *uio, struct ucr /* * Direct copy, bypassing a kernel buffer. */ - } else if ((size = rpipe->pipe_map.cnt) && - (rpipe->pipe_state & PIPE_DIRECTW)) { + } else if ((size = rpipe->pipe_map.cnt) != 0) { if (size > uio->uio_resid) size = (u_int) uio->uio_resid; - PIPE_UNLOCK(rpipe); error = uiomove_fromphys(rpipe->pipe_map.ms, rpipe->pipe_map.pos, size, uio); @@ -821,32 +819,33 @@ pipe_build_write_buffer(struct pipe *wpipe, struct uio u_int size; int i; - PIPE_LOCK_ASSERT(wpipe, MA_NOTOWNED); - KASSERT(wpipe->pipe_state & PIPE_DIRECTW, - ("Clone attempt on non-direct write pipe!")); + PIPE_LOCK_ASSERT(wpipe, MA_OWNED); + KASSERT((wpipe->pipe_state & PIPE_DIRECTW) == 0, + ("%s: PIPE_DIRECTW set on %p", __func__, wpipe)); + KASSERT(wpipe->pipe_map.cnt == 0, + ("%s: pipe map for %p contains residual data", __func__, wpipe)); if (uio->uio_iov->iov_len > wpipe->pipe_buffer.size) size = wpipe->pipe_buffer.size; else size = uio->uio_iov->iov_len; - if ((i = vm_fault_quick_hold_pages(&curproc->p_vmspace->vm_map, + wpipe->pipe_state |= PIPE_DIRECTW; + PIPE_UNLOCK(wpipe); + i = vm_fault_quick_hold_pages(&curproc->p_vmspace->vm_map, (vm_offset_t)uio->uio_iov->iov_base, size, VM_PROT_READ, - wpipe->pipe_map.ms, PIPENPAGES)) < 0) + wpipe->pipe_map.ms, PIPENPAGES); + PIPE_LOCK(wpipe); + if (i < 0) { + wpipe->pipe_state &= ~PIPE_DIRECTW; return (EFAULT); + } -/* - * set up the control block - */ wpipe->pipe_map.npages = i; wpipe->pipe_map.pos = ((vm_offset_t) uio->uio_iov->iov_base) & PAGE_MASK; wpipe->pipe_map.cnt = size; -/* - * and update the uio data - */ - uio->uio_iov->iov_len -= size; uio->uio_iov->iov_base = (char *)uio->uio_iov->iov_base + size; if (uio->uio_iov->iov_len == 0) @@ -866,6 +865,8 @@ pipe_destroy_write_buffer(struct pipe *wpipe) PIPE_LOCK_ASSERT(wpipe, MA_OWNED); KASSERT((wpipe->pipe_state & PIPE_DIRECTW) != 0, ("%s: PIPE_DIRECTW not set on %p", __func__, wpipe)); + KASSERT(wpipe->pipe_map.cnt == 0, + ("%s: pipe map for %p contains residual data", __func__, wpipe)); wpipe->pipe_state &= ~PIPE_DIRECTW; vm_page_unhold_pages(wpipe->pipe_map.ms, wpipe->pipe_map.npages); @@ -891,6 +892,7 @@ pipe_clone_write_buffer(struct pipe *wpipe) size = wpipe->pipe_map.cnt; pos = wpipe->pipe_map.pos; + wpipe->pipe_map.cnt = 0; wpipe->pipe_buffer.in = size; wpipe->pipe_buffer.out = 0; @@ -948,7 +950,6 @@ retry: else goto retry; } - wpipe->pipe_map.cnt = 0; /* transfer not ready yet */ if (wpipe->pipe_buffer.cnt > 0) { if (wpipe->pipe_state & PIPE_WANTR) { wpipe->pipe_state &= ~PIPE_WANTR; @@ -965,19 +966,15 @@ retry: goto retry; } - wpipe->pipe_state |= PIPE_DIRECTW; - - PIPE_UNLOCK(wpipe); error = pipe_build_write_buffer(wpipe, uio); - PIPE_LOCK(wpipe); if (error) { - wpipe->pipe_state &= ~PIPE_DIRECTW; pipeunlock(wpipe); goto error1; } while (wpipe->pipe_map.cnt != 0) { if (wpipe->pipe_state & PIPE_EOF) { + wpipe->pipe_map.cnt = 0; pipe_destroy_write_buffer(wpipe); pipeselwakeup(wpipe); pipeunlock(wpipe); @@ -1131,7 +1128,7 @@ pipe_write(struct file *fp, struct uio *uio, struct uc * pipe buffer. We break out if a signal occurs or the * reader goes away. */ - if (wpipe->pipe_state & PIPE_DIRECTW) { + if (wpipe->pipe_map.cnt != 0) { if (wpipe->pipe_state & PIPE_WANTR) { wpipe->pipe_state &= ~PIPE_WANTR; wakeup(wpipe); @@ -1349,7 +1346,7 @@ pipe_ioctl(struct file *fp, u_long cmd, void *data, st PIPE_UNLOCK(mpipe); return (0); } - if (mpipe->pipe_state & PIPE_DIRECTW) + if (mpipe->pipe_map.cnt != 0) *(int *)data = mpipe->pipe_map.cnt; else *(int *)data = mpipe->pipe_buffer.cnt; @@ -1405,14 +1402,13 @@ pipe_poll(struct file *fp, int events, struct ucred *a goto locked_error; #endif if (fp->f_flag & FREAD && events & (POLLIN | POLLRDNORM)) - if ((rpipe->pipe_state & PIPE_DIRECTW) || - (rpipe->pipe_buffer.cnt > 0)) + if (rpipe->pipe_map.cnt > 0 || rpipe->pipe_buffer.cnt > 0) revents |= events & (POLLIN | POLLRDNORM); if (fp->f_flag & FWRITE && events & (POLLOUT | POLLWRNORM)) if (wpipe->pipe_present != PIPE_ACTIVE || (wpipe->pipe_state & PIPE_EOF) || - (((wpipe->pipe_state & PIPE_DIRECTW) == 0) && + ((wpipe->pipe_state & PIPE_DIRECTW) == 0 && ((wpipe->pipe_buffer.size - wpipe->pipe_buffer.cnt) >= PIPE_BUF || wpipe->pipe_buffer.size == 0))) revents |= events & (POLLOUT | POLLWRNORM); @@ -1487,7 +1483,7 @@ pipe_stat(struct file *fp, struct stat *ub, struct ucr bzero(ub, sizeof(*ub)); ub->st_mode = S_IFIFO; ub->st_blksize = PAGE_SIZE; - if (pipe->pipe_state & PIPE_DIRECTW) + if (pipe->pipe_map.cnt != 0) ub->st_size = pipe->pipe_map.cnt; else ub->st_size = pipe->pipe_buffer.cnt; @@ -1729,7 +1725,7 @@ filt_piperead(struct knote *kn, long hint) PIPE_LOCK_ASSERT(rpipe, MA_OWNED); kn->kn_data = rpipe->pipe_buffer.cnt; - if ((kn->kn_data == 0) && (rpipe->pipe_state & PIPE_DIRECTW)) + if (kn->kn_data == 0) kn->kn_data = rpipe->pipe_map.cnt; if ((rpipe->pipe_state & PIPE_EOF) || From owner-svn-src-stable-12@freebsd.org Tue Aug 27 03:52:23 2019 Return-Path: Delivered-To: svn-src-stable-12@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 CB9C0C801F; Tue, 27 Aug 2019 03:52:23 +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 46HZh756J3z4JHN; Tue, 27 Aug 2019 03:52:23 +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 9104318E23; Tue, 27 Aug 2019 03:52: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 x7R3qNbT094379; Tue, 27 Aug 2019 03:52:23 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7R3qNtY094377; Tue, 27 Aug 2019 03:52:23 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201908270352.x7R3qNtY094377@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Tue, 27 Aug 2019 03:52:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r351527 - in stable/12: sbin/camcontrol sys/sys X-SVN-Group: stable-12 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: in stable/12: sbin/camcontrol sys/sys X-SVN-Commit-Revision: 351527 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-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Aug 2019 03:52:23 -0000 Author: mav Date: Tue Aug 27 03:52:22 2019 New Revision: 351527 URL: https://svnweb.freebsd.org/changeset/base/351527 Log: MFC r350393: Decode some more IDENTIFY DEVICE bits. Modified: stable/12/sbin/camcontrol/camcontrol.c stable/12/sys/sys/ata.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sbin/camcontrol/camcontrol.c ============================================================================== --- stable/12/sbin/camcontrol/camcontrol.c Tue Aug 27 03:05:57 2019 (r351526) +++ stable/12/sbin/camcontrol/camcontrol.c Tue Aug 27 03:52:22 2019 (r351527) @@ -1540,6 +1540,7 @@ atacapprint(struct ata_params *parm) printf("WWN %04x%04x%04x%04x\n", parm->wwn[0], parm->wwn[1], parm->wwn[2], parm->wwn[3]); } + printf("additional product id %.8s\n", parm->product_id); if (parm->enabled.extension & ATA_SUPPORT_MEDIASN) { printf("media serial number %.30s\n", parm->media_serial); @@ -1669,35 +1670,39 @@ atacapprint(struct ata_params *parm) } else printf("\n"); printf("Native Command Queuing (NCQ) "); - if (parm->satacapabilities != 0xffff && - (parm->satacapabilities & ATA_SUPPORT_NCQ)) { + if (atasata(parm) && (parm->satacapabilities & ATA_SUPPORT_NCQ)) { printf("yes %d tags\n", ATA_QUEUE_LEN(parm->queue) + 1); + printf("NCQ Priority Information %s\n", + parm->satacapabilities & ATA_SUPPORT_NCQ_PRIO ? + "yes" : "no"); + printf("NCQ Non-Data Command %s\n", + parm->satacapabilities2 & ATA_SUPPORT_NCQ_NON_DATA ? + "yes" : "no"); + printf("NCQ Streaming %s\n", + parm->satacapabilities2 & ATA_SUPPORT_NCQ_STREAM ? + "yes" : "no"); + printf("Receive & Send FPDMA Queued %s\n", + parm->satacapabilities2 & ATA_SUPPORT_RCVSND_FPDMA_QUEUED ? + "yes" : "no"); + printf("NCQ Autosense %s\n", + parm->satasupport & ATA_SUPPORT_NCQ_AUTOSENSE ? + "yes" : "no"); } else printf("no\n"); - printf("NCQ Queue Management %s\n", atasata(parm) && - parm->satacapabilities2 & ATA_SUPPORT_NCQ_QMANAGEMENT ? - "yes" : "no"); - printf("NCQ Streaming %s\n", atasata(parm) && - parm->satacapabilities2 & ATA_SUPPORT_NCQ_STREAM ? - "yes" : "no"); - printf("Receive & Send FPDMA Queued %s\n", atasata(parm) && - parm->satacapabilities2 & ATA_SUPPORT_RCVSND_FPDMA_QUEUED ? - "yes" : "no"); - printf("SMART %s %s\n", parm->support.command1 & ATA_SUPPORT_SMART ? "yes" : "no", parm->enabled.command1 & ATA_SUPPORT_SMART ? "yes" : "no"); - printf("microcode download %s %s\n", - parm->support.command2 & ATA_SUPPORT_MICROCODE ? "yes" : "no", - parm->enabled.command2 & ATA_SUPPORT_MICROCODE ? "yes" : "no"); printf("security %s %s\n", parm->support.command1 & ATA_SUPPORT_SECURITY ? "yes" : "no", parm->enabled.command1 & ATA_SUPPORT_SECURITY ? "yes" : "no"); printf("power management %s %s\n", parm->support.command1 & ATA_SUPPORT_POWERMGT ? "yes" : "no", parm->enabled.command1 & ATA_SUPPORT_POWERMGT ? "yes" : "no"); + printf("microcode download %s %s\n", + parm->support.command2 & ATA_SUPPORT_MICROCODE ? "yes" : "no", + parm->enabled.command2 & ATA_SUPPORT_MICROCODE ? "yes" : "no"); printf("advanced power management %s %s", parm->support.command2 & ATA_SUPPORT_APM ? "yes" : "no", parm->enabled.command2 & ATA_SUPPORT_APM ? "yes" : "no"); @@ -1740,6 +1745,15 @@ atacapprint(struct ata_params *parm) printf("free-fall %s %s\n", parm->support2 & ATA_SUPPORT_FREEFALL ? "yes" : "no", parm->enabled2 & ATA_SUPPORT_FREEFALL ? "yes" : "no"); + printf("sense data reporting %s %s\n", + parm->support2 & ATA_SUPPORT_SENSE_REPORT ? "yes" : "no", + parm->enabled2 & ATA_SUPPORT_SENSE_REPORT ? "yes" : "no"); + printf("extended power conditions %s %s\n", + parm->support2 & ATA_SUPPORT_EPC ? "yes" : "no", + parm->enabled2 & ATA_SUPPORT_EPC ? "yes" : "no"); + printf("device statistics notification %s %s\n", + parm->support2 & ATA_SUPPORT_DSN ? "yes" : "no", + parm->enabled2 & ATA_SUPPORT_DSN ? "yes" : "no"); printf("Data Set Management (DSM/TRIM) "); if (parm->support_dsm & ATA_SUPPORT_DSM_TRIM) { printf("yes\n"); @@ -1762,6 +1776,8 @@ atacapprint(struct ata_params *parm) } else { printf("no\n"); } + printf("encrypts all user data %s\n", + parm->support3 & ATA_ENCRYPTS_ALL_USER_DATA ? "yes" : "no"); printf("Sanitize "); if (parm->multi & ATA_SUPPORT_SANITIZE) { printf("yes\t\t%s%s%s\n", Modified: stable/12/sys/sys/ata.h ============================================================================== --- stable/12/sys/sys/ata.h Tue Aug 27 03:05:57 2019 (r351526) +++ stable/12/sys/sys/ata.h Tue Aug 27 03:52:22 2019 (r351527) @@ -143,7 +143,8 @@ struct ata_params { /*77*/ u_int16_t satacapabilities2; #define ATA_SATA_CURR_GEN_MASK 0x0006 #define ATA_SUPPORT_NCQ_STREAM 0x0010 -#define ATA_SUPPORT_NCQ_QMANAGEMENT 0x0020 +#define ATA_SUPPORT_NCQ_NON_DATA 0x0020 +#define ATA_SUPPORT_NCQ_QMANAGEMENT ATA_SUPPORT_NCQ_NON_DATA #define ATA_SUPPORT_RCVSND_FPDMA_QUEUED 0x0040 /*78*/ u_int16_t satasupport; #define ATA_SUPPORT_NONZERO 0x0002 @@ -152,6 +153,7 @@ struct ata_params { #define ATA_SUPPORT_INORDERDATA 0x0010 #define ATA_SUPPORT_ASYNCNOTIF 0x0020 #define ATA_SUPPORT_SOFTSETPRESERVE 0x0040 +#define ATA_SUPPORT_NCQ_AUTOSENSE 0x0080 /*79*/ u_int16_t sataenabled; #define ATA_ENABLED_DAPST 0x0080 @@ -285,7 +287,8 @@ struct ata_params { #define ATA_FORM_FACTOR_C_FAST 0x0009 /*169*/ u_int16_t support_dsm; #define ATA_SUPPORT_DSM_TRIM 0x0001 - u_int16_t reserved170[6]; +/*170*/ u_int8_t product_id[8]; /* Additional Product Identifier */ + u_int16_t reserved174[2]; /*176*/ u_int8_t media_serial[60]; /*206*/ u_int16_t sct; u_int16_t reserved207[2]; From owner-svn-src-stable-12@freebsd.org Tue Aug 27 03:53:22 2019 Return-Path: Delivered-To: svn-src-stable-12@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 AE3C6C80C9; Tue, 27 Aug 2019 03:53:22 +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 46HZjG4CXvz4JQd; Tue, 27 Aug 2019 03:53:22 +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 727DD18E3D; Tue, 27 Aug 2019 03:53:22 +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 x7R3rM38094474; Tue, 27 Aug 2019 03:53:22 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7R3rMwO094473; Tue, 27 Aug 2019 03:53:22 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201908270353.x7R3rMwO094473@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Tue, 27 Aug 2019 03:53:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r351528 - stable/12/sbin/camcontrol X-SVN-Group: stable-12 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/12/sbin/camcontrol X-SVN-Commit-Revision: 351528 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-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Aug 2019 03:53:22 -0000 Author: mav Date: Tue Aug 27 03:53:22 2019 New Revision: 351528 URL: https://svnweb.freebsd.org/changeset/base/351528 Log: MFC r350424: Use present now scsi_mode_sense_subpage(). Modified: stable/12/sbin/camcontrol/timestamp.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sbin/camcontrol/timestamp.c ============================================================================== --- stable/12/sbin/camcontrol/timestamp.c Tue Aug 27 03:52:22 2019 (r351527) +++ stable/12/sbin/camcontrol/timestamp.c Tue Aug 27 03:53:22 2019 (r351528) @@ -79,7 +79,6 @@ set_restore_flags(struct cam_device *device, uint8_t * int error = 0; struct scsi_control_ext_page *control_page = NULL; struct scsi_mode_header_10 *mode_hdr = NULL; - struct scsi_mode_sense_10 *cdb = NULL; union ccb *ccb = NULL; unsigned long mode_buf_size = sizeof(struct scsi_mode_header_10) + sizeof(struct scsi_mode_blk_desc) + @@ -96,25 +95,19 @@ set_restore_flags(struct cam_device *device, uint8_t * * Get the control extension subpage, we'll send it back modified to * enable SCSI control over the tape drive's timestamp */ - scsi_mode_sense_len(&ccb->csio, + scsi_mode_sense_subpage(&ccb->csio, /*retries*/ retry_count, /*cbfcnp*/ NULL, /*tag_action*/ task_attr, /*dbd*/ 0, /*page_control*/ SMS_PAGE_CTRL_CURRENT, /*page*/ SCEP_PAGE_CODE, + /*subpage*/ SCEP_SUBPAGE_CODE, /*param_buf*/ &mode_buf[0], /*param_len*/ mode_buf_size, /*minimum_cmd_size*/ 10, /*sense_len*/ SSD_FULL_SIZE, /*timeout*/ timeout ? timeout : 5000); - /* - * scsi_mode_sense_len does not have a subpage argument at the moment, - * so we have to manually set the subpage code before calling - * cam_send_ccb(). - */ - cdb = (struct scsi_mode_sense_10 *)ccb->csio.cdb_io.cdb_bytes; - cdb->subpage = SCEP_SUBPAGE_CODE; ccb->ccb_h.flags |= CAM_DEV_QFRZDIS; if (retry_count > 0) From owner-svn-src-stable-12@freebsd.org Tue Aug 27 03:54:30 2019 Return-Path: Delivered-To: svn-src-stable-12@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 93096C816E; Tue, 27 Aug 2019 03:54:30 +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 46HZkZ48WGz4JY7; Tue, 27 Aug 2019 03:54:30 +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 70A7018E3F; Tue, 27 Aug 2019 03:54:30 +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 x7R3sUR6094585; Tue, 27 Aug 2019 03:54:30 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7R3sTR7094581; Tue, 27 Aug 2019 03:54:29 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201908270354.x7R3sTR7094581@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Tue, 27 Aug 2019 03:54:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r351529 - stable/12/sbin/camcontrol X-SVN-Group: stable-12 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/12/sbin/camcontrol X-SVN-Commit-Revision: 351529 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-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Aug 2019 03:54:30 -0000 Author: mav Date: Tue Aug 27 03:54:29 2019 New Revision: 351529 URL: https://svnweb.freebsd.org/changeset/base/351529 Log: MFC r350457: Make `camcontrol modepage` to use 10 byte commands. While old devices may not support 10 byte MODE SENSE/MODE SELECT commands, new ones may not be able to report all mode pages with 6 byte commands. This patch makes camcontrol by default start with 10 byte commands and fall back to 6 byte on ILLEGAL REQUEST error, or 6 byte can be forced. Modified: stable/12/sbin/camcontrol/camcontrol.8 stable/12/sbin/camcontrol/camcontrol.c stable/12/sbin/camcontrol/camcontrol.h stable/12/sbin/camcontrol/modeedit.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sbin/camcontrol/camcontrol.8 ============================================================================== --- stable/12/sbin/camcontrol/camcontrol.8 Tue Aug 27 03:53:22 2019 (r351528) +++ stable/12/sbin/camcontrol/camcontrol.8 Tue Aug 27 03:54:29 2019 (r351529) @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 25, 2019 +.Dd July 30, 2019 .Dt CAMCONTROL 8 .Os .Sh NAME @@ -122,6 +122,7 @@ .Ic modepage .Op device id .Op generic args +.Op Fl 6 .Aq Fl m Ar page[,subpage] | Fl l .Op Fl P Ar pgctl .Op Fl b | Fl e @@ -723,6 +724,13 @@ The .Ic modepage command takes several arguments: .Bl -tag -width 12n +.It Fl 6 +Use 6 byte MODE commands instead of default 10 byte. +Old devices may not support 10 byte MODE commands, while new devices may +not be able to report all mode pages with 6 byte commands. +If not specified, +.Nm +starts with 10 byte commands and falls back to 6 byte on error. .It Fl d Disable block descriptors for mode sense. .It Fl b Modified: stable/12/sbin/camcontrol/camcontrol.c ============================================================================== --- stable/12/sbin/camcontrol/camcontrol.c Tue Aug 27 03:53:22 2019 (r351528) +++ stable/12/sbin/camcontrol/camcontrol.c Tue Aug 27 03:54:29 2019 (r351529) @@ -230,7 +230,7 @@ static struct camcontrol_opts option_table[] = { {"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:"}, + {"modepage", CAM_CMD_MODE_PAGE, CAM_ARG_NONE, "6bdelm:P:"}, {"tags", CAM_CMD_TAG, CAM_ARG_NONE, "N:q"}, {"negotiate", CAM_CMD_RATE, CAM_ARG_NONE, negotiate_opts}, {"rate", CAM_CMD_RATE, CAM_ARG_NONE, negotiate_opts}, @@ -4611,18 +4611,25 @@ reassignblocks(struct cam_device *device, u_int32_t *b #ifndef MINIMALISTIC void -mode_sense(struct cam_device *device, int dbd, int pc, int page, int subpage, - int task_attr, int retry_count, int timeout, u_int8_t *data, - int datalen) +mode_sense(struct cam_device *device, int *cdb_len, int dbd, int pc, int page, + int subpage, int task_attr, int retry_count, int timeout, u_int8_t *data, + int datalen) { union ccb *ccb; - int retval; + int error_code, sense_key, asc, ascq; ccb = cam_getccb(device); - if (ccb == NULL) errx(1, "mode_sense: couldn't allocate CCB"); +retry: + /* + * MODE SENSE(6) can't handle more then 255 bytes. If there are more, + * device must return error, so we should not get trucated data. + */ + if (*cdb_len == 6 && datalen > 255) + datalen = 255; + CCB_CLEAR_ALL_EXCEPT_HDR(&ccb->csio); scsi_mode_sense_subpage(&ccb->csio, @@ -4635,36 +4642,47 @@ mode_sense(struct cam_device *device, int dbd, int pc, /* subpage */ subpage, /* param_buf */ data, /* param_len */ datalen, - /* minimum_cmd_size */ 0, + /* minimum_cmd_size */ *cdb_len, /* sense_len */ SSD_FULL_SIZE, /* timeout */ timeout ? timeout : 5000); + /* Record what CDB size the above function really set. */ + *cdb_len = ccb->csio.cdb_len; + if (arglist & CAM_ARG_ERR_RECOVER) ccb->ccb_h.flags |= CAM_PASS_ERR_RECOVER; /* Disable freezing the device queue */ ccb->ccb_h.flags |= CAM_DEV_QFRZDIS; - if (((retval = cam_send_ccb(device, ccb)) < 0) - || ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP)) { + if (cam_send_ccb(device, ccb) < 0) + err(1, "error sending mode sense command"); + + /* In case of ILLEGEL REQUEST try to fall back to 6-byte command. */ + if (*cdb_len != 6 && + ((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_INVALID || + (scsi_extract_sense_ccb(ccb, &error_code, &sense_key, &asc, &ascq) + && sense_key == SSD_KEY_ILLEGAL_REQUEST))) { + *cdb_len = 6; + goto retry; + } + + if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { if (arglist & CAM_ARG_VERBOSE) { cam_error_print(device, ccb, CAM_ESF_ALL, CAM_EPF_ALL, stderr); } cam_freeccb(ccb); cam_close_device(device); - if (retval < 0) - err(1, "error sending mode sense command"); - else - errx(1, "error sending mode sense command"); + errx(1, "mode sense command returned error"); } cam_freeccb(ccb); } void -mode_select(struct cam_device *device, int save_pages, int task_attr, - int retry_count, int timeout, u_int8_t *data, int datalen) +mode_select(struct cam_device *device, int cdb_len, int save_pages, + int task_attr, int retry_count, int timeout, u_int8_t *data, int datalen) { union ccb *ccb; int retval; @@ -4676,7 +4694,7 @@ mode_select(struct cam_device *device, int save_pages, CCB_CLEAR_ALL_EXCEPT_HDR(&ccb->csio); - scsi_mode_select(&ccb->csio, + scsi_mode_select_len(&ccb->csio, /* retries */ retry_count, /* cbfcnp */ NULL, /* tag_action */ task_attr, @@ -4684,6 +4702,7 @@ mode_select(struct cam_device *device, int save_pages, /* save_pages */ save_pages, /* param_buf */ data, /* param_len */ datalen, + /* minimum_cmd_size */ cdb_len, /* sense_len */ SSD_FULL_SIZE, /* timeout */ timeout ? timeout : 5000); @@ -4718,10 +4737,13 @@ modepage(struct cam_device *device, int argc, char **a { char *str_subpage; int c, page = -1, subpage = -1, pc = 0; - int binary = 0, dbd = 0, edit = 0, list = 0; + int binary = 0, cdb_len = 10, dbd = 0, edit = 0, list = 0; while ((c = getopt(argc, argv, combinedopt)) != -1) { switch(c) { + case '6': + cdb_len = 6; + break; case 'b': binary = 1; break; @@ -4761,11 +4783,11 @@ modepage(struct cam_device *device, int argc, char **a errx(1, "you must specify a mode page!"); if (list != 0) { - mode_list(device, dbd, pc, list > 1, task_attr, retry_count, - timeout); + mode_list(device, cdb_len, dbd, pc, list > 1, task_attr, + retry_count, timeout); } else { - mode_edit(device, dbd, pc, page, subpage, edit, binary, - task_attr, retry_count, timeout); + mode_edit(device, cdb_len, dbd, pc, page, subpage, edit, + binary, task_attr, retry_count, timeout); } } Modified: stable/12/sbin/camcontrol/camcontrol.h ============================================================================== --- stable/12/sbin/camcontrol/camcontrol.h Tue Aug 27 03:53:22 2019 (r351528) +++ stable/12/sbin/camcontrol/camcontrol.h Tue Aug 27 03:54:29 2019 (r351529) @@ -88,16 +88,17 @@ int epc(struct cam_device *device, int argc, char **ar int timestamp(struct cam_device *device, int argc, char **argv, char *combinedopt, int task_attr, int retry_count, int timeout, int verbosemode); -void mode_sense(struct cam_device *device, int dbd, int pc, int page, - int subpage, int task_attr, int retry_count, int timeout, - uint8_t *data, int datalen); -void mode_select(struct cam_device *device, int save_pages, int task_attr, - int retry_count, int timeout, u_int8_t *data, int datalen); -void mode_edit(struct cam_device *device, int dbd, int pc, int page, - int subpage, int edit, int binary, int task_attr, +void mode_sense(struct cam_device *device, int *cdb_len, int dbd, int pc, + int page, int subpage, int task_attr, int retry_count, + int timeout, uint8_t *data, int datalen); +void mode_select(struct cam_device *device, int cdb_len, int save_pages, + int task_attr, int retry_count, int timeout, u_int8_t *data, + int datalen); +void mode_edit(struct cam_device *device, int cdb_len, int dbd, int pc, + int page, int subpage, int edit, int binary, int task_attr, int retry_count, int timeout); -void mode_list(struct cam_device *device, int dbd, int pc, int subpages, - int task_attr, int retry_count, int timeout); +void mode_list(struct cam_device *device, int cdb_len, int dbd, int pc, + int subpages, int task_attr, int retry_count, int timeout); int scsidoinquiry(struct cam_device *device, int argc, char **argv, char *combinedopt, int task_attr, int retry_count, int timeout); Modified: stable/12/sbin/camcontrol/modeedit.c ============================================================================== --- stable/12/sbin/camcontrol/modeedit.c Tue Aug 27 03:53:22 2019 (r351528) +++ stable/12/sbin/camcontrol/modeedit.c Tue Aug 27 03:54:29 2019 (r351529) @@ -60,15 +60,9 @@ __FBSDID("$FreeBSD$"); #define PAGENAME_START '"' /* Page name delimiter. */ #define PAGENAME_END '"' /* Page name delimiter. */ #define PAGEENTRY_END ';' /* Page entry terminator (optional). */ -#define MAX_COMMAND_SIZE 255 /* Mode/Log sense data buffer size. */ +#define MAX_DATA_SIZE 4096 /* Mode/Log sense data buffer size. */ #define PAGE_CTRL_SHIFT 6 /* Bit offset to page control field. */ - -/* Macros for working with mode pages. */ -#define MODE_PAGE_HEADER(mh) \ - (struct scsi_mode_page_header *)find_mode_page_6(mh) - - struct editentry { STAILQ_ENTRY(editentry) link; char *name; @@ -106,13 +100,12 @@ static int editentry_save(void *hook, char *name); static struct editentry *editentry_lookup(char *name); static int editentry_set(char *name, char *newvalue, int editonly); -static void editlist_populate(struct cam_device *device, int dbd, - int pc, int page, int subpage, - int task_attr, int retries, - int timeout); -static void editlist_save(struct cam_device *device, int dbd, - int pc, int page, int subpage, - int task_attr, int retries, int timeout); +static void editlist_populate(struct cam_device *device, + int cdb_len, int dbd, int pc, int page, int subpage, + int task_attr, int retries, int timeout); +static void editlist_save(struct cam_device *device, int cdb_len, + int dbd, int pc, int page, int subpage, + int task_attr, int retries, int timeout); static void nameentry_create(int page, int subpage, char *name); static struct pagename *nameentry_lookup(int page, int subpage); static int load_format(const char *pagedb_path, int lpage, @@ -120,9 +113,9 @@ static int load_format(const char *pagedb_path, int static int modepage_write(FILE *file, int editonly); static int modepage_read(FILE *file); static void modepage_edit(void); -static void modepage_dump(struct cam_device *device, int dbd, - int pc, int page, int subpage, int task_attr, - int retries, int timeout); +static void modepage_dump(struct cam_device *device, int cdb_len, + int dbd, int pc, int page, int subpage, + int task_attr, int retries, int timeout); static void cleanup_editfile(void); @@ -552,12 +545,11 @@ load_format(const char *pagedb_path, int lpage, int ls } static void -editlist_populate(struct cam_device *device, int dbd, int pc, int page, - int subpage, int task_attr, int retries, int timeout) +editlist_populate(struct cam_device *device, int cdb_len, int dbd, int pc, + int page, int subpage, int task_attr, int retries, int timeout) { - u_int8_t data[MAX_COMMAND_SIZE];/* Buffer to hold sense data. */ + u_int8_t data[MAX_DATA_SIZE];/* Buffer to hold sense data. */ u_int8_t *mode_pars; /* Pointer to modepage params. */ - struct scsi_mode_header_6 *mh; /* Location of mode header. */ struct scsi_mode_page_header *mph; struct scsi_mode_page_header_sp *mphsp; size_t len; @@ -565,11 +557,18 @@ editlist_populate(struct cam_device *device, int dbd, STAILQ_INIT(&editlist); /* Fetch changeable values; use to build initial editlist. */ - mode_sense(device, dbd, 1, page, subpage, task_attr, retries, timeout, - data, sizeof(data)); + mode_sense(device, &cdb_len, dbd, 1, page, subpage, task_attr, retries, + timeout, data, sizeof(data)); - mh = (struct scsi_mode_header_6 *)data; - mph = MODE_PAGE_HEADER(mh); + if (cdb_len == 6) { + struct scsi_mode_header_6 *mh = + (struct scsi_mode_header_6 *)data; + mph = find_mode_page_6(mh); + } else { + struct scsi_mode_header_10 *mh = + (struct scsi_mode_header_10 *)data; + mph = find_mode_page_10(mh); + } if ((mph->page_code & SMPH_SPF) == 0) { mode_pars = (uint8_t *)(mph + 1); len = mph->page_length; @@ -584,40 +583,80 @@ editlist_populate(struct cam_device *device, int dbd, buff_decode_visit(mode_pars, len, format, editentry_create, 0); /* Fetch the current/saved values; use to set editentry values. */ - mode_sense(device, dbd, pc, page, subpage, task_attr, retries, timeout, - data, sizeof(data)); + mode_sense(device, &cdb_len, dbd, pc, page, subpage, task_attr, + retries, timeout, data, sizeof(data)); buff_decode_visit(mode_pars, len, format, editentry_update, 0); } static void -editlist_save(struct cam_device *device, int dbd, int pc, int page, - int subpage, int task_attr, int retries, int timeout) +editlist_save(struct cam_device *device, int cdb_len, int dbd, int pc, + int page, int subpage, int task_attr, int retries, int timeout) { - u_int8_t data[MAX_COMMAND_SIZE];/* Buffer to hold sense data. */ + u_int8_t data[MAX_DATA_SIZE];/* Buffer to hold sense data. */ u_int8_t *mode_pars; /* Pointer to modepage params. */ - struct scsi_mode_header_6 *mh; /* Location of mode header. */ struct scsi_mode_page_header *mph; struct scsi_mode_page_header_sp *mphsp; - size_t len, hlen; + size_t len, hlen, mphlen; /* Make sure that something changed before continuing. */ if (! editlist_changed) return; /* Preload the CDB buffer with the current mode page data. */ - mode_sense(device, dbd, pc, page, subpage, task_attr, retries, timeout, - data, sizeof(data)); + mode_sense(device, &cdb_len, dbd, pc, page, subpage, task_attr, + retries, timeout, data, sizeof(data)); /* Initial headers & offsets. */ - mh = (struct scsi_mode_header_6 *)data; - mph = MODE_PAGE_HEADER(mh); + /* + * Tape drives include write protect (WP), Buffered Mode and Speed + * settings in the device-specific parameter. Clearing this + * parameter on a mode select can have the effect of turning off + * write protect or buffered mode, or changing the speed setting of + * the tape drive. + * + * Disks report DPO/FUA support via the device specific parameter + * for MODE SENSE, but the bit is reserved for MODE SELECT. So we + * clear this for disks (and other non-tape devices) to avoid + * potential errors from the target device. + */ + if (cdb_len == 6) { + struct scsi_mode_header_6 *mh = + (struct scsi_mode_header_6 *)data; + hlen = sizeof(*mh); + /* Eliminate block descriptors. */ + if (mh->blk_desc_len > 0) { + bcopy(find_mode_page_6(mh), mh + 1, + mh->data_length + 1 - hlen - + mh->blk_desc_len); + mh->blk_desc_len = 0; + } + mh->data_length = 0; /* Reserved for MODE SELECT command. */ + if (device->pd_type != T_SEQUENTIAL) + mh->dev_spec = 0; /* See comment above */ + mph = find_mode_page_6(mh); + } else { + struct scsi_mode_header_10 *mh = + (struct scsi_mode_header_10 *)data; + hlen = sizeof(*mh); + /* Eliminate block descriptors. */ + if (scsi_2btoul(mh->blk_desc_len) > 0) { + bcopy(find_mode_page_10(mh), mh + 1, + scsi_2btoul(mh->data_length) + 1 - hlen - + scsi_2btoul(mh->blk_desc_len)); + scsi_ulto2b(0, mh->blk_desc_len); + } + scsi_ulto2b(0, mh->data_length); /* Reserved for MODE SELECT. */ + if (device->pd_type != T_SEQUENTIAL) + mh->dev_spec = 0; /* See comment above */ + mph = find_mode_page_10(mh); + } if ((mph->page_code & SMPH_SPF) == 0) { - hlen = sizeof(*mph); + mphlen = sizeof(*mph); mode_pars = (uint8_t *)(mph + 1); len = mph->page_length; } else { mphsp = (struct scsi_mode_page_header_sp *)mph; - hlen = sizeof(*mphsp); + mphlen = sizeof(*mphsp); mode_pars = (uint8_t *)(mphsp + 1); len = scsi_2btoul(mphsp->page_length); } @@ -626,27 +665,6 @@ editlist_save(struct cam_device *device, int dbd, int /* Encode the value data to be passed back to the device. */ buff_encode_visit(mode_pars, len, format, editentry_save, 0); - /* Eliminate block descriptors. */ - bcopy(mph, mh + 1, hlen + len); - - /* Recalculate headers & offsets. */ - mh->data_length = 0; /* Reserved for MODE SELECT command. */ - mh->blk_desc_len = 0; /* No block descriptors. */ - /* - * Tape drives include write protect (WP), Buffered Mode and Speed - * settings in the device-specific parameter. Clearing this - * parameter on a mode select can have the effect of turning off - * write protect or buffered mode, or changing the speed setting of - * the tape drive. - * - * Disks report DPO/FUA support via the device specific parameter - * for MODE SENSE, but the bit is reserved for MODE SELECT. So we - * clear this for disks (and other non-tape devices) to avoid - * potential errors from the target device. - */ - if (device->pd_type != T_SEQUENTIAL) - mh->dev_spec = 0; - mph = MODE_PAGE_HEADER(mh); mph->page_code &= ~SMPH_PS; /* Reserved for MODE SELECT command. */ /* @@ -654,9 +672,8 @@ editlist_save(struct cam_device *device, int dbd, int * page 3 (saved values) then request the changes be permanently * recorded. */ - mode_select(device, (pc << PAGE_CTRL_SHIFT == SMS_PAGE_CTRL_SAVED), - task_attr, retries, timeout, (u_int8_t *)mh, - sizeof(*mh) + hlen + len); + mode_select(device, cdb_len, (pc << PAGE_CTRL_SHIFT == SMS_PAGE_CTRL_SAVED), + task_attr, retries, timeout, data, hlen + mphlen + len); } static int @@ -825,21 +842,27 @@ modepage_edit(void) } static void -modepage_dump(struct cam_device *device, int dbd, int pc, int page, int subpage, - int task_attr, int retries, int timeout) +modepage_dump(struct cam_device *device, int cdb_len, int dbd, int pc, + int page, int subpage, int task_attr, int retries, int timeout) { - u_int8_t data[MAX_COMMAND_SIZE];/* Buffer to hold sense data. */ + u_int8_t data[MAX_DATA_SIZE];/* Buffer to hold sense data. */ u_int8_t *mode_pars; /* Pointer to modepage params. */ - struct scsi_mode_header_6 *mh; /* Location of mode header. */ struct scsi_mode_page_header *mph; struct scsi_mode_page_header_sp *mphsp; size_t indx, len; - mode_sense(device, dbd, pc, page, subpage, task_attr, retries, timeout, - data, sizeof(data)); + mode_sense(device, &cdb_len, dbd, pc, page, subpage, task_attr, + retries, timeout, data, sizeof(data)); - mh = (struct scsi_mode_header_6 *)data; - mph = MODE_PAGE_HEADER(mh); + if (cdb_len == 6) { + struct scsi_mode_header_6 *mh = + (struct scsi_mode_header_6 *)data; + mph = find_mode_page_6(mh); + } else { + struct scsi_mode_header_10 *mh = + (struct scsi_mode_header_10 *)data; + mph = find_mode_page_10(mh); + } if ((mph->page_code & SMPH_SPF) == 0) { mode_pars = (uint8_t *)(mph + 1); len = mph->page_length; @@ -869,8 +892,9 @@ cleanup_editfile(void) } void -mode_edit(struct cam_device *device, int dbd, int pc, int page, int subpage, - int edit, int binary, int task_attr, int retry_count, int timeout) +mode_edit(struct cam_device *device, int cdb_len, int dbd, int pc, int page, + int subpage, int edit, int binary, int task_attr, int retry_count, + int timeout) { const char *pagedb_path; /* Path to modepage database. */ @@ -901,8 +925,8 @@ mode_edit(struct cam_device *device, int dbd, int pc, exit(EX_OSFILE); } - editlist_populate(device, dbd, pc, page, subpage, task_attr, - retry_count, timeout); + editlist_populate(device, cdb_len, dbd, pc, page, subpage, + task_attr, retry_count, timeout); } if (edit) { @@ -911,12 +935,12 @@ mode_edit(struct cam_device *device, int dbd, int pc, errx(EX_USAGE, "it only makes sense to edit page 0 " "(current) or page 3 (saved values)"); modepage_edit(); - editlist_save(device, dbd, pc, page, subpage, task_attr, - retry_count, timeout); + editlist_save(device, cdb_len, dbd, pc, page, subpage, + task_attr, retry_count, timeout); } else if (binary || STAILQ_EMPTY(&editlist)) { /* Display without formatting information. */ - modepage_dump(device, dbd, pc, page, subpage, task_attr, - retry_count, timeout); + modepage_dump(device, cdb_len, dbd, pc, page, subpage, + task_attr, retry_count, timeout); } else { /* Display with format. */ modepage_write(stdout, 0); @@ -924,16 +948,15 @@ mode_edit(struct cam_device *device, int dbd, int pc, } void -mode_list(struct cam_device *device, int dbd, int pc, int subpages, +mode_list(struct cam_device *device, int cdb_len, int dbd, int pc, int subpages, int task_attr, int retry_count, int timeout) { - u_int8_t data[MAX_COMMAND_SIZE];/* Buffer to hold sense data. */ - struct scsi_mode_header_6 *mh; /* Location of mode header. */ + u_int8_t data[MAX_DATA_SIZE];/* Buffer to hold sense data. */ struct scsi_mode_page_header *mph; struct scsi_mode_page_header_sp *mphsp; struct pagename *nameentry; const char *pagedb_path; - int len, page, subpage; + int len, off, page, subpage; if ((pagedb_path = getenv("SCSI_MODES")) == NULL) pagedb_path = DEFAULT_SCSI_MODE_DB; @@ -944,26 +967,36 @@ mode_list(struct cam_device *device, int dbd, int pc, } /* Build the list of all mode pages by querying the "all pages" page. */ - mode_sense(device, dbd, pc, SMS_ALL_PAGES_PAGE, + mode_sense(device, &cdb_len, dbd, pc, SMS_ALL_PAGES_PAGE, subpages ? SMS_SUBPAGE_ALL : 0, task_attr, retry_count, timeout, data, sizeof(data)); - mh = (struct scsi_mode_header_6 *)data; - len = sizeof(*mh) + mh->blk_desc_len; /* Skip block descriptors. */ + /* Skip block descriptors. */ + if (cdb_len == 6) { + struct scsi_mode_header_6 *mh = + (struct scsi_mode_header_6 *)data; + len = mh->data_length; + off = sizeof(*mh) + mh->blk_desc_len; + } else { + struct scsi_mode_header_10 *mh = + (struct scsi_mode_header_10 *)data; + len = scsi_2btoul(mh->data_length); + off = sizeof(*mh) + scsi_2btoul(mh->blk_desc_len); + } /* Iterate through the pages in the reply. */ - while (len < mh->data_length) { + while (off < len) { /* Locate the next mode page header. */ - mph = (struct scsi_mode_page_header *)((intptr_t)mh + len); + mph = (struct scsi_mode_page_header *)(data + off); if ((mph->page_code & SMPH_SPF) == 0) { page = mph->page_code & SMS_PAGE_CODE; subpage = 0; - len += sizeof(*mph) + mph->page_length; + off += sizeof(*mph) + mph->page_length; } else { mphsp = (struct scsi_mode_page_header_sp *)mph; page = mphsp->page_code & SMS_PAGE_CODE; subpage = mphsp->subpage; - len += sizeof(*mphsp) + scsi_2btoul(mphsp->page_length); + off += sizeof(*mphsp) + scsi_2btoul(mphsp->page_length); } nameentry = nameentry_lookup(page, subpage); From owner-svn-src-stable-12@freebsd.org Tue Aug 27 03:55:39 2019 Return-Path: Delivered-To: svn-src-stable-12@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 C9ED2C8241; Tue, 27 Aug 2019 03:55: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 46HZlv5XTHz4Jh8; Tue, 27 Aug 2019 03:55: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 8711A18E43; Tue, 27 Aug 2019 03:55: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 x7R3tdjr094723; Tue, 27 Aug 2019 03:55:39 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7R3tc9r094717; Tue, 27 Aug 2019 03:55:38 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201908270355.x7R3tc9r094717@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Tue, 27 Aug 2019 03:55:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r351530 - in stable/12: sbin/camcontrol sys/cam/scsi X-SVN-Group: stable-12 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: in stable/12: sbin/camcontrol sys/cam/scsi X-SVN-Commit-Revision: 351530 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-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Aug 2019 03:55:39 -0000 Author: mav Date: Tue Aug 27 03:55:38 2019 New Revision: 351530 URL: https://svnweb.freebsd.org/changeset/base/351530 Log: MFC r350676, r350677: Make `camcontrol modepage` support block descriptors. It allows to read and write block descriptors alike to mode page parameters. It allows to change block size or short-stroke HDDs or overprovision SSDs. Depenting on -P parameter the change can be either persistent or till reset. In case of block size change device may need reformat after the setting. In case of SSD overprovisioning format or sanitize may be needed to really free the flash. During implementation appeared that csio_encode_visit() can not handle integers of more then 4 bytes, that makes 8-byte LBA handling awkward. I had to split it into two 4-byte halves now. Relnotes: yes Sponsored by: iXsystems, Inc. Modified: stable/12/sbin/camcontrol/camcontrol.8 stable/12/sbin/camcontrol/camcontrol.c stable/12/sbin/camcontrol/camcontrol.h stable/12/sbin/camcontrol/modeedit.c stable/12/sys/cam/scsi/scsi_all.c stable/12/sys/cam/scsi/scsi_all.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sbin/camcontrol/camcontrol.8 ============================================================================== --- stable/12/sbin/camcontrol/camcontrol.8 Tue Aug 27 03:54:29 2019 (r351529) +++ stable/12/sbin/camcontrol/camcontrol.8 Tue Aug 27 03:55:38 2019 (r351530) @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 30, 2019 +.Dd August 6, 2019 .Dt CAMCONTROL 8 .Os .Sh NAME @@ -125,6 +125,8 @@ .Op Fl 6 .Aq Fl m Ar page[,subpage] | Fl l .Op Fl P Ar pgctl +.Op Fl D +.Op Fl L .Op Fl b | Fl e .Op Fl d .Nm @@ -733,6 +735,11 @@ If not specified, starts with 10 byte commands and falls back to 6 byte on error. .It Fl d Disable block descriptors for mode sense. +.It Fl D +Display/edit block descriptors instead of mode page. +.It Fl L +Use long LBA block descriptors. +Allows number of LBAs bigger then 2^^32. .It Fl b Displays mode page data in binary format. .It Fl e Modified: stable/12/sbin/camcontrol/camcontrol.c ============================================================================== --- stable/12/sbin/camcontrol/camcontrol.c Tue Aug 27 03:54:29 2019 (r351529) +++ stable/12/sbin/camcontrol/camcontrol.c Tue Aug 27 03:55:38 2019 (r351530) @@ -230,7 +230,7 @@ static struct camcontrol_opts option_table[] = { {"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, "6bdelm:P:"}, + {"modepage", CAM_CMD_MODE_PAGE, CAM_ARG_NONE, "6bdelm:DLP:"}, {"tags", CAM_CMD_TAG, CAM_ARG_NONE, "N:q"}, {"negotiate", CAM_CMD_RATE, CAM_ARG_NONE, negotiate_opts}, {"rate", CAM_CMD_RATE, CAM_ARG_NONE, negotiate_opts}, @@ -4611,9 +4611,9 @@ reassignblocks(struct cam_device *device, u_int32_t *b #ifndef MINIMALISTIC void -mode_sense(struct cam_device *device, int *cdb_len, int dbd, int pc, int page, - int subpage, int task_attr, int retry_count, int timeout, u_int8_t *data, - int datalen) +mode_sense(struct cam_device *device, int *cdb_len, int dbd, int llbaa, int pc, + int page, int subpage, int task_attr, int retry_count, int timeout, + u_int8_t *data, int datalen) { union ccb *ccb; int error_code, sense_key, asc, ascq; @@ -4645,6 +4645,11 @@ retry: /* minimum_cmd_size */ *cdb_len, /* sense_len */ SSD_FULL_SIZE, /* timeout */ timeout ? timeout : 5000); + if (llbaa && ccb->csio.cdb_len == 10) { + struct scsi_mode_sense_10 *cdb = + (struct scsi_mode_sense_10 *)ccb->csio.cdb_io.cdb_bytes; + cdb->byte2 |= SMS10_LLBAA; + } /* Record what CDB size the above function really set. */ *cdb_len = ccb->csio.cdb_len; @@ -4736,8 +4741,8 @@ modepage(struct cam_device *device, int argc, char **a int task_attr, int retry_count, int timeout) { char *str_subpage; - int c, page = -1, subpage = -1, pc = 0; - int binary = 0, cdb_len = 10, dbd = 0, edit = 0, list = 0; + int c, page = -1, subpage = -1, pc = 0, llbaa = 0; + int binary = 0, cdb_len = 10, dbd = 0, desc = 0, edit = 0, list = 0; while ((c = getopt(argc, argv, combinedopt)) != -1) { switch(c) { @@ -4769,6 +4774,12 @@ modepage(struct cam_device *device, int argc, char **a if (subpage < 0) errx(1, "invalid mode subpage %d", subpage); break; + case 'D': + desc = 1; + break; + case 'L': + llbaa = 1; + break; case 'P': pc = strtol(optarg, NULL, 0); if ((pc < 0) || (pc > 3)) @@ -4779,15 +4790,21 @@ modepage(struct cam_device *device, int argc, char **a } } - if (page == -1 && list == 0) + if (page == -1 && desc == 0 && list == 0) errx(1, "you must specify a mode page!"); + if (dbd && desc) + errx(1, "-d and -D are incompatible!"); + + if (llbaa && cdb_len != 10) + errx(1, "LLBAA bit is not present in MODE SENSE(6)!"); + if (list != 0) { mode_list(device, cdb_len, dbd, pc, list > 1, task_attr, retry_count, timeout); } else { - mode_edit(device, cdb_len, dbd, pc, page, subpage, edit, - binary, task_attr, retry_count, timeout); + mode_edit(device, cdb_len, desc, dbd, llbaa, pc, page, subpage, + edit, binary, task_attr, retry_count, timeout); } } Modified: stable/12/sbin/camcontrol/camcontrol.h ============================================================================== --- stable/12/sbin/camcontrol/camcontrol.h Tue Aug 27 03:54:29 2019 (r351529) +++ stable/12/sbin/camcontrol/camcontrol.h Tue Aug 27 03:55:38 2019 (r351530) @@ -88,15 +88,15 @@ int epc(struct cam_device *device, int argc, char **ar int timestamp(struct cam_device *device, int argc, char **argv, char *combinedopt, int task_attr, int retry_count, int timeout, int verbosemode); -void mode_sense(struct cam_device *device, int *cdb_len, int dbd, int pc, - int page, int subpage, int task_attr, int retry_count, +void mode_sense(struct cam_device *device, int *cdb_len, int dbd, int llbaa, + int pc, int page, int subpage, int task_attr, int retry_count, int timeout, uint8_t *data, int datalen); void mode_select(struct cam_device *device, int cdb_len, int save_pages, int task_attr, int retry_count, int timeout, u_int8_t *data, int datalen); -void mode_edit(struct cam_device *device, int cdb_len, int dbd, int pc, - int page, int subpage, int edit, int binary, int task_attr, - int retry_count, int timeout); +void mode_edit(struct cam_device *device, int cdb_len, int desc, int dbd, + int llbaa, int pc, int page, int subpage, int edit, int binary, + int task_attr, int retry_count, int timeout); void mode_list(struct cam_device *device, int cdb_len, int dbd, int pc, int subpages, int task_attr, int retry_count, int timeout); int scsidoinquiry(struct cam_device *device, int argc, char **argv, Modified: stable/12/sbin/camcontrol/modeedit.c ============================================================================== --- stable/12/sbin/camcontrol/modeedit.c Tue Aug 27 03:54:29 2019 (r351529) +++ stable/12/sbin/camcontrol/modeedit.c Tue Aug 27 03:55:38 2019 (r351530) @@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include @@ -96,6 +97,8 @@ static void editentry_create(void *hook, int letter, int count, char *name); static void editentry_update(void *hook, int letter, void *arg, int count, char *name); +static void editentry_create_desc(void *hook, int letter, void *arg, + int count, char *name); static int editentry_save(void *hook, char *name); static struct editentry *editentry_lookup(char *name); static int editentry_set(char *name, char *newvalue, @@ -103,9 +106,16 @@ static int editentry_set(char *name, char *newvalue, static void editlist_populate(struct cam_device *device, int cdb_len, int dbd, int pc, int page, int subpage, int task_attr, int retries, int timeout); +static void editlist_populate_desc(struct cam_device *device, + int cdb_len, int llbaa, int pc, int page, + int subpage, int task_attr, int retries, + int timeout); static void editlist_save(struct cam_device *device, int cdb_len, int dbd, int pc, int page, int subpage, int task_attr, int retries, int timeout); +static void editlist_save_desc(struct cam_device *device, int cdb_len, + int llbaa, int pc, int page, int subpage, + int task_attr, int retries, int timeout); static void nameentry_create(int page, int subpage, char *name); static struct pagename *nameentry_lookup(int page, int subpage); static int load_format(const char *pagedb_path, int lpage, @@ -116,6 +126,10 @@ static void modepage_edit(void); static void modepage_dump(struct cam_device *device, int cdb_len, int dbd, int pc, int page, int subpage, int task_attr, int retries, int timeout); +static void modepage_dump_desc(struct cam_device *device, + int cdb_len, int llbaa, int pc, int page, + int subpage, int task_attr, int retries, + int timeout); static void cleanup_editfile(void); @@ -182,6 +196,43 @@ editentry_update(void *hook __unused, int letter, void } } +static void +editentry_create_desc(void *hook __unused, int letter, void *arg, int count, + char *name) +{ + struct editentry *newentry; /* Buffer to hold new entry. */ + + /* Allocate memory for the new entry and a copy of the entry name. */ + if ((newentry = malloc(sizeof(struct editentry))) == NULL || + (newentry->name = strdup(name)) == NULL) + err(EX_OSERR, NULL); + + /* Trim any trailing whitespace for the entry name. */ + RTRIM(newentry->name); + + newentry->editable = 1; + newentry->type = letter; + newentry->size = count; + newentry->value.svalue = NULL; + + STAILQ_INSERT_TAIL(&editlist, newentry, link); + + switch (letter) { + case 'i': /* Byte-sized integral type. */ + case 'b': /* Bit-sized integral types. */ + case 't': + newentry->value.ivalue = (intptr_t)arg; + break; + + case 'c': /* Character array. */ + case 'z': /* Null-padded string. */ + editentry_set(name, (char *)arg, 0); + break; + default: + ; /* NOTREACHED */ + } +} + static int editentry_save(void *hook __unused, char *name) { @@ -238,17 +289,14 @@ editentry_set(char *name, char *newvalue, int editonly struct editentry *dest; /* Modepage entry to update. */ char *cval; /* Pointer to new string value. */ char *convertend; /* End-of-conversion pointer. */ - int ival; /* New integral value. */ + long long ival, newival; /* New integral value. */ int resolution; /* Resolution in bits for integer conversion. */ /* * Macro to determine the maximum value of the given size for the current * resolution. - * XXX Lovely x86's optimize out the case of shifting by 32 and gcc doesn't - * currently workaround it (even for int64's), so we have to kludge it. */ -#define RESOLUTION_MAX(size) ((resolution * (size) == 32)? \ - INT_MAX: (1 << (resolution * (size))) - 1) +#define RESOLUTION_MAX(size) ((1LL << (resolution * (size))) - 1) assert(newvalue != NULL); if (*newvalue == '\0') @@ -265,13 +313,13 @@ editentry_set(char *name, char *newvalue, int editonly case 't': /* Convert the value string to an integer. */ resolution = (dest->type == 'i')? 8: 1; - ival = (int)strtol(newvalue, &convertend, 0); + ival = strtoll(newvalue, &convertend, 0); if (*convertend != '\0') returnerr(EINVAL); if (ival > RESOLUTION_MAX(dest->size) || ival < 0) { - int newival = (ival < 0)? 0: RESOLUTION_MAX(dest->size); - warnx("value %d is out of range for entry %s; clipping " - "to %d", ival, name, newival); + newival = (ival < 0) ? 0 : RESOLUTION_MAX(dest->size); + warnx("value %lld is out of range for entry %s; " + "clipping to %lld", ival, name, newival); ival = newival; } if (dest->value.ivalue != ival) @@ -548,7 +596,7 @@ static void editlist_populate(struct cam_device *device, int cdb_len, int dbd, int pc, int page, int subpage, int task_attr, int retries, int timeout) { - u_int8_t data[MAX_DATA_SIZE];/* Buffer to hold sense data. */ + u_int8_t data[MAX_DATA_SIZE]; /* Buffer to hold mode parameters. */ u_int8_t *mode_pars; /* Pointer to modepage params. */ struct scsi_mode_page_header *mph; struct scsi_mode_page_header_sp *mphsp; @@ -557,8 +605,8 @@ editlist_populate(struct cam_device *device, int cdb_l STAILQ_INIT(&editlist); /* Fetch changeable values; use to build initial editlist. */ - mode_sense(device, &cdb_len, dbd, 1, page, subpage, task_attr, retries, - timeout, data, sizeof(data)); + mode_sense(device, &cdb_len, dbd, 0, 1, page, subpage, task_attr, + retries, timeout, data, sizeof(data)); if (cdb_len == 6) { struct scsi_mode_header_6 *mh = @@ -583,16 +631,77 @@ editlist_populate(struct cam_device *device, int cdb_l buff_decode_visit(mode_pars, len, format, editentry_create, 0); /* Fetch the current/saved values; use to set editentry values. */ - mode_sense(device, &cdb_len, dbd, pc, page, subpage, task_attr, + mode_sense(device, &cdb_len, dbd, 0, pc, page, subpage, task_attr, retries, timeout, data, sizeof(data)); buff_decode_visit(mode_pars, len, format, editentry_update, 0); } static void +editlist_populate_desc(struct cam_device *device, int cdb_len, int llbaa, int pc, + int page, int subpage, int task_attr, int retries, int timeout) +{ + uint8_t data[MAX_DATA_SIZE]; /* Buffer to hold mode parameters. */ + uint8_t *desc; /* Pointer to block descriptor. */ + char num[8]; + struct sbuf sb; + size_t len; + u_int longlba, dlen, i; + + STAILQ_INIT(&editlist); + + /* Fetch the current/saved values. */ + mode_sense(device, &cdb_len, 0, llbaa, pc, page, subpage, task_attr, + retries, timeout, data, sizeof(data)); + + if (cdb_len == 6) { + struct scsi_mode_header_6 *mh = + (struct scsi_mode_header_6 *)data; + desc = (uint8_t *)(mh + 1); + len = mh->blk_desc_len; + longlba = 0; + } else { + struct scsi_mode_header_10 *mh = + (struct scsi_mode_header_10 *)data; + desc = (uint8_t *)(mh + 1); + len = scsi_2btoul(mh->blk_desc_len); + longlba = (mh->flags & SMH_LONGLBA) != 0; + } + dlen = longlba ? 16 : 8; + len = MIN(len, sizeof(data) - (desc - data)); + + sbuf_new(&sb, format, sizeof(format), SBUF_FIXEDLEN); + num[0] = 0; + for (i = 0; i * dlen < len; i++) { + if (i > 0) + snprintf(num, sizeof(num), " %d", i + 1); + if (longlba) { + sbuf_printf(&sb, "{Number of Logical Blocks%s High} i4\n", num); + sbuf_printf(&sb, "{Number of Logical Blocks%s} i4\n", num); + sbuf_cat(&sb, "{Reserved} *i4\n"); + sbuf_printf(&sb, "{Logical Block Length%s} i4\n", num); + } else if (device->pd_type == T_DIRECT) { + sbuf_printf(&sb, "{Number of Logical Blocks%s} i4\n", num); + sbuf_cat(&sb, "{Reserved} *i1\n"); + sbuf_printf(&sb, "{Logical Block Length%s} i3\n", num); + } else { + sbuf_printf(&sb, "{Density Code%s} i1\n", num); + sbuf_printf(&sb, "{Number of Logical Blocks%s} i3\n", num); + sbuf_cat(&sb, "{Reserved} *i1\n"); + sbuf_printf(&sb, "{Logical Block Length%s} i3\n", num); + } + } + sbuf_finish(&sb); + sbuf_delete(&sb); + + /* Decode the value data, creating edit_entries for each value. */ + buff_decode_visit(desc, len, format, editentry_create_desc, 0); +} + +static void editlist_save(struct cam_device *device, int cdb_len, int dbd, int pc, int page, int subpage, int task_attr, int retries, int timeout) { - u_int8_t data[MAX_DATA_SIZE];/* Buffer to hold sense data. */ + u_int8_t data[MAX_DATA_SIZE]; /* Buffer to hold mode parameters. */ u_int8_t *mode_pars; /* Pointer to modepage params. */ struct scsi_mode_page_header *mph; struct scsi_mode_page_header_sp *mphsp; @@ -603,7 +712,7 @@ editlist_save(struct cam_device *device, int cdb_len, return; /* Preload the CDB buffer with the current mode page data. */ - mode_sense(device, &cdb_len, dbd, pc, page, subpage, task_attr, + mode_sense(device, &cdb_len, dbd, 0, pc, page, subpage, task_attr, retries, timeout, data, sizeof(data)); /* Initial headers & offsets. */ @@ -676,6 +785,56 @@ editlist_save(struct cam_device *device, int cdb_len, task_attr, retries, timeout, data, hlen + mphlen + len); } +static void +editlist_save_desc(struct cam_device *device, int cdb_len, int llbaa, int pc, + int page, int subpage, int task_attr, int retries, int timeout) +{ + uint8_t data[MAX_DATA_SIZE]; /* Buffer to hold mode parameters. */ + uint8_t *desc; /* Pointer to block descriptor. */ + size_t len, hlen; + + /* Make sure that something changed before continuing. */ + if (! editlist_changed) + return; + + /* Preload the CDB buffer with the current mode page data. */ + mode_sense(device, &cdb_len, 0, llbaa, pc, page, subpage, task_attr, + retries, timeout, data, sizeof(data)); + + /* Initial headers & offsets. */ + if (cdb_len == 6) { + struct scsi_mode_header_6 *mh = + (struct scsi_mode_header_6 *)data; + hlen = sizeof(*mh); + desc = (uint8_t *)(mh + 1); + len = mh->blk_desc_len; + mh->data_length = 0; /* Reserved for MODE SELECT command. */ + if (device->pd_type != T_SEQUENTIAL) + mh->dev_spec = 0; /* See comment above */ + } else { + struct scsi_mode_header_10 *mh = + (struct scsi_mode_header_10 *)data; + hlen = sizeof(*mh); + desc = (uint8_t *)(mh + 1); + len = scsi_2btoul(mh->blk_desc_len); + scsi_ulto2b(0, mh->data_length); /* Reserved for MODE SELECT. */ + if (device->pd_type != T_SEQUENTIAL) + mh->dev_spec = 0; /* See comment above */ + } + len = MIN(len, sizeof(data) - (desc - data)); + + /* Encode the value data to be passed back to the device. */ + buff_encode_visit(desc, len, format, editentry_save, 0); + + /* + * Write the changes back to the device. If the user editted control + * page 3 (saved values) then request the changes be permanently + * recorded. + */ + mode_select(device, cdb_len, (pc << PAGE_CTRL_SHIFT == SMS_PAGE_CTRL_SAVED), + task_attr, retries, timeout, data, hlen + len); +} + static int modepage_write(FILE *file, int editonly) { @@ -689,7 +848,7 @@ modepage_write(FILE *file, int editonly) fprintf(file, "%s: %s\n", scan->name, scan->value.svalue); } else { - fprintf(file, "%s: %d\n", scan->name, + fprintf(file, "%s: %u\n", scan->name, scan->value.ivalue); } } @@ -845,13 +1004,13 @@ static void modepage_dump(struct cam_device *device, int cdb_len, int dbd, int pc, int page, int subpage, int task_attr, int retries, int timeout) { - u_int8_t data[MAX_DATA_SIZE];/* Buffer to hold sense data. */ + u_int8_t data[MAX_DATA_SIZE]; /* Buffer to hold mode parameters. */ u_int8_t *mode_pars; /* Pointer to modepage params. */ struct scsi_mode_page_header *mph; struct scsi_mode_page_header_sp *mphsp; size_t indx, len; - mode_sense(device, &cdb_len, dbd, pc, page, subpage, task_attr, + mode_sense(device, &cdb_len, dbd, 0, pc, page, subpage, task_attr, retries, timeout, data, sizeof(data)); if (cdb_len == 6) { @@ -880,7 +1039,38 @@ modepage_dump(struct cam_device *device, int cdb_len, } putchar('\n'); } +static void +modepage_dump_desc(struct cam_device *device, int cdb_len, int llbaa, int pc, + int page, int subpage, int task_attr, int retries, int timeout) +{ + uint8_t data[MAX_DATA_SIZE]; /* Buffer to hold mode parameters. */ + uint8_t *desc; /* Pointer to block descriptor. */ + size_t indx, len; + mode_sense(device, &cdb_len, 0, llbaa, pc, page, subpage, task_attr, + retries, timeout, data, sizeof(data)); + + if (cdb_len == 6) { + struct scsi_mode_header_6 *mh = + (struct scsi_mode_header_6 *)data; + desc = (uint8_t *)(mh + 1); + len = mh->blk_desc_len; + } else { + struct scsi_mode_header_10 *mh = + (struct scsi_mode_header_10 *)data; + desc = (uint8_t *)(mh + 1); + len = scsi_2btoul(mh->blk_desc_len); + } + len = MIN(len, sizeof(data) - (desc - data)); + + /* Print the raw mode page data with newlines each 8 bytes. */ + for (indx = 0; indx < len; indx++) { + printf("%02x%c", desc[indx], + (((indx + 1) % 8) == 0) ? '\n' : ' '); + } + putchar('\n'); +} + static void cleanup_editfile(void) { @@ -892,16 +1082,19 @@ cleanup_editfile(void) } void -mode_edit(struct cam_device *device, int cdb_len, int dbd, int pc, int page, - int subpage, int edit, int binary, int task_attr, int retry_count, - int timeout) +mode_edit(struct cam_device *device, int cdb_len, int desc, int dbd, int llbaa, + int pc, int page, int subpage, int edit, int binary, int task_attr, + int retry_count, int timeout) { const char *pagedb_path; /* Path to modepage database. */ - if (edit && binary) - errx(EX_USAGE, "cannot edit in binary mode."); - - if (! binary) { + if (binary) { + if (edit) + errx(EX_USAGE, "cannot edit in binary mode."); + } else if (desc) { + editlist_populate_desc(device, cdb_len, llbaa, pc, page, + subpage, task_attr, retry_count, timeout); + } else { if ((pagedb_path = getenv("SCSI_MODES")) == NULL) pagedb_path = DEFAULT_SCSI_MODE_DB; @@ -935,12 +1128,22 @@ mode_edit(struct cam_device *device, int cdb_len, int errx(EX_USAGE, "it only makes sense to edit page 0 " "(current) or page 3 (saved values)"); modepage_edit(); - editlist_save(device, cdb_len, dbd, pc, page, subpage, - task_attr, retry_count, timeout); + if (desc) { + editlist_save_desc(device, cdb_len, llbaa, pc, page, + subpage, task_attr, retry_count, timeout); + } else { + editlist_save(device, cdb_len, dbd, pc, page, subpage, + task_attr, retry_count, timeout); + } } else if (binary || STAILQ_EMPTY(&editlist)) { /* Display without formatting information. */ - modepage_dump(device, cdb_len, dbd, pc, page, subpage, - task_attr, retry_count, timeout); + if (desc) { + modepage_dump_desc(device, cdb_len, llbaa, pc, page, + subpage, task_attr, retry_count, timeout); + } else { + modepage_dump(device, cdb_len, dbd, pc, page, subpage, + task_attr, retry_count, timeout); + } } else { /* Display with format. */ modepage_write(stdout, 0); @@ -951,7 +1154,7 @@ void mode_list(struct cam_device *device, int cdb_len, int dbd, int pc, int subpages, int task_attr, int retry_count, int timeout) { - u_int8_t data[MAX_DATA_SIZE];/* Buffer to hold sense data. */ + u_int8_t data[MAX_DATA_SIZE]; /* Buffer to hold mode parameters. */ struct scsi_mode_page_header *mph; struct scsi_mode_page_header_sp *mphsp; struct pagename *nameentry; @@ -967,7 +1170,7 @@ mode_list(struct cam_device *device, int cdb_len, int } /* Build the list of all mode pages by querying the "all pages" page. */ - mode_sense(device, &cdb_len, dbd, pc, SMS_ALL_PAGES_PAGE, + mode_sense(device, &cdb_len, dbd, 0, pc, SMS_ALL_PAGES_PAGE, subpages ? SMS_SUBPAGE_ALL : 0, task_attr, retry_count, timeout, data, sizeof(data)); Modified: stable/12/sys/cam/scsi/scsi_all.c ============================================================================== --- stable/12/sys/cam/scsi/scsi_all.c Tue Aug 27 03:54:29 2019 (r351529) +++ stable/12/sys/cam/scsi/scsi_all.c Tue Aug 27 03:55:38 2019 (r351530) @@ -2056,7 +2056,7 @@ static struct asc_table_entry asc_table[] = { { SST(0x30, 0x13, SS_RDEF, /* XXX TBD */ "Cleaning volume expired") }, /* DT WRO BK */ - { SST(0x31, 0x00, SS_RDEF, + { SST(0x31, 0x00, SS_FATAL | ENXIO, "Medium format corrupted") }, /* D L RO B */ { SST(0x31, 0x01, SS_RDEF, Modified: stable/12/sys/cam/scsi/scsi_all.h ============================================================================== --- stable/12/sys/cam/scsi/scsi_all.h Tue Aug 27 03:54:29 2019 (r351529) +++ stable/12/sys/cam/scsi/scsi_all.h Tue Aug 27 03:55:38 2019 (r351530) @@ -3622,7 +3622,9 @@ struct scsi_mode_header_10 u_int8_t data_length[2];/* Sense data length */ u_int8_t medium_type; u_int8_t dev_spec; - u_int8_t unused[2]; + u_int8_t flags; +#define SMH_LONGLBA 0x01 + u_int8_t unused; u_int8_t blk_desc_len[2]; }; From owner-svn-src-stable-12@freebsd.org Tue Aug 27 04:01:10 2019 Return-Path: Delivered-To: svn-src-stable-12@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 72A21C8502; Tue, 27 Aug 2019 04:01:10 +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 46HZtG1ZcSz4K11; Tue, 27 Aug 2019 04:01:10 +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 F195D18E82; Tue, 27 Aug 2019 04:01:09 +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 x7R419ki096585; Tue, 27 Aug 2019 04:01:09 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7R419bs096584; Tue, 27 Aug 2019 04:01:09 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201908270401.x7R419bs096584@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Tue, 27 Aug 2019 04:01:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r351531 - stable/12/sys/dev/nvd X-SVN-Group: stable-12 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/12/sys/dev/nvd X-SVN-Commit-Revision: 351531 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-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Aug 2019 04:01:10 -0000 Author: mav Date: Tue Aug 27 04:01:09 2019 New Revision: 351531 URL: https://svnweb.freebsd.org/changeset/base/351531 Log: MFC r351004, r351006: Make nvd(4) report NGUID or EUI64 as GEOM::lunid. With support for multiple namespaces and multiple ports in NVMe there is now a need for reliable unique namespace identification alike to SCSI. Sponsored by: iXsystems, Inc. Modified: stable/12/sys/dev/nvd/nvd.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/nvd/nvd.c ============================================================================== --- stable/12/sys/dev/nvd/nvd.c Tue Aug 27 03:55:38 2019 (r351530) +++ stable/12/sys/dev/nvd/nvd.c Tue Aug 27 04:01:09 2019 (r351531) @@ -54,6 +54,7 @@ struct nvd_controller; static disk_ioctl_t nvd_ioctl; static disk_strategy_t nvd_strategy; static dumper_t nvd_dump; +static disk_getattr_t nvd_getattr; static void nvd_done(void *arg, const struct nvme_completion *cpl); static void nvd_gone(struct nvd_disk *ndisk); @@ -294,6 +295,51 @@ nvd_dump(void *arg, void *virt, vm_offset_t phys, off_ return (nvme_ns_dump(ndisk->ns, virt, offset, len)); } +static int +nvd_getattr(struct bio *bp) +{ + struct nvd_disk *ndisk = (struct nvd_disk *)bp->bio_disk->d_drv1; + const struct nvme_namespace_data *nsdata; + u_int i; + + if (!strcmp("GEOM::lunid", bp->bio_attribute)) { + nsdata = nvme_ns_get_data(ndisk->ns); + + /* Try to return NGUID as lunid. */ + for (i = 0; i < sizeof(nsdata->nguid); i++) { + if (nsdata->nguid[i] != 0) + break; + } + if (i < sizeof(nsdata->nguid)) { + if (bp->bio_length < sizeof(nsdata->nguid) * 2 + 1) + return (EFAULT); + for (i = 0; i < sizeof(nsdata->nguid); i++) { + sprintf(&bp->bio_data[i * 2], "%02x", + nsdata->nguid[i]); + } + bp->bio_completed = bp->bio_length; + return (0); + } + + /* Try to return EUI64 as lunid. */ + for (i = 0; i < sizeof(nsdata->eui64); i++) { + if (nsdata->eui64[i] != 0) + break; + } + if (i < sizeof(nsdata->eui64)) { + if (bp->bio_length < sizeof(nsdata->eui64) * 2 + 1) + return (EFAULT); + for (i = 0; i < sizeof(nsdata->eui64); i++) { + sprintf(&bp->bio_data[i * 2], "%02x", + nsdata->eui64[i]); + } + bp->bio_completed = bp->bio_length; + return (0); + } + } + return (-1); +} + static void nvd_done(void *arg, const struct nvme_completion *cpl) { @@ -403,6 +449,7 @@ nvd_new_disk(struct nvme_namespace *ns, void *ctrlr_ar disk->d_strategy = nvd_strategy; disk->d_ioctl = nvd_ioctl; disk->d_dump = nvd_dump; + disk->d_getattr = nvd_getattr; disk->d_gone = nvd_gonecb; disk->d_name = NVD_STR; disk->d_unit = ndisk->unit; From owner-svn-src-stable-12@freebsd.org Tue Aug 27 04:01:57 2019 Return-Path: Delivered-To: svn-src-stable-12@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 3F3B6C857E; Tue, 27 Aug 2019 04:01:57 +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 46HZv9112Nz4K9H; Tue, 27 Aug 2019 04:01:57 +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 04D6C18EC4; Tue, 27 Aug 2019 04:01:57 +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 x7R41u98098125; Tue, 27 Aug 2019 04:01:56 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7R41uXe098123; Tue, 27 Aug 2019 04:01:56 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201908270401.x7R41uXe098123@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Tue, 27 Aug 2019 04:01:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r351532 - stable/12/sys/dev/nvme X-SVN-Group: stable-12 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/12/sys/dev/nvme X-SVN-Commit-Revision: 351532 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-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Aug 2019 04:01:57 -0000 Author: mav Date: Tue Aug 27 04:01:56 2019 New Revision: 351532 URL: https://svnweb.freebsd.org/changeset/base/351532 Log: MFC r351028: Report NOIOB and NPWG fields as stripe size. Namespace Optimal I/O Boundary field added in NVMe 1.3 and Namespace Preferred Write Granularity added in 1.4 allow upper layers to align I/Os for improved SSD performance and endurance. I don't have hardware reportig those yet, but NPWG could probably be reported by bhyve. Sponsored by: iXsystems, Inc. Modified: stable/12/sys/dev/nvme/nvme_ns.c stable/12/sys/dev/nvme/nvme_private.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/nvme/nvme_ns.c ============================================================================== --- stable/12/sys/dev/nvme/nvme_ns.c Tue Aug 27 04:01:09 2019 (r351531) +++ stable/12/sys/dev/nvme/nvme_ns.c Tue Aug 27 04:01:56 2019 (r351532) @@ -231,7 +231,11 @@ uint32_t nvme_ns_get_stripesize(struct nvme_namespace *ns) { - return (ns->stripesize); + if (((ns->data.nsfeat >> NVME_NS_DATA_NSFEAT_NPVALID_SHIFT) & + NVME_NS_DATA_NSFEAT_NPVALID_MASK) != 0 && ns->data.npwg != 0) { + return ((ns->data.npwg + 1) * nvme_ns_get_sector_size(ns)); + } + return (ns->boundary); } static void @@ -447,12 +451,12 @@ nvme_ns_bio_process(struct nvme_namespace *ns, struct bp->bio_driver1 = cb_fn; - if (ns->stripesize > 0 && + if (ns->boundary > 0 && (bp->bio_cmd == BIO_READ || bp->bio_cmd == BIO_WRITE)) { num_bios = nvme_get_num_segments(bp->bio_offset, - bp->bio_bcount, ns->stripesize); + bp->bio_bcount, ns->boundary); if (num_bios > 1) - return (nvme_ns_split_bio(ns, bp, ns->stripesize)); + return (nvme_ns_split_bio(ns, bp, ns->boundary)); } switch (bp->bio_cmd) { @@ -511,27 +515,8 @@ nvme_ns_construct(struct nvme_namespace *ns, uint32_t ns->ctrlr = ctrlr; ns->id = id; - ns->stripesize = 0; /* - * Older Intel devices advertise in vendor specific space an alignment - * that improves performance. If present use for the stripe size. NVMe - * 1.3 standardized this as NOIOB, and newer Intel drives use that. - */ - switch (pci_get_devid(ctrlr->dev)) { - case 0x09538086: /* Intel DC PC3500 */ - case 0x0a538086: /* Intel DC PC3520 */ - case 0x0a548086: /* Intel DC PC4500 */ - case 0x0a558086: /* Dell Intel P4600 */ - if (ctrlr->cdata.vs[3] != 0) - ns->stripesize = - (1 << ctrlr->cdata.vs[3]) * ctrlr->min_page_size; - break; - default: - break; - } - - /* * Namespaces are reconstructed after a controller reset, so check * to make sure we only call mtx_init once on each mtx. * @@ -574,6 +559,27 @@ nvme_ns_construct(struct nvme_namespace *ns, uint32_t printf("lba format %d exceeds number supported (%d)\n", flbas_fmt, ns->data.nlbaf + 1); return (ENXIO); + } + + /* + * Older Intel devices advertise in vendor specific space an alignment + * that improves performance. If present use for the stripe size. NVMe + * 1.3 standardized this as NOIOB, and newer Intel drives use that. + */ + switch (pci_get_devid(ctrlr->dev)) { + case 0x09538086: /* Intel DC PC3500 */ + case 0x0a538086: /* Intel DC PC3520 */ + case 0x0a548086: /* Intel DC PC4500 */ + case 0x0a558086: /* Dell Intel P4600 */ + if (ctrlr->cdata.vs[3] != 0) + ns->boundary = + (1 << ctrlr->cdata.vs[3]) * ctrlr->min_page_size; + else + ns->boundary = 0; + break; + default: + ns->boundary = ns->data.noiob * nvme_ns_get_sector_size(ns); + break; } if (nvme_ctrlr_has_dataset_mgmt(&ctrlr->cdata)) Modified: stable/12/sys/dev/nvme/nvme_private.h ============================================================================== --- stable/12/sys/dev/nvme/nvme_private.h Tue Aug 27 04:01:09 2019 (r351531) +++ stable/12/sys/dev/nvme/nvme_private.h Tue Aug 27 04:01:56 2019 (r351532) @@ -223,7 +223,7 @@ struct nvme_namespace { uint32_t flags; struct cdev *cdev; void *cons_cookie[NVME_MAX_CONSUMERS]; - uint32_t stripesize; + uint32_t boundary; struct mtx lock; }; From owner-svn-src-stable-12@freebsd.org Tue Aug 27 04:02:26 2019 Return-Path: Delivered-To: svn-src-stable-12@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 79B25C861F; Tue, 27 Aug 2019 04:02:26 +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 46HZvk2hnSz4KQr; Tue, 27 Aug 2019 04:02:26 +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 3F4DF19010; Tue, 27 Aug 2019 04:02:26 +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 x7R42QEH000533; Tue, 27 Aug 2019 04:02:26 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7R42Pw1000532; Tue, 27 Aug 2019 04:02:25 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201908270402.x7R42Pw1000532@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Tue, 27 Aug 2019 04:02:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r351533 - stable/12/sbin/nvmecontrol X-SVN-Group: stable-12 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/12/sbin/nvmecontrol X-SVN-Commit-Revision: 351533 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-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Aug 2019 04:02:26 -0000 Author: mav Date: Tue Aug 27 04:02:25 2019 New Revision: 351533 URL: https://svnweb.freebsd.org/changeset/base/351533 Log: MFC r351038: Print few more useful identify fields. Modified: stable/12/sbin/nvmecontrol/identify.c stable/12/sbin/nvmecontrol/identify_ext.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sbin/nvmecontrol/identify.c ============================================================================== --- stable/12/sbin/nvmecontrol/identify.c Tue Aug 27 04:01:56 2019 (r351532) +++ stable/12/sbin/nvmecontrol/identify.c Tue Aug 27 04:02:25 2019 (r351533) @@ -62,6 +62,7 @@ static struct options { void print_namespace(struct nvme_namespace_data *nsdata) { + char cbuf[UINT128_DIG + 1]; uint32_t i; uint32_t lbaf, lbads, ms, rp; uint8_t thin_prov, ptype; @@ -73,15 +74,12 @@ print_namespace(struct nvme_namespace_data *nsdata) flbas_fmt = (nsdata->flbas >> NVME_NS_DATA_FLBAS_FORMAT_SHIFT) & NVME_NS_DATA_FLBAS_FORMAT_MASK; - printf("Size (in LBAs): %lld (%lldM)\n", - (long long)nsdata->nsze, - (long long)nsdata->nsze / 1024 / 1024); - printf("Capacity (in LBAs): %lld (%lldM)\n", - (long long)nsdata->ncap, - (long long)nsdata->ncap / 1024 / 1024); - printf("Utilization (in LBAs): %lld (%lldM)\n", - (long long)nsdata->nuse, - (long long)nsdata->nuse / 1024 / 1024); + printf("Size: %lld blocks\n", + (long long)nsdata->nsze); + printf("Capacity: %lld blocks\n", + (long long)nsdata->ncap); + printf("Utilization: %lld blocks\n", + (long long)nsdata->nuse); printf("Thin Provisioning: %s\n", thin_prov ? "Supported" : "Not Supported"); printf("Number of LBA Formats: %d\n", nsdata->nlbaf+1); @@ -148,7 +146,22 @@ print_namespace(struct nvme_namespace_data *nsdata) NVME_NS_DATA_DLFEAT_DWZ_MASK ? ", Write Zero" : "", (nsdata->dlfeat >> NVME_NS_DATA_DLFEAT_GCRC_SHIFT) & NVME_NS_DATA_DLFEAT_GCRC_MASK ? ", Guard CRC" : ""); - printf("Optimal I/O Boundary (LBAs): %u\n", nsdata->noiob); + printf("Optimal I/O Boundary: %u blocks\n", nsdata->noiob); + printf("NVM Capacity: %s bytes\n", + uint128_to_str(to128(nsdata->nvmcap), cbuf, sizeof(cbuf))); + if ((nsdata->nsfeat >> NVME_NS_DATA_NSFEAT_NPVALID_SHIFT) & + NVME_NS_DATA_NSFEAT_NPVALID_MASK) { + printf("Preferred Write Granularity: %u blocks", + nsdata->npwg + 1); + printf("Preferred Write Alignment: %u blocks", + nsdata->npwa + 1); + printf("Preferred Deallocate Granul: %u blocks", + nsdata->npdg + 1); + printf("Preferred Deallocate Align: %u blocks", + nsdata->npda + 1); + printf("Optimal Write Size: %u blocks", + nsdata->nows + 1); + } printf("Globally Unique Identifier: "); for (i = 0; i < sizeof(nsdata->nguid); i++) printf("%02x", nsdata->nguid[i]); Modified: stable/12/sbin/nvmecontrol/identify_ext.c ============================================================================== --- stable/12/sbin/nvmecontrol/identify_ext.c Tue Aug 27 04:01:56 2019 (r351532) +++ stable/12/sbin/nvmecontrol/identify_ext.c Tue Aug 27 04:02:25 2019 (r351533) @@ -121,7 +121,7 @@ nvme_print_controller(struct nvme_controller_data *cda if (cdata->mdts == 0) printf("Unlimited\n"); else - printf("%ld\n", PAGE_SIZE * (1L << cdata->mdts)); + printf("%ld bytes\n", PAGE_SIZE * (1L << cdata->mdts)); printf("Controller ID: 0x%04x\n", cdata->ctrlr_id); printf("Version: %d.%d.%d\n", (cdata->ver >> 16) & 0xffff, (cdata->ver >> 8) & 0xff, @@ -184,6 +184,14 @@ nvme_print_controller(struct nvme_controller_data *cda ns_smart ? "Yes" : "No"); printf("Error Log Page Entries: %d\n", cdata->elpe+1); printf("Number of Power States: %d\n", cdata->npss+1); + if (cdata->ver >= 0x010200) { + printf("Total NVM Capacity: %s bytes\n", + uint128_to_str(to128(cdata->untncap.tnvmcap), + cbuf, sizeof(cbuf))); + printf("Unallocated NVM Capacity: %s bytes\n", + uint128_to_str(to128(cdata->untncap.unvmcap), + cbuf, sizeof(cbuf))); + } printf("\n"); printf("NVM Command Set Attributes\n"); @@ -235,13 +243,6 @@ nvme_print_controller(struct nvme_controller_data *cda (t == NVME_CTRLR_DATA_VWC_ALL_NO) ? ", no flush all" : (t == NVME_CTRLR_DATA_VWC_ALL_YES) ? ", flush all" : ""); - if (nsmgmt) { - printf("\n"); - printf("Namespace Drive Attributes\n"); - printf("==========================\n"); - printf("NVM total cap: %s\n", - uint128_to_str(to128(cdata->untncap.tnvmcap), cbuf, sizeof(cbuf))); - printf("NVM unallocated cap: %s\n", - uint128_to_str(to128(cdata->untncap.unvmcap), cbuf, sizeof(cbuf))); - } + if (cdata->ver >= 0x010201) + printf("\nNVM Subsystem Name: %.256s\n", cdata->subnqn); } From owner-svn-src-stable-12@freebsd.org Tue Aug 27 04:03:42 2019 Return-Path: Delivered-To: svn-src-stable-12@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 E146DC86F8; Tue, 27 Aug 2019 04:03: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 46HZxB5VWCz4KZq; Tue, 27 Aug 2019 04:03:42 +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 9E52719027; Tue, 27 Aug 2019 04:03:42 +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 x7R43gik000658; Tue, 27 Aug 2019 04:03:42 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7R43ggl000657; Tue, 27 Aug 2019 04:03:42 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201908270403.x7R43ggl000657@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Tue, 27 Aug 2019 04:03:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r351534 - stable/12/sys/dev/nvme X-SVN-Group: stable-12 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/12/sys/dev/nvme X-SVN-Commit-Revision: 351534 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-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Aug 2019 04:03:43 -0000 Author: mav Date: Tue Aug 27 04:03:42 2019 New Revision: 351534 URL: https://svnweb.freebsd.org/changeset/base/351534 Log: MFC r351320: Formalize NVMe controller consumer life cycle. This fixes possible double call of fail_fn, for example on hot removal. It also allows ctrlr_fn to safely return NULL cookie in case of failure and not get useless ns_fn or fail_fn call with NULL cookie later. Modified: stable/12/sys/dev/nvme/nvme.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/nvme/nvme.c ============================================================================== --- stable/12/sys/dev/nvme/nvme.c Tue Aug 27 04:02:25 2019 (r351533) +++ stable/12/sys/dev/nvme/nvme.c Tue Aug 27 04:03:42 2019 (r351534) @@ -330,16 +330,21 @@ nvme_notify(struct nvme_consumer *cons, return; cmpset = atomic_cmpset_32(&ctrlr->notification_sent, 0, 1); - if (cmpset == 0) return; if (cons->ctrlr_fn != NULL) ctrlr_cookie = (*cons->ctrlr_fn)(ctrlr); else - ctrlr_cookie = NULL; + ctrlr_cookie = (void *)(uintptr_t)0xdeadc0dedeadc0de; ctrlr->cons_cookie[cons->id] = ctrlr_cookie; + + /* ctrlr_fn has failed. Nothing to notify here any more. */ + if (ctrlr_cookie == NULL) + return; + if (ctrlr->is_failed) { + ctrlr->cons_cookie[cons->id] = NULL; if (cons->fail_fn != NULL) (*cons->fail_fn)(ctrlr_cookie); /* @@ -395,13 +400,16 @@ nvme_notify_async_consumers(struct nvme_controller *ct uint32_t log_page_size) { struct nvme_consumer *cons; + void *ctrlr_cookie; uint32_t i; for (i = 0; i < NVME_MAX_CONSUMERS; i++) { cons = &nvme_consumer[i]; - if (cons->id != INVALID_CONSUMER_ID && cons->async_fn != NULL) - (*cons->async_fn)(ctrlr->cons_cookie[i], async_cpl, + if (cons->id != INVALID_CONSUMER_ID && cons->async_fn != NULL && + (ctrlr_cookie = ctrlr->cons_cookie[i]) != NULL) { + (*cons->async_fn)(ctrlr_cookie, async_cpl, log_page_id, log_page_buffer, log_page_size); + } } } @@ -409,6 +417,7 @@ void nvme_notify_fail_consumers(struct nvme_controller *ctrlr) { struct nvme_consumer *cons; + void *ctrlr_cookie; uint32_t i; /* @@ -422,8 +431,12 @@ nvme_notify_fail_consumers(struct nvme_controller *ctr for (i = 0; i < NVME_MAX_CONSUMERS; i++) { cons = &nvme_consumer[i]; - if (cons->id != INVALID_CONSUMER_ID && cons->fail_fn != NULL) - cons->fail_fn(ctrlr->cons_cookie[i]); + if (cons->id != INVALID_CONSUMER_ID && + (ctrlr_cookie = ctrlr->cons_cookie[i]) != NULL) { + ctrlr->cons_cookie[i] = NULL; + if (cons->fail_fn != NULL) + cons->fail_fn(ctrlr_cookie); + } } } @@ -432,6 +445,7 @@ nvme_notify_ns(struct nvme_controller *ctrlr, int nsid { struct nvme_consumer *cons; struct nvme_namespace *ns = &ctrlr->ns[nsid - 1]; + void *ctrlr_cookie; uint32_t i; if (!ctrlr->is_initialized) @@ -439,9 +453,9 @@ nvme_notify_ns(struct nvme_controller *ctrlr, int nsid for (i = 0; i < NVME_MAX_CONSUMERS; i++) { cons = &nvme_consumer[i]; - if (cons->id != INVALID_CONSUMER_ID && cons->ns_fn != NULL) - ns->cons_cookie[cons->id] = - (*cons->ns_fn)(ns, ctrlr->cons_cookie[cons->id]); + if (cons->id != INVALID_CONSUMER_ID && cons->ns_fn != NULL && + (ctrlr_cookie = ctrlr->cons_cookie[i]) != NULL) + ns->cons_cookie[i] = (*cons->ns_fn)(ns, ctrlr_cookie); } } From owner-svn-src-stable-12@freebsd.org Tue Aug 27 04:04:20 2019 Return-Path: Delivered-To: svn-src-stable-12@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 099D1C8791; Tue, 27 Aug 2019 04:04:20 +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 46HZxv6XGwz4KjB; Tue, 27 Aug 2019 04:04:19 +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 C204C19028; Tue, 27 Aug 2019 04:04:19 +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 x7R44Jtt000743; Tue, 27 Aug 2019 04:04:19 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7R44JBt000742; Tue, 27 Aug 2019 04:04:19 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201908270404.x7R44JBt000742@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Tue, 27 Aug 2019 04:04:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r351535 - stable/12/sys/dev/nvme X-SVN-Group: stable-12 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/12/sys/dev/nvme X-SVN-Commit-Revision: 351535 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-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Aug 2019 04:04:20 -0000 Author: mav Date: Tue Aug 27 04:04:19 2019 New Revision: 351535 URL: https://svnweb.freebsd.org/changeset/base/351535 Log: MFC r351352: Improve NVMe hot unplug handling. If device is unplugged from the system (CSTS register reads return 0xffffffff), it makes no sense to send any more recovery requests or expect any responses back. If there is a detach call in such state, just stop all activity and free resources. If there is no detach call (hot-plug is not supported), rely on normal timeout handling, but when it trigger controller reset, do not wait for impossible and quickly report failure. Sponsored by: iXsystems, Inc. Modified: stable/12/sys/dev/nvme/nvme_ctrlr.c stable/12/sys/dev/nvme/nvme_qpair.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/nvme/nvme_ctrlr.c ============================================================================== --- stable/12/sys/dev/nvme/nvme_ctrlr.c Tue Aug 27 04:03:42 2019 (r351534) +++ stable/12/sys/dev/nvme/nvme_ctrlr.c Tue Aug 27 04:04:19 2019 (r351535) @@ -207,10 +207,13 @@ nvme_ctrlr_fail(struct nvme_controller *ctrlr) int i; ctrlr->is_failed = TRUE; + nvme_admin_qpair_disable(&ctrlr->adminq); nvme_qpair_fail(&ctrlr->adminq); if (ctrlr->ioq != NULL) { - for (i = 0; i < ctrlr->num_io_queues; i++) + for (i = 0; i < ctrlr->num_io_queues; i++) { + nvme_io_qpair_disable(&ctrlr->ioq[i]); nvme_qpair_fail(&ctrlr->ioq[i]); + } } nvme_notify_fail_consumers(ctrlr); } @@ -249,17 +252,20 @@ nvme_ctrlr_wait_for_ready(struct nvme_controller *ctrl int ms_waited; uint32_t csts; - csts = nvme_mmio_read_4(ctrlr, csts); - ms_waited = 0; - while (((csts >> NVME_CSTS_REG_RDY_SHIFT) & NVME_CSTS_REG_RDY_MASK) != desired_val) { + while (1) { + csts = nvme_mmio_read_4(ctrlr, csts); + if (csts == 0xffffffff) /* Hot unplug. */ + return (ENXIO); + if (((csts >> NVME_CSTS_REG_RDY_SHIFT) & NVME_CSTS_REG_RDY_MASK) + == desired_val) + break; if (ms_waited++ > ctrlr->ready_timeout_in_ms) { nvme_printf(ctrlr, "controller ready did not become %d " "within %d ms\n", desired_val, ctrlr->ready_timeout_in_ms); return (ENXIO); } DELAY(1000); - csts = nvme_mmio_read_4(ctrlr, csts); } return (0); @@ -1338,12 +1344,20 @@ nvme_ctrlr_construct(struct nvme_controller *ctrlr, de void nvme_ctrlr_destruct(struct nvme_controller *ctrlr, device_t dev) { - int i; + int gone, i; if (ctrlr->resource == NULL) goto nores; - nvme_notify_fail_consumers(ctrlr); + /* + * Check whether it is a hot unplug or a clean driver detach. + * If device is not there any more, skip any shutdown commands. + */ + gone = (nvme_mmio_read_4(ctrlr, csts) == 0xffffffff); + if (gone) + nvme_ctrlr_fail(ctrlr); + else + nvme_notify_fail_consumers(ctrlr); for (i = 0; i < NVME_MAX_NAMESPACES; i++) nvme_ns_destruct(&ctrlr->ns[i]); @@ -1351,12 +1365,11 @@ nvme_ctrlr_destruct(struct nvme_controller *ctrlr, dev if (ctrlr->cdev) destroy_dev(ctrlr->cdev); - nvme_ctrlr_destroy_qpairs(ctrlr); - for (i = 0; i < ctrlr->num_io_queues; i++) { + if (!gone) + nvme_ctrlr_destroy_qpairs(ctrlr); + for (i = 0; i < ctrlr->num_io_queues; i++) nvme_io_qpair_destroy(&ctrlr->ioq[i]); - } free(ctrlr->ioq, M_NVME); - nvme_admin_qpair_destroy(&ctrlr->adminq); /* @@ -1366,9 +1379,11 @@ nvme_ctrlr_destruct(struct nvme_controller *ctrlr, dev * shutdown notification in case the system is shutdown before * reloading the driver. */ - nvme_ctrlr_shutdown(ctrlr); + if (!gone) + nvme_ctrlr_shutdown(ctrlr); - nvme_ctrlr_disable(ctrlr); + if (!gone) + nvme_ctrlr_disable(ctrlr); if (ctrlr->taskqueue) taskqueue_free(ctrlr->taskqueue); @@ -1407,14 +1422,19 @@ nvme_ctrlr_shutdown(struct nvme_controller *ctrlr) cc |= NVME_SHN_NORMAL << NVME_CC_REG_SHN_SHIFT; nvme_mmio_write_4(ctrlr, cc, cc); - csts = nvme_mmio_read_4(ctrlr, csts); - while ((NVME_CSTS_GET_SHST(csts) != NVME_SHST_COMPLETE) && (ticks++ < 5*hz)) { - pause("nvme shn", 1); + while (1) { csts = nvme_mmio_read_4(ctrlr, csts); + if (csts == 0xffffffff) /* Hot unplug. */ + break; + if (NVME_CSTS_GET_SHST(csts) == NVME_SHST_COMPLETE) + break; + if (ticks++ > 5*hz) { + nvme_printf(ctrlr, "did not complete shutdown within" + " 5 seconds of notification\n"); + break; + } + pause("nvme shn", 1); } - if (NVME_CSTS_GET_SHST(csts) != NVME_SHST_COMPLETE) - nvme_printf(ctrlr, "did not complete shutdown within 5 seconds " - "of notification\n"); } void Modified: stable/12/sys/dev/nvme/nvme_qpair.c ============================================================================== --- stable/12/sys/dev/nvme/nvme_qpair.c Tue Aug 27 04:03:42 2019 (r351534) +++ stable/12/sys/dev/nvme/nvme_qpair.c Tue Aug 27 04:04:19 2019 (r351535) @@ -911,7 +911,8 @@ nvme_timeout(void *arg) nvme_abort_complete, tr); } else { nvme_printf(ctrlr, "Resetting controller due to a timeout%s.\n", - cfs ? " and fatal error status" : ""); + (csts == 0xffffffff) ? " and possible hot unplug" : + (cfs ? " and fatal error status" : "")); nvme_ctrlr_reset(ctrlr); } } From owner-svn-src-stable-12@freebsd.org Tue Aug 27 04:13:25 2019 Return-Path: Delivered-To: svn-src-stable-12@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 42B56C8B93; Tue, 27 Aug 2019 04:13:25 +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 46Hb8P1f7qz4LCf; Tue, 27 Aug 2019 04:13:25 +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 00B82191EC; Tue, 27 Aug 2019 04:13:25 +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 x7R4DOsN006897; Tue, 27 Aug 2019 04:13:24 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7R4DMwX006886; Tue, 27 Aug 2019 04:13:22 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201908270413.x7R4DMwX006886@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Tue, 27 Aug 2019 04:13:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r351536 - in stable/12/sys: amd64/conf conf dev/ntb dev/ntb/ntb_hw i386/conf modules/ntb modules/ntb/ntb_hw_amd X-SVN-Group: stable-12 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: in stable/12/sys: amd64/conf conf dev/ntb dev/ntb/ntb_hw i386/conf modules/ntb modules/ntb/ntb_hw_amd X-SVN-Commit-Revision: 351536 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-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Aug 2019 04:13:25 -0000 Author: mav Date: Tue Aug 27 04:13:22 2019 New Revision: 351536 URL: https://svnweb.freebsd.org/changeset/base/351536 Log: MFC r349594, r349595, r349601: Add driver for NTB in AMD SoC. This patch is the driver for NTB hardware in AMD SoCs (ported from Linux) and enables the NTB infrastructure like Doorbells, Scratchpads and Memory window in AMD SoC. This driver has been validated using ntb_transport and if_ntb driver already available in FreeBSD. Submitted by: Rajesh Kumar Relnotes: yes Added: stable/12/sys/dev/ntb/ntb_hw/ntb_hw_amd.c - copied, changed from r349594, head/sys/dev/ntb/ntb_hw/ntb_hw_amd.c stable/12/sys/dev/ntb/ntb_hw/ntb_hw_amd.h - copied unchanged from r349594, head/sys/dev/ntb/ntb_hw/ntb_hw_amd.h stable/12/sys/modules/ntb/ntb_hw_amd/ - copied from r349594, head/sys/modules/ntb/ntb_hw_amd/ Modified: stable/12/sys/amd64/conf/NOTES stable/12/sys/conf/files.amd64 stable/12/sys/conf/files.i386 stable/12/sys/dev/ntb/ntb.c stable/12/sys/dev/ntb/ntb.h stable/12/sys/dev/ntb/ntb_if.m stable/12/sys/dev/ntb/ntb_transport.c stable/12/sys/i386/conf/NOTES stable/12/sys/modules/ntb/Makefile Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/amd64/conf/NOTES ============================================================================== --- stable/12/sys/amd64/conf/NOTES Tue Aug 27 04:04:19 2019 (r351535) +++ stable/12/sys/amd64/conf/NOTES Tue Aug 27 04:13:22 2019 (r351536) @@ -398,6 +398,7 @@ device wpifw device if_ntb # Virtual NTB network interface device ntb_transport # NTB packet transport driver device ntb # NTB hardware interface +device ntb_hw_amd # AMD NTB hardware driver device ntb_hw_intel # Intel NTB hardware driver device ntb_hw_plx # PLX NTB hardware driver Modified: stable/12/sys/conf/files.amd64 ============================================================================== --- stable/12/sys/conf/files.amd64 Tue Aug 27 04:04:19 2019 (r351535) +++ stable/12/sys/conf/files.amd64 Tue Aug 27 04:13:22 2019 (r351536) @@ -346,8 +346,9 @@ dev/nctgpio/nctgpio.c optional nctgpio dev/nfe/if_nfe.c optional nfe pci dev/ntb/if_ntb/if_ntb.c optional if_ntb dev/ntb/ntb_transport.c optional ntb_transport | if_ntb -dev/ntb/ntb.c optional ntb | ntb_transport | if_ntb | ntb_hw_intel | ntb_hw_plx | ntb_hw -dev/ntb/ntb_if.m optional ntb | ntb_transport | if_ntb | ntb_hw_intel | ntb_hw_plx | ntb_hw +dev/ntb/ntb.c optional ntb | ntb_transport | if_ntb | ntb_hw_amd | ntb_hw_intel | ntb_hw_plx | ntb_hw +dev/ntb/ntb_if.m optional ntb | ntb_transport | if_ntb | ntb_hw_amd | ntb_hw_intel | ntb_hw_plx | ntb_hw +dev/ntb/ntb_hw/ntb_hw_amd.c optional ntb_hw_amd | ntb_hw dev/ntb/ntb_hw/ntb_hw_intel.c optional ntb_hw_intel | ntb_hw dev/ntb/ntb_hw/ntb_hw_plx.c optional ntb_hw_plx | ntb_hw dev/nvd/nvd.c optional nvd nvme Modified: stable/12/sys/conf/files.i386 ============================================================================== --- stable/12/sys/conf/files.i386 Tue Aug 27 04:04:19 2019 (r351535) +++ stable/12/sys/conf/files.i386 Tue Aug 27 04:13:22 2019 (r351536) @@ -284,8 +284,9 @@ dev/nctgpio/nctgpio.c optional nctgpio dev/nfe/if_nfe.c optional nfe pci dev/ntb/if_ntb/if_ntb.c optional if_ntb dev/ntb/ntb_transport.c optional ntb_transport | if_ntb -dev/ntb/ntb.c optional ntb | ntb_transport | if_ntb | ntb_hw_intel | ntb_hw_plx | ntb_hw -dev/ntb/ntb_if.m optional ntb | ntb_transport | if_ntb | ntb_hw_intel | ntb_hw_plx | ntb_hw +dev/ntb/ntb.c optional ntb | ntb_transport | if_ntb | ntb_hw_amd | ntb_hw_intel | ntb_hw_plx | ntb_hw +dev/ntb/ntb_if.m optional ntb | ntb_transport | if_ntb | ntb_hw_amd | ntb_hw_intel | ntb_hw_plx | ntb_hw +dev/ntb/ntb_hw/ntb_hw_amd.c optional ntb_hw_amd | ntb_hw dev/ntb/ntb_hw/ntb_hw_intel.c optional ntb_hw_intel | ntb_hw dev/ntb/ntb_hw/ntb_hw_plx.c optional ntb_hw_plx | ntb_hw dev/nvd/nvd.c optional nvd nvme Modified: stable/12/sys/dev/ntb/ntb.c ============================================================================== --- stable/12/sys/dev/ntb/ntb.c Tue Aug 27 04:04:19 2019 (r351535) +++ stable/12/sys/dev/ntb/ntb.c Tue Aug 27 04:13:22 2019 (r351536) @@ -243,6 +243,30 @@ ntb_db_event(device_t dev, uint32_t vec) } } +int +ntb_port_number(device_t ntb) +{ + return (NTB_PORT_NUMBER(device_get_parent(ntb))); +} + +int +ntb_peer_port_count(device_t ntb) +{ + return (NTB_PEER_PORT_COUNT(device_get_parent(ntb))); +} + +int +ntb_peer_port_number(device_t ntb, int pidx) +{ + return (NTB_PEER_PORT_NUMBER(device_get_parent(ntb), pidx)); +} + +int +ntb_peer_port_idx(device_t ntb, int port) +{ + return (NTB_PEER_PORT_IDX(device_get_parent(ntb), port)); +} + bool ntb_link_is_up(device_t ntb, enum ntb_speed *speed, enum ntb_width *width) { Modified: stable/12/sys/dev/ntb/ntb.h ============================================================================== --- stable/12/sys/dev/ntb/ntb.h Tue Aug 27 04:04:19 2019 (r351535) +++ stable/12/sys/dev/ntb/ntb.h Tue Aug 27 04:13:22 2019 (r351536) @@ -64,6 +64,51 @@ void ntb_link_event(device_t ntb); */ void ntb_db_event(device_t ntb, uint32_t vec); +/** + * ntb_port_number() - get the local port number + * @ntb: NTB device context. + * + * Hardware driver returns local port number in compliance with topology. + * + * Return: the local port number + */ +int ntb_port_number(device_t ntb); + +/** + * ntb_port_count() - get the number of peer device ports + * @ntb: NTB device context. + * + * By default hardware driver supports just one peer device. + * + * Return: the number of peer ports + */ +int ntb_peer_port_count(device_t ntb); + +/** + * ntb_peer_port_number() - get the peer port by given index + * @ntb: NTB device context. + * @idx: Peer port index (should be zero for now). + * + * By default hardware driver supports just one peer device, so this method + * shall return the corresponding value. + * + * Return: the peer device port or an error number + */ +int ntb_peer_port_number(device_t ntb, int pidx); + +/* + * ntb_peer_port_idx() - get the peer device port index by given port + * number + * @ntb: NTB device context. + * @port: Peer port number + * + * By default hardware driver supports just one peer device, so given a + * valid peer port number, the return value shall be zero. + * + * Return: the peer port index or an error number + */ +int ntb_peer_port_idx(device_t ntb, int port); + /* * ntb_link_is_up() - get the current ntb link state * @ntb: NTB device context Copied and modified: stable/12/sys/dev/ntb/ntb_hw/ntb_hw_amd.c (from r349594, head/sys/dev/ntb/ntb_hw/ntb_hw_amd.c) ============================================================================== --- head/sys/dev/ntb/ntb_hw/ntb_hw_amd.c Tue Jul 2 05:25:18 2019 (r349594, copy source) +++ stable/12/sys/dev/ntb/ntb_hw/ntb_hw_amd.c Tue Aug 27 04:13:22 2019 (r351536) @@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -93,6 +94,26 @@ SYSCTL_UINT(_hw_ntb, OID_AUTO, debug_level, CTLFLAG_RW device_printf(ntb->device, __VA_ARGS__); \ } while (0) +#ifdef __i386__ +static __inline uint64_t +bus_space_read_8(bus_space_tag_t tag, bus_space_handle_t handle, + bus_size_t offset) +{ + + return (bus_space_read_4(tag, handle, offset) | + ((uint64_t)bus_space_read_4(tag, handle, offset + 4)) << 32); +} + +static __inline void +bus_space_write_8(bus_space_tag_t tag, bus_space_handle_t handle, + bus_size_t offset, uint64_t val) +{ + + bus_space_write_4(tag, handle, offset, val); + bus_space_write_4(tag, handle, offset + 4, val >> 32); +} +#endif + /* * AMD NTB INTERFACE ROUTINES */ @@ -316,11 +337,6 @@ amd_ntb_mw_get_range(device_t dev, unsigned mw_idx, vm *plimit = BUS_SPACE_MAXADDR_32BIT; } - amd_ntb_printf(1, "%s: mw %d padd %p vadd %p psize 0x%lx " - "align 0x%lx asize 0x%lx alimit %p\n", __func__, mw_idx, - (void *)*base, (void *)*vbase, (uint64_t)*size, (uint64_t)*align, - (uint64_t)*align_size, (void *)*plimit); - return (0); } @@ -353,14 +369,14 @@ amd_ntb_mw_set_trans(device_t dev, unsigned mw_idx, bu * set and verify setting the translation address */ amd_ntb_peer_reg_write(8, bar_info->xlat_off, (uint64_t)addr); - amd_ntb_printf(0, "%s: mw %d xlat_off 0x%x cur_val 0x%lx addr %p\n", + amd_ntb_printf(0, "%s: mw %d xlat_off 0x%x cur_val 0x%jx addr %p\n", __func__, mw_idx, bar_info->xlat_off, amd_ntb_peer_reg_read(8, bar_info->xlat_off), (void *)addr); /* set and verify setting the limit */ if (mw_idx != 0) { amd_ntb_reg_write(8, bar_info->limit_off, (uint64_t)size); - amd_ntb_printf(1, "%s: limit_off 0x%x cur_val 0x%lx limit 0x%x\n", + amd_ntb_printf(1, "%s: limit_off 0x%x cur_val 0x%jx limit 0x%x\n", __func__, bar_info->limit_off, amd_ntb_peer_reg_read(8, bar_info->limit_off), (uint32_t)size); } else { @@ -470,7 +486,7 @@ amd_ntb_db_read(device_t dev) dbstat_off = (uint64_t)amd_ntb_reg_read(2, AMD_DBSTAT_OFFSET); - amd_ntb_printf(1, "%s: dbstat_off 0x%lx\n", __func__, dbstat_off); + amd_ntb_printf(1, "%s: dbstat_off 0x%jx\n", __func__, dbstat_off); return (dbstat_off); } @@ -480,7 +496,7 @@ amd_ntb_db_clear(device_t dev, uint64_t db_bits) { struct amd_ntb_softc *ntb = device_get_softc(dev); - amd_ntb_printf(1, "%s: db_bits 0x%lx\n", __func__, db_bits); + amd_ntb_printf(1, "%s: db_bits 0x%jx\n", __func__, db_bits); amd_ntb_reg_write(2, AMD_DBSTAT_OFFSET, (uint16_t)db_bits); } @@ -490,7 +506,7 @@ amd_ntb_db_set_mask(device_t dev, uint64_t db_bits) struct amd_ntb_softc *ntb = device_get_softc(dev); DB_MASK_LOCK(ntb); - amd_ntb_printf(1, "%s: db_mask 0x%x db_bits 0x%lx\n", + amd_ntb_printf(1, "%s: db_mask 0x%x db_bits 0x%jx\n", __func__, ntb->db_mask, db_bits); ntb->db_mask |= db_bits; @@ -504,7 +520,7 @@ amd_ntb_db_clear_mask(device_t dev, uint64_t db_bits) struct amd_ntb_softc *ntb = device_get_softc(dev); DB_MASK_LOCK(ntb); - amd_ntb_printf(1, "%s: db_mask 0x%x db_bits 0x%lx\n", + amd_ntb_printf(1, "%s: db_mask 0x%x db_bits 0x%jx\n", __func__, ntb->db_mask, db_bits); ntb->db_mask &= ~db_bits; @@ -517,7 +533,7 @@ amd_ntb_peer_db_set(device_t dev, uint64_t db_bits) { struct amd_ntb_softc *ntb = device_get_softc(dev); - amd_ntb_printf(1, "%s: db_bits 0x%lx\n", __func__, db_bits); + amd_ntb_printf(1, "%s: db_bits 0x%jx\n", __func__, db_bits); amd_ntb_reg_write(2, AMD_DBREQ_OFFSET, (uint16_t)db_bits); } @@ -660,17 +676,17 @@ amd_ntb_hw_info_handler(SYSCTL_HANDLER_ARGS) sbuf_printf(sb, "AMD Doorbell: 0x%x\n", amd_ntb_reg_read(4, AMD_DBSTAT_OFFSET)); sbuf_printf(sb, "AMD NTB Incoming XLAT: \n"); - sbuf_printf(sb, "AMD XLAT1: 0x%lx\n", + sbuf_printf(sb, "AMD XLAT1: 0x%jx\n", amd_ntb_peer_reg_read(8, AMD_BAR1XLAT_OFFSET)); - sbuf_printf(sb, "AMD XLAT23: 0x%lx\n", + sbuf_printf(sb, "AMD XLAT23: 0x%jx\n", amd_ntb_peer_reg_read(8, AMD_BAR23XLAT_OFFSET)); - sbuf_printf(sb, "AMD XLAT45: 0x%lx\n", + sbuf_printf(sb, "AMD XLAT45: 0x%jx\n", amd_ntb_peer_reg_read(8, AMD_BAR45XLAT_OFFSET)); sbuf_printf(sb, "AMD LMT1: 0x%x\n", amd_ntb_reg_read(4, AMD_BAR1LMT_OFFSET)); - sbuf_printf(sb, "AMD LMT23: 0x%lx\n", + sbuf_printf(sb, "AMD LMT23: 0x%jx\n", amd_ntb_reg_read(8, AMD_BAR23LMT_OFFSET)); - sbuf_printf(sb, "AMD LMT45: 0x%lx\n", + sbuf_printf(sb, "AMD LMT45: 0x%jx\n", amd_ntb_reg_read(8, AMD_BAR45LMT_OFFSET)); rc = sbuf_finish(sb); Copied: stable/12/sys/dev/ntb/ntb_hw/ntb_hw_amd.h (from r349594, head/sys/dev/ntb/ntb_hw/ntb_hw_amd.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/sys/dev/ntb/ntb_hw/ntb_hw_amd.h Tue Aug 27 04:13:22 2019 (r351536, copy of r349594, head/sys/dev/ntb/ntb_hw/ntb_hw_amd.h) @@ -0,0 +1,259 @@ +/*- + * This file is provided under a dual BSD/GPLv2 license. When using or + * redistributing this file, you may do so under either license. + * + * GPL LICENSE SUMMARY + * + * Copyright (C) 2019 Advanced Micro Devices, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * BSD LICENSE + * + * Copyright (C) 2019 Advanced Micro Devices, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copy + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the distribution. + * 3. Neither the name of AMD corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Contact Information : + * Rajesh Kumar + * + * $FreeBSD$ + */ + +#ifndef NTB_HW_AMD_H +#define NTB_HW_AMD_H + +#define NTB_HW_AMD_VENDOR_ID 0x1022 +#define NTB_HW_AMD_DEVICE_ID 0x145B + +#define NTB_DEF_PEER_CNT 1 +#define NTB_DEF_PEER_IDX 0 + +#define BIT(n) (1 << n) +#define AMD_LINK_HB_TIMEOUT (1 * hz) + +#define NTB_LIN_STA_ACTIVE_BIT 0x00000002 +#define NTB_LNK_STA_SPEED_MASK 0x000F0000 +#define NTB_LNK_STA_WIDTH_MASK 0x03F00000 +#define NTB_LNK_STA_ACTIVE(x) (!!((x) & NTB_LIN_STA_ACTIVE_BIT)) +#define NTB_LNK_STA_SPEED(x) (((x) & NTB_LNK_STA_SPEED_MASK) >> 16) +#define NTB_LNK_STA_WIDTH(x) (((x) & NTB_LNK_STA_WIDTH_MASK) >> 20) + +#define amd_ntb_bar_read(SIZE, bar, offset) \ + bus_space_read_ ## SIZE (ntb->bar_info[(bar)].pci_bus_tag, \ + ntb->bar_info[(bar)].pci_bus_handle, (offset)) +#define amd_ntb_bar_write(SIZE, bar, offset, val) \ + bus_space_write_ ## SIZE (ntb->bar_info[(bar)].pci_bus_tag, \ + ntb->bar_info[(bar)].pci_bus_handle, (offset), (val)) +#define amd_ntb_reg_read(SIZE, offset) \ + amd_ntb_bar_read(SIZE, NTB_CONFIG_BAR, offset) +#define amd_ntb_reg_write(SIZE, offset, val) \ + amd_ntb_bar_write(SIZE, NTB_CONFIG_BAR, offset, val) +#define amd_ntb_peer_reg_read(SIZE, offset) \ + amd_ntb_bar_read(SIZE, NTB_CONFIG_BAR, offset + AMD_PEER_OFFSET) +#define amd_ntb_peer_reg_write(SIZE, offset, val) \ + amd_ntb_bar_write(SIZE, NTB_CONFIG_BAR, offset + AMD_PEER_OFFSET, val) + +#define DB_MASK_LOCK(sc) mtx_lock_spin(&(sc)->db_mask_lock) +#define DB_MASK_UNLOCK(sc) mtx_unlock_spin(&(sc)->db_mask_lock) +#define DB_MASK_ASSERT(sc, f) mtx_assert(&(sc)->db_mask_lock, (f)) + +/* amd_ntb_conn_type are hardware numbers, cannot change. */ +enum amd_ntb_conn_type { + NTB_CONN_NONE = -1, + NTB_CONN_PRI, + NTB_CONN_SEC, +}; + +enum ntb_default_port { + NTB_PORT_PRI_USD, + NTB_PORT_SEC_DSD +}; + +enum amd_ntb_bar { + NTB_CONFIG_BAR = 0, + NTB_BAR_1, + NTB_BAR_2, + NTB_BAR_3, + NTB_MAX_BARS +}; + +struct amd_ntb_hw_info { + uint32_t device_id; + const char *desc; +}; + +struct amd_ntb_pci_bar_info { + bus_space_tag_t pci_bus_tag; + bus_space_handle_t pci_bus_handle; + struct resource *pci_resource; + vm_paddr_t pbase; + caddr_t vbase; + vm_size_t size; + vm_memattr_t map_mode; + int pci_resource_id; + + /* Configuration register offsets */ + uint32_t xlat_off; + uint32_t limit_off; +}; + +struct amd_ntb_int_info { + struct resource *res; + void *tag; + int rid; +}; + +struct amd_ntb_vec { + struct amd_ntb_softc *ntb; + uint32_t num; + unsigned masked; +}; + +enum { + /* AMD NTB Capability */ + AMD_MW_CNT = 3, + AMD_DB_CNT = 16, + AMD_MSIX_VECTOR_CNT = 24, + AMD_SPADS_CNT = 16, + + /* AMD NTB Link Status Offset */ + AMD_LINK_STATUS_OFFSET = 0x68, + + /* AMD NTB register offset */ + AMD_CNTL_OFFSET = 0x200, + + /* NTB control register bits */ + PMM_REG_CTL = BIT(21), + SMM_REG_CTL = BIT(20), + SMM_REG_ACC_PATH = BIT(18), + PMM_REG_ACC_PATH = BIT(17), + NTB_CLK_EN = BIT(16), + + AMD_STA_OFFSET = 0x204, + AMD_PGSLV_OFFSET = 0x208, + AMD_SPAD_MUX_OFFSET = 0x20C, + AMD_SPAD_OFFSET = 0x210, + AMD_RSMU_HCID = 0x250, + AMD_RSMU_SIID = 0x254, + AMD_PSION_OFFSET = 0x300, + AMD_SSION_OFFSET = 0x330, + AMD_MMINDEX_OFFSET = 0x400, + AMD_MMDATA_OFFSET = 0x404, + AMD_SIDEINFO_OFFSET = 0x408, + + AMD_SIDE_MASK = BIT(0), + AMD_SIDE_READY = BIT(1), + + /* limit register */ + AMD_ROMBARLMT_OFFSET = 0x410, + AMD_BAR1LMT_OFFSET = 0x414, + AMD_BAR23LMT_OFFSET = 0x418, + AMD_BAR45LMT_OFFSET = 0x420, + + /* xlat address */ + AMD_ROMBARXLAT_OFFSET = 0x428, + AMD_BAR1XLAT_OFFSET = 0x430, + AMD_BAR23XLAT_OFFSET = 0x438, + AMD_BAR45XLAT_OFFSET = 0x440, + + /* doorbell and interrupt */ + AMD_DBFM_OFFSET = 0x450, + AMD_DBREQ_OFFSET = 0x454, + AMD_MIRRDBSTAT_OFFSET = 0x458, + AMD_DBMASK_OFFSET = 0x45C, + AMD_DBSTAT_OFFSET = 0x460, + AMD_INTMASK_OFFSET = 0x470, + AMD_INTSTAT_OFFSET = 0x474, + + /* event type */ + AMD_PEER_FLUSH_EVENT = BIT(0), + AMD_PEER_RESET_EVENT = BIT(1), + AMD_PEER_D3_EVENT = BIT(2), + AMD_PEER_PMETO_EVENT = BIT(3), + AMD_PEER_D0_EVENT = BIT(4), + AMD_LINK_UP_EVENT = BIT(5), + AMD_LINK_DOWN_EVENT = BIT(6), + AMD_EVENT_INTMASK = (AMD_PEER_FLUSH_EVENT | + AMD_PEER_RESET_EVENT | AMD_PEER_D3_EVENT | + AMD_PEER_PMETO_EVENT | AMD_PEER_D0_EVENT | + AMD_LINK_UP_EVENT | AMD_LINK_DOWN_EVENT), + + AMD_PMESTAT_OFFSET = 0x480, + AMD_PMSGTRIG_OFFSET = 0x490, + AMD_LTRLATENCY_OFFSET = 0x494, + AMD_FLUSHTRIG_OFFSET = 0x498, + + /* SMU register*/ + AMD_SMUACK_OFFSET = 0x4A0, + AMD_SINRST_OFFSET = 0x4A4, + AMD_RSPNUM_OFFSET = 0x4A8, + AMD_SMU_SPADMUTEX = 0x4B0, + AMD_SMU_SPADOFFSET = 0x4B4, + + AMD_PEER_OFFSET = 0x400, +}; + +struct amd_ntb_softc { + /* ntb.c context. Do not move! Must go first! */ + void *ntb_store; + + device_t device; + enum amd_ntb_conn_type conn_type; + + struct amd_ntb_pci_bar_info bar_info[NTB_MAX_BARS]; + struct amd_ntb_int_info int_info[AMD_MSIX_VECTOR_CNT]; + struct amd_ntb_vec *msix_vec; + uint16_t allocated_interrupts; + + struct callout hb_timer; + + uint8_t mw_count; + uint8_t spad_count; + uint8_t db_count; + uint8_t msix_vec_count; + + struct mtx db_mask_lock; + + volatile uint32_t ntb_ctl; + volatile uint32_t lnk_sta; + volatile uint32_t peer_sta; + volatile uint32_t cntl_sta; + + uint16_t db_valid_mask; + uint16_t db_mask; + uint32_t int_mask; + + unsigned int self_spad; + unsigned int peer_spad; +}; + +static void amd_init_side_info(struct amd_ntb_softc *ntb); +static void amd_deinit_side_info(struct amd_ntb_softc *ntb); +static int amd_ntb_detach(device_t device); + +#endif Modified: stable/12/sys/dev/ntb/ntb_if.m ============================================================================== --- stable/12/sys/dev/ntb/ntb_if.m Tue Aug 27 04:04:19 2019 (r351535) +++ stable/12/sys/dev/ntb/ntb_if.m Tue Aug 27 04:13:22 2019 (r351536) @@ -61,6 +61,24 @@ HEADER { }; }; +METHOD int port_number { + device_t ntb; +}; + +METHOD int peer_port_count { + device_t ntb; +}; + +METHOD int peer_port_number { + device_t ntb; + int pidx; +}; + +METHOD int peer_port_idx { + device_t ntb; + int port; +}; + METHOD bool link_is_up { device_t ntb; enum ntb_speed *speed; Modified: stable/12/sys/dev/ntb/ntb_transport.c ============================================================================== --- stable/12/sys/dev/ntb/ntb_transport.c Tue Aug 27 04:04:19 2019 (r351535) +++ stable/12/sys/dev/ntb/ntb_transport.c Tue Aug 27 04:13:22 2019 (r351536) @@ -179,7 +179,6 @@ struct ntb_transport_mw { bus_addr_t addr_limit; /* Tx buff is off vbase / phys_addr */ caddr_t vbase; - size_t xlat_size; size_t buff_size; /* Rx buff is off virt_addr / dma_addr */ bus_dma_tag_t dma_tag; @@ -376,7 +375,6 @@ ntb_transport_attach(device_t dev) goto err; mw->buff_size = 0; - mw->xlat_size = 0; mw->virt_addr = NULL; mw->dma_addr = 0; @@ -462,6 +460,13 @@ ntb_transport_attach(device_t dev) ntb_link_enable(dev, NTB_SPEED_AUTO, NTB_WIDTH_AUTO); + for (i = 0; i < nt->mw_count; i++) { + mw = &nt->mw_vec[i]; + rc = ntb_mw_set_trans(nt->dev, i, mw->dma_addr, mw->buff_size); + if (rc != 0) + ntb_printf(0, "load time mw%d xlat fails, rc %d\n", i, rc); + } + if (enable_xeon_watchdog != 0) callout_reset(&nt->link_watchdog, 0, xeon_link_watchdog_hb, nt); @@ -1088,6 +1093,7 @@ static void ntb_transport_link_work(void *arg) { struct ntb_transport_ctx *nt = arg; + struct ntb_transport_mw *mw; device_t dev = nt->dev; struct ntb_transport_qp *qp; uint64_t val64, size; @@ -1132,9 +1138,26 @@ ntb_transport_link_work(void *arg) ntb_spad_read(dev, NTBT_MW0_SZ_LOW + (i * 2), &val); val64 |= val; - rc = ntb_set_mw(nt, i, val64); - if (rc != 0) - goto free_mws; + mw = &nt->mw_vec[i]; + val64 = roundup(val64, mw->xlat_align_size); + if (mw->buff_size != val64) { + + rc = ntb_set_mw(nt, i, val64); + if (rc != 0) { + ntb_printf(0, "link up set mw%d fails, rc %d\n", + i, rc); + goto free_mws; + } + + /* Notify HW the memory location of the receive buffer */ + rc = ntb_mw_set_trans(nt->dev, i, mw->dma_addr, + mw->buff_size); + if (rc != 0) { + ntb_printf(0, "link up mw%d xlat fails, rc %d\n", + i, rc); + goto free_mws; + } + } } nt->link_is_up = true; @@ -1179,42 +1202,37 @@ ntb_set_mw(struct ntb_transport_ctx *nt, int num_mw, s { struct ntb_transport_mw *mw = &nt->mw_vec[num_mw]; struct ntb_load_cb_args cba; - size_t xlat_size, buff_size; - int rc; + size_t buff_size; if (size == 0) return (EINVAL); - xlat_size = roundup(size, mw->xlat_align_size); - buff_size = xlat_size; + buff_size = roundup(size, mw->xlat_align_size); /* No need to re-setup */ - if (mw->xlat_size == xlat_size) + if (mw->buff_size == buff_size) return (0); if (mw->buff_size != 0) ntb_free_mw(nt, num_mw); /* Alloc memory for receiving data. Must be aligned */ - mw->xlat_size = xlat_size; mw->buff_size = buff_size; if (bus_dma_tag_create(bus_get_dma_tag(nt->dev), mw->xlat_align, 0, mw->addr_limit, BUS_SPACE_MAXADDR, NULL, NULL, mw->buff_size, 1, mw->buff_size, 0, NULL, NULL, &mw->dma_tag)) { - ntb_printf(0, "Unable to create MW tag of size %zu/%zu\n", - mw->buff_size, mw->xlat_size); - mw->xlat_size = 0; + ntb_printf(0, "Unable to create MW tag of size %zu\n", + mw->buff_size); mw->buff_size = 0; return (ENOMEM); } if (bus_dmamem_alloc(mw->dma_tag, (void **)&mw->virt_addr, BUS_DMA_WAITOK | BUS_DMA_ZERO, &mw->dma_map)) { bus_dma_tag_destroy(mw->dma_tag); - ntb_printf(0, "Unable to allocate MW buffer of size %zu/%zu\n", - mw->buff_size, mw->xlat_size); - mw->xlat_size = 0; + ntb_printf(0, "Unable to allocate MW buffer of size %zu\n", + mw->buff_size); mw->buff_size = 0; return (ENOMEM); } @@ -1222,22 +1240,13 @@ ntb_set_mw(struct ntb_transport_ctx *nt, int num_mw, s mw->buff_size, ntb_load_cb, &cba, BUS_DMA_NOWAIT) || cba.error) { bus_dmamem_free(mw->dma_tag, mw->virt_addr, mw->dma_map); bus_dma_tag_destroy(mw->dma_tag); - ntb_printf(0, "Unable to load MW buffer of size %zu/%zu\n", - mw->buff_size, mw->xlat_size); - mw->xlat_size = 0; + ntb_printf(0, "Unable to load MW buffer of size %zu\n", + mw->buff_size); mw->buff_size = 0; return (ENOMEM); } mw->dma_addr = cba.addr; - /* Notify HW the memory location of the receive buffer */ - rc = ntb_mw_set_trans(nt->dev, num_mw, mw->dma_addr, mw->xlat_size); - if (rc) { - ntb_printf(0, "Unable to set mw%d translation\n", num_mw); - ntb_free_mw(nt, num_mw); - return (rc); - } - return (0); } @@ -1253,7 +1262,6 @@ ntb_free_mw(struct ntb_transport_ctx *nt, int num_mw) bus_dmamap_unload(mw->dma_tag, mw->dma_map); bus_dmamem_free(mw->dma_tag, mw->virt_addr, mw->dma_map); bus_dma_tag_destroy(mw->dma_tag); - mw->xlat_size = 0; mw->buff_size = 0; mw->virt_addr = NULL; } @@ -1280,7 +1288,7 @@ ntb_transport_setup_qp_mw(struct ntb_transport_ctx *nt else num_qps_mw = nt->qp_count / mw_count; - rx_size = mw->xlat_size / num_qps_mw; + rx_size = mw->buff_size / num_qps_mw; qp->rx_buff = mw->virt_addr + rx_size * (qp_num / mw_count); rx_size -= sizeof(struct ntb_rx_info); Modified: stable/12/sys/i386/conf/NOTES ============================================================================== --- stable/12/sys/i386/conf/NOTES Tue Aug 27 04:04:19 2019 (r351535) +++ stable/12/sys/i386/conf/NOTES Tue Aug 27 04:13:22 2019 (r351536) @@ -643,6 +643,7 @@ device wpifw device if_ntb # Virtual NTB network interface device ntb_transport # NTB packet transport driver device ntb # NTB hardware interface +device ntb_hw_amd # AMD NTB hardware driver device ntb_hw_intel # Intel NTB hardware driver device ntb_hw_plx # PLX NTB hardware driver Modified: stable/12/sys/modules/ntb/Makefile ============================================================================== --- stable/12/sys/modules/ntb/Makefile Tue Aug 27 04:04:19 2019 (r351535) +++ stable/12/sys/modules/ntb/Makefile Tue Aug 27 04:13:22 2019 (r351536) @@ -1,5 +1,5 @@ # $FreeBSD$ -SUBDIR= ntb ntb_hw_intel ntb_hw_plx ntb_transport if_ntb +SUBDIR= ntb ntb_hw_amd ntb_hw_intel ntb_hw_plx ntb_transport if_ntb .include From owner-svn-src-stable-12@freebsd.org Tue Aug 27 04:14:39 2019 Return-Path: Delivered-To: svn-src-stable-12@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 6599EC8C11; Tue, 27 Aug 2019 04:14: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 46Hb9q2mK6z4LL4; Tue, 27 Aug 2019 04:14: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 4080E191ED; Tue, 27 Aug 2019 04:14: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 x7R4EdoA007021; Tue, 27 Aug 2019 04:14:39 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7R4EclF007020; Tue, 27 Aug 2019 04:14:38 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201908270414.x7R4EclF007020@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Tue, 27 Aug 2019 04:14:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r351537 - stable/12/sys/dev/ntb/ntb_hw X-SVN-Group: stable-12 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/12/sys/dev/ntb/ntb_hw X-SVN-Commit-Revision: 351537 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-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Aug 2019 04:14:39 -0000 Author: mav Date: Tue Aug 27 04:14:38 2019 New Revision: 351537 URL: https://svnweb.freebsd.org/changeset/base/351537 Log: MFC r351056, r351083: Add support for PCI Device ID 0x148B in ntb_hw_amd driver. Submitted by: Rajesh Kumar Modified: stable/12/sys/dev/ntb/ntb_hw/ntb_hw_amd.c stable/12/sys/dev/ntb/ntb_hw/ntb_hw_amd.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/ntb/ntb_hw/ntb_hw_amd.c ============================================================================== --- stable/12/sys/dev/ntb/ntb_hw/ntb_hw_amd.c Tue Aug 27 04:13:22 2019 (r351536) +++ stable/12/sys/dev/ntb/ntb_hw/ntb_hw_amd.c Tue Aug 27 04:14:38 2019 (r351537) @@ -80,8 +80,35 @@ __FBSDID("$FreeBSD$"); MALLOC_DEFINE(M_AMD_NTB, "amd_ntb_hw", "amd_ntb_hw driver memory allocations"); -struct pci_device_table amd_ntb_devs[] = { - { PCI_DEV(NTB_HW_AMD_VENDOR_ID, NTB_HW_AMD_DEVICE_ID), +static const struct amd_ntb_hw_info amd_ntb_hw_info_list[] = { + + { .vendor_id = NTB_HW_AMD_VENDOR_ID, + .device_id = NTB_HW_AMD_DEVICE_ID1, + .mw_count = 3, + .bar_start_idx = 1, + .spad_count = 16, + .db_count = 16, + .msix_vector_count = 24, + .quirks = QUIRK_MW0_32BIT, + .desc = "AMD Non-Transparent Bridge"}, + + { .vendor_id = NTB_HW_AMD_VENDOR_ID, + .device_id = NTB_HW_AMD_DEVICE_ID2, + .mw_count = 2, + .bar_start_idx = 2, + .spad_count = 16, + .db_count = 16, + .msix_vector_count = 24, + .quirks = 0, + .desc = "AMD Non-Transparent Bridge"}, +}; + +static const struct pci_device_table amd_ntb_devs[] = { + { PCI_DEV(NTB_HW_AMD_VENDOR_ID, NTB_HW_AMD_DEVICE_ID1), + .driver_data = (uintptr_t)&amd_ntb_hw_info_list[0], + PCI_DESCR("AMD Non-Transparent Bridge") }, + { PCI_DEV(NTB_HW_AMD_VENDOR_ID, NTB_HW_AMD_DEVICE_ID2), + .driver_data = (uintptr_t)&amd_ntb_hw_info_list[1], PCI_DESCR("AMD Non-Transparent Bridge") } }; @@ -299,7 +326,7 @@ amd_ntb_mw_count(device_t dev) { struct amd_ntb_softc *ntb = device_get_softc(dev); - return (ntb->mw_count); + return (ntb->hw_info->mw_count); } static int @@ -310,10 +337,10 @@ amd_ntb_mw_get_range(device_t dev, unsigned mw_idx, vm struct amd_ntb_softc *ntb = device_get_softc(dev); struct amd_ntb_pci_bar_info *bar_info; - if (mw_idx < 0 || mw_idx >= ntb->mw_count) + if (mw_idx < 0 || mw_idx >= ntb->hw_info->mw_count) return (EINVAL); - bar_info = &ntb->bar_info[mw_idx+1]; + bar_info = &ntb->bar_info[ntb->hw_info->bar_start_idx + mw_idx]; if (base != NULL) *base = bar_info->pbase; @@ -331,10 +358,15 @@ amd_ntb_mw_get_range(device_t dev, unsigned mw_idx, vm *align_size = 1; if (plimit != NULL) { - if (mw_idx != 0) - *plimit = BUS_SPACE_MAXADDR; - else + /* + * For Device ID 0x145B (which has 3 memory windows), + * memory window 0 use a 32-bit bar. The remaining + * cases all use 64-bit bar. + */ + if ((mw_idx == 0) && (ntb->hw_info->quirks & QUIRK_MW0_32BIT)) *plimit = BUS_SPACE_MAXADDR_32BIT; + else + *plimit = BUS_SPACE_MAXADDR; } return (0); @@ -346,44 +378,52 @@ amd_ntb_mw_set_trans(device_t dev, unsigned mw_idx, bu struct amd_ntb_softc *ntb = device_get_softc(dev); struct amd_ntb_pci_bar_info *bar_info; - if (mw_idx < 0 || mw_idx >= ntb->mw_count) + if (mw_idx < 0 || mw_idx >= ntb->hw_info->mw_count) return (EINVAL); - bar_info = &ntb->bar_info[mw_idx+1]; + bar_info = &ntb->bar_info[ntb->hw_info->bar_start_idx + mw_idx]; - /* make sure the range fits in the usable mw size */ + /* Make sure the range fits in the usable mw size. */ if (size > bar_info->size) { - amd_ntb_printf(0, "%s: size 0x%x greater than mw_size 0x%x\n", - __func__, (uint32_t)size, (uint32_t)bar_info->size); + amd_ntb_printf(0, "%s: size 0x%jx greater than mw_size 0x%jx\n", + __func__, (uintmax_t)size, (uintmax_t)bar_info->size); return (EINVAL); } - amd_ntb_printf(1, "%s: mw %d mw_size 0x%x size 0x%x base %p\n", - __func__, mw_idx, (uint32_t)bar_info->size, - (uint32_t)size, (void *)bar_info->pci_bus_handle); + amd_ntb_printf(1, "%s: mw %d mw_size 0x%jx size 0x%jx base %p\n", + __func__, mw_idx, (uintmax_t)bar_info->size, + (uintmax_t)size, (void *)bar_info->pci_bus_handle); /* * AMD NTB XLAT and Limit registers needs to be written only after - * link enable + * link enable. * - * set and verify setting the translation address + * Set and verify setting the translation address register. */ amd_ntb_peer_reg_write(8, bar_info->xlat_off, (uint64_t)addr); amd_ntb_printf(0, "%s: mw %d xlat_off 0x%x cur_val 0x%jx addr %p\n", __func__, mw_idx, bar_info->xlat_off, amd_ntb_peer_reg_read(8, bar_info->xlat_off), (void *)addr); - /* set and verify setting the limit */ - if (mw_idx != 0) { - amd_ntb_reg_write(8, bar_info->limit_off, (uint64_t)size); - amd_ntb_printf(1, "%s: limit_off 0x%x cur_val 0x%jx limit 0x%x\n", + /* + * Set and verify setting the limit register. + * + * For Device ID 0x145B (which has 3 memory windows), + * memory window 0 use a 32-bit bar. The remaining + * cases all use 64-bit bar. + */ + if ((mw_idx == 0) && (ntb->hw_info->quirks & QUIRK_MW0_32BIT)) { + amd_ntb_reg_write(4, bar_info->limit_off, (uint32_t)size); + amd_ntb_printf(1, "%s: limit_off 0x%x cur_val 0x%x limit 0x%x\n", __func__, bar_info->limit_off, - amd_ntb_peer_reg_read(8, bar_info->limit_off), (uint32_t)size); + amd_ntb_peer_reg_read(4, bar_info->limit_off), + (uint32_t)size); } else { - amd_ntb_reg_write(4, bar_info->limit_off, (uint64_t)size); - amd_ntb_printf(1, "%s: limit_off 0x%x cur_val 0x%x limit 0x%x\n", + amd_ntb_reg_write(8, bar_info->limit_off, (uint64_t)size); + amd_ntb_printf(1, "%s: limit_off 0x%x cur_val 0x%jx limit 0x%jx\n", __func__, bar_info->limit_off, - amd_ntb_peer_reg_read(4, bar_info->limit_off), (uint32_t)size); + amd_ntb_peer_reg_read(8, bar_info->limit_off), + (uintmax_t)size); } return (0); @@ -396,7 +436,7 @@ amd_ntb_mw_clear_trans(device_t dev, unsigned mw_idx) amd_ntb_printf(1, "%s: mw_idx %d\n", __func__, mw_idx); - if (mw_idx < 0 || mw_idx >= ntb->mw_count) + if (mw_idx < 0 || mw_idx >= ntb->hw_info->mw_count) return (EINVAL); return (amd_ntb_mw_set_trans(dev, mw_idx, 0, 0)); @@ -409,10 +449,10 @@ amd_ntb_mw_set_wc(device_t dev, unsigned int mw_idx, v struct amd_ntb_pci_bar_info *bar_info; int rc; - if (mw_idx < 0 || mw_idx >= ntb->mw_count) + if (mw_idx < 0 || mw_idx >= ntb->hw_info->mw_count) return (EINVAL); - bar_info = &ntb->bar_info[mw_idx+1]; + bar_info = &ntb->bar_info[ntb->hw_info->bar_start_idx + mw_idx]; if (mode == bar_info->map_mode) return (0); @@ -431,10 +471,10 @@ amd_ntb_mw_get_wc(device_t dev, unsigned mw_idx, vm_me amd_ntb_printf(1, "%s: mw_idx %d\n", __func__, mw_idx); - if (mw_idx < 0 || mw_idx >= ntb->mw_count) + if (mw_idx < 0 || mw_idx >= ntb->hw_info->mw_count) return (EINVAL); - bar_info = &ntb->bar_info[mw_idx+1]; + bar_info = &ntb->bar_info[ntb->hw_info->bar_start_idx + mw_idx]; *mode = bar_info->map_mode; return (0); @@ -448,9 +488,10 @@ amd_ntb_db_vector_count(device_t dev) { struct amd_ntb_softc *ntb = device_get_softc(dev); - amd_ntb_printf(1, "%s: db_count 0x%x\n", __func__, ntb->db_count); + amd_ntb_printf(1, "%s: db_count 0x%x\n", __func__, + ntb->hw_info->db_count); - return (ntb->db_count); + return (ntb->hw_info->db_count); } static uint64_t @@ -470,9 +511,9 @@ amd_ntb_db_vector_mask(device_t dev, uint32_t vector) struct amd_ntb_softc *ntb = device_get_softc(dev); amd_ntb_printf(1, "%s: vector %d db_count 0x%x db_valid_mask 0x%x\n", - __func__, vector, ntb->db_count, ntb->db_valid_mask); + __func__, vector, ntb->hw_info->db_count, ntb->db_valid_mask); - if (vector < 0 || vector >= ntb->db_count) + if (vector < 0 || vector >= ntb->hw_info->db_count) return (0); return (ntb->db_valid_mask & (1 << vector)); @@ -545,7 +586,8 @@ amd_ntb_spad_count(device_t dev) { struct amd_ntb_softc *ntb = device_get_softc(dev); - amd_ntb_printf(1, "%s: spad_count 0x%x\n", __func__, ntb->spad_count); + amd_ntb_printf(1, "%s: spad_count 0x%x\n", __func__, + ntb->spad_count); return (ntb->spad_count); } @@ -662,11 +704,11 @@ amd_ntb_hw_info_handler(SYSCTL_HANDLER_ARGS) } sbuf_printf(sb, "AMD Memory window count: %d\n", - ntb->mw_count); + ntb->hw_info->mw_count); sbuf_printf(sb, "AMD Spad count: %d\n", ntb->spad_count); sbuf_printf(sb, "AMD Doorbell count: %d\n", - ntb->db_count); + ntb->hw_info->db_count); sbuf_printf(sb, "AMD MSI-X vec count: %d\n\n", ntb->msix_vec_count); sbuf_printf(sb, "AMD Doorbell valid mask: 0x%x\n", @@ -757,7 +799,7 @@ amd_link_hb(void *arg) static void amd_ntb_interrupt(struct amd_ntb_softc *ntb, uint16_t vec) { - if (vec < AMD_DB_CNT) + if (vec < ntb->hw_info->db_count) ntb_db_event(ntb->device, vec); else amd_ntb_printf(0, "Invalid vector %d\n", vec); @@ -891,7 +933,7 @@ amd_ntb_init_isr(struct amd_ntb_softc *ntb) ntb->db_mask = ntb->db_valid_mask; - rc = amd_ntb_create_msix_vec(ntb, AMD_MSIX_VECTOR_CNT); + rc = amd_ntb_create_msix_vec(ntb, ntb->hw_info->msix_vector_count); if (rc != 0) { amd_ntb_printf(0, "Error creating msix vectors: %d\n", rc); return (ENOMEM); @@ -899,13 +941,13 @@ amd_ntb_init_isr(struct amd_ntb_softc *ntb) /* * Check the number of MSI-X message supported by the device. - * Minimum necessary MSI-X message count should be equal to db_count + * Minimum necessary MSI-X message count should be equal to db_count. */ supported_vectors = pci_msix_count(ntb->device); - num_vectors = MIN(supported_vectors, ntb->db_count); - if (num_vectors < ntb->db_count) { + num_vectors = MIN(supported_vectors, ntb->hw_info->db_count); + if (num_vectors < ntb->hw_info->db_count) { amd_ntb_printf(0, "No minimum msix: supported %d db %d\n", - supported_vectors, ntb->db_count); + supported_vectors, ntb->hw_info->db_count); msi = true; goto err_msix_enable; } @@ -918,12 +960,12 @@ amd_ntb_init_isr(struct amd_ntb_softc *ntb) goto err_msix_enable; } - if (num_vectors < ntb->db_count) { + if (num_vectors < ntb->hw_info->db_count) { amd_ntb_printf(0, "Allocated only %d MSI-X\n", num_vectors); msi = true; /* - * Else set ntb->db_count = ntb->msix_vec_count = num_vectors, - * msi=false and dont release msi + * Else set ntb->hw_info->db_count = ntb->msix_vec_count = + * num_vectors, msi=false and dont release msi. */ } @@ -942,16 +984,16 @@ err_msix_enable: } } - ntb->db_count = ntb->msix_vec_count = num_vectors; + ntb->hw_info->db_count = ntb->msix_vec_count = num_vectors; if (intx) { num_vectors = 1; - ntb->db_count = 1; + ntb->hw_info->db_count = 1; ntb->msix_vec_count = 0; } amd_ntb_printf(0, "%s: db %d msix %d msi %d intx %d\n", - __func__, ntb->db_count, ntb->msix_vec_count, (int)msi, (int)intx); + __func__, ntb->hw_info->db_count, ntb->msix_vec_count, (int)msi, (int)intx); rc = amd_ntb_setup_isr(ntb, num_vectors, msi, intx); if (rc != 0) { @@ -1002,10 +1044,7 @@ amd_ntb_get_topo(struct amd_ntb_softc *ntb) static int amd_ntb_init_dev(struct amd_ntb_softc *ntb) { - ntb->mw_count = AMD_MW_CNT; - ntb->spad_count = AMD_SPADS_CNT; - ntb->db_count = AMD_DB_CNT; - ntb->db_valid_mask = (1ull << ntb->db_count) - 1; + ntb->db_valid_mask = (1ull << ntb->hw_info->db_count) - 1; mtx_init(&ntb->db_mask_lock, "amd ntb db bits", NULL, MTX_SPIN); switch (ntb->conn_type) { @@ -1105,7 +1144,7 @@ amd_ntb_map_pci_bars(struct amd_ntb_softc *ntb) if (rc != 0) goto out; - /* Memory Window 0 BAR - BAR 1*/ + /* Memory Window 0 BAR - BAR 1 */ ntb->bar_info[NTB_BAR_1].pci_resource_id = PCIR_BAR(1); rc = map_bar(ntb, &ntb->bar_info[NTB_BAR_1]); if (rc != 0) @@ -1153,12 +1192,15 @@ amd_ntb_unmap_pci_bars(struct amd_ntb_softc *ntb) static int amd_ntb_probe(device_t device) { + struct amd_ntb_softc *ntb = device_get_softc(device); const struct pci_device_table *tbl; tbl = PCI_MATCH(device, amd_ntb_devs); if (tbl == NULL) return (ENXIO); + ntb->hw_info = (struct amd_ntb_hw_info *)tbl->driver_data; + ntb->spad_count = ntb->hw_info->spad_count; device_set_desc(device, tbl->descr); return (BUS_PROBE_GENERIC); Modified: stable/12/sys/dev/ntb/ntb_hw/ntb_hw_amd.h ============================================================================== --- stable/12/sys/dev/ntb/ntb_hw/ntb_hw_amd.h Tue Aug 27 04:13:22 2019 (r351536) +++ stable/12/sys/dev/ntb/ntb_hw/ntb_hw_amd.h Tue Aug 27 04:14:38 2019 (r351537) @@ -48,7 +48,8 @@ #define NTB_HW_AMD_H #define NTB_HW_AMD_VENDOR_ID 0x1022 -#define NTB_HW_AMD_DEVICE_ID 0x145B +#define NTB_HW_AMD_DEVICE_ID1 0x145B +#define NTB_HW_AMD_DEVICE_ID2 0x148B #define NTB_DEF_PEER_CNT 1 #define NTB_DEF_PEER_IDX 0 @@ -82,6 +83,8 @@ #define DB_MASK_UNLOCK(sc) mtx_unlock_spin(&(sc)->db_mask_lock) #define DB_MASK_ASSERT(sc, f) mtx_assert(&(sc)->db_mask_lock, (f)) +#define QUIRK_MW0_32BIT 0x01 + /* amd_ntb_conn_type are hardware numbers, cannot change. */ enum amd_ntb_conn_type { NTB_CONN_NONE = -1, @@ -103,8 +106,15 @@ enum amd_ntb_bar { }; struct amd_ntb_hw_info { - uint32_t device_id; - const char *desc; + uint16_t vendor_id; + uint16_t device_id; + uint8_t mw_count; + uint8_t bar_start_idx; + uint8_t spad_count; + uint8_t db_count; + uint8_t msix_vector_count; + uint8_t quirks; + char *desc; }; struct amd_ntb_pci_bar_info { @@ -135,12 +145,6 @@ struct amd_ntb_vec { }; enum { - /* AMD NTB Capability */ - AMD_MW_CNT = 3, - AMD_DB_CNT = 16, - AMD_MSIX_VECTOR_CNT = 24, - AMD_SPADS_CNT = 16, - /* AMD NTB Link Status Offset */ AMD_LINK_STATUS_OFFSET = 0x68, @@ -226,15 +230,14 @@ struct amd_ntb_softc { enum amd_ntb_conn_type conn_type; struct amd_ntb_pci_bar_info bar_info[NTB_MAX_BARS]; - struct amd_ntb_int_info int_info[AMD_MSIX_VECTOR_CNT]; + struct amd_ntb_int_info int_info[16]; struct amd_ntb_vec *msix_vec; uint16_t allocated_interrupts; struct callout hb_timer; - uint8_t mw_count; + struct amd_ntb_hw_info *hw_info; uint8_t spad_count; - uint8_t db_count; uint8_t msix_vec_count; struct mtx db_mask_lock; From owner-svn-src-stable-12@freebsd.org Tue Aug 27 04:15:22 2019 Return-Path: Delivered-To: svn-src-stable-12@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 52333C8CA5; Tue, 27 Aug 2019 04:15:22 +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 46HbBf1RYMz4LS8; Tue, 27 Aug 2019 04:15:22 +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 12E89191EE; Tue, 27 Aug 2019 04:15:22 +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 x7R4FLrR007118; Tue, 27 Aug 2019 04:15:21 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7R4FL7E007117; Tue, 27 Aug 2019 04:15:21 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201908270415.x7R4FL7E007117@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Tue, 27 Aug 2019 04:15:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r351538 - stable/12/sys/dev/ntb/ntb_hw X-SVN-Group: stable-12 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/12/sys/dev/ntb/ntb_hw X-SVN-Commit-Revision: 351538 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-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Aug 2019 04:15:22 -0000 Author: mav Date: Tue Aug 27 04:15:21 2019 New Revision: 351538 URL: https://svnweb.freebsd.org/changeset/base/351538 Log: MFC r351072: Implement new methods for Intel and PLX NTB. This restores parity with AMD NTB driver. Though without any drivers supporting more then one peer and respective KPI modification to pass peer index to most of the calls this addition is pretty useless now. Modified: stable/12/sys/dev/ntb/ntb_hw/ntb_hw_intel.c stable/12/sys/dev/ntb/ntb_hw/ntb_hw_plx.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/ntb/ntb_hw/ntb_hw_intel.c ============================================================================== --- stable/12/sys/dev/ntb/ntb_hw/ntb_hw_intel.c Tue Aug 27 04:14:38 2019 (r351537) +++ stable/12/sys/dev/ntb/ntb_hw/ntb_hw_intel.c Tue Aug 27 04:15:21 2019 (r351538) @@ -1977,6 +1977,44 @@ atom_perform_link_restart(struct ntb_softc *ntb) } static int +intel_ntb_port_number(device_t dev) +{ + struct ntb_softc *ntb = device_get_softc(dev); + + return (ntb->dev_type == NTB_DEV_USD ? 0 : 1); +} + +static int +intel_ntb_peer_port_count(device_t dev) +{ + + return (1); +} + +static int +intel_ntb_peer_port_number(device_t dev, int pidx) +{ + struct ntb_softc *ntb = device_get_softc(dev); + + if (pidx != 0) + return (-EINVAL); + + return (ntb->dev_type == NTB_DEV_USD ? 1 : 0); +} + +static int +intel_ntb_peer_port_idx(device_t dev, int port) +{ + int peer_port; + + peer_port = intel_ntb_peer_port_number(dev, 0); + if (peer_port == -EINVAL || port != peer_port) + return (-EINVAL); + + return (0); +} + +static int intel_ntb_link_enable(device_t dev, enum ntb_speed speed __unused, enum ntb_width width __unused) { @@ -3086,6 +3124,10 @@ static device_method_t ntb_intel_methods[] = { DEVMETHOD(bus_child_location_str, ntb_child_location_str), DEVMETHOD(bus_print_child, ntb_print_child), /* NTB interface */ + DEVMETHOD(ntb_port_number, intel_ntb_port_number), + DEVMETHOD(ntb_peer_port_count, intel_ntb_peer_port_count), + DEVMETHOD(ntb_peer_port_number, intel_ntb_peer_port_number), + DEVMETHOD(ntb_peer_port_idx, intel_ntb_peer_port_idx), DEVMETHOD(ntb_link_is_up, intel_ntb_link_is_up), DEVMETHOD(ntb_link_enable, intel_ntb_link_enable), DEVMETHOD(ntb_link_disable, intel_ntb_link_disable), Modified: stable/12/sys/dev/ntb/ntb_hw/ntb_hw_plx.c ============================================================================== --- stable/12/sys/dev/ntb/ntb_hw/ntb_hw_plx.c Tue Aug 27 04:14:38 2019 (r351537) +++ stable/12/sys/dev/ntb/ntb_hw/ntb_hw_plx.c Tue Aug 27 04:15:21 2019 (r351538) @@ -470,7 +470,44 @@ ntb_plx_detach(device_t dev) return (0); } +static int +ntb_plx_port_number(device_t dev) +{ + struct ntb_plx_softc *sc = device_get_softc(dev); + return (sc->link ? 1 : 0); +} + +static int +ntb_plx_peer_port_count(device_t dev) +{ + + return (1); +} + +static int +ntb_plx_peer_port_number(device_t dev, int pidx) +{ + struct ntb_plx_softc *sc = device_get_softc(dev); + + if (pidx != 0) + return (-EINVAL); + + return (sc->link ? 0 : 1); +} + +static int +ntb_plx_peer_port_idx(device_t dev, int port) +{ + int peer_port; + + peer_port = ntb_plx_peer_port_number(dev, 0); + if (peer_port == -EINVAL || port != peer_port) + return (-EINVAL); + + return (0); +} + static bool ntb_plx_link_is_up(device_t dev, enum ntb_speed *speed, enum ntb_width *width) { @@ -974,6 +1011,10 @@ static device_method_t ntb_plx_methods[] = { DEVMETHOD(bus_child_location_str, ntb_child_location_str), DEVMETHOD(bus_print_child, ntb_print_child), /* NTB interface */ + DEVMETHOD(ntb_port_number, ntb_plx_port_number), + DEVMETHOD(ntb_peer_port_count, ntb_plx_peer_port_count), + DEVMETHOD(ntb_peer_port_number, ntb_plx_peer_port_number), + DEVMETHOD(ntb_peer_port_idx, ntb_plx_peer_port_idx), DEVMETHOD(ntb_link_is_up, ntb_plx_link_is_up), DEVMETHOD(ntb_link_enable, ntb_plx_link_enable), DEVMETHOD(ntb_link_disable, ntb_plx_link_disable), From owner-svn-src-stable-12@freebsd.org Tue Aug 27 04:16:43 2019 Return-Path: Delivered-To: svn-src-stable-12@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 4D365C8D3E; Tue, 27 Aug 2019 04:16:43 +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 46HbDC1Ndbz4LZP; Tue, 27 Aug 2019 04:16:43 +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 1107C191EF; Tue, 27 Aug 2019 04:16:43 +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 x7R4GgQ6007246; Tue, 27 Aug 2019 04:16:42 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7R4GgSr007244; Tue, 27 Aug 2019 04:16:42 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201908270416.x7R4GgSr007244@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Tue, 27 Aug 2019 04:16:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r351539 - in stable/12: share/man/man4 sys/dev/ntb X-SVN-Group: stable-12 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: in stable/12: share/man/man4 sys/dev/ntb X-SVN-Commit-Revision: 351539 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-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Aug 2019 04:16:43 -0000 Author: mav Date: Tue Aug 27 04:16:42 2019 New Revision: 351539 URL: https://svnweb.freebsd.org/changeset/base/351539 Log: MFC r351105, r351107: Limit memory window usage in ntb_transport to 256MB. This adds safety net for the case of misconfigured NTB with too big memory window, for which we may be unable to allocate a memory buffer, which does not make much sense for the network interface. While there, fix the code to really work with asymmetric window sizes setup. This makes driver just print warning message on boot instead of hanging if too large memory window is configured. Modified: stable/12/share/man/man4/ntb_transport.4 stable/12/sys/dev/ntb/ntb_transport.c Directory Properties: stable/12/ (props changed) Modified: stable/12/share/man/man4/ntb_transport.4 ============================================================================== --- stable/12/share/man/man4/ntb_transport.4 Tue Aug 27 04:15:21 2019 (r351538) +++ stable/12/share/man/man4/ntb_transport.4 Tue Aug 27 04:16:42 2019 (r351539) @@ -1,5 +1,5 @@ .\" -.\" Copyright (c) 2016-2017 Alexander Motin +.\" Copyright (c) 2016-2019 Alexander Motin .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 2, 2017 +.Dd August 15, 2019 .Dt NTB_TRANSPORT 4 .Os .Sh NAME @@ -51,6 +51,10 @@ The following tunables are settable from the .It Va hw.ntb_transport.debug_level Driver debug level. The default value is 0, higher means more verbose. +.It Va hw.ntb_transport.max_mw_size +Limits maximum memory window usage. +Allocation of big physically contiguous memory buffer may be a problem, +while too big buffers makes no much sense for low latency network interface. .It Va hint.ntb_transport. Ns Ar X Ns Va .config Configures a set of the transport consumers, separated by commas. Each consumer can be configured as: "[][:]", where: Modified: stable/12/sys/dev/ntb/ntb_transport.c ============================================================================== --- stable/12/sys/dev/ntb/ntb_transport.c Tue Aug 27 04:15:21 2019 (r351538) +++ stable/12/sys/dev/ntb/ntb_transport.c Tue Aug 27 04:16:42 2019 (r351539) @@ -81,7 +81,7 @@ SYSCTL_UINT(_hw_ntb_transport, OID_AUTO, debug_level, static unsigned transport_mtu = 0x10000; -static uint64_t max_mw_size; +static uint64_t max_mw_size = 256*1024*1024; SYSCTL_UQUAD(_hw_ntb_transport, OID_AUTO, max_mw_size, CTLFLAG_RDTUN, &max_mw_size, 0, "If enabled (non-zero), limit the size of large memory windows. " "Both sides of the NTB MUST set the same value here."); @@ -177,14 +177,17 @@ struct ntb_transport_mw { size_t xlat_align; size_t xlat_align_size; bus_addr_t addr_limit; - /* Tx buff is off vbase / phys_addr */ + /* Tx buff is vbase / phys_addr / tx_size */ caddr_t vbase; - size_t buff_size; - /* Rx buff is off virt_addr / dma_addr */ + size_t tx_size; + /* Rx buff is virt_addr / dma_addr / rx_size */ bus_dma_tag_t dma_tag; bus_dmamap_t dma_map; caddr_t virt_addr; bus_addr_t dma_addr; + size_t rx_size; + /* rx_size increased to size alignment requirements of the hardware. */ + size_t buff_size; }; struct ntb_transport_child { @@ -331,7 +334,7 @@ ntb_transport_attach(device_t dev) struct ntb_transport_child **cpp = &nt->child; struct ntb_transport_child *nc; struct ntb_transport_mw *mw; - uint64_t db_bitmap, size; + uint64_t db_bitmap; int rc, i, db_count, spad_count, qp, qpu, qpo, qpt; char cfg[128] = ""; char buf[32]; @@ -374,6 +377,15 @@ ntb_transport_attach(device_t dev) if (rc != 0) goto err; + mw->tx_size = mw->phys_size; + if (max_mw_size != 0 && mw->tx_size > max_mw_size) { + device_printf(dev, "Memory window %d limited from " + "%ju to %ju\n", i, (uintmax_t)mw->phys_size, + max_mw_size); + mw->tx_size = max_mw_size; + } + + mw->rx_size = 0; mw->buff_size = 0; mw->virt_addr = NULL; mw->dma_addr = 0; @@ -388,10 +400,7 @@ ntb_transport_attach(device_t dev) * that NTB windows are symmetric and this allocation remain, * but even if not, we will just reallocate it later. */ - size = mw->phys_size; - if (max_mw_size != 0 && size > max_mw_size) - size = max_mw_size; - ntb_set_mw(nt, i, size); + ntb_set_mw(nt, i, mw->tx_size); } qpu = 0; @@ -556,7 +565,7 @@ ntb_transport_init_queue(struct ntb_transport_ctx *nt, struct ntb_transport_mw *mw; struct ntb_transport_qp *qp; vm_paddr_t mw_base; - uint64_t mw_size, qp_offset; + uint64_t qp_offset; size_t tx_size; unsigned num_qps_mw, mw_num, mw_count; @@ -578,9 +587,8 @@ ntb_transport_init_queue(struct ntb_transport_ctx *nt, num_qps_mw = nt->qp_count / mw_count; mw_base = mw->phys_addr; - mw_size = mw->phys_size; - tx_size = mw_size / num_qps_mw; + tx_size = mw->tx_size / num_qps_mw; qp_offset = tx_size * (qp_num / mw_count); qp->tx_mw = mw->vbase + qp_offset; @@ -1103,11 +1111,7 @@ ntb_transport_link_work(void *arg) /* send the local info, in the opposite order of the way we read it */ for (i = 0; i < nt->mw_count; i++) { - size = nt->mw_vec[i].phys_size; - - if (max_mw_size != 0 && size > max_mw_size) - size = max_mw_size; - + size = nt->mw_vec[i].tx_size; ntb_peer_spad_write(dev, NTBT_MW0_SZ_HIGH + (i * 2), size >> 32); ntb_peer_spad_write(dev, NTBT_MW0_SZ_LOW + (i * 2), size); @@ -1139,6 +1143,7 @@ ntb_transport_link_work(void *arg) val64 |= val; mw = &nt->mw_vec[i]; + mw->rx_size = val64; val64 = roundup(val64, mw->xlat_align_size); if (mw->buff_size != val64) { @@ -1288,7 +1293,7 @@ ntb_transport_setup_qp_mw(struct ntb_transport_ctx *nt else num_qps_mw = nt->qp_count / mw_count; - rx_size = mw->buff_size / num_qps_mw; + rx_size = mw->rx_size / num_qps_mw; qp->rx_buff = mw->virt_addr + rx_size * (qp_num / mw_count); rx_size -= sizeof(struct ntb_rx_info); From owner-svn-src-stable-12@freebsd.org Tue Aug 27 07:17:32 2019 Return-Path: Delivered-To: svn-src-stable-12@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 53A31CD38B; Tue, 27 Aug 2019 07:17:32 +0000 (UTC) (envelope-from araujo@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 46HgDr1Tlpz4WHl; Tue, 27 Aug 2019 07:17:32 +0000 (UTC) (envelope-from araujo@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 116031B226; Tue, 27 Aug 2019 07:17:32 +0000 (UTC) (envelope-from araujo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x7R7HVcd014172; Tue, 27 Aug 2019 07:17:31 GMT (envelope-from araujo@FreeBSD.org) Received: (from araujo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7R7HVv4014170; Tue, 27 Aug 2019 07:17:31 GMT (envelope-from araujo@FreeBSD.org) Message-Id: <201908270717.x7R7HVv4014170@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: araujo set sender to araujo@FreeBSD.org using -f From: Marcelo Araujo Date: Tue, 27 Aug 2019 07:17:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r351541 - stable/12/sys/dev/sound/pci/hda X-SVN-Group: stable-12 X-SVN-Commit-Author: araujo X-SVN-Commit-Paths: stable/12/sys/dev/sound/pci/hda X-SVN-Commit-Revision: 351541 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-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Aug 2019 07:17:32 -0000 Author: araujo Date: Tue Aug 27 07:17:31 2019 New Revision: 351541 URL: https://svnweb.freebsd.org/changeset/base/351541 Log: MFC r350433: Fix sound on headset jack for ALC255 and ALC256 codec. PR: 219350 [1], [2] Submitted by: Masachika ISHIZUKA (ish_at_amail.plala.or.jp) [1] Neel Chauhan (neel_at_neelc.org) [2] Yuri Momotyuk (yurkis_at_gmail.com) [3] Reported by: miwi Reviewed by: mav Obtained from: https://github.com/trueos/trueos/pull/279 [3] MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D19017 Modified: stable/12/sys/dev/sound/pci/hda/hdaa_patches.c stable/12/sys/dev/sound/pci/hda/hdac.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/sound/pci/hda/hdaa_patches.c ============================================================================== --- stable/12/sys/dev/sound/pci/hda/hdaa_patches.c Tue Aug 27 04:19:40 2019 (r351540) +++ stable/12/sys/dev/sound/pci/hda/hdaa_patches.c Tue Aug 27 07:17:31 2019 (r351541) @@ -425,12 +425,21 @@ hdac_pin_patch(struct hdaa_widget *w) } else if (id == HDA_CODEC_ALC298 && subid == DELL_XPS9560_SUBVENDOR) { switch (nid) { case 24: - config = 0x01a1913c; + config = 0x01a1913c; break; case 26: - config = 0x01a1913d; + config = 0x01a1913d; break; } + } else if (id == HDA_CODEC_ALC256 && subid == DELL_I7577_SUBVENDOR ) { + switch (nid) { + case 20: + patch = "as=1 seq=0"; + break; + case 33: + patch = "as=1 seq=15"; + break; + } } if (patch != NULL) @@ -768,6 +777,10 @@ hdaa_patch_direct(struct hdaa_devinfo *devinfo) hdaa_write_coef(dev, 0x20, 0x07, 0x7cb); } break; + } + if (id == HDA_CODEC_ALC255 || id == HDA_CODEC_ALC256) { + val = hdaa_read_coef(dev, 0x20, 0x46); + hdaa_write_coef(dev, 0x20, 0x46, val|0x3000); } if (subid == APPLE_INTEL_MAC) hda_command(dev, HDA_CMD_12BIT(0, devinfo->nid, Modified: stable/12/sys/dev/sound/pci/hda/hdac.h ============================================================================== --- stable/12/sys/dev/sound/pci/hda/hdac.h Tue Aug 27 04:19:40 2019 (r351540) +++ stable/12/sys/dev/sound/pci/hda/hdac.h Tue Aug 27 07:17:31 2019 (r351541) @@ -203,6 +203,7 @@ #define DELL_XPSM1210_SUBVENDOR HDA_MODEL_CONSTRUCT(DELL, 0x01d7) #define DELL_OPLX745_SUBVENDOR HDA_MODEL_CONSTRUCT(DELL, 0x01da) #define DELL_XPS9560_SUBVENDOR HDA_MODEL_CONSTRUCT(DELL, 0x07be) +#define DELL_I7577_SUBVENDOR HDA_MODEL_CONSTRUCT(DELL, 0x0802) #define DELL_ALL_SUBVENDOR HDA_MODEL_CONSTRUCT(DELL, 0xffff) /* Clevo */ From owner-svn-src-stable-12@freebsd.org Wed Aug 28 07:37:34 2019 Return-Path: Delivered-To: svn-src-stable-12@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 F08BED3F31; Wed, 28 Aug 2019 07:37:34 +0000 (UTC) (envelope-from brooks@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 46JHdV63FGz3N4H; Wed, 28 Aug 2019 07:37:34 +0000 (UTC) (envelope-from brooks@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 B0E4F3F2B; Wed, 28 Aug 2019 07:37:34 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x7S7bYiF013165; Wed, 28 Aug 2019 07:37:34 GMT (envelope-from brooks@FreeBSD.org) Received: (from brooks@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7S7bYud013164; Wed, 28 Aug 2019 07:37:34 GMT (envelope-from brooks@FreeBSD.org) Message-Id: <201908280737.x7S7bYud013164@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: brooks set sender to brooks@FreeBSD.org using -f From: Brooks Davis Date: Wed, 28 Aug 2019 07:37:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r351564 - stable/12/sys/kern X-SVN-Group: stable-12 X-SVN-Commit-Author: brooks X-SVN-Commit-Paths: stable/12/sys/kern X-SVN-Commit-Revision: 351564 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-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Aug 2019 07:37:35 -0000 Author: brooks Date: Wed Aug 28 07:37:34 2019 New Revision: 351564 URL: https://svnweb.freebsd.org/changeset/base/351564 Log: MFC r339624: Remove the need for backslashes in syscalls.master. Join non-special lines together until we hit a line containing a '}' character. This allows the function declaration body to be split across multiple lines without backslash continuation characters. Continue to join lines ending with backslashes to allow gradual migration and to support out-of-tree syscall vectors Reviewed by: emaste, kib Obtained from: CheriBSD Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D17488 Modified: stable/12/sys/kern/makesyscalls.sh Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/kern/makesyscalls.sh ============================================================================== --- stable/12/sys/kern/makesyscalls.sh Wed Aug 28 04:55:17 2019 (r351563) +++ stable/12/sys/kern/makesyscalls.sh Wed Aug 28 07:37:34 2019 (r351564) @@ -68,13 +68,33 @@ if [ -n "$2" ]; then fi sed -e ' -:join + # FreeBSD ID, includes, comments, and blank lines + /.*\$FreeBSD/b done_joining + /^[#;]/b done_joining + /^$/b done_joining + + # Join lines ending in backslash +:joining /\\$/{a\ N s/\\\n// - b join + b joining } + + # OBSOL, etc lines without function signatures + /^[0-9][^{]*$/b done_joining + + # Join incomplete signatures. The { must appear on the first line + # and the } must appear on the last line (modulo lines joined by + # backslashes). + /^[^}]*$/{a\ + + N + s/\n// + b joining + } +:done_joining 2,${ /^#/!s/\([{}()*,]\)/ \1 /g } From owner-svn-src-stable-12@freebsd.org Wed Aug 28 07:43:39 2019 Return-Path: Delivered-To: svn-src-stable-12@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 4193BD41D8; Wed, 28 Aug 2019 07:43:39 +0000 (UTC) (envelope-from brooks@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 46JHmW1kRgz3NS0; Wed, 28 Aug 2019 07:43:39 +0000 (UTC) (envelope-from brooks@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 1CBA2412C; Wed, 28 Aug 2019 07:43:39 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x7S7hcqq018749; Wed, 28 Aug 2019 07:43:38 GMT (envelope-from brooks@FreeBSD.org) Received: (from brooks@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7S7hV7U018712; Wed, 28 Aug 2019 07:43:31 GMT (envelope-from brooks@FreeBSD.org) Message-Id: <201908280743.x7S7hV7U018712@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: brooks set sender to brooks@FreeBSD.org using -f From: Brooks Davis Date: Wed, 28 Aug 2019 07:43:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r351565 - in stable/12/sys: amd64/linux amd64/linux32 arm64/linux compat/freebsd32 i386/ibcs2 i386/linux kern sys X-SVN-Group: stable-12 X-SVN-Commit-Author: brooks X-SVN-Commit-Paths: in stable/12/sys: amd64/linux amd64/linux32 arm64/linux compat/freebsd32 i386/ibcs2 i386/linux kern sys X-SVN-Commit-Revision: 351565 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-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Aug 2019 07:43:39 -0000 Author: brooks Date: Wed Aug 28 07:43:31 2019 New Revision: 351565 URL: https://svnweb.freebsd.org/changeset/base/351565 Log: Regenerate to add @generated tag in generated files. This is a manual merge of r347230. Modified: stable/12/sys/amd64/linux/linux_proto.h stable/12/sys/amd64/linux/linux_syscall.h stable/12/sys/amd64/linux/linux_syscalls.c stable/12/sys/amd64/linux/linux_sysent.c stable/12/sys/amd64/linux/linux_systrace_args.c stable/12/sys/amd64/linux32/linux32_proto.h stable/12/sys/amd64/linux32/linux32_syscall.h stable/12/sys/amd64/linux32/linux32_syscalls.c stable/12/sys/amd64/linux32/linux32_sysent.c stable/12/sys/amd64/linux32/linux32_systrace_args.c stable/12/sys/arm64/linux/linux_proto.h stable/12/sys/arm64/linux/linux_syscall.h stable/12/sys/arm64/linux/linux_syscalls.c stable/12/sys/arm64/linux/linux_sysent.c stable/12/sys/arm64/linux/linux_systrace_args.c stable/12/sys/compat/freebsd32/freebsd32_proto.h stable/12/sys/compat/freebsd32/freebsd32_syscall.h stable/12/sys/compat/freebsd32/freebsd32_syscalls.c stable/12/sys/compat/freebsd32/freebsd32_sysent.c stable/12/sys/compat/freebsd32/freebsd32_systrace_args.c stable/12/sys/i386/ibcs2/ibcs2_proto.h stable/12/sys/i386/ibcs2/ibcs2_syscall.h stable/12/sys/i386/ibcs2/ibcs2_sysent.c stable/12/sys/i386/linux/linux_proto.h stable/12/sys/i386/linux/linux_syscall.h stable/12/sys/i386/linux/linux_syscalls.c stable/12/sys/i386/linux/linux_sysent.c stable/12/sys/i386/linux/linux_systrace_args.c stable/12/sys/kern/init_sysent.c stable/12/sys/kern/syscalls.c stable/12/sys/kern/systrace_args.c stable/12/sys/sys/syscall.h stable/12/sys/sys/syscall.mk stable/12/sys/sys/sysproto.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/amd64/linux/linux_proto.h ============================================================================== --- stable/12/sys/amd64/linux/linux_proto.h Wed Aug 28 07:37:34 2019 (r351564) +++ stable/12/sys/amd64/linux/linux_proto.h Wed Aug 28 07:43:31 2019 (r351565) @@ -1,7 +1,7 @@ /* * System call prototypes. * - * DO NOT EDIT-- this file is automatically generated. + * DO NOT EDIT-- this file is automatically @generated. * $FreeBSD$ */ Modified: stable/12/sys/amd64/linux/linux_syscall.h ============================================================================== --- stable/12/sys/amd64/linux/linux_syscall.h Wed Aug 28 07:37:34 2019 (r351564) +++ stable/12/sys/amd64/linux/linux_syscall.h Wed Aug 28 07:43:31 2019 (r351565) @@ -1,7 +1,7 @@ /* * System call numbers. * - * DO NOT EDIT-- this file is automatically generated. + * DO NOT EDIT-- this file is automatically @generated. * $FreeBSD$ */ Modified: stable/12/sys/amd64/linux/linux_syscalls.c ============================================================================== --- stable/12/sys/amd64/linux/linux_syscalls.c Wed Aug 28 07:37:34 2019 (r351564) +++ stable/12/sys/amd64/linux/linux_syscalls.c Wed Aug 28 07:43:31 2019 (r351565) @@ -1,7 +1,7 @@ /* * System call names. * - * DO NOT EDIT-- this file is automatically generated. + * DO NOT EDIT-- this file is automatically @generated. * $FreeBSD$ */ Modified: stable/12/sys/amd64/linux/linux_sysent.c ============================================================================== --- stable/12/sys/amd64/linux/linux_sysent.c Wed Aug 28 07:37:34 2019 (r351564) +++ stable/12/sys/amd64/linux/linux_sysent.c Wed Aug 28 07:43:31 2019 (r351565) @@ -1,7 +1,7 @@ /* * System call switch table. * - * DO NOT EDIT-- this file is automatically generated. + * DO NOT EDIT-- this file is automatically @generated. * $FreeBSD$ */ Modified: stable/12/sys/amd64/linux/linux_systrace_args.c ============================================================================== --- stable/12/sys/amd64/linux/linux_systrace_args.c Wed Aug 28 07:37:34 2019 (r351564) +++ stable/12/sys/amd64/linux/linux_systrace_args.c Wed Aug 28 07:43:31 2019 (r351565) @@ -1,7 +1,7 @@ /* * System call argument to DTrace register array converstion. * - * DO NOT EDIT-- this file is automatically generated. + * DO NOT EDIT-- this file is automatically @generated. * $FreeBSD$ * This file is part of the DTrace syscall provider. */ Modified: stable/12/sys/amd64/linux32/linux32_proto.h ============================================================================== --- stable/12/sys/amd64/linux32/linux32_proto.h Wed Aug 28 07:37:34 2019 (r351564) +++ stable/12/sys/amd64/linux32/linux32_proto.h Wed Aug 28 07:43:31 2019 (r351565) @@ -1,7 +1,7 @@ /* * System call prototypes. * - * DO NOT EDIT-- this file is automatically generated. + * DO NOT EDIT-- this file is automatically @generated. * $FreeBSD$ */ Modified: stable/12/sys/amd64/linux32/linux32_syscall.h ============================================================================== --- stable/12/sys/amd64/linux32/linux32_syscall.h Wed Aug 28 07:37:34 2019 (r351564) +++ stable/12/sys/amd64/linux32/linux32_syscall.h Wed Aug 28 07:43:31 2019 (r351565) @@ -1,7 +1,7 @@ /* * System call numbers. * - * DO NOT EDIT-- this file is automatically generated. + * DO NOT EDIT-- this file is automatically @generated. * $FreeBSD$ */ Modified: stable/12/sys/amd64/linux32/linux32_syscalls.c ============================================================================== --- stable/12/sys/amd64/linux32/linux32_syscalls.c Wed Aug 28 07:37:34 2019 (r351564) +++ stable/12/sys/amd64/linux32/linux32_syscalls.c Wed Aug 28 07:43:31 2019 (r351565) @@ -1,7 +1,7 @@ /* * System call names. * - * DO NOT EDIT-- this file is automatically generated. + * DO NOT EDIT-- this file is automatically @generated. * $FreeBSD$ */ Modified: stable/12/sys/amd64/linux32/linux32_sysent.c ============================================================================== --- stable/12/sys/amd64/linux32/linux32_sysent.c Wed Aug 28 07:37:34 2019 (r351564) +++ stable/12/sys/amd64/linux32/linux32_sysent.c Wed Aug 28 07:43:31 2019 (r351565) @@ -1,7 +1,7 @@ /* * System call switch table. * - * DO NOT EDIT-- this file is automatically generated. + * DO NOT EDIT-- this file is automatically @generated. * $FreeBSD$ */ Modified: stable/12/sys/amd64/linux32/linux32_systrace_args.c ============================================================================== --- stable/12/sys/amd64/linux32/linux32_systrace_args.c Wed Aug 28 07:37:34 2019 (r351564) +++ stable/12/sys/amd64/linux32/linux32_systrace_args.c Wed Aug 28 07:43:31 2019 (r351565) @@ -1,7 +1,7 @@ /* * System call argument to DTrace register array converstion. * - * DO NOT EDIT-- this file is automatically generated. + * DO NOT EDIT-- this file is automatically @generated. * $FreeBSD$ * This file is part of the DTrace syscall provider. */ Modified: stable/12/sys/arm64/linux/linux_proto.h ============================================================================== --- stable/12/sys/arm64/linux/linux_proto.h Wed Aug 28 07:37:34 2019 (r351564) +++ stable/12/sys/arm64/linux/linux_proto.h Wed Aug 28 07:43:31 2019 (r351565) @@ -1,7 +1,7 @@ /* * System call prototypes. * - * DO NOT EDIT-- this file is automatically generated. + * DO NOT EDIT-- this file is automatically @generated. * $FreeBSD$ */ Modified: stable/12/sys/arm64/linux/linux_syscall.h ============================================================================== --- stable/12/sys/arm64/linux/linux_syscall.h Wed Aug 28 07:37:34 2019 (r351564) +++ stable/12/sys/arm64/linux/linux_syscall.h Wed Aug 28 07:43:31 2019 (r351565) @@ -1,7 +1,7 @@ /* * System call numbers. * - * DO NOT EDIT-- this file is automatically generated. + * DO NOT EDIT-- this file is automatically @generated. * $FreeBSD$ */ Modified: stable/12/sys/arm64/linux/linux_syscalls.c ============================================================================== --- stable/12/sys/arm64/linux/linux_syscalls.c Wed Aug 28 07:37:34 2019 (r351564) +++ stable/12/sys/arm64/linux/linux_syscalls.c Wed Aug 28 07:43:31 2019 (r351565) @@ -1,7 +1,7 @@ /* * System call names. * - * DO NOT EDIT-- this file is automatically generated. + * DO NOT EDIT-- this file is automatically @generated. * $FreeBSD$ */ Modified: stable/12/sys/arm64/linux/linux_sysent.c ============================================================================== --- stable/12/sys/arm64/linux/linux_sysent.c Wed Aug 28 07:37:34 2019 (r351564) +++ stable/12/sys/arm64/linux/linux_sysent.c Wed Aug 28 07:43:31 2019 (r351565) @@ -1,7 +1,7 @@ /* * System call switch table. * - * DO NOT EDIT-- this file is automatically generated. + * DO NOT EDIT-- this file is automatically @generated. * $FreeBSD$ */ Modified: stable/12/sys/arm64/linux/linux_systrace_args.c ============================================================================== --- stable/12/sys/arm64/linux/linux_systrace_args.c Wed Aug 28 07:37:34 2019 (r351564) +++ stable/12/sys/arm64/linux/linux_systrace_args.c Wed Aug 28 07:43:31 2019 (r351565) @@ -1,7 +1,7 @@ /* * System call argument to DTrace register array converstion. * - * DO NOT EDIT-- this file is automatically generated. + * DO NOT EDIT-- this file is automatically @generated. * $FreeBSD$ * This file is part of the DTrace syscall provider. */ Modified: stable/12/sys/compat/freebsd32/freebsd32_proto.h ============================================================================== --- stable/12/sys/compat/freebsd32/freebsd32_proto.h Wed Aug 28 07:37:34 2019 (r351564) +++ stable/12/sys/compat/freebsd32/freebsd32_proto.h Wed Aug 28 07:43:31 2019 (r351565) @@ -1,7 +1,7 @@ /* * System call prototypes. * - * DO NOT EDIT-- this file is automatically generated. + * DO NOT EDIT-- this file is automatically @generated. * $FreeBSD$ */ Modified: stable/12/sys/compat/freebsd32/freebsd32_syscall.h ============================================================================== --- stable/12/sys/compat/freebsd32/freebsd32_syscall.h Wed Aug 28 07:37:34 2019 (r351564) +++ stable/12/sys/compat/freebsd32/freebsd32_syscall.h Wed Aug 28 07:43:31 2019 (r351565) @@ -1,7 +1,7 @@ /* * System call numbers. * - * DO NOT EDIT-- this file is automatically generated. + * DO NOT EDIT-- this file is automatically @generated. * $FreeBSD$ */ Modified: stable/12/sys/compat/freebsd32/freebsd32_syscalls.c ============================================================================== --- stable/12/sys/compat/freebsd32/freebsd32_syscalls.c Wed Aug 28 07:37:34 2019 (r351564) +++ stable/12/sys/compat/freebsd32/freebsd32_syscalls.c Wed Aug 28 07:43:31 2019 (r351565) @@ -1,7 +1,7 @@ /* * System call names. * - * DO NOT EDIT-- this file is automatically generated. + * DO NOT EDIT-- this file is automatically @generated. * $FreeBSD$ */ Modified: stable/12/sys/compat/freebsd32/freebsd32_sysent.c ============================================================================== --- stable/12/sys/compat/freebsd32/freebsd32_sysent.c Wed Aug 28 07:37:34 2019 (r351564) +++ stable/12/sys/compat/freebsd32/freebsd32_sysent.c Wed Aug 28 07:43:31 2019 (r351565) @@ -1,7 +1,7 @@ /* * System call switch table. * - * DO NOT EDIT-- this file is automatically generated. + * DO NOT EDIT-- this file is automatically @generated. * $FreeBSD$ */ Modified: stable/12/sys/compat/freebsd32/freebsd32_systrace_args.c ============================================================================== --- stable/12/sys/compat/freebsd32/freebsd32_systrace_args.c Wed Aug 28 07:37:34 2019 (r351564) +++ stable/12/sys/compat/freebsd32/freebsd32_systrace_args.c Wed Aug 28 07:43:31 2019 (r351565) @@ -1,7 +1,7 @@ /* * System call argument to DTrace register array converstion. * - * DO NOT EDIT-- this file is automatically generated. + * DO NOT EDIT-- this file is automatically @generated. * $FreeBSD$ * This file is part of the DTrace syscall provider. */ Modified: stable/12/sys/i386/ibcs2/ibcs2_proto.h ============================================================================== --- stable/12/sys/i386/ibcs2/ibcs2_proto.h Wed Aug 28 07:37:34 2019 (r351564) +++ stable/12/sys/i386/ibcs2/ibcs2_proto.h Wed Aug 28 07:43:31 2019 (r351565) @@ -1,7 +1,7 @@ /* * System call prototypes. * - * DO NOT EDIT-- this file is automatically generated. + * DO NOT EDIT-- this file is automatically @generated. * $FreeBSD$ */ Modified: stable/12/sys/i386/ibcs2/ibcs2_syscall.h ============================================================================== --- stable/12/sys/i386/ibcs2/ibcs2_syscall.h Wed Aug 28 07:37:34 2019 (r351564) +++ stable/12/sys/i386/ibcs2/ibcs2_syscall.h Wed Aug 28 07:43:31 2019 (r351565) @@ -1,7 +1,7 @@ /* * System call numbers. * - * DO NOT EDIT-- this file is automatically generated. + * DO NOT EDIT-- this file is automatically @generated. * $FreeBSD$ */ Modified: stable/12/sys/i386/ibcs2/ibcs2_sysent.c ============================================================================== --- stable/12/sys/i386/ibcs2/ibcs2_sysent.c Wed Aug 28 07:37:34 2019 (r351564) +++ stable/12/sys/i386/ibcs2/ibcs2_sysent.c Wed Aug 28 07:43:31 2019 (r351565) @@ -1,7 +1,7 @@ /* * System call switch table. * - * DO NOT EDIT-- this file is automatically generated. + * DO NOT EDIT-- this file is automatically @generated. * $FreeBSD$ */ Modified: stable/12/sys/i386/linux/linux_proto.h ============================================================================== --- stable/12/sys/i386/linux/linux_proto.h Wed Aug 28 07:37:34 2019 (r351564) +++ stable/12/sys/i386/linux/linux_proto.h Wed Aug 28 07:43:31 2019 (r351565) @@ -1,7 +1,7 @@ /* * System call prototypes. * - * DO NOT EDIT-- this file is automatically generated. + * DO NOT EDIT-- this file is automatically @generated. * $FreeBSD$ */ Modified: stable/12/sys/i386/linux/linux_syscall.h ============================================================================== --- stable/12/sys/i386/linux/linux_syscall.h Wed Aug 28 07:37:34 2019 (r351564) +++ stable/12/sys/i386/linux/linux_syscall.h Wed Aug 28 07:43:31 2019 (r351565) @@ -1,7 +1,7 @@ /* * System call numbers. * - * DO NOT EDIT-- this file is automatically generated. + * DO NOT EDIT-- this file is automatically @generated. * $FreeBSD$ */ Modified: stable/12/sys/i386/linux/linux_syscalls.c ============================================================================== --- stable/12/sys/i386/linux/linux_syscalls.c Wed Aug 28 07:37:34 2019 (r351564) +++ stable/12/sys/i386/linux/linux_syscalls.c Wed Aug 28 07:43:31 2019 (r351565) @@ -1,7 +1,7 @@ /* * System call names. * - * DO NOT EDIT-- this file is automatically generated. + * DO NOT EDIT-- this file is automatically @generated. * $FreeBSD$ */ Modified: stable/12/sys/i386/linux/linux_sysent.c ============================================================================== --- stable/12/sys/i386/linux/linux_sysent.c Wed Aug 28 07:37:34 2019 (r351564) +++ stable/12/sys/i386/linux/linux_sysent.c Wed Aug 28 07:43:31 2019 (r351565) @@ -1,7 +1,7 @@ /* * System call switch table. * - * DO NOT EDIT-- this file is automatically generated. + * DO NOT EDIT-- this file is automatically @generated. * $FreeBSD$ */ Modified: stable/12/sys/i386/linux/linux_systrace_args.c ============================================================================== --- stable/12/sys/i386/linux/linux_systrace_args.c Wed Aug 28 07:37:34 2019 (r351564) +++ stable/12/sys/i386/linux/linux_systrace_args.c Wed Aug 28 07:43:31 2019 (r351565) @@ -1,7 +1,7 @@ /* * System call argument to DTrace register array converstion. * - * DO NOT EDIT-- this file is automatically generated. + * DO NOT EDIT-- this file is automatically @generated. * $FreeBSD$ * This file is part of the DTrace syscall provider. */ Modified: stable/12/sys/kern/init_sysent.c ============================================================================== --- stable/12/sys/kern/init_sysent.c Wed Aug 28 07:37:34 2019 (r351564) +++ stable/12/sys/kern/init_sysent.c Wed Aug 28 07:43:31 2019 (r351565) @@ -1,7 +1,7 @@ /* * System call switch table. * - * DO NOT EDIT-- this file is automatically generated. + * DO NOT EDIT-- this file is automatically @generated. * $FreeBSD$ */ Modified: stable/12/sys/kern/syscalls.c ============================================================================== --- stable/12/sys/kern/syscalls.c Wed Aug 28 07:37:34 2019 (r351564) +++ stable/12/sys/kern/syscalls.c Wed Aug 28 07:43:31 2019 (r351565) @@ -1,7 +1,7 @@ /* * System call names. * - * DO NOT EDIT-- this file is automatically generated. + * DO NOT EDIT-- this file is automatically @generated. * $FreeBSD$ */ Modified: stable/12/sys/kern/systrace_args.c ============================================================================== --- stable/12/sys/kern/systrace_args.c Wed Aug 28 07:37:34 2019 (r351564) +++ stable/12/sys/kern/systrace_args.c Wed Aug 28 07:43:31 2019 (r351565) @@ -1,7 +1,7 @@ /* * System call argument to DTrace register array converstion. * - * DO NOT EDIT-- this file is automatically generated. + * DO NOT EDIT-- this file is automatically @generated. * $FreeBSD$ * This file is part of the DTrace syscall provider. */ Modified: stable/12/sys/sys/syscall.h ============================================================================== --- stable/12/sys/sys/syscall.h Wed Aug 28 07:37:34 2019 (r351564) +++ stable/12/sys/sys/syscall.h Wed Aug 28 07:43:31 2019 (r351565) @@ -1,7 +1,7 @@ /* * System call numbers. * - * DO NOT EDIT-- this file is automatically generated. + * DO NOT EDIT-- this file is automatically @generated. * $FreeBSD$ */ Modified: stable/12/sys/sys/syscall.mk ============================================================================== --- stable/12/sys/sys/syscall.mk Wed Aug 28 07:37:34 2019 (r351564) +++ stable/12/sys/sys/syscall.mk Wed Aug 28 07:43:31 2019 (r351565) @@ -1,5 +1,5 @@ # FreeBSD system call object files. -# DO NOT EDIT-- this file is automatically generated. +# DO NOT EDIT-- this file is automatically @generated. # $FreeBSD$ MIASM = \ syscall.o \ Modified: stable/12/sys/sys/sysproto.h ============================================================================== --- stable/12/sys/sys/sysproto.h Wed Aug 28 07:37:34 2019 (r351564) +++ stable/12/sys/sys/sysproto.h Wed Aug 28 07:43:31 2019 (r351565) @@ -1,7 +1,7 @@ /* * System call prototypes. * - * DO NOT EDIT-- this file is automatically generated. + * DO NOT EDIT-- this file is automatically @generated. * $FreeBSD$ */ From owner-svn-src-stable-12@freebsd.org Wed Aug 28 07:53:11 2019 Return-Path: Delivered-To: svn-src-stable-12@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 D9F77D45CE; Wed, 28 Aug 2019 07:53:11 +0000 (UTC) (envelope-from brooks@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 46JHzW5BpKz3Nyd; Wed, 28 Aug 2019 07:53:11 +0000 (UTC) (envelope-from brooks@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 9374942FD; Wed, 28 Aug 2019 07:53:11 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x7S7rBg9024836; Wed, 28 Aug 2019 07:53:11 GMT (envelope-from brooks@FreeBSD.org) Received: (from brooks@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7S7rB29024833; Wed, 28 Aug 2019 07:53:11 GMT (envelope-from brooks@FreeBSD.org) Message-Id: <201908280753.x7S7rB29024833@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: brooks set sender to brooks@FreeBSD.org using -f From: Brooks Davis Date: Wed, 28 Aug 2019 07:53:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r351566 - in stable/12/sys: compat/freebsd32 kern X-SVN-Group: stable-12 X-SVN-Commit-Author: brooks X-SVN-Commit-Paths: in stable/12/sys: compat/freebsd32 kern X-SVN-Commit-Revision: 351566 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-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Aug 2019 07:53:11 -0000 Author: brooks Date: Wed Aug 28 07:53:10 2019 New Revision: 351566 URL: https://svnweb.freebsd.org/changeset/base/351566 Log: MFC r340424: Use the main capabilities.conf for freebsd32. Allow the location of capabilities.conf to be configured. Also allow a per-abi syscall prefix to be configured with the abi_func_prefix syscalls.conf variable and check syscalls against entries in capabilities.conf with and without the prefix amended. Take advantage of these two features to allow use shared capabilities.conf between the default syscall vector and the freebsd32 compatability layer. We've been inconsistent about keeping the two in sync as evidenced by the bugs fixed in r340294. This eliminates that problem going forward. Reviewed by: kib Obtained from: CheriBSD Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D17932 Deleted: stable/12/sys/compat/freebsd32/capabilities.conf Modified: stable/12/sys/compat/freebsd32/Makefile stable/12/sys/compat/freebsd32/syscalls.conf stable/12/sys/kern/makesyscalls.sh Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/compat/freebsd32/Makefile ============================================================================== --- stable/12/sys/compat/freebsd32/Makefile Wed Aug 28 07:43:31 2019 (r351565) +++ stable/12/sys/compat/freebsd32/Makefile Wed Aug 28 07:53:10 2019 (r351566) @@ -11,7 +11,7 @@ all: sysent: freebsd32_sysent.c freebsd32_syscall.h freebsd32_proto.h freebsd32_systrace_args.c freebsd32_sysent.c freebsd32_syscalls.c freebsd32_syscall.h freebsd32_proto.h freebsd32_systrace_args.c : \ - ../../kern/makesyscalls.sh syscalls.master syscalls.conf capabilities.conf + ../../kern/makesyscalls.sh syscalls.master syscalls.conf ../../kern/capabilities.conf sh ../../kern/makesyscalls.sh syscalls.master syscalls.conf clean: Modified: stable/12/sys/compat/freebsd32/syscalls.conf ============================================================================== --- stable/12/sys/compat/freebsd32/syscalls.conf Wed Aug 28 07:43:31 2019 (r351565) +++ stable/12/sys/compat/freebsd32/syscalls.conf Wed Aug 28 07:53:10 2019 (r351566) @@ -9,3 +9,5 @@ syscallprefix="FREEBSD32_SYS_" switchname="freebsd32_sysent" namesname="freebsd32_syscallnames" systrace="freebsd32_systrace_args.c" +abi_func_prefix="freebsd32_" +capabilities_conf="../../kern/capabilities.conf" Modified: stable/12/sys/kern/makesyscalls.sh ============================================================================== --- stable/12/sys/kern/makesyscalls.sh Wed Aug 28 07:43:31 2019 (r351565) +++ stable/12/sys/kern/makesyscalls.sh Wed Aug 28 07:53:10 2019 (r351566) @@ -45,14 +45,8 @@ sysarg="sysarg.switch.$$" sysprotoend="sysprotoend.$$" systracetmp="systrace.$$" systraceret="systraceret.$$" +capabilities_conf="capabilities.conf" -if [ -r capabilities.conf ]; then - capenabled=`egrep -v '^#|^$' capabilities.conf` - capenabled=`echo $capenabled | sed 's/ /,/g'` -else - capenabled="" -fi - trap "rm $sysaue $sysdcl $syscompat $syscompatdcl $syscompat4 $syscompat4dcl $syscompat6 $syscompat6dcl $syscompat7 $syscompat7dcl $syscompat10 $syscompat10dcl $syscompat11 $syscompat11dcl $sysent $sysinc $sysarg $sysprotoend $systracetmp $systraceret" 0 touch $sysaue $sysdcl $syscompat $syscompatdcl $syscompat4 $syscompat4dcl $syscompat6 $syscompat6dcl $syscompat7 $syscompat7dcl $syscompat10 $syscompat10dcl $syscompat11 $syscompat11dcl $sysent $sysinc $sysarg $sysprotoend $systracetmp $systraceret @@ -67,6 +61,13 @@ if [ -n "$2" ]; then . $2 fi +if [ -r $capabilities_conf ]; then + capenabled=`egrep -v '^#|^$' $capabilities_conf` + capenabled=`echo $capenabled | sed 's/ /,/g'` +else + capenabled="" +fi + sed -e ' # FreeBSD ID, includes, comments, and blank lines /.*\$FreeBSD/b done_joining @@ -137,6 +138,7 @@ sed -e ' switchname = \"$switchname\" namesname = \"$namesname\" infile = \"$1\" + abi_func_prefix = \"$abi_func_prefix\" capenabled_string = \"$capenabled\" "' @@ -375,7 +377,8 @@ sed -e ' # from it. # for (cap in capenabled) { - if (funcname == capenabled[cap]) { + if (funcname == capenabled[cap] || + funcname == abi_func_prefix capenabled[cap]) { flags = "SYF_CAPENABLED"; break; } From owner-svn-src-stable-12@freebsd.org Wed Aug 28 08:05:18 2019 Return-Path: Delivered-To: svn-src-stable-12@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 96411D5272; Wed, 28 Aug 2019 08:05:18 +0000 (UTC) (envelope-from brooks@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 46JJFV3K4Bz3PXg; Wed, 28 Aug 2019 08:05:18 +0000 (UTC) (envelope-from brooks@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 5012844D5; Wed, 28 Aug 2019 08:05:18 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x7S85IcC030853; Wed, 28 Aug 2019 08:05:18 GMT (envelope-from brooks@FreeBSD.org) Received: (from brooks@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7S85Gii030846; Wed, 28 Aug 2019 08:05:16 GMT (envelope-from brooks@FreeBSD.org) Message-Id: <201908280805.x7S85Gii030846@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: brooks set sender to brooks@FreeBSD.org using -f From: Brooks Davis Date: Wed, 28 Aug 2019 08:05:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r351567 - in stable/12/sys: amd64/linux amd64/linux32 arm64/linux compat/cloudabi32 compat/cloudabi64 compat/freebsd32 i386/linux kern X-SVN-Group: stable-12 X-SVN-Commit-Author: brooks X-SVN-Commit-Paths: in stable/12/sys: amd64/linux amd64/linux32 arm64/linux compat/cloudabi32 compat/cloudabi64 compat/freebsd32 i386/linux kern X-SVN-Commit-Revision: 351567 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-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Aug 2019 08:05:18 -0000 Author: brooks Date: Wed Aug 28 08:05:16 2019 New Revision: 351567 URL: https://svnweb.freebsd.org/changeset/base/351567 Log: MFC r348446: makesyscalls.sh: always use absolute path for syscalls.conf syscalls.conf is included using "." which per the Open Group: If file does not contain a , the shell shall use the search path specified by PATH to find the directory containing file. POSIX shells don't fall back to the current working directory. Submitted by: Nathaniel Wesley Filardo Reviewed by: bdrewery Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D20476 Modified: stable/12/sys/amd64/linux/Makefile stable/12/sys/amd64/linux32/Makefile stable/12/sys/arm64/linux/Makefile stable/12/sys/compat/cloudabi32/Makefile stable/12/sys/compat/cloudabi64/Makefile stable/12/sys/compat/freebsd32/Makefile stable/12/sys/i386/linux/Makefile stable/12/sys/kern/makesyscalls.sh Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/amd64/linux/Makefile ============================================================================== --- stable/12/sys/amd64/linux/Makefile Wed Aug 28 07:53:10 2019 (r351566) +++ stable/12/sys/amd64/linux/Makefile Wed Aug 28 08:05:16 2019 (r351567) @@ -11,5 +11,5 @@ all: sysent: linux_sysent.c linux_syscall.h linux_proto.h linux_syscalls.c linux_systrace_args.c linux_sysent.c linux_syscall.h linux_proto.h linux_syscalls.c linux_systrace_args.c: \ - ../../kern/makesyscalls.sh syscalls.master syscalls.conf - sh ../../kern/makesyscalls.sh syscalls.master syscalls.conf + ../../kern/makesyscalls.sh syscalls.master ${.CURDIR}/syscalls.conf + sh ../../kern/makesyscalls.sh syscalls.master ${.CURDIR}/syscalls.conf Modified: stable/12/sys/amd64/linux32/Makefile ============================================================================== --- stable/12/sys/amd64/linux32/Makefile Wed Aug 28 07:53:10 2019 (r351566) +++ stable/12/sys/amd64/linux32/Makefile Wed Aug 28 08:05:16 2019 (r351567) @@ -11,5 +11,5 @@ all: sysent: linux32_sysent.c linux32_syscall.h linux32_proto.h linux32_syscalls.c linux32_systrace_args.c linux32_sysent.c linux32_syscall.h linux32_proto.h linux32_syscalls.c linux32_systrace_args.c: ../../kern/makesyscalls.sh \ - syscalls.master syscalls.conf - sh ../../kern/makesyscalls.sh syscalls.master syscalls.conf + syscalls.master ${.CURDIR}/syscalls.conf + sh ../../kern/makesyscalls.sh syscalls.master ${.CURDIR}/syscalls.conf Modified: stable/12/sys/arm64/linux/Makefile ============================================================================== --- stable/12/sys/arm64/linux/Makefile Wed Aug 28 07:53:10 2019 (r351566) +++ stable/12/sys/arm64/linux/Makefile Wed Aug 28 08:05:16 2019 (r351567) @@ -11,5 +11,5 @@ all: sysent: linux_sysent.c linux_syscall.h linux_proto.h linux_syscalls.c linux_systrace_args.c linux_sysent.c linux_syscall.h linux_proto.h linux_syscalls.c linux_systrace_args.c: \ - ../../kern/makesyscalls.sh syscalls.master syscalls.conf - sh ../../kern/makesyscalls.sh syscalls.master syscalls.conf + ../../kern/makesyscalls.sh syscalls.master ${.CURDIR}/syscalls.conf + sh ../../kern/makesyscalls.sh syscalls.master ${.CURDIR}/syscalls.conf Modified: stable/12/sys/compat/cloudabi32/Makefile ============================================================================== --- stable/12/sys/compat/cloudabi32/Makefile Wed Aug 28 07:53:10 2019 (r351566) +++ stable/12/sys/compat/cloudabi32/Makefile Wed Aug 28 08:05:16 2019 (r351567) @@ -12,6 +12,6 @@ sysent: cloudabi32_sysent.c cloudabi32_syscall.h cloud cloudabi32_sysent.c cloudabi32_syscall.h cloudabi32_proto.h \ cloudabi32_syscalls.c cloudabi32_systrace_args.c: \ ../../kern/makesyscalls.sh ../../contrib/cloudabi/syscalls32.master \ - syscalls.conf + ${.CURDIR}/syscalls.conf sh ../../kern/makesyscalls.sh ../../contrib/cloudabi/syscalls32.master \ - syscalls.conf + ${.CURDIR}/syscalls.conf Modified: stable/12/sys/compat/cloudabi64/Makefile ============================================================================== --- stable/12/sys/compat/cloudabi64/Makefile Wed Aug 28 07:53:10 2019 (r351566) +++ stable/12/sys/compat/cloudabi64/Makefile Wed Aug 28 08:05:16 2019 (r351567) @@ -12,6 +12,6 @@ sysent: cloudabi64_sysent.c cloudabi64_syscall.h cloud cloudabi64_sysent.c cloudabi64_syscall.h cloudabi64_proto.h \ cloudabi64_syscalls.c cloudabi64_systrace_args.c: \ ../../kern/makesyscalls.sh ../../contrib/cloudabi/syscalls64.master \ - syscalls.conf + ${.CURDIR}/syscalls.conf sh ../../kern/makesyscalls.sh ../../contrib/cloudabi/syscalls64.master \ - syscalls.conf + ${.CURDIR}/syscalls.conf Modified: stable/12/sys/compat/freebsd32/Makefile ============================================================================== --- stable/12/sys/compat/freebsd32/Makefile Wed Aug 28 07:53:10 2019 (r351566) +++ stable/12/sys/compat/freebsd32/Makefile Wed Aug 28 08:05:16 2019 (r351567) @@ -11,8 +11,8 @@ all: sysent: freebsd32_sysent.c freebsd32_syscall.h freebsd32_proto.h freebsd32_systrace_args.c freebsd32_sysent.c freebsd32_syscalls.c freebsd32_syscall.h freebsd32_proto.h freebsd32_systrace_args.c : \ - ../../kern/makesyscalls.sh syscalls.master syscalls.conf ../../kern/capabilities.conf - sh ../../kern/makesyscalls.sh syscalls.master syscalls.conf + ../../kern/makesyscalls.sh syscalls.master ${.CURDIR}/syscalls.conf ../../kern/capabilities.conf + sh ../../kern/makesyscalls.sh syscalls.master ${.CURDIR}/syscalls.conf clean: rm -f freebsd32_sysent.c freebsd32_syscalls.c freebsd32_syscall.h freebsd32_proto.h Modified: stable/12/sys/i386/linux/Makefile ============================================================================== --- stable/12/sys/i386/linux/Makefile Wed Aug 28 07:53:10 2019 (r351566) +++ stable/12/sys/i386/linux/Makefile Wed Aug 28 08:05:16 2019 (r351567) @@ -11,5 +11,5 @@ all: sysent: linux_sysent.c linux_syscall.h linux_proto.h linux_syscalls.c linux_systrace_args.c linux_sysent.c linux_syscall.h linux_proto.h linux_syscalls.c linux_systrace_args.c: \ - ../../kern/makesyscalls.sh syscalls.master syscalls.conf - sh ../../kern/makesyscalls.sh syscalls.master syscalls.conf + ../../kern/makesyscalls.sh syscalls.master ${.CURDIR}/syscalls.conf + sh ../../kern/makesyscalls.sh syscalls.master ${.CURDIR}/syscalls.conf Modified: stable/12/sys/kern/makesyscalls.sh ============================================================================== --- stable/12/sys/kern/makesyscalls.sh Wed Aug 28 07:53:10 2019 (r351566) +++ stable/12/sys/kern/makesyscalls.sh Wed Aug 28 08:05:16 2019 (r351567) @@ -58,7 +58,7 @@ case $# in esac if [ -n "$2" ]; then - . $2 + . "$2" fi if [ -r $capabilities_conf ]; then From owner-svn-src-stable-12@freebsd.org Wed Aug 28 08:09:11 2019 Return-Path: Delivered-To: svn-src-stable-12@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 B59A1D5422; Wed, 28 Aug 2019 08:09:11 +0000 (UTC) (envelope-from brooks@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 46JJKz426Dz3Ppc; Wed, 28 Aug 2019 08:09:11 +0000 (UTC) (envelope-from brooks@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 6BD1944D8; Wed, 28 Aug 2019 08:09:11 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x7S89BRM031066; Wed, 28 Aug 2019 08:09:11 GMT (envelope-from brooks@FreeBSD.org) Received: (from brooks@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7S89BWL031065; Wed, 28 Aug 2019 08:09:11 GMT (envelope-from brooks@FreeBSD.org) Message-Id: <201908280809.x7S89BWL031065@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: brooks set sender to brooks@FreeBSD.org using -f From: Brooks Davis Date: Wed, 28 Aug 2019 08:09:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r351568 - stable/12/sys/kern X-SVN-Group: stable-12 X-SVN-Commit-Author: brooks X-SVN-Commit-Paths: stable/12/sys/kern X-SVN-Commit-Revision: 351568 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-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Aug 2019 08:09:11 -0000 Author: brooks Date: Wed Aug 28 08:09:10 2019 New Revision: 351568 URL: https://svnweb.freebsd.org/changeset/base/351568 Log: MFC r351389: Reorganise conditionals to reduce duplication. No functional change. Obtained from: CheriBSD Sponsored by: DARPA, AFRL Modified: stable/12/sys/kern/makesyscalls.sh Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/kern/makesyscalls.sh ============================================================================== --- stable/12/sys/kern/makesyscalls.sh Wed Aug 28 08:05:16 2019 (r351567) +++ stable/12/sys/kern/makesyscalls.sh Wed Aug 28 08:09:10 2019 (r351568) @@ -503,20 +503,20 @@ sed -e ' } printf("\t\t*n_args = %d;\n\t\tbreak;\n\t}\n", argc) > systrace printf("\t\tbreak;\n") > systracetmp - if (argc != 0 && !flag("NOARGS") && !flag("NOPROTO") && \ - !flag("NODEF")) { - printf("struct %s {\n", argalias) > sysarg - for (i = 1; i <= argc; i++) - printf("\tchar %s_l_[PADL_(%s)]; " \ - "%s %s; char %s_r_[PADR_(%s)];\n", - argname[i], argtype[i], - argtype[i], argname[i], - argname[i], argtype[i]) > sysarg - printf("};\n") > sysarg + if (!flag("NOARGS") && !flag("NOPROTO") && !flag("NODEF")) { + if (argc != 0) { + printf("struct %s {\n", argalias) > sysarg + for (i = 1; i <= argc; i++) + printf("\tchar %s_l_[PADL_(%s)]; " \ + "%s %s; char %s_r_[PADR_(%s)];\n", + argname[i], argtype[i], + argtype[i], argname[i], + argname[i], argtype[i]) > sysarg + printf("};\n") > sysarg + } else + printf("struct %s {\n\tregister_t dummy;\n};\n", + argalias) > sysarg } - else if (!flag("NOARGS") && !flag("NOPROTO") && !flag("NODEF")) - printf("struct %s {\n\tregister_t dummy;\n};\n", - argalias) > sysarg if (!flag("NOPROTO") && !flag("NODEF")) { if (funcname == "nosys" || funcname == "lkmnosys" || funcname == "sysarch" || funcname ~ /^freebsd/ || From owner-svn-src-stable-12@freebsd.org Wed Aug 28 16:16:15 2019 Return-Path: Delivered-To: svn-src-stable-12@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 7CF8FE07B3; Wed, 28 Aug 2019 16:16:15 +0000 (UTC) (envelope-from markj@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 46JW7z2knJz4NlR; Wed, 28 Aug 2019 16:16:15 +0000 (UTC) (envelope-from markj@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 3B59C9E47; Wed, 28 Aug 2019 16:16:15 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x7SGGE2P020595; Wed, 28 Aug 2019 16:16:14 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7SGGEmB020592; Wed, 28 Aug 2019 16:16:14 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201908281616.x7SGGEmB020592@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Wed, 28 Aug 2019 16:16:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r351570 - stable/12/sys/vm X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/12/sys/vm X-SVN-Commit-Revision: 351570 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-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Aug 2019 16:16:15 -0000 Author: markj Date: Wed Aug 28 16:16:14 2019 New Revision: 351570 URL: https://svnweb.freebsd.org/changeset/base/351570 Log: MFC r351333: Simplify vm_page_dequeue() and fix an assertion. Modified: stable/12/sys/vm/vm_page.c stable/12/sys/vm/vm_page.h stable/12/sys/vm/vm_pagequeue.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/vm/vm_page.c ============================================================================== --- stable/12/sys/vm/vm_page.c Wed Aug 28 16:08:06 2019 (r351569) +++ stable/12/sys/vm/vm_page.c Wed Aug 28 16:16:14 2019 (r351570) @@ -3079,21 +3079,15 @@ vm_waitpfault(struct domainset *dset) mtx_unlock(&vm_domainset_lock); } -struct vm_pagequeue * +static struct vm_pagequeue * vm_page_pagequeue(vm_page_t m) { - return (&vm_pagequeue_domain(m)->vmd_pagequeues[m->queue]); -} - -static struct mtx * -vm_page_pagequeue_lockptr(vm_page_t m) -{ uint8_t queue; if ((queue = atomic_load_8(&m->queue)) == PQ_NONE) return (NULL); - return (&vm_pagequeue_domain(m)->vmd_pagequeues[queue].pq_mutex); + return (&vm_pagequeue_domain(m)->vmd_pagequeues[queue]); } static inline void @@ -3116,10 +3110,8 @@ vm_pqbatch_process_page(struct vm_pagequeue *pq, vm_pa m, pq, qflags)); if ((qflags & PGA_DEQUEUE) != 0) { - if (__predict_true((qflags & PGA_ENQUEUED) != 0)) { - TAILQ_REMOVE(&pq->pq_pl, m, plinks.q); - vm_pagequeue_cnt_dec(pq); - } + if (__predict_true((qflags & PGA_ENQUEUED) != 0)) + vm_pagequeue_remove(pq, m); vm_page_dequeue_complete(m); } else if ((qflags & (PGA_REQUEUE | PGA_REQUEUE_HEAD)) != 0) { if ((qflags & PGA_ENQUEUED) != 0) @@ -3293,16 +3285,14 @@ vm_page_dequeue_deferred(vm_page_t m) void vm_page_dequeue(vm_page_t m) { - struct mtx *lock, *lock1; - struct vm_pagequeue *pq; + struct vm_pagequeue *pq, *pq1; uint8_t aflags; - KASSERT(mtx_owned(vm_page_lockptr(m)) || m->order == VM_NFREEORDER, + KASSERT(mtx_owned(vm_page_lockptr(m)) || m->object == NULL, ("page %p is allocated and unlocked", m)); - for (;;) { - lock = vm_page_pagequeue_lockptr(m); - if (lock == NULL) { + for (pq = vm_page_pagequeue(m);; pq = pq1) { + if (pq == NULL) { /* * A thread may be concurrently executing * vm_page_dequeue_complete(). Ensure that all queue @@ -3321,27 +3311,24 @@ vm_page_dequeue(vm_page_t m) * critical section. */ cpu_spinwait(); + pq1 = vm_page_pagequeue(m); continue; } - mtx_lock(lock); - if ((lock1 = vm_page_pagequeue_lockptr(m)) == lock) + vm_pagequeue_lock(pq); + if ((pq1 = vm_page_pagequeue(m)) == pq) break; - mtx_unlock(lock); - lock = lock1; + vm_pagequeue_unlock(pq); } - KASSERT(lock == vm_page_pagequeue_lockptr(m), + KASSERT(pq == vm_page_pagequeue(m), ("%s: page %p migrated directly between queues", __func__, m)); KASSERT((m->aflags & PGA_DEQUEUE) != 0 || mtx_owned(vm_page_lockptr(m)), ("%s: queued unlocked page %p", __func__, m)); - if ((m->aflags & PGA_ENQUEUED) != 0) { - pq = vm_page_pagequeue(m); - TAILQ_REMOVE(&pq->pq_pl, m, plinks.q); - vm_pagequeue_cnt_dec(pq); - } + if ((m->aflags & PGA_ENQUEUED) != 0) + vm_pagequeue_remove(pq, m); vm_page_dequeue_complete(m); - mtx_unlock(lock); + vm_pagequeue_unlock(pq); } /* Modified: stable/12/sys/vm/vm_page.h ============================================================================== --- stable/12/sys/vm/vm_page.h Wed Aug 28 16:08:06 2019 (r351569) +++ stable/12/sys/vm/vm_page.h Wed Aug 28 16:16:14 2019 (r351570) @@ -554,7 +554,6 @@ void vm_page_launder(vm_page_t m); vm_page_t vm_page_lookup (vm_object_t, vm_pindex_t); vm_page_t vm_page_next(vm_page_t m); int vm_page_pa_tryrelock(pmap_t, vm_paddr_t, vm_paddr_t *); -struct vm_pagequeue *vm_page_pagequeue(vm_page_t m); vm_page_t vm_page_prev(vm_page_t m); bool vm_page_ps_test(vm_page_t m, int flags, vm_page_t skip_m); void vm_page_putfake(vm_page_t m); Modified: stable/12/sys/vm/vm_pagequeue.h ============================================================================== --- stable/12/sys/vm/vm_pagequeue.h Wed Aug 28 16:08:06 2019 (r351569) +++ stable/12/sys/vm/vm_pagequeue.h Wed Aug 28 16:16:14 2019 (r351570) @@ -199,6 +199,14 @@ vm_pagequeue_cnt_add(struct vm_pagequeue *pq, int adde #define vm_pagequeue_cnt_dec(pq) vm_pagequeue_cnt_add((pq), -1) static inline void +vm_pagequeue_remove(struct vm_pagequeue *pq, vm_page_t m) +{ + + TAILQ_REMOVE(&pq->pq_pl, m, plinks.q); + vm_pagequeue_cnt_dec(pq); +} + +static inline void vm_batchqueue_init(struct vm_batchqueue *bq) { From owner-svn-src-stable-12@freebsd.org Wed Aug 28 16:16:36 2019 Return-Path: Delivered-To: svn-src-stable-12@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 04972E081D; Wed, 28 Aug 2019 16:16:36 +0000 (UTC) (envelope-from markj@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 46JW8M5qkqz4NsT; Wed, 28 Aug 2019 16:16:35 +0000 (UTC) (envelope-from markj@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 A98999E48; Wed, 28 Aug 2019 16:16:35 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x7SGGZoV020657; Wed, 28 Aug 2019 16:16:35 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7SGGZ0o020656; Wed, 28 Aug 2019 16:16:35 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201908281616.x7SGGZ0o020656@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Wed, 28 Aug 2019 16:16:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r351571 - stable/12/sys/vm X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/12/sys/vm X-SVN-Commit-Revision: 351571 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-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Aug 2019 16:16:36 -0000 Author: markj Date: Wed Aug 28 16:16:35 2019 New Revision: 351571 URL: https://svnweb.freebsd.org/changeset/base/351571 Log: MFC r351331: Don't requeue active pages in vm_swapout_object_deactivate_pages(). Modified: stable/12/sys/vm/vm_swapout.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/vm/vm_swapout.c ============================================================================== --- stable/12/sys/vm/vm_swapout.c Wed Aug 28 16:16:14 2019 (r351570) +++ stable/12/sys/vm/vm_swapout.c Wed Aug 28 16:16:35 2019 (r351571) @@ -227,20 +227,22 @@ vm_swapout_object_deactivate_pages(pmap_t pmap, vm_obj vm_page_activate(p); p->act_count += act_delta; } else if (vm_page_active(p)) { + /* + * The page daemon does not requeue pages + * after modifying their activation count. + */ if (act_delta == 0) { p->act_count -= min(p->act_count, ACT_DECLINE); if (!remove_mode && p->act_count == 0) { pmap_remove_all(p); vm_page_deactivate(p); - } else - vm_page_requeue(p); + } } else { vm_page_activate(p); if (p->act_count < ACT_MAX - ACT_ADVANCE) p->act_count += ACT_ADVANCE; - vm_page_requeue(p); } } else if (vm_page_inactive(p)) pmap_remove_all(p); From owner-svn-src-stable-12@freebsd.org Thu Aug 29 19:13:33 2019 Return-Path: Delivered-To: svn-src-stable-12@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 68D48DDED2; Thu, 29 Aug 2019 19:13:33 +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 46KC252wcWz45Ck; Thu, 29 Aug 2019 19:13:33 +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 45E5C247F2; Thu, 29 Aug 2019 19:13:33 +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 x7TJDXwM083999; Thu, 29 Aug 2019 19:13:33 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7TJDV5x083987; Thu, 29 Aug 2019 19:13:31 GMT (envelope-from cy@FreeBSD.org) Message-Id: <201908291913.x7TJDV5x083987@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Thu, 29 Aug 2019 19:13:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r351611 - in stable: 11/contrib/wpa/hostapd 11/contrib/wpa/hs20/client 11/contrib/wpa/src/ap 11/contrib/wpa/src/common 11/contrib/wpa/src/crypto 11/contrib/wpa/src/drivers 11/contrib/wp... X-SVN-Group: stable-12 X-SVN-Commit-Author: cy X-SVN-Commit-Paths: in stable: 11/contrib/wpa/hostapd 11/contrib/wpa/hs20/client 11/contrib/wpa/src/ap 11/contrib/wpa/src/common 11/contrib/wpa/src/crypto 11/contrib/wpa/src/drivers 11/contrib/wpa/src/eap_common 11/contr... X-SVN-Commit-Revision: 351611 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-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Aug 2019 19:13:33 -0000 Author: cy Date: Thu Aug 29 19:13:27 2019 New Revision: 351611 URL: https://svnweb.freebsd.org/changeset/base/351611 Log: MFC r351397: MFV r346563: Update wpa 2.8 --> 2.9 hostapd: * SAE changes - disable use of groups using Brainpool curves - improved protection against side channel attacks [https://w1.fi/security/2019-6/] * EAP-pwd changes - disable use of groups using Brainpool curves - improved protection against side channel attacks [https://w1.fi/security/2019-6/] * fixed FT-EAP initial mobility domain association using PMKSA caching * added configuration of airtime policy * fixed FILS to and RSNE into (Re)Association Response frames * fixed DPP bootstrapping URI parser of channel list * added support for regulatory WMM limitation (for ETSI) * added support for MACsec Key Agreement using IEEE 802.1X/PSK * added experimental support for EAP-TEAP server (RFC 7170) * added experimental support for EAP-TLS server with TLS v1.3 * added support for two server certificates/keys (RSA/ECC) * added AKMSuiteSelector into "STA " control interface data to determine with AKM was used for an association * added eap_sim_id parameter to allow EAP-SIM/AKA server pseudonym and fast reauthentication use to be disabled * fixed an ECDH operation corner case with OpenSSL wpa_supplicant: * SAE changes - disable use of groups using Brainpool curves - improved protection against side channel attacks [https://w1.fi/security/2019-6/] * EAP-pwd changes - disable use of groups using Brainpool curves - allow the set of groups to be configured (eap_pwd_groups) - improved protection against side channel attacks [https://w1.fi/security/2019-6/] * fixed FT-EAP initial mobility domain association using PMKSA caching (disabled by default for backwards compatibility; can be enabled with ft_eap_pmksa_caching=1) * fixed a regression in OpenSSL 1.1+ engine loading * added validation of RSNE in (Re)Association Response frames * fixed DPP bootstrapping URI parser of channel list * extended EAP-SIM/AKA fast re-authentication to allow use with FILS * extended ca_cert_blob to support PEM format * improved robustness of P2P Action frame scheduling * added support for EAP-SIM/AKA using anonymous@realm identity * fixed Hotspot 2.0 credential selection based on roaming consortium to ignore credentials without a specific EAP method * added experimental support for EAP-TEAP peer (RFC 7170) * added experimental support for EAP-TLS peer with TLS v1.3 * fixed a regression in WMM parameter configuration for a TDLS peer * fixed a regression in operation with drivers that offload 802.1X 4-way handshake * fixed an ECDH operation corner case with OpenSSL Security: https://w1.fi/security/2019-6/\ sae-eap-pwd-side-channel-attack-update.txt Added: stable/12/contrib/wpa/src/ap/airtime_policy.c - copied unchanged from r351397, head/contrib/wpa/src/ap/airtime_policy.c stable/12/contrib/wpa/src/ap/airtime_policy.h - copied unchanged from r351397, head/contrib/wpa/src/ap/airtime_policy.h stable/12/contrib/wpa/src/ap/wpa_auth_kay.c - copied unchanged from r351397, head/contrib/wpa/src/ap/wpa_auth_kay.c stable/12/contrib/wpa/src/ap/wpa_auth_kay.h - copied unchanged from r351397, head/contrib/wpa/src/ap/wpa_auth_kay.h stable/12/contrib/wpa/src/common/dragonfly.c - copied unchanged from r351397, head/contrib/wpa/src/common/dragonfly.c stable/12/contrib/wpa/src/common/dragonfly.h - copied unchanged from r351397, head/contrib/wpa/src/common/dragonfly.h stable/12/contrib/wpa/src/drivers/driver_atheros.c - copied unchanged from r351397, head/contrib/wpa/src/drivers/driver_atheros.c stable/12/contrib/wpa/src/drivers/driver_hostap.c - copied unchanged from r351397, head/contrib/wpa/src/drivers/driver_hostap.c stable/12/contrib/wpa/src/drivers/nl80211_copy.h - copied unchanged from r351397, head/contrib/wpa/src/drivers/nl80211_copy.h stable/12/contrib/wpa/src/eap_common/eap_teap_common.c - copied unchanged from r351397, head/contrib/wpa/src/eap_common/eap_teap_common.c stable/12/contrib/wpa/src/eap_common/eap_teap_common.h - copied unchanged from r351397, head/contrib/wpa/src/eap_common/eap_teap_common.h stable/12/contrib/wpa/src/eap_peer/eap_teap.c - copied unchanged from r351397, head/contrib/wpa/src/eap_peer/eap_teap.c stable/12/contrib/wpa/src/eap_peer/eap_teap_pac.c - copied unchanged from r351397, head/contrib/wpa/src/eap_peer/eap_teap_pac.c stable/12/contrib/wpa/src/eap_peer/eap_teap_pac.h - copied unchanged from r351397, head/contrib/wpa/src/eap_peer/eap_teap_pac.h stable/12/contrib/wpa/src/eap_server/eap_server_teap.c - copied unchanged from r351397, head/contrib/wpa/src/eap_server/eap_server_teap.c Modified: stable/12/contrib/wpa/hostapd/ChangeLog stable/12/contrib/wpa/hostapd/config_file.c stable/12/contrib/wpa/hostapd/ctrl_iface.c stable/12/contrib/wpa/hostapd/defconfig stable/12/contrib/wpa/hostapd/eap_register.c stable/12/contrib/wpa/hostapd/hostapd.conf stable/12/contrib/wpa/hostapd/hostapd_cli.c stable/12/contrib/wpa/hostapd/main.c stable/12/contrib/wpa/hs20/client/osu_client.c stable/12/contrib/wpa/src/ap/accounting.c stable/12/contrib/wpa/src/ap/acs.c stable/12/contrib/wpa/src/ap/ap_config.c stable/12/contrib/wpa/src/ap/ap_config.h stable/12/contrib/wpa/src/ap/ap_drv_ops.c stable/12/contrib/wpa/src/ap/ap_drv_ops.h stable/12/contrib/wpa/src/ap/authsrv.c stable/12/contrib/wpa/src/ap/beacon.c stable/12/contrib/wpa/src/ap/ctrl_iface_ap.c stable/12/contrib/wpa/src/ap/dfs.c stable/12/contrib/wpa/src/ap/dpp_hostapd.c stable/12/contrib/wpa/src/ap/dpp_hostapd.h stable/12/contrib/wpa/src/ap/drv_callbacks.c stable/12/contrib/wpa/src/ap/gas_serv.c stable/12/contrib/wpa/src/ap/gas_serv.h stable/12/contrib/wpa/src/ap/hostapd.c stable/12/contrib/wpa/src/ap/hostapd.h stable/12/contrib/wpa/src/ap/hw_features.c stable/12/contrib/wpa/src/ap/ieee802_11.c stable/12/contrib/wpa/src/ap/ieee802_11.h stable/12/contrib/wpa/src/ap/ieee802_11_he.c stable/12/contrib/wpa/src/ap/ieee802_11_vht.c stable/12/contrib/wpa/src/ap/ieee802_1x.c stable/12/contrib/wpa/src/ap/ieee802_1x.h stable/12/contrib/wpa/src/ap/neighbor_db.c stable/12/contrib/wpa/src/ap/sta_info.c stable/12/contrib/wpa/src/ap/sta_info.h stable/12/contrib/wpa/src/ap/wmm.c stable/12/contrib/wpa/src/ap/wpa_auth.c stable/12/contrib/wpa/src/ap/wpa_auth.h stable/12/contrib/wpa/src/ap/wpa_auth_ft.c stable/12/contrib/wpa/src/ap/wpa_auth_glue.c stable/12/contrib/wpa/src/ap/wpa_auth_ie.c stable/12/contrib/wpa/src/common/dpp.c stable/12/contrib/wpa/src/common/dpp.h stable/12/contrib/wpa/src/common/hw_features_common.c stable/12/contrib/wpa/src/common/hw_features_common.h stable/12/contrib/wpa/src/common/ieee802_11_common.c stable/12/contrib/wpa/src/common/ieee802_11_common.h stable/12/contrib/wpa/src/common/ieee802_11_defs.h stable/12/contrib/wpa/src/common/qca-vendor.h stable/12/contrib/wpa/src/common/sae.c stable/12/contrib/wpa/src/common/sae.h stable/12/contrib/wpa/src/common/version.h stable/12/contrib/wpa/src/common/wpa_common.c stable/12/contrib/wpa/src/common/wpa_ctrl.h stable/12/contrib/wpa/src/crypto/aes_i.h stable/12/contrib/wpa/src/crypto/crypto.h stable/12/contrib/wpa/src/crypto/crypto_openssl.c stable/12/contrib/wpa/src/crypto/crypto_wolfssl.c stable/12/contrib/wpa/src/crypto/sha1-internal.c stable/12/contrib/wpa/src/crypto/sha1-prf.c stable/12/contrib/wpa/src/crypto/sha1-tlsprf.c stable/12/contrib/wpa/src/crypto/sha1-tprf.c stable/12/contrib/wpa/src/crypto/sha1.c stable/12/contrib/wpa/src/crypto/sha256-kdf.c stable/12/contrib/wpa/src/crypto/sha256-prf.c stable/12/contrib/wpa/src/crypto/sha256-tlsprf.c stable/12/contrib/wpa/src/crypto/sha256.h stable/12/contrib/wpa/src/crypto/sha384-kdf.c stable/12/contrib/wpa/src/crypto/sha384-prf.c stable/12/contrib/wpa/src/crypto/sha512-kdf.c stable/12/contrib/wpa/src/crypto/sha512-prf.c stable/12/contrib/wpa/src/crypto/tls.h stable/12/contrib/wpa/src/crypto/tls_openssl.c stable/12/contrib/wpa/src/crypto/tls_wolfssl.c stable/12/contrib/wpa/src/drivers/driver.h stable/12/contrib/wpa/src/drivers/driver_bsd.c stable/12/contrib/wpa/src/drivers/driver_common.c stable/12/contrib/wpa/src/drivers/driver_macsec_linux.c stable/12/contrib/wpa/src/drivers/driver_macsec_qca.c stable/12/contrib/wpa/src/drivers/driver_ndis.c stable/12/contrib/wpa/src/drivers/driver_nl80211.h stable/12/contrib/wpa/src/drivers/driver_nl80211_capa.c stable/12/contrib/wpa/src/drivers/driver_nl80211_event.c stable/12/contrib/wpa/src/drivers/driver_privsep.c stable/12/contrib/wpa/src/eap_common/eap_defs.h stable/12/contrib/wpa/src/eap_common/eap_pwd_common.c stable/12/contrib/wpa/src/eap_common/eap_sim_common.c stable/12/contrib/wpa/src/eap_common/eap_sim_common.h stable/12/contrib/wpa/src/eap_peer/eap.c stable/12/contrib/wpa/src/eap_peer/eap.h stable/12/contrib/wpa/src/eap_peer/eap_aka.c stable/12/contrib/wpa/src/eap_peer/eap_config.h stable/12/contrib/wpa/src/eap_peer/eap_eke.c stable/12/contrib/wpa/src/eap_peer/eap_leap.c stable/12/contrib/wpa/src/eap_peer/eap_methods.h stable/12/contrib/wpa/src/eap_peer/eap_peap.c stable/12/contrib/wpa/src/eap_peer/eap_pwd.c stable/12/contrib/wpa/src/eap_peer/eap_sim.c stable/12/contrib/wpa/src/eap_peer/eap_tls.c stable/12/contrib/wpa/src/eap_peer/eap_tls_common.c stable/12/contrib/wpa/src/eap_peer/eap_tls_common.h stable/12/contrib/wpa/src/eap_server/eap.h stable/12/contrib/wpa/src/eap_server/eap_i.h stable/12/contrib/wpa/src/eap_server/eap_methods.h stable/12/contrib/wpa/src/eap_server/eap_server.c stable/12/contrib/wpa/src/eap_server/eap_server_aka.c stable/12/contrib/wpa/src/eap_server/eap_server_pax.c stable/12/contrib/wpa/src/eap_server/eap_server_peap.c stable/12/contrib/wpa/src/eap_server/eap_server_pwd.c stable/12/contrib/wpa/src/eap_server/eap_server_sim.c stable/12/contrib/wpa/src/eap_server/eap_server_tls.c stable/12/contrib/wpa/src/eap_server/eap_server_tls_common.c stable/12/contrib/wpa/src/eap_server/eap_tls_common.h stable/12/contrib/wpa/src/eapol_auth/eapol_auth_sm.c stable/12/contrib/wpa/src/eapol_auth/eapol_auth_sm.h stable/12/contrib/wpa/src/eapol_supp/eapol_supp_sm.c stable/12/contrib/wpa/src/eapol_supp/eapol_supp_sm.h stable/12/contrib/wpa/src/p2p/p2p.c stable/12/contrib/wpa/src/p2p/p2p_go_neg.c stable/12/contrib/wpa/src/p2p/p2p_i.h stable/12/contrib/wpa/src/pae/ieee802_1x_kay.c stable/12/contrib/wpa/src/radius/radius_server.c stable/12/contrib/wpa/src/radius/radius_server.h stable/12/contrib/wpa/src/rsn_supp/wpa.c stable/12/contrib/wpa/src/rsn_supp/wpa.h stable/12/contrib/wpa/src/rsn_supp/wpa_ft.c stable/12/contrib/wpa/src/rsn_supp/wpa_i.h stable/12/contrib/wpa/src/tls/asn1.c stable/12/contrib/wpa/src/tls/libtommath.c stable/12/contrib/wpa/src/tls/x509v3.c stable/12/contrib/wpa/src/utils/common.c stable/12/contrib/wpa/src/utils/common.h stable/12/contrib/wpa/src/utils/trace.c stable/12/contrib/wpa/src/utils/wpa_debug.c stable/12/contrib/wpa/src/wps/wps.h stable/12/contrib/wpa/wpa_supplicant/Android.mk stable/12/contrib/wpa/wpa_supplicant/ChangeLog stable/12/contrib/wpa/wpa_supplicant/README-DPP stable/12/contrib/wpa/wpa_supplicant/ap.c stable/12/contrib/wpa/wpa_supplicant/ap.h stable/12/contrib/wpa/wpa_supplicant/bss.c stable/12/contrib/wpa/wpa_supplicant/config.c stable/12/contrib/wpa/wpa_supplicant/config.h stable/12/contrib/wpa/wpa_supplicant/config_file.c stable/12/contrib/wpa/wpa_supplicant/config_ssid.h stable/12/contrib/wpa/wpa_supplicant/ctrl_iface.c stable/12/contrib/wpa/wpa_supplicant/dbus/dbus_new_helpers.c stable/12/contrib/wpa/wpa_supplicant/defconfig stable/12/contrib/wpa/wpa_supplicant/dpp_supplicant.c stable/12/contrib/wpa/wpa_supplicant/dpp_supplicant.h stable/12/contrib/wpa/wpa_supplicant/driver_i.h stable/12/contrib/wpa/wpa_supplicant/eap_register.c stable/12/contrib/wpa/wpa_supplicant/eapol_test.c stable/12/contrib/wpa/wpa_supplicant/events.c stable/12/contrib/wpa/wpa_supplicant/ibss_rsn.c stable/12/contrib/wpa/wpa_supplicant/interworking.c stable/12/contrib/wpa/wpa_supplicant/mesh.c stable/12/contrib/wpa/wpa_supplicant/mesh_mpm.c stable/12/contrib/wpa/wpa_supplicant/notify.c stable/12/contrib/wpa/wpa_supplicant/notify.h stable/12/contrib/wpa/wpa_supplicant/op_classes.c stable/12/contrib/wpa/wpa_supplicant/p2p_supplicant.c stable/12/contrib/wpa/wpa_supplicant/preauth_test.c stable/12/contrib/wpa/wpa_supplicant/rrm.c stable/12/contrib/wpa/wpa_supplicant/sme.c stable/12/contrib/wpa/wpa_supplicant/wnm_sta.c stable/12/contrib/wpa/wpa_supplicant/wpa_cli.c stable/12/contrib/wpa/wpa_supplicant/wpa_supplicant.c stable/12/contrib/wpa/wpa_supplicant/wpa_supplicant.conf stable/12/contrib/wpa/wpa_supplicant/wpa_supplicant_i.h stable/12/contrib/wpa/wpa_supplicant/wpas_glue.c Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Added: stable/11/contrib/wpa/src/ap/airtime_policy.c - copied unchanged from r351397, head/contrib/wpa/src/ap/airtime_policy.c stable/11/contrib/wpa/src/ap/airtime_policy.h - copied unchanged from r351397, head/contrib/wpa/src/ap/airtime_policy.h stable/11/contrib/wpa/src/ap/wpa_auth_kay.c - copied unchanged from r351397, head/contrib/wpa/src/ap/wpa_auth_kay.c stable/11/contrib/wpa/src/ap/wpa_auth_kay.h - copied unchanged from r351397, head/contrib/wpa/src/ap/wpa_auth_kay.h stable/11/contrib/wpa/src/common/dragonfly.c - copied unchanged from r351397, head/contrib/wpa/src/common/dragonfly.c stable/11/contrib/wpa/src/common/dragonfly.h - copied unchanged from r351397, head/contrib/wpa/src/common/dragonfly.h stable/11/contrib/wpa/src/drivers/driver_atheros.c - copied unchanged from r351397, head/contrib/wpa/src/drivers/driver_atheros.c stable/11/contrib/wpa/src/drivers/driver_hostap.c - copied unchanged from r351397, head/contrib/wpa/src/drivers/driver_hostap.c stable/11/contrib/wpa/src/drivers/nl80211_copy.h - copied unchanged from r351397, head/contrib/wpa/src/drivers/nl80211_copy.h stable/11/contrib/wpa/src/eap_common/eap_teap_common.c - copied unchanged from r351397, head/contrib/wpa/src/eap_common/eap_teap_common.c stable/11/contrib/wpa/src/eap_common/eap_teap_common.h - copied unchanged from r351397, head/contrib/wpa/src/eap_common/eap_teap_common.h stable/11/contrib/wpa/src/eap_peer/eap_teap.c - copied unchanged from r351397, head/contrib/wpa/src/eap_peer/eap_teap.c stable/11/contrib/wpa/src/eap_peer/eap_teap_pac.c - copied unchanged from r351397, head/contrib/wpa/src/eap_peer/eap_teap_pac.c stable/11/contrib/wpa/src/eap_peer/eap_teap_pac.h - copied unchanged from r351397, head/contrib/wpa/src/eap_peer/eap_teap_pac.h stable/11/contrib/wpa/src/eap_server/eap_server_teap.c - copied unchanged from r351397, head/contrib/wpa/src/eap_server/eap_server_teap.c Modified: stable/11/contrib/wpa/hostapd/ChangeLog stable/11/contrib/wpa/hostapd/config_file.c stable/11/contrib/wpa/hostapd/ctrl_iface.c stable/11/contrib/wpa/hostapd/defconfig stable/11/contrib/wpa/hostapd/eap_register.c stable/11/contrib/wpa/hostapd/hostapd.conf stable/11/contrib/wpa/hostapd/hostapd_cli.c stable/11/contrib/wpa/hostapd/main.c stable/11/contrib/wpa/hs20/client/osu_client.c stable/11/contrib/wpa/src/ap/accounting.c stable/11/contrib/wpa/src/ap/acs.c stable/11/contrib/wpa/src/ap/ap_config.c stable/11/contrib/wpa/src/ap/ap_config.h stable/11/contrib/wpa/src/ap/ap_drv_ops.c stable/11/contrib/wpa/src/ap/ap_drv_ops.h stable/11/contrib/wpa/src/ap/authsrv.c stable/11/contrib/wpa/src/ap/beacon.c stable/11/contrib/wpa/src/ap/ctrl_iface_ap.c stable/11/contrib/wpa/src/ap/dfs.c stable/11/contrib/wpa/src/ap/dpp_hostapd.c stable/11/contrib/wpa/src/ap/dpp_hostapd.h stable/11/contrib/wpa/src/ap/drv_callbacks.c stable/11/contrib/wpa/src/ap/gas_serv.c stable/11/contrib/wpa/src/ap/gas_serv.h stable/11/contrib/wpa/src/ap/hostapd.c stable/11/contrib/wpa/src/ap/hostapd.h stable/11/contrib/wpa/src/ap/hw_features.c stable/11/contrib/wpa/src/ap/ieee802_11.c stable/11/contrib/wpa/src/ap/ieee802_11.h stable/11/contrib/wpa/src/ap/ieee802_11_he.c stable/11/contrib/wpa/src/ap/ieee802_11_vht.c stable/11/contrib/wpa/src/ap/ieee802_1x.c stable/11/contrib/wpa/src/ap/ieee802_1x.h stable/11/contrib/wpa/src/ap/neighbor_db.c stable/11/contrib/wpa/src/ap/sta_info.c stable/11/contrib/wpa/src/ap/sta_info.h stable/11/contrib/wpa/src/ap/wmm.c stable/11/contrib/wpa/src/ap/wpa_auth.c stable/11/contrib/wpa/src/ap/wpa_auth.h stable/11/contrib/wpa/src/ap/wpa_auth_ft.c stable/11/contrib/wpa/src/ap/wpa_auth_glue.c stable/11/contrib/wpa/src/ap/wpa_auth_ie.c stable/11/contrib/wpa/src/common/dpp.c stable/11/contrib/wpa/src/common/dpp.h stable/11/contrib/wpa/src/common/hw_features_common.c stable/11/contrib/wpa/src/common/hw_features_common.h stable/11/contrib/wpa/src/common/ieee802_11_common.c stable/11/contrib/wpa/src/common/ieee802_11_common.h stable/11/contrib/wpa/src/common/ieee802_11_defs.h stable/11/contrib/wpa/src/common/qca-vendor.h stable/11/contrib/wpa/src/common/sae.c stable/11/contrib/wpa/src/common/sae.h stable/11/contrib/wpa/src/common/version.h stable/11/contrib/wpa/src/common/wpa_common.c stable/11/contrib/wpa/src/common/wpa_ctrl.h stable/11/contrib/wpa/src/crypto/aes_i.h stable/11/contrib/wpa/src/crypto/crypto.h stable/11/contrib/wpa/src/crypto/crypto_openssl.c stable/11/contrib/wpa/src/crypto/crypto_wolfssl.c stable/11/contrib/wpa/src/crypto/sha1-internal.c stable/11/contrib/wpa/src/crypto/sha1-prf.c stable/11/contrib/wpa/src/crypto/sha1-tlsprf.c stable/11/contrib/wpa/src/crypto/sha1-tprf.c stable/11/contrib/wpa/src/crypto/sha1.c stable/11/contrib/wpa/src/crypto/sha256-kdf.c stable/11/contrib/wpa/src/crypto/sha256-prf.c stable/11/contrib/wpa/src/crypto/sha256-tlsprf.c stable/11/contrib/wpa/src/crypto/sha256.h stable/11/contrib/wpa/src/crypto/sha384-kdf.c stable/11/contrib/wpa/src/crypto/sha384-prf.c stable/11/contrib/wpa/src/crypto/sha512-kdf.c stable/11/contrib/wpa/src/crypto/sha512-prf.c stable/11/contrib/wpa/src/crypto/tls.h stable/11/contrib/wpa/src/crypto/tls_openssl.c stable/11/contrib/wpa/src/crypto/tls_wolfssl.c stable/11/contrib/wpa/src/drivers/driver.h stable/11/contrib/wpa/src/drivers/driver_bsd.c stable/11/contrib/wpa/src/drivers/driver_common.c stable/11/contrib/wpa/src/drivers/driver_macsec_linux.c stable/11/contrib/wpa/src/drivers/driver_macsec_qca.c stable/11/contrib/wpa/src/drivers/driver_ndis.c stable/11/contrib/wpa/src/drivers/driver_nl80211.h stable/11/contrib/wpa/src/drivers/driver_nl80211_capa.c stable/11/contrib/wpa/src/drivers/driver_nl80211_event.c stable/11/contrib/wpa/src/drivers/driver_privsep.c stable/11/contrib/wpa/src/eap_common/eap_defs.h stable/11/contrib/wpa/src/eap_common/eap_pwd_common.c stable/11/contrib/wpa/src/eap_common/eap_sim_common.c stable/11/contrib/wpa/src/eap_common/eap_sim_common.h stable/11/contrib/wpa/src/eap_peer/eap.c stable/11/contrib/wpa/src/eap_peer/eap.h stable/11/contrib/wpa/src/eap_peer/eap_aka.c stable/11/contrib/wpa/src/eap_peer/eap_config.h stable/11/contrib/wpa/src/eap_peer/eap_eke.c stable/11/contrib/wpa/src/eap_peer/eap_leap.c stable/11/contrib/wpa/src/eap_peer/eap_methods.h stable/11/contrib/wpa/src/eap_peer/eap_peap.c stable/11/contrib/wpa/src/eap_peer/eap_pwd.c stable/11/contrib/wpa/src/eap_peer/eap_sim.c stable/11/contrib/wpa/src/eap_peer/eap_tls.c stable/11/contrib/wpa/src/eap_peer/eap_tls_common.c stable/11/contrib/wpa/src/eap_peer/eap_tls_common.h stable/11/contrib/wpa/src/eap_server/eap.h stable/11/contrib/wpa/src/eap_server/eap_i.h stable/11/contrib/wpa/src/eap_server/eap_methods.h stable/11/contrib/wpa/src/eap_server/eap_server.c stable/11/contrib/wpa/src/eap_server/eap_server_aka.c stable/11/contrib/wpa/src/eap_server/eap_server_pax.c stable/11/contrib/wpa/src/eap_server/eap_server_peap.c stable/11/contrib/wpa/src/eap_server/eap_server_pwd.c stable/11/contrib/wpa/src/eap_server/eap_server_sim.c stable/11/contrib/wpa/src/eap_server/eap_server_tls.c stable/11/contrib/wpa/src/eap_server/eap_server_tls_common.c stable/11/contrib/wpa/src/eap_server/eap_tls_common.h stable/11/contrib/wpa/src/eapol_auth/eapol_auth_sm.c stable/11/contrib/wpa/src/eapol_auth/eapol_auth_sm.h stable/11/contrib/wpa/src/eapol_supp/eapol_supp_sm.c stable/11/contrib/wpa/src/eapol_supp/eapol_supp_sm.h stable/11/contrib/wpa/src/p2p/p2p.c stable/11/contrib/wpa/src/p2p/p2p_go_neg.c stable/11/contrib/wpa/src/p2p/p2p_i.h stable/11/contrib/wpa/src/pae/ieee802_1x_kay.c stable/11/contrib/wpa/src/radius/radius_server.c stable/11/contrib/wpa/src/radius/radius_server.h stable/11/contrib/wpa/src/rsn_supp/wpa.c stable/11/contrib/wpa/src/rsn_supp/wpa.h stable/11/contrib/wpa/src/rsn_supp/wpa_ft.c stable/11/contrib/wpa/src/rsn_supp/wpa_i.h stable/11/contrib/wpa/src/tls/asn1.c stable/11/contrib/wpa/src/tls/libtommath.c stable/11/contrib/wpa/src/tls/x509v3.c stable/11/contrib/wpa/src/utils/common.c stable/11/contrib/wpa/src/utils/common.h stable/11/contrib/wpa/src/utils/trace.c stable/11/contrib/wpa/src/utils/wpa_debug.c stable/11/contrib/wpa/src/wps/wps.h stable/11/contrib/wpa/wpa_supplicant/Android.mk stable/11/contrib/wpa/wpa_supplicant/ChangeLog stable/11/contrib/wpa/wpa_supplicant/README-DPP stable/11/contrib/wpa/wpa_supplicant/ap.c stable/11/contrib/wpa/wpa_supplicant/ap.h stable/11/contrib/wpa/wpa_supplicant/bss.c stable/11/contrib/wpa/wpa_supplicant/config.c stable/11/contrib/wpa/wpa_supplicant/config.h stable/11/contrib/wpa/wpa_supplicant/config_file.c stable/11/contrib/wpa/wpa_supplicant/config_ssid.h stable/11/contrib/wpa/wpa_supplicant/ctrl_iface.c stable/11/contrib/wpa/wpa_supplicant/dbus/dbus_new_helpers.c stable/11/contrib/wpa/wpa_supplicant/defconfig stable/11/contrib/wpa/wpa_supplicant/dpp_supplicant.c stable/11/contrib/wpa/wpa_supplicant/dpp_supplicant.h stable/11/contrib/wpa/wpa_supplicant/driver_i.h stable/11/contrib/wpa/wpa_supplicant/eap_register.c stable/11/contrib/wpa/wpa_supplicant/eapol_test.c stable/11/contrib/wpa/wpa_supplicant/events.c stable/11/contrib/wpa/wpa_supplicant/ibss_rsn.c stable/11/contrib/wpa/wpa_supplicant/interworking.c stable/11/contrib/wpa/wpa_supplicant/mesh.c stable/11/contrib/wpa/wpa_supplicant/mesh_mpm.c stable/11/contrib/wpa/wpa_supplicant/notify.c stable/11/contrib/wpa/wpa_supplicant/notify.h stable/11/contrib/wpa/wpa_supplicant/op_classes.c stable/11/contrib/wpa/wpa_supplicant/p2p_supplicant.c stable/11/contrib/wpa/wpa_supplicant/preauth_test.c stable/11/contrib/wpa/wpa_supplicant/rrm.c stable/11/contrib/wpa/wpa_supplicant/sme.c stable/11/contrib/wpa/wpa_supplicant/wnm_sta.c stable/11/contrib/wpa/wpa_supplicant/wpa_cli.c stable/11/contrib/wpa/wpa_supplicant/wpa_supplicant.c stable/11/contrib/wpa/wpa_supplicant/wpa_supplicant.conf stable/11/contrib/wpa/wpa_supplicant/wpa_supplicant_i.h stable/11/contrib/wpa/wpa_supplicant/wpas_glue.c Directory Properties: stable/11/ (props changed) Modified: stable/12/contrib/wpa/hostapd/ChangeLog ============================================================================== --- stable/12/contrib/wpa/hostapd/ChangeLog Thu Aug 29 18:53:00 2019 (r351610) +++ stable/12/contrib/wpa/hostapd/ChangeLog Thu Aug 29 19:13:27 2019 (r351611) @@ -1,5 +1,29 @@ ChangeLog for hostapd +2019-08-07 - v2.9 + * SAE changes + - disable use of groups using Brainpool curves + - improved protection against side channel attacks + [https://w1.fi/security/2019-6/] + * EAP-pwd changes + - disable use of groups using Brainpool curves + - improved protection against side channel attacks + [https://w1.fi/security/2019-6/] + * fixed FT-EAP initial mobility domain association using PMKSA caching + * added configuration of airtime policy + * fixed FILS to and RSNE into (Re)Association Response frames + * fixed DPP bootstrapping URI parser of channel list + * added support for regulatory WMM limitation (for ETSI) + * added support for MACsec Key Agreement using IEEE 802.1X/PSK + * added experimental support for EAP-TEAP server (RFC 7170) + * added experimental support for EAP-TLS server with TLS v1.3 + * added support for two server certificates/keys (RSA/ECC) + * added AKMSuiteSelector into "STA " control interface data to + determine with AKM was used for an association + * added eap_sim_id parameter to allow EAP-SIM/AKA server pseudonym and + fast reauthentication use to be disabled + * fixed an ECDH operation corner case with OpenSSL + 2019-04-21 - v2.8 * SAE changes - added support for SAE Password Identifier Modified: stable/12/contrib/wpa/hostapd/config_file.c ============================================================================== --- stable/12/contrib/wpa/hostapd/config_file.c Thu Aug 29 18:53:00 2019 (r351610) +++ stable/12/contrib/wpa/hostapd/config_file.c Thu Aug 29 19:13:27 2019 (r351611) @@ -24,14 +24,6 @@ #include "config_file.h" -#ifndef CONFIG_NO_RADIUS -#ifdef EAP_SERVER -static struct hostapd_radius_attr * -hostapd_parse_radius_attr(const char *value); -#endif /* EAP_SERVER */ -#endif /* CONFIG_NO_RADIUS */ - - #ifndef CONFIG_NO_VLAN static int hostapd_config_read_vlan_file(struct hostapd_bss_config *bss, const char *fname) @@ -660,76 +652,7 @@ hostapd_config_read_radius_addr(struct hostapd_radius_ } -static struct hostapd_radius_attr * -hostapd_parse_radius_attr(const char *value) -{ - const char *pos; - char syntax; - struct hostapd_radius_attr *attr; - size_t len; - attr = os_zalloc(sizeof(*attr)); - if (attr == NULL) - return NULL; - - attr->type = atoi(value); - - pos = os_strchr(value, ':'); - if (pos == NULL) { - attr->val = wpabuf_alloc(1); - if (attr->val == NULL) { - os_free(attr); - return NULL; - } - wpabuf_put_u8(attr->val, 0); - return attr; - } - - pos++; - if (pos[0] == '\0' || pos[1] != ':') { - os_free(attr); - return NULL; - } - syntax = *pos++; - pos++; - - switch (syntax) { - case 's': - attr->val = wpabuf_alloc_copy(pos, os_strlen(pos)); - break; - case 'x': - len = os_strlen(pos); - if (len & 1) - break; - len /= 2; - attr->val = wpabuf_alloc(len); - if (attr->val == NULL) - break; - if (hexstr2bin(pos, wpabuf_put(attr->val, len), len) < 0) { - wpabuf_free(attr->val); - os_free(attr); - return NULL; - } - break; - case 'd': - attr->val = wpabuf_alloc(4); - if (attr->val) - wpabuf_put_be32(attr->val, atoi(pos)); - break; - default: - os_free(attr); - return NULL; - } - - if (attr->val == NULL) { - os_free(attr); - return NULL; - } - - return attr; -} - - static int hostapd_parse_das_client(struct hostapd_bss_config *bss, char *val) { char *secret; @@ -2313,6 +2236,42 @@ static unsigned int parse_tls_flags(const char *val) #endif /* EAP_SERVER */ +#ifdef CONFIG_AIRTIME_POLICY +static int add_airtime_weight(struct hostapd_bss_config *bss, char *value) +{ + struct airtime_sta_weight *wt; + char *pos, *next; + + wt = os_zalloc(sizeof(*wt)); + if (!wt) + return -1; + + /* 02:01:02:03:04:05 10 */ + pos = value; + next = os_strchr(pos, ' '); + if (next) + *next++ = '\0'; + if (!next || hwaddr_aton(pos, wt->addr)) { + wpa_printf(MSG_ERROR, "Invalid station address: '%s'", pos); + os_free(wt); + return -1; + } + + pos = next; + wt->weight = atoi(pos); + if (!wt->weight) { + wpa_printf(MSG_ERROR, "Invalid weight: '%s'", pos); + os_free(wt); + return -1; + } + + wt->next = bss->airtime_weight_list; + bss->airtime_weight_list = wt; + return 0; +} +#endif /* CONFIG_AIRTIME_POLICY */ + + #ifdef CONFIG_SAE static int parse_sae_password(struct hostapd_bss_config *bss, const char *val) { @@ -2376,6 +2335,36 @@ fail: #endif /* CONFIG_SAE */ +#ifdef CONFIG_DPP2 +static int hostapd_dpp_controller_parse(struct hostapd_bss_config *bss, + const char *pos) +{ + struct dpp_controller_conf *conf; + char *val; + + conf = os_zalloc(sizeof(*conf)); + if (!conf) + return -1; + val = get_param(pos, "ipaddr="); + if (!val || hostapd_parse_ip_addr(val, &conf->ipaddr)) + goto fail; + os_free(val); + val = get_param(pos, "pkhash="); + if (!val || os_strlen(val) != 2 * SHA256_MAC_LEN || + hexstr2bin(val, conf->pkhash, SHA256_MAC_LEN) < 0) + goto fail; + os_free(val); + conf->next = bss->dpp_controller; + bss->dpp_controller = conf; + return 0; +fail: + os_free(val); + os_free(conf); + return -1; +} +#endif /* CONFIG_DPP2 */ + + static int hostapd_config_fill(struct hostapd_config *conf, struct hostapd_bss_config *bss, const char *buf, char *pos, int line) @@ -2496,7 +2485,11 @@ static int hostapd_config_fill(struct hostapd_config * } else if (os_strcmp(buf, "eapol_version") == 0) { int eapol_version = atoi(pos); +#ifdef CONFIG_MACSEC + if (eapol_version < 1 || eapol_version > 3) { +#else /* CONFIG_MACSEC */ if (eapol_version < 1 || eapol_version > 2) { +#endif /* CONFIG_MACSEC */ wpa_printf(MSG_ERROR, "Line %d: invalid EAPOL version (%d): '%s'.", line, eapol_version, pos); @@ -2519,12 +2512,21 @@ static int hostapd_config_fill(struct hostapd_config * } else if (os_strcmp(buf, "server_cert") == 0) { os_free(bss->server_cert); bss->server_cert = os_strdup(pos); + } else if (os_strcmp(buf, "server_cert2") == 0) { + os_free(bss->server_cert2); + bss->server_cert2 = os_strdup(pos); } else if (os_strcmp(buf, "private_key") == 0) { os_free(bss->private_key); bss->private_key = os_strdup(pos); + } else if (os_strcmp(buf, "private_key2") == 0) { + os_free(bss->private_key2); + bss->private_key2 = os_strdup(pos); } else if (os_strcmp(buf, "private_key_passwd") == 0) { os_free(bss->private_key_passwd); bss->private_key_passwd = os_strdup(pos); + } else if (os_strcmp(buf, "private_key_passwd2") == 0) { + os_free(bss->private_key_passwd2); + bss->private_key_passwd2 = os_strdup(pos); } else if (os_strcmp(buf, "check_cert_subject") == 0) { if (!pos[0]) { wpa_printf(MSG_ERROR, "Line %d: unknown check_cert_subject '%s'", @@ -2605,6 +2607,20 @@ static int hostapd_config_fill(struct hostapd_config * } else if (os_strcmp(buf, "pac_key_refresh_time") == 0) { bss->pac_key_refresh_time = atoi(pos); #endif /* EAP_SERVER_FAST */ +#ifdef EAP_SERVER_TEAP + } else if (os_strcmp(buf, "eap_teap_auth") == 0) { + int val = atoi(pos); + + if (val < 0 || val > 1) { + wpa_printf(MSG_ERROR, + "Line %d: Invalid eap_teap_auth value", + line); + return 1; + } + bss->eap_teap_auth = val; + } else if (os_strcmp(buf, "eap_teap_pac_no_inner") == 0) { + bss->eap_teap_pac_no_inner = atoi(pos); +#endif /* EAP_SERVER_TEAP */ #ifdef EAP_SERVER_SIM } else if (os_strcmp(buf, "eap_sim_db") == 0) { os_free(bss->eap_sim_db); @@ -2613,6 +2629,8 @@ static int hostapd_config_fill(struct hostapd_config * bss->eap_sim_db_timeout = atoi(pos); } else if (os_strcmp(buf, "eap_sim_aka_result_ind") == 0) { bss->eap_sim_aka_result_ind = atoi(pos); + } else if (os_strcmp(buf, "eap_sim_id") == 0) { + bss->eap_sim_id = atoi(pos); #endif /* EAP_SERVER_SIM */ #ifdef EAP_SERVER_TNC } else if (os_strcmp(buf, "tnc") == 0) { @@ -2816,6 +2834,9 @@ static int hostapd_config_fill(struct hostapd_config * a = a->next; a->next = attr; } + } else if (os_strcmp(buf, "radius_req_attr_sqlite") == 0) { + os_free(bss->radius_req_attr_sqlite); + bss->radius_req_attr_sqlite = os_strdup(pos); } else if (os_strcmp(buf, "radius_das_port") == 0) { bss->radius_das_port = atoi(pos); } else if (os_strcmp(buf, "radius_das_client") == 0) { @@ -3442,6 +3463,8 @@ static int hostapd_config_fill(struct hostapd_config * conf->he_op.he_twt_required = atoi(pos); } else if (os_strcmp(buf, "he_rts_threshold") == 0) { conf->he_op.he_rts_threshold = atoi(pos); + } else if (os_strcmp(buf, "he_basic_mcs_nss_set") == 0) { + conf->he_op.he_basic_mcs_nss_set = atoi(pos); } else if (os_strcmp(buf, "he_mu_edca_qos_info_param_count") == 0) { conf->he_mu_edca.he_qos_info |= set_he_cap(atoi(pos), HE_QOS_INFO_EDCA_PARAM_SET_COUNT); @@ -3526,6 +3549,20 @@ static int hostapd_config_fill(struct hostapd_config * } else if (os_strcmp(buf, "he_mu_edca_ac_vo_timer") == 0) { conf->he_mu_edca.he_mu_ac_vo_param[HE_MU_AC_PARAM_TIMER_IDX] = atoi(pos) & 0xff; + } else if (os_strcmp(buf, "he_spr_sr_control") == 0) { + conf->spr.sr_control = atoi(pos) & 0xff; + } else if (os_strcmp(buf, "he_spr_non_srg_obss_pd_max_offset") == 0) { + conf->spr.non_srg_obss_pd_max_offset = atoi(pos); + } else if (os_strcmp(buf, "he_spr_srg_obss_pd_min_offset") == 0) { + conf->spr.srg_obss_pd_min_offset = atoi(pos); + } else if (os_strcmp(buf, "he_spr_srg_obss_pd_max_offset") == 0) { + conf->spr.srg_obss_pd_max_offset = atoi(pos); + } else if (os_strcmp(buf, "he_oper_chwidth") == 0) { + conf->he_oper_chwidth = atoi(pos); + } else if (os_strcmp(buf, "he_oper_centr_freq_seg0_idx") == 0) { + conf->he_oper_centr_freq_seg0_idx = atoi(pos); + } else if (os_strcmp(buf, "he_oper_centr_freq_seg1_idx") == 0) { + conf->he_oper_centr_freq_seg1_idx = atoi(pos); #endif /* CONFIG_IEEE80211AX */ } else if (os_strcmp(buf, "max_listen_interval") == 0) { bss->max_listen_interval = atoi(pos); @@ -4298,6 +4335,11 @@ static int hostapd_config_fill(struct hostapd_config * } else if (os_strcmp(buf, "dpp_csign") == 0) { if (parse_wpabuf_hex(line, buf, &bss->dpp_csign, pos)) return 1; +#ifdef CONFIG_DPP2 + } else if (os_strcmp(buf, "dpp_controller") == 0) { + if (hostapd_dpp_controller_parse(bss, pos)) + return 1; +#endif /* CONFIG_DPP2 */ #endif /* CONFIG_DPP */ #ifdef CONFIG_OWE } else if (os_strcmp(buf, "owe_transition_bssid") == 0) { @@ -4349,6 +4391,121 @@ static int hostapd_config_fill(struct hostapd_config * conf->rssi_reject_assoc_timeout = atoi(pos); } else if (os_strcmp(buf, "pbss") == 0) { bss->pbss = atoi(pos); +#ifdef CONFIG_AIRTIME_POLICY + } else if (os_strcmp(buf, "airtime_mode") == 0) { + int val = atoi(pos); + + if (val < 0 || val > AIRTIME_MODE_MAX) { + wpa_printf(MSG_ERROR, "Line %d: Unknown airtime_mode", + line); + return 1; + } + conf->airtime_mode = val; + } else if (os_strcmp(buf, "airtime_update_interval") == 0) { + conf->airtime_update_interval = atoi(pos); + } else if (os_strcmp(buf, "airtime_bss_weight") == 0) { + bss->airtime_weight = atoi(pos); + } else if (os_strcmp(buf, "airtime_bss_limit") == 0) { + int val = atoi(pos); + + if (val < 0 || val > 1) { + wpa_printf(MSG_ERROR, + "Line %d: Invalid airtime_bss_limit (must be 0 or 1)", + line); + return 1; + } + bss->airtime_limit = val; + } else if (os_strcmp(buf, "airtime_sta_weight") == 0) { + if (add_airtime_weight(bss, pos) < 0) { + wpa_printf(MSG_ERROR, + "Line %d: Invalid airtime weight '%s'", + line, pos); + return 1; + } +#endif /* CONFIG_AIRTIME_POLICY */ +#ifdef CONFIG_MACSEC + } else if (os_strcmp(buf, "macsec_policy") == 0) { + int macsec_policy = atoi(pos); + + if (macsec_policy < 0 || macsec_policy > 1) { + wpa_printf(MSG_ERROR, + "Line %d: invalid macsec_policy (%d): '%s'.", + line, macsec_policy, pos); + return 1; + } + bss->macsec_policy = macsec_policy; + } else if (os_strcmp(buf, "macsec_integ_only") == 0) { + int macsec_integ_only = atoi(pos); + + if (macsec_integ_only < 0 || macsec_integ_only > 1) { + wpa_printf(MSG_ERROR, + "Line %d: invalid macsec_integ_only (%d): '%s'.", + line, macsec_integ_only, pos); + return 1; + } + bss->macsec_integ_only = macsec_integ_only; + } else if (os_strcmp(buf, "macsec_replay_protect") == 0) { + int macsec_replay_protect = atoi(pos); + + if (macsec_replay_protect < 0 || macsec_replay_protect > 1) { + wpa_printf(MSG_ERROR, + "Line %d: invalid macsec_replay_protect (%d): '%s'.", + line, macsec_replay_protect, pos); + return 1; + } + bss->macsec_replay_protect = macsec_replay_protect; + } else if (os_strcmp(buf, "macsec_replay_window") == 0) { + bss->macsec_replay_window = atoi(pos); + } else if (os_strcmp(buf, "macsec_port") == 0) { + int macsec_port = atoi(pos); + + if (macsec_port < 1 || macsec_port > 65534) { + wpa_printf(MSG_ERROR, + "Line %d: invalid macsec_port (%d): '%s'.", + line, macsec_port, pos); + return 1; + } + bss->macsec_port = macsec_port; + } else if (os_strcmp(buf, "mka_priority") == 0) { + int mka_priority = atoi(pos); + + if (mka_priority < 0 || mka_priority > 255) { + wpa_printf(MSG_ERROR, + "Line %d: invalid mka_priority (%d): '%s'.", + line, mka_priority, pos); + return 1; + } + bss->mka_priority = mka_priority; + } else if (os_strcmp(buf, "mka_cak") == 0) { + size_t len = os_strlen(pos); + + if (len > 2 * MACSEC_CAK_MAX_LEN || + (len != 2 * 16 && len != 2 * 32) || + hexstr2bin(pos, bss->mka_cak, len / 2)) { + wpa_printf(MSG_ERROR, "Line %d: Invalid MKA-CAK '%s'.", + line, pos); + return 1; + } + bss->mka_cak_len = len / 2; + bss->mka_psk_set |= MKA_PSK_SET_CAK; + } else if (os_strcmp(buf, "mka_ckn") == 0) { + size_t len = os_strlen(pos); + + if (len > 2 * MACSEC_CKN_MAX_LEN || /* too long */ + len < 2 || /* too short */ + len % 2 != 0 /* not an integral number of bytes */) { + wpa_printf(MSG_ERROR, "Line %d: Invalid MKA-CKN '%s'.", + line, pos); + return 1; + } + bss->mka_ckn_len = len / 2; + if (hexstr2bin(pos, bss->mka_ckn, bss->mka_ckn_len)) { + wpa_printf(MSG_ERROR, "Line %d: Invalid MKA-CKN '%s'.", + line, pos); + return -1; + } + bss->mka_psk_set |= MKA_PSK_SET_CKN; +#endif /* CONFIG_MACSEC */ } else { wpa_printf(MSG_ERROR, "Line %d: unknown configuration item '%s'", Modified: stable/12/contrib/wpa/hostapd/ctrl_iface.c ============================================================================== --- stable/12/contrib/wpa/hostapd/ctrl_iface.c Thu Aug 29 18:53:00 2019 (r351610) +++ stable/12/contrib/wpa/hostapd/ctrl_iface.c Thu Aug 29 19:13:27 2019 (r351611) @@ -1830,26 +1830,40 @@ static void hostapd_data_test_rx(void *ctx, const u8 * struct iphdr ip; const u8 *pos; unsigned int i; + char extra[30]; - if (len != HWSIM_PACKETLEN) + if (len < sizeof(*eth) + sizeof(ip) || len > HWSIM_PACKETLEN) { + wpa_printf(MSG_DEBUG, + "test data: RX - ignore unexpected length %d", + (int) len); return; + } eth = (const struct ether_header *) buf; os_memcpy(&ip, eth + 1, sizeof(ip)); pos = &buf[sizeof(*eth) + sizeof(ip)]; if (ip.ihl != 5 || ip.version != 4 || - ntohs(ip.tot_len) != HWSIM_IP_LEN) + ntohs(ip.tot_len) > HWSIM_IP_LEN) { + wpa_printf(MSG_DEBUG, + "test data: RX - ignore unexpect IP header"); return; + } - for (i = 0; i < HWSIM_IP_LEN - sizeof(ip); i++) { - if (*pos != (u8) i) + for (i = 0; i < ntohs(ip.tot_len) - sizeof(ip); i++) { + if (*pos != (u8) i) { + wpa_printf(MSG_DEBUG, + "test data: RX - ignore mismatching payload"); return; + } pos++; } - wpa_msg(hapd->msg_ctx, MSG_INFO, "DATA-TEST-RX " MACSTR " " MACSTR, - MAC2STR(eth->ether_dhost), MAC2STR(eth->ether_shost)); + extra[0] = '\0'; + if (ntohs(ip.tot_len) != HWSIM_IP_LEN) + os_snprintf(extra, sizeof(extra), " len=%d", ntohs(ip.tot_len)); + wpa_msg(hapd->msg_ctx, MSG_INFO, "DATA-TEST-RX " MACSTR " " MACSTR "%s", + MAC2STR(eth->ether_dhost), MAC2STR(eth->ether_shost), extra); } @@ -1894,7 +1908,7 @@ static int hostapd_ctrl_iface_data_test_config(struct static int hostapd_ctrl_iface_data_test_tx(struct hostapd_data *hapd, char *cmd) { u8 dst[ETH_ALEN], src[ETH_ALEN]; - char *pos; + char *pos, *pos2; int used; long int val; u8 tos; @@ -1903,11 +1917,12 @@ static int hostapd_ctrl_iface_data_test_tx(struct host struct iphdr *ip; u8 *dpos; unsigned int i; + size_t send_len = HWSIM_IP_LEN; if (hapd->l2_test == NULL) return -1; - /* format: */ + /* format: [len=] */ pos = cmd; used = hwaddr_aton2(pos, dst); @@ -1921,11 +1936,19 @@ static int hostapd_ctrl_iface_data_test_tx(struct host return -1; pos += used; - val = strtol(pos, NULL, 0); + val = strtol(pos, &pos2, 0); if (val < 0 || val > 0xff) return -1; tos = val; + pos = os_strstr(pos2, " len="); + if (pos) { + i = atoi(pos + 5); + if (i < sizeof(*ip) || i > HWSIM_IP_LEN) + return -1; + send_len = i; + } + eth = (struct ether_header *) &buf[2]; os_memcpy(eth->ether_dhost, dst, ETH_ALEN); os_memcpy(eth->ether_shost, src, ETH_ALEN); @@ -1936,17 +1959,17 @@ static int hostapd_ctrl_iface_data_test_tx(struct host ip->version = 4; ip->ttl = 64; ip->tos = tos; - ip->tot_len = htons(HWSIM_IP_LEN); + ip->tot_len = htons(send_len); ip->protocol = 1; ip->saddr = htonl(192U << 24 | 168 << 16 | 1 << 8 | 1); ip->daddr = htonl(192U << 24 | 168 << 16 | 1 << 8 | 2); ip->check = ipv4_hdr_checksum(ip, sizeof(*ip)); dpos = (u8 *) (ip + 1); - for (i = 0; i < HWSIM_IP_LEN - sizeof(*ip); i++) + for (i = 0; i < send_len - sizeof(*ip); i++) *dpos++ = i; if (l2_packet_send(hapd->l2_test, dst, ETHERTYPE_IP, &buf[2], - HWSIM_PACKETLEN) < 0) + sizeof(struct ether_header) + send_len) < 0) return -1; wpa_dbg(hapd->msg_ctx, MSG_DEBUG, "test data: TX dst=" MACSTR Modified: stable/12/contrib/wpa/hostapd/defconfig ============================================================================== --- stable/12/contrib/wpa/hostapd/defconfig Thu Aug 29 18:53:00 2019 (r351610) +++ stable/12/contrib/wpa/hostapd/defconfig Thu Aug 29 19:13:27 2019 (r351611) @@ -108,11 +108,18 @@ CONFIG_EAP_TTLS=y #CONFIG_EAP_GPSK_SHA256=y # EAP-FAST for the integrated EAP server -# Note: If OpenSSL is used as the TLS library, OpenSSL 1.0 or newer is needed -# for EAP-FAST support. Older OpenSSL releases would need to be patched, e.g., -# with openssl-0.9.8x-tls-extensions.patch, to add the needed functions. #CONFIG_EAP_FAST=y +# EAP-TEAP for the integrated EAP server +# Note: The current EAP-TEAP implementation is experimental and should not be +# enabled for production use. The IETF RFC 7170 that defines EAP-TEAP has number +# of conflicting statements and missing details and the implementation has +# vendor specific workarounds for those and as such, may not interoperate with +# any other implementation. This should not be used for anything else than +# experimentation and interoperability testing until those issues has been +# resolved. +#CONFIG_EAP_TEAP=y + # Wi-Fi Protected Setup (WPS) #CONFIG_WPS=y # Enable UPnP support for external WPS Registrars @@ -375,6 +382,9 @@ CONFIG_IPV6=y # Opportunistic Wireless Encryption (OWE) # Experimental implementation of draft-harkins-owe-07.txt #CONFIG_OWE=y + +# Airtime policy support +#CONFIG_AIRTIME_POLICY=y # Override default value for the wpa_disable_eapol_key_retries configuration # parameter. See that parameter in hostapd.conf for more details. Modified: stable/12/contrib/wpa/hostapd/eap_register.c ============================================================================== --- stable/12/contrib/wpa/hostapd/eap_register.c Thu Aug 29 18:53:00 2019 (r351610) +++ stable/12/contrib/wpa/hostapd/eap_register.c Thu Aug 29 19:13:27 2019 (r351611) @@ -121,6 +121,11 @@ int eap_server_register_methods(void) ret = eap_server_fast_register(); #endif /* EAP_SERVER_FAST */ +#ifdef EAP_SERVER_TEAP + if (ret == 0) + ret = eap_server_teap_register(); +#endif /* EAP_SERVER_TEAP */ + #ifdef EAP_SERVER_WSC if (ret == 0) ret = eap_server_wsc_register(); Modified: stable/12/contrib/wpa/hostapd/hostapd.conf ============================================================================== --- stable/12/contrib/wpa/hostapd/hostapd.conf Thu Aug 29 18:53:00 2019 (r351610) +++ stable/12/contrib/wpa/hostapd/hostapd.conf Thu Aug 29 19:13:27 2019 (r351611) @@ -782,10 +782,8 @@ wmm_ac_vo_acm=0 # 1 = supported #he_mu_beamformer=1 -# he_bss_color: BSS color -# 0 = no BSS color (default) -# unsigned integer = BSS color -#he_bss_color=0 +# he_bss_color: BSS color (1-63) +#he_bss_color=1 #he_default_pe_duration: The duration of PE field in an HE PPDU in us # Possible values are 0 us (default), 4 us, 8 us, 12 us, and 16 us @@ -801,6 +799,17 @@ wmm_ac_vo_acm=0 # unsigned integer = duration in units of 16 us #he_rts_threshold=0 +# HE operating channel information; see matching vht_* parameters for details. +#he_oper_chwidth +#he_oper_centr_freq_seg0_idx +#he_oper_centr_freq_seg1_idx + +#he_basic_mcs_nss_set: Basic NSS/MCS set +# 16-bit combination of 2-bit values of Max HE-MCS For 1..8 SS; each 2-bit +# value having following meaning: +# 0 = HE-MCS 0-7, 1 = HE-MCS 0-9, 2 = HE-MCS 0-11, 3 = not supported +#he_basic_mcs_nss_set + #he_mu_edca_qos_info_param_count #he_mu_edca_qos_info_q_ack #he_mu_edca_qos_info_queue_request=1 @@ -825,6 +834,12 @@ wmm_ac_vo_acm=0 #he_mu_edca_ac_vo_ecwmax=15 #he_mu_edca_ac_vo_timer=255 +# Spatial Reuse Parameter Set +#he_spr_sr_control +#he_spr_non_srg_obss_pd_max_offset +#he_spr_srg_obss_pd_min_offset +#he_spr_srg_obss_pd_max_offset + ##### IEEE 802.1X-2004 related configuration ################################## # Require IEEE 802.1X authorization @@ -836,6 +851,8 @@ wmm_ac_vo_acm=0 # the new version number correctly (they seem to drop the frames completely). # In order to make hostapd interoperate with these clients, the version number # can be set to the older version (1) with this configuration value. +# Note: When using MACsec, eapol_version shall be set to 3, which is +# defined in IEEE Std 802.1X-2010. #eapol_version=2 # Optional displayable message sent with EAP Request-Identity. The first \0 @@ -879,6 +896,54 @@ eapol_key_index_workaround=0 # ERP is enabled (eap_server_erp=1). #erp_domain=example.com +##### MACsec ################################################################## + +# macsec_policy: IEEE 802.1X/MACsec options +# This determines how sessions are secured with MACsec (only for MACsec +# drivers). +# 0: MACsec not in use (default) +# 1: MACsec enabled - Should secure, accept key server's advice to +# determine whether to use a secure session or not. +# +# macsec_integ_only: IEEE 802.1X/MACsec transmit mode +# This setting applies only when MACsec is in use, i.e., +# - macsec_policy is enabled +# - the key server has decided to enable MACsec +# 0: Encrypt traffic (default) +# 1: Integrity only +# +# macsec_replay_protect: IEEE 802.1X/MACsec replay protection +# This setting applies only when MACsec is in use, i.e., +# - macsec_policy is enabled +# - the key server has decided to enable MACsec +# 0: Replay protection disabled (default) +# 1: Replay protection enabled +# +# macsec_replay_window: IEEE 802.1X/MACsec replay protection window +# This determines a window in which replay is tolerated, to allow receipt +# of frames that have been misordered by the network. +# This setting applies only when MACsec replay protection active, i.e., +# - macsec_replay_protect is enabled +# - the key server has decided to enable MACsec +# 0: No replay window, strict check (default) +# 1..2^32-1: number of packets that could be misordered +# +# macsec_port: IEEE 802.1X/MACsec port +# Port component of the SCI +# Range: 1-65534 (default: 1) +# +# mka_priority (Priority of MKA Actor) +# Range: 0..255 (default: 255) +# +# mka_cak, mka_ckn, and mka_priority: IEEE 802.1X/MACsec pre-shared key mode +# This allows to configure MACsec with a pre-shared key using a (CAK,CKN) pair. +# In this mode, instances of hostapd can act as MACsec peers. The peer +# with lower priority will become the key server and start distributing SAKs. +# mka_cak (CAK = Secure Connectivity Association Key) takes a 16-byte (128-bit) +# hex-string (32 hex-digits) or a 32-byte (256-bit) hex-string (64 hex-digits) +# mka_ckn (CKN = CAK Name) takes a 1..32-bytes (8..256 bit) hex-string +# (2..64 hex-digits) + ##### Integrated EAP server ################################################### # Optionally, hostapd can be configured to use an integrated EAP server @@ -912,6 +977,23 @@ eap_server=0 # Passphrase for private key #private_key_passwd=secret passphrase +# An alternative server certificate and private key can be configured with the +# following parameters (with values just like the parameters above without the +# '2' suffix). The ca_cert file (in PEM encoding) is used to add the trust roots +# for both server certificates and/or client certificates). +# +# The main use case for this alternative server certificate configuration is to +# enable both RSA and ECC public keys. The server will pick which one to use +# based on the client preferences for the cipher suite (in the TLS ClientHello +# message). It should be noted that number of deployed EAP peer implementations +# do not filter out the cipher suite list based on their local configuration and +# as such, configuration of alternative types of certificates on the server may +# result in interoperability issues. +#server_cert2=/etc/hostapd.server-ecc.pem +#private_key2=/etc/hostapd.server-ecc.prv +#private_key_passwd2=secret passphrase + + # Server identity # EAP methods that provide mechanism for authenticated server identity delivery # use this value. If not set, "hostapd" is used as a default. @@ -1109,10 +1191,27 @@ eap_server=0 # (or fewer) of the lifetime remains. #pac_key_refresh_time=86400 +# EAP-TEAP authentication type +# 0 = inner EAP (default) +# 1 = Basic-Password-Auth +#eap_teap_auth=0 + +# EAP-TEAP authentication behavior when using PAC +# 0 = perform inner authentication (default) +# 1 = skip inner authentication (inner EAP/Basic-Password-Auth) +#eap_teap_pac_no_inner=0 + # EAP-SIM and EAP-AKA protected success/failure indication using AT_RESULT_IND # (default: 0 = disabled). #eap_sim_aka_result_ind=1 +# EAP-SIM and EAP-AKA identity options +# 0 = do not use pseudonyms or fast reauthentication +# 1 = use pseudonyms, but not fast reauthentication +# 2 = do not use pseudonyms, but use fast reauthentication +# 3 = use pseudonyms and use fast reauthentication (default) +#eap_sim_id=3 + # Trusted Network Connect (TNC) # If enabled, TNC validation will be required before the peer is allowed to # connect. Note: This is only used with EAP-TTLS and EAP-FAST. If any other @@ -1292,6 +1391,17 @@ own_ip_addr=127.0.0.1 # Operator-Name = "Operator" #radius_acct_req_attr=126:s:Operator +# If SQLite support is included, path to a database from which additional +# RADIUS request attributes are extracted based on the station MAC address. +# +# The schema for the radius_attributes table is: +# id | sta | reqtype | attr : multi-key (sta, reqtype) +# id = autonumber +# sta = station MAC address in `11:22:33:44:55:66` format. +# type = `auth` | `acct` | NULL (match any) +# attr = existing config file format, e.g. `126:s:Test Operator` +#radius_req_attr_sqlite=radius_attr.sqlite + # Dynamic Authorization Extensions (RFC 5176) # This mechanism can be used to allow dynamic changes to user session based on # commands from a RADIUS server (or some other disconnect client that has the @@ -2491,6 +2601,42 @@ own_ip_addr=127.0.0.1 # as a radio measurement even if the request doesn't contain a max age element # that allows sending of such data. Default: 0. #stationary_ap=0 + +##### Airtime policy configuration ########################################### + +# Set the airtime policy operating mode: +# 0 = disabled (default) +# 1 = static config +# 2 = per-BSS dynamic config +# 3 = per-BSS limit mode +#airtime_mode=0 + +# Interval (in milliseconds) to poll the kernel for updated station activity in +# dynamic and limit modes +#airtime_update_interval=200 + +# Static configuration of station weights (when airtime_mode=1). Kernel default +# weight is 256; set higher for larger airtime share, lower for smaller share. +# Each entry is a MAC address followed by a weight. +#airtime_sta_weight=02:01:02:03:04:05 256 +#airtime_sta_weight=02:01:02:03:04:06 512 + +# Per-BSS airtime weight. In multi-BSS mode, set for each BSS and hostapd will +# configure station weights to enforce the correct ratio between BSS weights +# depending on the number of active stations. The *ratios* between different +# BSSes is what's important, not the absolute numbers. +# Must be set for all BSSes if airtime_mode=2 or 3, has no effect otherwise. +#airtime_bss_weight=1 + +# Whether the current BSS should be limited (when airtime_mode=3). +# +# If set, the BSS weight ratio will be applied in the case where the current BSS +# would exceed the share defined by the BSS weight ratio. E.g., if two BSSes are +# set to the same weights, and one is set to limited, the limited BSS will get +# no more than half the available airtime, but if the non-limited BSS has more +# stations active, that *will* be allowed to exceed its half of the available +# airtime. +#airtime_bss_limit=1 ##### TESTING OPTIONS ######################################################### # Modified: stable/12/contrib/wpa/hostapd/hostapd_cli.c ============================================================================== --- stable/12/contrib/wpa/hostapd/hostapd_cli.c Thu Aug 29 18:53:00 2019 (r351610) +++ stable/12/contrib/wpa/hostapd/hostapd_cli.c Thu Aug 29 19:13:27 2019 (r351611) @@ -1214,6 +1214,13 @@ static int hostapd_cli_cmd_disable(struct wpa_ctrl *ct } +static int hostapd_cli_cmd_update_beacon(struct wpa_ctrl *ctrl, int argc, + char *argv[]) +{ + return wpa_ctrl_command(ctrl, "UPDATE_BEACON"); +} + + static int hostapd_cli_cmd_vendor(struct wpa_ctrl *ctrl, int argc, char *argv[]) { char cmd[256]; @@ -1617,6 +1624,8 @@ static const struct hostapd_cli_cmd hostapd_cli_comman "= reload configuration for current interface" }, { "disable", hostapd_cli_cmd_disable, NULL, "= disable hostapd on current interface" }, + { "update_beacon", hostapd_cli_cmd_update_beacon, NULL, + "= update Beacon frame contents\n"}, { "erp_flush", hostapd_cli_cmd_erp_flush, NULL, "= drop all ERP keys"}, { "log_level", hostapd_cli_cmd_log_level, NULL, Modified: stable/12/contrib/wpa/hostapd/main.c ============================================================================== --- stable/12/contrib/wpa/hostapd/main.c Thu Aug 29 18:53:00 2019 (r351610) +++ stable/12/contrib/wpa/hostapd/main.c Thu Aug 29 19:13:27 2019 (r351611) @@ -653,6 +653,9 @@ int main(int argc, char *argv[]) int start_ifaces_in_sync = 0; char **if_names = NULL; size_t if_names_size = 0; +#ifdef CONFIG_DPP + struct dpp_global_config dpp_conf; +#endif /* CONFIG_DPP */ if (os_program_init()) return -1; @@ -672,7 +675,9 @@ int main(int argc, char *argv[]) dl_list_init(&interfaces.eth_p_oui); #endif /* CONFIG_ETH_P_OUI */ #ifdef CONFIG_DPP - interfaces.dpp = dpp_global_init(); + os_memset(&dpp_conf, 0, sizeof(dpp_conf)); + /* TODO: dpp_conf.msg_ctx? */ + interfaces.dpp = dpp_global_init(&dpp_conf); if (!interfaces.dpp) return -1; #endif /* CONFIG_DPP */ Modified: stable/12/contrib/wpa/hs20/client/osu_client.c ============================================================================== --- stable/12/contrib/wpa/hs20/client/osu_client.c Thu Aug 29 18:53:00 2019 (r351610) +++ stable/12/contrib/wpa/hs20/client/osu_client.c Thu Aug 29 19:13:27 2019 (r351611) @@ -1588,6 +1588,7 @@ static void set_pps_cred_digital_cert(struct hs20_osu_ xml_node_t *node, const char *fqdn) { char buf[200], dir[200]; + int res; wpa_printf(MSG_INFO, "- Credential/DigitalCertificate"); @@ -1599,14 +1600,20 @@ static void set_pps_cred_digital_cert(struct hs20_osu_ wpa_printf(MSG_INFO, "Failed to set username"); } - snprintf(buf, sizeof(buf), "%s/SP/%s/client-cert.pem", dir, fqdn); + res = os_snprintf(buf, sizeof(buf), "%s/SP/%s/client-cert.pem", dir, + fqdn); + if (os_snprintf_error(sizeof(buf), res)) + return; if (os_file_exists(buf)) { if (set_cred_quoted(ctx->ifname, id, "client_cert", buf) < 0) { wpa_printf(MSG_INFO, "Failed to set client_cert"); } } - snprintf(buf, sizeof(buf), "%s/SP/%s/client-key.pem", dir, fqdn); + res = os_snprintf(buf, sizeof(buf), "%s/SP/%s/client-key.pem", dir, + fqdn); + if (os_snprintf_error(sizeof(buf), res)) + return; if (os_file_exists(buf)) { if (set_cred_quoted(ctx->ifname, id, "private_key", buf) < 0) { wpa_printf(MSG_INFO, "Failed to set private_key"); @@ -1620,6 +1627,7 @@ static void set_pps_cred_realm(struct hs20_osu_client { char *str = xml_node_get_text(ctx->xml, node); char buf[200], dir[200]; + int res; if (str == NULL) return; @@ -1634,7 +1642,9 @@ static void set_pps_cred_realm(struct hs20_osu_client if (getcwd(dir, sizeof(dir)) == NULL) return; - snprintf(buf, sizeof(buf), "%s/SP/%s/aaa-ca.pem", dir, fqdn); + res = os_snprintf(buf, sizeof(buf), "%s/SP/%s/aaa-ca.pem", dir, fqdn); + if (os_snprintf_error(sizeof(buf), res)) + return; if (os_file_exists(buf)) { if (set_cred_quoted(ctx->ifname, id, "ca_cert", buf) < 0) { wpa_printf(MSG_INFO, "Failed to set CA cert"); @@ -2717,6 +2727,8 @@ static int cmd_pol_upd(struct hs20_osu_client *ctx, co if (!pps_fname) { char buf[256]; + int res; + wpa_printf(MSG_INFO, "Determining PPS file based on Home SP information"); if (address && os_strncmp(address, "fqdn=", 5) == 0) { wpa_printf(MSG_INFO, "Use requested FQDN from command line"); @@ -2737,8 +2749,13 @@ static int cmd_pol_upd(struct hs20_osu_client *ctx, co "SP/%s/pps.xml", ctx->fqdn); pps_fname = pps_fname_buf; - os_snprintf(ca_fname_buf, sizeof(ca_fname_buf), "SP/%s/ca.pem", - buf); + res = os_snprintf(ca_fname_buf, sizeof(ca_fname_buf), + "SP/%s/ca.pem", buf); + if (os_snprintf_error(sizeof(ca_fname_buf), res)) { + os_free(ctx->fqdn); + ctx->fqdn = NULL; + return -1; + } ca_fname = ca_fname_buf; } Modified: stable/12/contrib/wpa/src/ap/accounting.c ============================================================================== --- stable/12/contrib/wpa/src/ap/accounting.c Thu Aug 29 18:53:00 2019 (r351610) +++ stable/12/contrib/wpa/src/ap/accounting.c Thu Aug 29 19:13:27 2019 (r351611) @@ -97,6 +97,9 @@ static struct radius_msg * accounting_msg(struct hosta msg) < 0) goto fail; + if (sta && add_sqlite_radius_attr(hapd, sta, msg, 1) < 0) + goto fail; + if (sta) { for (i = 0; ; i++) { val = ieee802_1x_get_radius_class(sta->eapol_sm, &len, Modified: stable/12/contrib/wpa/src/ap/acs.c ============================================================================== --- stable/12/contrib/wpa/src/ap/acs.c Thu Aug 29 18:53:00 2019 (r351610) +++ stable/12/contrib/wpa/src/ap/acs.c Thu Aug 29 19:13:27 2019 (r351611) @@ -594,12 +594,12 @@ acs_find_ideal_chan(struct hostapd_iface *iface) iface->conf->secondary_channel) n_chans = 2; - if (iface->conf->ieee80211ac) { - switch (iface->conf->vht_oper_chwidth) { - case VHT_CHANWIDTH_80MHZ: + if (iface->conf->ieee80211ac || iface->conf->ieee80211ax) { + switch (hostapd_get_oper_chwidth(iface->conf)) { + case CHANWIDTH_80MHZ: n_chans = 4; break; - case VHT_CHANWIDTH_160MHZ: + case CHANWIDTH_160MHZ: n_chans = 8; break; } @@ -607,7 +607,7 @@ acs_find_ideal_chan(struct hostapd_iface *iface) bw = num_chan_to_bw(n_chans); - /* TODO: VHT80+80. Update acs_adjust_vht_center_freq() too. */ + /* TODO: VHT/HE80+80. Update acs_adjust_center_freq() too. */ wpa_printf(MSG_DEBUG, "ACS: Survey analysis for selected bandwidth %d MHz", bw); @@ -647,9 +647,9 @@ acs_find_ideal_chan(struct hostapd_iface *iface) } if (iface->current_mode->mode == HOSTAPD_MODE_IEEE80211A && - iface->conf->ieee80211ac) { - if (iface->conf->vht_oper_chwidth == *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-12@freebsd.org Fri Aug 30 17:36:45 2019 Return-Path: Delivered-To: svn-src-stable-12@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 F1490D42F9; Fri, 30 Aug 2019 17:36:45 +0000 (UTC) (envelope-from erj@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 46Kmqx65c2z4LnF; Fri, 30 Aug 2019 17:36:45 +0000 (UTC) (envelope-from erj@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 AE99D3C42; Fri, 30 Aug 2019 17:36:45 +0000 (UTC) (envelope-from erj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x7UHajIe081023; Fri, 30 Aug 2019 17:36:45 GMT (envelope-from erj@FreeBSD.org) Received: (from erj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7UHajvY081022; Fri, 30 Aug 2019 17:36:45 GMT (envelope-from erj@FreeBSD.org) Message-Id: <201908301736.x7UHajvY081022@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: erj set sender to erj@FreeBSD.org using -f From: Eric Joyner Date: Fri, 30 Aug 2019 17:36:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r351627 - stable/12/sys/sys X-SVN-Group: stable-12 X-SVN-Commit-Author: erj X-SVN-Commit-Paths: stable/12/sys/sys X-SVN-Commit-Revision: 351627 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-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Aug 2019 17:36:46 -0000 Author: erj Date: Fri Aug 30 17:36:45 2019 New Revision: 351627 URL: https://svnweb.freebsd.org/changeset/base/351627 Log: Bump __FreeBSD_version number for changes made in r351276 Sponsored by: Intel Corporation Modified: stable/12/sys/sys/param.h Modified: stable/12/sys/sys/param.h ============================================================================== --- stable/12/sys/sys/param.h Fri Aug 30 16:35:31 2019 (r351626) +++ stable/12/sys/sys/param.h Fri Aug 30 17:36:45 2019 (r351627) @@ -60,7 +60,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1200515 /* Master, propagated to newvers */ +#define __FreeBSD_version 1200516 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, From owner-svn-src-stable-12@freebsd.org Sat Aug 31 04:23:27 2019 Return-Path: Delivered-To: svn-src-stable-12@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 76CDAE3463; Sat, 31 Aug 2019 04:23:27 +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 46L3B73Ht5z3yLs; Sat, 31 Aug 2019 04:23:27 +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 50E4CB401; Sat, 31 Aug 2019 04:23:27 +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 x7V4NRxk073840; Sat, 31 Aug 2019 04:23:27 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7V4NQJw073836; Sat, 31 Aug 2019 04:23:26 GMT (envelope-from cy@FreeBSD.org) Message-Id: <201908310423.x7V4NQJw073836@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Sat, 31 Aug 2019 04:23:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r351633 - in stable: 11/contrib/sqlite3 11/contrib/sqlite3/tea 12/contrib/sqlite3 12/contrib/sqlite3/tea X-SVN-Group: stable-12 X-SVN-Commit-Author: cy X-SVN-Commit-Paths: in stable: 11/contrib/sqlite3 11/contrib/sqlite3/tea 12/contrib/sqlite3 12/contrib/sqlite3/tea X-SVN-Commit-Revision: 351633 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-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 31 Aug 2019 04:23:27 -0000 Author: cy Date: Sat Aug 31 04:23:25 2019 New Revision: 351633 URL: https://svnweb.freebsd.org/changeset/base/351633 Log: MFC r350103: MFV r350080: Update sqlite3-3.28.0 (3280000) --> sqlite3-3.29.0 (3290000) Modified: stable/12/contrib/sqlite3/configure stable/12/contrib/sqlite3/configure.ac stable/12/contrib/sqlite3/shell.c stable/12/contrib/sqlite3/sqlite3.c stable/12/contrib/sqlite3/sqlite3.h stable/12/contrib/sqlite3/tea/configure stable/12/contrib/sqlite3/tea/configure.ac Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Modified: stable/11/contrib/sqlite3/configure stable/11/contrib/sqlite3/configure.ac stable/11/contrib/sqlite3/shell.c stable/11/contrib/sqlite3/sqlite3.c stable/11/contrib/sqlite3/sqlite3.h stable/11/contrib/sqlite3/tea/configure stable/11/contrib/sqlite3/tea/configure.ac Directory Properties: stable/11/ (props changed) Modified: stable/12/contrib/sqlite3/configure ============================================================================== --- stable/12/contrib/sqlite3/configure Fri Aug 30 21:54:45 2019 (r351632) +++ stable/12/contrib/sqlite3/configure Sat Aug 31 04:23:25 2019 (r351633) @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for sqlite 3.28.0. +# Generated by GNU Autoconf 2.69 for sqlite 3.29.0. # # Report bugs to . # @@ -590,8 +590,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='sqlite' PACKAGE_TARNAME='sqlite' -PACKAGE_VERSION='3.28.0' -PACKAGE_STRING='sqlite 3.28.0' +PACKAGE_VERSION='3.29.0' +PACKAGE_STRING='sqlite 3.29.0' PACKAGE_BUGREPORT='http://www.sqlite.org' PACKAGE_URL='' @@ -1341,7 +1341,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures sqlite 3.28.0 to adapt to many kinds of systems. +\`configure' configures sqlite 3.29.0 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1412,7 +1412,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of sqlite 3.28.0:";; + short | recursive ) echo "Configuration of sqlite 3.29.0:";; esac cat <<\_ACEOF @@ -1537,7 +1537,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -sqlite configure 3.28.0 +sqlite configure 3.29.0 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -1952,7 +1952,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by sqlite $as_me 3.28.0, which was +It was created by sqlite $as_me 3.29.0, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2818,7 +2818,7 @@ fi # Define the identity of the package. PACKAGE='sqlite' - VERSION='3.28.0' + VERSION='3.29.0' cat >>confdefs.h <<_ACEOF @@ -14438,7 +14438,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by sqlite $as_me 3.28.0, which was +This file was extended by sqlite $as_me 3.29.0, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -14495,7 +14495,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -sqlite config.status 3.28.0 +sqlite config.status 3.29.0 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" Modified: stable/12/contrib/sqlite3/configure.ac ============================================================================== --- stable/12/contrib/sqlite3/configure.ac Fri Aug 30 21:54:45 2019 (r351632) +++ stable/12/contrib/sqlite3/configure.ac Sat Aug 31 04:23:25 2019 (r351633) @@ -10,7 +10,7 @@ # AC_PREREQ(2.61) -AC_INIT(sqlite, 3.28.0, http://www.sqlite.org) +AC_INIT(sqlite, 3.29.0, http://www.sqlite.org) AC_CONFIG_SRCDIR([sqlite3.c]) AC_CONFIG_AUX_DIR([.]) Modified: stable/12/contrib/sqlite3/shell.c ============================================================================== --- stable/12/contrib/sqlite3/shell.c Fri Aug 30 21:54:45 2019 (r351632) +++ stable/12/contrib/sqlite3/shell.c Sat Aug 31 04:23:25 2019 (r351633) @@ -983,6 +983,7 @@ static void shellAddSchemaName( ** We need several support functions from the SQLite core. */ +/* #include "sqlite3.h" */ /* ** We need several things from the ANSI and MSVCRT headers. @@ -1336,6 +1337,7 @@ INT closedir( ** is used. If SIZE is included it must be one of the integers 224, 256, ** 384, or 512, to determine SHA3 hash variant that is computed. */ +/* #include "sqlite3ext.h" */ SQLITE_EXTENSION_INIT1 #include #include @@ -2099,6 +2101,7 @@ int sqlite3_shathree_init( ** And the paths returned in the "name" column of the table are also ** relative to directory $dir. */ +/* #include "sqlite3ext.h" */ SQLITE_EXTENSION_INIT1 #include #include @@ -3056,6 +3059,7 @@ int sqlite3_fileio_init( ** faster than any human can type. ** */ +/* #include "sqlite3ext.h" */ SQLITE_EXTENSION_INIT1 #include #include @@ -3572,6 +3576,7 @@ int sqlite3_completion_init( ** If the file being opened is not an appended database, then this shim is ** a pass-through into the default underlying VFS. **/ +/* #include "sqlite3ext.h" */ SQLITE_EXTENSION_INIT1 #include #include @@ -4228,6 +4233,7 @@ int sqlite3MemTraceDeactivate(void){ ** * No support for zip64 extensions ** * Only the "inflate/deflate" (zlib) compression method is supported */ +/* #include "sqlite3ext.h" */ SQLITE_EXTENSION_INIT1 #include #include @@ -6398,6 +6404,7 @@ int sqlite3_zipfile_init( ** for working with sqlar archives and used by the shell tool's built-in ** sqlar support. */ +/* #include "sqlite3ext.h" */ SQLITE_EXTENSION_INIT1 #include @@ -6520,6 +6527,7 @@ int sqlite3_sqlar_init( */ +/* #include "sqlite3.h" */ typedef struct sqlite3expert sqlite3expert; @@ -6688,6 +6696,7 @@ void sqlite3_expert_destroy(sqlite3expert*); ** ************************************************************************* */ +/* #include "sqlite3expert.h" */ #include #include #include @@ -8631,6 +8640,863 @@ void sqlite3_expert_destroy(sqlite3expert *p){ /************************* End ../ext/expert/sqlite3expert.c ********************/ +#if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_ENABLE_DBPAGE_VTAB) +/************************* Begin ../ext/misc/dbdata.c ******************/ +/* +** 2019-04-17 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +****************************************************************************** +** +** This file contains an implementation of two eponymous virtual tables, +** "sqlite_dbdata" and "sqlite_dbptr". Both modules require that the +** "sqlite_dbpage" eponymous virtual table be available. +** +** SQLITE_DBDATA: +** sqlite_dbdata is used to extract data directly from a database b-tree +** page and its associated overflow pages, bypassing the b-tree layer. +** The table schema is equivalent to: +** +** CREATE TABLE sqlite_dbdata( +** pgno INTEGER, +** cell INTEGER, +** field INTEGER, +** value ANY, +** schema TEXT HIDDEN +** ); +** +** IMPORTANT: THE VIRTUAL TABLE SCHEMA ABOVE IS SUBJECT TO CHANGE. IN THE +** FUTURE NEW NON-HIDDEN COLUMNS MAY BE ADDED BETWEEN "value" AND +** "schema". +** +** Each page of the database is inspected. If it cannot be interpreted as +** a b-tree page, or if it is a b-tree page containing 0 entries, the +** sqlite_dbdata table contains no rows for that page. Otherwise, the +** table contains one row for each field in the record associated with +** each cell on the page. For intkey b-trees, the key value is stored in +** field -1. +** +** For example, for the database: +** +** CREATE TABLE t1(a, b); -- root page is page 2 +** INSERT INTO t1(rowid, a, b) VALUES(5, 'v', 'five'); +** INSERT INTO t1(rowid, a, b) VALUES(10, 'x', 'ten'); +** +** the sqlite_dbdata table contains, as well as from entries related to +** page 1, content equivalent to: +** +** INSERT INTO sqlite_dbdata(pgno, cell, field, value) VALUES +** (2, 0, -1, 5 ), +** (2, 0, 0, 'v' ), +** (2, 0, 1, 'five'), +** (2, 1, -1, 10 ), +** (2, 1, 0, 'x' ), +** (2, 1, 1, 'ten' ); +** +** If database corruption is encountered, this module does not report an +** error. Instead, it attempts to extract as much data as possible and +** ignores the corruption. +** +** SQLITE_DBPTR: +** The sqlite_dbptr table has the following schema: +** +** CREATE TABLE sqlite_dbptr( +** pgno INTEGER, +** child INTEGER, +** schema TEXT HIDDEN +** ); +** +** It contains one entry for each b-tree pointer between a parent and +** child page in the database. +*/ +#if !defined(SQLITEINT_H) +/* #include "sqlite3ext.h" */ + +/* typedef unsigned char u8; */ + +#endif +SQLITE_EXTENSION_INIT1 +#include +#include + +#define DBDATA_PADDING_BYTES 100 + +typedef struct DbdataTable DbdataTable; +typedef struct DbdataCursor DbdataCursor; + +/* Cursor object */ +struct DbdataCursor { + sqlite3_vtab_cursor base; /* Base class. Must be first */ + sqlite3_stmt *pStmt; /* For fetching database pages */ + + int iPgno; /* Current page number */ + u8 *aPage; /* Buffer containing page */ + int nPage; /* Size of aPage[] in bytes */ + int nCell; /* Number of cells on aPage[] */ + int iCell; /* Current cell number */ + int bOnePage; /* True to stop after one page */ + int szDb; + sqlite3_int64 iRowid; + + /* Only for the sqlite_dbdata table */ + u8 *pRec; /* Buffer containing current record */ + int nRec; /* Size of pRec[] in bytes */ + int nHdr; /* Size of header in bytes */ + int iField; /* Current field number */ + u8 *pHdrPtr; + u8 *pPtr; + + sqlite3_int64 iIntkey; /* Integer key value */ +}; + +/* Table object */ +struct DbdataTable { + sqlite3_vtab base; /* Base class. Must be first */ + sqlite3 *db; /* The database connection */ + sqlite3_stmt *pStmt; /* For fetching database pages */ + int bPtr; /* True for sqlite3_dbptr table */ +}; + +/* Column and schema definitions for sqlite_dbdata */ +#define DBDATA_COLUMN_PGNO 0 +#define DBDATA_COLUMN_CELL 1 +#define DBDATA_COLUMN_FIELD 2 +#define DBDATA_COLUMN_VALUE 3 +#define DBDATA_COLUMN_SCHEMA 4 +#define DBDATA_SCHEMA \ + "CREATE TABLE x(" \ + " pgno INTEGER," \ + " cell INTEGER," \ + " field INTEGER," \ + " value ANY," \ + " schema TEXT HIDDEN" \ + ")" + +/* Column and schema definitions for sqlite_dbptr */ +#define DBPTR_COLUMN_PGNO 0 +#define DBPTR_COLUMN_CHILD 1 +#define DBPTR_COLUMN_SCHEMA 2 +#define DBPTR_SCHEMA \ + "CREATE TABLE x(" \ + " pgno INTEGER," \ + " child INTEGER," \ + " schema TEXT HIDDEN" \ + ")" + +/* +** Connect to an sqlite_dbdata (pAux==0) or sqlite_dbptr (pAux!=0) virtual +** table. +*/ +static int dbdataConnect( + sqlite3 *db, + void *pAux, + int argc, const char *const*argv, + sqlite3_vtab **ppVtab, + char **pzErr +){ + DbdataTable *pTab = 0; + int rc = sqlite3_declare_vtab(db, pAux ? DBPTR_SCHEMA : DBDATA_SCHEMA); + + if( rc==SQLITE_OK ){ + pTab = (DbdataTable*)sqlite3_malloc64(sizeof(DbdataTable)); + if( pTab==0 ){ + rc = SQLITE_NOMEM; + }else{ + memset(pTab, 0, sizeof(DbdataTable)); + pTab->db = db; + pTab->bPtr = (pAux!=0); + } + } + + *ppVtab = (sqlite3_vtab*)pTab; + return rc; +} + +/* +** Disconnect from or destroy a sqlite_dbdata or sqlite_dbptr virtual table. +*/ +static int dbdataDisconnect(sqlite3_vtab *pVtab){ + DbdataTable *pTab = (DbdataTable*)pVtab; + if( pTab ){ + sqlite3_finalize(pTab->pStmt); + sqlite3_free(pVtab); + } + return SQLITE_OK; +} + +/* +** This function interprets two types of constraints: +** +** schema=? +** pgno=? +** +** If neither are present, idxNum is set to 0. If schema=? is present, +** the 0x01 bit in idxNum is set. If pgno=? is present, the 0x02 bit +** in idxNum is set. +** +** If both parameters are present, schema is in position 0 and pgno in +** position 1. +*/ +static int dbdataBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdx){ + DbdataTable *pTab = (DbdataTable*)tab; + int i; + int iSchema = -1; + int iPgno = -1; + int colSchema = (pTab->bPtr ? DBPTR_COLUMN_SCHEMA : DBDATA_COLUMN_SCHEMA); + + for(i=0; inConstraint; i++){ + struct sqlite3_index_constraint *p = &pIdx->aConstraint[i]; + if( p->op==SQLITE_INDEX_CONSTRAINT_EQ ){ + if( p->iColumn==colSchema ){ + if( p->usable==0 ) return SQLITE_CONSTRAINT; + iSchema = i; + } + if( p->iColumn==DBDATA_COLUMN_PGNO && p->usable ){ + iPgno = i; + } + } + } + + if( iSchema>=0 ){ + pIdx->aConstraintUsage[iSchema].argvIndex = 1; + pIdx->aConstraintUsage[iSchema].omit = 1; + } + if( iPgno>=0 ){ + pIdx->aConstraintUsage[iPgno].argvIndex = 1 + (iSchema>=0); + pIdx->aConstraintUsage[iPgno].omit = 1; + pIdx->estimatedCost = 100; + pIdx->estimatedRows = 50; + + if( pTab->bPtr==0 && pIdx->nOrderBy && pIdx->aOrderBy[0].desc==0 ){ + int iCol = pIdx->aOrderBy[0].iColumn; + if( pIdx->nOrderBy==1 ){ + pIdx->orderByConsumed = (iCol==0 || iCol==1); + }else if( pIdx->nOrderBy==2 && pIdx->aOrderBy[1].desc==0 && iCol==0 ){ + pIdx->orderByConsumed = (pIdx->aOrderBy[1].iColumn==1); + } + } + + }else{ + pIdx->estimatedCost = 100000000; + pIdx->estimatedRows = 1000000000; + } + pIdx->idxNum = (iSchema>=0 ? 0x01 : 0x00) | (iPgno>=0 ? 0x02 : 0x00); + return SQLITE_OK; +} + +/* +** Open a new sqlite_dbdata or sqlite_dbptr cursor. +*/ +static int dbdataOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){ + DbdataCursor *pCsr; + + pCsr = (DbdataCursor*)sqlite3_malloc64(sizeof(DbdataCursor)); + if( pCsr==0 ){ + return SQLITE_NOMEM; + }else{ + memset(pCsr, 0, sizeof(DbdataCursor)); + pCsr->base.pVtab = pVTab; + } + + *ppCursor = (sqlite3_vtab_cursor *)pCsr; + return SQLITE_OK; +} + +/* +** Restore a cursor object to the state it was in when first allocated +** by dbdataOpen(). +*/ +static void dbdataResetCursor(DbdataCursor *pCsr){ + DbdataTable *pTab = (DbdataTable*)(pCsr->base.pVtab); + if( pTab->pStmt==0 ){ + pTab->pStmt = pCsr->pStmt; + }else{ + sqlite3_finalize(pCsr->pStmt); + } + pCsr->pStmt = 0; + pCsr->iPgno = 1; + pCsr->iCell = 0; + pCsr->iField = 0; + pCsr->bOnePage = 0; + sqlite3_free(pCsr->aPage); + sqlite3_free(pCsr->pRec); + pCsr->pRec = 0; + pCsr->aPage = 0; +} + +/* +** Close an sqlite_dbdata or sqlite_dbptr cursor. +*/ +static int dbdataClose(sqlite3_vtab_cursor *pCursor){ + DbdataCursor *pCsr = (DbdataCursor*)pCursor; + dbdataResetCursor(pCsr); + sqlite3_free(pCsr); + return SQLITE_OK; +} + +/* +** Utility methods to decode 16 and 32-bit big-endian unsigned integers. +*/ +static unsigned int get_uint16(unsigned char *a){ + return (a[0]<<8)|a[1]; +} +static unsigned int get_uint32(unsigned char *a){ + return ((unsigned int)a[0]<<24) + | ((unsigned int)a[1]<<16) + | ((unsigned int)a[2]<<8) + | ((unsigned int)a[3]); +} + +/* +** Load page pgno from the database via the sqlite_dbpage virtual table. +** If successful, set (*ppPage) to point to a buffer containing the page +** data, (*pnPage) to the size of that buffer in bytes and return +** SQLITE_OK. In this case it is the responsibility of the caller to +** eventually free the buffer using sqlite3_free(). +** +** Or, if an error occurs, set both (*ppPage) and (*pnPage) to 0 and +** return an SQLite error code. +*/ +static int dbdataLoadPage( + DbdataCursor *pCsr, /* Cursor object */ + unsigned int pgno, /* Page number of page to load */ + u8 **ppPage, /* OUT: pointer to page buffer */ + int *pnPage /* OUT: Size of (*ppPage) in bytes */ +){ + int rc2; + int rc = SQLITE_OK; + sqlite3_stmt *pStmt = pCsr->pStmt; + + *ppPage = 0; + *pnPage = 0; + sqlite3_bind_int64(pStmt, 2, pgno); + if( SQLITE_ROW==sqlite3_step(pStmt) ){ + int nCopy = sqlite3_column_bytes(pStmt, 0); + if( nCopy>0 ){ + u8 *pPage; + pPage = (u8*)sqlite3_malloc64(nCopy + DBDATA_PADDING_BYTES); + if( pPage==0 ){ + rc = SQLITE_NOMEM; + }else{ + const u8 *pCopy = sqlite3_column_blob(pStmt, 0); + memcpy(pPage, pCopy, nCopy); + memset(&pPage[nCopy], 0, DBDATA_PADDING_BYTES); + } + *ppPage = pPage; + *pnPage = nCopy; + } + } + rc2 = sqlite3_reset(pStmt); + if( rc==SQLITE_OK ) rc = rc2; + + return rc; +} + +/* +** Read a varint. Put the value in *pVal and return the number of bytes. +*/ +static int dbdataGetVarint(const u8 *z, sqlite3_int64 *pVal){ + sqlite3_int64 v = 0; + int i; + for(i=0; i<8; i++){ + v = (v<<7) + (z[i]&0x7f); + if( (z[i]&0x80)==0 ){ *pVal = v; return i+1; } + } + v = (v<<8) + (z[i]&0xff); + *pVal = v; + return 9; +} + +/* +** Return the number of bytes of space used by an SQLite value of type +** eType. +*/ +static int dbdataValueBytes(int eType){ + switch( eType ){ + case 0: case 8: case 9: + case 10: case 11: + return 0; + case 1: + return 1; + case 2: + return 2; + case 3: + return 3; + case 4: + return 4; + case 5: + return 6; + case 6: + case 7: + return 8; + default: + if( eType>0 ){ + return ((eType-12) / 2); + } + return 0; + } +} + +/* +** Load a value of type eType from buffer pData and use it to set the +** result of context object pCtx. +*/ +static void dbdataValue( + sqlite3_context *pCtx, + int eType, + u8 *pData, + int nData +){ + if( eType>=0 && dbdataValueBytes(eType)<=nData ){ + switch( eType ){ + case 0: + case 10: + case 11: + sqlite3_result_null(pCtx); + break; + + case 8: + sqlite3_result_int(pCtx, 0); + break; + case 9: + sqlite3_result_int(pCtx, 1); + break; + + case 1: case 2: case 3: case 4: case 5: case 6: case 7: { + sqlite3_uint64 v = (signed char)pData[0]; + pData++; + switch( eType ){ + case 7: + case 6: v = (v<<16) + (pData[0]<<8) + pData[1]; pData += 2; + case 5: v = (v<<16) + (pData[0]<<8) + pData[1]; pData += 2; + case 4: v = (v<<8) + pData[0]; pData++; + case 3: v = (v<<8) + pData[0]; pData++; + case 2: v = (v<<8) + pData[0]; pData++; + } + + if( eType==7 ){ + double r; + memcpy(&r, &v, sizeof(r)); + sqlite3_result_double(pCtx, r); + }else{ + sqlite3_result_int64(pCtx, (sqlite3_int64)v); + } + break; + } + + default: { + int n = ((eType-12) / 2); + if( eType % 2 ){ + sqlite3_result_text(pCtx, (const char*)pData, n, SQLITE_TRANSIENT); + }else{ + sqlite3_result_blob(pCtx, pData, n, SQLITE_TRANSIENT); + } + } + } + } +} + +/* +** Move an sqlite_dbdata or sqlite_dbptr cursor to the next entry. +*/ +static int dbdataNext(sqlite3_vtab_cursor *pCursor){ + DbdataCursor *pCsr = (DbdataCursor*)pCursor; + DbdataTable *pTab = (DbdataTable*)pCursor->pVtab; + + pCsr->iRowid++; + while( 1 ){ + int rc; + int iOff = (pCsr->iPgno==1 ? 100 : 0); + int bNextPage = 0; + + if( pCsr->aPage==0 ){ + while( 1 ){ + if( pCsr->bOnePage==0 && pCsr->iPgno>pCsr->szDb ) return SQLITE_OK; + rc = dbdataLoadPage(pCsr, pCsr->iPgno, &pCsr->aPage, &pCsr->nPage); + if( rc!=SQLITE_OK ) return rc; + if( pCsr->aPage ) break; + pCsr->iPgno++; + } + pCsr->iCell = pTab->bPtr ? -2 : 0; + pCsr->nCell = get_uint16(&pCsr->aPage[iOff+3]); + } + + if( pTab->bPtr ){ + if( pCsr->aPage[iOff]!=0x02 && pCsr->aPage[iOff]!=0x05 ){ + pCsr->iCell = pCsr->nCell; + } + pCsr->iCell++; + if( pCsr->iCell>=pCsr->nCell ){ + sqlite3_free(pCsr->aPage); + pCsr->aPage = 0; + if( pCsr->bOnePage ) return SQLITE_OK; + pCsr->iPgno++; + }else{ + return SQLITE_OK; + } + }else{ + /* If there is no record loaded, load it now. */ + if( pCsr->pRec==0 ){ + int bHasRowid = 0; + int nPointer = 0; + sqlite3_int64 nPayload = 0; + sqlite3_int64 nHdr = 0; + int iHdr; + int U, X; + int nLocal; + + switch( pCsr->aPage[iOff] ){ + case 0x02: + nPointer = 4; + break; + case 0x0a: + break; + case 0x0d: + bHasRowid = 1; + break; + default: + /* This is not a b-tree page with records on it. Continue. */ + pCsr->iCell = pCsr->nCell; + break; + } + + if( pCsr->iCell>=pCsr->nCell ){ + bNextPage = 1; + }else{ + + iOff += 8 + nPointer + pCsr->iCell*2; + if( iOff>pCsr->nPage ){ + bNextPage = 1; + }else{ + iOff = get_uint16(&pCsr->aPage[iOff]); + } + + /* For an interior node cell, skip past the child-page number */ + iOff += nPointer; + + /* Load the "byte of payload including overflow" field */ + if( bNextPage || iOff>pCsr->nPage ){ + bNextPage = 1; + }else{ + iOff += dbdataGetVarint(&pCsr->aPage[iOff], &nPayload); + } + + /* If this is a leaf intkey cell, load the rowid */ + if( bHasRowid && !bNextPage && iOffnPage ){ + iOff += dbdataGetVarint(&pCsr->aPage[iOff], &pCsr->iIntkey); + } + + /* Figure out how much data to read from the local page */ + U = pCsr->nPage; + if( bHasRowid ){ + X = U-35; + }else{ + X = ((U-12)*64/255)-23; + } + if( nPayload<=X ){ + nLocal = nPayload; + }else{ + int M, K; + M = ((U-12)*32/255)-23; + K = M+((nPayload-M)%(U-4)); + if( K<=X ){ + nLocal = K; + }else{ + nLocal = M; + } + } + + if( bNextPage || nLocal+iOff>pCsr->nPage ){ + bNextPage = 1; + }else{ + + /* Allocate space for payload. And a bit more to catch small buffer + ** overruns caused by attempting to read a varint or similar from + ** near the end of a corrupt record. */ + pCsr->pRec = (u8*)sqlite3_malloc64(nPayload+DBDATA_PADDING_BYTES); + if( pCsr->pRec==0 ) return SQLITE_NOMEM; + memset(pCsr->pRec, 0, nPayload+DBDATA_PADDING_BYTES); + pCsr->nRec = nPayload; + + /* Load the nLocal bytes of payload */ + memcpy(pCsr->pRec, &pCsr->aPage[iOff], nLocal); + iOff += nLocal; + + /* Load content from overflow pages */ + if( nPayload>nLocal ){ + sqlite3_int64 nRem = nPayload - nLocal; + unsigned int pgnoOvfl = get_uint32(&pCsr->aPage[iOff]); + while( nRem>0 ){ + u8 *aOvfl = 0; + int nOvfl = 0; + int nCopy; + rc = dbdataLoadPage(pCsr, pgnoOvfl, &aOvfl, &nOvfl); + assert( rc!=SQLITE_OK || aOvfl==0 || nOvfl==pCsr->nPage ); + if( rc!=SQLITE_OK ) return rc; + if( aOvfl==0 ) break; + + nCopy = U-4; + if( nCopy>nRem ) nCopy = nRem; + memcpy(&pCsr->pRec[nPayload-nRem], &aOvfl[4], nCopy); + nRem -= nCopy; + + pgnoOvfl = get_uint32(aOvfl); + sqlite3_free(aOvfl); + } + } + + iHdr = dbdataGetVarint(pCsr->pRec, &nHdr); + pCsr->nHdr = nHdr; + pCsr->pHdrPtr = &pCsr->pRec[iHdr]; + pCsr->pPtr = &pCsr->pRec[pCsr->nHdr]; + pCsr->iField = (bHasRowid ? -1 : 0); + } + } + }else{ + pCsr->iField++; + if( pCsr->iField>0 ){ + sqlite3_int64 iType; + if( pCsr->pHdrPtr>&pCsr->pRec[pCsr->nRec] ){ + bNextPage = 1; + }else{ + pCsr->pHdrPtr += dbdataGetVarint(pCsr->pHdrPtr, &iType); + pCsr->pPtr += dbdataValueBytes(iType); + } + } + } + + if( bNextPage ){ + sqlite3_free(pCsr->aPage); + sqlite3_free(pCsr->pRec); + pCsr->aPage = 0; + pCsr->pRec = 0; + if( pCsr->bOnePage ) return SQLITE_OK; + pCsr->iPgno++; + }else{ + if( pCsr->iField<0 || pCsr->pHdrPtr<&pCsr->pRec[pCsr->nHdr] ){ + return SQLITE_OK; + } + + /* Advance to the next cell. The next iteration of the loop will load + ** the record and so on. */ + sqlite3_free(pCsr->pRec); + pCsr->pRec = 0; + pCsr->iCell++; + } + } + } + + assert( !"can't get here" ); + return SQLITE_OK; +} + +/* +** Return true if the cursor is at EOF. +*/ +static int dbdataEof(sqlite3_vtab_cursor *pCursor){ + DbdataCursor *pCsr = (DbdataCursor*)pCursor; + return pCsr->aPage==0; +} + +/* +** Determine the size in pages of database zSchema (where zSchema is +** "main", "temp" or the name of an attached database) and set +** pCsr->szDb accordingly. If successful, return SQLITE_OK. Otherwise, +** an SQLite error code. +*/ +static int dbdataDbsize(DbdataCursor *pCsr, const char *zSchema){ + DbdataTable *pTab = (DbdataTable*)pCsr->base.pVtab; + char *zSql = 0; + int rc, rc2; + sqlite3_stmt *pStmt = 0; + + zSql = sqlite3_mprintf("PRAGMA %Q.page_count", zSchema); + if( zSql==0 ) return SQLITE_NOMEM; + rc = sqlite3_prepare_v2(pTab->db, zSql, -1, &pStmt, 0); + sqlite3_free(zSql); + if( rc==SQLITE_OK && sqlite3_step(pStmt)==SQLITE_ROW ){ + pCsr->szDb = sqlite3_column_int(pStmt, 0); + } + rc2 = sqlite3_finalize(pStmt); + if( rc==SQLITE_OK ) rc = rc2; + return rc; +} + +/* +** xFilter method for sqlite_dbdata and sqlite_dbptr. +*/ +static int dbdataFilter( + sqlite3_vtab_cursor *pCursor, + int idxNum, const char *idxStr, + int argc, sqlite3_value **argv +){ + DbdataCursor *pCsr = (DbdataCursor*)pCursor; + DbdataTable *pTab = (DbdataTable*)pCursor->pVtab; + int rc = SQLITE_OK; + const char *zSchema = "main"; + + dbdataResetCursor(pCsr); + assert( pCsr->iPgno==1 ); + if( idxNum & 0x01 ){ + zSchema = (const char*)sqlite3_value_text(argv[0]); + } + if( idxNum & 0x02 ){ + pCsr->iPgno = sqlite3_value_int(argv[(idxNum & 0x01)]); + pCsr->bOnePage = 1; + }else{ + pCsr->nPage = dbdataDbsize(pCsr, zSchema); + rc = dbdataDbsize(pCsr, zSchema); + } + + if( rc==SQLITE_OK ){ + if( pTab->pStmt ){ + pCsr->pStmt = pTab->pStmt; + pTab->pStmt = 0; + }else{ + rc = sqlite3_prepare_v2(pTab->db, + "SELECT data FROM sqlite_dbpage(?) WHERE pgno=?", -1, + &pCsr->pStmt, 0 + ); + } + } + if( rc==SQLITE_OK ){ + rc = sqlite3_bind_text(pCsr->pStmt, 1, zSchema, -1, SQLITE_TRANSIENT); + }else{ + pTab->base.zErrMsg = sqlite3_mprintf("%s", sqlite3_errmsg(pTab->db)); + } + if( rc==SQLITE_OK ){ + rc = dbdataNext(pCursor); + } + return rc; +} + +/* +** Return a column for the sqlite_dbdata or sqlite_dbptr table. +*/ +static int dbdataColumn( + sqlite3_vtab_cursor *pCursor, + sqlite3_context *ctx, + int i +){ + DbdataCursor *pCsr = (DbdataCursor*)pCursor; + DbdataTable *pTab = (DbdataTable*)pCursor->pVtab; + if( pTab->bPtr ){ + switch( i ){ + case DBPTR_COLUMN_PGNO: + sqlite3_result_int64(ctx, pCsr->iPgno); + break; + case DBPTR_COLUMN_CHILD: { + int iOff = pCsr->iPgno==1 ? 100 : 0; + if( pCsr->iCell<0 ){ + iOff += 8; + }else{ + iOff += 12 + pCsr->iCell*2; + if( iOff>pCsr->nPage ) return SQLITE_OK; + iOff = get_uint16(&pCsr->aPage[iOff]); + } + if( iOff<=pCsr->nPage ){ + sqlite3_result_int64(ctx, get_uint32(&pCsr->aPage[iOff])); + } + break; + } + } + }else{ + switch( i ){ + case DBDATA_COLUMN_PGNO: + sqlite3_result_int64(ctx, pCsr->iPgno); + break; + case DBDATA_COLUMN_CELL: + sqlite3_result_int(ctx, pCsr->iCell); + break; + case DBDATA_COLUMN_FIELD: + sqlite3_result_int(ctx, pCsr->iField); + break; + case DBDATA_COLUMN_VALUE: { + if( pCsr->iField<0 ){ + sqlite3_result_int64(ctx, pCsr->iIntkey); + }else{ + sqlite3_int64 iType; + dbdataGetVarint(pCsr->pHdrPtr, &iType); + dbdataValue( + ctx, iType, pCsr->pPtr, &pCsr->pRec[pCsr->nRec] - pCsr->pPtr + ); + } + break; + } + } + } + return SQLITE_OK; +} + +/* +** Return the rowid for an sqlite_dbdata or sqlite_dptr table. +*/ +static int dbdataRowid(sqlite3_vtab_cursor *pCursor, sqlite_int64 *pRowid){ + DbdataCursor *pCsr = (DbdataCursor*)pCursor; + *pRowid = pCsr->iRowid; + return SQLITE_OK; +} + + +/* +** Invoke this routine to register the "sqlite_dbdata" virtual table module +*/ +static int sqlite3DbdataRegister(sqlite3 *db){ + static sqlite3_module dbdata_module = { + 0, /* iVersion */ + 0, /* xCreate */ + dbdataConnect, /* xConnect */ + dbdataBestIndex, /* xBestIndex */ + dbdataDisconnect, /* xDisconnect */ + 0, /* xDestroy */ + dbdataOpen, /* xOpen - open a cursor */ + dbdataClose, /* xClose - close a cursor */ + dbdataFilter, /* xFilter - configure scan constraints */ + dbdataNext, /* xNext - advance a cursor */ + dbdataEof, /* xEof - check for end of scan */ + dbdataColumn, /* xColumn - read data */ + dbdataRowid, /* xRowid - read data */ + 0, /* xUpdate */ + 0, /* xBegin */ + 0, /* xSync */ + 0, /* xCommit */ + 0, /* xRollback */ *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-12@freebsd.org Sat Aug 31 04:25:36 2019 Return-Path: Delivered-To: svn-src-stable-12@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 D91F2E3589; Sat, 31 Aug 2019 04:25: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 46L3Dc42xjz3yc6; Sat, 31 Aug 2019 04:25: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 6CB4FB408; Sat, 31 Aug 2019 04:25: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 x7V4Pa6R074009; Sat, 31 Aug 2019 04:25:36 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7V4Pacf074008; Sat, 31 Aug 2019 04:25:36 GMT (envelope-from cy@FreeBSD.org) Message-Id: <201908310425.x7V4Pacf074008@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Sat, 31 Aug 2019 04:25:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r351634 - in stable: 11/sys/contrib/ipfilter/netinet 12/sys/contrib/ipfilter/netinet X-SVN-Group: stable-12 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: 351634 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-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 31 Aug 2019 04:25:36 -0000 Author: cy Date: Sat Aug 31 04:25:35 2019 New Revision: 351634 URL: https://svnweb.freebsd.org/changeset/base/351634 Log: MFC r351561: Fixup typo in comment. Obtained from: NetBSD ip_nat.c r1.7 Modified: stable/12/sys/contrib/ipfilter/netinet/ip_nat.c Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Modified: stable/11/sys/contrib/ipfilter/netinet/ip_nat.c Directory Properties: stable/11/ (props changed) Modified: stable/12/sys/contrib/ipfilter/netinet/ip_nat.c ============================================================================== --- stable/12/sys/contrib/ipfilter/netinet/ip_nat.c Sat Aug 31 04:23:25 2019 (r351633) +++ stable/12/sys/contrib/ipfilter/netinet/ip_nat.c Sat Aug 31 04:25:35 2019 (r351634) @@ -3073,7 +3073,7 @@ ipf_nat_newrdr(fin, nat, ni) /* Attempts to create a new NAT entry. Does not actually change the packet */ /* in any way. */ /* */ -/* This fucntion is in three main parts: (1) deal with creating a new NAT */ +/* This function is in three main parts: (1) deal with creating a new NAT */ /* structure for a "MAP" rule (outgoing NAT translation); (2) deal with */ /* creating a new NAT structure for a "RDR" rule (incoming NAT translation) */ /* and (3) building that structure and putting it into the NAT table(s). */ From owner-svn-src-stable-12@freebsd.org Sat Aug 31 04:27:01 2019 Return-Path: Delivered-To: svn-src-stable-12@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 21E57E36BC; Sat, 31 Aug 2019 04:27:01 +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 46L3GD2Vz4z3yrX; Sat, 31 Aug 2019 04:27:00 +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 E11BBB40C; Sat, 31 Aug 2019 04:26:59 +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 x7V4Qx4a074144; Sat, 31 Aug 2019 04:26:59 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7V4Qx1m074143; Sat, 31 Aug 2019 04:26:59 GMT (envelope-from cy@FreeBSD.org) Message-Id: <201908310426.x7V4Qx1m074143@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Sat, 31 Aug 2019 04:26:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r351635 - in stable: 11/sys/contrib/ipfilter/netinet 12/sys/contrib/ipfilter/netinet X-SVN-Group: stable-12 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: 351635 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-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 31 Aug 2019 04:27:01 -0000 Author: cy Date: Sat Aug 31 04:26:59 2019 New Revision: 351635 URL: https://svnweb.freebsd.org/changeset/base/351635 Log: MFC r351562: Destroy the mutex in case of error. Obtained from: NetBSD ip_nat.c r1.7 Modified: stable/12/sys/contrib/ipfilter/netinet/ip_nat.c Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Modified: stable/11/sys/contrib/ipfilter/netinet/ip_nat.c Directory Properties: stable/11/ (props changed) Modified: stable/12/sys/contrib/ipfilter/netinet/ip_nat.c ============================================================================== --- stable/12/sys/contrib/ipfilter/netinet/ip_nat.c Sat Aug 31 04:25:35 2019 (r351634) +++ stable/12/sys/contrib/ipfilter/netinet/ip_nat.c Sat Aug 31 04:26:59 2019 (r351635) @@ -3078,7 +3078,7 @@ ipf_nat_newrdr(fin, nat, ni) /* creating a new NAT structure for a "RDR" rule (incoming NAT translation) */ /* and (3) building that structure and putting it into the NAT table(s). */ /* */ -/* NOTE: natsave should NOT be used top point back to an ipstate_t struct */ +/* NOTE: natsave should NOT be used to point back to an ipstate_t struct */ /* as it can result in memory being corrupted. */ /* ------------------------------------------------------------------------ */ nat_t * @@ -3406,6 +3406,7 @@ ipf_nat_insert(softc, softn, nat) u_int hv0, hv1; u_int sp, dp; ipnat_t *in; + int ret; /* * Try and return an error as early as possible, so calculate the hash @@ -3488,7 +3489,10 @@ ipf_nat_insert(softc, softn, nat) nat->nat_mtu[1] = GETIFMTU_4(nat->nat_ifps[1]); } - return ipf_nat_hashtab_add(softc, softn, nat); + ret = ipf_nat_hashtab_add(softc, softn, nat); + if (ret == -1) + MUTEX_DESTROY(&nat->nat_lock); + return ret; } From owner-svn-src-stable-12@freebsd.org Sat Aug 31 04:28:23 2019 Return-Path: Delivered-To: svn-src-stable-12@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 CDAF8E379C; Sat, 31 Aug 2019 04:28:23 +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 46L3Hq4z6Qz405g; Sat, 31 Aug 2019 04:28:23 +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 8A5DFB40E; Sat, 31 Aug 2019 04:28:23 +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 x7V4SNKq074257; Sat, 31 Aug 2019 04:28:23 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7V4SNeQ074256; Sat, 31 Aug 2019 04:28:23 GMT (envelope-from cy@FreeBSD.org) Message-Id: <201908310428.x7V4SNeQ074256@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Sat, 31 Aug 2019 04:28:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r351636 - in stable: 11/sys/contrib/ipfilter/netinet 12/sys/contrib/ipfilter/netinet X-SVN-Group: stable-12 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: 351636 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-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 31 Aug 2019 04:28:23 -0000 Author: cy Date: Sat Aug 31 04:28:22 2019 New Revision: 351636 URL: https://svnweb.freebsd.org/changeset/base/351636 Log: MFC r351563: Document ipf_nat_hashtab_add() return codes. Modified: stable/12/sys/contrib/ipfilter/netinet/ip_nat.c Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Modified: stable/11/sys/contrib/ipfilter/netinet/ip_nat.c Directory Properties: stable/11/ (props changed) Modified: stable/12/sys/contrib/ipfilter/netinet/ip_nat.c ============================================================================== --- stable/12/sys/contrib/ipfilter/netinet/ip_nat.c Sat Aug 31 04:26:59 2019 (r351635) +++ stable/12/sys/contrib/ipfilter/netinet/ip_nat.c Sat Aug 31 04:28:22 2019 (r351636) @@ -3498,6 +3498,7 @@ ipf_nat_insert(softc, softn, nat) /* ------------------------------------------------------------------------ */ /* Function: ipf_nat_hashtab_add */ +/* Returns: int - 0 == sucess, -1 == failure */ /* Parameters: softc(I) - pointer to soft context main structure */ /* softn(I) - pointer to NAT context structure */ /* nat(I) - pointer to NAT structure */ From owner-svn-src-stable-12@freebsd.org Sat Aug 31 08:40:42 2019 Return-Path: Delivered-To: svn-src-stable-12@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 40C7ECAA95; Sat, 31 Aug 2019 08:40:42 +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 46L8ty14Yyz4Fmm; Sat, 31 Aug 2019 08:40:42 +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 08491E361; Sat, 31 Aug 2019 08:40:42 +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 x7V8efMC027032; Sat, 31 Aug 2019 08:40:41 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7V8efJU027031; Sat, 31 Aug 2019 08:40:41 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201908310840.x7V8efJU027031@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sat, 31 Aug 2019 08:40:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r351639 - stable/12/sys/vm X-SVN-Group: stable-12 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/12/sys/vm X-SVN-Commit-Revision: 351639 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-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 31 Aug 2019 08:40:42 -0000 Author: kib Date: Sat Aug 31 08:40:41 2019 New Revision: 351639 URL: https://svnweb.freebsd.org/changeset/base/351639 Log: MFC r351453: Make stack grow use the same gap as stack create. Modified: stable/12/sys/vm/vm_map.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/vm/vm_map.c ============================================================================== --- stable/12/sys/vm/vm_map.c Sat Aug 31 08:18:49 2019 (r351638) +++ stable/12/sys/vm/vm_map.c Sat Aug 31 08:40:41 2019 (r351639) @@ -4156,8 +4156,20 @@ vm_map_stack_locked(vm_map_t map, vm_offset_t addrbos, rv = vm_map_insert(map, NULL, 0, gap_bot, gap_top, VM_PROT_NONE, VM_PROT_NONE, MAP_CREATE_GUARD | (orient == MAP_STACK_GROWS_DOWN ? MAP_CREATE_STACK_GAP_DN : MAP_CREATE_STACK_GAP_UP)); - if (rv != KERN_SUCCESS) + if (rv == KERN_SUCCESS) { + /* + * Gap can never successfully handle a fault, so + * read-ahead logic is never used for it. Re-use + * next_read of the gap entry to store + * stack_guard_page for vm_map_growstack(). + */ + if (orient == MAP_STACK_GROWS_DOWN) + new_entry->prev->next_read = sgp; + else + new_entry->next->next_read = sgp; + } else { (void)vm_map_delete(map, bot, top); + } return (rv); } @@ -4198,7 +4210,6 @@ vm_map_growstack(vm_map_t map, vm_offset_t addr, vm_ma MPASS(!map->system_map); - guard = stack_guard_page * PAGE_SIZE; lmemlim = lim_cur(curthread, RLIMIT_MEMLOCK); stacklim = lim_cur(curthread, RLIMIT_STACK); vmemlim = lim_cur(curthread, RLIMIT_VMEM); @@ -4225,6 +4236,7 @@ retry: } else { return (KERN_FAILURE); } + guard = gap_entry->next_read; max_grow = gap_entry->end - gap_entry->start; if (guard > max_grow) return (KERN_NO_SPACE);