Re: svn commit: r305821 - head/usr.bin/login

2016-09-14 Thread Bruce Evans

On Thu, 15 Sep 2016, Ed Maste wrote:


Log:
 login: clean up errx strings

 errx() prefixes the error string with argv[0] so including "login: "
 in the string is redundant. Also remove a superfluous newline.


The strings still have plenty of dirt:


Modified: head/usr.bin/login/login_audit.c
==
--- head/usr.bin/login/login_audit.cWed Sep 14 23:24:23 2016
(r305820)
+++ head/usr.bin/login/login_audit.cThu Sep 15 01:55:18 2016
(r305821)
@@ -73,14 +73,14 @@ au_login_success(void)
if (auditon(A_GETCOND, _cond, sizeof(au_cond)) < 0) {
if (errno == ENOSYS)
return;
-   errx(1, "login: Could not determine audit condition");
+   errx(1, "Could not determine audit condition");


Capitalization.  Error messages are conventionally not capitalized
(but strerror() strings break this).  This file does this in many
more places, but not all.


@@ -88,22 +88,22 @@ au_login_success(void)
bcopy(, _termid, sizeof(auinfo.ai_termid));
bcopy(, _mask, sizeof(auinfo.ai_mask));
if (setaudit() != 0)
-   err(1, "login: setaudit failed");
+   err(1, "setaudit failed");


Example of normal style for an error message.  Should possibly indicate
that it was a specific function/syscall that failed by marking up the
function with "()".



if ((aufd = au_open()) == -1)
-   errx(1,"login: Audit Error: au_open() failed");
+   errx(1, "Audit Error: au_open() failed");


This marks up the function and adds the doubly Capitalized spam
"Audit Error: ".  Who would have thought that an error message is for
an error?  "Audit " is not as redundant as that, but is not used in
all of the messages.

Since this uses errx() and not err(), a different style is justified,
but it is probably wrong to not use strerror() when a function/syscall
name is printed.  The "failed" part of the message is nondescript.



if ((tok = au_to_subject32(uid, geteuid(), getegid(), uid, gid, pid,
pid, )) == NULL)
-   errx(1, "login: Audit Error: au_to_subject32() failed");
+   errx(1, "Audit Error: au_to_subject32() failed");
au_write(aufd, tok);

if ((tok = au_to_return32(0, 0)) == NULL)
-   errx(1, "login: Audit Error: au_to_return32() failed");
+   errx(1, "Audit Error: au_to_return32() failed");
au_write(aufd, tok);


Spam continues.  The function name is a bit too long to print.



if (au_close(aufd, 1, AUE_login) == -1)
-   errx(1, "login: Audit Record was not committed.");
+   errx(1, "Audit Record was not committed.");
}


Now "Audit Record" is useful because the function name is not printed.
Not printing the function name is a different and perhaps better style.
I usually print the function name when I don't want to think about a
better discription.

Error messages are conventionally not capitalized, and most in this file
are not. but this one is.



/*
@@ -124,13 +124,13 @@ au_login_fail(const char *errmsg, int na
if (auditon(A_GETCOND, _cond, sizeof(au_cond)) < 0) {
if (errno == ENOSYS)
return;
-   errx(1, "login: Could not determine audit condition");
+   errx(1, "Could not determine audit condition");
}


Back to only 1 capitialization error.


if (au_cond == AUC_NOAUDIT)
return;

if ((aufd = au_open()) == -1)
-   errx(1, "login: Audit Error: au_open() failed");
+   errx(1, "Audit Error: au_open() failed");


Back to spam.



if (na) {
/*
@@ -139,28 +139,28 @@ au_login_fail(const char *errmsg, int na
 */
if ((tok = au_to_subject32(-1, geteuid(), getegid(), -1, -1,
pid, -1, )) == NULL)
-   errx(1, "login: Audit Error: au_to_subject32() failed");
+   errx(1, "Audit Error: au_to_subject32() failed");
} else {
/* We know the subject -- so use its value instead. */
uid = pwd->pw_uid;
gid = pwd->pw_gid;
if ((tok = au_to_subject32(uid, geteuid(), getegid(), uid,
gid, pid, pid, )) == NULL)
-   errx(1, "login: Audit Error: au_to_subject32() failed");
+   errx(1, "Audit Error: au_to_subject32() failed");
...


The general style reduces to "error: xxx failed [duh]" with careful use
of errx() instead of err() to prevent leakage of useful information.

Bruce
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r305823 - head/usr.bin/sdiff

2016-09-14 Thread Ed Maste
Author: emaste
Date: Thu Sep 15 02:48:56 2016
New Revision: 305823
URL: https://svnweb.freebsd.org/changeset/base/305823

Log:
  sdiff: improve errx string
  
  errx() appends a newline so \n is superfluous. Also switch to lower case
  with no period for consistency with other errx strings.

Modified:
  head/usr.bin/sdiff/sdiff.c

Modified: head/usr.bin/sdiff/sdiff.c
==
--- head/usr.bin/sdiff/sdiff.c  Thu Sep 15 01:58:12 2016(r305822)
+++ head/usr.bin/sdiff/sdiff.c  Thu Sep 15 02:48:56 2016(r305823)
@@ -488,7 +488,7 @@ binexec(char *diffprog, char *f1, char *
execv(diffprog, args);
 
/* If execv() fails, sdiff's execution will continue below. */
-   errx(1, "Could not execute diff process.\n");
+   errx(1, "could not execute diff process");
 }
 
 /*
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r305822 - head/usr.bin/bsdiff/bspatch

2016-09-14 Thread Ed Maste
Author: emaste
Date: Thu Sep 15 01:58:12 2016
New Revision: 305822
URL: https://svnweb.freebsd.org/changeset/base/305822

Log:
  bspatch: use #define for header size instead of magic number
  
  Reviewed by:  allanjude, kib
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D7861

Modified:
  head/usr.bin/bsdiff/bspatch/bspatch.c

Modified: head/usr.bin/bsdiff/bspatch/bspatch.c
==
--- head/usr.bin/bsdiff/bspatch/bspatch.c   Thu Sep 15 01:55:18 2016
(r305821)
+++ head/usr.bin/bsdiff/bspatch/bspatch.c   Thu Sep 15 01:58:12 2016
(r305822)
@@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -52,6 +53,7 @@ __FBSDID("$FreeBSD$");
 #ifndef O_BINARY
 #define O_BINARY 0
 #endif
+#define HEADER_SIZE 32
 
 static char *newfile;
 static int dirfd = -1;
@@ -101,12 +103,11 @@ int main(int argc, char *argv[])
int newfd, oldfd;
off_t oldsize, newsize;
off_t bzctrllen, bzdatalen;
-   u_char header[32], buf[8];
+   u_char header[HEADER_SIZE], buf[8];
u_char *old, *new;
off_t oldpos, newpos;
off_t ctrl[3];
-   off_t lenread;
-   off_t i;
+   off_t i, lenread, offset;
 #ifdef HAVE_CAPSICUM
cap_rights_t rights_dir, rights_ro, rights_wr;
 #endif
@@ -181,7 +182,7 @@ int main(int argc, char *argv[])
*/
 
/* Read header */
-   if (fread(header, 1, 32, f) < 32) {
+   if (fread(header, 1, HEADER_SIZE, f) < HEADER_SIZE) {
if (feof(f))
errx(1, "Corrupt patch");
err(1, "fread(%s)", argv[3]);
@@ -195,27 +196,27 @@ int main(int argc, char *argv[])
bzctrllen = offtin(header + 8);
bzdatalen = offtin(header + 16);
newsize = offtin(header + 24);
-   if (bzctrllen < 0 || bzctrllen > OFF_MAX - 32 ||
-   bzdatalen < 0 || bzctrllen + 32 > OFF_MAX - bzdatalen ||
+   if (bzctrllen < 0 || bzctrllen > OFF_MAX - HEADER_SIZE ||
+   bzdatalen < 0 || bzctrllen + HEADER_SIZE > OFF_MAX - bzdatalen ||
newsize < 0 || newsize > SSIZE_MAX)
errx(1, "Corrupt patch");
 
/* Close patch file and re-open it via libbzip2 at the right places */
if (fclose(f))
err(1, "fclose(%s)", argv[3]);
-   if (fseeko(cpf, 32, SEEK_SET))
-   err(1, "fseeko(%s, %lld)", argv[3],
-   (long long)32);
+   offset = HEADER_SIZE;
+   if (fseeko(cpf, offset, SEEK_SET))
+   err(1, "fseeko(%s, %jd)", argv[3], (intmax_t)offset);
if ((cpfbz2 = BZ2_bzReadOpen(, cpf, 0, 0, NULL, 0)) == NULL)
errx(1, "BZ2_bzReadOpen, bz2err = %d", cbz2err);
-   if (fseeko(dpf, 32 + bzctrllen, SEEK_SET))
-   err(1, "fseeko(%s, %lld)", argv[3],
-   (long long)(32 + bzctrllen));
+   offset += bzctrllen;
+   if (fseeko(dpf, offset, SEEK_SET))
+   err(1, "fseeko(%s, %jd)", argv[3], (intmax_t)offset);
if ((dpfbz2 = BZ2_bzReadOpen(, dpf, 0, 0, NULL, 0)) == NULL)
errx(1, "BZ2_bzReadOpen, bz2err = %d", dbz2err);
-   if (fseeko(epf, 32 + bzctrllen + bzdatalen, SEEK_SET))
-   err(1, "fseeko(%s, %lld)", argv[3],
-   (long long)(32 + bzctrllen + bzdatalen));
+   offset += bzdatalen;
+   if (fseeko(epf, offset, SEEK_SET))
+   err(1, "fseeko(%s, %jd)", argv[3], (intmax_t)offset);
if ((epfbz2 = BZ2_bzReadOpen(, epf, 0, 0, NULL, 0)) == NULL)
errx(1, "BZ2_bzReadOpen, bz2err = %d", ebz2err);
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r305821 - head/usr.bin/login

2016-09-14 Thread Ed Maste
Author: emaste
Date: Thu Sep 15 01:55:18 2016
New Revision: 305821
URL: https://svnweb.freebsd.org/changeset/base/305821

Log:
  login: clean up errx strings
  
  errx() prefixes the error string with argv[0] so including "login: "
  in the string is redundant. Also remove a superfluous newline.
  
  Sponsored by: The FreeBSD Foundation

Modified:
  head/usr.bin/login/login_audit.c

Modified: head/usr.bin/login/login_audit.c
==
--- head/usr.bin/login/login_audit.cWed Sep 14 23:24:23 2016
(r305820)
+++ head/usr.bin/login/login_audit.cThu Sep 15 01:55:18 2016
(r305821)
@@ -73,14 +73,14 @@ au_login_success(void)
if (auditon(A_GETCOND, _cond, sizeof(au_cond)) < 0) {
if (errno == ENOSYS)
return;
-   errx(1, "login: Could not determine audit condition");
+   errx(1, "Could not determine audit condition");
}
if (au_cond == AUC_NOAUDIT)
return;
 
/* Compute and set the user's preselection mask. */
if (au_user_mask(pwd->pw_name, ) == -1)
-   errx(1, "login: Could not set audit mask\n");
+   errx(1, "Could not set audit mask");
 
/* Set the audit info for the user. */
auinfo.ai_auid = uid;
@@ -88,22 +88,22 @@ au_login_success(void)
bcopy(, _termid, sizeof(auinfo.ai_termid));
bcopy(, _mask, sizeof(auinfo.ai_mask));
if (setaudit() != 0)
-   err(1, "login: setaudit failed");
+   err(1, "setaudit failed");
 
if ((aufd = au_open()) == -1)
-   errx(1,"login: Audit Error: au_open() failed");
+   errx(1, "Audit Error: au_open() failed");
 
if ((tok = au_to_subject32(uid, geteuid(), getegid(), uid, gid, pid,
pid, )) == NULL)
-   errx(1, "login: Audit Error: au_to_subject32() failed");
+   errx(1, "Audit Error: au_to_subject32() failed");
au_write(aufd, tok);
 
if ((tok = au_to_return32(0, 0)) == NULL)
-   errx(1, "login: Audit Error: au_to_return32() failed");
+   errx(1, "Audit Error: au_to_return32() failed");
au_write(aufd, tok);
 
if (au_close(aufd, 1, AUE_login) == -1)
-   errx(1, "login: Audit Record was not committed.");
+   errx(1, "Audit Record was not committed.");
 }
 
 /*
@@ -124,13 +124,13 @@ au_login_fail(const char *errmsg, int na
if (auditon(A_GETCOND, _cond, sizeof(au_cond)) < 0) {
if (errno == ENOSYS)
return;
-   errx(1, "login: Could not determine audit condition");
+   errx(1, "Could not determine audit condition");
}
if (au_cond == AUC_NOAUDIT)
return;
 
if ((aufd = au_open()) == -1)
-   errx(1, "login: Audit Error: au_open() failed");
+   errx(1, "Audit Error: au_open() failed");
 
if (na) {
/*
@@ -139,28 +139,28 @@ au_login_fail(const char *errmsg, int na
 */
if ((tok = au_to_subject32(-1, geteuid(), getegid(), -1, -1,
pid, -1, )) == NULL)
-   errx(1, "login: Audit Error: au_to_subject32() failed");
+   errx(1, "Audit Error: au_to_subject32() failed");
} else {
/* We know the subject -- so use its value instead. */
uid = pwd->pw_uid;
gid = pwd->pw_gid;
if ((tok = au_to_subject32(uid, geteuid(), getegid(), uid,
gid, pid, pid, )) == NULL)
-   errx(1, "login: Audit Error: au_to_subject32() failed");
+   errx(1, "Audit Error: au_to_subject32() failed");
}
au_write(aufd, tok);
 
/* Include the error message. */
if ((tok = au_to_text(errmsg)) == NULL)
-   errx(1, "login: Audit Error: au_to_text() failed");
+   errx(1, "Audit Error: au_to_text() failed");
au_write(aufd, tok);
 
if ((tok = au_to_return32(1, errno)) == NULL)
-   errx(1, "login: Audit Error: au_to_return32() failed");
+   errx(1, "Audit Error: au_to_return32() failed");
au_write(aufd, tok);
 
if (au_close(aufd, 1, AUE_login) == -1)
-   errx(1, "login: Audit Error: au_close() was not committed");
+   errx(1, "Audit Error: au_close() was not committed");
 }
 
 /*
@@ -181,24 +181,24 @@ audit_logout(void)
if (auditon(A_GETCOND, _cond, sizeof(int)) < 0) {
if (errno == ENOSYS)
return;
-   errx(1, "login: Could not determine audit condition");
+   errx(1, "Could not determine audit condition");
}
if (au_cond == AUC_NOAUDIT)
return;
 
if ((aufd = au_open()) == -1)
- 

Re: svn commit: r305787 - in head/usr.sbin/amd: amd amq fixmount fsinfo hlfsd include libamu mk-amd-map pawd scripts wire-test

2016-09-14 Thread Cy Schubert
In message , Pedro 
Giffuni wr
ites:
> Hello;
> 
> 
> On 14/09/2016 00:00, Baptiste Daroussin wrote:
> > On Wed, Sep 14, 2016 at 01:47:01AM +, Cy Schubert wrote:
> >> Author: cy
> >> Date: Wed Sep 14 01:47:01 2016
> >> New Revision: 305787
> >> URL: https://svnweb.freebsd.org/changeset/base/305787
> >>
> >> Log:
> >>Switch from .CURDIR to the simpler, more legible SRCTOP.
> >>
> >>Suggested by:   emaste
> >>X-MFC-with: upcoming amd upgrade
> >>
> > I thought the plans was more to deprecated and remove amd at some points gi
> ven
> > we now have autofs/automountd? Am I missing something?
> 
> We haven't discussed deprecation, although it's not off the table.
> 
>  From what I read about amd, it gets along with autofs well.
> It appears some sysadmins may be used to amd and just removing it may 
> violate POLA.

True.

> 
> It may be that the port/pkg is sufficient but before removing we should 
> update it to match what the port has.

Agreed. I'm working on the update bit. It's mostly done.


-- 
Cheers,
Cy Schubert 
FreeBSD UNIX:     Web:  http://www.FreeBSD.org

The need of the many outweighs the greed of the few.


___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r305820 - head/sys/powerpc/powerpc

2016-09-14 Thread Justin Hibbits
Author: jhibbits
Date: Wed Sep 14 23:24:23 2016
New Revision: 305820
URL: https://svnweb.freebsd.org/changeset/base/305820

Log:
  Only define db_show_spr if DDB is enabled.
  
  PR:   212667
  Reported by:  Kenneth Salerno 

Modified:
  head/sys/powerpc/powerpc/machdep.c

Modified: head/sys/powerpc/powerpc/machdep.c
==
--- head/sys/powerpc/powerpc/machdep.c  Wed Sep 14 21:15:01 2016
(r305819)
+++ head/sys/powerpc/powerpc/machdep.c  Wed Sep 14 23:24:23 2016
(r305820)
@@ -527,6 +527,7 @@ spinlock_exit(void)
  */
 extern register_t get_spr(int);
 
+#ifdef DDB
 DB_SHOW_COMMAND(spr, db_show_spr)
 {
register_t spr;
@@ -546,3 +547,4 @@ DB_SHOW_COMMAND(spr, db_show_spr)
db_printf("SPR %d(%x): %lx\n", saved_sprno, saved_sprno,
(unsigned long)spr);
 }
+#endif
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r305819 - in head: contrib/libarchive/libarchive contrib/libarchive/libarchive/test lib/libarchive/tests

2016-09-14 Thread Martin Matuska
Author: mm
Date: Wed Sep 14 21:15:01 2016
New Revision: 305819
URL: https://svnweb.freebsd.org/changeset/base/305819

Log:
  MFV r305816:
  Sync libarchive with vendor including important security fixes.
  
  Issues fixed (FreeBSD):
  PR #778: ACL error handling
  Issue #745: Symlink check prefix optimization is too aggressive
  Issue #746: Hard links with data can evade sandboxing restrictions
  
  This update fixes the vulnerability #3 and vulnerability #4 as reported in
  "non-cryptanalytic attacks against FreeBSD update components".
  https://gist.github.com/anonymous/e48209b03f1dd9625a992717e7b89c4f
  
  Fix for vulnerability #2 has already been merged in r304989.
  
  MFC after:1 week
  Security: http://gist.github.com/anonymous/e48209b03f1dd9625a992717e7b89c4f

Modified:
  head/contrib/libarchive/libarchive/archive_platform.h
  head/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c
  head/contrib/libarchive/libarchive/archive_read_disk_posix.c
  head/contrib/libarchive/libarchive/archive_read_support_format_tar.c
  head/contrib/libarchive/libarchive/archive_write_disk_acl.c
  head/contrib/libarchive/libarchive/archive_write_disk_posix.c
  head/contrib/libarchive/libarchive/test/test_write_disk_secure745.c
  head/contrib/libarchive/libarchive/test/test_write_disk_secure746.c
  head/contrib/libarchive/libarchive/test/test_write_format_gnutar_filenames.c
  head/lib/libarchive/tests/Makefile
Directory Properties:
  head/contrib/libarchive/   (props changed)

Modified: head/contrib/libarchive/libarchive/archive_platform.h
==
--- head/contrib/libarchive/libarchive/archive_platform.h   Wed Sep 14 
21:01:02 2016(r305818)
+++ head/contrib/libarchive/libarchive/archive_platform.h   Wed Sep 14 
21:15:01 2016(r305819)
@@ -159,6 +159,15 @@
 #defineCAN_RESTORE_METADATA_FD
 #endif
 
+/*
+ * glibc 2.24 deprecates readdir_r
+ */
+#if defined(HAVE_READDIR_R) && (!defined(__GLIBC__) || 
!defined(__GLIBC_MINOR__) || __GLIBC__ < 2 || (__GLIBC__ == 2 && 
__GLIBC_MINOR__ < 24))
+#defineUSE_READDIR_R   1
+#else
+#undef USE_READDIR_R
+#endif
+
 /* Set up defaults for internal error codes. */
 #ifndef ARCHIVE_ERRNO_FILE_FORMAT
 #if HAVE_EFTYPE

Modified: head/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c
==
--- head/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c  
Wed Sep 14 21:01:02 2016(r305818)
+++ head/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c  
Wed Sep 14 21:15:01 2016(r305819)
@@ -411,9 +411,7 @@ setup_acls(struct archive_read_disk *a,
 {
const char  *accpath;
acl_tacl;
-#if HAVE_ACL_IS_TRIVIAL_NP
int r;
-#endif
 
accpath = archive_entry_sourcepath(entry);
if (accpath == NULL)
@@ -473,9 +471,13 @@ setup_acls(struct archive_read_disk *a,
}
 #endif
if (acl != NULL) {
-   translate_acl(a, entry, acl, ARCHIVE_ENTRY_ACL_TYPE_NFS4);
+   r = translate_acl(a, entry, acl, ARCHIVE_ENTRY_ACL_TYPE_NFS4);
acl_free(acl);
-   return (ARCHIVE_OK);
+   if (r != ARCHIVE_OK) {
+   archive_set_error(>archive, errno,
+   "Couldn't translate NFSv4 ACLs: %s", accpath);
+   }
+   return (r);
}
 #endif /* ACL_TYPE_NFS4 */
 
@@ -506,19 +508,30 @@ setup_acls(struct archive_read_disk *a,
 #endif
 
if (acl != NULL) {
-   translate_acl(a, entry, acl,
+   r = translate_acl(a, entry, acl,
ARCHIVE_ENTRY_ACL_TYPE_ACCESS);
acl_free(acl);
acl = NULL;
+   if (r != ARCHIVE_OK) {
+   archive_set_error(>archive, errno,
+   "Couldn't translate access ACLs: %s", accpath);
+   return (r);
+   }
}
 
/* Only directories can have default ACLs. */
if (S_ISDIR(archive_entry_mode(entry))) {
acl = acl_get_file(accpath, ACL_TYPE_DEFAULT);
if (acl != NULL) {
-   translate_acl(a, entry, acl,
+   r = translate_acl(a, entry, acl,
ARCHIVE_ENTRY_ACL_TYPE_DEFAULT);
acl_free(acl);
+   if (r != ARCHIVE_OK) {
+   archive_set_error(>archive, errno,
+   "Couldn't translate default ACLs: %s",
+   accpath);
+   return (r);
+   }
}
}
return (ARCHIVE_OK);
@@ -574,19 +587,23 @@ translate_acl(struct archive_read_disk *
 #ifdef ACL_TYPE_NFS4
acl_entry_type_t 

svn commit: r305818 - head/contrib/libarchive/cpio

2016-09-14 Thread Martin Matuska
Author: mm
Date: Wed Sep 14 21:01:02 2016
New Revision: 305818
URL: https://svnweb.freebsd.org/changeset/base/305818

Log:
  Remove mergeinfo from contrib/libarchive/cpio

Modified:
Directory Properties:
  head/contrib/libarchive/cpio/   (props changed)
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r305817 - in head/contrib/libarchive: libarchive libarchive_fe tar

2016-09-14 Thread Martin Matuska
Author: mm
Date: Wed Sep 14 20:55:03 2016
New Revision: 305817
URL: https://svnweb.freebsd.org/changeset/base/305817

Log:
  Remove mergeinfo from contrib/libarchive subdirs

Modified:
Directory Properties:
  head/contrib/libarchive/libarchive/   (props changed)
  head/contrib/libarchive/libarchive_fe/   (props changed)
  head/contrib/libarchive/tar/   (props changed)
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r305814 - head/sys/boot/common

2016-09-14 Thread Bruce Evans

On Wed, 14 Sep 2016, Emmanuel Vadot wrote:


Bruce Evans  wrote:


On Wed, 14 Sep 2016, Emmanuel Vadot wrote:


Log:
 ufsread: Do not cast struct direct from void *
 This cause alignment problem on ARM (and possibly other archs), instead copy 
it.
...


This looks like a good pessimization for space.  boot2 on i386 has to
fit in 8192 bytes and has a negative number to spare (features are
already left out).


Do you have any suggestion on making the code better ?
This was the last patch for having EFI working on ARMv6 and this is
something that I want to be enabled by default at some point.


At least copy to a local variable.  Ifdefs for the space-constrained &&
non-strict-alignment arches work of course, but shouldn't be needed.

You will have to investigate the -ffreestanding and builtin situation.
-ffreestanding is set in 24 sub-Makefiles instead of correctly in 1
Makefile.inc.  I think it applies to all of boot/i386.  boot code
almost never recovers from this using __builtin_*.  Beware that some
builtins just call an extern function which might not exist in boot
code.  Even memcpy barely exists in small boot2's.  Some compilers
have buggy -ffreestanding and call memcpy() for struct copying, so it
is preferred to bcopy() in boot code.

Bruce
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r305816 - in vendor/libarchive/dist/libarchive: . test

2016-09-14 Thread Martin Matuska
Author: mm
Date: Wed Sep 14 20:32:34 2016
New Revision: 305816
URL: https://svnweb.freebsd.org/changeset/base/305816

Log:
  Update vendor/libarchive to git c31379acc9009f5a3bafcfa33d7672a24b3f51f3
  
  Vendor issues fixed (FreeBSD):
  PR #778: ACL error handling
  Issue #745: Symlink check prefix optimization is too aggressive
  Issue #746: Hard links with data can evade sandboxing restrictions
  
  This update fixes the vulnerability #3 and vulnerability #4 as reported in
  the "non-cryptanalytic attacks against FreeBSD update components".
  https://gist.github.com/anonymous/e48209b03f1dd9625a992717e7b89c4f
  
  Vulnerability #2 has already been fixed in r304866

Modified:
  vendor/libarchive/dist/libarchive/archive_platform.h
  vendor/libarchive/dist/libarchive/archive_read_disk_entry_from_file.c
  vendor/libarchive/dist/libarchive/archive_read_disk_posix.c
  vendor/libarchive/dist/libarchive/archive_read_support_format_tar.c
  vendor/libarchive/dist/libarchive/archive_write_disk_acl.c
  vendor/libarchive/dist/libarchive/archive_write_disk_posix.c
  vendor/libarchive/dist/libarchive/test/test_write_disk_secure745.c
  vendor/libarchive/dist/libarchive/test/test_write_disk_secure746.c
  vendor/libarchive/dist/libarchive/test/test_write_format_gnutar_filenames.c

Modified: vendor/libarchive/dist/libarchive/archive_platform.h
==
--- vendor/libarchive/dist/libarchive/archive_platform.hWed Sep 14 
18:22:12 2016(r305815)
+++ vendor/libarchive/dist/libarchive/archive_platform.hWed Sep 14 
20:32:34 2016(r305816)
@@ -159,6 +159,15 @@
 #defineCAN_RESTORE_METADATA_FD
 #endif
 
+/*
+ * glibc 2.24 deprecates readdir_r
+ */
+#if defined(HAVE_READDIR_R) && (!defined(__GLIBC__) || 
!defined(__GLIBC_MINOR__) || __GLIBC__ < 2 || (__GLIBC__ == 2 && 
__GLIBC_MINOR__ < 24))
+#defineUSE_READDIR_R   1
+#else
+#undef USE_READDIR_R
+#endif
+
 /* Set up defaults for internal error codes. */
 #ifndef ARCHIVE_ERRNO_FILE_FORMAT
 #if HAVE_EFTYPE

Modified: vendor/libarchive/dist/libarchive/archive_read_disk_entry_from_file.c
==
--- vendor/libarchive/dist/libarchive/archive_read_disk_entry_from_file.c   
Wed Sep 14 18:22:12 2016(r305815)
+++ vendor/libarchive/dist/libarchive/archive_read_disk_entry_from_file.c   
Wed Sep 14 20:32:34 2016(r305816)
@@ -411,9 +411,7 @@ setup_acls(struct archive_read_disk *a,
 {
const char  *accpath;
acl_tacl;
-#if HAVE_ACL_IS_TRIVIAL_NP
int r;
-#endif
 
accpath = archive_entry_sourcepath(entry);
if (accpath == NULL)
@@ -473,9 +471,13 @@ setup_acls(struct archive_read_disk *a,
}
 #endif
if (acl != NULL) {
-   translate_acl(a, entry, acl, ARCHIVE_ENTRY_ACL_TYPE_NFS4);
+   r = translate_acl(a, entry, acl, ARCHIVE_ENTRY_ACL_TYPE_NFS4);
acl_free(acl);
-   return (ARCHIVE_OK);
+   if (r != ARCHIVE_OK) {
+   archive_set_error(>archive, errno,
+   "Couldn't translate NFSv4 ACLs: %s", accpath);
+   }
+   return (r);
}
 #endif /* ACL_TYPE_NFS4 */
 
@@ -506,19 +508,30 @@ setup_acls(struct archive_read_disk *a,
 #endif
 
if (acl != NULL) {
-   translate_acl(a, entry, acl,
+   r = translate_acl(a, entry, acl,
ARCHIVE_ENTRY_ACL_TYPE_ACCESS);
acl_free(acl);
acl = NULL;
+   if (r != ARCHIVE_OK) {
+   archive_set_error(>archive, errno,
+   "Couldn't translate access ACLs: %s", accpath);
+   return (r);
+   }
}
 
/* Only directories can have default ACLs. */
if (S_ISDIR(archive_entry_mode(entry))) {
acl = acl_get_file(accpath, ACL_TYPE_DEFAULT);
if (acl != NULL) {
-   translate_acl(a, entry, acl,
+   r = translate_acl(a, entry, acl,
ARCHIVE_ENTRY_ACL_TYPE_DEFAULT);
acl_free(acl);
+   if (r != ARCHIVE_OK) {
+   archive_set_error(>archive, errno,
+   "Couldn't translate default ACLs: %s",
+   accpath);
+   return (r);
+   }
}
}
return (ARCHIVE_OK);
@@ -574,12 +587,12 @@ translate_acl(struct archive_read_disk *
 #ifdef ACL_TYPE_NFS4
acl_entry_type_t acl_type;
acl_flagset_tacl_flagset;
-   int brand, r;
+   int brand;
 #endif
acl_entry_t  acl_entry;
acl_permset_tacl_permset;
int  i, entry_acl_type;
-   int

Re: svn commit: r305814 - head/sys/boot/common

2016-09-14 Thread Emmanuel Vadot

 Hi Bruce,

On Thu, 15 Sep 2016 05:37:19 +1000 (EST)
Bruce Evans  wrote:

> On Wed, 14 Sep 2016, Emmanuel Vadot wrote:
> 
> > Log:
> >  ufsread: Do not cast struct direct from void *
> >  This cause alignment problem on ARM (and possibly other archs), instead 
> > copy it.
> >
> >  MFC after: 1 week
> >
> > Modified:
> >  head/sys/boot/common/ufsread.c
> >
> > Modified: head/sys/boot/common/ufsread.c
> > ==
> > --- head/sys/boot/common/ufsread.c  Wed Sep 14 16:47:17 2016
> > (r305813)
> > +++ head/sys/boot/common/ufsread.c  Wed Sep 14 17:43:32 2016
> > (r305814)
> > @@ -97,21 +97,21 @@ static __inline uint8_t
> > fsfind(const char *name, ufs_ino_t * ino)
> > {
> > static char buf[DEV_BSIZE];
> > -   struct direct *d;
> > +   static struct direct d;
> > char *s;
> > ssize_t n;
> 
> This looks like a good pessimization for space.  boot2 on i386 has to
> fit in 8192 bytes and has a negative number to spare (features are
> already left out).

 Do you have any suggestion on making the code better ?
 This was the last patch for having EFI working on ARMv6 and this is
something that I want to be enabled by default at some point.

> 
> With auto buffers, and also builtin memcpy, the compiler can optimize
> the memcpy to nothing on arches with no alignment, and should do this
> with -Os.  I think -ffreestanding in boot programs kills the builtin,
> and this is almost intentional since compilers have poor support for
> -Os so the inline memcpy is sometimes larger unless it is null.
> 
> >
> > fs_off = 0;
> > while ((n = fsread(*ino, buf, DEV_BSIZE)) > 0)
> > for (s = buf; s < buf + DEV_BSIZE;) {
> > -   d = (void *)s;
> > +   memcpy(, s, sizeof(struct direct));
> > if (ls)
> > -   printf("%s ", d->d_name);
> > -   else if (!strcmp(name, d->d_name)) {
> > -   *ino = d->d_ino;
> > -   return d->d_type;
> > +   printf("%s ", d.d_name);
> > +   else if (!strcmp(name, d.d_name)) {
> > +   *ino = d.d_ino;
> > +   return d.d_type;
> > }
> > -   s += d->d_reclen;
> > +   s += d.d_reclen;
> > }
> > if (n != -1 && ls)
> > printf("\n");
> 
> The static buffer in the old code also looks like a pessimization for
> space.  It doesn't seem to be needed to preserver or return results.
> Compilers don't seem to be smart enough to see this and optimize it
> to auto or vice versa.
> 
> Testing shows that the static buffer is space optimization for gcc
> and a space pessimization for clang:
> 
> X #include 
> X #include 
> X 
> X int
> X foo(void)
> X {
> X static char buf[101];
> X static int buf1[3];
> X 
> X read(0, buf, sizeof(buf));
> X memcpy(buf1, [2], sizeof(buf1));
> X return (buf[0] + buf1[0]);
> X }
> 
> 2 static buffers give the best pessimizations for clang -Os -m32.
> Even with -Os, clang prefers to use large instructions to reduce the
> number of instructions.  The static buffers give largest instructions,
> and also prevent optimizing away the memcpy().  With auto buf1, it
> takes -ffreestanding to kill the optimization of memcpy() and with
> that optimization the size is reduced by almost a factor of 2.  With
> auto buf too, other pessimizations are applied to give a size reduction
> of just 1 byte.  gcc-4.2.1 never inlines the memcpy(), but it does
> the other pessimizations less well to give an in-between size.
> 
> Aproximate sizes on i386: 65 bytes for clang with statics, 49 for gcc,
> 33 for clang with autos and builtins, 28 for tweaked output for clang
> with static buf, auto buf1 and builtins (null memcpy).
> 
> Probably the static buf is an intentional optimization for gcc.
> Compilers do too good a job of generating large code for large stack
> offsets.  In my test code, the offsets are about 101 which is less than
> 128 so it takes only 2 bytes.  DEV_BSIZE is 512 so it needs 5-byte
> offsets from the usual pessimizations for the base pointer (these
> are to point %ebp at the top of the variables and put all the scalar
> variables below the buffer so that the offsets are largest).  But
> clang also does good pessimizations for offsets from the static buffer:
> 
>   pushl   $foo.buf# 5 bytes
>   movsbl  foo.buf, %eax   # 7 bytes
>   addlfoo.buf+2, %eax # 6 bytes
> 
> Actually optimizing for space:
> 
>   movl$foo.buf,%ebx   # 5 bytes
>   pushl   %ebx# 1 byte
>   movsbl  (%ebx), %eax# 3 bytes
>   addl2(%ebx), %eax   # 3 bytes
> 
> Bruce

 Cheers,

-- 
Emmanuel Vadot
___
svn-src-all@freebsd.org mailing list

Re: svn commit: r305814 - head/sys/boot/common

2016-09-14 Thread Bruce Evans

On Wed, 14 Sep 2016, Emmanuel Vadot wrote:


Log:
 ufsread: Do not cast struct direct from void *
 This cause alignment problem on ARM (and possibly other archs), instead copy 
it.

 MFC after: 1 week

Modified:
 head/sys/boot/common/ufsread.c

Modified: head/sys/boot/common/ufsread.c
==
--- head/sys/boot/common/ufsread.c  Wed Sep 14 16:47:17 2016
(r305813)
+++ head/sys/boot/common/ufsread.c  Wed Sep 14 17:43:32 2016
(r305814)
@@ -97,21 +97,21 @@ static __inline uint8_t
fsfind(const char *name, ufs_ino_t * ino)
{
static char buf[DEV_BSIZE];
-   struct direct *d;
+   static struct direct d;
char *s;
ssize_t n;


This looks like a good pessimization for space.  boot2 on i386 has to
fit in 8192 bytes and has a negative number to spare (features are
already left out).

With auto buffers, and also builtin memcpy, the compiler can optimize
the memcpy to nothing on arches with no alignment, and should do this
with -Os.  I think -ffreestanding in boot programs kills the builtin,
and this is almost intentional since compilers have poor support for
-Os so the inline memcpy is sometimes larger unless it is null.



fs_off = 0;
while ((n = fsread(*ino, buf, DEV_BSIZE)) > 0)
for (s = buf; s < buf + DEV_BSIZE;) {
-   d = (void *)s;
+   memcpy(, s, sizeof(struct direct));
if (ls)
-   printf("%s ", d->d_name);
-   else if (!strcmp(name, d->d_name)) {
-   *ino = d->d_ino;
-   return d->d_type;
+   printf("%s ", d.d_name);
+   else if (!strcmp(name, d.d_name)) {
+   *ino = d.d_ino;
+   return d.d_type;
}
-   s += d->d_reclen;
+   s += d.d_reclen;
}
if (n != -1 && ls)
printf("\n");


The static buffer in the old code also looks like a pessimization for
space.  It doesn't seem to be needed to preserver or return results.
Compilers don't seem to be smart enough to see this and optimize it
to auto or vice versa.

Testing shows that the static buffer is space optimization for gcc
and a space pessimization for clang:

X #include 
X #include 
X 
X int

X foo(void)
X {
X   static char buf[101];
X   static int buf1[3];
X 
X 	read(0, buf, sizeof(buf));

X   memcpy(buf1, [2], sizeof(buf1));
X   return (buf[0] + buf1[0]);
X }

2 static buffers give the best pessimizations for clang -Os -m32.
Even with -Os, clang prefers to use large instructions to reduce the
number of instructions.  The static buffers give largest instructions,
and also prevent optimizing away the memcpy().  With auto buf1, it
takes -ffreestanding to kill the optimization of memcpy() and with
that optimization the size is reduced by almost a factor of 2.  With
auto buf too, other pessimizations are applied to give a size reduction
of just 1 byte.  gcc-4.2.1 never inlines the memcpy(), but it does
the other pessimizations less well to give an in-between size.

Aproximate sizes on i386: 65 bytes for clang with statics, 49 for gcc,
33 for clang with autos and builtins, 28 for tweaked output for clang
with static buf, auto buf1 and builtins (null memcpy).

Probably the static buf is an intentional optimization for gcc.
Compilers do too good a job of generating large code for large stack
offsets.  In my test code, the offsets are about 101 which is less than
128 so it takes only 2 bytes.  DEV_BSIZE is 512 so it needs 5-byte
offsets from the usual pessimizations for the base pointer (these
are to point %ebp at the top of the variables and put all the scalar
variables below the buffer so that the offsets are largest).  But
clang also does good pessimizations for offsets from the static buffer:

pushl   $foo.buf# 5 bytes
movsbl  foo.buf, %eax   # 7 bytes
addlfoo.buf+2, %eax # 6 bytes

Actually optimizing for space:

movl$foo.buf,%ebx   # 5 bytes
pushl   %ebx# 1 byte
movsbl  (%ebx), %eax# 3 bytes
addl2(%ebx), %eax   # 3 bytes

Bruce
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r305815 - head/usr.bin/vtfontcvt

2016-09-14 Thread Ed Maste
Author: emaste
Date: Wed Sep 14 18:22:12 2016
New Revision: 305815
URL: https://svnweb.freebsd.org/changeset/base/305815

Log:
  vtfontcvt: remove superfluous newlines in errx messages

Modified:
  head/usr.bin/vtfontcvt/vtfontcvt.c

Modified: head/usr.bin/vtfontcvt/vtfontcvt.c
==
--- head/usr.bin/vtfontcvt/vtfontcvt.c  Wed Sep 14 17:43:32 2016
(r305814)
+++ head/usr.bin/vtfontcvt/vtfontcvt.c  Wed Sep 14 18:22:12 2016
(r305815)
@@ -122,7 +122,7 @@ add_mapping(struct glyph *gl, unsigned i
ml = [map_idx];
if (TAILQ_LAST(ml, mapping_list) != NULL &&
TAILQ_LAST(ml, mapping_list)->m_char >= c)
-   errx(1, "Bad ordering at character %u\n", c);
+   errx(1, "Bad ordering at character %u", c);
TAILQ_INSERT_TAIL(ml, mp, m_list);
 
map_count[map_idx]++;
@@ -143,7 +143,7 @@ dedup_mapping(unsigned int map_idx)
while (mp_normal->m_char < mp_bold->m_char)
mp_normal = TAILQ_NEXT(mp_normal, m_list);
if (mp_bold->m_char != mp_normal->m_char)
-   errx(1, "Character %u not in normal font!\n",
+   errx(1, "Character %u not in normal font!",
mp_bold->m_char);
if (mp_bold->m_glyph != mp_normal->m_glyph)
continue;
@@ -218,7 +218,7 @@ parse_bitmap_line(uint8_t *left, uint8_t
unsigned int i, subline;
 
if (dwidth != width && dwidth != width * 2)
-   errx(1, "Bitmap with unsupported width %u!\n", dwidth);
+   errx(1, "Bitmap with unsupported width %u!", dwidth);
 
/* Move pixel data right to simplify splitting double characters. */
line >>= (howmany(dwidth, 8) * 8) - dwidth;
@@ -235,7 +235,7 @@ parse_bitmap_line(uint8_t *left, uint8_t
*p++ = subline >> 8;
*p = subline;
} else {
-   errx(1, "Unsupported wbytes %u!\n", wbytes);
+   errx(1, "Unsupported wbytes %u!", wbytes);
}
 
line >>= width;
@@ -267,7 +267,7 @@ parse_bdf(FILE *fp, unsigned int map_idx
(ln[6] == ' ' || ln[6] == '\0')) {
for (i = 0; i < height; i++) {
if ((ln = fgetln(fp, )) == NULL)
-   errx(1, "Unexpected EOF!\n");
+   errx(1, "Unexpected EOF!");
ln[length - 1] = '\0';
sscanf(ln, "%x", );
if (parse_bitmap_line(bytes + i * wbytes,
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r305634 - head/share/mk

2016-09-14 Thread Bryan Drewery
On 9/9/16 5:37 PM, Simon J. Gerraty wrote:
> Bryan Drewery  wrote:
> 
>>> +# some targets involve old pre-built targets
>>> +# ignore mtime of shell
>>> +# and mtime of makefiles does not matter in meta mode
>>> +.MAKE.META.IGNORE_PATHS += \
>>> +${MAKEFILE} \
>>> +${SHELL} \
>>> +${SYS_MK_DIR}
>>
>> I think it could be problematic to ignore *.mk changes.  The build
> 
> If you're not concerned with build optimization,
> this can be disabled - but pretty much any sub-make for which there is a
> .meta file will be out-of-date by any changed to *.mk
> 
>> commands may stay the same, but targets could grow new dependencies.  If
>> those dependencies are already "met" then meta mode won't reconsider them.
> 
> I'm not sure how easy it is to accomplish that situation.

Can you at least wrap it in something like .if
!defined(META_CONSIDER_MK_FILES) ?

>  
>> Consider:
>> Build 1:
>> bar:
>>  touch dep
>>  touch bar
>>
>> foo:
>>  touch foo
>>
>> all: bar foo
>>
>> In the first build, all generates dep, bar and foo.
>>
>> Then the code is changed to:
>>
>> bar:
>>  touch bar
>>
>> dep:
>>  touch notmade
>>  touch dep
>>
>> foo: dep
>>  touch foo
>>
>> all: foo bar
>>
>> Now in the second build, all finds bar command changes and rebuilds,
>> finds foo command is the same and that dep is already satisfied from the
>> last build.  So 'notmade' is never made.
> 
> Actually given you have missing-meta=yes
> target dep would be remade, either because there is no .meta file, or
> because its commands changed. 
> Thus notmade should be.
> 

Good point.

-- 
Regards,
Bryan Drewery



signature.asc
Description: OpenPGP digital signature


svn commit: r305814 - head/sys/boot/common

2016-09-14 Thread Emmanuel Vadot
Author: manu
Date: Wed Sep 14 17:43:32 2016
New Revision: 305814
URL: https://svnweb.freebsd.org/changeset/base/305814

Log:
  ufsread: Do not cast struct direct from void *
  This cause alignment problem on ARM (and possibly other archs), instead copy 
it.
  
  MFC after:1 week

Modified:
  head/sys/boot/common/ufsread.c

Modified: head/sys/boot/common/ufsread.c
==
--- head/sys/boot/common/ufsread.c  Wed Sep 14 16:47:17 2016
(r305813)
+++ head/sys/boot/common/ufsread.c  Wed Sep 14 17:43:32 2016
(r305814)
@@ -97,21 +97,21 @@ static __inline uint8_t
 fsfind(const char *name, ufs_ino_t * ino)
 {
static char buf[DEV_BSIZE];
-   struct direct *d;
+   static struct direct d;
char *s;
ssize_t n;
 
fs_off = 0;
while ((n = fsread(*ino, buf, DEV_BSIZE)) > 0)
for (s = buf; s < buf + DEV_BSIZE;) {
-   d = (void *)s;
+   memcpy(, s, sizeof(struct direct));
if (ls)
-   printf("%s ", d->d_name);
-   else if (!strcmp(name, d->d_name)) {
-   *ino = d->d_ino;
-   return d->d_type;
+   printf("%s ", d.d_name);
+   else if (!strcmp(name, d.d_name)) {
+   *ino = d.d_ino;
+   return d.d_type;
}
-   s += d->d_reclen;
+   s += d.d_reclen;
}
if (n != -1 && ls)
printf("\n");
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r305807 - in head/sys: amd64/amd64 i386/i386 x86/include

2016-09-14 Thread Bruce Evans

On Wed, 14 Sep 2016, Bjoern A. Zeeb wrote:


On 14 Sep 2016, at 12:57, Bruce Evans wrote:


Author: bde
Date: Wed Sep 14 12:57:40 2016
New Revision: 305807
URL: https://svnweb.freebsd.org/changeset/base/305807

Log:

Modified:
  head/sys/amd64/amd64/trap.c


breaks all amd64 LINT* kernels:

/scratch/tmp/bz/head.svn/sys/amd64/amd64/trap.c:937:22: error: use of 
undeclared identifier 'frame'; did you mean 'free'?

   if (!TRAPF_USERMODE(frame)) {
   ^
   free


Oops.  I see you fixed it.  Thanks.

Bruce
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r305811 - head/sys/amd64/amd64

2016-09-14 Thread Bruce Evans

On Wed, 14 Sep 2016, Bjoern A. Zeeb wrote:


Log:
 Try to fix LINT builds after r305807.  Seems to be a simple s error
 I missed while reading through the 1st time as well.


Thanks.  The fix looks right.


Modified:
 head/sys/amd64/amd64/trap.c

Modified: head/sys/amd64/amd64/trap.c
==
--- head/sys/amd64/amd64/trap.c Wed Sep 14 14:48:00 2016(r305810)
+++ head/sys/amd64/amd64/trap.c Wed Sep 14 16:08:23 2016(r305811)
@@ -934,7 +934,7 @@ amd64_syscall(struct thread *td, int tra
ksiginfo_t ksi;

#ifdef DIAGNOSTIC
-   if (!TRAPF_USERMODE(frame)) {
+   if (!TRAPF_USERMODE(td->td_frame)) {
panic("syscall");
/* NOT REACHED */
}


Bruce
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r305813 - head/usr.bin/localedef

2016-09-14 Thread Pedro F. Giffuni
Author: pfg
Date: Wed Sep 14 16:47:17 2016
New Revision: 305813
URL: https://svnweb.freebsd.org/changeset/base/305813

Log:
  localedef(1): make better use of calloc(3) arguments.
  
  The first argument of calloc(3) should be an ordinal type, and the
  second a size: split a multiplication to make better use of calloc(3)
  and detect overflows.
  
  Do some other re-ordering and style fixes while here.
  
  MFC after:3 weeks

Modified:
  head/usr.bin/localedef/collate.c

Modified: head/usr.bin/localedef/collate.c
==
--- head/usr.bin/localedef/collate.cWed Sep 14 16:34:52 2016
(r305812)
+++ head/usr.bin/localedef/collate.cWed Sep 14 16:47:17 2016
(r305813)
@@ -1204,7 +1204,7 @@ dump_collate(void)
subst_t *temp;
RB_COUNT(temp, substs, [i], n);
collinfo.subst_count[i] = n;
-   if ((st = calloc(sizeof (collate_subst_t) * n, 1)) == NULL) {
+   if ((st = calloc(n, sizeof(collate_subst_t))) == NULL) {
fprintf(stderr, "out of memory");
return;
}
@@ -1233,7 +1233,7 @@ dump_collate(void)
 */
RB_NUMNODES(collelem_t, elem_by_expand, _by_expand,
collinfo.chain_count);
-   chain = calloc(sizeof (collate_chain_t), collinfo.chain_count);
+   chain = calloc(collinfo.chain_count, sizeof(collate_chain_t));
if (chain == NULL) {
fprintf(stderr, "out of memory");
return;
@@ -1253,7 +1253,7 @@ dump_collate(void)
 * Large (> UCHAR_MAX) character priorities
 */
RB_NUMNODES(collchar_t, collchars, , n);
-   large = calloc(n, sizeof (collate_large_t));
+   large = calloc(n, sizeof(collate_large_t));
if (large == NULL) {
fprintf(stderr, "out of memory");
return;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r305812 - head/usr.sbin/fifolog/lib

2016-09-14 Thread Pedro F. Giffuni
Author: pfg
Date: Wed Sep 14 16:34:52 2016
New Revision: 305812
URL: https://svnweb.freebsd.org/changeset/base/305812

Log:
  fifolog(1): invert order of calloc(3) arguments.
  
  The second argment to calloc(3) should be the size, make it so.
  
  While here be a little bit more cautious in fifolog_reader_open()
  to protect in the unlikely event of an overflowed allocation.
  
  MFC after:3 weeks

Modified:
  head/usr.sbin/fifolog/lib/fifolog_create.c
  head/usr.sbin/fifolog/lib/fifolog_reader.c
  head/usr.sbin/fifolog/lib/fifolog_write_poll.c
  head/usr.sbin/fifolog/lib/miniobj.h

Modified: head/usr.sbin/fifolog/lib/fifolog_create.c
==
--- head/usr.sbin/fifolog/lib/fifolog_create.c  Wed Sep 14 16:08:23 2016
(r305811)
+++ head/usr.sbin/fifolog/lib/fifolog_create.c  Wed Sep 14 16:34:52 2016
(r305812)
@@ -97,7 +97,7 @@ fifolog_create(const char *fn, off_t siz
if (S_ISREG(st.st_mode) && ftruncate(fd, size) < 0)
return ("Could not ftrunc");
 
-   buf = calloc(recsize, 1);
+   buf = calloc(1, recsize);
if (buf == NULL)
return ("Could not malloc");
 

Modified: head/usr.sbin/fifolog/lib/fifolog_reader.c
==
--- head/usr.sbin/fifolog/lib/fifolog_reader.c  Wed Sep 14 16:08:23 2016
(r305811)
+++ head/usr.sbin/fifolog/lib/fifolog_reader.c  Wed Sep 14 16:34:52 2016
(r305812)
@@ -67,10 +67,10 @@ fifolog_reader_open(const char *fname)
if (retval != NULL)
err(1, "%s", retval);
 
-   fr->olen = fr->ff->recsize * 16;
-   fr->obuf = calloc(fr->olen, 1);
+   fr->obuf = calloc(16, fr->ff->recsize);
if (fr->obuf == NULL)
err(1, "Cannot malloc");
+   fr->olen = fr->ff->recsize * 16;
 
i = inflateInit(fr->ff->zs);
assert(i == Z_OK);

Modified: head/usr.sbin/fifolog/lib/fifolog_write_poll.c
==
--- head/usr.sbin/fifolog/lib/fifolog_write_poll.c  Wed Sep 14 16:08:23 
2016(r305811)
+++ head/usr.sbin/fifolog/lib/fifolog_write_poll.c  Wed Sep 14 16:34:52 
2016(r305812)
@@ -45,7 +45,7 @@
 static int fifolog_write_gzip(struct fifolog_writer *f, time_t now);
 
 #define ALLOC(ptr, size) do {   \
-   (*(ptr)) = calloc(size, 1); \
+   (*(ptr)) = calloc(1, size); \
assert(*(ptr) != NULL); \
 } while (0)
 

Modified: head/usr.sbin/fifolog/lib/miniobj.h
==
--- head/usr.sbin/fifolog/lib/miniobj.h Wed Sep 14 16:08:23 2016
(r305811)
+++ head/usr.sbin/fifolog/lib/miniobj.h Wed Sep 14 16:34:52 2016
(r305812)
@@ -28,7 +28,7 @@
 
 #define ALLOC_OBJ(to, type_magic)  \
do {\
-   (to) = calloc(sizeof *(to), 1); \
+   (to) = calloc(1, sizeof *(to)); \
if ((to) != NULL)   \
(to)->magic = (type_magic); \
} while (0)
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r305811 - head/sys/amd64/amd64

2016-09-14 Thread Bjoern A. Zeeb
Author: bz
Date: Wed Sep 14 16:08:23 2016
New Revision: 305811
URL: https://svnweb.freebsd.org/changeset/base/305811

Log:
  Try to fix LINT builds after r305807.  Seems to be a simple s error
  I missed while reading through the 1st time as well.

Modified:
  head/sys/amd64/amd64/trap.c

Modified: head/sys/amd64/amd64/trap.c
==
--- head/sys/amd64/amd64/trap.c Wed Sep 14 14:48:00 2016(r305810)
+++ head/sys/amd64/amd64/trap.c Wed Sep 14 16:08:23 2016(r305811)
@@ -934,7 +934,7 @@ amd64_syscall(struct thread *td, int tra
ksiginfo_t ksi;
 
 #ifdef DIAGNOSTIC
-   if (!TRAPF_USERMODE(frame)) {
+   if (!TRAPF_USERMODE(td->td_frame)) {
panic("syscall");
/* NOT REACHED */
}
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r305807 - in head/sys: amd64/amd64 i386/i386 x86/include

2016-09-14 Thread Bjoern A. Zeeb

On 14 Sep 2016, at 12:57, Bruce Evans wrote:


Author: bde
Date: Wed Sep 14 12:57:40 2016
New Revision: 305807
URL: https://svnweb.freebsd.org/changeset/base/305807

Log:

Modified:
  head/sys/amd64/amd64/trap.c


breaks all amd64 LINT* kernels:

/scratch/tmp/bz/head.svn/sys/amd64/amd64/trap.c:937:22: error: use of 
undeclared identifier 'frame'; did you mean 'free'?

if (!TRAPF_USERMODE(frame)) {
^
free
./machine/cpu.h:53:9: note: expanded from macro 'TRAPF_USERMODE'
(ISPL((framep)->tf_cs) == SEL_UPL)
   ^
./x86/segments.h:48:20: note: expanded from macro 'ISPL'
#define ISPL(s) ((s)&3) /* priority level of a selector 
*/

  ^
/scratch/tmp/bz/head.svn/sys/sys/malloc.h:175:6: note: 'free' declared 
here

voidfree(void *addr, struct malloc_type *type);
^
/scratch/tmp/bz/head.svn/sys/amd64/amd64/trap.c:937:7: error: member 
reference base type 'void (void *, struct malloc_type *)' is not a 
structure or union

if (!TRAPF_USERMODE(frame)) {
 ^
./machine/cpu.h:53:16: note: expanded from macro 'TRAPF_USERMODE'
(ISPL((framep)->tf_cs) == SEL_UPL)
 ~^~~~
./x86/segments.h:48:20: note: expanded from macro 'ISPL'
#define ISPL(s) ((s)&3) /* priority level of a selector 
*/

  ^
2 errors generated.
--- trap.o ---
*** [trap.o] Error code 1

bmake[5]: stopped in /storage/head/obj/scratch/tmp/bz/head.svn/sys/LINT
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r305810 - head/sys/netinet

2016-09-14 Thread Michael Tuexen
Author: tuexen
Date: Wed Sep 14 14:48:00 2016
New Revision: 305810
URL: https://svnweb.freebsd.org/changeset/base/305810

Log:
  Ensure that the IPPROTO_TCP level socket options
  * TCP_KEEPINIT
  * TCP_KEEPINTVL
  * TCP_KEEPIDLE
  * TCP_KEEPCNT
  always always report the values currently used when getsockopt()
  is used. This wasn't the case when the sysctl-inherited default
  values where used.
  Ensure that the IPPROTO_TCP level socket option TCP_INFO has the
  TCPI_OPT_ECN flag set in the tcpi_options field when ECN support
  has been negotiated successfully.
  
  Reviewed by:  rrs, jtl, hiren
  MFC after:1 month
  Differential Revision:7833

Modified:
  head/sys/netinet/tcp_usrreq.c

Modified: head/sys/netinet/tcp_usrreq.c
==
--- head/sys/netinet/tcp_usrreq.c   Wed Sep 14 14:05:31 2016
(r305809)
+++ head/sys/netinet/tcp_usrreq.c   Wed Sep 14 14:48:00 2016
(r305810)
@@ -1329,6 +1329,8 @@ tcp_fill_info(struct tcpcb *tp, struct t
ti->tcpi_snd_wscale = tp->snd_scale;
ti->tcpi_rcv_wscale = tp->rcv_scale;
}
+   if (tp->t_flags & TF_ECN_PERMIT)
+   ti->tcpi_options |= TCPI_OPT_ECN;
 
ti->tcpi_rto = tp->t_rxtcur * tick;
ti->tcpi_last_data_recv = (long)(ticks - (int)tp->t_rcvtime) * tick;
@@ -1817,16 +1819,16 @@ unlock_and_done:
case TCP_KEEPCNT:
switch (sopt->sopt_name) {
case TCP_KEEPIDLE:
-   ui = tp->t_keepidle / hz;
+   ui = TP_KEEPIDLE(tp) / hz;
break;
case TCP_KEEPINTVL:
-   ui = tp->t_keepintvl / hz;
+   ui = TP_KEEPINTVL(tp) / hz;
break;
case TCP_KEEPINIT:
-   ui = tp->t_keepinit / hz;
+   ui = TP_KEEPINIT(tp) / hz;
break;
case TCP_KEEPCNT:
-   ui = tp->t_keepcnt;
+   ui = TP_KEEPCNT(tp);
break;
}
INP_WUNLOCK(inp);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r305787 - in head/usr.sbin/amd: amd amq fixmount fsinfo hlfsd include libamu mk-amd-map pawd scripts wire-test

2016-09-14 Thread Pedro Giffuni

Hello;


On 14/09/2016 00:00, Baptiste Daroussin wrote:

On Wed, Sep 14, 2016 at 01:47:01AM +, Cy Schubert wrote:

Author: cy
Date: Wed Sep 14 01:47:01 2016
New Revision: 305787
URL: https://svnweb.freebsd.org/changeset/base/305787

Log:
   Switch from .CURDIR to the simpler, more legible SRCTOP.
   
   Suggested by:	emaste

   X-MFC-with:  upcoming amd upgrade


I thought the plans was more to deprecated and remove amd at some points given
we now have autofs/automountd? Am I missing something?


We haven't discussed deprecation, although it's not off the table.

From what I read about amd, it gets along with autofs well.
It appears some sysadmins may be used to amd and just removing it may 
violate POLA.


It may be that the port/pkg is sufficient but before removing we should 
update it to match what the port has.


Pedro.

___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r305807 - in head/sys: amd64/amd64 i386/i386 x86/include

2016-09-14 Thread Bruce Evans

On Wed, 14 Sep 2016, Bruce Evans wrote:


...
Log:
 ...
 Fix logic errors in treating vm86 bioscall mode as kernel mode.  The
 main place checked all the necessary flags, but put the necessary
 parentheses for the PSL_VM and PCB_VM86CALL checks in the wrong
 place.  The broken case is only reached if a vm86 bioscall uses a
 %cs which is nonzero mod 4, but that is unusual -- most bios calls
 start with %cs = 0xc000 or 0xf000 and rarely change it.  Another
 place was missing the check for PCB_VM86CALL, but was only reachable
 if there are bugs virtualizing PSL_I.


Forgot: Reviewed by: kib

Just before committing, I checked when this was broken.  It was in
the Giant attack for SMPng.  vm86 bios calls need mutual exclusion,
and apparently Giant was used, and WITNESS warned about this, so as
a quick fix vm86 bios calls were treated as kernel mode although
this causes other problems.  Now vm86 bios calls use vm86_lock instead
of Giant, but the quick fix is still in place.

vm86 bios calls shouldn't be treated as kernel mode, but I used this
recently to debug one.  ddb almost worked on them without really trying.
It should work similarly on normal vm86 user mode and normal user mode
if we sent the debugger traps to ddb instead of to the thread.  There
is the problem that users must not be allowed to enter the kernel using
unprivileged debugger traps.  Already for vm86 bios calls, we depend
on BIOSes not generating any debugger traps.  My recent changes to
keep the trace flag set by ddb will have to be reviewed to make sure
that if vm86 mode initiates the setting of the trace flag then the
resulting trap doesn't go to the kernel.

Bruce
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r305807 - in head/sys: amd64/amd64 i386/i386 x86/include

2016-09-14 Thread Bruce Evans
Author: bde
Date: Wed Sep 14 12:57:40 2016
New Revision: 305807
URL: https://svnweb.freebsd.org/changeset/base/305807

Log:
  Use the MI macro TRAPF_USERMODE() instead of open-coded checks for
  SEL_UPL and sometimes PSL_VM.  This is just a style change on amd64,
  but on i386 it fixes 1 unimportant place where the PSL_VM check was
  missing and starts fixing 1 important place where the PSL_VM check
  had a logic error.
  
  Fix logic errors in treating vm86 bioscall mode as kernel mode.  The
  main place checked all the necessary flags, but put the necessary
  parentheses for the PSL_VM and PCB_VM86CALL checks in the wrong
  place.  The broken case is only reached if a vm86 bioscall uses a
  %cs which is nonzero mod 4, but that is unusual -- most bios calls
  start with %cs = 0xc000 or 0xf000 and rarely change it.  Another
  place was missing the check for PCB_VM86CALL, but was only reachable
  if there are bugs virtualizing PSL_I.
  
  Add a macro TF_HAS_STACKREGS() and use this instead of converting
  open-coded checks of SEL_UPL, etc. to TRAPF_USERMODE() when we only
  care about whether the frame has stack registers.  This fixes 3
  places in my recent fix for register variables in vm86 mode where I
  messed up the PSL_VM check and cleans up other places.

Modified:
  head/sys/amd64/amd64/trap.c
  head/sys/i386/i386/db_trace.c
  head/sys/i386/i386/trap.c
  head/sys/x86/include/frame.h

Modified: head/sys/amd64/amd64/trap.c
==
--- head/sys/amd64/amd64/trap.c Wed Sep 14 12:07:34 2016(r305806)
+++ head/sys/amd64/amd64/trap.c Wed Sep 14 12:57:40 2016(r305807)
@@ -236,7 +236,7 @@ trap(struct trapframe *frame)
 * interrupts disabled until they are accidentally
 * enabled later.
 */
-   if (ISPL(frame->tf_cs) == SEL_UPL)
+   if (TRAPF_USERMODE(frame))
uprintf(
"pid %ld (%s): trap %d with interrupts disabled\n",
(long)curproc->p_pid, curthread->td_name, type);
@@ -260,7 +260,7 @@ trap(struct trapframe *frame)
 
code = frame->tf_err;
 
-if (ISPL(frame->tf_cs) == SEL_UPL) {
+   if (TRAPF_USERMODE(frame)) {
/* user trap */
 
td->td_pticks = 0;
@@ -787,7 +787,7 @@ trap_fatal(frame, eva)
else
msg = "UNKNOWN";
printf("\n\nFatal trap %d: %s while in %s mode\n", type, msg,
-   ISPL(frame->tf_cs) == SEL_UPL ? "user" : "kernel");
+   TRAPF_USERMODE(frame) ? "user" : "kernel");
 #ifdef SMP
/* two separate prints in case of a trap on an unmapped page */
printf("cpuid = %d; ", PCPU_GET(cpuid));
@@ -804,7 +804,7 @@ trap_fatal(frame, eva)
}
printf("instruction pointer = 0x%lx:0x%lx\n",
   frame->tf_cs & 0x, frame->tf_rip);
-if (ISPL(frame->tf_cs) == SEL_UPL) {
+   if (TF_HAS_STACKREGS(frame)) {
ss = frame->tf_ss & 0x;
esp = frame->tf_rsp;
} else {
@@ -934,7 +934,7 @@ amd64_syscall(struct thread *td, int tra
ksiginfo_t ksi;
 
 #ifdef DIAGNOSTIC
-   if (ISPL(td->td_frame->tf_cs) != SEL_UPL) {
+   if (!TRAPF_USERMODE(frame)) {
panic("syscall");
/* NOT REACHED */
}

Modified: head/sys/i386/i386/db_trace.c
==
--- head/sys/i386/i386/db_trace.c   Wed Sep 14 12:07:34 2016
(r305806)
+++ head/sys/i386/i386/db_trace.c   Wed Sep 14 12:57:40 2016
(r305807)
@@ -82,8 +82,7 @@ struct db_variable *db_eregs = db_regs +
 static __inline int
 get_esp(struct trapframe *tf)
 {
-   return ((ISPL(tf->tf_cs) || kdb_frame->tf_eflags & PSL_VM) ?
-   tf->tf_esp : (intptr_t)>tf_esp);
+   return (TF_HAS_STACKREGS(tf) ? tf->tf_esp : (intptr_t)>tf_esp);
 }
 
 static int
@@ -147,7 +146,7 @@ db_esp(struct db_variable *vp, db_expr_t
 
if (op == DB_VAR_GET)
*valuep = get_esp(kdb_frame);
-   else if (ISPL(kdb_frame->tf_cs))
+   else if (TF_HAS_STACKREGS(kdb_frame))
kdb_frame->tf_esp = *valuep;
return (1);
 }
@@ -180,9 +179,9 @@ db_ss(struct db_variable *vp, db_expr_t 
return (0);
 
if (op == DB_VAR_GET)
-   *valuep = (ISPL(kdb_frame->tf_cs) ||
-   kdb_frame->tf_eflags & PSL_VM) ? kdb_frame->tf_ss : rss();
-   else if (ISPL(kdb_frame->tf_cs) || kdb_frame->tf_eflags & PSL_VM)
+   *valuep = TF_HAS_STACKREGS(kdb_frame) ? kdb_frame->tf_ss :
+   rss();
+   else if (TF_HAS_STACKREGS(kdb_frame))
kdb_frame->tf_ss = *valuep;
return (1);
 }
@@ -439,7 +438,7 @@ db_backtrace(struct thread *td, struct t
 * Find where the trap frame actually ends.
 * It won't 

svn commit: r305806 - in head/sys/dev/usb: . input quirk serial storage

2016-09-14 Thread Hans Petter Selasky
Author: hselasky
Date: Wed Sep 14 12:07:34 2016
New Revision: 305806
URL: https://svnweb.freebsd.org/changeset/base/305806

Log:
  Improve USB polling mode by not locking any mutexes, asserting any
  mutexes or using any callouts when active.
  
  Trying to lock a mutex when KDB is active or the scheduler is stopped
  can result in infinite wait loops. The same goes for calling callout
  related functions which in turn lock mutexes.
  
  If the USB controller at which a USB keyboard is connected is idle
  when KDB is entered, polling the USB keyboard via USB will always
  succeed. Else polling may fail depending on which state the USB
  subsystem and USB interrupt handler is in. This is unavoidable unless
  KDB can wait for USB interrupt threads to complete before stalling the
  CPU(s).
  
  Tested by:Bruce Evans 
  MFC after:4 weeks

Modified:
  head/sys/dev/usb/input/ukbd.c
  head/sys/dev/usb/quirk/usb_quirk.c
  head/sys/dev/usb/serial/usb_serial.c
  head/sys/dev/usb/serial/usb_serial.h
  head/sys/dev/usb/storage/umass.c
  head/sys/dev/usb/usb_busdma.c
  head/sys/dev/usb/usb_core.c
  head/sys/dev/usb/usb_core.h
  head/sys/dev/usb/usb_dev.c
  head/sys/dev/usb/usb_device.c
  head/sys/dev/usb/usb_freebsd.h
  head/sys/dev/usb/usb_freebsd_loader.h
  head/sys/dev/usb/usb_generic.c
  head/sys/dev/usb/usb_hub.c
  head/sys/dev/usb/usb_msctest.c
  head/sys/dev/usb/usb_process.c
  head/sys/dev/usb/usb_request.c
  head/sys/dev/usb/usb_transfer.c
  head/sys/dev/usb/usbdi.h

Modified: head/sys/dev/usb/input/ukbd.c
==
--- head/sys/dev/usb/input/ukbd.c   Wed Sep 14 11:20:58 2016
(r305805)
+++ head/sys/dev/usb/input/ukbd.c   Wed Sep 14 12:07:34 2016
(r305806)
@@ -60,8 +60,6 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
-#include 
-#include 
 
 #include 
 #include 
@@ -248,32 +246,9 @@ struct ukbd_softc {
 SCAN_PREFIX_CTL | SCAN_PREFIX_SHIFT)
 #defineSCAN_CHAR(c)((c) & 0x7f)
 
-#defineUKBD_LOCK() mtx_lock()
-#defineUKBD_UNLOCK()   mtx_unlock()
-
-#ifdef INVARIANTS
-
-/*
- * Assert that the lock is held in all contexts
- * where the code can be executed.
- */
-#defineUKBD_LOCK_ASSERT()  mtx_assert(, MA_OWNED)
-
-/*
- * Assert that the lock is held in the contexts
- * where it really has to be so.
- */
-#defineUKBD_CTX_LOCK_ASSERT()  \
-   do {\
-   if (!kdb_active && panicstr == NULL)\
-   mtx_assert(, MA_OWNED);   \
-   } while (0)
-#else
-
-#define UKBD_LOCK_ASSERT() (void)0
-#define UKBD_CTX_LOCK_ASSERT() (void)0
-
-#endif
+#defineUKBD_LOCK() USB_MTX_LOCK()
+#defineUKBD_UNLOCK()   USB_MTX_UNLOCK()
+#defineUKBD_LOCK_ASSERT()  USB_MTX_ASSERT(, MA_OWNED)
 
 struct ukbd_mods {
uint32_t mask, key;
@@ -400,7 +375,7 @@ ukbd_start_timer(struct ukbd_softc *sc)
sc->sc_co_basetime += delay;
/* This is rarely called, so prefer precision to efficiency. */
prec = qmin(delay >> 7, SBT_1MS * 10);
-   callout_reset_sbt(>sc_callout.co, sc->sc_co_basetime, prec,
+   usb_callout_reset_sbt(>sc_callout, sc->sc_co_basetime, prec,
ukbd_timeout, sc, C_ABSOLUTE);
 }
 
@@ -408,7 +383,7 @@ static void
 ukbd_put_key(struct ukbd_softc *sc, uint32_t key)
 {
 
-   UKBD_CTX_LOCK_ASSERT();
+   UKBD_LOCK_ASSERT();
 
DPRINTF("0x%02x (%d) %s\n", key, key,
(key & KEY_RELEASE) ? "released" : "pressed");
@@ -429,12 +404,12 @@ static void
 ukbd_do_poll(struct ukbd_softc *sc, uint8_t wait)
 {
 
-   UKBD_CTX_LOCK_ASSERT();
+   UKBD_LOCK_ASSERT();
KASSERT((sc->sc_flags & UKBD_FLAG_POLLING) != 0,
("ukbd_do_poll called when not polling\n"));
DPRINTFN(2, "polling\n");
 
-   if (!kdb_active && !SCHEDULER_STOPPED()) {
+   if (USB_IN_POLLING_MODE_FUNC() == 0) {
/*
 * In this context the kernel is polling for input,
 * but the USB subsystem works in normal interrupt-driven
@@ -479,9 +454,9 @@ ukbd_get_key(struct ukbd_softc *sc, uint
 {
int32_t c;
 
-   UKBD_CTX_LOCK_ASSERT();
-   KASSERT((!kdb_active && !SCHEDULER_STOPPED())
-   || (sc->sc_flags & UKBD_FLAG_POLLING) != 0,
+   UKBD_LOCK_ASSERT();
+   KASSERT((USB_IN_POLLING_MODE_FUNC() == 0) ||
+   (sc->sc_flags & UKBD_FLAG_POLLING) != 0,
("not polling in kdb or panic\n"));
 
if (sc->sc_inputs == 0 &&
@@ -519,7 +494,7 @@ ukbd_interrupt(struct ukbd_softc *sc)
uint8_t i;
uint8_t j;
 
-   UKBD_CTX_LOCK_ASSERT();
+   UKBD_LOCK_ASSERT();
 
if (sc->sc_ndata.keycode[0] == KEY_ERROR)
return;
@@ -615,7 +590,7 @@ ukbd_event_keyinput(struct ukbd_softc *s
 {
int c;
 
-   

svn commit: r305805 - head/usr.sbin/autofs

2016-09-14 Thread Edward Tomasz Napierala
Author: trasz
Date: Wed Sep 14 11:20:58 2016
New Revision: 305805
URL: https://svnweb.freebsd.org/changeset/base/305805

Log:
  Use proper argument order for calloc(3).
  
  MFC after:1 month

Modified:
  head/usr.sbin/autofs/automountd.c
  head/usr.sbin/autofs/autounmountd.c
  head/usr.sbin/autofs/defined.c

Modified: head/usr.sbin/autofs/automountd.c
==
--- head/usr.sbin/autofs/automountd.c   Wed Sep 14 11:16:00 2016
(r305804)
+++ head/usr.sbin/autofs/automountd.c   Wed Sep 14 11:20:58 2016
(r305805)
@@ -97,7 +97,7 @@ pick_option(const char *option, char **o
 
tofree = *optionsp;
 
-   newoptions = calloc(strlen(*optionsp) + 1, 1);
+   newoptions = calloc(1, strlen(*optionsp) + 1);
if (newoptions == NULL)
log_err(1, "calloc");
 

Modified: head/usr.sbin/autofs/autounmountd.c
==
--- head/usr.sbin/autofs/autounmountd.c Wed Sep 14 11:16:00 2016
(r305804)
+++ head/usr.sbin/autofs/autounmountd.c Wed Sep 14 11:20:58 2016
(r305805)
@@ -78,7 +78,7 @@ automounted_add(fsid_t fsid, const char 
 {
struct automounted_fs *af;
 
-   af = calloc(sizeof(*af), 1);
+   af = calloc(1, sizeof(*af));
if (af == NULL)
log_err(1, "calloc");
af->af_mount_time = time(NULL);

Modified: head/usr.sbin/autofs/defined.c
==
--- head/usr.sbin/autofs/defined.c  Wed Sep 14 11:16:00 2016
(r305804)
+++ head/usr.sbin/autofs/defined.c  Wed Sep 14 11:20:58 2016
(r305805)
@@ -225,7 +225,7 @@ defined_add(const char *name, const char
 
log_debugx("defining variable %s=%s", name, value);
 
-   d = calloc(sizeof(*d), 1);
+   d = calloc(1, sizeof(*d));
if (d == NULL)
log_err(1, "calloc");
d->d_name = checked_strdup(name);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r305804 - head/sys/boot/kshim

2016-09-14 Thread Hans Petter Selasky
Author: hselasky
Date: Wed Sep 14 11:16:00 2016
New Revision: 305804
URL: https://svnweb.freebsd.org/changeset/base/305804

Log:
  Make the callout structure in the boot loader's kernel shim more
  similar to the kernel one.
  
  MFC after:1 week

Modified:
  head/sys/boot/kshim/bsd_kernel.c
  head/sys/boot/kshim/bsd_kernel.h

Modified: head/sys/boot/kshim/bsd_kernel.c
==
--- head/sys/boot/kshim/bsd_kernel.cWed Sep 14 10:51:06 2016
(r305803)
+++ head/sys/boot/kshim/bsd_kernel.cWed Sep 14 11:16:00 2016
(r305804)
@@ -432,8 +432,8 @@ callout_callback(struct callout *c)
}
mtx_unlock(_callout);
 
-   if (c->func)
-   (c->func) (c->arg);
+   if (c->c_func != NULL)
+   (c->c_func) (c->c_arg);
 
if (!(c->flags & CALLOUT_RETURNUNLOCKED))
mtx_unlock(c->mtx);
@@ -487,8 +487,8 @@ callout_reset(struct callout *c, int to_
 {
callout_stop(c);
 
-   c->func = func;
-   c->arg = arg;
+   c->c_func = func;
+   c->c_arg = arg;
c->timeout = ticks + to_ticks;
 
mtx_lock(_callout);
@@ -507,8 +507,8 @@ callout_stop(struct callout *c)
}
mtx_unlock(_callout);
 
-   c->func = NULL;
-   c->arg = NULL;
+   c->c_func = NULL;
+   c->c_arg = NULL;
 }
 
 void

Modified: head/sys/boot/kshim/bsd_kernel.h
==
--- head/sys/boot/kshim/bsd_kernel.hWed Sep 14 10:51:06 2016
(r305803)
+++ head/sys/boot/kshim/bsd_kernel.hWed Sep 14 11:16:00 2016
(r305804)
@@ -299,8 +299,8 @@ extern volatile int ticks;
 
 struct callout {
LIST_ENTRY(callout) entry;
-   callout_fn_t *func;
-   void   *arg;
+   callout_fn_t *c_func;
+   void   *c_arg;
struct mtx *mtx;
int flags;
int timeout;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r305803 - stable/10/sys/vm

2016-09-14 Thread Konstantin Belousov
Author: kib
Date: Wed Sep 14 10:51:06 2016
New Revision: 305803
URL: https://svnweb.freebsd.org/changeset/base/305803

Log:
  MFC r305129:
  Make swapoff reliable.

Modified:
  stable/10/sys/vm/swap_pager.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/vm/swap_pager.c
==
--- stable/10/sys/vm/swap_pager.c   Wed Sep 14 10:36:44 2016
(r305802)
+++ stable/10/sys/vm/swap_pager.c   Wed Sep 14 10:51:06 2016
(r305803)
@@ -1764,36 +1764,49 @@ static void
 swap_pager_swapoff(struct swdevt *sp)
 {
struct swblock *swap;
+   vm_object_t locked_obj, object;
+   vm_pindex_t pindex;
int i, j, retries;
 
GIANT_REQUIRED;
 
retries = 0;
+   locked_obj = NULL;
 full_rescan:
mtx_lock(_mtx);
for (i = 0; i <= swhash_mask; i++) { /* '<=' is correct here */
 restart:
for (swap = swhash[i]; swap != NULL; swap = swap->swb_hnext) {
-   vm_object_t object = swap->swb_object;
-   vm_pindex_t pindex = swap->swb_index;
+   object = swap->swb_object;
+   pindex = swap->swb_index;
for (j = 0; j < SWAP_META_PAGES; ++j) {
-   if (swp_pager_isondev(swap->swb_pages[j], sp)) {
-   /* avoid deadlock */
+   if (!swp_pager_isondev(swap->swb_pages[j], sp))
+   continue;
+   if (locked_obj != object) {
+   if (locked_obj != NULL)
+   VM_OBJECT_WUNLOCK(locked_obj);
+   locked_obj = object;
if (!VM_OBJECT_TRYWLOCK(object)) {
-   break;
-   } else {
mtx_unlock(_mtx);
-   swp_pager_force_pagein(object,
-   pindex + j);
-   VM_OBJECT_WUNLOCK(object);
+   /* Depends on type-stability. */
+   VM_OBJECT_WLOCK(object);
mtx_lock(_mtx);
goto restart;
}
}
+   MPASS(locked_obj == object);
+   mtx_unlock(_mtx);
+   swp_pager_force_pagein(object, pindex + j);
+   mtx_lock(_mtx);
+   goto restart;
}
}
}
mtx_unlock(_mtx);
+   if (locked_obj != NULL) {
+   VM_OBJECT_WUNLOCK(locked_obj);
+   locked_obj = NULL;
+   }
if (sp->sw_used) {
/*
 * Objects may be locked or paging to the device being
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r305802 - stable/11/sys/vm

2016-09-14 Thread Konstantin Belousov
Author: kib
Date: Wed Sep 14 10:36:44 2016
New Revision: 305802
URL: https://svnweb.freebsd.org/changeset/base/305802

Log:
  MFC r305129:
  Make swapoff reliable.

Modified:
  stable/11/sys/vm/swap_pager.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/vm/swap_pager.c
==
--- stable/11/sys/vm/swap_pager.c   Wed Sep 14 09:17:00 2016
(r305801)
+++ stable/11/sys/vm/swap_pager.c   Wed Sep 14 10:36:44 2016
(r305802)
@@ -1664,36 +1664,49 @@ static void
 swap_pager_swapoff(struct swdevt *sp)
 {
struct swblock *swap;
+   vm_object_t locked_obj, object;
+   vm_pindex_t pindex;
int i, j, retries;
 
sx_assert(_syscall_lock, SA_XLOCKED);
 
retries = 0;
+   locked_obj = NULL;
 full_rescan:
mtx_lock(_mtx);
for (i = 0; i <= swhash_mask; i++) { /* '<=' is correct here */
 restart:
for (swap = swhash[i]; swap != NULL; swap = swap->swb_hnext) {
-   vm_object_t object = swap->swb_object;
-   vm_pindex_t pindex = swap->swb_index;
+   object = swap->swb_object;
+   pindex = swap->swb_index;
for (j = 0; j < SWAP_META_PAGES; ++j) {
-   if (swp_pager_isondev(swap->swb_pages[j], sp)) {
-   /* avoid deadlock */
+   if (!swp_pager_isondev(swap->swb_pages[j], sp))
+   continue;
+   if (locked_obj != object) {
+   if (locked_obj != NULL)
+   VM_OBJECT_WUNLOCK(locked_obj);
+   locked_obj = object;
if (!VM_OBJECT_TRYWLOCK(object)) {
-   break;
-   } else {
mtx_unlock(_mtx);
-   swp_pager_force_pagein(object,
-   pindex + j);
-   VM_OBJECT_WUNLOCK(object);
+   /* Depends on type-stability. */
+   VM_OBJECT_WLOCK(object);
mtx_lock(_mtx);
goto restart;
}
}
+   MPASS(locked_obj == object);
+   mtx_unlock(_mtx);
+   swp_pager_force_pagein(object, pindex + j);
+   mtx_lock(_mtx);
+   goto restart;
}
}
}
mtx_unlock(_mtx);
+   if (locked_obj != NULL) {
+   VM_OBJECT_WUNLOCK(locked_obj);
+   locked_obj = NULL;
+   }
if (sp->sw_used) {
/*
 * Objects may be locked or paging to the device being
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r305797 - stable/11/sys/dev/ahci

2016-09-14 Thread Alexander Motin
Author: mav
Date: Wed Sep 14 09:10:31 2016
New Revision: 305797
URL: https://svnweb.freebsd.org/changeset/base/305797

Log:
  MFC r305536: Fix channel initialization in FBS mode.
  
  Due to reading initialized variable, FIS receive area was always allocated
  as 256 bytes, suitable for command-based switching, instead of 4096 bytes,
  required for FIS-based switching.  This caused memory corruption in case of
  port multipliers used on FBS-capable HBAs (Marvell).

Modified:
  stable/11/sys/dev/ahci/ahci.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/dev/ahci/ahci.c
==
--- stable/11/sys/dev/ahci/ahci.c   Wed Sep 14 08:59:13 2016
(r305796)
+++ stable/11/sys/dev/ahci/ahci.c   Wed Sep 14 09:10:31 2016
(r305797)
@@ -715,6 +715,21 @@ ahci_ch_attach(device_t dev)
if (!(ch->r_mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
, RF_ACTIVE)))
return (ENXIO);
+   ch->chcaps = ATA_INL(ch->r_mem, AHCI_P_CMD);
+   version = ATA_INL(ctlr->r_mem, AHCI_VS);
+   if (version < 0x00010200 && (ctlr->caps & AHCI_CAP_FBSS))
+   ch->chcaps |= AHCI_P_CMD_FBSCP;
+   if (ch->caps2 & AHCI_CAP2_SDS)
+   ch->chscaps = ATA_INL(ch->r_mem, AHCI_P_DEVSLP);
+   if (bootverbose) {
+   device_printf(dev, "Caps:%s%s%s%s%s%s\n",
+   (ch->chcaps & AHCI_P_CMD_HPCP) ? " HPCP":"",
+   (ch->chcaps & AHCI_P_CMD_MPSP) ? " MPSP":"",
+   (ch->chcaps & AHCI_P_CMD_CPD) ? " CPD":"",
+   (ch->chcaps & AHCI_P_CMD_ESP) ? " ESP":"",
+   (ch->chcaps & AHCI_P_CMD_FBSCP) ? " FBSCP":"",
+   (ch->chscaps & AHCI_P_DEVSLP_DSP) ? " DSP":"");
+   }
ahci_dmainit(dev);
ahci_slotsalloc(dev);
mtx_lock(>mtx);
@@ -733,21 +748,6 @@ ahci_ch_attach(device_t dev)
error = ENXIO;
goto err1;
}
-   ch->chcaps = ATA_INL(ch->r_mem, AHCI_P_CMD);
-   version = ATA_INL(ctlr->r_mem, AHCI_VS);
-   if (version < 0x00010200 && (ctlr->caps & AHCI_CAP_FBSS))
-   ch->chcaps |= AHCI_P_CMD_FBSCP;
-   if (ch->caps2 & AHCI_CAP2_SDS)
-   ch->chscaps = ATA_INL(ch->r_mem, AHCI_P_DEVSLP);
-   if (bootverbose) {
-   device_printf(dev, "Caps:%s%s%s%s%s%s\n",
-   (ch->chcaps & AHCI_P_CMD_HPCP) ? " HPCP":"",
-   (ch->chcaps & AHCI_P_CMD_MPSP) ? " MPSP":"",
-   (ch->chcaps & AHCI_P_CMD_CPD) ? " CPD":"",
-   (ch->chcaps & AHCI_P_CMD_ESP) ? " ESP":"",
-   (ch->chcaps & AHCI_P_CMD_FBSCP) ? " FBSCP":"",
-   (ch->chscaps & AHCI_P_DEVSLP_DSP) ? " DSP":"");
-   }
/* Create the device queue for our SIM. */
devq = cam_simq_alloc(ch->numslots);
if (devq == NULL) {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r305801 - head/sys/dev/hyperv/netvsc

2016-09-14 Thread Sepherosa Ziehau
Author: sephe
Date: Wed Sep 14 09:17:00 2016
New Revision: 305801
URL: https://svnweb.freebsd.org/changeset/base/305801

Log:
  hyperv/hn: Fix some ifnet settings
  
  - ifnet.if_mtu does not require explicit setting.
  - ifnet.if_hdrlen must be set after ether_ifattach().
  
  MFC after:1 week
  Sponsored by: Microsoft
  Differential Revision:https://reviews.freebsd.org/D7873

Modified:
  head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c

Modified: head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
==
--- head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c  Wed Sep 14 09:13:17 
2016(r305800)
+++ head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c  Wed Sep 14 09:17:00 
2016(r305801)
@@ -536,7 +536,6 @@ netvsc_attach(device_t dev)
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_ioctl = hn_ioctl;
ifp->if_init = hn_init;
-   ifp->if_mtu = ETHERMTU;
if (hn_use_if_start) {
int qdepth = hn_get_txswq_depth(>hn_tx_ring[0]);
 
@@ -558,7 +557,6 @@ netvsc_attach(device_t dev)
/*
 * Tell upper layers that we support full VLAN capability.
 */
-   ifp->if_hdrlen = sizeof(struct ether_vlan_header);
ifp->if_capabilities |=
IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_MTU | IFCAP_HWCSUM | IFCAP_TSO |
IFCAP_LRO;
@@ -600,6 +598,9 @@ netvsc_attach(device_t dev)
if_printf(ifp, "TSO: %u/%u/%u\n", ifp->if_hw_tsomax,
ifp->if_hw_tsomaxsegcount, ifp->if_hw_tsomaxsegsize);
 
+   /* Inform the upper layer about the long frame support. */
+   ifp->if_hdrlen = sizeof(struct ether_vlan_header);
+
hn_set_chim_size(sc, sc->hn_chim_szmax);
if (hn_tx_chimney_size > 0 &&
hn_tx_chimney_size < sc->hn_chim_szmax)
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r305800 - stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2016-09-14 Thread Alexander Motin
Author: mav
Date: Wed Sep 14 09:13:17 2016
New Revision: 305800
URL: https://svnweb.freebsd.org/changeset/base/305800

Log:
  MFC r305123: Fix kernel panic when inheriting properties without default.
  
  There are two writable hidden properties "iscsioptions" and "stmf_sbd_lu",
  that have no default string value.  Attempt to unset them or replicate
  caused kernel panic.  This simple bandaid seems fixes the problem nicely.

Modified:
  stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_prop.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_prop.c
==
--- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_prop.c Wed Sep 
14 09:12:49 2016(r305799)
+++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_prop.c Wed Sep 
14 09:13:17 2016(r305800)
@@ -54,6 +54,8 @@ dodefault(zfs_prop_t prop, int intsz, in
return (SET_ERROR(ENOENT));
 
if (zfs_prop_get_type(prop) == PROP_TYPE_STRING) {
+   if (zfs_prop_default_string(prop) == NULL)
+   return (SET_ERROR(ENOENT));
if (intsz != 1)
return (SET_ERROR(EOVERFLOW));
(void) strncpy(buf, zfs_prop_default_string(prop),
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r305799 - stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2016-09-14 Thread Alexander Motin
Author: mav
Date: Wed Sep 14 09:12:49 2016
New Revision: 305799
URL: https://svnweb.freebsd.org/changeset/base/305799

Log:
  MFC r305123: Fix kernel panic when inheriting properties without default.
  
  There are two writable hidden properties "iscsioptions" and "stmf_sbd_lu",
  that have no default string value.  Attempt to unset them or replicate
  caused kernel panic.  This simple bandaid seems fixes the problem nicely.

Modified:
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_prop.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_prop.c
==
--- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_prop.c Wed Sep 
14 09:11:03 2016(r305798)
+++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_prop.c Wed Sep 
14 09:12:49 2016(r305799)
@@ -54,6 +54,8 @@ dodefault(zfs_prop_t prop, int intsz, in
return (SET_ERROR(ENOENT));
 
if (zfs_prop_get_type(prop) == PROP_TYPE_STRING) {
+   if (zfs_prop_default_string(prop) == NULL)
+   return (SET_ERROR(ENOENT));
if (intsz != 1)
return (SET_ERROR(EOVERFLOW));
(void) strncpy(buf, zfs_prop_default_string(prop),
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r305798 - stable/10/sys/dev/ahci

2016-09-14 Thread Alexander Motin
Author: mav
Date: Wed Sep 14 09:11:03 2016
New Revision: 305798
URL: https://svnweb.freebsd.org/changeset/base/305798

Log:
  MFC r305536: Fix channel initialization in FBS mode.
  
  Due to reading initialized variable, FIS receive area was always allocated
  as 256 bytes, suitable for command-based switching, instead of 4096 bytes,
  required for FIS-based switching.  This caused memory corruption in case of
  MFC r305536: Fix channel initialization in FBS mode.
  
  Due to reading initialized variable, FIS receive area was always allocated
  as 256 bytes, suitable for command-based switching, instead of 4096 bytes,
  required for FIS-based switching.  This caused memory corruption in case of
  port multipliers used on FBS-capable HBAs (Marvell).

Modified:
  stable/10/sys/dev/ahci/ahci.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/ahci/ahci.c
==
--- stable/10/sys/dev/ahci/ahci.c   Wed Sep 14 09:10:31 2016
(r305797)
+++ stable/10/sys/dev/ahci/ahci.c   Wed Sep 14 09:11:03 2016
(r305798)
@@ -668,6 +668,21 @@ ahci_ch_attach(device_t dev)
if (!(ch->r_mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
, RF_ACTIVE)))
return (ENXIO);
+   ch->chcaps = ATA_INL(ch->r_mem, AHCI_P_CMD);
+   version = ATA_INL(ctlr->r_mem, AHCI_VS);
+   if (version < 0x00010200 && (ctlr->caps & AHCI_CAP_FBSS))
+   ch->chcaps |= AHCI_P_CMD_FBSCP;
+   if (ch->caps2 & AHCI_CAP2_SDS)
+   ch->chscaps = ATA_INL(ch->r_mem, AHCI_P_DEVSLP);
+   if (bootverbose) {
+   device_printf(dev, "Caps:%s%s%s%s%s%s\n",
+   (ch->chcaps & AHCI_P_CMD_HPCP) ? " HPCP":"",
+   (ch->chcaps & AHCI_P_CMD_MPSP) ? " MPSP":"",
+   (ch->chcaps & AHCI_P_CMD_CPD) ? " CPD":"",
+   (ch->chcaps & AHCI_P_CMD_ESP) ? " ESP":"",
+   (ch->chcaps & AHCI_P_CMD_FBSCP) ? " FBSCP":"",
+   (ch->chscaps & AHCI_P_DEVSLP_DSP) ? " DSP":"");
+   }
ahci_dmainit(dev);
ahci_slotsalloc(dev);
mtx_lock(>mtx);
@@ -686,21 +701,6 @@ ahci_ch_attach(device_t dev)
error = ENXIO;
goto err1;
}
-   ch->chcaps = ATA_INL(ch->r_mem, AHCI_P_CMD);
-   version = ATA_INL(ctlr->r_mem, AHCI_VS);
-   if (version < 0x00010200 && (ctlr->caps & AHCI_CAP_FBSS))
-   ch->chcaps |= AHCI_P_CMD_FBSCP;
-   if (ch->caps2 & AHCI_CAP2_SDS)
-   ch->chscaps = ATA_INL(ch->r_mem, AHCI_P_DEVSLP);
-   if (bootverbose) {
-   device_printf(dev, "Caps:%s%s%s%s%s%s\n",
-   (ch->chcaps & AHCI_P_CMD_HPCP) ? " HPCP":"",
-   (ch->chcaps & AHCI_P_CMD_MPSP) ? " MPSP":"",
-   (ch->chcaps & AHCI_P_CMD_CPD) ? " CPD":"",
-   (ch->chcaps & AHCI_P_CMD_ESP) ? " ESP":"",
-   (ch->chcaps & AHCI_P_CMD_FBSCP) ? " FBSCP":"",
-   (ch->chscaps & AHCI_P_DEVSLP_DSP) ? " DSP":"");
-   }
/* Create the device queue for our SIM. */
devq = cam_simq_alloc(ch->numslots);
if (devq == NULL) {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r305796 - head/sys/dev/hyperv/netvsc

2016-09-14 Thread Sepherosa Ziehau
Author: sephe
Date: Wed Sep 14 08:59:13 2016
New Revision: 305796
URL: https://svnweb.freebsd.org/changeset/base/305796

Log:
  hyperv/hn: Remove the FreeBSD_version check for TSO configuration
  
  It is available on both stable/10 and stable/11. This eases future MFCs
  to stable/10.
  
  MFC after:1 week
  Sponsored by: Microsoft
  Differential Revision:https://reviews.freebsd.org/D7872

Modified:
  head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c

Modified: head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
==
--- head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c  Wed Sep 14 08:48:08 
2016(r305795)
+++ head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c  Wed Sep 14 08:59:13 
2016(r305796)
@@ -232,12 +232,10 @@ SYSCTL_INT(_hw_hn, OID_AUTO, trust_hosti
 "Trust ip packet verification on host side, "
 "when csum info is missing (global setting)");
 
-#if __FreeBSD_version >= 1100045
 /* Limit TSO burst size */
 static int hn_tso_maxlen = 0;
 SYSCTL_INT(_hw_hn, OID_AUTO, tso_maxlen, CTLFLAG_RDTUN,
 _tso_maxlen, 0, "TSO burst limit");
-#endif
 
 /* Limit chimney send size */
 static int hn_tx_chimney_size = 0;
@@ -452,9 +450,7 @@ netvsc_attach(device_t dev)
uint32_t link_status;
struct ifnet *ifp = NULL;
int error, ring_cnt, tx_ring_cnt;
-#if __FreeBSD_version >= 1100045
int tso_maxlen;
-#endif
 
sc->hn_dev = dev;
sc->hn_prichan = vmbus_get_channel(dev);
@@ -587,7 +583,6 @@ netvsc_attach(device_t dev)
if (link_status == NDIS_MEDIA_STATE_CONNECTED)
sc->hn_carrier = 1;
 
-#if __FreeBSD_version >= 1100045
tso_maxlen = hn_tso_maxlen;
if (tso_maxlen <= 0 || tso_maxlen > IP_MAXPACKET)
tso_maxlen = IP_MAXPACKET;
@@ -596,17 +591,14 @@ netvsc_attach(device_t dev)
ifp->if_hw_tsomaxsegsize = PAGE_SIZE;
ifp->if_hw_tsomax = tso_maxlen -
(ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN);
-#endif
 
error = hn_rndis_get_eaddr(sc, eaddr);
if (error)
goto failed;
ether_ifattach(ifp, eaddr);
 
-#if __FreeBSD_version >= 1100045
if_printf(ifp, "TSO: %u/%u/%u\n", ifp->if_hw_tsomax,
ifp->if_hw_tsomaxsegcount, ifp->if_hw_tsomaxsegsize);
-#endif
 
hn_set_chim_size(sc, sc->hn_chim_szmax);
if (hn_tx_chimney_size > 0 &&
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r305795 - head/sys/dev/hyperv/netvsc

2016-09-14 Thread Sepherosa Ziehau
Author: sephe
Date: Wed Sep 14 08:48:08 2016
New Revision: 305795
URL: https://svnweb.freebsd.org/changeset/base/305795

Log:
  hyperv/hn: Bring in shims from stable/10
  
  This eases future MFCs to stable/10.
  
  MFC after:1 week
  Sponsored by: Microsoft
  Differential Revision:https://reviews.freebsd.org/D7871

Modified:
  head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c

Modified: head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
==
--- head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c  Wed Sep 14 08:33:08 
2016(r305794)
+++ head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c  Wed Sep 14 08:48:08 
2016(r305795)
@@ -318,8 +318,12 @@ static int hn_lro_ackcnt_sysctl(SYSCTL_H
 #endif
 static int hn_trust_hcsum_sysctl(SYSCTL_HANDLER_ARGS);
 static int hn_chim_size_sysctl(SYSCTL_HANDLER_ARGS);
-static int hn_rx_stat_ulong_sysctl(SYSCTL_HANDLER_ARGS);
+#if __FreeBSD_version < 1100095
+static int hn_rx_stat_int_sysctl(SYSCTL_HANDLER_ARGS);
+#else
 static int hn_rx_stat_u64_sysctl(SYSCTL_HANDLER_ARGS);
+#endif
+static int hn_rx_stat_ulong_sysctl(SYSCTL_HANDLER_ARGS);
 static int hn_tx_stat_ulong_sysctl(SYSCTL_HANDLER_ARGS);
 static int hn_tx_conf_int_sysctl(SYSCTL_HANDLER_ARGS);
 static int hn_ndis_version_sysctl(SYSCTL_HANDLER_ARGS);
@@ -1866,32 +1870,33 @@ hn_chim_size_sysctl(SYSCTL_HANDLER_ARGS)
return 0;
 }
 
+#if __FreeBSD_version < 1100095
 static int
-hn_rx_stat_ulong_sysctl(SYSCTL_HANDLER_ARGS)
+hn_rx_stat_int_sysctl(SYSCTL_HANDLER_ARGS)
 {
struct hn_softc *sc = arg1;
int ofs = arg2, i, error;
struct hn_rx_ring *rxr;
-   u_long stat;
+   uint64_t stat;
 
stat = 0;
-   for (i = 0; i < sc->hn_rx_ring_inuse; ++i) {
+   for (i = 0; i < sc->hn_rx_ring_cnt; ++i) {
rxr = >hn_rx_ring[i];
-   stat += *((u_long *)((uint8_t *)rxr + ofs));
+   stat += *((int *)((uint8_t *)rxr + ofs));
}
 
-   error = sysctl_handle_long(oidp, , 0, req);
+   error = sysctl_handle_64(oidp, , 0, req);
if (error || req->newptr == NULL)
return error;
 
/* Zero out this stat. */
-   for (i = 0; i < sc->hn_rx_ring_inuse; ++i) {
+   for (i = 0; i < sc->hn_rx_ring_cnt; ++i) {
rxr = >hn_rx_ring[i];
-   *((u_long *)((uint8_t *)rxr + ofs)) = 0;
+   *((int *)((uint8_t *)rxr + ofs)) = 0;
}
return 0;
 }
-
+#else
 static int
 hn_rx_stat_u64_sysctl(SYSCTL_HANDLER_ARGS)
 {
@@ -1918,6 +1923,34 @@ hn_rx_stat_u64_sysctl(SYSCTL_HANDLER_ARG
return 0;
 }
 
+#endif
+
+static int
+hn_rx_stat_ulong_sysctl(SYSCTL_HANDLER_ARGS)
+{
+   struct hn_softc *sc = arg1;
+   int ofs = arg2, i, error;
+   struct hn_rx_ring *rxr;
+   u_long stat;
+
+   stat = 0;
+   for (i = 0; i < sc->hn_rx_ring_inuse; ++i) {
+   rxr = >hn_rx_ring[i];
+   stat += *((u_long *)((uint8_t *)rxr + ofs));
+   }
+
+   error = sysctl_handle_long(oidp, , 0, req);
+   if (error || req->newptr == NULL)
+   return error;
+
+   /* Zero out this stat. */
+   for (i = 0; i < sc->hn_rx_ring_inuse; ++i) {
+   rxr = >hn_rx_ring[i];
+   *((u_long *)((uint8_t *)rxr + ofs)) = 0;
+   }
+   return 0;
+}
+
 static int
 hn_tx_stat_ulong_sysctl(SYSCTL_HANDLER_ARGS)
 {
@@ -2168,11 +2201,21 @@ hn_create_rx_data(struct hn_softc *sc, i
SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "lro_queued",
CTLTYPE_U64 | CTLFLAG_RW | CTLFLAG_MPSAFE, sc,
__offsetof(struct hn_rx_ring, hn_lro.lro_queued),
-   hn_rx_stat_u64_sysctl, "LU", "LRO queued");
+#if __FreeBSD_version < 1100095
+   hn_rx_stat_int_sysctl,
+#else
+   hn_rx_stat_u64_sysctl,
+#endif
+   "LU", "LRO queued");
SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "lro_flushed",
CTLTYPE_U64 | CTLFLAG_RW | CTLFLAG_MPSAFE, sc,
__offsetof(struct hn_rx_ring, hn_lro.lro_flushed),
-   hn_rx_stat_u64_sysctl, "LU", "LRO flushed");
+#if __FreeBSD_version < 1100095
+   hn_rx_stat_int_sysctl,
+#else
+   hn_rx_stat_u64_sysctl,
+#endif
+   "LU", "LRO flushed");
SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "lro_tried",
CTLTYPE_ULONG | CTLFLAG_RW | CTLFLAG_MPSAFE, sc,
__offsetof(struct hn_rx_ring, hn_lro_tried),
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r305794 - head/sys/dev/hyperv/netvsc

2016-09-14 Thread Sepherosa Ziehau
Author: sephe
Date: Wed Sep 14 08:33:08 2016
New Revision: 305794
URL: https://svnweb.freebsd.org/changeset/base/305794

Log:
  hyperv/hn: Use sx for the main lock.
  
  MFC after:1 week
  Sponsored by: Microsoft
  Differential Revision:https://reviews.freebsd.org/D7870

Modified:
  head/sys/dev/hyperv/netvsc/hv_net_vsc.h
  head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c

Modified: head/sys/dev/hyperv/netvsc/hv_net_vsc.h
==
--- head/sys/dev/hyperv/netvsc/hv_net_vsc.h Wed Sep 14 08:24:01 2016
(r305793)
+++ head/sys/dev/hyperv/netvsc/hv_net_vsc.h Wed Sep 14 08:33:08 2016
(r305794)
@@ -204,10 +204,7 @@ struct hn_softc {
device_thn_dev;
int hn_carrier;
int hn_if_flags;
-   struct mtx  hn_lock;
-   int hn_initdone;
-   /* See hv_netvsc_drv_freebsd.c for rules on how to use */
-   int temp_unusable;
+   struct sx   hn_lock;
struct vmbus_channel *hn_prichan;
 
int hn_rx_ring_cnt;

Modified: head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
==
--- head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c  Wed Sep 14 08:24:01 
2016(r305793)
+++ head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c  Wed Sep 14 08:33:08 
2016(r305794)
@@ -195,21 +195,12 @@ struct hn_txdesc {
 
 #define HN_LRO_ACKCNT_DEF  1
 
-/*
- * Be aware that this sleepable mutex will exhibit WITNESS errors when
- * certain TCP and ARP code paths are taken.  This appears to be a
- * well-known condition, as all other drivers checked use a sleeping
- * mutex to protect their transmit paths.
- * Also Be aware that mutexes do not play well with semaphores, and there
- * is a conflicting semaphore in a certain channel code path.
- */
-#define NV_LOCK_INIT(_sc, _name) \
-   mtx_init(&(_sc)->hn_lock, _name, MTX_NETWORK_LOCK, MTX_DEF)
-#define NV_LOCK(_sc)   mtx_lock(&(_sc)->hn_lock)
-#define NV_LOCK_ASSERT(_sc)mtx_assert(&(_sc)->hn_lock, MA_OWNED)
-#define NV_UNLOCK(_sc) mtx_unlock(&(_sc)->hn_lock)
-#define NV_LOCK_DESTROY(_sc)   mtx_destroy(&(_sc)->hn_lock)
-
+#define HN_LOCK_INIT(sc)   \
+   sx_init(&(sc)->hn_lock, device_get_nameunit((sc)->hn_dev))
+#define HN_LOCK_ASSERT(sc) sx_assert(&(sc)->hn_lock, SA_XLOCKED)
+#define HN_LOCK_DESTROY(sc)sx_destroy(&(sc)->hn_lock)
+#define HN_LOCK(sc)sx_xlock(&(sc)->hn_lock)
+#define HN_UNLOCK(sc)  sx_xunlock(&(sc)->hn_lock)
 
 /*
  * Globals
@@ -463,6 +454,7 @@ netvsc_attach(device_t dev)
 
sc->hn_dev = dev;
sc->hn_prichan = vmbus_get_channel(dev);
+   HN_LOCK_INIT(sc);
 
if (hn_tx_taskq == NULL) {
sc->hn_tx_taskq = taskqueue_create("hn_tx", M_WAITOK,
@@ -484,7 +476,6 @@ netvsc_attach(device_t dev)
} else {
sc->hn_tx_taskq = hn_tx_taskq;
}
-   NV_LOCK_INIT(sc, "NetVSCLock");
 
ifp = sc->hn_ifp = if_alloc(IFT_ETHER);
ifp->if_softc = sc;
@@ -669,6 +660,7 @@ netvsc_detach(device_t dev)
taskqueue_free(sc->hn_tx_taskq);
 
vmbus_xact_ctx_destroy(sc->hn_xact);
+   HN_LOCK_DESTROY(sc);
return (0);
 }
 
@@ -1475,39 +1467,27 @@ skip:
return (0);
 }
 
-/*
- * Rules for using sc->temp_unusable:
- * 1.  sc->temp_unusable can only be read or written while holding NV_LOCK()
- * 2.  code reading sc->temp_unusable under NV_LOCK(), and finding 
- * sc->temp_unusable set, must release NV_LOCK() and exit
- * 3.  to retain exclusive control of the interface,
- * sc->temp_unusable must be set by code before releasing NV_LOCK()
- * 4.  only code setting sc->temp_unusable can clear sc->temp_unusable
- * 5.  code setting sc->temp_unusable must eventually clear sc->temp_unusable
- */
-
-/*
- * Standard ioctl entry point.  Called when the user wants to configure
- * the interface.
- */
 static int
 hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
 {
struct hn_softc *sc = ifp->if_softc;
struct ifreq *ifr = (struct ifreq *)data;
int mask, error = 0;
-   int retry_cnt = 500;
-   
+
switch (cmd) {
case SIOCSIFMTU:
-   if (ifp->if_mtu == ifr->ifr_mtu)
-   break;
-
if (ifr->ifr_mtu > NETVSC_MAX_CONFIGURABLE_MTU) {
error = EINVAL;
break;
}
 
+   HN_LOCK(sc);
+
+   if (ifp->if_mtu == ifr->ifr_mtu) {
+   HN_UNLOCK(sc);
+   break;
+   }
+
/* Obtain and record requested MTU */
ifp->if_mtu = ifr->ifr_mtu;
 
@@ -1516,40 +1496,18 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, 
 * Make 

svn commit: r305793 - head/sys/dev/hyperv/netvsc

2016-09-14 Thread Sepherosa Ziehau
Author: sephe
Date: Wed Sep 14 08:24:01 2016
New Revision: 305793
URL: https://svnweb.freebsd.org/changeset/base/305793

Log:
  hyperv/hn: Cleanup hn_ioctl.
  
  MFC after:1 week
  Sponsored by: Microsoft
  Differential Revision:https://reviews.freebsd.org/D7869

Modified:
  head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c

Modified: head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
==
--- head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c  Wed Sep 14 08:08:45 
2016(r305792)
+++ head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c  Wed Sep 14 08:24:01 
2016(r305793)
@@ -1495,27 +1495,11 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, 
 {
struct hn_softc *sc = ifp->if_softc;
struct ifreq *ifr = (struct ifreq *)data;
-#ifdef INET
-   struct ifaddr *ifa = (struct ifaddr *)data;
-#endif
int mask, error = 0;
int retry_cnt = 500;

-   switch(cmd) {
-
-   case SIOCSIFADDR:
-#ifdef INET
-   if (ifa->ifa_addr->sa_family == AF_INET) {
-   ifp->if_flags |= IFF_UP;
-   if (!(ifp->if_drv_flags & IFF_DRV_RUNNING))
-   hn_init(sc);
-   arp_ifinit(ifp, ifa);
-   } else
-#endif
-   error = ether_ioctl(ifp, cmd, data);
-   break;
+   switch (cmd) {
case SIOCSIFMTU:
-   /* Check MTU value change */
if (ifp->if_mtu == ifr->ifr_mtu)
break;
 
@@ -1589,6 +1573,7 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, 
sc->temp_unusable = FALSE;
NV_UNLOCK(sc);
break;
+
case SIOCSIFFLAGS:
do {
NV_LOCK(sc);
@@ -1639,8 +1624,8 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, 
sc->temp_unusable = FALSE;
NV_UNLOCK(sc);
sc->hn_if_flags = ifp->if_flags;
-   error = 0;
break;
+
case SIOCSIFCAP:
NV_LOCK(sc);
 
@@ -1679,30 +1664,27 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, 
}
 
NV_UNLOCK(sc);
-   error = 0;
break;
+
case SIOCADDMULTI:
case SIOCDELMULTI:
-#ifdef notyet
-   /* Fixme:  Multicast mode? */
-   if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
-   NV_LOCK(sc);
-   netvsc_setmulti(sc);
-   NV_UNLOCK(sc);
-   error = 0;
-   }
-#endif
-   error = EINVAL;
+   /* Always all-multi */
+   /*
+* TODO:
+* Enable/disable all-multi according to the emptiness of
+* the mcast address list.
+*/
break;
+
case SIOCSIFMEDIA:
case SIOCGIFMEDIA:
error = ifmedia_ioctl(ifp, ifr, >hn_media, cmd);
break;
+
default:
error = ether_ioctl(ifp, cmd, data);
break;
}
-
return (error);
 }
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r305792 - head/sys/dev/hyperv/netvsc

2016-09-14 Thread Sepherosa Ziehau
Author: sephe
Date: Wed Sep 14 08:08:45 2016
New Revision: 305792
URL: https://svnweb.freebsd.org/changeset/base/305792

Log:
  hyperv/hn: Function renaming: hn_ifinit -> hn_init
  
  No functional changes.
  
  MFC after:1 week
  Sponsored by: Microsoft
  Differential Revision:https://reviews.freebsd.org/D7868

Modified:
  head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c

Modified: head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
==
--- head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c  Wed Sep 14 08:00:30 
2016(r305791)
+++ head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c  Wed Sep 14 08:08:45 
2016(r305792)
@@ -313,8 +313,8 @@ static u_int hn_cpu_index;
  * Forward declarations
  */
 static void hn_stop(struct hn_softc *sc);
-static void hn_ifinit_locked(struct hn_softc *sc);
-static void hn_ifinit(void *xsc);
+static void hn_init_locked(struct hn_softc *sc);
+static void hn_init(void *xsc);
 static int  hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data);
 static int hn_start_locked(struct hn_tx_ring *txr, int len);
 static void hn_start(struct ifnet *ifp);
@@ -544,7 +544,7 @@ netvsc_attach(device_t dev)
 
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_ioctl = hn_ioctl;
-   ifp->if_init = hn_ifinit;
+   ifp->if_init = hn_init;
ifp->if_mtu = ETHERMTU;
if (hn_use_if_start) {
int qdepth = hn_get_txswq_depth(>hn_tx_ring[0]);
@@ -1508,7 +1508,7 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, 
if (ifa->ifa_addr->sa_family == AF_INET) {
ifp->if_flags |= IFF_UP;
if (!(ifp->if_drv_flags & IFF_DRV_RUNNING))
-   hn_ifinit(sc);
+   hn_init(sc);
arp_ifinit(ifp, ifa);
} else
 #endif
@@ -1583,7 +1583,7 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, 
if (sc->hn_tx_ring[0].hn_chim_size > sc->hn_chim_szmax)
hn_set_chim_size(sc, sc->hn_chim_szmax);
 
-   hn_ifinit_locked(sc);
+   hn_init_locked(sc);
 
NV_LOCK(sc);
sc->temp_unusable = FALSE;
@@ -1629,7 +1629,7 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, 
/* do something here for Hyper-V */
} else
 #endif
-   hn_ifinit_locked(sc);
+   hn_init_locked(sc);
} else {
if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
hn_stop(sc);
@@ -1787,7 +1787,7 @@ do_sched:
 }
 
 static void
-hn_ifinit_locked(struct hn_softc *sc)
+hn_init_locked(struct hn_softc *sc)
 {
struct ifnet *ifp;
int ret, i;
@@ -1819,7 +1819,7 @@ hn_ifinit_locked(struct hn_softc *sc)
  *
  */
 static void
-hn_ifinit(void *xsc)
+hn_init(void *xsc)
 {
struct hn_softc *sc = xsc;
 
@@ -1831,7 +1831,7 @@ hn_ifinit(void *xsc)
sc->temp_unusable = TRUE;
NV_UNLOCK(sc);
 
-   hn_ifinit_locked(sc);
+   hn_init_locked(sc);
 
NV_LOCK(sc);
sc->temp_unusable = FALSE;
@@ -1847,7 +1847,7 @@ hn_watchdog(struct ifnet *ifp)
 {
 
if_printf(ifp, "watchdog timeout -- resetting\n");
-   hn_ifinit(ifp->if_softc);/* XXX */
+   hn_init(ifp->if_softc);/* XXX */
if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
 }
 #endif
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r305791 - head/sys/dev/hyperv/netvsc

2016-09-14 Thread Sepherosa Ziehau
Author: sephe
Date: Wed Sep 14 08:00:30 2016
New Revision: 305791
URL: https://svnweb.freebsd.org/changeset/base/305791

Log:
  hyperv/hn: Deprecate hn_softc_t
  
  MFC after:1 week
  Sponsored by: Microsoft
  Differential Revision:https://reviews.freebsd.org/D7867

Modified:
  head/sys/dev/hyperv/netvsc/hv_net_vsc.h
  head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c

Modified: head/sys/dev/hyperv/netvsc/hv_net_vsc.h
==
--- head/sys/dev/hyperv/netvsc/hv_net_vsc.h Wed Sep 14 06:47:25 2016
(r305790)
+++ head/sys/dev/hyperv/netvsc/hv_net_vsc.h Wed Sep 14 08:00:30 2016
(r305791)
@@ -198,7 +198,7 @@ struct hn_tx_ring {
 /*
  * Device-specific softc structure
  */
-typedef struct hn_softc {
+struct hn_softc {
struct ifnet*hn_ifp;
struct ifmedia  hn_media;
device_thn_dev;
@@ -243,7 +243,7 @@ typedef struct hn_softc {
uint32_thn_ndis_ver;
 
struct ndis_rssprm_toeplitz hn_rss;
-} hn_softc_t;
+};
 
 #define HN_FLAG_RXBUF_CONNECTED0x0001
 #define HN_FLAG_CHIM_CONNECTED 0x0002

Modified: head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
==
--- head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c  Wed Sep 14 06:47:25 
2016(r305790)
+++ head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c  Wed Sep 14 08:00:30 
2016(r305791)
@@ -312,8 +312,8 @@ static u_int hn_cpu_index;
 /*
  * Forward declarations
  */
-static void hn_stop(hn_softc_t *sc);
-static void hn_ifinit_locked(hn_softc_t *sc);
+static void hn_stop(struct hn_softc *sc);
+static void hn_ifinit_locked(struct hn_softc *sc);
 static void hn_ifinit(void *xsc);
 static int  hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data);
 static int hn_start_locked(struct hn_tx_ring *txr, int len);
@@ -450,19 +450,17 @@ netvsc_probe(device_t dev)
 static int
 netvsc_attach(device_t dev)
 {
+   struct hn_softc *sc = device_get_softc(dev);
struct sysctl_oid_list *child;
struct sysctl_ctx_list *ctx;
uint8_t eaddr[ETHER_ADDR_LEN];
uint32_t link_status;
-   hn_softc_t *sc;
struct ifnet *ifp = NULL;
int error, ring_cnt, tx_ring_cnt;
 #if __FreeBSD_version >= 1100045
int tso_maxlen;
 #endif
 
-   sc = device_get_softc(dev);
-
sc->hn_dev = dev;
sc->hn_prichan = vmbus_get_channel(dev);
 
@@ -1495,7 +1493,7 @@ skip:
 static int
 hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
 {
-   hn_softc_t *sc = ifp->if_softc;
+   struct hn_softc *sc = ifp->if_softc;
struct ifreq *ifr = (struct ifreq *)data;
 #ifdef INET
struct ifaddr *ifa = (struct ifaddr *)data;
@@ -1708,11 +1706,8 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, 
return (error);
 }
 
-/*
- *
- */
 static void
-hn_stop(hn_softc_t *sc)
+hn_stop(struct hn_softc *sc)
 {
struct ifnet *ifp;
int ret, i;
@@ -1791,11 +1786,8 @@ do_sched:
}
 }
 
-/*
- *
- */
 static void
-hn_ifinit_locked(hn_softc_t *sc)
+hn_ifinit_locked(struct hn_softc *sc)
 {
struct ifnet *ifp;
int ret, i;
@@ -1829,7 +1821,7 @@ hn_ifinit_locked(hn_softc_t *sc)
 static void
 hn_ifinit(void *xsc)
 {
-   hn_softc_t *sc = xsc;
+   struct hn_softc *sc = xsc;
 
NV_LOCK(sc);
if (sc->temp_unusable) {
@@ -3485,7 +3477,7 @@ static device_method_t netvsc_methods[] 
 static driver_t netvsc_driver = {
 NETVSC_DEVNAME,
 netvsc_methods,
-sizeof(hn_softc_t)
+sizeof(struct hn_softc)
 };
 
 static devclass_t netvsc_devclass;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r305790 - head/sys/dev/hyperv/netvsc

2016-09-14 Thread Sepherosa Ziehau
Author: sephe
Date: Wed Sep 14 06:47:25 2016
New Revision: 305790
URL: https://svnweb.freebsd.org/changeset/base/305790

Log:
  hyperv/hn: Remove unused softc field
  
  MFC after:1 week
  Sponsored by: Microsoft
  Differential Revision:https://reviews.freebsd.org/D7866

Modified:
  head/sys/dev/hyperv/netvsc/hv_net_vsc.h
  head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c

Modified: head/sys/dev/hyperv/netvsc/hv_net_vsc.h
==
--- head/sys/dev/hyperv/netvsc/hv_net_vsc.h Wed Sep 14 06:30:14 2016
(r305789)
+++ head/sys/dev/hyperv/netvsc/hv_net_vsc.h Wed Sep 14 06:47:25 2016
(r305790)
@@ -202,7 +202,6 @@ typedef struct hn_softc {
struct ifnet*hn_ifp;
struct ifmedia  hn_media;
device_thn_dev;
-   uint8_t hn_unit;
int hn_carrier;
int hn_if_flags;
struct mtx  hn_lock;

Modified: head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
==
--- head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c  Wed Sep 14 06:30:14 
2016(r305789)
+++ head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c  Wed Sep 14 06:47:25 
2016(r305790)
@@ -455,7 +455,6 @@ netvsc_attach(device_t dev)
uint8_t eaddr[ETHER_ADDR_LEN];
uint32_t link_status;
hn_softc_t *sc;
-   int unit = device_get_unit(dev);
struct ifnet *ifp = NULL;
int error, ring_cnt, tx_ring_cnt;
 #if __FreeBSD_version >= 1100045
@@ -464,7 +463,6 @@ netvsc_attach(device_t dev)
 
sc = device_get_softc(dev);
 
-   sc->hn_unit = unit;
sc->hn_dev = dev;
sc->hn_prichan = vmbus_get_channel(dev);
 
@@ -1855,11 +1853,9 @@ hn_ifinit(void *xsc)
 static void
 hn_watchdog(struct ifnet *ifp)
 {
-   hn_softc_t *sc;
-   sc = ifp->if_softc;
 
-   printf("hn%d: watchdog timeout -- resetting\n", sc->hn_unit);
-   hn_ifinit(sc);/*???*/
+   if_printf(ifp, "watchdog timeout -- resetting\n");
+   hn_ifinit(ifp->if_softc);/* XXX */
if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
 }
 #endif
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r305789 - head/sys/dev/hyperv/vmbus

2016-09-14 Thread Sepherosa Ziehau
Author: sephe
Date: Wed Sep 14 06:30:14 2016
New Revision: 305789
URL: https://svnweb.freebsd.org/changeset/base/305789

Log:
  hyperv/vmbus: Make sure that the sub-channel count is valid.
  
  MFC after:1 week
  Sponsored by: Microsoft
  Differential Revision:https://reviews.freebsd.org/D7865

Modified:
  head/sys/dev/hyperv/vmbus/vmbus_chan.c

Modified: head/sys/dev/hyperv/vmbus/vmbus_chan.c
==
--- head/sys/dev/hyperv/vmbus/vmbus_chan.c  Wed Sep 14 06:15:45 2016
(r305788)
+++ head/sys/dev/hyperv/vmbus/vmbus_chan.c  Wed Sep 14 06:30:14 2016
(r305789)
@@ -1346,6 +1346,8 @@ vmbus_subchan_get(struct vmbus_channel *
struct vmbus_channel **ret, *chan;
int i;
 
+   KASSERT(subchan_cnt > 0, ("invalid sub-channel count %d", subchan_cnt));
+
ret = malloc(subchan_cnt * sizeof(struct vmbus_channel *), M_TEMP,
M_WAITOK);
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r305788 - head/sys/dev/hyperv/netvsc

2016-09-14 Thread Sepherosa Ziehau
Author: sephe
Date: Wed Sep 14 06:15:45 2016
New Revision: 305788
URL: https://svnweb.freebsd.org/changeset/base/305788

Log:
  hyperv/hn: Pull RSS key and indirect table setup up.
  
  This paves the way for the dynamic RSS key and indirect table setting.
  
  MFC after:1 week
  Sponsored by: Microsoft
  Differential Revision:https://reviews.freebsd.org/D7864

Modified:
  head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
  head/sys/dev/hyperv/netvsc/hv_rndis_filter.c
  head/sys/dev/hyperv/netvsc/if_hnvar.h

Modified: head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
==
--- head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c  Wed Sep 14 01:47:01 
2016(r305787)
+++ head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c  Wed Sep 14 06:15:45 
2016(r305788)
@@ -368,6 +368,14 @@ static void hn_xmit_txeof(struct hn_tx_r
 static void hn_xmit_taskfunc(void *, int);
 static void hn_xmit_txeof_taskfunc(void *, int);
 
+static const uint8_t   hn_rss_key_default[NDIS_HASH_KEYSIZE_TOEPLITZ] = {
+   0x6d, 0x5a, 0x56, 0xda, 0x25, 0x5b, 0x0e, 0xc2,
+   0x41, 0x67, 0x25, 0x3d, 0x43, 0xa3, 0x8f, 0xb0,
+   0xd0, 0xca, 0x2b, 0xcb, 0xae, 0x7b, 0x30, 0xb4,
+   0x77, 0xcb, 0x2d, 0xa3, 0x80, 0x30, 0xf2, 0x0c,
+   0x6a, 0x42, 0xb7, 0x3b, 0xbe, 0xac, 0x01, 0xfa
+};
+
 #if __FreeBSD_version >= 1100099
 static void
 hn_set_lro_lenlim(struct hn_softc *sc, int lenlim)
@@ -3146,7 +3154,8 @@ hn_synth_alloc_subchans(struct hn_softc 
 static int
 hn_synth_attach(struct hn_softc *sc, int mtu)
 {
-   int error, nsubch;
+   struct ndis_rssprm_toeplitz *rss = >hn_rss;
+   int error, nsubch, nchan, i;
 
/*
 * Attach the primary channel _before_ attaching NVS and RNDIS.
@@ -3180,7 +3189,9 @@ hn_synth_attach(struct hn_softc *sc, int
error = hn_synth_alloc_subchans(sc, );
if (error)
return (error);
-   if (nsubch == 0) {
+
+   nchan = nsubch + 1;
+   if (nchan == 1) {
/* Only the primary channel can be used; done */
goto back;
}
@@ -3189,20 +3200,29 @@ hn_synth_attach(struct hn_softc *sc, int
 * Configure RSS key and indirect table _after_ all sub-channels
 * are allocated.
 */
-   error = hn_rndis_conf_rss(sc, nsubch + 1);
+
+   /* Setup default RSS key. */
+   memcpy(rss->rss_key, hn_rss_key_default, sizeof(rss->rss_key));
+
+   /* Setup default RSS indirect table. */
+   /* TODO: Take ndis_rss_caps.ndis_nind into account. */
+   for (i = 0; i < NDIS_HASH_INDCNT; ++i)
+   rss->rss_ind[i] = i % nchan;
+
+   error = hn_rndis_conf_rss(sc);
if (error) {
/*
 * Failed to configure RSS key or indirect table; only
 * the primary channel can be used.
 */
-   nsubch = 0;
+   nchan = 1;
}
 back:
/*
 * Set the # of TX/RX rings that could be used according to
 * the # of channels that NVS offered.
 */
-   hn_set_ring_inuse(sc, nsubch + 1);
+   hn_set_ring_inuse(sc, nchan);
 
/*
 * Attach the sub-channels, if any.

Modified: head/sys/dev/hyperv/netvsc/hv_rndis_filter.c
==
--- head/sys/dev/hyperv/netvsc/hv_rndis_filter.cWed Sep 14 01:47:01 
2016(r305787)
+++ head/sys/dev/hyperv/netvsc/hv_rndis_filter.cWed Sep 14 06:15:45 
2016(r305788)
@@ -510,14 +510,6 @@ hn_rndis_get_linkstatus(struct hn_softc 
return (0);
 }
 
-static uint8_t netvsc_hash_key[NDIS_HASH_KEYSIZE_TOEPLITZ] = {
-   0x6d, 0x5a, 0x56, 0xda, 0x25, 0x5b, 0x0e, 0xc2,
-   0x41, 0x67, 0x25, 0x3d, 0x43, 0xa3, 0x8f, 0xb0,
-   0xd0, 0xca, 0x2b, 0xcb, 0xae, 0x7b, 0x30, 0xb4,
-   0x77, 0xcb, 0x2d, 0xa3, 0x80, 0x30, 0xf2, 0x0c,
-   0x6a, 0x42, 0xb7, 0x3b, 0xbe, 0xac, 0x01, 0xfa
-};
-
 static const void *
 hn_rndis_xact_exec1(struct hn_softc *sc, struct vmbus_xact *xact, size_t 
reqlen,
 struct hn_send_ctx *sndc, size_t *comp_len)
@@ -845,11 +837,11 @@ hn_rndis_conf_offload(struct hn_softc *s
 }
 
 int
-hn_rndis_conf_rss(struct hn_softc *sc, int nchan)
+hn_rndis_conf_rss(struct hn_softc *sc)
 {
struct ndis_rssprm_toeplitz *rss = >hn_rss;
struct ndis_rss_params *prm = >rss_params;
-   int i, error;
+   int error;
 
/*
 * Only NDIS 6.30+ is supported.
@@ -857,7 +849,12 @@ hn_rndis_conf_rss(struct hn_softc *sc, i
KASSERT(sc->hn_ndis_ver >= HN_NDIS_VERSION_6_30,
("NDIS 6.30+ is required, NDIS version 0x%08x", sc->hn_ndis_ver));
 
-   memset(rss, 0, sizeof(*rss));
+   /*
+* NOTE:
+* DO NOT whack rss_key and rss_ind, which are setup by the caller.
+*/
+   memset(prm, 0, sizeof(*prm));
+
prm->ndis_hdr.ndis_type =