Re: svn commit: r323329 - head/sys/sys

2017-09-08 Thread Bruce Evans

On Fri, 8 Sep 2017, Ngie Cooper (yaneurabeya) wrote:


On Sep 8, 2017, at 13:09, Mateusz Guzik  wrote:
...
Log:
 Allow __builtin_memset instead of bzero for small buffers of known size


This change breaks all platforms that use gcc. If it???s not reverted in the 
next 3 hours, I???ll revert it.


Not all.  It works for me.  My version of it is 15-20 years old and never
always worked on old versions of FreeBSD

The problem seems to be with inlining parameters.  These are fairly broken
by default in gcc-4.2.1, and the overrides in kern/pre.mk only work in some
cases.  -Os is completely broken (with the overrides, it at best gives a
20% pessimization for space, and with other overrides inlining tends to
fail).  I recently found a workaround: compile with -fno-inline-functions.
So my full compiler flags are CONF_CFLAGS=[-march=i386] -Os
-fno-inline-functions -fno-inline-functions-called-once.  This should
reduce problems with inlining.  However, kernels still build with the
bad default flags of -O2.


Please fix ASAP if possible: 
https://ci.freebsd.org/job/FreeBSD-head-riscv64-build/3668/console .


This also shows problems with uninitialized variables.  But
-Wno-uninitialized is the default for gcc-4.2.1.  This breaks lots of
warnings Maybe you have different nonstandard options to avoid the
breakage.

-Wno-uninitialized is set in kern.mk, and also in kern.pre.mk for cddl.
(CDDL_CFLAGS apparerently gives a dumbed down subset of CWARNFLAGS to
break many more warnings.)  There is a problem getting flags passed
to all Makefiles.  CONF_CFLAGS (and all other makeoptions in config
files) is broken for modules (since macros in the kernel Makefile are
not inherited).  This feature prevents me using modules even if I
forget I don't like them.  Flags in kern.mk are only broken for boot
Makefiles which neglect to include kern.mk (that is, for all current
boot Makefiles).

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

svn commit: r323350 - head/sys/ofed/drivers/infiniband/core

2017-09-08 Thread Hans Petter Selasky
Author: hselasky
Date: Sat Sep  9 06:34:20 2017
New Revision: 323350
URL: https://svnweb.freebsd.org/changeset/base/323350

Log:
  Remove unsafe access to the LinuxKPI file structure from ibcore.
  selwakeup() is now done by the wake_up() family of functions.
  
  MFC after:1 week
  Sponsored by: Mellanox Technologies

Modified:
  head/sys/ofed/drivers/infiniband/core/ucm.c
  head/sys/ofed/drivers/infiniband/core/ucma.c
  head/sys/ofed/drivers/infiniband/core/user_mad.c
  head/sys/ofed/drivers/infiniband/core/uverbs_main.c

Modified: head/sys/ofed/drivers/infiniband/core/ucm.c
==
--- head/sys/ofed/drivers/infiniband/core/ucm.c Sat Sep  9 06:29:29 2017
(r323349)
+++ head/sys/ofed/drivers/infiniband/core/ucm.c Sat Sep  9 06:34:20 2017
(r323350)
@@ -378,8 +378,6 @@ static int ib_ucm_event_handler(struct ib_cm_id *cm_id
list_add_tail(&uevent->file_list, &ctx->file->events);
list_add_tail(&uevent->ctx_list, &ctx->events);
wake_up_interruptible(&ctx->file->poll_wait);
-   if (ctx->file->filp)
-   selwakeup(&ctx->file->filp->f_selinfo);
mutex_unlock(&ctx->file->file_mutex);
return 0;
 

Modified: head/sys/ofed/drivers/infiniband/core/ucma.c
==
--- head/sys/ofed/drivers/infiniband/core/ucma.cSat Sep  9 06:29:29 
2017(r323349)
+++ head/sys/ofed/drivers/infiniband/core/ucma.cSat Sep  9 06:34:20 
2017(r323350)
@@ -287,8 +287,6 @@ static int ucma_event_handler(struct rdma_cm_id *cm_id
 
list_add_tail(&uevent->list, &ctx->file->event_list);
wake_up_interruptible(&ctx->file->poll_wait);
-   if (ctx->file->filp)
-   selwakeup(&ctx->file->filp->f_selinfo);
 out:
mutex_unlock(&ctx->file->mut);
return ret;

Modified: head/sys/ofed/drivers/infiniband/core/user_mad.c
==
--- head/sys/ofed/drivers/infiniband/core/user_mad.cSat Sep  9 06:29:29 
2017(r323349)
+++ head/sys/ofed/drivers/infiniband/core/user_mad.cSat Sep  9 06:34:20 
2017(r323350)
@@ -236,7 +236,6 @@ static int queue_packet(struct ib_umad_file *file,
 packet->mad.hdr.id++)
if (agent == __get_agent(file, packet->mad.hdr.id)) {
list_add_tail(&packet->list, &file->recv_list);
-   selwakeup(&file->filp->f_selinfo);
wake_up_interruptible(&file->recv_wait);
ret = 0;
break;

Modified: head/sys/ofed/drivers/infiniband/core/uverbs_main.c
==
--- head/sys/ofed/drivers/infiniband/core/uverbs_main.c Sat Sep  9 06:29:29 
2017(r323349)
+++ head/sys/ofed/drivers/infiniband/core/uverbs_main.c Sat Sep  9 06:34:20 
2017(r323350)
@@ -519,8 +519,6 @@ void ib_uverbs_comp_handler(struct ib_cq *cq, void *cq
spin_unlock_irqrestore(&file->lock, flags);
 
wake_up_interruptible(&file->poll_wait);
-   if (file->filp)
-   selwakeup(&file->filp->f_selinfo);
kill_fasync(&file->async_queue, SIGIO, POLL_IN);
 }
 
@@ -554,8 +552,6 @@ static void ib_uverbs_async_handler(struct ib_uverbs_f
spin_unlock_irqrestore(&file->async_file->lock, flags);
 
wake_up_interruptible(&file->async_file->poll_wait);
-   if (file->async_file->filp)
-   selwakeup(&file->async_file->filp->f_selinfo);
kill_fasync(&file->async_file->async_queue, SIGIO, POLL_IN);
 }
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r323349 - in head/sys: compat/linuxkpi/common/include/linux compat/linuxkpi/common/src sys

2017-09-08 Thread Hans Petter Selasky
Author: hselasky
Date: Sat Sep  9 06:29:29 2017
New Revision: 323349
URL: https://svnweb.freebsd.org/changeset/base/323349

Log:
  Properly implement poll_wait() in the LinuxKPI. This prevents direct
  use of the linux_poll_wakeup() function from unsafe contexts, which
  can lead to use-after-free issues.
  
  Instead of calling linux_poll_wakeup() directly use the wake_up()
  family of functions in the LinuxKPI to do this.
  
  Bump the FreeBSD version to force recompilation of external kernel modules.
  
  MFC after:1 week
  Sponsored by: Mellanox Technologies

Modified:
  head/sys/compat/linuxkpi/common/include/linux/fs.h
  head/sys/compat/linuxkpi/common/include/linux/poll.h
  head/sys/compat/linuxkpi/common/src/linux_compat.c
  head/sys/sys/param.h

Modified: head/sys/compat/linuxkpi/common/include/linux/fs.h
==
--- head/sys/compat/linuxkpi/common/include/linux/fs.h  Sat Sep  9 06:24:21 
2017(r323348)
+++ head/sys/compat/linuxkpi/common/include/linux/fs.h  Sat Sep  9 06:29:29 
2017(r323349)
@@ -72,6 +72,17 @@ struct dentry {
 
 struct file_operations;
 
+struct linux_file_wait_queue {
+   struct wait_queue wq;
+   struct wait_queue_head *wqh;
+   atomic_t state;
+#defineLINUX_FWQ_STATE_INIT 0
+#defineLINUX_FWQ_STATE_NOT_READY 1
+#defineLINUX_FWQ_STATE_QUEUED 2
+#defineLINUX_FWQ_STATE_READY 3
+#defineLINUX_FWQ_STATE_MAX 4
+};
+
 struct linux_file {
struct file *_file;
const struct file_operations*f_op;
@@ -97,6 +108,7 @@ struct linux_file {
 #defineLINUX_KQ_FLAG_NEED_WRITE (1 << 3)
/* protects f_selinfo.si_note */
spinlock_t  f_kqlock;
+   struct linux_file_wait_queue f_wait_queue;
 };
 
 #definefilelinux_file

Modified: head/sys/compat/linuxkpi/common/include/linux/poll.h
==
--- head/sys/compat/linuxkpi/common/include/linux/poll.hSat Sep  9 
06:24:21 2017(r323348)
+++ head/sys/compat/linuxkpi/common/include/linux/poll.hSat Sep  9 
06:29:29 2017(r323349)
@@ -40,11 +40,8 @@
 typedef struct poll_table_struct {
 } poll_table;
 
-static inline void
-poll_wait(struct linux_file *filp, wait_queue_head_t *wait_address, poll_table 
*p)
-{
-   /* NOP */
-}
+extern void linux_poll_wait(struct linux_file *, wait_queue_head_t *, 
poll_table *);
+#definepoll_wait(...) linux_poll_wait(__VA_ARGS__)
 
 extern void linux_poll_wakeup(struct linux_file *);
 

Modified: head/sys/compat/linuxkpi/common/src/linux_compat.c
==
--- head/sys/compat/linuxkpi/common/src/linux_compat.c  Sat Sep  9 06:24:21 
2017(r323348)
+++ head/sys/compat/linuxkpi/common/src/linux_compat.c  Sat Sep  9 06:29:29 
2017(r323349)
@@ -1023,10 +1023,9 @@ linux_dev_poll(struct cdev *dev, int events, struct th
file = td->td_fpop;
filp->f_flags = file->f_flag;
linux_set_current(td);
-   if (filp->f_op->poll != NULL) {
-   selrecord(td, &filp->f_selinfo);
+   if (filp->f_op->poll != NULL)
revents = filp->f_op->poll(filp, NULL) & events;
-   } else
+   else
revents = 0;
 
return (revents);
@@ -1034,7 +1033,93 @@ error:
return (events & (POLLHUP|POLLIN|POLLRDNORM|POLLOUT|POLLWRNORM));
 }
 
+/*
+ * This function atomically updates the poll wakeup state and returns
+ * the previous state at the time of update.
+ */
+static uint8_t
+linux_poll_wakeup_state(atomic_t *v, const uint8_t *pstate)
+{
+   int c, old;
+
+   c = v->counter;
+
+   while ((old = atomic_cmpxchg(v, c, pstate[c])) != c)
+   c = old;
+
+   return (c);
+}
+
+
+static int
+linux_poll_wakeup_callback(wait_queue_t *wq, unsigned int wq_state, int flags, 
void *key)
+{
+   static const uint8_t state[LINUX_FWQ_STATE_MAX] = {
+   [LINUX_FWQ_STATE_INIT] = LINUX_FWQ_STATE_INIT, /* NOP */
+   [LINUX_FWQ_STATE_NOT_READY] = LINUX_FWQ_STATE_NOT_READY, /* NOP 
*/
+   [LINUX_FWQ_STATE_QUEUED] = LINUX_FWQ_STATE_READY,
+   [LINUX_FWQ_STATE_READY] = LINUX_FWQ_STATE_READY, /* NOP */
+   };
+   struct linux_file *filp = container_of(wq, struct linux_file, 
f_wait_queue.wq);
+
+   switch (linux_poll_wakeup_state(&filp->f_wait_queue.state, state)) {
+   case LINUX_FWQ_STATE_QUEUED:
+   linux_poll_wakeup(filp);
+   return (1);
+   default:
+   return (0);
+   }
+}
+
 void
+linux_poll_wait(struct linux_file *filp, wait_queue_head_t *wqh, poll_table *p)
+{
+   static const uint8_t state[LINUX_FWQ_STATE_MAX] = {
+   [LINUX_FWQ_STATE_INIT] = LINUX_FWQ_STATE_NOT_READY,
+   [LINUX_FWQ_STATE_NOT_READY] = LINUX_FWQ_ST

svn commit: r323348 - head/usr.bin/tail/tests

2017-09-08 Thread Ngie Cooper
Author: ngie
Date: Sat Sep  9 06:24:21 2017
New Revision: 323348
URL: https://svnweb.freebsd.org/changeset/base/323348

Log:
  Unbreak :broken_pipe
  
  - Capture exit code in pipeline and test in output.
  - Drop awk use in favor of `sleep 2`. This helps guarantee the EPIPE
behavior without the potential race.

Modified:
  head/usr.bin/tail/tests/tail_test.sh

Modified: head/usr.bin/tail/tests/tail_test.sh
==
--- head/usr.bin/tail/tests/tail_test.shSat Sep  9 06:04:05 2017
(r323347)
+++ head/usr.bin/tail/tests/tail_test.shSat Sep  9 06:24:21 2017
(r323348)
@@ -222,10 +222,10 @@ broken_pipe_head()
 }
 broken_pipe_body()
 {
-   atf_expect_fail "Can't seem to get testcase to work in test 
environment.  Reproduces easily in interactive shell."
-
atf_check -o save:ints seq -f '%128g' 1 1000
-   atf_check -s exit:1 -o ignore -e "inline:tail: stdout" tail -n 856 ints 
| awk '{ exit }'
+   atf_check -s ignore \
+   -e "inline:tail: stdout\nexit code: 1\n" \
+   -x '(tail -n 856 ints; echo exit code: $? >&2) | sleep 2'
 }
 
 
@@ -243,5 +243,5 @@ atf_init_test_cases()
atf_add_test_case longfile_rc135782
atf_add_test_case longfile_rc145782_longlines
atf_add_test_case longfile_rn2500
-   #atf_add_test_case broken_pipe
+   atf_add_test_case broken_pipe
 }
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r323347 - head/sys/compat/linuxkpi/common/include/linux

2017-09-08 Thread Hans Petter Selasky
Author: hselasky
Date: Sat Sep  9 06:04:05 2017
New Revision: 323347
URL: https://svnweb.freebsd.org/changeset/base/323347

Log:
  Add more sanity checks to linux_fget() in the LinuxKPI. This prevents
  returning pointers to file descriptors which were not created by the
  LinuxKPI.
  
  MFC after:1 week
  Sponsored by: Mellanox Technologies

Modified:
  head/sys/compat/linuxkpi/common/include/linux/file.h

Modified: head/sys/compat/linuxkpi/common/include/linux/file.h
==
--- head/sys/compat/linuxkpi/common/include/linux/file.hSat Sep  9 
05:56:04 2017(r323346)
+++ head/sys/compat/linuxkpi/common/include/linux/file.hSat Sep  9 
06:04:05 2017(r323347)
@@ -53,11 +53,18 @@ linux_fget(unsigned int fd)
cap_rights_t rights;
struct file *file;
 
+   /* lookup file pointer by file descriptor index */
if (fget_unlocked(curthread->td_proc->p_fd, fd,
-   cap_rights_init(&rights), &file, NULL) != 0) {
+   cap_rights_init(&rights), &file, NULL) != 0)
return (NULL);
+
+   /* check if file handle really belongs to us */
+   if (file->f_data == NULL ||
+   file->f_ops != &linuxfileops) {
+   fdrop(file, curthread);
+   return (NULL);
}
-   return (struct linux_file *)file->f_data;
+   return ((struct linux_file *)file->f_data);
 }
 
 extern void linux_file_free(struct linux_file *filp);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r323346 - in head/sys: powerpc/powerpc riscv/riscv

2017-09-08 Thread Mateusz Guzik
Author: mjg
Date: Sat Sep  9 05:56:04 2017
New Revision: 323346
URL: https://svnweb.freebsd.org/changeset/base/323346

Log:
  Fix riscv and powerpc compilation after r323329.
  
  On these archs bzero is a C function, which triggers a compilation error
  as the compiler tries to expand the macro.

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

Modified: head/sys/powerpc/powerpc/machdep.c
==
--- head/sys/powerpc/powerpc/machdep.c  Sat Sep  9 05:50:47 2017
(r323345)
+++ head/sys/powerpc/powerpc/machdep.c  Sat Sep  9 05:56:04 2017
(r323346)
@@ -417,43 +417,6 @@ powerpc_init(vm_offset_t fdt, vm_offset_t toc, vm_offs
(sizeof(struct callframe) - 3*sizeof(register_t))) & ~15UL);
 }
 
-void
-bzero(void *buf, size_t len)
-{
-   caddr_t p;
-
-   p = buf;
-
-   while (((vm_offset_t) p & (sizeof(u_long) - 1)) && len) {
-   *p++ = 0;
-   len--;
-   }
-
-   while (len >= sizeof(u_long) * 8) {
-   *(u_long*) p = 0;
-   *((u_long*) p + 1) = 0;
-   *((u_long*) p + 2) = 0;
-   *((u_long*) p + 3) = 0;
-   len -= sizeof(u_long) * 8;
-   *((u_long*) p + 4) = 0;
-   *((u_long*) p + 5) = 0;
-   *((u_long*) p + 6) = 0;
-   *((u_long*) p + 7) = 0;
-   p += sizeof(u_long) * 8;
-   }
-
-   while (len >= sizeof(u_long)) {
-   *(u_long*) p = 0;
-   len -= sizeof(u_long);
-   p += sizeof(u_long);
-   }
-
-   while (len) {
-   *p++ = 0;
-   len--;
-   }
-}
-
 /*
  * Flush the D-cache for non-DMA I/O so that the I-cache can
  * be made coherent later.
@@ -555,3 +518,41 @@ DB_SHOW_COMMAND(spr, db_show_spr)
(unsigned long)spr);
 }
 #endif
+
+#undef bzero
+void
+bzero(void *buf, size_t len)
+{
+   caddr_t p;
+
+   p = buf;
+
+   while (((vm_offset_t) p & (sizeof(u_long) - 1)) && len) {
+   *p++ = 0;
+   len--;
+   }
+
+   while (len >= sizeof(u_long) * 8) {
+   *(u_long*) p = 0;
+   *((u_long*) p + 1) = 0;
+   *((u_long*) p + 2) = 0;
+   *((u_long*) p + 3) = 0;
+   len -= sizeof(u_long) * 8;
+   *((u_long*) p + 4) = 0;
+   *((u_long*) p + 5) = 0;
+   *((u_long*) p + 6) = 0;
+   *((u_long*) p + 7) = 0;
+   p += sizeof(u_long) * 8;
+   }
+
+   while (len >= sizeof(u_long)) {
+   *(u_long*) p = 0;
+   len -= sizeof(u_long);
+   p += sizeof(u_long);
+   }
+
+   while (len) {
+   *p++ = 0;
+   len--;
+   }
+}

Modified: head/sys/riscv/riscv/machdep.c
==
--- head/sys/riscv/riscv/machdep.c  Sat Sep  9 05:50:47 2017
(r323345)
+++ head/sys/riscv/riscv/machdep.c  Sat Sep  9 05:56:04 2017
(r323346)
@@ -151,16 +151,6 @@ cpu_idle_wakeup(int cpu)
return (0);
 }
 
-void
-bzero(void *buf, size_t len)
-{
-   uint8_t *p;
-
-   p = buf;
-   while(len-- > 0)
-   *p++ = 0;
-}
-
 int
 fill_regs(struct thread *td, struct reg *regs)
 {
@@ -890,4 +880,15 @@ initriscv(struct riscv_bootparams *rvbp)
riscv_init_interrupts();
 
early_boot = 0;
+}
+
+#undef bzero
+void
+bzero(void *buf, size_t len)
+{
+   uint8_t *p;
+
+   p = buf;
+   while(len-- > 0)
+   *p++ = 0;
 }
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r323345 - head/usr.bin/tail/tests

2017-09-08 Thread Ngie Cooper
Author: ngie
Date: Sat Sep  9 05:50:47 2017
New Revision: 323345
URL: https://svnweb.freebsd.org/changeset/base/323345

Log:
  Check result of seq call and save output via atf_check -o
  
  This ensures that seq outputting to ints will not fail as silently if there's
  an error.

Modified:
  head/usr.bin/tail/tests/tail_test.sh

Modified: head/usr.bin/tail/tests/tail_test.sh
==
--- head/usr.bin/tail/tests/tail_test.shSat Sep  9 05:42:23 2017
(r323344)
+++ head/usr.bin/tail/tests/tail_test.shSat Sep  9 05:50:47 2017
(r323345)
@@ -224,7 +224,7 @@ broken_pipe_body()
 {
atf_expect_fail "Can't seem to get testcase to work in test 
environment.  Reproduces easily in interactive shell."
 
-   seq -f '%128g' 1 1000 > ints
+   atf_check -o save:ints seq -f '%128g' 1 1000
atf_check -s exit:1 -o ignore -e "inline:tail: stdout" tail -n 856 ints 
| awk '{ exit }'
 }
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r323343 - head/sys/dev/cxgbe

2017-09-08 Thread Navdeep Parhar
Author: np
Date: Sat Sep  9 05:12:14 2017
New Revision: 323343
URL: https://svnweb.freebsd.org/changeset/base/323343

Log:
  cxgbe(4): Fix a couple of problems in the sge_wrq data path.
  
  - start_wrq_wr must not drain the wr_list if there are incomplete_wrs
pending.  This can happen when a t4_wrq_tx runs between two
start_wrq_wr.
  
  - commit_wrq_wr must examine the cookie's pidx and ndesc with the
queue's lock held.  Otherwise there is a bad race when incomplete WRs
are being completed and commit_wrq_wr for the WR that is ahead in the
queue updates the next incomplete WR's cookie's pidx/ndesc but the
commit_wrq_wr for the second one is using stale values that it read
without the lock.
  
  MFC after:1 week
  Sponsored by: Chelsio Communications

Modified:
  head/sys/dev/cxgbe/t4_sge.c

Modified: head/sys/dev/cxgbe/t4_sge.c
==
--- head/sys/dev/cxgbe/t4_sge.c Sat Sep  9 03:09:02 2017(r323342)
+++ head/sys/dev/cxgbe/t4_sge.c Sat Sep  9 05:12:14 2017(r323343)
@@ -2354,7 +2354,7 @@ start_wrq_wr(struct sge_wrq *wrq, int len16, struct wr
 
EQ_LOCK(eq);
 
-   if (!STAILQ_EMPTY(&wrq->wr_list))
+   if (TAILQ_EMPTY(&wrq->incomplete_wrs) && !STAILQ_EMPTY(&wrq->wr_list))
drain_wrq_wr_list(sc, wrq);
 
if (!STAILQ_EMPTY(&wrq->wr_list)) {
@@ -2408,9 +2408,6 @@ commit_wrq_wr(struct sge_wrq *wrq, void *w, struct wrq
return;
}
 
-   ndesc = cookie->ndesc;  /* Can be more than SGE_MAX_WR_NDESC here. */
-   pidx = cookie->pidx;
-   MPASS(pidx >= 0 && pidx < eq->sidx);
if (__predict_false(w == &wrq->ss[0])) {
int n = (eq->sidx - wrq->ss_pidx) * EQ_ESIZE;
 
@@ -2422,6 +2419,9 @@ commit_wrq_wr(struct sge_wrq *wrq, void *w, struct wrq
wrq->tx_wrs_direct++;
 
EQ_LOCK(eq);
+   ndesc = cookie->ndesc;  /* Can be more than SGE_MAX_WR_NDESC here. */
+   pidx = cookie->pidx;
+   MPASS(pidx >= 0 && pidx < eq->sidx);
prev = TAILQ_PREV(cookie, wrq_incomplete_wrs, link);
next = TAILQ_NEXT(cookie, link);
if (prev == NULL) {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r323329 - head/sys/sys

2017-09-08 Thread Ngie Cooper (yaneurabeya)

> On Sep 8, 2017, at 13:09, Mateusz Guzik  wrote:
> 
> Author: mjg
> Date: Fri Sep  8 20:09:14 2017
> New Revision: 323329
> URL: https://svnweb.freebsd.org/changeset/base/323329
> 
> Log:
>  Allow __builtin_memset instead of bzero for small buffers of known size
> 
>  In particular this eliminates function calls and related register 
> save/restore
>  when only few writes would suffice.
> 
>  Example speed up can be seen in a fstat microbenchmark on AMD Ryzen cpus, 
> where
>  the throughput went up by ~4.5%.
> 
>  Thanks to cem@ for benchmarking and reviewing the patch.

This change breaks all platforms that use gcc. If it’s not reverted in the next 
3 hours, I’ll revert it.

Please fix ASAP if possible: 
https://ci.freebsd.org/job/FreeBSD-head-riscv64-build/3668/console .

Thanks,
-Ngie


signature.asc
Description: Message signed with OpenPGP using GPGMail


Re: svn commit: r323342 - head/usr.sbin/manctl

2017-09-08 Thread Cy Schubert
In message <201709090309.v89392bq078...@repo.freebsd.org>, Gordon Tetlow 
writes
:
> Author: gordon
> Date: Sat Sep  9 03:09:02 2017
> New Revision: 323342
> URL: https://svnweb.freebsd.org/changeset/base/323342
> 
> Log:
>   The purge option hasn't been implemented since 1994 when we imported this
>   code. I think it is safe to say it's not going to be. I'm also working to
>   de-orbit catman, so remove the reference in the manpage.
>   
>   Reviewed by:allanjude
> 
> Modified:
>   head/usr.sbin/manctl/manctl.8
>   head/usr.sbin/manctl/manctl.sh
> 
> Modified: head/usr.sbin/manctl/manctl.8
> =
> =
> --- head/usr.sbin/manctl/manctl.8 Sat Sep  9 02:28:21 2017(r32334
> 1)
> +++ head/usr.sbin/manctl/manctl.8 Sat Sep  9 03:09:02 2017(r32334
> 2)
> @@ -33,7 +33,6 @@
>  .Nm
>  .Op Fl compress
>  .Op Fl uncompress
> -.Op Fl purge
>  .Op Fl help
>  .Ar path ...
>  .Sh DESCRIPTION
> @@ -50,9 +49,6 @@ Print options and exit.
>  Compress uncompressed man pages (eliminating .so's).
>  .It Fl uncompress
>  Uncompress compressed man pages.
> -.It Fl purge
> -Purge old formatted man pages (not implemented yet).
>  .El
>  .Sh SEE ALSO
> -.Xr catman 1 ,
>  .Xr man 1

Don't forget this...

Index: manctl.8
===
--- manctl.8(revision 323342)
+++ manctl.8(working copy)
@@ -23,7 +23,7 @@
 .\" SUCH DAMAGE.
 .\"
 .\" $FreeBSD$
-.Dd January 1, 1996
+.Dd September 8, 2017
 .Dt MANCTL 8
 .Os
 .Sh NAME


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

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


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


svn commit: r323342 - head/usr.sbin/manctl

2017-09-08 Thread Gordon Tetlow
Author: gordon
Date: Sat Sep  9 03:09:02 2017
New Revision: 323342
URL: https://svnweb.freebsd.org/changeset/base/323342

Log:
  The purge option hasn't been implemented since 1994 when we imported this
  code. I think it is safe to say it's not going to be. I'm also working to
  de-orbit catman, so remove the reference in the manpage.
  
  Reviewed by:  allanjude

Modified:
  head/usr.sbin/manctl/manctl.8
  head/usr.sbin/manctl/manctl.sh

Modified: head/usr.sbin/manctl/manctl.8
==
--- head/usr.sbin/manctl/manctl.8   Sat Sep  9 02:28:21 2017
(r323341)
+++ head/usr.sbin/manctl/manctl.8   Sat Sep  9 03:09:02 2017
(r323342)
@@ -33,7 +33,6 @@
 .Nm
 .Op Fl compress
 .Op Fl uncompress
-.Op Fl purge
 .Op Fl help
 .Ar path ...
 .Sh DESCRIPTION
@@ -50,9 +49,6 @@ Print options and exit.
 Compress uncompressed man pages (eliminating .so's).
 .It Fl uncompress
 Uncompress compressed man pages.
-.It Fl purge
-Purge old formatted man pages (not implemented yet).
 .El
 .Sh SEE ALSO
-.Xr catman 1 ,
 .Xr man 1

Modified: head/usr.sbin/manctl/manctl.sh
==
--- head/usr.sbin/manctl/manctl.sh  Sat Sep  9 02:28:21 2017
(r323341)
+++ head/usr.sbin/manctl/manctl.sh  Sat Sep  9 03:09:02 2017
(r323342)
@@ -39,7 +39,6 @@
 #  this is now two-pass.  If possible, .so's
 #  are replaced with hard links
 #  uncompress compressed man pages
-#  purge old formatted man pages (not implemented yet)
 # Things to watch out for:
 #  Hard links - careful with g(un)zipping!
 #  .so's - throw everything through soelim before gzip!
@@ -49,16 +48,6 @@
 PATH=/bin:/sbin:/usr/bin:/usr/sbin; export PATH
 
 #
-# purge cat? directories
-#
-do_purge()
-{
-   echo "purge $@" 2>&1
-   echo "not implemented yet\n" 2>&1
-}
-
-
-#
 # Uncompress one page
 #
 uncompress_page()
@@ -351,8 +340,6 @@ ctl_usage()
 {
echo "usage: $1 -compress  ... " 1>&2
echo "   $1 -uncompress  ... " 1>&2
-   echo "   $1 -purge   ... " 1>&2
-   echo "   $1 -purge expire  ... " 1>&2
exit 1
 }
 
@@ -375,6 +362,5 @@ if [ $# -lt 2 ] ; then ctl_usage $0 ; fi ;
 case "$1" in
-compress)  shift ; do_compress "$@" ;;
-uncompress)shift ; do_uncompress "$@" ;;
-   -purge) shift ; do_purge "$@" ;;
*)  ctl_usage $0 ;;
 esac
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r323341 - head/share/man/man5

2017-09-08 Thread Ian Lepore
Author: ian
Date: Sat Sep  9 02:28:21 2017
New Revision: 323341
URL: https://svnweb.freebsd.org/changeset/base/323341

Log:
  Clarify that the size option is in bytes by default, but also accepts the
  usual SI suffixes.

Modified:
  head/share/man/man5/tmpfs.5

Modified: head/share/man/man5/tmpfs.5
==
--- head/share/man/man5/tmpfs.5 Sat Sep  9 02:19:44 2017(r323340)
+++ head/share/man/man5/tmpfs.5 Sat Sep  9 02:28:21 2017(r323341)
@@ -54,7 +54,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd January 20, 2017
+.Dd September 8, 2017
 .Dt TMPFS 5
 .Os
 .Sh NAME
@@ -131,7 +131,9 @@ the file system size, which can be limited with the
 .Cm size
 option.
 .It Cm size
-Specifies the total file system size in bytes.
+Specifies the total file system size in bytes, unless suffixed
+with one of k, m, g, t, or p, which denote byte, kilobyte,
+megabyte, gigabyte, terabyte and petabyte respectively.
 If zero (the default) or a value larger than SIZE_MAX - PAGE_SIZE
 is given, the available amount of memory (including
 main memory and swap space) will be used.
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r323340 - head/sys/powerpc/mpc85xx

2017-09-08 Thread Justin Hibbits
Author: jhibbits
Date: Sat Sep  9 02:19:44 2017
New Revision: 323340
URL: https://svnweb.freebsd.org/changeset/base/323340

Log:
  Add P5021 and P5040 conditions for LAW count check.
  
  P5040/P5021 have the same number of LAWs as P5020.  There may be a better way 
of
  getting the count from the FDT (fsl,num-laws property on soc/corenet-law or
  soc/ecm-law), but that's not supported everywhere, so we still need this check
  for those other cases.

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

Modified: head/sys/powerpc/mpc85xx/mpc85xx.c
==
--- head/sys/powerpc/mpc85xx/mpc85xx.c  Sat Sep  9 02:08:22 2017
(r323339)
+++ head/sys/powerpc/mpc85xx/mpc85xx.c  Sat Sep  9 02:19:44 2017
(r323340)
@@ -96,6 +96,10 @@ law_getmax(void)
break;
case SVR_P5020:
case SVR_P5020E:
+   case SVR_P5021:
+   case SVR_P5021E:
+   case SVR_P5040:
+   case SVR_P5040E:
law_max = 32;
break;
default:
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r323339 - head/sys/powerpc/include

2017-09-08 Thread Justin Hibbits
Author: jhibbits
Date: Sat Sep  9 02:08:22 2017
New Revision: 323339
URL: https://svnweb.freebsd.org/changeset/base/323339

Log:
  Add some more PVR and SVR defines
  
  These processors may not be supported yet, but add them for completion.
  
  POWER9 is planned for support.  e300 may work (based on 603e core).
  P5040/P5021 are similar to P5020, so should work as well.  One addition is
  needed for P5040, to support the number of LAWs, and will be a separate 
commit.

Modified:
  head/sys/powerpc/include/spr.h

Modified: head/sys/powerpc/include/spr.h
==
--- head/sys/powerpc/include/spr.h  Sat Sep  9 01:41:01 2017
(r323338)
+++ head/sys/powerpc/include/spr.h  Sat Sep  9 02:08:22 2017
(r323339)
@@ -171,6 +171,7 @@
 #define  IBMPOWER7PLUS   0x004a
 #define  IBMPOWER8E  0x004b
 #define  IBMPOWER8   0x004d
+#define  IBMPOWER9   0x004e
 #define  MPC860  0x0050
 #define  IBMCELLBE   0x0070
 #define  MPC8240 0x0081
@@ -191,6 +192,10 @@
 #define  FSL_E500mc  0x8023
 #define  FSL_E5500   0x8024
 #define  FSL_E6500   0x8040
+#define  FSL_E300C1  0x8083
+#define  FSL_E300C2  0x8084
+#define  FSL_E300C3  0x8085
+#define  FSL_E300C4  0x8086
 
 #defineSPR_EPCR0x133
 #define  EPCR_EXTGS  0x8000
@@ -733,6 +738,10 @@
 #define  SVR_P4080E  0x8209
 #define  SVR_P5020   0x8220
 #define  SVR_P5020E  0x8228
+#define  SVR_P5021   0x8205
+#define  SVR_P5021E  0x820d
+#define  SVR_P5040   0x8204
+#define  SVR_P5040E  0x820c
 #defineSVR_VER(svr)(((svr) >> 16) & 0x)
 
 #defineSPR_PID00x030   /* ..8 Process ID Register 0 */
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r323338 - head/sys/geom/eli

2017-09-08 Thread Conrad Meyer
Author: cem
Date: Sat Sep  9 01:41:01 2017
New Revision: 323338
URL: https://svnweb.freebsd.org/changeset/base/323338

Log:
  Fix information leak in geli(8) integrity mode
  
  In integrity mode, a larger logical sector (e.g., 4096 bytes) spans several
  physical sectors (e.g., 512 bytes) on the backing device.  Due to hash
  overhead, a 4096 byte logical sector takes 8.5625 512-byte physical sectors.
  This means that only 288 bytes (256 data + 32 hash) of the last 512 byte
  sector are used.
  
  The memory allocation used to store the encrypted data to be written to the
  physical sectors comes from malloc(9) and does not use M_ZERO.
  
  Previously, nothing initialized the final physical sector backing each
  logical sector, aside from the hash + encrypted data portion.  So 224 bytes
  of kernel heap memory was leaked to every block :-(.
  
  This patch addresses the issue by initializing the trailing portion of the
  physical sector in every logical sector to zeros before use.  A much simpler
  but higher overhead fix would be to tag the entire allocation M_ZERO.
  
  PR:   222077
  Reported by:  Maxim Khitrov 
  Reviewed by:  emaste
  Security: yes
  Sponsored by: Dell EMC Isilon
  Differential Revision:https://reviews.freebsd.org/D12272

Modified:
  head/sys/geom/eli/g_eli_integrity.c

Modified: head/sys/geom/eli/g_eli_integrity.c
==
--- head/sys/geom/eli/g_eli_integrity.c Sat Sep  9 01:23:30 2017
(r323337)
+++ head/sys/geom/eli/g_eli_integrity.c Sat Sep  9 01:41:01 2017
(r323338)
@@ -463,8 +463,16 @@ g_eli_auth_run(struct g_eli_worker *wr, struct bio *bp
authkey = (u_char *)p;  p += G_ELI_AUTH_SECKEYLEN;
 
data_secsize = sc->sc_data_per_sector;
-   if ((i % lsec) == 0)
+   if ((i % lsec) == 0) {
data_secsize = decr_secsize % data_secsize;
+   /*
+* Last encrypted sector of each decrypted sector is
+* only partially filled.
+*/
+   if (bp->bio_cmd == BIO_WRITE)
+   memset(data + sc->sc_alen + data_secsize, 0,
+   encr_secsize - sc->sc_alen - data_secsize);
+   }
 
if (bp->bio_cmd == BIO_READ) {
/* Remember read HMAC. */
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r323337 - stable/10/usr.sbin/bsdinstall/scripts

2017-09-08 Thread Ed Maste
Author: emaste
Date: Sat Sep  9 01:23:30 2017
New Revision: 323337
URL: https://svnweb.freebsd.org/changeset/base/323337

Log:
  MFC r322374: bsdinstall: record DHCP config after obtaining lease
  
  Previously we added an ifconfig_$INTERFACE line to rc.conf for each
  unsuccessful DCHP attempt.
  
  PR:   219515
  Approved by:  re (marius)
  Sponsored by: The FreeBSD Foundation

Modified:
  stable/10/usr.sbin/bsdinstall/scripts/netconfig_ipv4
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.sbin/bsdinstall/scripts/netconfig_ipv4
==
--- stable/10/usr.sbin/bsdinstall/scripts/netconfig_ipv4Sat Sep  9 
00:33:19 2017(r323336)
+++ stable/10/usr.sbin/bsdinstall/scripts/netconfig_ipv4Sat Sep  9 
01:23:30 2017(r323337)
@@ -48,8 +48,6 @@ esac
 
 dialog --backtitle 'FreeBSD Installer' --title 'Network Configuration' --yesno 
'Would you like to use DHCP to configure this interface?' 0 0
 if [ $? -eq $DIALOG_OK ]; then
-   echo ifconfig_$INTERFACE=\"${IFCONFIG_PREFIX}DHCP\" >> 
$BSDINSTALL_TMPETC/._rc.conf.net
-
if [ ! -z $BSDINSTALL_CONFIGCURRENT ]; then
dialog --backtitle 'FreeBSD Installer' --infobox "Acquiring 
DHCP lease..." 0 0
err=$( dhclient $INTERFACE 2>&1 )
@@ -59,6 +57,7 @@ if [ $? -eq $DIALOG_OK ]; then
exec $0 ${INTERFACE} "${IFCONFIG_PREFIX}"
fi
fi
+   echo ifconfig_$INTERFACE=\"${IFCONFIG_PREFIX}DHCP\" >> 
$BSDINSTALL_TMPETC/._rc.conf.net
exit 0
 fi
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r323336 - stable/11/usr.sbin/bsdinstall/scripts

2017-09-08 Thread Ed Maste
Author: emaste
Date: Sat Sep  9 00:33:19 2017
New Revision: 323336
URL: https://svnweb.freebsd.org/changeset/base/323336

Log:
  MFC r322374: bsdinstall: record DHCP config after obtaining lease
  
  Previously we added an ifconfig_$INTERFACE line to rc.conf for each
  unsuccessful DCHP attempt.
  
  PR:   219515
  Sponsored by: The FreeBSD Foundation

Modified:
  stable/11/usr.sbin/bsdinstall/scripts/netconfig_ipv4
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/usr.sbin/bsdinstall/scripts/netconfig_ipv4
==
--- stable/11/usr.sbin/bsdinstall/scripts/netconfig_ipv4Fri Sep  8 
22:04:28 2017(r323335)
+++ stable/11/usr.sbin/bsdinstall/scripts/netconfig_ipv4Sat Sep  9 
00:33:19 2017(r323336)
@@ -48,8 +48,6 @@ esac
 
 dialog --backtitle 'FreeBSD Installer' --title 'Network Configuration' --yesno 
'Would you like to use DHCP to configure this interface?' 0 0
 if [ $? -eq $DIALOG_OK ]; then
-   echo ifconfig_$INTERFACE=\"${IFCONFIG_PREFIX}DHCP\" >> 
$BSDINSTALL_TMPETC/._rc.conf.net
-
if [ ! -z $BSDINSTALL_CONFIGCURRENT ]; then
dialog --backtitle 'FreeBSD Installer' --infobox "Acquiring 
DHCP lease..." 0 0
err=$( dhclient $INTERFACE 2>&1 )
@@ -59,6 +57,7 @@ if [ $? -eq $DIALOG_OK ]; then
exec $0 ${INTERFACE} "${IFCONFIG_PREFIX}"
fi
fi
+   echo ifconfig_$INTERFACE=\"${IFCONFIG_PREFIX}DHCP\" >> 
$BSDINSTALL_TMPETC/._rc.conf.net
exit 0
 fi
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r323333 - in stable/10/usr.sbin/pw: . tests

2017-09-08 Thread Ed Maste
Author: emaste
Date: Fri Sep  8 21:16:23 2017
New Revision: 32
URL: https://svnweb.freebsd.org/changeset/base/32

Log:
  MFC r322677: pw usermod: handle empty secondary group lists (-G '')
  
  "pw usermod someuser -G ''" is supposed make sure that someuser
  doesn't have any secondary group memberships.
  
  Previouly it was a nop because split_groups() only intitialised
  "groups" if at least one group was specified. As a result the
  existing secondary group memberships were kept.
  
  PR:   221417
  Submitted by: Fabian Keil
  Approved by:  re (kib)
  Obtained from:ElectroBSD
  Relnotes: yes

Modified:
  stable/10/usr.sbin/pw/pw_user.c
  stable/10/usr.sbin/pw/tests/pw_usermod_test.sh
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.sbin/pw/pw_user.c
==
--- stable/10/usr.sbin/pw/pw_user.c Fri Sep  8 21:02:15 2017
(r323332)
+++ stable/10/usr.sbin/pw/pw_user.c Fri Sep  8 21:16:23 2017
(r32)
@@ -1089,10 +1089,10 @@ split_groups(StringList **groups, char *groupsstr)
char *p;
char tok[] = ", \t";
 
+   if (*groups == NULL)
+   *groups = sl_init();
for (p = strtok(groupsstr, tok); p != NULL; p = strtok(NULL, tok)) {
grp = group_from_name_or_id(p);
-   if (*groups == NULL)
-   *groups = sl_init();
sl_add(*groups, newstr(grp->gr_name));
}
 }

Modified: stable/10/usr.sbin/pw/tests/pw_usermod_test.sh
==
--- stable/10/usr.sbin/pw/tests/pw_usermod_test.sh  Fri Sep  8 21:02:15 
2017(r323332)
+++ stable/10/usr.sbin/pw/tests/pw_usermod_test.sh  Fri Sep  8 21:16:23 
2017(r32)
@@ -128,6 +128,9 @@ user_mod_nogroups_body() {
atf_check -s exit:0 ${PW} usermod foo -G test3,test4
atf_check -s exit:0 -o inline:"test3\ntest4\n" \
awk -F\: '$4 == "foo" { print $1 }' ${HOME}/group
+   atf_check -s exit:0 ${PW} usermod foo -G ""
+   atf_check -s exit:0 -o empty \
+   awk -F\: '$4 == "foo" { print $1 }' ${HOME}/group
 }
 
 atf_test_case user_mod_rename
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r323332 - in stable/10/usr.sbin/pw: . tests

2017-09-08 Thread Ed Maste
Author: emaste
Date: Fri Sep  8 21:02:15 2017
New Revision: 323332
URL: https://svnweb.freebsd.org/changeset/base/323332

Log:
  MFC r322678: pw useradd: Validate the user name before creating the entry
  
  Previouly it was possible to create users with spaces in the name with:
  pw useradd -u 1234 -g 1234 -n 'test user'
  
  The "-g 1234" is relevant, without it the name was already rejected
  as expected:
  
  [fk@test ~]$ sudo pw useradd -u 1234 -n 'test user'
  pw: invalid character ` ' at position 4 in userid/group name
  
  Bug unintentionally found with a salt config without explicit name entry:
  
  test user:
user.present:
  - uid: 1234
  - gid: 1234
  - fullname: Test user
  - shell: /usr/local/bin/bash
  - home: /home/test
  - groups:
- wheel
- salt
  
  "Luckily" salt modules rarely bother with input validation either ...
  
  PR:   221416
  Submitted by: Fabian Keil
  Approved by:  re (kib)
  Obtained from:ElectroBSD

Modified:
  stable/10/usr.sbin/pw/pw_user.c
  stable/10/usr.sbin/pw/tests/pw_useradd_test.sh
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.sbin/pw/pw_user.c
==
--- stable/10/usr.sbin/pw/pw_user.c Fri Sep  8 20:41:49 2017
(r323331)
+++ stable/10/usr.sbin/pw/pw_user.c Fri Sep  8 21:02:15 2017
(r323332)
@@ -1204,7 +1204,7 @@ pw_user_add(int argc, char **argv, char *arg1)
if (arg1[strspn(arg1, "0123456789")] == '\0')
id = pw_checkid(arg1, UID_MAX);
else
-   name = arg1;
+   name = pw_checkname(arg1, 0);
}
 
while ((ch = getopt(argc, argv, args)) != -1) {
@@ -1216,7 +1216,7 @@ pw_user_add(int argc, char **argv, char *arg1)
quiet = true;
break;
case 'n':
-   name = optarg;
+   name = pw_checkname(optarg, 0);
break;
case 'u':
userid = optarg;

Modified: stable/10/usr.sbin/pw/tests/pw_useradd_test.sh
==
--- stable/10/usr.sbin/pw/tests/pw_useradd_test.sh  Fri Sep  8 20:41:49 
2017(r323331)
+++ stable/10/usr.sbin/pw/tests/pw_useradd_test.sh  Fri Sep  8 21:02:15 
2017(r323332)
@@ -176,6 +176,43 @@ user_add_name_too_long_body() {
${PW} useradd name_very_vert_very_very_very_long
 }
 
+atf_test_case user_add_name_with_spaces
+user_add_name_with_spaces_body() {
+   populate_etc_skel
+   atf_check -s exit:65 -e match:"invalid character" \
+ ${PW} useradd 'test user'
+   atf_check -s exit:1 -o empty grep "^test user:.*" $HOME/master.passwd
+   # Try again with -n which uses a slightly different code path.
+   atf_check -s exit:65 -e match:"invalid character" \
+ ${PW} useradd -n 'test user'
+   atf_check -s exit:1 -o empty grep "^test user:.*" $HOME/master.passwd
+}
+
+atf_test_case user_add_name_with_spaces_and_gid_specified
+user_add_name_with_spaces_and_gid_specified_body() {
+   populate_etc_skel
+   gid=12345
+   user_name="test user"
+   # pw useradd should fail because of the space in the user
+   # name, not because the group doesn't exist.
+   atf_check -s exit:65 -e match:"invalid character" \
+ ${PW} useradd "${user_name}" -g ${gid}
+   atf_check -s exit:1 -o empty grep "^${user_name}:.*" $HOME/master.passwd
+   # Try again with -n which uses a slightly different code path.
+   atf_check -s exit:65 -e match:"invalid character" \
+ ${PW} useradd -n "${user_name}" -g ${gid}
+   atf_check -s exit:1 -o empty grep "^${user_name}:.*" $HOME/master.passwd
+   # Make sure the user isn't added even if the group exists
+   atf_check -s exit:0 ${PW} groupadd blafasel -g ${gid}
+   atf_check -s exit:65 -e match:"invalid character" \
+ ${PW} useradd "${user_name}" -g ${gid}
+   atf_check -s exit:1 -o empty grep "^${user_name}:.*" $HOME/master.passwd
+   # Try again with the -n option.
+   atf_check -s exit:65 -e match:"invalid character" \
+ ${PW} useradd -n "${user_name}" -g ${gid}
+   atf_check -s exit:1 -o empty grep "^${user_name}:.*" $HOME/master.passwd
+}
+
 atf_test_case user_add_expiration
 user_add_expiration_body() {
populate_etc_skel
@@ -415,6 +452,8 @@ atf_init_test_cases() {
atf_add_test_case user_add_password_expiration_date_month
atf_add_test_case user_add_password_expiration_date_relative
atf_add_test_case user_add_name_too_long
+   atf_add_test_case user_add_name_with_spaces
+   atf_add_test_case user_add_name_with_spaces_and_gid_specified
atf_add_test_case user_add_expirat

svn commit: r323331 - stable/10/sys/cddl/contrib/opensolaris/common/zfs

2017-09-08 Thread Ed Maste
Author: emaste
Date: Fri Sep  8 20:41:49 2017
New Revision: 323331
URL: https://svnweb.freebsd.org/changeset/base/323331

Log:
  MFC r323002: zfs: do not advertise unsupported hash algorithms
  
  illumos 4185 ("add new cryptographic checksums to ZFS: SHA-512, Skein,
  Edon-R") was intentionally merged only partially in r289422, without
  adding support for skein, sha512 and edonr on FreeBSD.
  
  Support for skein and sha512 was added later on (in head), but none of
  these are supported in stable/10. Prior to this commit zfs(8) correctly
  rejected these algorithms, but with an error message that claimed
  support:
  
  fk@r500 ~ $zfs set checksum=edonr tank
  cannot set property for 'tank': 'checksum' must be one of 'on | off |
fletcher2 | fletcher4 | sha256 | sha512 | skein | edonr'
  
  (This commit removes sha512 and skein in addition to edonr from the
  merge of head's r323002.)
  
  PR:   204055
  Submitted by: Fabian Keil
  Approved by:  re (kib)
  Obtained from:ElectroBSD

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

Modified: stable/10/sys/cddl/contrib/opensolaris/common/zfs/zfs_prop.c
==
--- stable/10/sys/cddl/contrib/opensolaris/common/zfs/zfs_prop.cFri Sep 
 8 20:20:35 2017(r323330)
+++ stable/10/sys/cddl/contrib/opensolaris/common/zfs/zfs_prop.cFri Sep 
 8 20:41:49 2017(r323331)
@@ -241,12 +241,12 @@ zfs_prop_init(void)
zprop_register_index(ZFS_PROP_CHECKSUM, "checksum",
ZIO_CHECKSUM_DEFAULT, PROP_INHERIT, ZFS_TYPE_FILESYSTEM |
ZFS_TYPE_VOLUME,
-   "on | off | fletcher2 | fletcher4 | sha256 | sha512 | "
-   "skein | edonr", "CHECKSUM", checksum_table);
+   "on | off | fletcher2 | fletcher4 | sha256",
+   "CHECKSUM", checksum_table);
zprop_register_index(ZFS_PROP_DEDUP, "dedup", ZIO_CHECKSUM_OFF,
PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
-   "on | off | verify | sha256[,verify], sha512[,verify], "
-   "skein[,verify], edonr,verify", "DEDUP", dedup_table);
+   "on | off | verify | sha256[,verify]",
+   "DEDUP", dedup_table);
zprop_register_index(ZFS_PROP_COMPRESSION, "compression",
ZIO_COMPRESS_DEFAULT, PROP_INHERIT,
ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r323330 - in head/sys/dev: mpr mps

2017-09-08 Thread Scott Long
Author: scottl
Date: Fri Sep  8 20:20:35 2017
New Revision: 323330
URL: https://svnweb.freebsd.org/changeset/base/323330

Log:
  Refactor interrupt allocation and deallocation.  Add some extra
  diagnostics.  No other functional changes.
  
  Sponsored by: Netflix

Modified:
  head/sys/dev/mpr/mpr_pci.c
  head/sys/dev/mps/mps_pci.c

Modified: head/sys/dev/mpr/mpr_pci.c
==
--- head/sys/dev/mpr/mpr_pci.c  Fri Sep  8 20:09:14 2017(r323329)
+++ head/sys/dev/mpr/mpr_pci.c  Fri Sep  8 20:20:35 2017(r323330)
@@ -268,10 +268,21 @@ mpr_pci_alloc_interrupts(struct mpr_softc *sc)
if ((error != 0) && (sc->disable_msi == 0) &&
((msgs = pci_msi_count(dev)) >= MPR_MSI_COUNT))
error = mpr_alloc_msi(sc, MPR_MSI_COUNT);
-   if (error != 0)
-   msgs = 0;
+   if (error != 0) {
+   /*
+* If neither MSI or MSI-X are available, assume legacy INTx.
+* This also implies that there will be only 1 queue.
+*/
+   sc->mpr_flags |= MPR_FLAGS_INTX;
+   msgs = 1;
+   } else {
+   sc->mpr_flags |= MPR_FLAGS_MSI;
+   msgs = MPR_MSI_COUNT;   /* XXX */
+   }
 
sc->msi_msgs = msgs;
+   mpr_dprint(sc, MPR_INIT, "Allocated %d interrupts\n", msgs);
+
return (error);
 }
 
@@ -279,47 +290,45 @@ int
 mpr_pci_setup_interrupts(struct mpr_softc *sc)
 {
device_t dev;
-   int i, error;
+   void *ihandler;
+   int i, error, rid, initial_rid;
 
dev = sc->mpr_dev;
error = ENXIO;
 
-   if (sc->msi_msgs == 0) {
-   sc->mpr_flags |= MPR_FLAGS_INTX;
-   sc->mpr_irq_rid[0] = 0;
-   sc->mpr_irq[0] = bus_alloc_resource_any(dev, SYS_RES_IRQ,
-   &sc->mpr_irq_rid[0],  RF_SHAREABLE | RF_ACTIVE);
-   if (sc->mpr_irq[0] == NULL) {
-   mpr_printf(sc, "Cannot allocate INTx interrupt\n");
-   return (ENXIO);
-   }
-   error = bus_setup_intr(dev, sc->mpr_irq[0],
-   INTR_TYPE_BIO | INTR_MPSAFE, NULL, mpr_intr, sc,
-   &sc->mpr_intrhand[0]);
-   if (error)
-   mpr_printf(sc, "Cannot setup INTx interrupt\n");
+   if (sc->mpr_flags & MPR_FLAGS_INTX) {
+   initial_rid = 0;
+   ihandler = mpr_intr;
+   } else if (sc->mpr_flags & MPR_FLAGS_MSI) {
+   initial_rid = 1;
+   ihandler = mpr_intr_msi;
} else {
-   sc->mpr_flags |= MPR_FLAGS_MSI;
-   for (i = 0; i < MPR_MSI_COUNT; i++) {
-   sc->mpr_irq_rid[i] = i + 1;
-   sc->mpr_irq[i] = bus_alloc_resource_any(dev,
-   SYS_RES_IRQ, &sc->mpr_irq_rid[i], RF_ACTIVE);
-   if (sc->mpr_irq[i] == NULL) {
-   mpr_printf(sc,
-   "Cannot allocate MSI interrupt\n");
-   return (ENXIO);
-   }
-   error = bus_setup_intr(dev, sc->mpr_irq[i],
-   INTR_TYPE_BIO | INTR_MPSAFE, NULL, mpr_intr_msi,
-   sc, &sc->mpr_intrhand[i]);
-   if (error) {
-   mpr_printf(sc,
-   "Cannot setup MSI interrupt %d\n", i);
-   break;
-   }
+   mpr_dprint(sc, MPR_ERROR|MPR_INIT,
+   "Unable to set up interrupts\n");
+   return (EINVAL);
+   }
+
+   for (i = 0; i < sc->msi_msgs; i++) {
+   rid = i + initial_rid;
+   sc->mpr_irq_rid[i] = rid;
+   sc->mpr_irq[i] = bus_alloc_resource_any(dev, SYS_RES_IRQ,
+   &sc->mpr_irq_rid[i], RF_ACTIVE);
+   if (sc->mpr_irq[i] == NULL) {
+   mpr_dprint(sc, MPR_ERROR|MPR_INIT,
+   "Cannot allocate interrupt RID %d\n", rid);
+   break;
}
+   error = bus_setup_intr(dev, sc->mpr_irq[i],
+   INTR_TYPE_BIO | INTR_MPSAFE, NULL, mpr_intr_msi,
+   sc, &sc->mpr_intrhand[i]);
+   if (error) {
+   mpr_dprint(sc, MPR_ERROR|MPR_INIT,
+   "Cannot setup interrupt RID %d\n", rid);
+   break;
+   }
}
 
+mpr_dprint(sc, MPR_INIT, "Set up %d interrupts\n", sc->msi_msgs);
return (error);
 }
 
@@ -347,24 +356,17 @@ mpr_pci_free(struct mpr_softc *sc)
bus_dma_tag_destroy(sc->mpr_parent_dmat);
}
 
-   if (sc->mpr_flags & MPR_FLAGS_MSI) {
-   for (i = 0; i < MPR_MSI_COUNT; i++) {
-   if (s

svn commit: r323329 - head/sys/sys

2017-09-08 Thread Mateusz Guzik
Author: mjg
Date: Fri Sep  8 20:09:14 2017
New Revision: 323329
URL: https://svnweb.freebsd.org/changeset/base/323329

Log:
  Allow __builtin_memset instead of bzero for small buffers of known size
  
  In particular this eliminates function calls and related register save/restore
  when only few writes would suffice.
  
  Example speed up can be seen in a fstat microbenchmark on AMD Ryzen cpus, 
where
  the throughput went up by ~4.5%.
  
  Thanks to cem@ for benchmarking and reviewing the patch.
  
  MFC after:1 week

Modified:
  head/sys/sys/systm.h

Modified: head/sys/sys/systm.h
==
--- head/sys/sys/systm.hFri Sep  8 20:07:53 2017(r323328)
+++ head/sys/sys/systm.hFri Sep  8 20:09:14 2017(r323329)
@@ -258,6 +258,12 @@ void   hexdump(const void *ptr, int length, const char 
*
 #define ovbcopy(f, t, l) bcopy((f), (t), (l))
 void   bcopy(const void * _Nonnull from, void * _Nonnull to, size_t len);
 void   bzero(void * _Nonnull buf, size_t len);
+#define bzero(buf, len) ({ \
+   if (__builtin_constant_p(len) && (len) <= 64)   \
+   __builtin_memset((buf), 0, (len));  \
+   else\
+   bzero((buf), (len));\
+})
 void   explicit_bzero(void * _Nonnull, size_t);
 
 void   *memcpy(void * _Nonnull to, const void * _Nonnull from, size_t len);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r323327 - head/sys/x86/pci

2017-09-08 Thread Konstantin Belousov
Author: kib
Date: Fri Sep  8 19:51:03 2017
New Revision: 323327
URL: https://svnweb.freebsd.org/changeset/base/323327

Log:
  Enhance qpi.c to make it usable on all Core-microarchitecture Xeons.
  
  Scan all buses for CSR bus, not stopping on the first failed
  match. Scan all slots for function 0 on the found bus, for instance on
  IvyBridge the slot 0 is not decoded at all. Since the scan is quite
  unsafe, and access to the buses is mostly useful for developers,
  enable the csr buses scan with the tunable.
  
  Current qpi.c makes too many assumptions about the uncore
  configuration buses location and about slots occupied.  Also it
  restricts itself only to Nehalem CPUs.  It is needed on all Core-based
  Xeons.  On the 2600 v2 (IvyBridge) machine I have access to, the CSR
  buses have numbers 31 (BSP socket) and 63 (second socket), and there
  is no functions pci0.31.0.0 or pci0.63.0.0.  According to the CPU
  datasheet, all devices on the uncore bus occupy slots >= 8.
  
  Practically, the attach to config buses is required for the intel-pcm
  pcm-memory.x tool to work, for instance.
  
  Reviewed by:  jhb (previous version)
  Sponsored by: Mellanox Technologies
  MFC after:1 week
  Differential revision:https://reviews.freebsd.org/D12268

Modified:
  head/sys/x86/pci/qpi.c

Modified: head/sys/x86/pci/qpi.c
==
--- head/sys/x86/pci/qpi.c  Fri Sep  8 19:45:37 2017(r323326)
+++ head/sys/x86/pci/qpi.c  Fri Sep  8 19:51:03 2017(r323327)
@@ -63,13 +63,19 @@ static MALLOC_DEFINE(M_QPI, "qpidrv", "qpi system devi
 static void
 qpi_identify(driver_t *driver, device_t parent)
 {
+   int do_qpi;
 
/* Check CPUID to ensure this is an i7 CPU of some sort. */
-   if (!(cpu_vendor_id == CPU_VENDOR_INTEL &&
-   CPUID_TO_FAMILY(cpu_id) == 0x6 &&
-   (CPUID_TO_MODEL(cpu_id) == 0x1a || CPUID_TO_MODEL(cpu_id) == 0x2c)))
+   if (cpu_vendor_id != CPU_VENDOR_INTEL ||
+   CPUID_TO_FAMILY(cpu_id) != 0x6)
return;
 
+   /* Only discover buses with configuration devices if allowed by user */
+   do_qpi = 0;
+   TUNABLE_INT_FETCH("hw.attach_intel_csr_pci", &do_qpi);
+   if (!do_qpi)
+   return;
+
/* PCI config register access is required. */
if (pci_cfgregopen() == 0)
return;
@@ -97,6 +103,7 @@ qpi_probe_pcib(device_t dev, int bus)
struct qpi_device *qdev;
device_t child;
uint32_t devid;
+   int s;
 
/*
 * If a PCI bus already exists for this bus number, then
@@ -106,18 +113,23 @@ qpi_probe_pcib(device_t dev, int bus)
return (EEXIST);
 
/*
-* Attempt to read the device id for device 0, function 0 on
-* the bus.  A value of 0x means that the bus is not
-* present.
+* Attempt to read the device id for every slot, function 0 on
+* the bus.  If all read values are 0x this means that
+* the bus is not present.
 */
-   devid = pci_cfgregread(bus, 0, 0, PCIR_DEVVENDOR, 4);
+   for (s = 0; s <= PCI_SLOTMAX; s++) {
+   devid = pci_cfgregread(bus, s, 0, PCIR_DEVVENDOR, 4);
+   if (devid != 0x)
+   break;
+   }
if (devid == 0x)
return (ENOENT);
 
if ((devid & 0x) != 0x8086) {
-   device_printf(dev,
-   "Device at pci%d.0.0 has non-Intel vendor 0x%x\n", bus,
-   devid & 0x);
+   if (bootverbose)
+   device_printf(dev,
+   "Device at pci%d.%d.0 has non-Intel vendor 0x%x\n",
+   bus, s, devid & 0x);
return (ENXIO);
}
 
@@ -137,12 +149,12 @@ qpi_attach(device_t dev)
int bus;
 
/*
-* Each processor socket has a dedicated PCI bus counting down from
-* 255.  We keep probing buses until one fails.
+* Each processor socket has a dedicated PCI bus, sometimes
+* not enumerated by ACPI.  Probe all unattached buses from 0
+* to 255.
 */
-   for (bus = 255;; bus--)
-   if (qpi_probe_pcib(dev, bus) != 0)
-   break;
+   for (bus = PCI_BUSMAX; bus >= 0; bus--)
+   qpi_probe_pcib(dev, bus);
 
return (bus_generic_attach(dev));
 }
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r323326 - head/sys/x86/iommu

2017-09-08 Thread Konstantin Belousov
Author: kib
Date: Fri Sep  8 19:45:37 2017
New Revision: 323326
URL: https://svnweb.freebsd.org/changeset/base/323326

Log:
  Use IOAPIC PCI rid as the interrupt TLP source id for DMAR interrupt
  remapping.
  
  VT-d specification requires use of PCI rid as source id for IOAPICs
  enumerated by PCI bus.  The values from the DMAR ACPI table should be
  only used when IOAPIC is not on PCI.
  
  Reviewed by:  jhb
  Sponsored by: The FreeBSD Foundation
  Hardware provided by: Intel
  MFC after:2 weeks
  Differential revision:https://reviews.freebsd.org/D12205

Modified:
  head/sys/x86/iommu/intel_drv.c

Modified: head/sys/x86/iommu/intel_drv.c
==
--- head/sys/x86/iommu/intel_drv.c  Fri Sep  8 19:39:20 2017
(r323325)
+++ head/sys/x86/iommu/intel_drv.c  Fri Sep  8 19:45:37 2017
(r323326)
@@ -71,6 +71,9 @@ __FBSDID("$FreeBSD$");
 
 #ifdef DEV_APIC
 #include "pcib_if.h"
+#include 
+#include 
+#include 
 #endif
 
 #defineDMAR_FAULT_IRQ_RID  0
@@ -788,6 +791,9 @@ dmar_find_nonpci(u_int id, u_int entry_type, uint16_t 
ACPI_DMAR_DEVICE_SCOPE *devscope;
ACPI_DMAR_PCI_PATH *path;
char *ptr, *ptrend;
+#ifdef DEV_APIC
+   int error;
+#endif
int i;
 
for (i = 0; i < dmar_devcnt; i++) {
@@ -809,6 +815,17 @@ dmar_find_nonpci(u_int id, u_int entry_type, uint16_t 
continue;
if (devscope->EnumerationId != id)
continue;
+#ifdef DEV_APIC
+   if (entry_type == ACPI_DMAR_SCOPE_TYPE_IOAPIC) {
+   error = ioapic_get_rid(id, rid);
+   /*
+* If our IOAPIC has PCI bindings then
+* use the PCI device rid.
+*/
+   if (error == 0)
+   return (unit);
+   }
+#endif
if (devscope->Length - sizeof(ACPI_DMAR_DEVICE_SCOPE)
== 2) {
if (rid != NULL) {
@@ -818,12 +835,11 @@ dmar_find_nonpci(u_int id, u_int entry_type, uint16_t 
path->Device, path->Function);
}
return (unit);
-   } else {
-   /* XXXKIB */
-   printf(
-  "dmar_find_nonpci: id %d type %d path length != 2\n",
-   id, entry_type);
}
+   printf(
+  "dmar_find_nonpci: id %d type %d path length != 2\n",
+   id, entry_type);
+   break;
}
}
return (NULL);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r323325 - in head/sys/x86: include x86

2017-09-08 Thread Konstantin Belousov
Author: kib
Date: Fri Sep  8 19:39:20 2017
New Revision: 323325
URL: https://svnweb.freebsd.org/changeset/base/323325

Log:
  Add an ioapic_get_rid() function to obtain PCIe TLP requester-id for
  the interrupt messages from given IOAPIC, if the IOAPIC can be
  enumerated on PCI bus.
  
  If IOAPIC has PCI binding, match the PCI device against MADT
  enumerated IOAPIC.  Match is done first by registers window physical
  address, then by IOAPIC ID as read from the APIC ID register.
  
  PCI bsf address of the matched PCI device is the rid.
  
  Reviewed by:  jhb
  Sponsored by: The FreeBSD Foundation
  Hardware provided by: Intel
  MFC after:2 weeks
  X-Differential revision:  https://reviews.freebsd.org/D12205

Modified:
  head/sys/x86/include/apicvar.h
  head/sys/x86/x86/io_apic.c

Modified: head/sys/x86/include/apicvar.h
==
--- head/sys/x86/include/apicvar.h  Fri Sep  8 19:25:11 2017
(r323324)
+++ head/sys/x86/include/apicvar.h  Fri Sep  8 19:39:20 2017
(r323325)
@@ -478,6 +478,8 @@ voidlapic_handle_error(void);
 void   lapic_handle_intr(int vector, struct trapframe *frame);
 void   lapic_handle_timer(struct trapframe *frame);
 
+intioapic_get_rid(u_int apic_id, uint16_t *ridp);
+
 extern int x2apic_mode;
 extern int lapic_eoi_suppression;
 

Modified: head/sys/x86/x86/io_apic.c
==
--- head/sys/x86/x86/io_apic.c  Fri Sep  8 19:25:11 2017(r323324)
+++ head/sys/x86/x86/io_apic.c  Fri Sep  8 19:39:20 2017(r323325)
@@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -99,6 +100,9 @@ struct ioapic {
volatile ioapic_t *io_addr; /* XXX: should use bus_space */
vm_paddr_t io_paddr;
STAILQ_ENTRY(ioapic) io_next;
+   device_t pci_dev;   /* matched pci device, if found */
+   struct resource *pci_wnd;   /* BAR 0, should be same or alias to
+  io_paddr */
struct ioapic_intsrc io_pins[0];
 };
 
@@ -622,6 +626,8 @@ ioapic_create(vm_paddr_t addr, int32_t apic_id, int in
io = malloc(sizeof(struct ioapic) +
numintr * sizeof(struct ioapic_intsrc), M_IOAPIC, M_WAITOK);
io->io_pic = ioapic_template;
+   io->pci_dev = NULL;
+   io->pci_wnd = NULL;
mtx_lock_spin(&icu_lock);
io->io_id = next_id++;
io->io_apic_id = ioapic_read(apic, IOAPIC_ID) >> APIC_ID_SHIFT;
@@ -954,7 +960,72 @@ ioapic_pci_probe(device_t dev)
 static int
 ioapic_pci_attach(device_t dev)
 {
+   struct resource *res;
+   volatile ioapic_t *apic;
+   struct ioapic *io;
+   int rid;
+   u_int apic_id;
 
+   /*
+* Try to match the enumerated ioapic.  Match BAR start
+* against io_paddr.  Due to a fear that PCI window is not the
+* same as the MADT reported io window, but an alias, read the
+* APIC ID from the mapped BAR and match against it.
+*/
+   rid = PCIR_BAR(0);
+   res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
+   RF_ACTIVE | RF_SHAREABLE);
+   if (res == NULL) {
+   if (bootverbose)
+   device_printf(dev, "cannot activate BAR0\n");
+   return (ENXIO);
+   }
+   apic = (volatile ioapic_t *)rman_get_virtual(res);
+   if (rman_get_size(res) < IOAPIC_WND_SIZE) {
+   if (bootverbose)
+   device_printf(dev,
+   "BAR0 too small (%jd) for IOAPIC window\n",
+   (uintmax_t)rman_get_size(res));
+   goto fail;
+   }
+   mtx_lock_spin(&icu_lock);
+   apic_id = ioapic_read(apic, IOAPIC_ID) >> APIC_ID_SHIFT;
+   /* First match by io window address */
+   STAILQ_FOREACH(io, &ioapic_list, io_next) {
+   if (io->io_paddr == (vm_paddr_t)rman_get_start(res))
+   goto found;
+   }
+   /* Then by apic id */
+   STAILQ_FOREACH(io, &ioapic_list, io_next) {
+   if (io->io_id == apic_id)
+   goto found;
+   }
+   mtx_unlock_spin(&icu_lock);
+   if (bootverbose)
+   device_printf(dev,
+   "cannot match pci bar apic id %d against MADT\n",
+   apic_id);
+fail:
+   bus_release_resource(dev, SYS_RES_MEMORY, rid, res);
+   return (ENXIO);
+found:
+   KASSERT(io->pci_dev == NULL,
+   ("ioapic %d pci_dev not NULL", io->io_id));
+   KASSERT(io->pci_wnd == NULL,
+   ("ioapic %d pci_wnd not NULL", io->io_id));
+
+   io->pci_dev = dev;
+   io->pci_wnd = res;
+   if (bootverbose && (io->io_paddr != (vm_paddr_t)rman_get_start(res) ||
+   io->io_id != apic_id)) {
+   device_printf(dev, "pci%d:%d:%d:%d pci BAR0@%jx id %d "
+

svn commit: r323324 - head/sys/x86/include

2017-09-08 Thread Konstantin Belousov
Author: kib
Date: Fri Sep  8 19:25:11 2017
New Revision: 323324
URL: https://svnweb.freebsd.org/changeset/base/323324

Log:
  Add a constant specifying the min size of the IOAPIC registers window.
  
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week

Modified:
  head/sys/x86/include/apicreg.h

Modified: head/sys/x86/include/apicreg.h
==
--- head/sys/x86/include/apicreg.h  Fri Sep  8 19:20:42 2017
(r323323)
+++ head/sys/x86/include/apicreg.h  Fri Sep  8 19:25:11 2017
(r323324)
@@ -469,6 +469,8 @@ typedef struct IOAPIC ioapic_t;
 #define IOAPIC_WINDOW  0x10
 #define IOAPIC_EOIR0x40
 
+#defineIOAPIC_WND_SIZE 0x50
+
 /* indexes into IO APIC */
 #define IOAPIC_ID  0x00
 #define IOAPIC_VER 0x01
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r323323 - head/share/mk

2017-09-08 Thread Bryan Drewery
Author: bdrewery
Date: Fri Sep  8 19:20:42 2017
New Revision: 323323
URL: https://svnweb.freebsd.org/changeset/base/323323

Log:
  Tweak comment for install -S usage since it does not impact the build.
  
  The -S flag is currently ignored for builds since we filter through
  tools/install.sh that is intended for both non-root and cross-builds.
  
  Sponsored by: Dell EMC Isilon
  X-MFC-With:   r322565

Modified:
  head/share/mk/bsd.lib.mk

Modified: head/share/mk/bsd.lib.mk
==
--- head/share/mk/bsd.lib.mkFri Sep  8 18:32:13 2017(r323322)
+++ head/share/mk/bsd.lib.mkFri Sep  8 19:20:42 2017(r323323)
@@ -327,9 +327,9 @@ _EXTRADEPEND:
 SHLINSTALLFLAGS+= -fschg
 .endif
 .endif
-# Install libraries with -S to avoid linker races with WORLDTMP and risk
-# of modifying in-use libraries when installing to a running system.
-# It is safe to avoid this for NO_ROOT builds that are only creating an image.
+# Install libraries with -S to avoid risk of modifying in-use libraries when
+# installing to a running system.  It is safe to avoid this for NO_ROOT builds
+# that are only creating an image.
 .if !defined(NO_SAFE_LIBINSTALL) && !defined(NO_ROOT)
 SHLINSTALLFLAGS+= -S
 .endif
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r323322 - head/sys/compat/freebsd32

2017-09-08 Thread Maxim Sobolev
Author: sobomax
Date: Fri Sep  8 18:32:13 2017
New Revision: 323322
URL: https://svnweb.freebsd.org/changeset/base/323322

Log:
  Correct bintime32 declaration: uint32_t sec -> time32_t sec.
  
  Submitted by: jhb
  MFC after:1 month

Modified:
  head/sys/compat/freebsd32/freebsd32.h

Modified: head/sys/compat/freebsd32/freebsd32.h
==
--- head/sys/compat/freebsd32/freebsd32.h   Fri Sep  8 18:03:34 2017
(r323321)
+++ head/sys/compat/freebsd32/freebsd32.h   Fri Sep  8 18:32:13 2017
(r323322)
@@ -79,7 +79,7 @@ struct itimerspec32 {
 } while (0)
 
 struct bintime32 {
-   uint32_t sec;
+   time32_t sec;
uint32_t frac[2];
 };
 #define BT_CP(src, dst, fld) do {  \
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r323321 - head/sys/dev/bnxt

2017-09-08 Thread Stephen Hurd
Author: shurd
Date: Fri Sep  8 18:03:34 2017
New Revision: 323321
URL: https://svnweb.freebsd.org/changeset/base/323321

Log:
  Added support for displaying HW port stats using sysctl.
  
  This provides port stats (updated once per second) in
  dev.bnxt.X.port_stats for PFs.  VFs do not have access to the port stats.
  
  Submitted by: Bhargava Chenna Marreddy 
  Reviewed by:  shurd, sbruno
  Approved by:  sbruno (mentor)
  Sponsored by: Broadcom Limited
  Differential Revision:https://reviews.freebsd.org/D11914

Modified:
  head/sys/dev/bnxt/bnxt.h
  head/sys/dev/bnxt/bnxt_hwrm.c
  head/sys/dev/bnxt/bnxt_hwrm.h
  head/sys/dev/bnxt/bnxt_sysctl.c
  head/sys/dev/bnxt/bnxt_sysctl.h
  head/sys/dev/bnxt/if_bnxt.c

Modified: head/sys/dev/bnxt/bnxt.h
==
--- head/sys/dev/bnxt/bnxt.hFri Sep  8 17:51:19 2017(r323320)
+++ head/sys/dev/bnxt/bnxt.hFri Sep  8 18:03:34 2017(r323321)
@@ -558,6 +558,7 @@ struct bnxt_softc {
uint8_t max_tc;
struct bnxt_cos_queue   q_info[BNXT_MAX_QUEUE];
 
+   uint64_tadmin_ticks;
struct iflib_dma_info   hw_rx_port_stats;
struct iflib_dma_info   hw_tx_port_stats;
struct rx_port_stats*rx_port_stats;

Modified: head/sys/dev/bnxt/bnxt_hwrm.c
==
--- head/sys/dev/bnxt/bnxt_hwrm.c   Fri Sep  8 17:51:19 2017
(r323320)
+++ head/sys/dev/bnxt/bnxt_hwrm.c   Fri Sep  8 18:03:34 2017
(r323321)
@@ -820,6 +820,25 @@ fail:
 }
 
 int
+bnxt_hwrm_port_qstats(struct bnxt_softc *softc)
+{
+   struct hwrm_port_qstats_input req = {0};
+   int rc = 0;
+
+   bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_PORT_QSTATS);
+
+   req.port_id = htole16(softc->pf.port_id);
+   req.rx_stat_host_addr = htole64(softc->hw_rx_port_stats.idi_paddr);
+   req.tx_stat_host_addr = htole64(softc->hw_tx_port_stats.idi_paddr);
+
+   BNXT_HWRM_LOCK(softc);
+   rc = _hwrm_send_message(softc, &req, sizeof(req));
+   BNXT_HWRM_UNLOCK(softc);
+
+   return rc;
+}
+
+int
 bnxt_hwrm_cfa_l2_set_rx_mask(struct bnxt_softc *softc,
 struct bnxt_vnic_info *vnic)
 {

Modified: head/sys/dev/bnxt/bnxt_hwrm.h
==
--- head/sys/dev/bnxt/bnxt_hwrm.h   Fri Sep  8 17:51:19 2017
(r323320)
+++ head/sys/dev/bnxt/bnxt_hwrm.h   Fri Sep  8 18:03:34 2017
(r323321)
@@ -52,6 +52,7 @@ int bnxt_hwrm_vnic_ctx_alloc(struct bnxt_softc *softc,
 int bnxt_hwrm_vnic_cfg(struct bnxt_softc *softc, struct bnxt_vnic_info *vnic);
 int bnxt_hwrm_stat_ctx_alloc(struct bnxt_softc *softc, struct bnxt_cp_ring 
*cpr,
 uint64_t paddr);
+int bnxt_hwrm_port_qstats(struct bnxt_softc *softc);
 int bnxt_hwrm_ring_grp_alloc(struct bnxt_softc *softc,
 struct bnxt_grp_info *grp);
 int bnxt_hwrm_vnic_alloc(struct bnxt_softc *softc, struct bnxt_vnic_info 
*vnic);

Modified: head/sys/dev/bnxt/bnxt_sysctl.c
==
--- head/sys/dev/bnxt/bnxt_sysctl.c Fri Sep  8 17:51:19 2017
(r323320)
+++ head/sys/dev/bnxt/bnxt_sysctl.c Fri Sep  8 18:03:34 2017
(r323321)
@@ -164,6 +164,456 @@ bnxt_create_tx_sysctls(struct bnxt_softc *softc, int t
 }
 
 int
+bnxt_create_port_stats_sysctls(struct bnxt_softc *softc)
+{
+   struct sysctl_oid *oid;
+   charname[32];
+   chardesc[64];
+
+   sprintf(name, "port_stats");
+   sprintf(desc, "Port Stats");
+   oid = SYSCTL_ADD_NODE(&softc->hw_stats,
+   SYSCTL_CHILDREN(softc->hw_stats_oid), OID_AUTO, name, 
CTLFLAG_RD, 0,
+   desc);
+   if (!oid)
+   return ENOMEM;
+
+   SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+   "tx_64b_frames", CTLFLAG_RD,
+   &softc->tx_port_stats->tx_64b_frames, "Transmitted 64b frames");
+   SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+   "tx_65b_127b_frames", CTLFLAG_RD,
+   &softc->tx_port_stats->tx_65b_127b_frames, 
+   "Transmitted 65b 127b frames");
+   SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+   "tx_128b_255b_frames", CTLFLAG_RD,
+   &softc->tx_port_stats->tx_128b_255b_frames, 
+   "Transmitted 128b 255b frames");
+   SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+   "tx_256b_511b_frames", CTLFLAG_RD,
+   &softc->tx_port_stats->tx_256b_511b_frames, 
+   "Transmitted 256b 511b frames");
+   SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
+   "tx_512b_1023b_frames", CTLFLAG_RD,
+   &softc->tx_port_stats->tx_512b_1023b_frames, 
+   "Transmitted 512b 1023b frames");
+   SYSCTL_ADD_QUAD(&softc->hw_stats, 

svn commit: r323320 - head/sys/dev/mfi

2017-09-08 Thread Scott Long
Author: scottl
Date: Fri Sep  8 17:51:19 2017
New Revision: 323320
URL: https://svnweb.freebsd.org/changeset/base/323320

Log:
  Fix intrhook release in MFI as well

Modified:
  head/sys/dev/mfi/mfi.c

Modified: head/sys/dev/mfi/mfi.c
==
--- head/sys/dev/mfi/mfi.c  Fri Sep  8 17:40:29 2017(r323319)
+++ head/sys/dev/mfi/mfi.c  Fri Sep  8 17:51:19 2017(r323320)
@@ -1263,8 +1263,6 @@ mfi_startup(void *arg)
 
sc = (struct mfi_softc *)arg;
 
-   config_intrhook_disestablish(&sc->mfi_ich);
-
sc->mfi_enable_intr(sc);
sx_xlock(&sc->mfi_config_lock);
mtx_lock(&sc->mfi_io_lock);
@@ -1273,6 +1271,8 @@ mfi_startup(void *arg)
mfi_syspdprobe(sc);
mtx_unlock(&sc->mfi_io_lock);
sx_xunlock(&sc->mfi_config_lock);
+
+   config_intrhook_disestablish(&sc->mfi_ich);
 }
 
 static void
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r323319 - head/sys/dev/amr

2017-09-08 Thread Scott Long
Author: scottl
Date: Fri Sep  8 17:40:29 2017
New Revision: 323319
URL: https://svnweb.freebsd.org/changeset/base/323319

Log:
  As with r323317, hold off on releasing the intrhook during boot until
  we're ready to accept probing from GEOM.  Untested, but the pattern is
  the same as with aac.

Modified:
  head/sys/dev/amr/amr.c

Modified: head/sys/dev/amr/amr.c
==
--- head/sys/dev/amr/amr.c  Fri Sep  8 16:59:56 2017(r323318)
+++ head/sys/dev/amr/amr.c  Fri Sep  8 17:40:29 2017(r323319)
@@ -302,11 +302,6 @@ amr_startup(void *arg)
 
 debug_called(1);
 
-/* pull ourselves off the intrhook chain */
-if (sc->amr_ich.ich_func)
-   config_intrhook_disestablish(&sc->amr_ich);
-sc->amr_ich.ich_func = NULL;
-
 /* get up-to-date drive information */
 if (amr_query_controller(sc)) {
device_printf(sc->amr_dev, "can't scan controller for drives\n");
@@ -342,6 +337,11 @@ amr_startup(void *arg)
 
 /* interrupts will be enabled before we do anything more */
 sc->amr_state |= AMR_STATE_INTEN;
+
+/* pull ourselves off the intrhook chain */
+if (sc->amr_ich.ich_func)
+   config_intrhook_disestablish(&sc->amr_ich);
+sc->amr_ich.ich_func = NULL;
 
 return;
 }
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r323254 - head/sys/compat/freebsd32

2017-09-08 Thread John Baldwin
On 9/8/17 10:56 AM, Ian Lepore wrote:
> On Fri, 2017-09-08 at 08:14 -0400, John Baldwin wrote:
>> On 9/7/17 12:29 AM, Maxim Sobolev wrote:
>>>
>>> Author: sobomax
>>> Date: Thu Sep  7 04:29:57 2017
>>> New Revision: 323254
>>> URL: https://svnweb.freebsd.org/changeset/base/323254
>>>
>>> Log:
>>>   In the recvmsg32() system call iterate over returned structure(s)
>>>   and convert any messages of types SCM_BINTIME, SCM_TIMESTAMP,
>>>   SCM_REALTIME and SCM_MONOTONIC from 64-bit to its 32-bit
>>>   representation. Otherwise we either run out of user-supplied
>>>   buffer to copy those out resulting in the MSG_CTRUNC or simply
>>>   return values that the userland 32-bit code is not going
>>>   to parse correctly. This fixes at least two regression tests
>>>   failing to function properly in 32-bit compat mode:
>>>   
>>>   tools/regression/sockets/udp_pingpong
>>>   tools/regression/sockets/unix_cmsg
>>>   
>>>   PR: kern/222039
>>>   MFC after:30 days
>> Is this correct on !amd64?  Other 32-bit platforms use a 64-bit time_t
>> (note the time32_t type defined earlier in freebsd32.h).  struct bintime32
>> should use time32_t for the seconds field, not uint32_t.  I think that
>> will be sufficient to make this correct on !amd64 (it also means that
>> bintime32 == bintime on !amd64 so you could perhaps use a simpler BT_CP
>> for !amd64, but the existing one is probably ok).
>>
> 
> The existing one now does *(uint64_t *) on a value that's only aligned
> to a 32-bit boundary.  That will work in practice because only i386 has
> a 32-bit time_t that will use this code, and it's not a strict-
> alignment platform.  It may still cause compiler warnings about
> alignment.

Mmmm, the code is used on ppc and mips as well (and mips will fault for
unaligned access at least).  However, once bintime32 is fixed to use
time32_t I think the fraction will be 64-bit aligned?  I would be fine
with BT_CP() being an #ifdef though that just uses "(dst) = (src)" for
!amd64.

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

svn commit: r323317 - head/sys/dev/aac

2017-09-08 Thread Scott Long
Author: scottl
Date: Fri Sep  8 16:52:59 2017
New Revision: 323317
URL: https://svnweb.freebsd.org/changeset/base/323317

Log:
  Move the intrhook release to later in the function so that GEOM knows to wait 
longer
  for possible root devices to come online.  This fixes a race that seems to be
  triggered by EARLY_AP_STARTUP.
  
  Submitted by: cg...@glup.org

Modified:
  head/sys/dev/aac/aac.c

Modified: head/sys/dev/aac/aac.c
==
--- head/sys/dev/aac/aac.c  Fri Sep  8 15:44:52 2017(r323316)
+++ head/sys/dev/aac/aac.c  Fri Sep  8 16:52:59 2017(r323317)
@@ -418,9 +418,6 @@ aac_startup(void *arg)
sc = (struct aac_softc *)arg;
fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "");
 
-   /* disconnect ourselves from the intrhook chain */
-   config_intrhook_disestablish(&sc->aac_ich);
-
mtx_lock(&sc->aac_io_lock);
aac_alloc_sync_fib(sc, &fib);
 
@@ -437,12 +434,15 @@ aac_startup(void *arg)
aac_release_sync_fib(sc);
mtx_unlock(&sc->aac_io_lock);
 
+   /* mark the controller up */
+   sc->aac_state &= ~AAC_STATE_SUSPEND;
+
/* poke the bus to actually attach the child devices */
if (bus_generic_attach(sc->aac_dev))
device_printf(sc->aac_dev, "bus_generic_attach failed\n");
 
-   /* mark the controller up */
-   sc->aac_state &= ~AAC_STATE_SUSPEND;
+   /* disconnect ourselves from the intrhook chain */
+   config_intrhook_disestablish(&sc->aac_ich);
 
/* enable interrupts now */
AAC_UNMASK_INTERRUPTS(sc);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r323316 - head/lib/libgeom

2017-09-08 Thread Conrad Meyer
Author: cem
Date: Fri Sep  8 15:44:52 2017
New Revision: 323316
URL: https://svnweb.freebsd.org/changeset/base/323316

Log:
  libgeom: Remove redundant and duplicated code
  
  In g_open(), g_device_path_open().
  
  No functional change.
  
  Sponsored by: Dell EMC Isilon

Modified:
  head/lib/libgeom/geom_util.c

Modified: head/lib/libgeom/geom_util.c
==
--- head/lib/libgeom/geom_util.cFri Sep  8 15:38:02 2017
(r323315)
+++ head/lib/libgeom/geom_util.cFri Sep  8 15:44:52 2017
(r323316)
@@ -56,8 +56,6 @@ g_open(const char *name, int dowrite)
path = g_device_path_open(name, &fd, dowrite);
if (path != NULL)
free(path);
-   if (fd == -1)
-   return (-1);
return (fd);
 }
 
@@ -281,58 +279,45 @@ g_device_path_open(const char *devpath, int *fdp, int 
/* Make sure that we can fail. */
if (fdp != NULL)
*fdp = -1;
+
/* Use the device node if we're able to open it. */
-   do {
-   fd = open(devpath, dowrite ? O_RDWR : O_RDONLY);
-   if (fd == -1)
-   break;
-   /*
-* Let try to get sectorsize, which will prove it is a GEOM
-* provider. 
-*/
-   if (g_sectorsize(fd) == -1) {
-   close(fd);
-   errno = EFTYPE;
-   return (NULL);
-   }
+   fd = open(devpath, dowrite ? O_RDWR : O_RDONLY);
+   if (fd != -1) {
if ((path = strdup(devpath)) == NULL) {
close(fd);
return (NULL);
}
-   if (fdp != NULL)
-   *fdp = fd;
-   else
-   close(fd);
-   return (path);
-   } while (0);
+   goto fd_ok;
+   }
 
/* If we're not given an absolute path, assume /dev/ prefix. */
-   if (*devpath != '/') {
-   asprintf(&path, "%s%s", _PATH_DEV, devpath);
-   if (path == NULL)
-   return (NULL);
-   fd = open(path, dowrite ? O_RDWR : O_RDONLY);
-   if (fd == -1) {
-   free(path);
-   return (NULL);
-   }
-   /*
-* Let try to get sectorsize, which will prove it is a GEOM
-* provider.
-*/
-   if (g_sectorsize(fd) == -1) {
-   free(path);
-   close(fd);
-   errno = EFTYPE;
-   return (NULL);
-   }
-   if (fdp != NULL)
-   *fdp = fd;
-   else
-   close(fd);
-   return (path);
+   if (*devpath == '/')
+   return (NULL);
+
+   asprintf(&path, "%s%s", _PATH_DEV, devpath);
+   if (path == NULL)
+   return (NULL);
+   fd = open(path, dowrite ? O_RDWR : O_RDONLY);
+   if (fd == -1) {
+   free(path);
+   return (NULL);
}
-   return (NULL);
+
+fd_ok:
+   /*
+* Let try to get sectorsize, which will prove it is a GEOM provider.
+*/
+   if (g_sectorsize(fd) == -1) {
+   free(path);
+   close(fd);
+   errno = EFTYPE;
+   return (NULL);
+   }
+   if (fdp != NULL)
+   *fdp = fd;
+   else
+   close(fd);
+   return (path);
 }
 
 char *
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r323315 - head/sbin/geom/class/virstor

2017-09-08 Thread Conrad Meyer
Author: cem
Date: Fri Sep  8 15:38:02 2017
New Revision: 323315
URL: https://svnweb.freebsd.org/changeset/base/323315

Log:
  geom_virstor: Remove wholly unnecessary g_metadata_store copy
  
  Just code cleanup.  No functional change.
  
  Sponsored by: Dell EMC Isilon

Modified:
  head/sbin/geom/class/virstor/geom_virstor.c

Modified: head/sbin/geom/class/virstor/geom_virstor.c
==
--- head/sbin/geom/class/virstor/geom_virstor.c Fri Sep  8 15:08:17 2017
(r323314)
+++ head/sbin/geom/class/virstor/geom_virstor.c Fri Sep  8 15:38:02 2017
(r323315)
@@ -140,62 +140,6 @@ virstor_main(struct gctl_req *req, unsigned flags)
*/
 }
 
-static void
-pathgen(const char *name, char *path, size_t size)
-{
-
-   if (strncmp(name, _PATH_DEV, sizeof(_PATH_DEV) - 1) != 0)
-   snprintf(path, size, "%s%s", _PATH_DEV, name);
-   else
-   strlcpy(path, name, size);
-}
-
-static int
-my_g_metadata_store(const char *name, u_char *md, size_t size)
-{
-   char path[MAXPATHLEN];
-   unsigned sectorsize;
-   off_t mediasize;
-   u_char *sector;
-   int error, fd;
-
-   pathgen(name, path, sizeof(path));
-   sector = NULL;
-   error = 0;
-
-   fd = open(path, O_RDWR);
-   if (fd == -1)
-   return (errno);
-   mediasize = g_get_mediasize(name);
-   if (mediasize == 0) {
-   error = errno;
-   goto out;
-   }
-   sectorsize = g_get_sectorsize(name);
-   if (sectorsize == 0) {
-   error = errno;
-   goto out;
-   }
-   assert(sectorsize >= size);
-   sector = malloc(sectorsize);
-   if (sector == NULL) {
-   error = ENOMEM;
-   goto out;
-   }
-   bcopy(md, sector, size);
-   bzero(sector + size, sectorsize - size);
-   if (pwrite(fd, sector, sectorsize, mediasize - sectorsize) !=
-   (ssize_t)sectorsize) {
-   error = errno;
-   goto out;
-   }
-out:
-   if (sector != NULL)
-   free(sector);
-   close(fd);
-   return (error);
-}
-
 /*
  * Labels a new geom Meaning: parses and checks the parameters, calculates &
  * writes metadata to the relevant providers so when the next round of
@@ -465,7 +409,7 @@ virstor_label(struct gctl_req *req)
err(1, "Cannot allocate sector of %zu bytes", ssize);
bzero(sect, ssize);
virstor_metadata_encode(&md, sect);
-   error = my_g_metadata_store(name, sect, ssize);
+   error = g_metadata_store(name, sect, ssize);
free(sect);
if (error != 0) {
if (verbose)
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r323254 - head/sys/compat/freebsd32

2017-09-08 Thread Ian Lepore
On Fri, 2017-09-08 at 08:14 -0400, John Baldwin wrote:
> On 9/7/17 12:29 AM, Maxim Sobolev wrote:
> > 
> > Author: sobomax
> > Date: Thu Sep  7 04:29:57 2017
> > New Revision: 323254
> > URL: https://svnweb.freebsd.org/changeset/base/323254
> > 
> > Log:
> >   In the recvmsg32() system call iterate over returned structure(s)
> >   and convert any messages of types SCM_BINTIME, SCM_TIMESTAMP,
> >   SCM_REALTIME and SCM_MONOTONIC from 64-bit to its 32-bit
> >   representation. Otherwise we either run out of user-supplied
> >   buffer to copy those out resulting in the MSG_CTRUNC or simply
> >   return values that the userland 32-bit code is not going
> >   to parse correctly. This fixes at least two regression tests
> >   failing to function properly in 32-bit compat mode:
> >   
> >   tools/regression/sockets/udp_pingpong
> >   tools/regression/sockets/unix_cmsg
> >   
> >   PR: kern/222039
> >   MFC after:30 days
> Is this correct on !amd64?  Other 32-bit platforms use a 64-bit time_t
> (note the time32_t type defined earlier in freebsd32.h).  struct bintime32
> should use time32_t for the seconds field, not uint32_t.  I think that
> will be sufficient to make this correct on !amd64 (it also means that
> bintime32 == bintime on !amd64 so you could perhaps use a simpler BT_CP
> for !amd64, but the existing one is probably ok).
> 

The existing one now does *(uint64_t *) on a value that's only aligned
to a 32-bit boundary.  That will work in practice because only i386 has
a 32-bit time_t that will use this code, and it's not a strict-
alignment platform.  It may still cause compiler warnings about
alignment.

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


svn commit: r323314 - in head/sbin/geom: class/virstor misc

2017-09-08 Thread Conrad Meyer
Author: cem
Date: Fri Sep  8 15:08:17 2017
New Revision: 323314
URL: https://svnweb.freebsd.org/changeset/base/323314

Log:
  Audit userspace geom code for leaking memory to disk
  
  Any geom class using g_metadata_store, as well as geom_virstor which
  duplicated g_metadata_store internally, would dump sectorsize - mdsize bytes
  of userspace memory following the metadata block stored. This is most or all
  geom classes (gcache, gconcat, geli, gjournal, glabel, gmirror, gmultipath,
  graid3, gshsec, gstripe, and geom_virstor).
  
  PR:   222077 (comment #3)
  Reported by:  Maxim Khitrov 
  Reviewed by:  des
  Security: yes
  Sponsored by: Dell EMC Isilon
  Differential Revision:https://reviews.freebsd.org/D12269

Modified:
  head/sbin/geom/class/virstor/geom_virstor.c
  head/sbin/geom/misc/subr.c

Modified: head/sbin/geom/class/virstor/geom_virstor.c
==
--- head/sbin/geom/class/virstor/geom_virstor.c Fri Sep  8 14:56:26 2017
(r323313)
+++ head/sbin/geom/class/virstor/geom_virstor.c Fri Sep  8 15:08:17 2017
(r323314)
@@ -183,6 +183,7 @@ my_g_metadata_store(const char *name, u_char *md, size
goto out;
}
bcopy(md, sector, size);
+   bzero(sector + size, sectorsize - size);
if (pwrite(fd, sector, sectorsize, mediasize - sectorsize) !=
(ssize_t)sectorsize) {
error = errno;

Modified: head/sbin/geom/misc/subr.c
==
--- head/sbin/geom/misc/subr.c  Fri Sep  8 14:56:26 2017(r323313)
+++ head/sbin/geom/misc/subr.c  Fri Sep  8 15:08:17 2017(r323314)
@@ -302,6 +302,7 @@ g_metadata_store(const char *name, const unsigned char
goto out;
}
bcopy(md, sector, size);
+   bzero(sector + size, sectorsize - size);
if (pwrite(fd, sector, sectorsize, mediasize - sectorsize) !=
sectorsize) {
error = errno;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r323312 - head/sys/dev/e1000

2017-09-08 Thread Konstantin Belousov
Author: kib
Date: Fri Sep  8 14:54:07 2017
New Revision: 323312
URL: https://svnweb.freebsd.org/changeset/base/323312

Log:
  Fix malloc() uses in em_get_regs().
  
  Do not use malloc(M_NOWAIT), wait is possible there, and the malloc
  failures where not checked.  Do not forget to free malloced memory.
  
  Reported and tested by:   pho
  Approved by:  sbruno
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/dev/e1000/if_em.c

Modified: head/sys/dev/e1000/if_em.c
==
--- head/sys/dev/e1000/if_em.c  Fri Sep  8 14:35:17 2017(r323311)
+++ head/sys/dev/e1000/if_em.c  Fri Sep  8 14:54:07 2017(r323312)
@@ -534,22 +534,26 @@ static int em_get_regs(SYSCTL_HANDLER_ARGS)
 {
struct adapter *adapter = (struct adapter *)arg1;
struct e1000_hw *hw = &adapter->hw;
-
struct sbuf *sb;
-   u32 *regs_buff = (u32 *)malloc(sizeof(u32) * IGB_REGS_LEN, M_DEVBUF, 
M_NOWAIT);
+   u32 *regs_buff;
int rc;
 
+   regs_buff = malloc(sizeof(u32) * IGB_REGS_LEN, M_DEVBUF, M_WAITOK);
memset(regs_buff, 0, IGB_REGS_LEN * sizeof(u32));
 
rc = sysctl_wire_old_buffer(req, 0);
MPASS(rc == 0);
-   if (rc != 0)
+   if (rc != 0) {
+   free(regs_buff, M_DEVBUF);
return (rc);
+   }
 
sb = sbuf_new_for_sysctl(NULL, NULL, 32*400, req);
MPASS(sb != NULL);
-   if (sb == NULL)
+   if (sb == NULL) {
+   free(regs_buff, M_DEVBUF);
return (ENOMEM);
+   }
 
/* General Registers */
regs_buff[0] = E1000_READ_REG(hw, E1000_CTRL);
@@ -604,6 +608,8 @@ static int em_get_regs(SYSCTL_HANDLER_ARGS)
sbuf_printf(sb, "\tTDFT\t %08x\n", regs_buff[19]);
sbuf_printf(sb, "\tTDFHS\t %08x\n", regs_buff[20]);
sbuf_printf(sb, "\tTDFPC\t %08x\n\n", regs_buff[21]);
+
+   free(regs_buff, M_DEVBUF);
 
 #ifdef DUMP_DESCS
{
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r323311 - svnadmin/conf

2017-09-08 Thread Pedro F. Giffuni
Author: pfg
Date: Fri Sep  8 14:35:17 2017
New Revision: 323311
URL: https://svnweb.freebsd.org/changeset/base/323311

Log:
  Add Fedor Uporov (fsu@) as a src committer.
  
  He will be having fun with the ext2fs driver and perhaps other slightly
  related places.
  
  Approved by:  core

Modified:
  svnadmin/conf/access
  svnadmin/conf/mentors

Modified: svnadmin/conf/access
==
--- svnadmin/conf/accessFri Sep  8 10:39:28 2017(r323310)
+++ svnadmin/conf/accessFri Sep  8 14:35:17 2017(r323311)
@@ -73,6 +73,7 @@ eri
 erj
 fabient
 fanf
+fsu
 gabor
 gad
 gallatin

Modified: svnadmin/conf/mentors
==
--- svnadmin/conf/mentors   Fri Sep  8 10:39:28 2017(r323310)
+++ svnadmin/conf/mentors   Fri Sep  8 14:35:17 2017(r323311)
@@ -16,6 +16,7 @@ arichardson   jhb Co-mentor: brooks
 dabvangyzen
 defpjd
 eriae  Co-mentor: thompsa
+fsupfg
 gordon delphij Co-mentor: emaste
 ivadaszadrian  Co-mentor: cognet
 jceel  trasz
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r323254 - head/sys/compat/freebsd32

2017-09-08 Thread John Baldwin
On 9/7/17 12:29 AM, Maxim Sobolev wrote:
> Author: sobomax
> Date: Thu Sep  7 04:29:57 2017
> New Revision: 323254
> URL: https://svnweb.freebsd.org/changeset/base/323254
> 
> Log:
>   In the recvmsg32() system call iterate over returned structure(s)
>   and convert any messages of types SCM_BINTIME, SCM_TIMESTAMP,
>   SCM_REALTIME and SCM_MONOTONIC from 64-bit to its 32-bit
>   representation. Otherwise we either run out of user-supplied
>   buffer to copy those out resulting in the MSG_CTRUNC or simply
>   return values that the userland 32-bit code is not going
>   to parse correctly. This fixes at least two regression tests
>   failing to function properly in 32-bit compat mode:
>   
>   tools/regression/sockets/udp_pingpong
>   tools/regression/sockets/unix_cmsg
>   
>   PR: kern/222039
>   MFC after:  30 days

Is this correct on !amd64?  Other 32-bit platforms use a 64-bit time_t
(note the time32_t type defined earlier in freebsd32.h).  struct bintime32
should use time32_t for the seconds field, not uint32_t.  I think that
will be sufficient to make this correct on !amd64 (it also means that
bintime32 == bintime on !amd64 so you could perhaps use a simpler BT_CP
for !amd64, but the existing one is probably ok).

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


svn commit: r323310 - head/sys/x86/pci

2017-09-08 Thread Konstantin Belousov
Author: kib
Date: Fri Sep  8 10:39:28 2017
New Revision: 323310
URL: https://svnweb.freebsd.org/changeset/base/323310

Log:
  Consistently use tabs for indent.
  
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week

Modified:
  head/sys/x86/pci/qpi.c

Modified: head/sys/x86/pci/qpi.c
==
--- head/sys/x86/pci/qpi.c  Fri Sep  8 08:02:06 2017(r323309)
+++ head/sys/x86/pci/qpi.c  Fri Sep  8 10:39:28 2017(r323310)
@@ -64,15 +64,15 @@ static void
 qpi_identify(driver_t *driver, device_t parent)
 {
 
-/* Check CPUID to ensure this is an i7 CPU of some sort. */
-if (!(cpu_vendor_id == CPU_VENDOR_INTEL &&
+   /* Check CPUID to ensure this is an i7 CPU of some sort. */
+   if (!(cpu_vendor_id == CPU_VENDOR_INTEL &&
CPUID_TO_FAMILY(cpu_id) == 0x6 &&
(CPUID_TO_MODEL(cpu_id) == 0x1a || CPUID_TO_MODEL(cpu_id) == 0x2c)))
-return;
+   return;
 
-/* PCI config register access is required. */
-if (pci_cfgregopen() == 0)
-return;
+   /* PCI config register access is required. */
+   if (pci_cfgregopen() == 0)
+   return;
 
/* Add a qpi bus device. */
if (BUS_ADD_CHILD(parent, 20, "qpi", -1) == NULL)
@@ -219,7 +219,7 @@ qpi_pcib_attach(device_t dev)
 {
 
device_add_child(dev, "pci", -1);
-return (bus_generic_attach(dev));
+   return (bus_generic_attach(dev));
 }
 
 static int
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r323309 - head/sys/arm64/arm64

2017-09-08 Thread Andrew Turner
Author: andrew
Date: Fri Sep  8 08:02:06 2017
New Revision: 323309
URL: https://svnweb.freebsd.org/changeset/base/323309

Log:
  Not all CPUs handle reading ID_AA64MMFR2_EL1 (e.g. qemu), disable it for now.
  
  Sponsored by: DARPA, AFRL

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

Modified: head/sys/arm64/arm64/identcpu.c
==
--- head/sys/arm64/arm64/identcpu.c Fri Sep  8 06:57:11 2017
(r323308)
+++ head/sys/arm64/arm64/identcpu.c Fri Sep  8 08:02:06 2017
(r323309)
@@ -897,7 +897,11 @@ identify_cpu(void)
cpu_desc[cpu].id_aa64isar1 = READ_SPECIALREG(ID_AA64ISAR1_EL1);
cpu_desc[cpu].id_aa64mmfr0 = READ_SPECIALREG(ID_AA64MMFR0_EL1);
cpu_desc[cpu].id_aa64mmfr1 = READ_SPECIALREG(ID_AA64MMFR1_EL1);
+#ifdef NOTYET
cpu_desc[cpu].id_aa64mmfr2 = READ_SPECIALREG(ID_AA64MMFR2_EL1);
+#else
+   cpu_desc[cpu].id_aa64mmfr2 = 0;
+#endif
cpu_desc[cpu].id_aa64pfr0 = READ_SPECIALREG(ID_AA64PFR0_EL1);
cpu_desc[cpu].id_aa64pfr1 = READ_SPECIALREG(ID_AA64PFR1_EL1);
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"