svn commit: r273727 - head/sys/fs/nfsserver

2014-10-27 Thread Konstantin Belousov
Author: kib
Date: Mon Oct 27 07:47:13 2014
New Revision: 273727
URL: https://svnweb.freebsd.org/changeset/base/273727

Log:
  Allow the vfs.nfsd knobs to be set from loader.conf (or using
  kenv(8)).  This is useful when nfsd is loaded as module.
  
  Reviewed by:  rmacklem
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week

Modified:
  head/sys/fs/nfsserver/nfs_nfsdkrpc.c

Modified: head/sys/fs/nfsserver/nfs_nfsdkrpc.c
==
--- head/sys/fs/nfsserver/nfs_nfsdkrpc.cMon Oct 27 07:21:37 2014
(r273726)
+++ head/sys/fs/nfsserver/nfs_nfsdkrpc.cMon Oct 27 07:47:13 2014
(r273727)
@@ -85,16 +85,16 @@ SYSCTL_DECL(_vfs_nfsd);
 SVCPOOL*nfsrvd_pool;
 
 static int nfs_privport = 0;
-SYSCTL_INT(_vfs_nfsd, OID_AUTO, nfs_privport, CTLFLAG_RW,
+SYSCTL_INT(_vfs_nfsd, OID_AUTO, nfs_privport, CTLFLAG_RWTUN,
 &nfs_privport, 0,
 "Only allow clients using a privileged port for NFSv2 and 3");
 
 static int nfs_minvers = NFS_VER2;
-SYSCTL_INT(_vfs_nfsd, OID_AUTO, server_min_nfsvers, CTLFLAG_RW,
+SYSCTL_INT(_vfs_nfsd, OID_AUTO, server_min_nfsvers, CTLFLAG_RWTUN,
 &nfs_minvers, 0, "The lowest version of NFS handled by the server");
 
 static int nfs_maxvers = NFS_VER4;
-SYSCTL_INT(_vfs_nfsd, OID_AUTO, server_max_nfsvers, CTLFLAG_RW,
+SYSCTL_INT(_vfs_nfsd, OID_AUTO, server_max_nfsvers, CTLFLAG_RWTUN,
 &nfs_maxvers, 0, "The highest version of NFS handled by the server");
 
 static int nfs_proc(struct nfsrv_descript *, u_int32_t, SVCXPRT *xprt,
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r273728 - head/sys/dev/iicbus

2014-10-27 Thread Konstantin Belousov
Author: kib
Date: Mon Oct 27 07:51:26 2014
New Revision: 273728
URL: https://svnweb.freebsd.org/changeset/base/273728

Log:
  Add a method to iicbus to request IIC_M_NOSTOP behaviour for multibyte
  transfers to be default.  It simplifies porting code which assumes
  such settings.
  
  Discussed with:   avg, llos, nwhitehorn
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week

Modified:
  head/sys/dev/iicbus/iicbus.h
  head/sys/dev/iicbus/iiconf.c

Modified: head/sys/dev/iicbus/iicbus.h
==
--- head/sys/dev/iicbus/iicbus.hMon Oct 27 07:47:13 2014
(r273727)
+++ head/sys/dev/iicbus/iicbus.hMon Oct 27 07:51:26 2014
(r273728)
@@ -49,16 +49,19 @@ struct iicbus_softc
 struct iicbus_ivar
 {
uint32_taddr;
+   boolnostop;
 };
 
 enum {
-   IICBUS_IVAR_ADDR/* Address or base address */
+   IICBUS_IVAR_ADDR,   /* Address or base address */
+   IICBUS_IVAR_NOSTOP, /* nostop defaults */
 };
 
 #define IICBUS_ACCESSOR(A, B, T)   \
__BUS_ACCESSOR(iicbus, A, IICBUS, B, T)

 IICBUS_ACCESSOR(addr,  ADDR,   uint32_t)
+IICBUS_ACCESSOR(nostop,NOSTOP, bool)
 
 #defineIICBUS_LOCK(sc) mtx_lock(&(sc)->lock)
 #defineIICBUS_UNLOCK(sc)   mtx_unlock(&(sc)->lock)

Modified: head/sys/dev/iicbus/iiconf.c
==
--- head/sys/dev/iicbus/iiconf.cMon Oct 27 07:47:13 2014
(r273727)
+++ head/sys/dev/iicbus/iiconf.cMon Oct 27 07:51:26 2014
(r273728)
@@ -365,6 +365,7 @@ iicbus_transfer_gen(device_t dev, struct
 {
int i, error, lenread, lenwrote, nkid, rpstart, addr;
device_t *children, bus;
+   bool nostop;
 
if ((error = device_get_children(dev, &children, &nkid)) != 0)
return (error);
@@ -375,6 +376,7 @@ iicbus_transfer_gen(device_t dev, struct
bus = children[0];
rpstart = 0;
free(children, M_TEMP);
+   nostop = iicbus_get_nostop(dev);
for (i = 0, error = 0; i < nmsgs && error == 0; i++) {
addr = msgs[i].slave;
if (msgs[i].flags & IIC_M_RD)
@@ -399,11 +401,12 @@ iicbus_transfer_gen(device_t dev, struct
error = iicbus_write(bus, msgs[i].buf, msgs[i].len,
&lenwrote, 0);
 
-   if (!(msgs[i].flags & IIC_M_NOSTOP)) {
+   if ((msgs[i].flags & IIC_M_NOSTOP) != 0 ||
+   (nostop && i + 1 < nmsgs)) {
+   rpstart = 1;/* Next message gets repeated start */
+   } else {
rpstart = 0;
iicbus_stop(bus);
-   } else {
-   rpstart = 1;/* Next message gets repeated start */
}
}
return (error);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r273730 - head/sys/cam/ctl

2014-10-27 Thread Alexander Motin
Author: mav
Date: Mon Oct 27 09:26:24 2014
New Revision: 273730
URL: https://svnweb.freebsd.org/changeset/base/273730

Log:
  Reduce code duplication around Write Exclusive persistent reservation.
  
  While there, allow some more commands to pass persistent reservation.
  
  MFC after:1 week

Modified:
  head/sys/cam/ctl/ctl.c
  head/sys/cam/ctl/ctl_cmd_table.c
  head/sys/cam/ctl/ctl_private.h

Modified: head/sys/cam/ctl/ctl.c
==
--- head/sys/cam/ctl/ctl.c  Mon Oct 27 09:07:30 2014(r273729)
+++ head/sys/cam/ctl/ctl.c  Mon Oct 27 09:26:24 2014(r273730)
@@ -5341,8 +5341,7 @@ ctl_scsi_reserve(struct ctl_scsiio *ctsi
 
mtx_lock(&lun->lun_lock);
if ((lun->flags & CTL_LUN_RESERVED) && (lun->res_idx != residx)) {
-   ctsio->scsi_status = SCSI_STATUS_RESERV_CONFLICT;
-   ctsio->io_hdr.status = CTL_SCSI_ERROR;
+   ctl_set_reservation_conflict(ctsio);
goto bailout;
}
 
@@ -5693,24 +5692,6 @@ ctl_read_buffer(struct ctl_scsiio *ctsio
lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr;
cdb = (struct scsi_read_buffer *)ctsio->cdb;
 
-   if (lun->flags & CTL_LUN_PR_RESERVED) {
-   uint32_t residx;
-
-   /*
-* XXX KDM need a lock here.
-*/
-   residx = ctl_get_resindex(&ctsio->io_hdr.nexus);
-   if ((lun->res_type == SPR_TYPE_EX_AC
- && residx != lun->pr_res_idx)
-|| ((lun->res_type == SPR_TYPE_EX_AC_RO
-  || lun->res_type == SPR_TYPE_EX_AC_AR)
- && lun->pr_keys[residx] == 0)) {
-   ctl_set_reservation_conflict(ctsio);
-   ctl_done((union ctl_io *)ctsio);
-   return (CTL_RETVAL_COMPLETE);
-   }
-   }
-
if ((cdb->byte2 & RWB_MODE) != RWB_MODE_DATA &&
(cdb->byte2 & RWB_MODE) != RWB_MODE_ECHO_DESCR &&
(cdb->byte2 & RWB_MODE) != RWB_MODE_DESCR) {
@@ -6642,24 +6623,6 @@ ctl_mode_sense(struct ctl_scsiio *ctsio)
else
control_dev = 0;
 
-   if (lun->flags & CTL_LUN_PR_RESERVED) {
-   uint32_t residx;
-
-   /*
-* XXX KDM need a lock here.
-*/
-   residx = ctl_get_resindex(&ctsio->io_hdr.nexus);
-   if ((lun->res_type == SPR_TYPE_EX_AC
- && residx != lun->pr_res_idx)
-|| ((lun->res_type == SPR_TYPE_EX_AC_RO
-  || lun->res_type == SPR_TYPE_EX_AC_AR)
- && lun->pr_keys[residx] == 0)) {
-   ctl_set_reservation_conflict(ctsio);
-   ctl_done((union ctl_io *)ctsio);
-   return (CTL_RETVAL_COMPLETE);
-   }
-   }
-
switch (ctsio->cdb[0]) {
case MODE_SENSE_6: {
struct scsi_mode_sense_6 *cdb;
@@ -7196,23 +7159,6 @@ ctl_read_defect(struct ctl_scsiio *ctsio
CTL_DEBUG_PRINT(("ctl_read_defect\n"));
 
lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr;
-   if (lun->flags & CTL_LUN_PR_RESERVED) {
-   uint32_t residx;
-
-   /*
-* XXX KDM need a lock here.
-*/
-   residx = ctl_get_resindex(&ctsio->io_hdr.nexus);
-   if ((lun->res_type == SPR_TYPE_EX_AC
- && residx != lun->pr_res_idx)
-|| ((lun->res_type == SPR_TYPE_EX_AC_RO
-  || lun->res_type == SPR_TYPE_EX_AC_AR)
- && lun->pr_keys[residx] == 0)) {
-   ctl_set_reservation_conflict(ctsio);
-   ctl_done((union ctl_io *)ctsio);
-   return (CTL_RETVAL_COMPLETE);
-   }
-   }
 
if (ctsio->cdb[0] == READ_DEFECT_DATA_10) {
ccb10 = (struct scsi_read_defect_data_10 *)&ctsio->cdb;
@@ -8906,24 +8852,6 @@ ctl_read_write(struct ctl_scsiio *ctsio)
 
isread = ctsio->cdb[0] == READ_6  || ctsio->cdb[0] == READ_10
  || ctsio->cdb[0] == READ_12 || ctsio->cdb[0] == READ_16;
-   if (lun->flags & CTL_LUN_PR_RESERVED && isread) {
-   uint32_t residx;
-
-   /*
-* XXX KDM need a lock here.
-*/
-   residx = ctl_get_resindex(&ctsio->io_hdr.nexus);
-   if ((lun->res_type == SPR_TYPE_EX_AC
- && residx != lun->pr_res_idx)
-|| ((lun->res_type == SPR_TYPE_EX_AC_RO
-  || lun->res_type == SPR_TYPE_EX_AC_AR)
- && lun->pr_keys[residx] == 0)) {
-   ctl_set_reservation_conflict(ctsio);
-   ctl_done((union ctl_io *)ctsio);
-   return (CTL_RETVAL_COMPLETE);
-   }
-   }
-
switch (ct

svn commit: r273731 - head/sys/cam/ctl

2014-10-27 Thread Alexander Motin
Author: mav
Date: Mon Oct 27 09:30:57 2014
New Revision: 273731
URL: https://svnweb.freebsd.org/changeset/base/273731

Log:
  Remove comment obsoleted by r273730.
  
  MFC after:1 week

Modified:
  head/sys/cam/ctl/ctl.c

Modified: head/sys/cam/ctl/ctl.c
==
--- head/sys/cam/ctl/ctl.c  Mon Oct 27 09:26:24 2014(r273730)
+++ head/sys/cam/ctl/ctl.c  Mon Oct 27 09:30:57 2014(r273731)
@@ -11172,9 +11172,6 @@ ctl_scsiio_lun_check(struct ctl_softc *c
 * if we aren't registered or it's a res holder type
 * reservation and this isn't the res holder then set a
 * conflict.
-* NOTE: Commands which might be allowed on write exclusive
-* type reservations are checked in the particular command
-* for a conflict. Read and SSU are the only ones.
 */
if (lun->pr_keys[residx] == 0
 || (residx != lun->pr_res_idx && lun->res_type < 4)) {
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r273732 - head/sys/netinet6

2014-10-27 Thread Andrey V. Elsukov
Author: ae
Date: Mon Oct 27 10:34:09 2014
New Revision: 273732
URL: https://svnweb.freebsd.org/changeset/base/273732

Log:
  Remove unused function.
  
  Sponsored by: Yandex LLC

Modified:
  head/sys/netinet6/in6.c
  head/sys/netinet6/in6_var.h

Modified: head/sys/netinet6/in6.c
==
--- head/sys/netinet6/in6.c Mon Oct 27 09:30:57 2014(r273731)
+++ head/sys/netinet6/in6.c Mon Oct 27 10:34:09 2014(r273732)
@@ -1584,20 +1584,6 @@ in6_unlink_ifa(struct in6_ifaddr *ia, st
ifa_free(&ia->ia_ifa);  /* in6_ifaddrhead */
 }
 
-void
-in6_purgeif(struct ifnet *ifp)
-{
-   struct ifaddr *ifa, *nifa;
-
-   TAILQ_FOREACH_SAFE(ifa, &ifp->if_addrhead, ifa_link, nifa) {
-   if (ifa->ifa_addr->sa_family != AF_INET6)
-   continue;
-   in6_purgeaddr(ifa);
-   }
-
-   in6_ifdetach(ifp);
-}
-
 /*
  * Notifies other other subsystems about address change/arrival:
  * 1) Notifies device handler on first IPv6 address assignment

Modified: head/sys/netinet6/in6_var.h
==
--- head/sys/netinet6/in6_var.h Mon Oct 27 09:30:57 2014(r273731)
+++ head/sys/netinet6/in6_var.h Mon Oct 27 10:34:09 2014(r273732)
@@ -804,7 +804,6 @@ voidin6_prepare_ifra(struct in6_aliasre
const struct in6_addr *);
 void   in6_purgeaddr(struct ifaddr *);
 intin6if_do_dad(struct ifnet *);
-void   in6_purgeif(struct ifnet *);
 void   in6_savemkludge(struct in6_ifaddr *);
 void   *in6_domifattach(struct ifnet *);
 void   in6_domifdetach(struct ifnet *, void *);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r273733 - head/sys/netinet/cc

2014-10-27 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Oct 27 11:21:47 2014
New Revision: 273733
URL: https://svnweb.freebsd.org/changeset/base/273733

Log:
  Make assignments to "net.inet.tcp.cc.algorithm" work by fixing a bad
  string comparison.
  
  MFC after:3 days
  Reported by:  Jukka Ukkonen 
  Sponsored by: Mellanox Technologies

Modified:
  head/sys/netinet/cc/cc.c

Modified: head/sys/netinet/cc/cc.c
==
--- head/sys/netinet/cc/cc.cMon Oct 27 10:34:09 2014(r273732)
+++ head/sys/netinet/cc/cc.cMon Oct 27 11:21:47 2014(r273733)
@@ -106,11 +106,13 @@ cc_default_algo(SYSCTL_HANDLER_ARGS)
/* Find algo with specified name and set it to default. */
CC_LIST_RLOCK();
STAILQ_FOREACH(funcs, &cc_list, entries) {
-   if (strncmp((char *)req->newptr, funcs->name,
-   TCP_CA_NAME_MAX) == 0) {
-   found = 1;
-   V_default_cc_ptr = funcs;
-   }
+   /* NOTE: "newptr" is not zero terminated */
+   if (req->newlen != strlen(funcs->name))
+   continue;
+   if (bcmp(req->newptr, funcs->name, req->newlen))
+   continue;
+   found = 1;
+   V_default_cc_ptr = funcs;
}
CC_LIST_RUNLOCK();
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r273734 - head/bin/dd

2014-10-27 Thread Kurt Jaeger
Author: pi (ports committer)
Date: Mon Oct 27 11:38:17 2014
New Revision: 273734
URL: https://svnweb.freebsd.org/changeset/base/273734

Log:
  bin/dd: Fix incorrect casting of arguments
  
  dd(1) casts many of its numeric arguments from uintmax_t to intmax_t
  and back again to detect whether or not the original arguments were
  negative. This caused wrong behaviour in some boundary cases:
  
  $ dd if=/dev/zero of=/dev/null count=18446744073709551615
  dd: count cannot be negative
  
  After the fix:
  
  $ dd if=/dev/zero of=/dev/null count=18446744073709551615
  dd: count: Result too large
  
  PR:   191263
  Submitted by: w...@worrbase.com
  Approved by:  cognet@

Modified:
  head/bin/dd/args.c
  head/bin/dd/conv.c
  head/bin/dd/dd.c
  head/bin/dd/dd.h
  head/bin/dd/position.c

Modified: head/bin/dd/args.c
==
--- head/bin/dd/args.c  Mon Oct 27 11:21:47 2014(r273733)
+++ head/bin/dd/args.c  Mon Oct 27 11:38:17 2014(r273734)
@@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$");
 
 #include 
 
+#include 
 #include 
 #include 
 #include 
@@ -171,8 +172,7 @@ jcl(char **argv)
 */
if (in.offset > OFF_MAX / (ssize_t)in.dbsz ||
out.offset > OFF_MAX / (ssize_t)out.dbsz)
-   errx(1, "seek offsets cannot be larger than %jd",
-   (intmax_t)OFF_MAX);
+   errx(1, "seek offsets cannot be larger than %jd", OFF_MAX);
 }
 
 static int
@@ -186,37 +186,30 @@ c_arg(const void *a, const void *b)
 static void
 f_bs(char *arg)
 {
-   uintmax_t res;
 
-   res = get_num(arg);
-   if (res < 1 || res > SSIZE_MAX)
-   errx(1, "bs must be between 1 and %jd", (intmax_t)SSIZE_MAX);
-   in.dbsz = out.dbsz = (size_t)res;
+   in.dbsz = out.dbsz = get_num(arg);
+   if (out.dbsz < 1 || out.dbsz > SSIZE_MAX)
+   errx(1, "bs must be between 1 and %jd", SSIZE_MAX);
 }
 
 static void
 f_cbs(char *arg)
 {
-   uintmax_t res;
 
-   res = get_num(arg);
-   if (res < 1 || res > SSIZE_MAX)
-   errx(1, "cbs must be between 1 and %jd", (intmax_t)SSIZE_MAX);
-   cbsz = (size_t)res;
+   cbsz = get_num(arg);
+   if (cbsz < 1 || cbsz > SSIZE_MAX)
+   errx(1, "cbs must be between 1 and %jd", SSIZE_MAX);
 }
 
 static void
 f_count(char *arg)
 {
-   intmax_t res;
 
-   res = (intmax_t)get_num(arg);
-   if (res < 0)
-   errx(1, "count cannot be negative");
-   if (res == 0)
-   cpy_cnt = (uintmax_t)-1;
-   else
-   cpy_cnt = (uintmax_t)res;
+   cpy_cnt = get_num(arg);
+   if (cpy_cnt == SIZE_MAX)
+   errc(1, ERANGE, "%s", oper);
+   if (cpy_cnt == 0)
+   cpy_cnt = -1;
 }
 
 static void
@@ -225,7 +218,7 @@ f_files(char *arg)
 
files_cnt = get_num(arg);
if (files_cnt < 1)
-   errx(1, "files must be between 1 and %jd", (uintmax_t)-1);
+   errx(1, "files must be between 1 and %ju", SIZE_MAX);
 }
 
 static void
@@ -241,14 +234,11 @@ f_fillchar(char *arg)
 static void
 f_ibs(char *arg)
 {
-   uintmax_t res;
 
if (!(ddflags & C_BS)) {
-   res = get_num(arg);
-   if (res < 1 || res > SSIZE_MAX)
-   errx(1, "ibs must be between 1 and %jd",
-   (intmax_t)SSIZE_MAX);
-   in.dbsz = (size_t)res;
+   in.dbsz = get_num(arg);
+   if (in.dbsz < 1 || in.dbsz > SSIZE_MAX)
+   errx(1, "ibs must be between 1 and %ju", SSIZE_MAX);
}
 }
 
@@ -262,14 +252,11 @@ f_if(char *arg)
 static void
 f_obs(char *arg)
 {
-   uintmax_t res;
 
if (!(ddflags & C_BS)) {
-   res = get_num(arg);
-   if (res < 1 || res > SSIZE_MAX)
-   errx(1, "obs must be between 1 and %jd",
-   (intmax_t)SSIZE_MAX);
-   out.dbsz = (size_t)res;
+   out.dbsz = get_num(arg);
+   if (out.dbsz < 1 || out.dbsz > SSIZE_MAX)
+   errx(1, "obs must be between 1 and %jd", SSIZE_MAX);
}
 }
 
@@ -378,11 +365,17 @@ get_num(const char *val)
uintmax_t num, mult, prevnum;
char *expr;
 
+   while (isspace(val[0]))
+   val++;
+
+   if (val[0] == '-')
+   errx(1, "%s: cannot be negative", oper);
+
errno = 0;
-   num = strtouq(val, &expr, 0);
+   num = strtoull(val, &expr, 0);
if (errno != 0) /* Overflow or underflow. */
err(1, "%s", oper);
-   
+
if (expr == val)/* No valid digits. */
errx(1, "%s: illegal numeric value", oper);
 

Modified: head/bin/dd/conv.c
==
--- head/bin/dd/conv.c  Mon Oct 27 11:21:47 2014(r273733)
+++ head/bin/

svn commit: r273737 - head/usr.sbin/pmcstat

2014-10-27 Thread Baptiste Daroussin
Author: bapt
Date: Mon Oct 27 15:33:44 2014
New Revision: 273737
URL: https://svnweb.freebsd.org/changeset/base/273737

Log:
  Clarify the documentation of pmcstat:
  the -d argument should be passed before -p, -s, -P or -S to be taken in 
account
  
  Differential Revision:https://reviews.freebsd.org/D1011
  Reviewed by:  adrian, gnn
  MFC after:1 week

Modified:
  head/usr.sbin/pmcstat/pmcstat.8

Modified: head/usr.sbin/pmcstat/pmcstat.8
==
--- head/usr.sbin/pmcstat/pmcstat.8 Mon Oct 27 14:38:00 2014
(r273736)
+++ head/usr.sbin/pmcstat/pmcstat.8 Mon Oct 27 15:33:44 2014
(r273737)
@@ -25,7 +25,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd May 16, 2014
+.Dd Oct 27, 2014
 .Dt PMCSTAT 8
 .Os
 .Sh NAME
@@ -254,6 +254,13 @@ Toggle between process mode PMCs measuri
 process' current and future children or only measuring events for
 the target process.
 The default is to measure events for the target process alone.
+(it has to be passed in the command line prior to
+.Fl p ,
+.Fl s ,
+.Fl P ,
+or
+.Fl S
+).
 .It Fl f Ar pluginopt
 Pass option string to the active plugin.
 .br
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r273734 - head/bin/dd

2014-10-27 Thread Konstantin Belousov
On Mon, Oct 27, 2014 at 11:38:17AM +, Kurt Jaeger wrote:
> Author: pi (ports committer)
> Date: Mon Oct 27 11:38:17 2014
> New Revision: 273734
> URL: https://svnweb.freebsd.org/changeset/base/273734
> 
> Log:
>   bin/dd: Fix incorrect casting of arguments
This causes non-trivial amount of errors like

cc1: warnings being treated as errors
/scratch/tmp/kib/src/bin/dd/args.c: In function 'f_bs':
/scratch/tmp/kib/src/bin/dd/args.c:192: warning: format '%jd' expects type 'intm
ax_t', but argument 3 has type 'int'

(this is on arm).
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r273738 - head/share/man/man3

2014-10-27 Thread John Baldwin
Author: jhb
Date: Mon Oct 27 15:45:37 2014
New Revision: 273738
URL: https://svnweb.freebsd.org/changeset/base/273738

Log:
  Correct a typo: this is the manpage for pthread_cleanup_pop, not push.
  
  Submitted by: ian

Modified:
  head/share/man/man3/pthread_cleanup_pop.3

Modified: head/share/man/man3/pthread_cleanup_pop.3
==
--- head/share/man/man3/pthread_cleanup_pop.3   Mon Oct 27 15:33:44 2014
(r273737)
+++ head/share/man/man3/pthread_cleanup_pop.3   Mon Oct 27 15:45:37 2014
(r273738)
@@ -52,7 +52,7 @@ then
 does nothing.
 .Pp
 The
-.Fn pthread_cleanup_push
+.Fn pthread_cleanup_pop
 function is implemented as a macro that closes a block.
 Invocations of this function must appear as standalone statements that are
 paired with an earlier call of
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r273733 - head/sys/netinet/cc

2014-10-27 Thread George Neville-Neil

Can you modify this to preserve the limitation of TCP_CA_NAME_MAX ?

Best,
George


On 27 Oct 2014, at 7:21, Hans Petter Selasky wrote:


Author: hselasky
Date: Mon Oct 27 11:21:47 2014
New Revision: 273733
URL: https://svnweb.freebsd.org/changeset/base/273733

Log:
Make assignments to "net.inet.tcp.cc.algorithm" work by fixing a bad
string comparison.

MFC after:  3 days
Reported by:Jukka Ukkonen 
Sponsored by:   Mellanox Technologies

Modified:
head/sys/netinet/cc/cc.c

Modified: head/sys/netinet/cc/cc.c
==
--- head/sys/netinet/cc/cc.cMon Oct 27 10:34:09 2014(r273732)
+++ head/sys/netinet/cc/cc.cMon Oct 27 11:21:47 2014(r273733)
@@ -106,11 +106,13 @@ cc_default_algo(SYSCTL_HANDLER_ARGS)
/* Find algo with specified name and set it to default. */
CC_LIST_RLOCK();
STAILQ_FOREACH(funcs, &cc_list, entries) {
-   if (strncmp((char *)req->newptr, funcs->name,
-   TCP_CA_NAME_MAX) == 0) {
-   found = 1;
-   V_default_cc_ptr = funcs;
-   }
+   /* NOTE: "newptr" is not zero terminated */
+   if (req->newlen != strlen(funcs->name))
+   continue;
+   if (bcmp(req->newptr, funcs->name, req->newlen))
+   continue;
+   found = 1;
+   V_default_cc_ptr = funcs;
}
CC_LIST_RUNLOCK();

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


svn commit: r273739 - head/usr.sbin/pmcstat

2014-10-27 Thread Baptiste Daroussin
Author: bapt
Date: Mon Oct 27 15:50:47 2014
New Revision: 273739
URL: https://svnweb.freebsd.org/changeset/base/273739

Log:
  Fix rendering
  
  Submitted by: brueffer

Modified:
  head/usr.sbin/pmcstat/pmcstat.8

Modified: head/usr.sbin/pmcstat/pmcstat.8
==
--- head/usr.sbin/pmcstat/pmcstat.8 Mon Oct 27 15:45:37 2014
(r273738)
+++ head/usr.sbin/pmcstat/pmcstat.8 Mon Oct 27 15:50:47 2014
(r273739)
@@ -259,8 +259,7 @@ The default is to measure events for the
 .Fl s ,
 .Fl P ,
 or
-.Fl S
-).
+.Fl S ) .
 .It Fl f Ar pluginopt
 Pass option string to the active plugin.
 .br
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r273734 - head/bin/dd

2014-10-27 Thread Kurt Jaeger
> On Mon, Oct 27, 2014 at 11:38:17AM +, Kurt Jaeger wrote:
> > Author: pi (ports committer)
> > Date: Mon Oct 27 11:38:17 2014
> > New Revision: 273734
> > URL: https://svnweb.freebsd.org/changeset/base/273734
> > 
> > Log:
> >   bin/dd: Fix incorrect casting of arguments
> This causes non-trivial amount of errors like
> 
> cc1: warnings being treated as errors
> /scratch/tmp/kib/src/bin/dd/args.c: In function 'f_bs':
> /scratch/tmp/kib/src/bin/dd/args.c:192: warning: format '%jd' expects type 
> 'intm
> ax_t', but argument 3 has type 'int'
> 
> (this is on arm).

Thanks for the pointer. I'll take it up with the submitter. I do not
have a working arm setup right now.

-- 
p...@freebsd.org +49 171 31013726 years to go !
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r273734 - head/bin/dd

2014-10-27 Thread Bruce Evans

On Mon, 27 Oct 2014, Konstantin Belousov wrote:


On Mon, Oct 27, 2014 at 11:38:17AM +, Kurt Jaeger wrote:

Log:
  bin/dd: Fix incorrect casting of arguments

This causes non-trivial amount of errors like

cc1: warnings being treated as errors
/scratch/tmp/kib/src/bin/dd/args.c: In function 'f_bs':
/scratch/tmp/kib/src/bin/dd/args.c:192: warning: format '%jd' expects type 'intm
ax_t', but argument 3 has type 'int'

(this is on arm).


Sigh.  I noticed that half the changes were to break correct casting,
but thought that the errors were not detected on any supported arch
(since the patch wouldn't have passed review if they were).  Actually,
they are detected on all 32-bit arches (since 32-bit SSIZE_MAX is
incompatible with 64-bit intmax_t).

Further examination of the history: in green's big patch that fixed most
of the arg checking, or at least in its MFC, there is this breakage:

% Index: args.c
% ===
% RCS file: /home/ncvs/src/bin/dd/args.c,v
% retrieving revision 1.13.2.2
% retrieving revision 1.13.2.3
% diff -u -2 -r1.13.2.2 -r1.13.2.3
% --- args.c29 Aug 1999 14:12:07 -  1.13.2.2
% +++ args.c12 Dec 1999 01:54:03 -  1.13.2.3
% ...
% @@ -207,7 +208,9 @@
%  {
% 
% -	cpy_cnt = (u_int)get_bsz(arg);

% - if (!cpy_cnt)
% - terminate(0);
% + cpy_cnt = get_num(arg);
% + if (cpy_cnt < 0)
% + errx(1, "count cannot be negative");
% + if (cpy_cnt == 0)
% + cpy_cnt = -1;
%  }
% 
% @@ -217,5 +220,7 @@

%  {
% 
% -	files_cnt = (int)get_bsz(arg);

% + files_cnt = get_num(arg);
% + if (files_cnt < 1)
% + errx(1, "files must be between 1 and %qd", QUAD_MAX);
%  }
%

The magic -1 wasn't in previous versions.  It is just some hack to recover
the previous behaviour.  My version doesn't have it, but uses essentially
the old code with no range checking but the type expanded to uintmax_t.
All uintmax_t values are valid counts.  The correct range checking is
already in get_num().

I also removed the special case for cpuy_cnt = 0.  I think it means no
limit in my version.  This is more useful than immediate termination.

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


Re: svn commit: r273734 - head/bin/dd

2014-10-27 Thread Bruce Evans

On Mon, 27 Oct 2014, Kurt Jaeger wrote:


Log:
 bin/dd: Fix incorrect casting of arguments

 dd(1) casts many of its numeric arguments from uintmax_t to intmax_t
 and back again to detect whether or not the original arguments were
 negative. This caused wrong behaviour in some boundary cases:

 $ dd if=/dev/zero of=/dev/null count=18446744073709551615
 dd: count cannot be negative

 After the fix:

 $ dd if=/dev/zero of=/dev/null count=18446744073709551615
 dd: count: Result too large


Both of these work correctly in my version (with a relatively small patch
and no breakage of other cases).  (I actually typed large values as -1
and 11.  -1 means (uintmax_t)-1 although this
is undocumented and now broken).



 PR:191263
 Submitted by:  w...@worrbase.com
 Approved by:   cognet@


I couldn't review the PR since I bugzilla doesn't accept mail responses.
I didn't fear it was so bad.


Modified: head/bin/dd/args.c
==
--- head/bin/dd/args.c  Mon Oct 27 11:21:47 2014(r273733)
+++ head/bin/dd/args.c  Mon Oct 27 11:38:17 2014(r273734)
@@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$");

#include 

+#include 
#include 
#include 
#include 
@@ -171,8 +172,7 @@ jcl(char **argv)
 */
if (in.offset > OFF_MAX / (ssize_t)in.dbsz ||
out.offset > OFF_MAX / (ssize_t)out.dbsz)
-   errx(1, "seek offsets cannot be larger than %jd",
-   (intmax_t)OFF_MAX);
+   errx(1, "seek offsets cannot be larger than %jd", OFF_MAX);
}


This used to be correct.  Now it assumes that off_t == intmax_t.  Both
just happen to be int64_t.  This will break when intmax_t is expanded
(off_t is unlikely to be expanded).  The bug would be detected at compile
time now if the type of intmax_t had maximal rank (long long) but int64_t
and off_t remain as long on 64-bit arches.  C99 doesn't seem to require
intmax_t to have maximal rank.  This seems to be a bug in C99, but FreeBSD
exploits it to avoid using the long long abomination on 6 4-bit arches.



static int
@@ -186,37 +186,30 @@ c_arg(const void *a, const void *b)
static void
f_bs(char *arg)
{
-   uintmax_t res;

-   res = get_num(arg);


This used to be correct.  Though I don't like unsigned types, the API
of read() and write() encourages use of size_t instead of ssize_t for
buffer sizes.  That was done, but a limit of SSIZE_MAX was applied,
partly to avoid problems detecting errors from read() and write()
and partly to distinguish overflowing cases.

get_num() returns an unsigned type (uintmax_t), so it is suitable for
handling the size_t args here.  It was used.  However, size_t might be
smaller than uintmax_t, so it cannot always hold the result of get_num().
So a temporary variable was used to hold the value before checking it.


-   if (res < 1 || res > SSIZE_MAX)
-   errx(1, "bs must be between 1 and %jd", (intmax_t)SSIZE_MAX);


get_num() returns UINTMAX_MAX if the result is too large.  This may or may
not be an error.  But in all arches, UINTMAX_MAX exceeds SSIZE_MAX, so
the overflowing case gives the same error as a non-overflowing but too
large value.


-   in.dbsz = out.dbsz = (size_t)res;
+   in.dbsz = out.dbsz = get_num(arg);


This breaks the error checking.  Blind assignment may corrupt the value
before it can be checked.


+   if (out.dbsz < 1 || out.dbsz > SSIZE_MAX)
+   errx(1, "bs must be between 1 and %jd", SSIZE_MAX);
}


Printf format error, as above.



static void
f_cbs(char *arg)
{
-   uintmax_t res;

-   res = get_num(arg);
-   if (res < 1 || res > SSIZE_MAX)
-   errx(1, "cbs must be between 1 and %jd", (intmax_t)SSIZE_MAX);
-   cbsz = (size_t)res;
+   cbsz = get_num(arg);
+   if (cbsz < 1 || cbsz > SSIZE_MAX)
+   errx(1, "cbs must be between 1 and %jd", SSIZE_MAX);
}


This just breaks the range checking and the printf format, as above.



static void
f_count(char *arg)
{
-   intmax_t res;

-   res = (intmax_t)get_num(arg);
-   if (res < 0)
-   errx(1, "count cannot be negative");


This was correct too.

Though get_num() returns an unsigned type, it is based on strtoul()
which handles negative values as correctly as possible.  (The
multipliers in get_num() don't handle negative values as correctly as
possible.)  dd also has a get_off_t() function.  This is supposed to
handle negative values more carefully, but is so badly implemented
that it has many more bugs than blindly casting get_num() to off_t.
The above cast is safer since it converts to the signed type
corresponding to the return type.  In 2's complement, the result is
predictable and correct except in unrepresentable cases.  E.g., an arg
of -1 is returned as UINTMAX_MAX and casting it gives -1 again.

My version implements get_off_t() using get_num().  Of course it doesn't
blindly convert to an off_t.  If does range

Re: svn commit: r273734 - head/bin/dd

2014-10-27 Thread Konstantin Belousov
On Mon, Oct 27, 2014 at 04:54:27PM +0100, Kurt Jaeger wrote:
> > On Mon, Oct 27, 2014 at 11:38:17AM +, Kurt Jaeger wrote:
> > > Author: pi (ports committer)
> > > Date: Mon Oct 27 11:38:17 2014
> > > New Revision: 273734
> > > URL: https://svnweb.freebsd.org/changeset/base/273734
> > > 
> > > Log:
> > >   bin/dd: Fix incorrect casting of arguments
> > This causes non-trivial amount of errors like
> > 
> > cc1: warnings being treated as errors
> > /scratch/tmp/kib/src/bin/dd/args.c: In function 'f_bs':
> > /scratch/tmp/kib/src/bin/dd/args.c:192: warning: format '%jd' expects type 
> > 'intm
> > ax_t', but argument 3 has type 'int'
> > 
> > (this is on arm).
> 
> Thanks for the pointer. I'll take it up with the submitter. I do not
> have a working arm setup right now.

I do not have arm setup either.  Errors for arm and mips (at least) are
reported by make tinderbox.
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r273740 - head/sys/netinet/cc

2014-10-27 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Oct 27 16:08:41 2014
New Revision: 273740
URL: https://svnweb.freebsd.org/changeset/base/273740

Log:
  Preserve limitation of "TCP_CA_NAME_MAX" when matching the algorithm
  name.
  
  MFC after:3 days
  Suggested by: gnn @

Modified:
  head/sys/netinet/cc/cc.c

Modified: head/sys/netinet/cc/cc.c
==
--- head/sys/netinet/cc/cc.cMon Oct 27 15:50:47 2014(r273739)
+++ head/sys/netinet/cc/cc.cMon Oct 27 16:08:41 2014(r273740)
@@ -107,7 +107,8 @@ cc_default_algo(SYSCTL_HANDLER_ARGS)
CC_LIST_RLOCK();
STAILQ_FOREACH(funcs, &cc_list, entries) {
/* NOTE: "newptr" is not zero terminated */
-   if (req->newlen != strlen(funcs->name))
+   if (req->newlen != strnlen(funcs->name,
+   TCP_CA_NAME_MAX - 1))
continue;
if (bcmp(req->newptr, funcs->name, req->newlen))
continue;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r273733 - head/sys/netinet/cc

2014-10-27 Thread Hans Petter Selasky

On 10/27/14 16:45, George Neville-Neil wrote:

Can you modify this to preserve the limitation of TCP_CA_NAME_MAX ?

Best,
George



Can you verify the following change? Subtracted one character from the 
limit for the terminating zero:


https://svnweb.freebsd.org/changeset/base/273740

--HPS

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


Re: svn commit: r273733 - head/sys/netinet/cc

2014-10-27 Thread George Neville-Neil

On 27 Oct 2014, at 12:09, Hans Petter Selasky wrote:


On 10/27/14 16:45, George Neville-Neil wrote:

Can you modify this to preserve the limitation of TCP_CA_NAME_MAX ?

Best,
George



Can you verify the following change? Subtracted one character from the 
limit for the terminating zero:


https://svnweb.freebsd.org/changeset/base/273740



That looks right.

Also, can you sign up for reviews.freebsd.org ?

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


svn commit: r273741 - head/sys/sys

2014-10-27 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 27 16:13:51 2014
New Revision: 273741
URL: https://svnweb.freebsd.org/changeset/base/273741

Log:
  Tiny comment fixup.

Modified:
  head/sys/sys/mbuf.h

Modified: head/sys/sys/mbuf.h
==
--- head/sys/sys/mbuf.h Mon Oct 27 16:08:41 2014(r273740)
+++ head/sys/sys/mbuf.h Mon Oct 27 16:13:51 2014(r273741)
@@ -393,7 +393,7 @@ void sf_ext_free(void *, void *);
  * Outbound flags that are set by upper protocol layers requesting lower
  * layers, or ideally the hardware, to perform these offloading tasks.
  * For outbound packets this field and its flags can be directly tested
- * against if_data.ifi_hwassist.
+ * against ifnet if_hwassist.
  */
 #defineCSUM_IP 0x0001  /* IP header checksum 
offload */
 #defineCSUM_IP_UDP 0x0002  /* UDP checksum offload 
*/
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r273742 - head/sys/netinet6

2014-10-27 Thread Andrey V. Elsukov
Author: ae
Date: Mon Oct 27 16:15:15 2014
New Revision: 273742
URL: https://svnweb.freebsd.org/changeset/base/273742

Log:
  Do not automatically install routes to link-local and interface-local 
multicast
  addresses.
  
  Obtained from:Yandex LLC
  Sponsored by: Yandex LLC

Modified:
  head/sys/netinet6/in6.c

Modified: head/sys/netinet6/in6.c
==
--- head/sys/netinet6/in6.c Mon Oct 27 16:13:51 2014(r273741)
+++ head/sys/netinet6/in6.c Mon Oct 27 16:15:15 2014(r273742)
@@ -782,27 +782,24 @@ in6_update_ifa_join_mc(struct ifnet *ifp
 struct in6_ifaddr *ia, int flags, struct in6_multi **in6m_sol)
 {
char ip6buf[INET6_ADDRSTRLEN];
-   struct sockaddr_in6 mltaddr, mltmask;
-   struct in6_addr llsol;
+   struct in6_addr mltaddr;
struct in6_multi_mship *imm;
-   struct rtentry *rt;
int delay, error;
 
KASSERT(in6m_sol != NULL, ("%s: in6m_sol is NULL", __func__));
 
/* Join solicited multicast addr for new host id. */
-   bzero(&llsol, sizeof(struct in6_addr));
-   llsol.s6_addr32[0] = IPV6_ADDR_INT32_MLL;
-   llsol.s6_addr32[1] = 0;
-   llsol.s6_addr32[2] = htonl(1);
-   llsol.s6_addr32[3] = ifra->ifra_addr.sin6_addr.s6_addr32[3];
-   llsol.s6_addr8[12] = 0xff;
-   if ((error = in6_setscope(&llsol, ifp, NULL)) != 0) {
+   bzero(&mltaddr, sizeof(struct in6_addr));
+   mltaddr.s6_addr32[0] = IPV6_ADDR_INT32_MLL;
+   mltaddr.s6_addr32[2] = htonl(1);
+   mltaddr.s6_addr32[3] = ifra->ifra_addr.sin6_addr.s6_addr32[3];
+   mltaddr.s6_addr8[12] = 0xff;
+   if ((error = in6_setscope(&mltaddr, ifp, NULL)) != 0) {
/* XXX: should not happen */
log(LOG_ERR, "%s: in6_setscope failed\n", __func__);
goto cleanup;
}
-   delay = 0;
+   delay = error = 0;
if ((flags & IN6_IFAUPDATE_DADDELAY)) {
/*
 * We need a random delay for DAD on the address being
@@ -812,62 +809,28 @@ in6_update_ifa_join_mc(struct ifnet *ifp
 */
delay = arc4random() % (MAX_RTR_SOLICITATION_DELAY * hz);
}
-   imm = in6_joingroup(ifp, &llsol, &error, delay);
+   imm = in6_joingroup(ifp, &mltaddr, &error, delay);
if (imm == NULL) {
-   nd6log((LOG_WARNING, "%s: addmulti failed for %s on %s "
-   "(errno=%d)\n", __func__, ip6_sprintf(ip6buf, &llsol),
+   nd6log((LOG_WARNING, "%s: in6_joingroup failed for %s on %s "
+   "(errno=%d)\n", __func__, ip6_sprintf(ip6buf, &mltaddr),
if_name(ifp), error));
goto cleanup;
}
LIST_INSERT_HEAD(&ia->ia6_memberships, imm, i6mm_chain);
*in6m_sol = imm->i6mm_maddr;
 
-   bzero(&mltmask, sizeof(mltmask));
-   mltmask.sin6_len = sizeof(struct sockaddr_in6);
-   mltmask.sin6_family = AF_INET6;
-   mltmask.sin6_addr = in6mask32;
-#defineMLTMASK_LEN  4  /* mltmask's masklen (=32bit=4octet) */
-
/*
 * Join link-local all-nodes address.
 */
-   bzero(&mltaddr, sizeof(mltaddr));
-   mltaddr.sin6_len = sizeof(struct sockaddr_in6);
-   mltaddr.sin6_family = AF_INET6;
-   mltaddr.sin6_addr = in6addr_linklocal_allnodes;
-   if ((error = in6_setscope(&mltaddr.sin6_addr, ifp, NULL)) != 0)
+   mltaddr = in6addr_linklocal_allnodes;
+   if ((error = in6_setscope(&mltaddr, ifp, NULL)) != 0)
goto cleanup; /* XXX: should not fail */
 
-   /*
-* XXX: do we really need this automatic routes?  We should probably
-* reconsider this stuff.  Most applications actually do not need the
-* routes, since they usually specify the outgoing interface.
-*/
-   rt = in6_rtalloc1((struct sockaddr *)&mltaddr, 0, 0UL, RT_DEFAULT_FIB);
-   if (rt != NULL) {
-   /* XXX: only works in !SCOPEDROUTING case. */
-   if (memcmp(&mltaddr.sin6_addr,
-   &((struct sockaddr_in6 *)rt_key(rt))->sin6_addr,
-   MLTMASK_LEN)) {
-   RTFREE_LOCKED(rt);
-   rt = NULL;
-   }
-   }
-   if (rt == NULL) {
-   error = in6_rtrequest(RTM_ADD, (struct sockaddr *)&mltaddr,
-   (struct sockaddr *)&ia->ia_addr,
-   (struct sockaddr *)&mltmask, RTF_UP,
-   (struct rtentry **)0, RT_DEFAULT_FIB);
-   if (error)
-   goto cleanup;
-   } else
-   RTFREE_LOCKED(rt);
-
-   imm = in6_joingroup(ifp, &mltaddr.sin6_addr, &error, 0);
+   imm = in6_joingroup(ifp, &mltaddr, &error, 0);
if (imm == NULL) {
-   nd6log((LOG_WARNING, "%s: addmulti failed for %s on %s "
-   "(errno=%d)\n", __func__, ip6_sprintf(ip6buf,
-

Re: svn commit: r273734 - head/bin/dd

2014-10-27 Thread Kurt Jaeger
Hi!

> > Log:
> >  bin/dd: Fix incorrect casting of arguments
[...]
> Both of these work correctly in my version (with a relatively small patch
> and no breakage of other cases).  (I actually typed large values as -1
> and 11.  -1 means (uintmax_t)-1 although this
> is undocumented and now broken).

So, given this detailed review, should I revert the change ?

-- 
p...@freebsd.org +49 171 31013726 years to go !
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r273401 - head/sys/kern

2014-10-27 Thread John Baldwin
On Sunday, October 26, 2014 02:57:43 AM Mateusz Guzik wrote:
> On Thu, Oct 23, 2014 at 12:14:03PM -0400, John Baldwin wrote:
> I specifically added sysctl_lock/unlock so that next folk with similar
> usecse will not have to. So I'm not going to remove it, but if you
> really don't like it feel free to do it.

However, if there isn't a future use case that needs it then it is just
obfuscation. :-/  Given how static the sysctl code is in terms of API
changes, etc. I strongly doubt there will be a future use case any time
soon.

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


Re: svn commit: r273644 - head/share/man/man3

2014-10-27 Thread John Baldwin
On Saturday, October 25, 2014 02:11:36 PM Ian Lepore wrote:
> On Sat, 2014-10-25 at 19:31 +, John Baldwin wrote:
> > +.Pp
> > +The
> > +.Fn pthread_cleanup_push
> 
> Should be pop?

Doh, yes!

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


Re: svn commit: r273214 - in head/sys: amd64/vmm/intel modules/vmm

2014-10-27 Thread John Baldwin
On Friday, October 17, 2014 01:20:50 PM Warner Losh wrote:
> Author: imp
> Date: Fri Oct 17 13:20:49 2014
> New Revision: 273214
> URL: https://svnweb.freebsd.org/changeset/base/273214
> 
> Log:
>   Fix build to not bogusly always rebuild vmm.ko.
> 
>   Rename vmx_assym.s to vmx_assym.h to reflect that file's actual use
>   and update vmx_support.S's include to match. Add vmx_assym.h to the
>   SRCS to that it gets properly added to the dependency list. Add
>   vmx_support.S to SRCS as well, so it gets built and needs fewer
>   special-case goo. Remove now-redundant special-case goo. Finally,
>   vmx_genassym.o doesn't need to depend on a hand expanded ${_ILINKS}
>   explicitly, that's all taken care of by beforedepend.
> 
>   With these items fixed, we no longer build vmm.ko every single time
>   through the modules on a KERNFAST build.

So I cheered for this before, but it appears to be broken. :(

Namely, I rebuilt world + kernel on my laptop this weekend (it was about a 
month old).  My normal setup builds kernels with NO_KERNELCLEAN=yes.  On my 
next reboot when I started a bhyve VM I promptly got a panic due to a page 
fault in this assembly code:

/*
 * If 'vmx->eptgen[curcpu]' is not identical to 'pmap->pm_eptgen'
 * then we must invalidate all mappings associated with this EPTP.
 */
movqPM_EPTGEN(%r11), %r10
cmpq%r10, VMX_EPTGEN(%rsi, %rax, 8)
je  guest_restore

(The 'cmpq' instruction)

This change came to mind, so I blew away the 'vmm' module directory and 
rebuilt my kernel.  Comparing the assembly of this instruction before and 
after used different values for VMX_EPTGEN.  In other words, the 
NO_KERNELCLEAN=yes build failed to regenerate vmx_assym.h and the build used 
stale values.

In particular, if you examine the generated .depend file, you will find that 
there are no dependencies recorded for vmx_genassym.o, so it is never rebuilt 
if any of the headers it includes are changed.  In my case the panic happened 
to be one that was easily diagnosed, but I could imagine stale assym headers 
causing very odd crashes that would be quite hard to track down.  I think 
these changes should be reverted if we can't fix the dependencies of the 
associated object files they are generated from. :(

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


Re: svn commit: r273214 - in head/sys: amd64/vmm/intel modules/vmm

2014-10-27 Thread Warner Losh

On Oct 27, 2014, at 10:54 AM, John Baldwin  wrote:

> On Friday, October 17, 2014 01:20:50 PM Warner Losh wrote:
>> Author: imp
>> Date: Fri Oct 17 13:20:49 2014
>> New Revision: 273214
>> URL: https://svnweb.freebsd.org/changeset/base/273214
>> 
>> Log:
>>  Fix build to not bogusly always rebuild vmm.ko.
>> 
>>  Rename vmx_assym.s to vmx_assym.h to reflect that file's actual use
>>  and update vmx_support.S's include to match. Add vmx_assym.h to the
>>  SRCS to that it gets properly added to the dependency list. Add
>>  vmx_support.S to SRCS as well, so it gets built and needs fewer
>>  special-case goo. Remove now-redundant special-case goo. Finally,
>>  vmx_genassym.o doesn't need to depend on a hand expanded ${_ILINKS}
>>  explicitly, that's all taken care of by beforedepend.
>> 
>>  With these items fixed, we no longer build vmm.ko every single time
>>  through the modules on a KERNFAST build.
> 
> So I cheered for this before, but it appears to be broken. :(
> 
> Namely, I rebuilt world + kernel on my laptop this weekend (it was about a 
> month old).  My normal setup builds kernels with NO_KERNELCLEAN=yes.  On my 
> next reboot when I started a bhyve VM I promptly got a panic due to a page 
> fault in this assembly code:
> 
>   /*
>* If 'vmx->eptgen[curcpu]' is not identical to 'pmap->pm_eptgen'
>* then we must invalidate all mappings associated with this EPTP.
>*/
>   movqPM_EPTGEN(%r11), %r10
>   cmpq%r10, VMX_EPTGEN(%rsi, %rax, 8)
>   je  guest_restore
> 
> (The 'cmpq' instruction)
> 
> This change came to mind, so I blew away the 'vmm' module directory and 
> rebuilt my kernel.  Comparing the assembly of this instruction before and 
> after used different values for VMX_EPTGEN.  In other words, the 
> NO_KERNELCLEAN=yes build failed to regenerate vmx_assym.h and the build used 
> stale values.

Is there a way to force this condition for testing?

> In particular, if you examine the generated .depend file, you will find that 
> there are no dependencies recorded for vmx_genassym.o, so it is never rebuilt 
> if any of the headers it includes are changed.  In my case the panic happened 
> to be one that was easily diagnosed, but I could imagine stale assym headers 
> causing very odd crashes that would be quite hard to track down.  I think 
> these changes should be reverted if we can't fix the dependencies of the 
> associated object files they are generated from. :(

Give me a bit and I’ll fix it. There’s a number of implicit dependencies that 
don’t get recorded in the .depend file, iirc, so that’s not completely 
conclusive. Not building, though is kinda a big hint that something’s amiss.

However, -DNO_CLEAN has always been a very-sharp edged tool that will cut you 
in a number of ways, so there’s no rush to back this out.

Warner


signature.asc
Description: Message signed with OpenPGP using GPGMail


Re: svn commit: r273742 - head/sys/netinet6

2014-10-27 Thread Bjoern A. Zeeb

On 27 Oct 2014, at 16:15 , Andrey V. Elsukov  wrote:

> Author: ae
> Date: Mon Oct 27 16:15:15 2014
> New Revision: 273742
> URL: https://svnweb.freebsd.org/changeset/base/273742
> 
> Log:
>  Do not automatically install routes to link-local and interface-local 
> multicast
>  addresses.

Why?


> 
>  Obtained from:   Yandex LLC
>  Sponsored by:Yandex LLC
> 
> Modified:
>  head/sys/netinet6/in6.c
> 
> Modified: head/sys/netinet6/in6.c
> ==
> --- head/sys/netinet6/in6.c   Mon Oct 27 16:13:51 2014(r273741)
> +++ head/sys/netinet6/in6.c   Mon Oct 27 16:15:15 2014(r273742)
> @@ -782,27 +782,24 @@ in6_update_ifa_join_mc(struct ifnet *ifp
> struct in6_ifaddr *ia, int flags, struct in6_multi **in6m_sol)
> {
>   char ip6buf[INET6_ADDRSTRLEN];
> - struct sockaddr_in6 mltaddr, mltmask;
> - struct in6_addr llsol;
> + struct in6_addr mltaddr;
>   struct in6_multi_mship *imm;
> - struct rtentry *rt;
>   int delay, error;
> 
>   KASSERT(in6m_sol != NULL, ("%s: in6m_sol is NULL", __func__));
> 
>   /* Join solicited multicast addr for new host id. */
> - bzero(&llsol, sizeof(struct in6_addr));
> - llsol.s6_addr32[0] = IPV6_ADDR_INT32_MLL;
> - llsol.s6_addr32[1] = 0;
> - llsol.s6_addr32[2] = htonl(1);
> - llsol.s6_addr32[3] = ifra->ifra_addr.sin6_addr.s6_addr32[3];
> - llsol.s6_addr8[12] = 0xff;
> - if ((error = in6_setscope(&llsol, ifp, NULL)) != 0) {
> + bzero(&mltaddr, sizeof(struct in6_addr));
> + mltaddr.s6_addr32[0] = IPV6_ADDR_INT32_MLL;
> + mltaddr.s6_addr32[2] = htonl(1);
> + mltaddr.s6_addr32[3] = ifra->ifra_addr.sin6_addr.s6_addr32[3];
> + mltaddr.s6_addr8[12] = 0xff;
> + if ((error = in6_setscope(&mltaddr, ifp, NULL)) != 0) {
>   /* XXX: should not happen */
>   log(LOG_ERR, "%s: in6_setscope failed\n", __func__);
>   goto cleanup;
>   }
> - delay = 0;
> + delay = error = 0;
>   if ((flags & IN6_IFAUPDATE_DADDELAY)) {
>   /*
>* We need a random delay for DAD on the address being
> @@ -812,62 +809,28 @@ in6_update_ifa_join_mc(struct ifnet *ifp
>*/
>   delay = arc4random() % (MAX_RTR_SOLICITATION_DELAY * hz);
>   }
> - imm = in6_joingroup(ifp, &llsol, &error, delay);
> + imm = in6_joingroup(ifp, &mltaddr, &error, delay);
>   if (imm == NULL) {
> - nd6log((LOG_WARNING, "%s: addmulti failed for %s on %s "
> - "(errno=%d)\n", __func__, ip6_sprintf(ip6buf, &llsol),
> + nd6log((LOG_WARNING, "%s: in6_joingroup failed for %s on %s "
> + "(errno=%d)\n", __func__, ip6_sprintf(ip6buf, &mltaddr),
>   if_name(ifp), error));
>   goto cleanup;
>   }
>   LIST_INSERT_HEAD(&ia->ia6_memberships, imm, i6mm_chain);
>   *in6m_sol = imm->i6mm_maddr;
> 
> - bzero(&mltmask, sizeof(mltmask));
> - mltmask.sin6_len = sizeof(struct sockaddr_in6);
> - mltmask.sin6_family = AF_INET6;
> - mltmask.sin6_addr = in6mask32;
> -#define  MLTMASK_LEN  4  /* mltmask's masklen (=32bit=4octet) */
> -
>   /*
>* Join link-local all-nodes address.
>*/
> - bzero(&mltaddr, sizeof(mltaddr));
> - mltaddr.sin6_len = sizeof(struct sockaddr_in6);
> - mltaddr.sin6_family = AF_INET6;
> - mltaddr.sin6_addr = in6addr_linklocal_allnodes;
> - if ((error = in6_setscope(&mltaddr.sin6_addr, ifp, NULL)) != 0)
> + mltaddr = in6addr_linklocal_allnodes;
> + if ((error = in6_setscope(&mltaddr, ifp, NULL)) != 0)
>   goto cleanup; /* XXX: should not fail */
> 
> - /*
> -  * XXX: do we really need this automatic routes?  We should probably
> -  * reconsider this stuff.  Most applications actually do not need the
> -  * routes, since they usually specify the outgoing interface.
> -  */
> - rt = in6_rtalloc1((struct sockaddr *)&mltaddr, 0, 0UL, RT_DEFAULT_FIB);
> - if (rt != NULL) {
> - /* XXX: only works in !SCOPEDROUTING case. */
> - if (memcmp(&mltaddr.sin6_addr,
> - &((struct sockaddr_in6 *)rt_key(rt))->sin6_addr,
> - MLTMASK_LEN)) {
> - RTFREE_LOCKED(rt);
> - rt = NULL;
> - }
> - }
> - if (rt == NULL) {
> - error = in6_rtrequest(RTM_ADD, (struct sockaddr *)&mltaddr,
> - (struct sockaddr *)&ia->ia_addr,
> - (struct sockaddr *)&mltmask, RTF_UP,
> - (struct rtentry **)0, RT_DEFAULT_FIB);
> - if (error)
> - goto cleanup;
> - } else
> - RTFREE_LOCKED(rt);
> -
> - imm = in6_joingroup(ifp, &mltaddr.sin6_addr, &error, 0);
> + imm = in6_joingroup(ifp, &mltaddr, &error, 0);
>   if (imm == NULL) {
> - nd6log((LOG_WARNING, "%s: ad

Re: svn commit: r273742 - head/sys/netinet6

2014-10-27 Thread Andrey V. Elsukov
On 27.10.2014 19:43, Bjoern A. Zeeb wrote:
> 
> On 27 Oct 2014, at 16:15 , Andrey V. Elsukov  wrote:
> 
>> Author: ae
>> Date: Mon Oct 27 16:15:15 2014
>> New Revision: 273742
>> URL: https://svnweb.freebsd.org/changeset/base/273742
>>
>> Log:
>>  Do not automatically install routes to link-local and interface-local 
>> multicast
>>  addresses.
> 
> Why?

They are useless. Multicast code maintains needed routing information
internally when system does join to multicast groups.

-- 
WBR, Andrey V. Elsukov
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r273734 - head/bin/dd

2014-10-27 Thread Bruce Evans

On Mon, 27 Oct 2014, Kurt Jaeger wrote:


Log:
 bin/dd: Fix incorrect casting of arguments

[...]

Both of these work correctly in my version (with a relatively small patch
and no breakage of other cases).  (I actually typed large values as -1
and 11.  -1 means (uintmax_t)-1 although this
is undocumented and now broken).


So, given this detailed review, should I revert the change ?


Yes.  You would have to change half of it just to get it to compile
on 32-bit arches.

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


Re: svn commit: r273734 - head/bin/dd

2014-10-27 Thread Ian Lepore
On Mon, 2014-10-27 at 17:20 +0100, Kurt Jaeger wrote:
> Hi!
> 
> > > Log:
> > >  bin/dd: Fix incorrect casting of arguments
> [...]
> > Both of these work correctly in my version (with a relatively small patch
> > and no breakage of other cases).  (I actually typed large values as -1
> > and 11.  -1 means (uintmax_t)-1 although this
> > is undocumented and now broken).
> 
> So, given this detailed review, should I revert the change ?
> 

Given that it breaks the build for 32 bit architectures, it probably
should be reverted until a different set of changes is available.

-- Ian


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


Re: svn commit: r273129 - head/sys/kern

2014-10-27 Thread Bruce Evans

On Wed, 15 Oct 2014, Konstantin Belousov wrote:


Log:
 Implement FIODTYPE for master ptys.

 Requested and reviewed by: bde
 Sponsored by:  The FreeBSD Foundation
 MFC after: 1 week


Thanks. This allows dd to work on ptys again.  dd has the following bad code:

% static void
% getfdtype(IO *io)
% {
%   struct stat sb;
%   int type;
% 
% 	if (fstat(io->fd, &sb) == -1)

%   err(1, "%s", io->name);

FIODTYPE should only be used as a hint, but dd makes its non-support fatal
in some cases.  Even fstat() failure for determining the hint shouldn't be
fatal.

%   if (S_ISREG(sb.st_mode))
%   io->flags |= ISTRUNC;
% 	if (S_ISCHR(sb.st_mode) || S_ISBLK(sb.st_mode)) { 
% 		if (ioctl(io->fd, FIODTYPE, &type) == -1) {

%   err(1, "%s", io->name);
%   } else {

dd only uses the dtype hint for devices.  Otherwise, it uses defaults.  It
might as well use the defaults for devices that don't support dtype too.

%   if (type & D_TAPE)
%   io->flags |= ISTAPE;
%   else if (type & (D_DISK | D_MEM))
%   io->flags |= ISSEEK;
%   if (S_ISCHR(sb.st_mode) && (type & D_TAPE) == 0)
%   io->flags |= ISCHR;
%   }
%   return;
%   }
%   errno = 0;
%   if (lseek(io->fd, (off_t)0, SEEK_CUR) == -1 && errno == ESPIPE)
%   io->flags |= ISPIPE;
%   else
%   io->flags |= ISSEEK;
% }

Not only the dtype check is bad.  dd still has to guess about seekability,
and does this not very well.  Guessing is not needed for pipes, but dd
guesses for them.  Pipes are not seekable, but the converse is false.
Tapes ar character devices, but ISCHR is not set for them.  I use the
following fixes (not complete -- at least the spelling change for ISSEEK
is mostly in other files).

@diff -u2 dd.c~ dd.c
@--- dd.c~  Wed Apr  7 20:20:48 2004
@+++ dd.c   Wed Apr  7 20:20:49 2004
@@@ -247,21 +245,18 @@
@   io->flags |= ISTRUNC;
@ 	if (S_ISCHR(sb.st_mode) || S_ISBLK(sb.st_mode)) { 
@-		if (ioctl(io->fd, FIODTYPE, &type) == -1) {

@+  if (ioctl(io->fd, FIODTYPE, &type) == -1)
@   err(1, "%s", io->name);
@-  } else {
@+  else {
@   if (type & D_TAPE)
@   io->flags |= ISTAPE;
@   else if (type & (D_DISK | D_MEM))
@-  io->flags |= ISSEEK;
@-  if (S_ISCHR(sb.st_mode) && (type & D_TAPE) == 0)
@+  io->flags |= ISSEEKABLE;
@+  if (S_ISCHR(sb.st_mode))
@   io->flags |= ISCHR;
@   }
@-  return;
@-  }
@-  errno = 0;
@-  if (lseek(io->fd, (off_t)0, SEEK_CUR) == -1 && errno == ESPIPE)
@-  io->flags |= ISPIPE;
@-  else
@-  io->flags |= ISSEEK;
@+  } else if (lseek(io->fd, (off_t)0, SEEK_CUR) == 0)
@+  io->flags |= ISSEEKABLE;
@+  else if (errno == ESPIPE)
@+  io->flags |= ISPIPE; /* XXX fixed in 4.4BSD */
@ }
@

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


svn commit: r273743 - head/bin/dd

2014-10-27 Thread Kurt Jaeger
Author: pi (ports committer)
Date: Mon Oct 27 17:39:37 2014
New Revision: 273743
URL: https://svnweb.freebsd.org/changeset/base/273743

Log:
  bin/dd: revert 273734, as it fails on 32bit platforms
  
  Revert: insufficient testing on 32bit platforms
  
  PR:   191263

Modified:
  head/bin/dd/args.c
  head/bin/dd/conv.c
  head/bin/dd/dd.c
  head/bin/dd/dd.h
  head/bin/dd/position.c

Modified: head/bin/dd/args.c
==
--- head/bin/dd/args.c  Mon Oct 27 16:15:15 2014(r273742)
+++ head/bin/dd/args.c  Mon Oct 27 17:39:37 2014(r273743)
@@ -41,7 +41,6 @@ __FBSDID("$FreeBSD$");
 
 #include 
 
-#include 
 #include 
 #include 
 #include 
@@ -172,7 +171,8 @@ jcl(char **argv)
 */
if (in.offset > OFF_MAX / (ssize_t)in.dbsz ||
out.offset > OFF_MAX / (ssize_t)out.dbsz)
-   errx(1, "seek offsets cannot be larger than %jd", OFF_MAX);
+   errx(1, "seek offsets cannot be larger than %jd",
+   (intmax_t)OFF_MAX);
 }
 
 static int
@@ -186,30 +186,37 @@ c_arg(const void *a, const void *b)
 static void
 f_bs(char *arg)
 {
+   uintmax_t res;
 
-   in.dbsz = out.dbsz = get_num(arg);
-   if (out.dbsz < 1 || out.dbsz > SSIZE_MAX)
-   errx(1, "bs must be between 1 and %jd", SSIZE_MAX);
+   res = get_num(arg);
+   if (res < 1 || res > SSIZE_MAX)
+   errx(1, "bs must be between 1 and %jd", (intmax_t)SSIZE_MAX);
+   in.dbsz = out.dbsz = (size_t)res;
 }
 
 static void
 f_cbs(char *arg)
 {
+   uintmax_t res;
 
-   cbsz = get_num(arg);
-   if (cbsz < 1 || cbsz > SSIZE_MAX)
-   errx(1, "cbs must be between 1 and %jd", SSIZE_MAX);
+   res = get_num(arg);
+   if (res < 1 || res > SSIZE_MAX)
+   errx(1, "cbs must be between 1 and %jd", (intmax_t)SSIZE_MAX);
+   cbsz = (size_t)res;
 }
 
 static void
 f_count(char *arg)
 {
+   intmax_t res;
 
-   cpy_cnt = get_num(arg);
-   if (cpy_cnt == SIZE_MAX)
-   errc(1, ERANGE, "%s", oper);
-   if (cpy_cnt == 0)
-   cpy_cnt = -1;
+   res = (intmax_t)get_num(arg);
+   if (res < 0)
+   errx(1, "count cannot be negative");
+   if (res == 0)
+   cpy_cnt = (uintmax_t)-1;
+   else
+   cpy_cnt = (uintmax_t)res;
 }
 
 static void
@@ -218,7 +225,7 @@ f_files(char *arg)
 
files_cnt = get_num(arg);
if (files_cnt < 1)
-   errx(1, "files must be between 1 and %ju", SIZE_MAX);
+   errx(1, "files must be between 1 and %jd", (uintmax_t)-1);
 }
 
 static void
@@ -234,11 +241,14 @@ f_fillchar(char *arg)
 static void
 f_ibs(char *arg)
 {
+   uintmax_t res;
 
if (!(ddflags & C_BS)) {
-   in.dbsz = get_num(arg);
-   if (in.dbsz < 1 || in.dbsz > SSIZE_MAX)
-   errx(1, "ibs must be between 1 and %ju", SSIZE_MAX);
+   res = get_num(arg);
+   if (res < 1 || res > SSIZE_MAX)
+   errx(1, "ibs must be between 1 and %jd",
+   (intmax_t)SSIZE_MAX);
+   in.dbsz = (size_t)res;
}
 }
 
@@ -252,11 +262,14 @@ f_if(char *arg)
 static void
 f_obs(char *arg)
 {
+   uintmax_t res;
 
if (!(ddflags & C_BS)) {
-   out.dbsz = get_num(arg);
-   if (out.dbsz < 1 || out.dbsz > SSIZE_MAX)
-   errx(1, "obs must be between 1 and %jd", SSIZE_MAX);
+   res = get_num(arg);
+   if (res < 1 || res > SSIZE_MAX)
+   errx(1, "obs must be between 1 and %jd",
+   (intmax_t)SSIZE_MAX);
+   out.dbsz = (size_t)res;
}
 }
 
@@ -365,17 +378,11 @@ get_num(const char *val)
uintmax_t num, mult, prevnum;
char *expr;
 
-   while (isspace(val[0]))
-   val++;
-
-   if (val[0] == '-')
-   errx(1, "%s: cannot be negative", oper);
-
errno = 0;
-   num = strtoull(val, &expr, 0);
+   num = strtouq(val, &expr, 0);
if (errno != 0) /* Overflow or underflow. */
err(1, "%s", oper);
-
+   
if (expr == val)/* No valid digits. */
errx(1, "%s: illegal numeric value", oper);
 

Modified: head/bin/dd/conv.c
==
--- head/bin/dd/conv.c  Mon Oct 27 16:15:15 2014(r273742)
+++ head/bin/dd/conv.c  Mon Oct 27 17:39:37 2014(r273743)
@@ -133,7 +133,7 @@ block(void)
 */
ch = 0;
for (inp = in.dbp - in.dbcnt, outp = out.dbp; in.dbcnt;) {
-   maxlen = MIN(cbsz, (size_t)in.dbcnt);
+   maxlen = MIN(cbsz, in.dbcnt);
if ((t = ctab) != NULL)
for (cnt = 0; cnt < maxlen && (ch = *inp++) != '\n';

Re: svn commit: r273734 - head/bin/dd

2014-10-27 Thread Kurt Jaeger
Hi!

> > So, given this detailed review, should I revert the change ?
> 
> Yes.  You would have to change half of it just to get it to compile
> on 32-bit arches.

Done. It's clearly my fault, I was sloppy in testing 8-(

-- 
p...@freebsd.org +49 171 31013726 years to go !
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r273130 - head/sys/fs/deadfs

2014-10-27 Thread Bruce Evans

On Wed, 15 Oct 2014, Konstantin Belousov wrote:


Log:
 Change the deadfs poll VOP to return POLLIN|POLLRDNORM if the caller
 is interested in i/o state.  Return POLLNVAL for invalid bits, similar
 to poll_no_poll().  Note that POLLOUT must not be returned, since
 POLLHUP is set.

 Noted and reviewed by: bde
 Sponsored by:  The FreeBSD Foundation
 MFC after: 1 week


Thanks.

This is not a complete fix, but is just bug for bug compatible with
poll_no_poll() and less buggy that the previous version.

POLLNVAL means that the fd is valid, so it should not be returned for
dead fd's (the whole point of deadfs is to keep the fd's alive enough
to be valid).  POLLIN should only be returned in there is (non-null)
data.

For some fd's, there may be both hangup and data, but for dead fd's
there can only be hangup, so POLLIN is especially useless for deadfs.
ttys are one of the few file types that usually set POLLIN correctly
for EOF (that is, POLLIN is not set for EOF).  2 unusual broken cases
remain for ttys:
- when the tty goes away but the fd is still connected to the tty driver,
  POLLIN is set if it is checked for
- but the fd is connected to deadfs (typically after it is revoked), the
  behaviour is now the same as when the tty goes away, except POLLNVAL
  is also set.
For other file types, the new behaviour matches bugs in the handling for
undead fd's better, while fixing some of the bugs in the old behaviour.

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


Re: svn commit: r273214 - in head/sys: amd64/vmm/intel modules/vmm

2014-10-27 Thread John Baldwin
On Monday, October 27, 2014 11:36:41 AM Warner Losh wrote:
> On Oct 27, 2014, at 10:54 AM, John Baldwin  wrote:
> > On Friday, October 17, 2014 01:20:50 PM Warner Losh wrote:
> >> Author: imp
> >> Date: Fri Oct 17 13:20:49 2014
> >> New Revision: 273214
> >> URL: https://svnweb.freebsd.org/changeset/base/273214
> >> 
> >> Log:
> >>  Fix build to not bogusly always rebuild vmm.ko.
> >>  
> >>  Rename vmx_assym.s to vmx_assym.h to reflect that file's actual use
> >>  and update vmx_support.S's include to match. Add vmx_assym.h to the
> >>  SRCS to that it gets properly added to the dependency list. Add
> >>  vmx_support.S to SRCS as well, so it gets built and needs fewer
> >>  special-case goo. Remove now-redundant special-case goo. Finally,
> >>  vmx_genassym.o doesn't need to depend on a hand expanded ${_ILINKS}
> >>  explicitly, that's all taken care of by beforedepend.
> >>  
> >>  With these items fixed, we no longer build vmm.ko every single time
> >>  through the modules on a KERNFAST build.
> > 
> > So I cheered for this before, but it appears to be broken. :(
> > 
> > Namely, I rebuilt world + kernel on my laptop this weekend (it was about a
> > month old).  My normal setup builds kernels with NO_KERNELCLEAN=yes.  On my
> > next reboot when I started a bhyve VM I promptly got a panic due to a page
> > 
> > fault in this assembly code:
> > /*
> > 
> >  * If 'vmx->eptgen[curcpu]' is not identical to 'pmap->pm_eptgen'
> >  * then we must invalidate all mappings associated with this EPTP.
> >  */
> > 
> > movqPM_EPTGEN(%r11), %r10
> > cmpq%r10, VMX_EPTGEN(%rsi, %rax, 8)
> > je  guest_restore
> > 
> > (The 'cmpq' instruction)
> > 
> > This change came to mind, so I blew away the 'vmm' module directory and
> > rebuilt my kernel.  Comparing the assembly of this instruction before and
> > after used different values for VMX_EPTGEN.  In other words, the
> > NO_KERNELCLEAN=yes build failed to regenerate vmx_assym.h and the build
> > used stale values.
> 
> Is there a way to force this condition for testing?

You could checkout an older tree (probably before the recent merge of AMD SVM
support) and build vmm.ko, then svn update and see if vmx_assym and
vmx_support.o are updated.

Actually, this was simpler:

% cd sys/modules/vmm
% make depend
% make vmx_assym.h  # reports nothing to do
% touch machine/vmm.h  # vmx_genassym.c includes this
% make vmx_assym.h  # should rebuild, but doesn't

> > In particular, if you examine the generated .depend file, you will find
> > that there are no dependencies recorded for vmx_genassym.o, so it is
> > never rebuilt if any of the headers it includes are changed.  In my case
> > the panic happened to be one that was easily diagnosed, but I could
> > imagine stale assym headers causing very odd crashes that would be quite
> > hard to track down.  I think these changes should be reverted if we can't
> > fix the dependencies of the associated object files they are generated
> > from. :(
> 
> Give me a bit and I’ll fix it. There’s a number of implicit dependencies
> that don’t get recorded in the .depend file, iirc, so that’s not completely
> conclusive. Not building, though is kinda a big hint that something’s
> amiss.

I think the thing here is that for the assym files we don't record any
dependency info at all.  The main kernel build does record dependencies
for genassym.o in .depend, so it must be doable.

In kern.pre.mk:

GEN_CFILES= $S/$M/$M/genassym.c ${MFILES:T:S/.m$/.c/}

and those are then explicitly passed to mkdep in kern.post.mk.

So this fixes it:

Index: Makefile
===
--- Makefile(revision 273555)
+++ Makefile(working copy)
@@ -4,6 +4,7 @@ KMOD=   vmm
 
 SRCS=  opt_acpi.h opt_ddb.h device_if.h bus_if.h pci_if.h
 SRCS+= vmx_assym.h svm_assym.h
+DPSRCS=vmx_genassym.c svm_genassym.c
 
 CFLAGS+= -DVMM_KEEP_STATS -DSMP
 CFLAGS+= -I${.CURDIR}/../../amd64/vmm

I'll try to track down all the other assym files and fix them as well.

> However, -DNO_CLEAN has always been a very-sharp edged tool that will cut
> you in a number of ways, so there’s no rush to back this out.

This is the first time in many years that NO_KERNELCLEAN=yes has been a
problem for me.  (worlds sometimes have issues, but kernels rarely do).
Also, usually when it breaks it fails to compile, it doesn't compile and
then panic. :(

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

svn commit: r273744 - in head/sys/modules: linux vmm

2014-10-27 Thread John Baldwin
Author: jhb
Date: Mon Oct 27 18:37:11 2014
New Revision: 273744
URL: https://svnweb.freebsd.org/changeset/base/273744

Log:
  Add foo_genassym.c files to DPSRCS so dependencies for them are generated.
  This ensures these objects are rebuilt to generate an updated header of
  assembly constants if needed.

Modified:
  head/sys/modules/linux/Makefile
  head/sys/modules/vmm/Makefile

Modified: head/sys/modules/linux/Makefile
==
--- head/sys/modules/linux/Makefile Mon Oct 27 17:39:37 2014
(r273743)
+++ head/sys/modules/linux/Makefile Mon Oct 27 18:37:11 2014
(r273744)
@@ -17,6 +17,7 @@ SRCS= linux_fork.c linux${SFX}_dummy.c l
opt_inet6.h opt_compat.h opt_posix.h opt_usb.h vnode_if.h \
device_if.h bus_if.h assym.s \
linux${SFX}_locore.s linux${SFX}_support.s
+DPSRCS=linux${SFX}_genassym.c
 
 # XXX: for assym.s
 SRCS+=  opt_kstack_pages.h opt_nfs.h opt_compat.h opt_hwpmc_hooks.h

Modified: head/sys/modules/vmm/Makefile
==
--- head/sys/modules/vmm/Makefile   Mon Oct 27 17:39:37 2014
(r273743)
+++ head/sys/modules/vmm/Makefile   Mon Oct 27 18:37:11 2014
(r273744)
@@ -4,6 +4,7 @@ KMOD=   vmm
 
 SRCS=  opt_acpi.h opt_ddb.h device_if.h bus_if.h pci_if.h
 SRCS+= vmx_assym.h svm_assym.h
+DPSRCS=vmx_genassym.c svm_genassym.c
 
 CFLAGS+= -DVMM_KEEP_STATS -DSMP
 CFLAGS+= -I${.CURDIR}/../../amd64/vmm
@@ -53,7 +54,7 @@ SRCS+=vmcb.c  \
npt.c   \
amdv.c  \
svm_msr.c
-   
+
 CLEANFILES=vmx_assym.h vmx_genassym.o svm_assym.h svm_genassym.o
 
 vmx_assym.h:vmx_genassym.o
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r273745 - head/sys/kern

2014-10-27 Thread Mateusz Guzik
Author: mjg
Date: Mon Oct 27 20:18:30 2014
New Revision: 273745
URL: https://svnweb.freebsd.org/changeset/base/273745

Log:
  De-k&r-ify function definitions in kern/kern_resource.c
  
  No functional changes.

Modified:
  head/sys/kern/kern_resource.c

Modified: head/sys/kern/kern_resource.c
==
--- head/sys/kern/kern_resource.c   Mon Oct 27 18:37:11 2014
(r273744)
+++ head/sys/kern/kern_resource.c   Mon Oct 27 20:18:30 2014
(r273745)
@@ -92,9 +92,7 @@ struct getpriority_args {
 };
 #endif
 int
-sys_getpriority(td, uap)
-   struct thread *td;
-   register struct getpriority_args *uap;
+sys_getpriority(struct thread *td, register struct getpriority_args *uap)
 {
struct proc *p;
struct pgrp *pg;
@@ -177,9 +175,7 @@ struct setpriority_args {
 };
 #endif
 int
-sys_setpriority(td, uap)
-   struct thread *td;
-   struct setpriority_args *uap;
+sys_setpriority(struct thread *td, struct setpriority_args *uap)
 {
struct proc *curp, *p;
struct pgrp *pg;
@@ -373,9 +369,7 @@ struct rtprio_args {
 };
 #endif
 int
-sys_rtprio(td, uap)
-   struct thread *td;  /* curthread */
-   register struct rtprio_args *uap;
+sys_rtprio(struct thread *td, register struct rtprio_args *uap)
 {
struct proc *p;
struct thread *tdp;
@@ -541,9 +535,7 @@ struct osetrlimit_args {
 };
 #endif
 int
-osetrlimit(td, uap)
-   struct thread *td;
-   register struct osetrlimit_args *uap;
+osetrlimit(struct thread *td, register struct osetrlimit_args *uap)
 {
struct orlimit olim;
struct rlimit lim;
@@ -564,9 +556,7 @@ struct ogetrlimit_args {
 };
 #endif
 int
-ogetrlimit(td, uap)
-   struct thread *td;
-   register struct ogetrlimit_args *uap;
+ogetrlimit(struct thread *td, register struct ogetrlimit_args *uap)
 {
struct orlimit olim;
struct rlimit rl;
@@ -603,9 +593,7 @@ struct __setrlimit_args {
 };
 #endif
 int
-sys_setrlimit(td, uap)
-   struct thread *td;
-   register struct __setrlimit_args *uap;
+sys_setrlimit(struct thread *td, register struct __setrlimit_args *uap)
 {
struct rlimit alim;
int error;
@@ -797,9 +785,7 @@ struct __getrlimit_args {
 #endif
 /* ARGSUSED */
 int
-sys_getrlimit(td, uap)
-   struct thread *td;
-   register struct __getrlimit_args *uap;
+sys_getrlimit(struct thread *td, register struct __getrlimit_args *uap)
 {
struct rlimit rlim;
struct proc *p;
@@ -820,10 +806,7 @@ sys_getrlimit(td, uap)
  * into user and system time usage.
  */
 void
-calccru(p, up, sp)
-   struct proc *p;
-   struct timeval *up;
-   struct timeval *sp;
+calccru(struct proc *p, struct timeval *up, struct timeval *sp)
 {
 
PROC_LOCK_ASSERT(p, MA_OWNED);
@@ -976,9 +959,7 @@ struct getrusage_args {
 };
 #endif
 int
-sys_getrusage(td, uap)
-   register struct thread *td;
-   register struct getrusage_args *uap;
+sys_getrusage(register struct thread *td, register struct getrusage_args *uap)
 {
struct rusage ru;
int error;
@@ -1133,8 +1114,7 @@ lim_alloc()
 }
 
 struct plimit *
-lim_hold(limp)
-   struct plimit *limp;
+lim_hold(struct plimit *limp)
 {
 
refcount_acquire(&limp->pl_refcnt);
@@ -1142,8 +1122,7 @@ lim_hold(limp)
 }
 
 static __inline int
-lim_shared(limp)
-   struct plimit *limp;
+lim_shared(struct plimit *limp)
 {
 
return (limp->pl_refcnt > 1);
@@ -1164,8 +1143,7 @@ lim_fork(struct proc *p1, struct proc *p
 }
 
 void
-lim_free(limp)
-   struct plimit *limp;
+lim_free(struct plimit *limp)
 {
 
if (refcount_release(&limp->pl_refcnt))
@@ -1177,8 +1155,7 @@ lim_free(limp)
  * We share these structures copy-on-write after fork.
  */
 void
-lim_copy(dst, src)
-   struct plimit *dst, *src;
+lim_copy(struct plimit *dst, struct plimit *src)
 {
 
KASSERT(!lim_shared(dst), ("lim_copy to shared limit"));
@@ -1240,8 +1217,7 @@ uihashinit()
  * uihashtbl_lock must be locked.
  */
 static struct uidinfo *
-uilookup(uid)
-   uid_t uid;
+uilookup(uid_t uid)
 {
struct uihashhead *uipp;
struct uidinfo *uip;
@@ -1261,8 +1237,7 @@ uilookup(uid)
  * uifree() should be called on a struct uidinfo when released.
  */
 struct uidinfo *
-uifind(uid)
-   uid_t uid;
+uifind(uid_t uid)
 {
struct uidinfo *old_uip, *uip;
 
@@ -1300,8 +1275,7 @@ uifind(uid)
  * Place another refcount on a uidinfo struct.
  */
 void
-uihold(uip)
-   struct uidinfo *uip;
+uihold(struct uidinfo *uip)
 {
 
refcount_acquire(&uip->ui_ref);
@@ -1323,8 +1297,7 @@ uihold(uip)
  *   order to try again.
  */
 void
-uifree(uip)
-   struct uidinfo *uip;
+uifree(struct uidinfo *uip)
 {
int old;
 
@@ -1380,10 +1353,7 @@ ui_racct_foreach(void (*callback)(struct
  * a given user is using.  When 'max' is 0, don't enforce a limit
  */
 int
-chgproccnt(uip, diff, max)
-   struct  uidi

svn commit: r273746 - head/sys/kern

2014-10-27 Thread Mateusz Guzik
Author: mjg
Date: Mon Oct 27 20:20:05 2014
New Revision: 273746
URL: https://svnweb.freebsd.org/changeset/base/273746

Log:
  Tidy up functions related to uidinfo management.
  
  - reference found uidinfo in uilookup
  - reduce nesting by handling shorter cases first

Modified:
  head/sys/kern/kern_resource.c

Modified: head/sys/kern/kern_resource.c
==
--- head/sys/kern/kern_resource.c   Mon Oct 27 20:18:30 2014
(r273745)
+++ head/sys/kern/kern_resource.c   Mon Oct 27 20:20:05 2014
(r273746)
@@ -1215,6 +1215,7 @@ uihashinit()
 /*
  * Look up a uidinfo struct for the parameter uid.
  * uihashtbl_lock must be locked.
+ * Increase refcount on uidinfo struct returned.
  */
 static struct uidinfo *
 uilookup(uid_t uid)
@@ -1225,49 +1226,52 @@ uilookup(uid_t uid)
rw_assert(&uihashtbl_lock, RA_LOCKED);
uipp = UIHASH(uid);
LIST_FOREACH(uip, uipp, ui_hash)
-   if (uip->ui_uid == uid)
+   if (uip->ui_uid == uid) {
+   uihold(uip);
break;
+   }
 
return (uip);
 }
 
 /*
  * Find or allocate a struct uidinfo for a particular uid.
- * Increase refcount on uidinfo struct returned.
+ * Returns with uidinfo struct referenced.
  * uifree() should be called on a struct uidinfo when released.
  */
 struct uidinfo *
 uifind(uid_t uid)
 {
-   struct uidinfo *old_uip, *uip;
+   struct uidinfo *new_uip, *uip;
 
rw_rlock(&uihashtbl_lock);
uip = uilookup(uid);
-   if (uip == NULL) {
-   rw_runlock(&uihashtbl_lock);
-   uip = malloc(sizeof(*uip), M_UIDINFO, M_WAITOK | M_ZERO);
-   racct_create(&uip->ui_racct);
-   rw_wlock(&uihashtbl_lock);
-   /*
-* There's a chance someone created our uidinfo while we
-* were in malloc and not holding the lock, so we have to
-* make sure we don't insert a duplicate uidinfo.
-*/
-   if ((old_uip = uilookup(uid)) != NULL) {
-   /* Someone else beat us to it. */
-   racct_destroy(&uip->ui_racct);
-   free(uip, M_UIDINFO);
-   uip = old_uip;
-   } else {
-   refcount_init(&uip->ui_ref, 0);
-   uip->ui_uid = uid;
-   mtx_init(&uip->ui_vmsize_mtx, "ui_vmsize", NULL,
-   MTX_DEF);
-   LIST_INSERT_HEAD(UIHASH(uid), uip, ui_hash);
-   }
+   rw_runlock(&uihashtbl_lock);
+   if (uip != NULL)
+   return (uip);
+
+   new_uip = malloc(sizeof(*new_uip), M_UIDINFO, M_WAITOK | M_ZERO);
+   racct_create(&new_uip->ui_racct);
+   refcount_init(&new_uip->ui_ref, 1);
+   new_uip->ui_uid = uid;
+   mtx_init(&new_uip->ui_vmsize_mtx, "ui_vmsize", NULL, MTX_DEF);
+
+   rw_wlock(&uihashtbl_lock);
+   /*
+* There's a chance someone created our uidinfo while we
+* were in malloc and not holding the lock, so we have to
+* make sure we don't insert a duplicate uidinfo.
+*/
+   if ((uip = uilookup(uid)) == NULL) {
+   LIST_INSERT_HEAD(UIHASH(uid), new_uip, ui_hash);
+   rw_wunlock(&uihashtbl_lock);
+   uip = new_uip;
+   } else {
+   rw_wunlock(&uihashtbl_lock);
+   racct_destroy(&new_uip->ui_racct);
+   mtx_destroy(&new_uip->ui_vmsize_mtx);
+   free(new_uip, M_UIDINFO);
}
-   uihold(uip);
-   rw_unlock(&uihashtbl_lock);
return (uip);
 }
 
@@ -1308,28 +1312,26 @@ uifree(struct uidinfo *uip)
 
/* Prepare for suboptimal case. */
rw_wlock(&uihashtbl_lock);
-   if (refcount_release(&uip->ui_ref)) {
-   racct_destroy(&uip->ui_racct);
-   LIST_REMOVE(uip, ui_hash);
+   if (refcount_release(&uip->ui_ref) == 0) {
rw_wunlock(&uihashtbl_lock);
-   if (uip->ui_sbsize != 0)
-   printf("freeing uidinfo: uid = %d, sbsize = %ld\n",
-   uip->ui_uid, uip->ui_sbsize);
-   if (uip->ui_proccnt != 0)
-   printf("freeing uidinfo: uid = %d, proccnt = %ld\n",
-   uip->ui_uid, uip->ui_proccnt);
-   if (uip->ui_vmsize != 0)
-   printf("freeing uidinfo: uid = %d, swapuse = %lld\n",
-   uip->ui_uid, (unsigned long long)uip->ui_vmsize);
-   mtx_destroy(&uip->ui_vmsize_mtx);
-   free(uip, M_UIDINFO);
return;
}
-   /*
-* Someone added a reference between atomic_cmpset_int() and
-* rw_wlock(&uihashtbl_lock).
-*/
+
+   racct_destroy(&uip->ui_racct);
+   LIST_REMOVE(uip, ui_hash);
 

svn commit: r273747 - in head: contrib/hyperv/tools share/man/man8 tools/build/mk

2014-10-27 Thread Xin LI
Author: delphij
Date: Mon Oct 27 21:29:42 2014
New Revision: 273747
URL: https://svnweb.freebsd.org/changeset/base/273747

Log:
  Remove an extra copy of hv_kvp_daemon(8) [1].
  
  While I'm there also correct typos in OptionalObsoleteFiles and add
  information of the command line options for hv_kvp_daemon(8).
  
  Reported by:  jmg [1]
  Reviewed by:  jmg
  MFC after:2 weeks

Deleted:
  head/share/man/man8/hv_kvp_daemon.8
Modified:
  head/contrib/hyperv/tools/hv_kvp_daemon.8
  head/share/man/man8/Makefile
  head/tools/build/mk/OptionalObsoleteFiles.inc

Modified: head/contrib/hyperv/tools/hv_kvp_daemon.8
==
--- head/contrib/hyperv/tools/hv_kvp_daemon.8   Mon Oct 27 20:20:05 2014
(r273746)
+++ head/contrib/hyperv/tools/hv_kvp_daemon.8   Mon Oct 27 21:29:42 2014
(r273747)
@@ -22,41 +22,71 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd September 10, 2013
-.Dt HYPER-V 4
+.\" $FreeBSD$
+.Dd October 27, 2014
+.Dt HV_KVP_DAEMON 8
 .Os
 .Sh NAME
 .Nm hv_kvp_daemon
 .Nd Hyper-V Key Value Pair Daemon
 .Sh SYNOPSIS
-The \fBhv_kvp_daemon\fP daemon provides the ability to store, retrieve, modify 
and delete 
-Key Value pairs for FreeBSD guest partitions running on Hyper-V.
+.Nm
+.Op Fl dn
 .Sh DESCRIPTION
+The
+.Nm
+daemon provides the ability to store, retrieve, modify and delete 
+Key Value pairs for
+.Fx
+guest partitions running on Hyper-V.
+.Pp
 Hyper-V allows administrators to store custom metadata in the form
-of Key Value pairs inside the FreeBSD guest partition. Administrators can
+of Key Value pairs inside the
+.Fx
+guest partition.
+Administrators can
 use Windows Powershell scripts to add, read, modify and delete such
 Key Value pairs.
-
-The \fBhv_kvp_daemon\fP accepts Key Value pair management requests from the
-\fBhv_utils\fP driver and performs the actual metadata management on the 
file-system.
-
+.Pp
+The
+.Nm
+accepts Key Value pair management requests from the
+.Xr hv_utils 4
+driver and performs the actual metadata management on the file-system.
+.Pp
 The same daemon and driver combination is also used to set and get
-IP addresses from a FreeBSD guest. 
-
+IP addresses from a
+.Fx
+guest. 
+.Pp
 The set functionality is particularly
-useful when the FreeBSD guest is assigned a static IP address and is failed
-over from one Hyper-V host to another. After failover, Hyper-V uses the set IP
+useful when the
+.Fx
+guest is assigned a static IP address and is failed
+over from one Hyper-V host to another.
+After failover, Hyper-V uses the set IP
 functionality to automatically
-update the FreeBSD guest's IP address to its original static value. 
-
+update the
+.Fx
+guest's IP address to its original static value.
+.Pp
 On the other hand, the get IP functionality is used to update the guest IP
 address in the Hyper-V management console window.
+.Pp
+The options are as follows:
+.Bl -tag -width indent
+.It Fl d
+Run as regular process instead of a daemon for debugging purpose.
+.It Fl n
+Generate debugging output.
+.El
 .Sh SEE ALSO
 .Xr hv_vmbus 4 ,
 .Xr hv_utils 4 ,
 .Xr hv_netvsc 4 ,
 .Xr hv_storvsc 4 ,
-.Xr hv_ata_pci_disengage 4
+.Xr hv_ata_pci_disengage 4 ,
+.Xr hv_kvp 4
 .Sh HISTORY
 Support for Hyper-V in the form of ports was first released in September 2013.
 The daemon was developed through a joint effort between Citrix Inc., 
@@ -64,5 +94,7 @@ Microsoft Corp. and Network Appliance In
 .Sh AUTHORS
 .An -nosplit
 .Fx
-support for \fBhv_kvp_daemon\fP was first added by
-.An Microsoft BSD Integration Services Team Aq bs...@microsoft.com .
+support for
+.Nm
+was first added by
+.An Microsoft BSD Integration Services Team Aq Mt bs...@microsoft.com .

Modified: head/share/man/man8/Makefile
==
--- head/share/man/man8/MakefileMon Oct 27 20:20:05 2014
(r273746)
+++ head/share/man/man8/MakefileMon Oct 27 21:29:42 2014
(r273747)
@@ -3,7 +3,6 @@
 
 MAN=   crash.8 \
diskless.8 \
-   hv_kvp_daemon.8 \
intro.8 \
nanobsd.8 \
picobsd.8 \

Modified: head/tools/build/mk/OptionalObsoleteFiles.inc
==
--- head/tools/build/mk/OptionalObsoleteFiles.inc   Mon Oct 27 20:20:05 
2014(r273746)
+++ head/tools/build/mk/OptionalObsoleteFiles.inc   Mon Oct 27 21:29:42 
2014(r273747)
@@ -4779,5 +4779,6 @@ OLD_FILES+=etc/devd/hyperv.conf
 OLD_FILES+=usr/libexec/hyperv/hv_set_ifconfig
 OLD_FILES+=usr/libexec/hyperv/hv_get_dns_info
 OLD_FILES+=usr/libexec/hyperv/hv_get_dhcp_info
-OLD_FILES+=usr/sbin/hv_kvpd
+OLD_FILES+=usr/sbin/hv_kvp_daemon
+OLD_FILES+=usr/share/man/man8/hv_kvp_daemon.8.gz
 .endif
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head

svn commit: r273748 - head/sys/x86/x86

2014-10-27 Thread Peter Grehan
Author: grehan
Date: Mon Oct 27 22:02:35 2014
New Revision: 273748
URL: https://svnweb.freebsd.org/changeset/base/273748

Log:
  Output a summary of optional SVM features in dmesg similar to CPU features.
  If bootverbose is enabled, a detailed list is provided; otherwise, a
  single-line summary is displayed.
  
  Differential Revision:https://reviews.freebsd.org/D1008
  Reviewed by:  jhb, neel
  MFC after:1 week

Modified:
  head/sys/x86/x86/identcpu.c

Modified: head/sys/x86/x86/identcpu.c
==
--- head/sys/x86/x86/identcpu.c Mon Oct 27 21:29:42 2014(r273747)
+++ head/sys/x86/x86/identcpu.c Mon Oct 27 22:02:35 2014(r273748)
@@ -76,6 +76,7 @@ static u_int find_cpu_vendor_id(void);
 static void print_AMD_info(void);
 static void print_INTEL_info(void);
 static void print_INTEL_TLB(u_int data);
+static void print_svm_info(void);
 static void print_via_padlock_info(void);
 static void print_vmx_info(void);
 
@@ -932,6 +933,9 @@ printcpuinfo(void)
if (cpu_feature2 & CPUID2_VMX)
print_vmx_info();
 
+   if (amd_feature2 & AMDID2_SVM)
+   print_svm_info();
+
if ((cpu_feature & CPUID_HTT) &&
cpu_vendor_id == CPU_VENDOR_AMD)
cpu_feature &= ~CPUID_HTT;
@@ -1735,6 +1739,67 @@ print_INTEL_TLB(u_int data)
}
 }
 
+static void
+print_svm_info(void)
+{
+   u_int features, regs[4];
+   uint64_t msr;
+   int comma;
+
+   printf("\n  SVM: ");
+   do_cpuid(0x800A, regs);
+   features = regs[3];
+
+   msr = rdmsr(MSR_VM_CR);
+   if ((msr & VM_CR_SVMDIS) == VM_CR_SVMDIS)
+   printf("(disabled in BIOS) ");
+
+   if (!bootverbose) {
+   comma = 0;
+   if (features & (1 << 0)) {
+   printf("%sNP", comma ? "," : "");
+comma = 1; 
+   }
+   if (features & (1 << 3)) {
+   printf("%sNRIP", comma ? "," : "");
+comma = 1; 
+   }
+   if (features & (1 << 5)) {
+   printf("%sVClean", comma ? "," : "");
+comma = 1; 
+   }
+   if (features & (1 << 6)) {
+   printf("%sAFlush", comma ? "," : "");
+comma = 1; 
+   }
+   if (features & (1 << 7)) {
+   printf("%sDAssist", comma ? "," : "");
+comma = 1; 
+   }
+   printf("%sNAsids=%d", comma ? "," : "", regs[1]);
+   return;
+   }
+
+   printf("Features=0x%b", features,
+  "\020"
+  "\001NP" /* Nested paging */
+  "\002LbrVirt"/* LBR virtualization */
+  "\003SVML"   /* SVM lock */
+  "\004NRIPS"  /* NRIP save */
+  "\005TscRateMsr" /* MSR based TSC rate control */
+  "\006VmcbClean"  /* VMCB clean bits */
+  "\007FlushByAsid"/* Flush by ASID */
+  "\010DecodeAssist"   /* Decode assist */
+  "\011"
+  "\012"
+  "\013PauseFilter"/* PAUSE intercept filter */
+  "\014"
+  "\015PauseFilterThreshold" /* PAUSE filter threshold */
+  "\016AVIC"   /* virtual interrupt controller */
+);
+   printf("\nRevision=%d, ASIDs=%d", regs[0] & 0xff, regs[1]);
+}
+
 #ifdef __i386__
 static void
 print_transmeta_info(void)
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r273749 - head/sys/amd64/vmm/amd

2014-10-27 Thread Peter Grehan
Author: grehan
Date: Mon Oct 27 22:20:51 2014
New Revision: 273749
URL: https://svnweb.freebsd.org/changeset/base/273749

Log:
  Remove bhyve SVM feature printf's now that they are available in the
  general CPU feature detection code.
  
  Reviewed by:  neel

Modified:
  head/sys/amd64/vmm/amd/svm.c

Modified: head/sys/amd64/vmm/amd/svm.c
==
--- head/sys/amd64/vmm/amd/svm.cMon Oct 27 22:02:35 2014
(r273748)
+++ head/sys/amd64/vmm/amd/svm.cMon Oct 27 22:20:51 2014
(r273749)
@@ -174,30 +174,9 @@ check_svm_features(void)
do_cpuid(0x800A, regs);
svm_feature = regs[3];
 
-   printf("SVM: Revision %d\n", regs[0] & 0xFF);
-   printf("SVM: NumASID %u\n", regs[1]);
-
nasid = regs[1];
KASSERT(nasid > 1, ("Insufficient ASIDs for guests: %#x", nasid));
 
-   printf("SVM: Features 0x%b\n", svm_feature,
-   "\020"
-   "\001NP"/* Nested paging */
-   "\002LbrVirt"   /* LBR virtualization */
-   "\003SVML"  /* SVM lock */
-   "\004NRIPS" /* NRIP save */
-   "\005TscRateMsr"/* MSR based TSC rate control */
-   "\006VmcbClean" /* VMCB clean bits */
-   "\007FlushByAsid"   /* Flush by ASID */
-   "\010DecodeAssist"  /* Decode assist */
-   "\011"
-   "\012"
-   "\013PauseFilter"   
-   "\014"
-   "\015PauseFilterThreshold"  
-   "\016AVIC"  
-   );
-
/* bhyve requires the Nested Paging feature */
if (!(svm_feature & AMD_CPUID_SVM_NP)) {
printf("SVM: Nested Paging feature not available.\n");
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r273750 - head/sys/dev/cxgbe/iw_cxgbe

2014-10-27 Thread Navdeep Parhar
Author: np
Date: Mon Oct 27 22:22:46 2014
New Revision: 273750
URL: https://svnweb.freebsd.org/changeset/base/273750

Log:
  Some cxgbe/iw_cxgbe fixes:
  - Free rt in c4iw_connect only if it is allocated.
  - Call soclose instead of so_shutdown if there is an abort from the peer.
  - Close socket and return failure if TOE is not enabled.
  
  Submitted by: Hariprasad at Chelsio dot com
  Sponsored by: Chelsio Communications

Modified:
  head/sys/dev/cxgbe/iw_cxgbe/cm.c

Modified: head/sys/dev/cxgbe/iw_cxgbe/cm.c
==
--- head/sys/dev/cxgbe/iw_cxgbe/cm.cMon Oct 27 22:20:51 2014
(r273749)
+++ head/sys/dev/cxgbe/iw_cxgbe/cm.cMon Oct 27 22:22:46 2014
(r273750)
@@ -474,7 +474,7 @@ process_conn_error(struct c4iw_ep *ep)
if (state != ABORTING) {
 
CTR2(KTR_IW_CXGBE, "%s:pce1 %p", __func__, ep);
-   close_socket(&ep->com, 0);
+   close_socket(&ep->com, 1);
state_set(&ep->com, DEAD);
c4iw_put_ep(&ep->com);
}
@@ -2084,14 +2084,15 @@ int c4iw_connect(struct iw_cm_id *cm_id,
CTR2(KTR_IW_CXGBE, "%s:cc7 %p", __func__, ep);
printk(KERN_ERR MOD "%s - cannot find route.\n", __func__);
err = -EHOSTUNREACH;
-   goto fail3;
+   goto fail2;
}
 
-
-   if (!(rt->rt_ifp->if_flags & IFCAP_TOE)) {
+   if (!(rt->rt_ifp->if_capenable & IFCAP_TOE)) {
 
CTR2(KTR_IW_CXGBE, "%s:cc8 %p", __func__, ep);
printf("%s - interface not TOE capable.\n", __func__);
+   close_socket(&ep->com, 0);
+   err = -ENOPROTOOPT;
goto fail3;
}
tdev = TOEDEV(rt->rt_ifp);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r273751 - head/sys/contrib/rdma/krping

2014-10-27 Thread Navdeep Parhar
Author: np
Date: Mon Oct 27 22:41:55 2014
New Revision: 273751
URL: https://svnweb.freebsd.org/changeset/base/273751

Log:
  krping: In verbose mode print only first 128 bytes of krping data.
  
  Submitted by: Hariprasad at Chelsio dot com.
  Sponsored by: Chelsio Communications

Modified:
  head/sys/contrib/rdma/krping/krping.c

Modified: head/sys/contrib/rdma/krping/krping.c
==
--- head/sys/contrib/rdma/krping/krping.c   Mon Oct 27 22:22:46 2014
(r273750)
+++ head/sys/contrib/rdma/krping/krping.c   Mon Oct 27 22:41:55 2014
(r273751)
@@ -1011,9 +1011,17 @@ static void krping_test_server(struct kr
DEBUG_LOG(cb, "server received read complete\n");
 
/* Display data in recv buf */
-   if (cb->verbose)
-   PRINTF(cb, "server ping data: %s\n", 
-   cb->rdma_buf);
+   if (cb->verbose) {
+   if (strlen(cb->rdma_buf) > 128) {
+   char msgbuf[128];
+
+   strlcpy(msgbuf, cb->rdma_buf, sizeof(msgbuf));
+   PRINTF(cb, "server ping data stripped: %s\n",
+  msgbuf);
+   } else
+   PRINTF(cb, "server ping data: %s\n",
+  cb->rdma_buf);
+   }
 
/* Tell client to continue */
if (cb->server && cb->server_invalidate) {
@@ -1713,8 +1721,16 @@ static void krping_test_client(struct kr
break;
}
 
-   if (cb->verbose)
-   PRINTF(cb, "ping data: %s\n", cb->rdma_buf);
+   if (cb->verbose) {
+   if (strlen(cb->rdma_buf) > 128) {
+   char msgbuf[128];
+
+   strlcpy(msgbuf, cb->rdma_buf, sizeof(msgbuf));
+   PRINTF(cb, "ping data stripped: %s\n",
+  msgbuf);
+   } else
+   PRINTF(cb, "ping data: %s\n", cb->rdma_buf);
+   }
 #ifdef SLOW_KRPING
wait_event_interruptible_timeout(cb->sem, cb->state == ERROR, 
HZ);
 #endif
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r273752 - head/lib/libnv

2014-10-27 Thread John-Mark Gurney
Author: jmg
Date: Mon Oct 27 23:03:17 2014
New Revision: 273752
URL: https://svnweb.freebsd.org/changeset/base/273752

Log:
  fix typo, properly install a link to nv for nvlist_freev...

Modified:
  head/lib/libnv/Makefile

Modified: head/lib/libnv/Makefile
==
--- head/lib/libnv/Makefile Mon Oct 27 22:41:55 2014(r273751)
+++ head/lib/libnv/Makefile Mon Oct 27 23:03:17 2014(r273752)
@@ -149,7 +149,7 @@ MLINKS+=nv.3 nvlist_existsv.3 \
nv.3 nvlist_takev_nvlist.3 \
nv.3 nvlist_takev_descriptor.3 \
nv.3 nvlist_takev_binary.3 \
-   nv.3 nvlist_freef.3 \
+   nv.3 nvlist_freev.3 \
nv.3 nvlist_freev_type.3 \
nv.3 nvlist_freev_null.3 \
nv.3 nvlist_freev_bool.3 \
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r273753 - head/sys/dev/cxgbe/iw_cxgbe

2014-10-27 Thread Navdeep Parhar
Author: np
Date: Mon Oct 27 23:11:48 2014
New Revision: 273753
URL: https://svnweb.freebsd.org/changeset/base/273753

Log:
  iwcm_event status needs to be populated for close_complete_upcall
  
  Submitted by: Hariprasad at Chelsio dot com
  Sponsored by: Chelsio Communications

Modified:
  head/sys/dev/cxgbe/iw_cxgbe/cm.c

Modified: head/sys/dev/cxgbe/iw_cxgbe/cm.c
==
--- head/sys/dev/cxgbe/iw_cxgbe/cm.cMon Oct 27 23:03:17 2014
(r273752)
+++ head/sys/dev/cxgbe/iw_cxgbe/cm.cMon Oct 27 23:11:48 2014
(r273753)
@@ -94,7 +94,7 @@ static void abort_socket(struct c4iw_ep 
 static void send_mpa_req(struct c4iw_ep *ep);
 static int send_mpa_reject(struct c4iw_ep *ep, const void *pdata, u8 plen);
 static int send_mpa_reply(struct c4iw_ep *ep, const void *pdata, u8 plen);
-static void close_complete_upcall(struct c4iw_ep *ep);
+static void close_complete_upcall(struct c4iw_ep *ep, int status);
 static int abort_connection(struct c4iw_ep *ep);
 static void peer_close_upcall(struct c4iw_ep *ep);
 static void peer_abort_upcall(struct c4iw_ep *ep);
@@ -366,7 +366,7 @@ process_peer_close(struct c4iw_ep *ep)
C4IW_QP_ATTR_NEXT_STATE, 
&attrs, 1);
}
close_socket(&ep->com, 0);
-   close_complete_upcall(ep);
+   close_complete_upcall(ep, 0);
__state_set(&ep->com, DEAD);
release = 1;
disconnect = 0;
@@ -528,7 +528,7 @@ process_close_complete(struct c4iw_ep *e
CTR2(KTR_IW_CXGBE, "%s:pcc4 %p", __func__, ep);
close_socket(&ep->com, 0);
}
-   close_complete_upcall(ep);
+   close_complete_upcall(ep, 0);
__state_set(&ep->com, DEAD);
release = 1;
break;
@@ -1192,13 +1192,14 @@ static int send_mpa_reply(struct c4iw_ep
 
 
 
-static void close_complete_upcall(struct c4iw_ep *ep)
+static void close_complete_upcall(struct c4iw_ep *ep, int status)
 {
struct iw_cm_event event;
 
CTR2(KTR_IW_CXGBE, "%s:ccuB %p", __func__, ep);
memset(&event, 0, sizeof(event));
event.event = IW_CM_EVENT_CLOSE;
+   event.status = status;
 
if (ep->com.cm_id) {
 
@@ -1217,7 +1218,7 @@ static int abort_connection(struct c4iw_
int err;
 
CTR2(KTR_IW_CXGBE, "%s:abB %p", __func__, ep);
-   close_complete_upcall(ep);
+   close_complete_upcall(ep, -ECONNRESET);
state_set(&ep->com, ABORTING);
abort_socket(ep);
err = close_socket(&ep->com, 0);
@@ -2212,7 +2213,7 @@ int c4iw_ep_disconnect(struct c4iw_ep *e
 
CTR2(KTR_IW_CXGBE, "%s:ced1 %p", __func__, ep);
fatal = 1;
-   close_complete_upcall(ep);
+   close_complete_upcall(ep, -EIO);
ep->com.state = DEAD;
}
CTR3(KTR_IW_CXGBE, "%s:ced2 %p %s", __func__, ep,
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r273754 - head/usr.sbin/pkg

2014-10-27 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Mon Oct 27 23:19:51 2014
New Revision: 273754
URL: https://svnweb.freebsd.org/changeset/base/273754

Log:
  Use pkg-1.4-style platform identifiers based on MACHINE_ARCH (e.g.
  FreeBSD:11:amd64 instead of freebsd:11:x86:64) when bootstrapping pkg.
  Thanks to portmgr for providing symlinks so both styles work.
  
  Reviewed by:  bapt
  MFC after:3 weeks

Deleted:
  head/usr.sbin/pkg/elf_tables.h
Modified:
  head/usr.sbin/pkg/Makefile
  head/usr.sbin/pkg/config.c

Modified: head/usr.sbin/pkg/Makefile
==
--- head/usr.sbin/pkg/Makefile  Mon Oct 27 23:11:48 2014(r273753)
+++ head/usr.sbin/pkg/Makefile  Mon Oct 27 23:19:51 2014(r273754)
@@ -8,7 +8,7 @@ CFLAGS+=-I${.CURDIR}/../../contrib/libuc
 .PATH: ${.CURDIR}/../../contrib/libucl/include
 DPADD= ${LIBARCHIVE} ${LIBELF} ${LIBFETCH} ${LIBUCL} ${LIBSBUF} ${LIBSSL} \
${LIBCRYPTO} ${LIBM}
-LDADD= -larchive -lelf -lfetch ${LDUCL} -lsbuf -lssl -lcrypto -lm
+LDADD= -larchive -lfetch ${LDUCL} -lsbuf -lssl -lcrypto -lm
 USEPRIVATELIB= ucl
 
 .include 

Modified: head/usr.sbin/pkg/config.c
==
--- head/usr.sbin/pkg/config.c  Mon Oct 27 23:11:48 2014(r273753)
+++ head/usr.sbin/pkg/config.c  Mon Oct 27 23:19:51 2014(r273754)
@@ -31,9 +31,9 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
-#include 
-#include 
 #include 
+#include 
+#include 
 
 #include 
 #include 
@@ -42,14 +42,12 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
 #include 
 #include 
 
-#include "elf_tables.h"
 #include "config.h"
 
 #define roundup2(x, y) (((x)+((y)-1))&(~((y)-1))) /* if y is powers of two */
@@ -135,349 +133,32 @@ static struct config_entry c[] = {
},
 };
 
-static const char *
-elf_corres_to_string(struct _elf_corres *m, int e)
-{
-   int i;
-
-   for (i = 0; m[i].string != NULL; i++)
-   if (m[i].elf_nb == e)
-   return (m[i].string);
-
-   return ("unknown");
-}
-
-static const char *
-aeabi_parse_arm_attributes(void *data, size_t length) 
-{
-   uint32_t sect_len;
-   uint8_t *section = data;
-
-#defineMOVE(len) do {\
-   assert(length >= (len));  \
-   section += (len); \
-   length -= (len);  \
-} while (0)
-
-   if (length == 0 || *section != 'A')
-   return (NULL);
-
-   MOVE(1);
-
-   /* Read the section length */
-   if (length < sizeof(sect_len))
-   return (NULL);
-
-   memcpy(§_len, section, sizeof(sect_len));
-
-   /*
-* The section length should be no longer than the section it is within
-*/
-   if (sect_len > length)
-   return (NULL);
-
-   MOVE(sizeof(sect_len));
-
-   /* Skip the vendor name */
-   while (length != 0) {
-   if (*section == '\0')
-   break;
-   MOVE(1);
-   }
-   if (length == 0)
-   return (NULL);
-   MOVE(1);
-
-   while (length != 0) {
-   uint32_t tag_length;
-
-   switch(*section) {
-   case 1: /* Tag_File */
-   MOVE(1);
-   if (length < sizeof(tag_length))
-   return (NULL);
-   memcpy(&tag_length, section, sizeof(tag_length));
-   break;
-   case 2: /* Tag_Section */
-   case 3: /* Tag_Symbol */
-   default:
-   return (NULL);
-   }
-   /* At least space for the tag and size */
-   if (tag_length <= 5)
-   return (NULL);
-   tag_length--;
-   /* Check the tag fits */
-   if (tag_length > length)
-   return (NULL);
-
-#define  MOVE_TAG(len) do {   \
-   assert(tag_length >= (len));  \
-   MOVE(len);\
-   tag_length -= (len);  \
-} while(0)
-
-   MOVE(sizeof(tag_length));
-   tag_length -= sizeof(tag_length);
-
-   while (tag_length != 0) {
-   uint8_t tag;
-
-   assert(tag_length >= length);
-
-   tag = *section;
-   MOVE_TAG(1);
-
-   /*
-* These tag values come from:
-* 
-* Addenda to, and Errata in, the ABI for the
-* ARM Architecture. Release 2.08, section 2.3.
-*/
-   if (tag == 6) { /* == Tag_CPU_arch */
-   uint8_t val;
-
-   val = *section;
-   /*
-* We don't support values that require
-* more than one byte.
-*/
-  

svn commit: r273755 - head

2014-10-27 Thread Baptiste Daroussin
Author: bapt
Date: Mon Oct 27 23:31:07 2014
New Revision: 273755
URL: https://svnweb.freebsd.org/changeset/base/273755

Log:
  Rename XFLAGS to XCFLAGS and XXFLAGS to XCXXFLAGS
  
  This is less confusing names and actually more reflexting what they are 
intended
  to.
  
  Discussed with:   brooks

Modified:
  head/Makefile.inc1

Modified: head/Makefile.inc1
==
--- head/Makefile.inc1  Mon Oct 27 23:19:51 2014(r273754)
+++ head/Makefile.inc1  Mon Oct 27 23:31:07 2014(r273755)
@@ -323,9 +323,9 @@ X${BINUTIL}?=   ${CROSS_BINUTILS_PREFIX}${
 X${BINUTIL}?=  ${${BINUTIL}}
 .endif
 .endfor
-WMAKEENV+= CC="${XCC} ${XFLAGS}" CXX="${XCXX} ${XFLAGS} ${XXFLAGS}" \
+WMAKEENV+= CC="${XCC} ${XCFLAGS}" CXX="${XCXX} ${XCFLAGS} ${XCXXFLAGS}" \
DEPFLAGS="${DEPFLAGS}" \
-   CPP="${XCPP} ${XFLAGS}" \
+   CPP="${XCPP} ${XCFLAGS}" \
AS="${XAS}" AR="${XAR}" LD="${XLD}" NM=${XNM} \
OBJDUMP=${XOBJDUMP} OBJCOPY="${XOBJCOPY}" \
RANLIB=${XRANLIB} STRINGS=${XSTRINGS} \
@@ -351,13 +351,13 @@ TARGET_ABI=   gnueabi
 .endif
 .endif
 .if defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc
-XFLAGS+=   -isystem ${WORLDTMP}/usr/include -L${WORLDTMP}/usr/lib
-XXFLAGS+=  -I${WORLDTMP}/usr/include/c++/v1 -std=gnu++11 
-L${WORLDTMP}/../lib/libc++
+XCFLAGS+=  -isystem ${WORLDTMP}/usr/include -L${WORLDTMP}/usr/lib
+XCXXFLAGS+=-I${WORLDTMP}/usr/include/c++/v1 -std=gnu++11 
-L${WORLDTMP}/../lib/libc++
 DEPFLAGS+= -I${WORLDTMP}/usr/include/c++/v1
 .else
 TARGET_ABI?=   unknown
 TARGET_TRIPLE?=${TARGET_ARCH:C/amd64/x86_64/}-${TARGET_ABI}-freebsd11.0
-XFLAGS+=   -target ${TARGET_TRIPLE}
+XCFLAGS+=  -target ${TARGET_TRIPLE}
 .endif
 .endif
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r273756 - in head/lib: libusb libz

2014-10-27 Thread John-Mark Gurney
Author: jmg
Date: Mon Oct 27 23:43:25 2014
New Revision: 273756
URL: https://svnweb.freebsd.org/changeset/base/273756

Log:
  only install .pc files when we are not installing 32bit compat libs...
  
  This fixes the problem of installing the .pc files multiple times...

Modified:
  head/lib/libusb/Makefile
  head/lib/libz/Makefile

Modified: head/lib/libusb/Makefile
==
--- head/lib/libusb/MakefileMon Oct 27 23:31:07 2014(r273755)
+++ head/lib/libusb/MakefileMon Oct 27 23:43:25 2014(r273756)
@@ -38,6 +38,7 @@ SRCS+=libusb10_io.c
 CFLAGS+=   -DCOMPAT_32BIT
 .endif
 
+.ifndef COMPAT_32BIT
 beforeinstall:
${INSTALL} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
${.CURDIR}/libusb-0.1.pc ${DESTDIR}${LIBDATADIR}/pkgconfig
@@ -45,6 +46,7 @@ beforeinstall:
${.CURDIR}/libusb-1.0.pc ${DESTDIR}${LIBDATADIR}/pkgconfig
${INSTALL} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
${.CURDIR}/libusb-2.0.pc ${DESTDIR}${LIBDATADIR}/pkgconfig
+.endif
 
 #
 # Cross platform support

Modified: head/lib/libz/Makefile
==
--- head/lib/libz/Makefile  Mon Oct 27 23:31:07 2014(r273755)
+++ head/lib/libz/Makefile  Mon Oct 27 23:43:25 2014(r273756)
@@ -68,9 +68,11 @@ test: example minigzip
(export LD_LIBRARY_PATH=. ; \
echo hello world | ./minigzip | ./minigzip -d )
 
+.ifndef COMPAT_32BIT
 beforeinstall:
${INSTALL} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
${.CURDIR}/zlib.pc ${DESTDIR}${LIBDATADIR}/pkgconfig
+.endif
 
 .include 
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r273756 - in head/lib: libusb libz

2014-10-27 Thread Baptiste Daroussin
On Mon, Oct 27, 2014 at 11:43:25PM +, John-Mark Gurney wrote:
> Author: jmg
> Date: Mon Oct 27 23:43:25 2014
> New Revision: 273756
> URL: https://svnweb.freebsd.org/changeset/base/273756
> 
> Log:
>   only install .pc files when we are not installing 32bit compat libs...
>   
>   This fixes the problem of installing the .pc files multiple times...
> 
May be we should start having an infrastructure to work with .pc files because
we will add more of them I do have in mind at least libarchive so far

regards,
Bapt


pgpt14mMMmHTf.pgp
Description: PGP signature


Re: svn commit: r273755 - head

2014-10-27 Thread NGie Cooper
On Mon, Oct 27, 2014 at 4:31 PM, Baptiste Daroussin  wrote:
> Author: bapt
> Date: Mon Oct 27 23:31:07 2014
> New Revision: 273755
> URL: https://svnweb.freebsd.org/changeset/base/273755
>
> Log:
>   Rename XFLAGS to XCFLAGS and XXFLAGS to XCXXFLAGS
>
>   This is less confusing names and actually more reflexting what they are 
> intended
>   to.
>
>   Discussed with:   brooks

Add an UPDATING entry?
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r273759 - head/sys/powerpc/conf

2014-10-27 Thread Justin Hibbits
Author: jhibbits
Date: Tue Oct 28 01:34:01 2014
New Revision: 273759
URL: https://svnweb.freebsd.org/changeset/base/273759

Log:
  Add CAPABILITIES and CAPABILITY_MODE to powerpc GENERIC64, missed with the 
addition to
  GENERIC
  
  MFC after:3 weeks

Modified:
  head/sys/powerpc/conf/GENERIC64

Modified: head/sys/powerpc/conf/GENERIC64
==
--- head/sys/powerpc/conf/GENERIC64 Tue Oct 28 00:44:20 2014
(r273758)
+++ head/sys/powerpc/conf/GENERIC64 Tue Oct 28 01:34:01 2014
(r273759)
@@ -70,6 +70,8 @@ options   SYSVSEM #SYSV-style semaphore
 options_KPOSIX_PRIORITY_SCHEDULING #Posix P1003_1B real-time extensions
 optionsHWPMC_HOOKS # Necessary kernel hooks for hwpmc(4)
 optionsAUDIT   # Security event auditing
+optionsCAPABILITY_MODE # Capsicum capability mode
+optionsCAPABILITIES# Capsicum capabilities
 optionsMAC # TrustedBSD MAC Framework
 optionsKDTRACE_HOOKS   # Kernel DTrace hooks
 optionsDDB_CTF # Kernel ELF linker loads CTF data
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r273760 - head/lib/libc/stdio

2014-10-27 Thread Kevin Lo
Author: kevlo
Date: Tue Oct 28 02:05:57 2014
New Revision: 273760
URL: https://svnweb.freebsd.org/changeset/base/273760

Log:
  Fix prototypes.

Modified:
  head/lib/libc/stdio/open_memstream.3

Modified: head/lib/libc/stdio/open_memstream.3
==
--- head/lib/libc/stdio/open_memstream.3Tue Oct 28 01:34:01 2014
(r273759)
+++ head/lib/libc/stdio/open_memstream.3Tue Oct 28 02:05:57 2014
(r273760)
@@ -25,7 +25,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd February 27, 2013
+.Dd October 28, 2014
 .Dt OPEN_MEMSTREAM 3
 .Os
 .Sh NAME
@@ -37,10 +37,10 @@
 .Sh SYNOPSIS
 .In stdio.h
 .Ft FILE *
-.Fn open_memstream "char **bufp" "size_t **sizep"
+.Fn open_memstream "char **bufp" "size_t *sizep"
 .In wchar.h
 .Ft FILE *
-.Fn open_wmemstream "wchar_t **bufp" "size_t **sizep"
+.Fn open_wmemstream "wchar_t **bufp" "size_t *sizep"
 .Sh DESCRIPTION
 The
 .Fn open_memstream
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r273214 - in head/sys: amd64/vmm/intel modules/vmm

2014-10-27 Thread Warner Losh

On Oct 27, 2014, at 1:18 PM, John Baldwin  wrote:

> On Monday, October 27, 2014 11:36:41 AM Warner Losh wrote:
>> On Oct 27, 2014, at 10:54 AM, John Baldwin  wrote:
>>> On Friday, October 17, 2014 01:20:50 PM Warner Losh wrote:
 Author: imp
 Date: Fri Oct 17 13:20:49 2014
 New Revision: 273214
 URL: https://svnweb.freebsd.org/changeset/base/273214
 
 Log:
 Fix build to not bogusly always rebuild vmm.ko.
 
 Rename vmx_assym.s to vmx_assym.h to reflect that file's actual use
 and update vmx_support.S's include to match. Add vmx_assym.h to the
 SRCS to that it gets properly added to the dependency list. Add
 vmx_support.S to SRCS as well, so it gets built and needs fewer
 special-case goo. Remove now-redundant special-case goo. Finally,
 vmx_genassym.o doesn't need to depend on a hand expanded ${_ILINKS}
 explicitly, that's all taken care of by beforedepend.
 
 With these items fixed, we no longer build vmm.ko every single time
 through the modules on a KERNFAST build.
>>> 
>>> So I cheered for this before, but it appears to be broken. :(
>>> 
>>> Namely, I rebuilt world + kernel on my laptop this weekend (it was about a
>>> month old).  My normal setup builds kernels with NO_KERNELCLEAN=yes.  On my
>>> next reboot when I started a bhyve VM I promptly got a panic due to a page
>>> 
>>> fault in this assembly code:
>>> /*
>>> 
>>>  * If 'vmx->eptgen[curcpu]' is not identical to 'pmap->pm_eptgen'
>>>  * then we must invalidate all mappings associated with this EPTP.
>>>  */
>>> 
>>> movqPM_EPTGEN(%r11), %r10
>>> cmpq%r10, VMX_EPTGEN(%rsi, %rax, 8)
>>> je  guest_restore
>>> 
>>> (The 'cmpq' instruction)
>>> 
>>> This change came to mind, so I blew away the 'vmm' module directory and
>>> rebuilt my kernel.  Comparing the assembly of this instruction before and
>>> after used different values for VMX_EPTGEN.  In other words, the
>>> NO_KERNELCLEAN=yes build failed to regenerate vmx_assym.h and the build
>>> used stale values.
>> 
>> Is there a way to force this condition for testing?
> 
> You could checkout an older tree (probably before the recent merge of AMD SVM
> support) and build vmm.ko, then svn update and see if vmx_assym and
> vmx_support.o are updated.
> 
> Actually, this was simpler:
> 
> % cd sys/modules/vmm
> % make depend
> % make vmx_assym.h  # reports nothing to do
> % touch machine/vmm.h  # vmx_genassym.c includes this
> % make vmx_assym.h  # should rebuild, but doesn’t

Thanks!

>>> In particular, if you examine the generated .depend file, you will find
>>> that there are no dependencies recorded for vmx_genassym.o, so it is
>>> never rebuilt if any of the headers it includes are changed.  In my case
>>> the panic happened to be one that was easily diagnosed, but I could
>>> imagine stale assym headers causing very odd crashes that would be quite
>>> hard to track down.  I think these changes should be reverted if we can't
>>> fix the dependencies of the associated object files they are generated
>>> from. :(
>> 
>> Give me a bit and I’ll fix it. There’s a number of implicit dependencies
>> that don’t get recorded in the .depend file, iirc, so that’s not completely
>> conclusive. Not building, though is kinda a big hint that something’s
>> amiss.
> 
> I think the thing here is that for the assym files we don't record any
> dependency info at all.  The main kernel build does record dependencies
> for genassym.o in .depend, so it must be doable.

True.

> In kern.pre.mk:
> 
> GEN_CFILES= $S/$M/$M/genassym.c ${MFILES:T:S/.m$/.c/}
> 
> and those are then explicitly passed to mkdep in kern.post.mk.
> 
> So this fixes it:
> 
> Index: Makefile
> ===
> --- Makefile  (revision 273555)
> +++ Makefile  (working copy)
> @@ -4,6 +4,7 @@ KMOD= vmm
> 
> SRCS= opt_acpi.h opt_ddb.h device_if.h bus_if.h pci_if.h
> SRCS+=vmx_assym.h svm_assym.h
> +DPSRCS=  vmx_genassym.c svm_genassym.c

That’s the magic I was looking for...

> CFLAGS+= -DVMM_KEEP_STATS -DSMP
> CFLAGS+= -I${.CURDIR}/../../amd64/vmm
> 
> I'll try to track down all the other assym files and fix them as well.

Cool. There’s three more (but I had only fixed two of them, since I didn’t have 
a i386 build handy).

>> However, -DNO_CLEAN has always been a very-sharp edged tool that will cut
>> you in a number of ways, so there’s no rush to back this out.
> 
> This is the first time in many years that NO_KERNELCLEAN=yes has been a
> problem for me.  (worlds sometimes have issues, but kernels rarely do).
> Also, usually when it breaks it fails to compile, it doesn't compile and
> then panic. :(

But it is current… :)

Warner



signature.asc
Description: Message signed with OpenPGP using GPGMail


svn commit: r273761 - head/sys/dev/uart

2014-10-27 Thread Marcelo Araujo
Author: araujo (ports committer)
Date: Tue Oct 28 03:42:09 2014
New Revision: 273761
URL: https://svnweb.freebsd.org/changeset/base/273761

Log:
  Drop __DECONST as well as few fixes of style(9).
  
  Phabric:  D1012
  Suggested by: mjg, jhb
  Reviewed by:  mjg, jhb
  Sponsored by: QNAP Systems Inc.

Modified:
  head/sys/dev/uart/uart_subr.c

Modified: head/sys/dev/uart/uart_subr.c
==
--- head/sys/dev/uart/uart_subr.c   Tue Oct 28 02:05:57 2014
(r273760)
+++ head/sys/dev/uart/uart_subr.c   Tue Oct 28 03:42:09 2014
(r273761)
@@ -196,7 +196,8 @@ out:
 int
 uart_getenv(int devtype, struct uart_devinfo *di, struct uart_class *class)
 {
-   const char *cp, *spec;
+   const char *spec;
+   char *cp;
bus_addr_t addr = ~0U;
int error;
 
@@ -213,12 +214,18 @@ uart_getenv(int devtype, struct uart_dev
 * which UART port is to be used as serial console or debug
 * port (resp).
 */
-   if (devtype == UART_DEV_CONSOLE)
+   switch (devtype) {
+   case UART_DEV_CONSOLE:
cp = kern_getenv("hw.uart.console");
-   else if (devtype == UART_DEV_DBGPORT)
+   break;
+   case UART_DEV_DBGPORT:
cp = kern_getenv("hw.uart.dbgport");
-   else
+   break;
+   default:
cp = NULL;
+   break;
+   }
+
if (cp == NULL)
return (ENXIO);
 
@@ -233,7 +240,7 @@ uart_getenv(int devtype, struct uart_dev
 
/* Parse the attributes. */
spec = cp;
-   while (1) {
+   for (;;) {
switch (uart_parse_tag(&spec)) {
case UART_TAG_BR:
di->baudrate = uart_parse_long(&spec);
@@ -268,18 +275,18 @@ uart_getenv(int devtype, struct uart_dev
di->bas.rclk = uart_parse_long(&spec);
break;
default:
-   freeenv(__DECONST(char *, cp));
+   freeenv(cp);
return (EINVAL);
}
if (*spec == '\0')
break;
if (*spec != ',') {
-   freeenv(__DECONST(char *, cp));
+   freeenv(cp);
return (EINVAL);
}
spec++;
}
-   freeenv(__DECONST(char *, cp));
+   freeenv(cp);
 
/*
 * If we still have an invalid address, the specification must be
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r273576 - head/sys/dev/uart

2014-10-27 Thread Marcelo Araujo
Done: https://svnweb.freebsd.org/base?view=revision&revision=273761

Thank you guys

2014-10-25 0:14 GMT+08:00 John Baldwin :

> On Friday, October 24, 2014 05:39:32 AM Marcelo Araujo wrote:
> > Author: araujo (ports committer)
> > Date: Fri Oct 24 05:39:32 2014
> > New Revision: 273576
> > URL: https://svnweb.freebsd.org/changeset/base/273576
> >
> > Log:
> >   Fix a leaked Storage Variable.
> >
> >   Phabric:D981
> >   Submitted by:   myself
> >   Reported by:Coverity
> >   CID:1248848
> >   Reworked by:kevlo
> >   Reviewed by:marcel, davide, ray, kevlo
> >   Approved by:marcel, kevlo
> >
> > Modified:
> >   head/sys/dev/uart/uart_subr.c
> >
> > Modified: head/sys/dev/uart/uart_subr.c
> >
> ==
> > --- head/sys/dev/uart/uart_subr.c Fri Oct 24 04:01:14 2014
> (r273575)
> > +++ head/sys/dev/uart/uart_subr.c Fri Oct 24 05:39:32 2014
> (r273576)
> > @@ -196,7 +196,7 @@ out:
> >  int
> >  uart_getenv(int devtype, struct uart_devinfo *di, struct uart_class
> *class)
> > {
> > - const char *spec;
> > + const char *cp, *spec;
>
> Dropping const here is preferable to using __DECONST() for the freeenv()
> calls.
>
> --
> John Baldwin
>



-- 

-- 
Marcelo Araujo(__)ara...@freebsd.org
\\\'',)http://www.FreeBSD.org    \/  \ ^
Power To Server. .\. /_)
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r273762 - head/sys/modules/dtrace/dtraceall

2014-10-27 Thread Julian Elischer
Author: julian
Date: Tue Oct 28 04:18:09 2014
New Revision: 273762
URL: https://svnweb.freebsd.org/changeset/base/273762

Log:
  Allow loading of dtraceall without nfscl if what you really wnat is nfsclient
  
  Obtained from:Panzura tree
  MFC after:1 week

Modified:
  head/sys/modules/dtrace/dtraceall/dtraceall.c

Modified: head/sys/modules/dtrace/dtraceall/dtraceall.c
==
--- head/sys/modules/dtrace/dtraceall/dtraceall.c   Tue Oct 28 03:42:09 
2014(r273761)
+++ head/sys/modules/dtrace/dtraceall/dtraceall.c   Tue Oct 28 04:18:09 
2014(r273762)
@@ -67,7 +67,9 @@ MODULE_DEPEND(dtraceall, cyclic, 1, 1, 1
 MODULE_DEPEND(dtraceall, opensolaris, 1, 1, 1);
 MODULE_DEPEND(dtraceall, dtrace, 1, 1, 1);
 MODULE_DEPEND(dtraceall, dtmalloc, 1, 1, 1);
+#if defined(NFSCLIENT)
 MODULE_DEPEND(dtraceall, dtnfscl, 1, 1, 1);
+#endif
 #if defined(NFSCLIENT)
 MODULE_DEPEND(dtraceall, dtnfsclient, 1, 1, 1);
 #endif
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r273763 - head/sys/kern

2014-10-27 Thread Mateusz Guzik
Author: mjg
Date: Tue Oct 28 04:33:57 2014
New Revision: 273763
URL: https://svnweb.freebsd.org/changeset/base/273763

Log:
  Change loginclass mutex to an rwlock.
  
  While here reduce nesting in loginclass_free.
  
  Submitted by: Tiwei Bie 
  X-Additional: JuniorJobs project
  MFC after:2 weeks

Modified:
  head/sys/kern/kern_loginclass.c

Modified: head/sys/kern/kern_loginclass.c
==
--- head/sys/kern/kern_loginclass.c Tue Oct 28 04:18:09 2014
(r273762)
+++ head/sys/kern/kern_loginclass.c Tue Oct 28 04:33:57 2014
(r273763)
@@ -51,13 +51,13 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -68,8 +68,8 @@ LIST_HEAD(, loginclass)   loginclasses;
 /*
  * Lock protecting loginclasses list.
  */
-static struct mtx loginclasses_lock;
-MTX_SYSINIT(loginclasses_init, &loginclasses_lock, "loginclasses lock", 
MTX_DEF);
+static struct rwlock loginclasses_lock;
+RW_SYSINIT(loginclasses_init, &loginclasses_lock, "loginclasses lock");
 
 void
 loginclass_hold(struct loginclass *lc)
@@ -87,16 +87,37 @@ loginclass_free(struct loginclass *lc)
if (old > 1 && atomic_cmpset_int(&lc->lc_refcount, old, old - 1))
return;
 
-   mtx_lock(&loginclasses_lock);
-   if (refcount_release(&lc->lc_refcount)) {
-   racct_destroy(&lc->lc_racct);
-   LIST_REMOVE(lc, lc_next);
-   mtx_unlock(&loginclasses_lock);
-   free(lc, M_LOGINCLASS);
-
+   rw_wlock(&loginclasses_lock);
+   if (!refcount_release(&lc->lc_refcount)) {
+   rw_wunlock(&loginclasses_lock);
return;
}
-   mtx_unlock(&loginclasses_lock);
+
+   racct_destroy(&lc->lc_racct);
+   LIST_REMOVE(lc, lc_next);
+   rw_wunlock(&loginclasses_lock);
+
+   free(lc, M_LOGINCLASS);
+}
+
+/*
+ * Look up a loginclass struct for the parameter name.
+ * loginclasses_lock must be locked.
+ * Increase refcount on loginclass struct returned.
+ */
+static struct loginclass *
+loginclass_lookup(const char *name)
+{
+   struct loginclass *lc;
+
+   rw_assert(&loginclasses_lock, RA_LOCKED);
+   LIST_FOREACH(lc, &loginclasses, lc_next)
+   if (strcmp(name, lc->lc_name) == 0) {
+   loginclass_hold(lc);
+   break;
+   }
+
+   return (lc);
 }
 
 /*
@@ -109,34 +130,39 @@ loginclass_free(struct loginclass *lc)
 struct loginclass *
 loginclass_find(const char *name)
 {
-   struct loginclass *lc, *newlc;
+   struct loginclass *lc, *new_lc;
 
if (name[0] == '\0' || strlen(name) >= MAXLOGNAME)
return (NULL);
 
-   newlc = malloc(sizeof(*newlc), M_LOGINCLASS, M_ZERO | M_WAITOK);
-   racct_create(&newlc->lc_racct);
-
-   mtx_lock(&loginclasses_lock);
-   LIST_FOREACH(lc, &loginclasses, lc_next) {
-   if (strcmp(name, lc->lc_name) != 0)
-   continue;
-
-   /* Found loginclass with a matching name? */
-   loginclass_hold(lc);
-   mtx_unlock(&loginclasses_lock);
-   racct_destroy(&newlc->lc_racct);
-   free(newlc, M_LOGINCLASS);
+   rw_rlock(&loginclasses_lock);
+   lc = loginclass_lookup(name);
+   rw_runlock(&loginclasses_lock);
+   if (lc != NULL)
return (lc);
-   }
 
-   /* Add new loginclass. */
-   strcpy(newlc->lc_name, name);
-   refcount_init(&newlc->lc_refcount, 1);
-   LIST_INSERT_HEAD(&loginclasses, newlc, lc_next);
-   mtx_unlock(&loginclasses_lock);
+   new_lc = malloc(sizeof(*new_lc), M_LOGINCLASS, M_ZERO | M_WAITOK);
+   racct_create(&new_lc->lc_racct);
+   refcount_init(&new_lc->lc_refcount, 1);
+   strcpy(new_lc->lc_name, name);
+
+   rw_wlock(&loginclasses_lock);
+   /*
+* There's a chance someone created our loginclass while we
+* were in malloc and not holding the lock, so we have to
+* make sure we don't insert a duplicate loginclass.
+*/
+   if ((lc = loginclass_lookup(name)) == NULL) {
+   LIST_INSERT_HEAD(&loginclasses, new_lc, lc_next);
+   rw_wunlock(&loginclasses_lock);
+   lc = new_lc;
+   } else {
+   rw_wunlock(&loginclasses_lock);
+   racct_destroy(&new_lc->lc_racct);
+   free(new_lc, M_LOGINCLASS);
+   }
 
-   return (newlc);
+   return (lc);
 }
 
 /*
@@ -222,8 +248,8 @@ loginclass_racct_foreach(void (*callback
 {
struct loginclass *lc;
 
-   mtx_lock(&loginclasses_lock);
+   rw_rlock(&loginclasses_lock);
LIST_FOREACH(lc, &loginclasses, lc_next)
(callback)(lc->lc_racct, arg2, arg3);
-   mtx_unlock(&loginclasses_lock);
+   rw_runlock(&loginclasses_loc

svn commit: r273764 - head/sys/kern

2014-10-27 Thread Mateusz Guzik
Author: mjg
Date: Tue Oct 28 04:59:33 2014
New Revision: 273764
URL: https://svnweb.freebsd.org/changeset/base/273764

Log:
  Simplify sys_getloginclass.
  
  Just use current thread credentials as they have the same accuracy as the
  ones obtained from proc..

Modified:
  head/sys/kern/kern_loginclass.c

Modified: head/sys/kern/kern_loginclass.c
==
--- head/sys/kern/kern_loginclass.c Tue Oct 28 04:33:57 2014
(r273763)
+++ head/sys/kern/kern_loginclass.c Tue Oct 28 04:59:33 2014
(r273764)
@@ -178,24 +178,14 @@ struct getloginclass_args {
 int
 sys_getloginclass(struct thread *td, struct getloginclass_args *uap)
 {
-   int error = 0;
-   size_t lcnamelen;
-   struct proc *p;
struct loginclass *lc;
+   size_t lcnamelen;
 
-   p = td->td_proc;
-   PROC_LOCK(p);
-   lc = p->p_ucred->cr_loginclass;
-   loginclass_hold(lc);
-   PROC_UNLOCK(p);
-
+   lc = td->td_ucred->cr_loginclass;
lcnamelen = strlen(lc->lc_name) + 1;
if (lcnamelen > uap->namelen)
-   error = ERANGE;
-   if (error == 0)
-   error = copyout(lc->lc_name, uap->namebuf, lcnamelen);
-   loginclass_free(lc);
-   return (error);
+   return (ERANGE);
+   return (copyout(lc->lc_name, uap->namebuf, lcnamelen));
 }
 
 /*
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r273762 - head/sys/modules/dtrace/dtraceall

2014-10-27 Thread John-Mark Gurney
Julian Elischer wrote this message on Tue, Oct 28, 2014 at 04:18 +:
> Author: julian
> Date: Tue Oct 28 04:18:09 2014
> New Revision: 273762
> URL: https://svnweb.freebsd.org/changeset/base/273762
> 
> Log:
>   Allow loading of dtraceall without nfscl if what you really wnat is 
> nfsclient
>   
>   Obtained from:  Panzura tree
>   MFC after:  1 week
> 
> Modified:
>   head/sys/modules/dtrace/dtraceall/dtraceall.c
> 
> Modified: head/sys/modules/dtrace/dtraceall/dtraceall.c
> ==
> --- head/sys/modules/dtrace/dtraceall/dtraceall.c Tue Oct 28 03:42:09 
> 2014(r273761)
> +++ head/sys/modules/dtrace/dtraceall/dtraceall.c Tue Oct 28 04:18:09 
> 2014(r273762)
> @@ -67,7 +67,9 @@ MODULE_DEPEND(dtraceall, cyclic, 1, 1, 1
>  MODULE_DEPEND(dtraceall, opensolaris, 1, 1, 1);
>  MODULE_DEPEND(dtraceall, dtrace, 1, 1, 1);
>  MODULE_DEPEND(dtraceall, dtmalloc, 1, 1, 1);
> +#if defined(NFSCLIENT)
>  MODULE_DEPEND(dtraceall, dtnfscl, 1, 1, 1);
> +#endif
>  #if defined(NFSCLIENT)
>  MODULE_DEPEND(dtraceall, dtnfsclient, 1, 1, 1);
>  #endif

Why not put the MODULE_DEPEND in the same #if defined block that follows?

-- 
  John-Mark Gurney  Voice: +1 415 225 5579

 "All that I will do, has been done, All that I have, has not."
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r273755 - head

2014-10-27 Thread Baptiste Daroussin
On Mon, Oct 27, 2014 at 05:26:42PM -0700, NGie Cooper wrote:
> On Mon, Oct 27, 2014 at 4:31 PM, Baptiste Daroussin  wrote:
> > Author: bapt
> > Date: Mon Oct 27 23:31:07 2014
> > New Revision: 273755
> > URL: https://svnweb.freebsd.org/changeset/base/273755
> >
> > Log:
> >   Rename XFLAGS to XCFLAGS and XXFLAGS to XCXXFLAGS
> >
> >   This is less confusing names and actually more reflexting what they are 
> > intended
> >   to.
> >
> >   Discussed with:   brooks
> 
> Add an UPDATING entry?

Well XCFLAGS and XCXXFLAGS are inernal only and concerning a feature (external
toolchain) which is still WIP so it is worth adding an UPDATING entry?

regards,
Bapt


pgpzF2lyy2wla.pgp
Description: PGP signature