svn commit: r285622 - in head/sys: compat/cloudabi kern sys

2015-07-16 Thread Ed Schouten
Author: ed
Date: Thu Jul 16 07:05:42 2015
New Revision: 285622
URL: https://svnweb.freebsd.org/changeset/base/285622

Log:
  Implement CloudABI's exec() call.
  
  Summary:
  In a runtime that is purely based on capability-based security, there is
  a strong emphasis on how programs start their execution. We need to make
  sure that we execute an new program with an exact set of file
  descriptors, ensuring that credentials are not leaked into the process
  accidentally.
  
  Providing the right file descriptors is just half the problem. There
  also needs to be a framework in place that gives meaning to these file
  descriptors. How does a CloudABI mail server know which of the file
  descriptors corresponds to the socket that receives incoming emails?
  Furthermore, how will this mail server acquire its configuration
  parameters, as it cannot open a configuration file from a global path on
  disk?
  
  CloudABI solves this problem by replacing traditional string command
  line arguments by tree-like data structure consisting of scalars,
  sequences and mappings (similar to YAML/JSON). In this structure, file
  descriptors are treated as a first-class citizen. When calling exec(),
  file descriptors are passed on to the new executable if and only if they
  are referenced from this tree structure. See the cloudabi-run(1) man
  page for more details and examples (sysutils/cloudabi-utils).
  
  Fortunately, the kernel does not need to care about this tree structure
  at all. The C library is responsible for serializing and deserializing,
  but also for extracting the list of referenced file descriptors. The
  system call only receives a copy of the serialized data and a layout of
  what the new file descriptor table should look like:
  
  int proc_exec(int execfd, const void *data, size_t datalen, const int 
*fds,
size_t fdslen);
  
  This change introduces a set of fd*_remapped() functions:
  
  - fdcopy_remapped() pulls a copy of a file descriptor table, remapping
all of the file descriptors according to the provided mapping table.
  - fdinstall_remapped() replaces the file descriptor table of the process
by the copy created by fdcopy_remapped().
  - fdescfree_remapped() frees the table in case we aborted before
fdinstall_remapped().
  
  We then add a function exec_copyin_data_fds() that builds on top these
  functions. It copies in the data and constructs a new remapped file
  descriptor. This is used by cloudabi_sys_proc_exec().
  
  Test Plan:
  cloudabi-run(1) is capable of spawning processes successfully, providing
  it data and file descriptors. procstat -f seems to confirm all is good.
  Regular FreeBSD processes also work properly.
  
  Reviewers: kib, mjg
  
  Reviewed By: mjg
  
  Subscribers: imp
  
  Differential Revision: https://reviews.freebsd.org/D3079

Modified:
  head/sys/compat/cloudabi/cloudabi_proc.c
  head/sys/kern/kern_descrip.c
  head/sys/kern/kern_exec.c
  head/sys/sys/filedesc.h
  head/sys/sys/imgact.h

Modified: head/sys/compat/cloudabi/cloudabi_proc.c
==
--- head/sys/compat/cloudabi/cloudabi_proc.cThu Jul 16 05:14:20 2015
(r285621)
+++ head/sys/compat/cloudabi/cloudabi_proc.cThu Jul 16 07:05:42 2015
(r285622)
@@ -27,10 +27,12 @@
 __FBSDID("$FreeBSD$");
 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -38,9 +40,16 @@ int
 cloudabi_sys_proc_exec(struct thread *td,
 struct cloudabi_sys_proc_exec_args *uap)
 {
+   struct image_args args;
+   int error;
 
-   /* Not implemented. */
-   return (ENOSYS);
+   error = exec_copyin_data_fds(td, &args, uap->data, uap->datalen,
+   uap->fds, uap->fdslen);
+   if (error == 0) {
+   args.fd = uap->fd;
+   error = kern_execve(td, &args, NULL);
+   }
+   return (error);
 }
 
 int

Modified: head/sys/kern/kern_descrip.c
==
--- head/sys/kern/kern_descrip.cThu Jul 16 05:14:20 2015
(r285621)
+++ head/sys/kern/kern_descrip.cThu Jul 16 07:05:42 2015
(r285622)
@@ -1921,6 +1921,14 @@ fdunshare(struct thread *td)
p->p_fd = tmp;
 }
 
+void
+fdinstall_remapped(struct thread *td, struct filedesc *fdp)
+{
+
+   fdescfree(td);
+   td->td_proc->p_fd = fdp;
+}
+
 /*
  * Copy a filedesc structure.  A NULL pointer in returns a NULL reference,
  * this is to ease callers, not catch errors.
@@ -1960,6 +1968,65 @@ fdcopy(struct filedesc *fdp)
 }
 
 /*
+ * Copies a filedesc structure, while remapping all file descriptors
+ * stored inside using a translation table.
+ *
+ * File descriptors are copied over to the new file descriptor table,
+ * regardless of whether the close-on-exec flag is set.
+ */
+int
+fdcopy_remapped(struct filedesc *fdp, const int *fds, size_t nfds,
+struct filedesc **ret)
+

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

2015-07-16 Thread Kevin Lo
Author: kevlo
Date: Thu Jul 16 08:03:23 2015
New Revision: 285623
URL: https://svnweb.freebsd.org/changeset/base/285623

Log:
  Fix typo in register definition.
  
  Submitted by: James Hung
  Reviewed by:  sbruno

Modified:
  head/sys/dev/e1000/e1000_regs.h

Modified: head/sys/dev/e1000/e1000_regs.h
==
--- head/sys/dev/e1000/e1000_regs.h Thu Jul 16 07:05:42 2015
(r285622)
+++ head/sys/dev/e1000/e1000_regs.h Thu Jul 16 08:03:23 2015
(r285623)
@@ -552,7 +552,7 @@
 #define E1000_WVBR 0x03554 /* VM Wrong Behavior - RWS */
 #define E1000_RPLOLR   0x05AF0 /* Replication Offload - RW */
 #define E1000_UTA  0x0A000 /* Unicast Table Array - RW */
-#define E1000_IOVTCL   0x05BBC /* IOV Control Register */
+#define E1000_IOVCTL   0x05BBC /* IOV Control Register */
 #define E1000_VMRCTL   0X05D80 /* Virtual Mirror Rule Control */
 #define E1000_VMRVLAN  0x05D90 /* Virtual Mirror Rule VLAN */
 #define E1000_VMRVM0x05DA0 /* Virtual Mirror Rule VM */
___
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: r285626 - in head/sys/arm64: arm64 include

2015-07-16 Thread Zbigniew Bodek
Author: zbb
Date: Thu Jul 16 10:22:57 2015
New Revision: 285626
URL: https://svnweb.freebsd.org/changeset/base/285626

Log:
  Set-up proper TCR values for memory related to Translation Table Walking
  
  This commit adds proper cache and shareability attributes to
  the TCR register.
  Set memory attributes to Normal, outer and inner cacheable WBWA.
  Set shareability to inner and outer shareable when SMP is enabled.
  
  Reviewed by:   andrew
  Obtained from: Semihalf
  Sponsored by:  The FreeBSD Foundation
  Differential Revision: https://reviews.freebsd.org/D3093

Modified:
  head/sys/arm64/arm64/locore.S
  head/sys/arm64/include/armreg.h

Modified: head/sys/arm64/arm64/locore.S
==
--- head/sys/arm64/arm64/locore.S   Thu Jul 16 10:12:10 2015
(r285625)
+++ head/sys/arm64/arm64/locore.S   Thu Jul 16 10:22:57 2015
(r285626)
@@ -535,7 +535,8 @@ mair:
/* DeviceNormal, no cache Normal, write-back */
.quad   MAIR_ATTR(0x00, 0) | MAIR_ATTR(0x44, 1) | MAIR_ATTR(0xff, 2)
 tcr:
-   .quad (TCR_TxSZ(64 - VIRT_BITS) | TCR_ASID_16 | TCR_TG1_4K)
+   .quad (TCR_TxSZ(64 - VIRT_BITS) | TCR_ASID_16 | TCR_TG1_4K | \
+   TCR_CACHE_ATTRS | TCR_SMP_ATTRS)
 sctlr_set:
/* Bits to set */
.quad (SCTLR_UCI | SCTLR_nTWE | SCTLR_nTWI | SCTLR_UCT | SCTLR_DZE | \

Modified: head/sys/arm64/include/armreg.h
==
--- head/sys/arm64/include/armreg.h Thu Jul 16 10:12:10 2015
(r285625)
+++ head/sys/arm64/include/armreg.h Thu Jul 16 10:22:57 2015
(r285626)
@@ -200,6 +200,28 @@
 #defineTCR_TG1_4K  (2 << TCR_TG1_SHIFT)
 #defineTCR_TG1_64K (3 << TCR_TG1_SHIFT)
 
+#defineTCR_SH1_SHIFT   28
+#defineTCR_SH1_IS  (0x3UL << TCR_SH1_SHIFT)
+#defineTCR_ORGN1_SHIFT 26
+#defineTCR_ORGN1_WBWA  (0x1UL << TCR_ORGN1_SHIFT)
+#defineTCR_IRGN1_SHIFT 24
+#defineTCR_IRGN1_WBWA  (0x1UL << TCR_IRGN1_SHIFT)
+#defineTCR_SH0_SHIFT   12
+#defineTCR_SH0_IS  (0x3UL << TCR_SH0_SHIFT)
+#defineTCR_ORGN0_SHIFT 10
+#defineTCR_ORGN0_WBWA  (0x1UL << TCR_ORGN0_SHIFT)
+#defineTCR_IRGN0_SHIFT 8
+#defineTCR_IRGN0_WBWA  (0x1UL << TCR_IRGN0_SHIFT)
+
+#defineTCR_CACHE_ATTRS ((TCR_IRGN0_WBWA | TCR_IRGN1_WBWA) |\
+   (TCR_ORGN0_WBWA | TCR_ORGN1_WBWA))
+
+#ifdef SMP
+#defineTCR_SMP_ATTRS   (TCR_SH0_IS | TCR_SH1_IS)
+#else
+#defineTCR_SMP_ATTRS   0
+#endif
+
 #defineTCR_T1SZ_SHIFT  16
 #defineTCR_T0SZ_SHIFT  0
 #defineTCR_TxSZ(x) (((x) << TCR_T1SZ_SHIFT) | ((x) << 
TCR_T0SZ_SHIFT))
___
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: r285627 - in head/sys: arm/arm arm/at91 arm/cavium/cns11xx arm/samsung/s3c2xx0 arm/xscale/i80321 arm/xscale/i8134x arm/xscale/ixp425 arm/xscale/pxa arm64/arm64 ddb i386/i386 powerpc/boo...

2015-07-16 Thread Zbigniew Bodek
Author: zbb
Date: Thu Jul 16 10:46:52 2015
New Revision: 285627
URL: https://svnweb.freebsd.org/changeset/base/285627

Log:
  Fix KSTACK_PAGES issue when the default value was changed in KERNCONF
  
  If KSTACK_PAGES was changed to anything alse than the default,
  the value from param.h was taken instead in some places and
  the value from KENRCONF in some others. This resulted in
  inconsistency which caused corruption in SMP envorinment.
  
  Ensure all places where KSTACK_PAGES are used the opt_kstack_pages.h
  is included.
  
  The file opt_kstack_pages.h could not be included in param.h
  because was breaking the toolchain compilation.
  
  Reviewed by:   kib
  Obtained from: Semihalf
  Sponsored by:  The FreeBSD Foundation
  Differential Revision: https://reviews.freebsd.org/D3094

Modified:
  head/sys/arm/arm/machdep.c
  head/sys/arm/at91/at91_machdep.c
  head/sys/arm/cavium/cns11xx/econa_machdep.c
  head/sys/arm/samsung/s3c2xx0/s3c24x0_machdep.c
  head/sys/arm/xscale/i80321/ep80219_machdep.c
  head/sys/arm/xscale/i80321/iq31244_machdep.c
  head/sys/arm/xscale/i8134x/crb_machdep.c
  head/sys/arm/xscale/ixp425/avila_machdep.c
  head/sys/arm/xscale/pxa/pxa_machdep.c
  head/sys/arm64/arm64/locore.S
  head/sys/arm64/arm64/mp_machdep.c
  head/sys/arm64/arm64/swtch.S
  head/sys/ddb/db_ps.c
  head/sys/ddb/db_sym.c
  head/sys/i386/i386/locore.s
  head/sys/powerpc/booke/pmap.c
  head/sys/sparc64/sparc64/exception.S
  head/sys/sparc64/sparc64/stack_machdep.c
  head/sys/sparc64/sparc64/support.S
  head/sys/x86/xen/pv.c

Modified: head/sys/arm/arm/machdep.c
==
--- head/sys/arm/arm/machdep.c  Thu Jul 16 10:22:57 2015(r285626)
+++ head/sys/arm/arm/machdep.c  Thu Jul 16 10:46:52 2015(r285627)
@@ -44,6 +44,7 @@
 
 #include "opt_compat.h"
 #include "opt_ddb.h"
+#include "opt_kstack_pages.h"
 #include "opt_platform.h"
 #include "opt_sched.h"
 #include "opt_timer.h"

Modified: head/sys/arm/at91/at91_machdep.c
==
--- head/sys/arm/at91/at91_machdep.cThu Jul 16 10:22:57 2015
(r285626)
+++ head/sys/arm/at91/at91_machdep.cThu Jul 16 10:46:52 2015
(r285627)
@@ -43,6 +43,7 @@
  * Created  : 17/09/94
  */
 
+#include "opt_kstack_pages.h"
 #include "opt_platform.h"
 
 #include 

Modified: head/sys/arm/cavium/cns11xx/econa_machdep.c
==
--- head/sys/arm/cavium/cns11xx/econa_machdep.c Thu Jul 16 10:22:57 2015
(r285626)
+++ head/sys/arm/cavium/cns11xx/econa_machdep.c Thu Jul 16 10:46:52 2015
(r285627)
@@ -38,6 +38,8 @@
 #include 
 __FBSDID("$FreeBSD$");
 
+#include "opt_kstack_pages.h"
+
 #define_ARM32_BUS_DMA_PRIVATE
 #include 
 #include 

Modified: head/sys/arm/samsung/s3c2xx0/s3c24x0_machdep.c
==
--- head/sys/arm/samsung/s3c2xx0/s3c24x0_machdep.c  Thu Jul 16 10:22:57 
2015(r285626)
+++ head/sys/arm/samsung/s3c2xx0/s3c24x0_machdep.c  Thu Jul 16 10:46:52 
2015(r285627)
@@ -44,6 +44,7 @@
  */
 
 #include "opt_ddb.h"
+#include "opt_kstack_pages.h"
 
 #include 
 __FBSDID("$FreeBSD$");

Modified: head/sys/arm/xscale/i80321/ep80219_machdep.c
==
--- head/sys/arm/xscale/i80321/ep80219_machdep.cThu Jul 16 10:22:57 
2015(r285626)
+++ head/sys/arm/xscale/i80321/ep80219_machdep.cThu Jul 16 10:46:52 
2015(r285627)
@@ -48,6 +48,8 @@
 #include 
 __FBSDID("$FreeBSD$");
 
+#include "opt_kstack_pages.h"
+
 #define _ARM32_BUS_DMA_PRIVATE
 #include 
 #include 

Modified: head/sys/arm/xscale/i80321/iq31244_machdep.c
==
--- head/sys/arm/xscale/i80321/iq31244_machdep.cThu Jul 16 10:22:57 
2015(r285626)
+++ head/sys/arm/xscale/i80321/iq31244_machdep.cThu Jul 16 10:46:52 
2015(r285627)
@@ -48,6 +48,8 @@
 #include 
 __FBSDID("$FreeBSD$");
 
+#include "opt_kstack_pages.h"
+
 #define _ARM32_BUS_DMA_PRIVATE
 #include 
 #include 

Modified: head/sys/arm/xscale/i8134x/crb_machdep.c
==
--- head/sys/arm/xscale/i8134x/crb_machdep.cThu Jul 16 10:22:57 2015
(r285626)
+++ head/sys/arm/xscale/i8134x/crb_machdep.cThu Jul 16 10:46:52 2015
(r285627)
@@ -48,6 +48,8 @@
 #include 
 __FBSDID("$FreeBSD$");
 
+#include "opt_kstack_pages.h"
+
 #define _ARM32_BUS_DMA_PRIVATE
 #include 
 #include 

Modified: head/sys/arm/xscale/ixp425/avila_machdep.c
==
--- head/sys/arm/xscale/ixp425/avila_machdep.c  Thu Jul 16 10:22:57 2015
(r285626)
+++ head/sys/arm/xscale/ixp425/avila_machdep.c  Thu Jul 16 10:

svn commit: r285628 - head/sys/dev/ichwd

2015-07-16 Thread Christian Brueffer
Author: brueffer
Date: Thu Jul 16 11:14:59 2015
New Revision: 285628
URL: https://svnweb.freebsd.org/changeset/base/285628

Log:
  Actually recognize all Intel Lynx Point devices we have device IDs for.
  
  PR:   195851
  Submitted by: ftig...@wolfpond.org
  MFC after:1 week

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

Modified: head/sys/dev/ichwd/ichwd.c
==
--- head/sys/dev/ichwd/ichwd.c  Thu Jul 16 10:46:52 2015(r285627)
+++ head/sys/dev/ichwd/ichwd.c  Thu Jul 16 11:14:59 2015(r285628)
@@ -194,6 +194,35 @@ static struct ichwd_device ichwd_devices
{ DEVICEID_LPT0, "Intel Lynx Point watchdog timer", 10 },
{ DEVICEID_LPT1, "Intel Lynx Point watchdog timer", 10 },
{ DEVICEID_LPT2, "Intel Lynx Point watchdog timer", 10 },
+   { DEVICEID_LPT3, "Intel Lynx Point watchdog timer", 10 },
+   { DEVICEID_LPT4, "Intel Lynx Point watchdog timer", 10 },
+   { DEVICEID_LPT5, "Intel Lynx Point watchdog timer", 10 },
+   { DEVICEID_LPT6, "Intel Lynx Point watchdog timer", 10 },
+   { DEVICEID_LPT7, "Intel Lynx Point watchdog timer", 10 },
+   { DEVICEID_LPT8, "Intel Lynx Point watchdog timer", 10 },
+   { DEVICEID_LPT9, "Intel Lynx Point watchdog timer", 10 },
+   { DEVICEID_LPT10,"Intel Lynx Point watchdog timer", 10 },
+   { DEVICEID_LPT11,"Intel Lynx Point watchdog timer", 10 },
+   { DEVICEID_LPT12,"Intel Lynx Point watchdog timer", 10 },
+   { DEVICEID_LPT13,"Intel Lynx Point watchdog timer", 10 },
+   { DEVICEID_LPT14,"Intel Lynx Point watchdog timer", 10 },
+   { DEVICEID_LPT15,"Intel Lynx Point watchdog timer", 10 },
+   { DEVICEID_LPT16,"Intel Lynx Point watchdog timer", 10 },
+   { DEVICEID_LPT17,"Intel Lynx Point watchdog timer", 10 },
+   { DEVICEID_LPT18,"Intel Lynx Point watchdog timer", 10 },
+   { DEVICEID_LPT19,"Intel Lynx Point watchdog timer", 10 },
+   { DEVICEID_LPT20,"Intel Lynx Point watchdog timer", 10 },
+   { DEVICEID_LPT21,"Intel Lynx Point watchdog timer", 10 },
+   { DEVICEID_LPT22,"Intel Lynx Point watchdog timer", 10 },
+   { DEVICEID_LPT23,"Intel Lynx Point watchdog timer", 10 },
+   { DEVICEID_LPT24,"Intel Lynx Point watchdog timer", 10 },
+   { DEVICEID_LPT25,"Intel Lynx Point watchdog timer", 10 },
+   { DEVICEID_LPT26,"Intel Lynx Point watchdog timer", 10 },
+   { DEVICEID_LPT27,"Intel Lynx Point watchdog timer", 10 },
+   { DEVICEID_LPT28,"Intel Lynx Point watchdog timer", 10 },
+   { DEVICEID_LPT29,"Intel Lynx Point watchdog timer", 10 },
+   { DEVICEID_LPT30,"Intel Lynx Point watchdog timer", 10 },
+   { DEVICEID_LPT31,"Intel Lynx Point watchdog timer", 10 },
{ DEVICEID_WCPT2,"Intel Wildcat Point watchdog timer",  10 },
{ DEVICEID_WCPT4,"Intel Wildcat Point watchdog timer",  10 },
{ DEVICEID_WCPT6,"Intel Wildcat Point watchdog timer",  10 },
___
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: r285629 - head/sys/x86/x86

2015-07-16 Thread Konstantin Belousov
Author: kib
Date: Thu Jul 16 12:16:42 2015
New Revision: 285629
URL: https://svnweb.freebsd.org/changeset/base/285629

Log:
  Fix warnings about unused functions for UP build.
  
  Sponsored by: The FreeBSD Foundation

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

Modified: head/sys/x86/x86/local_apic.c
==
--- head/sys/x86/x86/local_apic.c   Thu Jul 16 11:14:59 2015
(r285628)
+++ head/sys/x86/x86/local_apic.c   Thu Jul 16 12:16:42 2015
(r285629)
@@ -204,6 +204,7 @@ lapic_write32_nofence(enum LAPIC_REGISTE
}
 }
 
+#ifdef SMP
 static uint64_t
 lapic_read_icr(void)
 {
@@ -241,6 +242,7 @@ lapic_write_icr(uint32_t vhi, uint32_t v
lapic_write32(LAPIC_ICR_LO, vlo);
}
 }
+#endif /* SMP */
 
 static void
 native_lapic_enable_x2apic(void)
@@ -292,9 +294,6 @@ static int  native_lapic_enable_pmc(void
 static voidnative_lapic_disable_pmc(void);
 static voidnative_lapic_reenable_pmc(void);
 static voidnative_lapic_enable_cmc(void);
-static voidnative_lapic_ipi_raw(register_t icrlo, u_int dest);
-static voidnative_lapic_ipi_vectored(u_int vector, int dest);
-static int native_lapic_ipi_wait(int delay);
 static int native_lapic_set_lvt_mask(u_int apic_id, u_int lvt,
u_char masked);
 static int native_lapic_set_lvt_mode(u_int apic_id, u_int lvt,
@@ -303,8 +302,13 @@ static int native_lapic_set_lvt_polarit
enum intr_polarity pol);
 static int native_lapic_set_lvt_triggermode(u_int apic_id, u_int lvt,
enum intr_trigger trigger);
+#ifdef SMP
+static voidnative_lapic_ipi_raw(register_t icrlo, u_int dest);
+static voidnative_lapic_ipi_vectored(u_int vector, int dest);
+static int native_lapic_ipi_wait(int delay);
 static int native_lapic_ipi_alloc(inthand_t *ipifunc);
 static voidnative_lapic_ipi_free(int vector);
+#endif /* SMP */
 
 struct apic_ops apic_ops = {
.create = native_lapic_create,
___
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: r285630 - head/usr.bin/sockstat

2015-07-16 Thread Dag-Erling Smørgrav
Author: des
Date: Thu Jul 16 13:09:21 2015
New Revision: 285630
URL: https://svnweb.freebsd.org/changeset/base/285630

Log:
  Add a -s option which adds a column listing the connection state if
  applicable (currently only for TCP).
  
  PR:   201585
  MFC after:3 weeks

Modified:
  head/usr.bin/sockstat/sockstat.1
  head/usr.bin/sockstat/sockstat.c

Modified: head/usr.bin/sockstat/sockstat.1
==
--- head/usr.bin/sockstat/sockstat.1Thu Jul 16 12:16:42 2015
(r285629)
+++ head/usr.bin/sockstat/sockstat.1Thu Jul 16 13:09:21 2015
(r285630)
@@ -27,7 +27,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd June 20, 2015
+.Dd July 14, 2015
 .Dt SOCKSTAT 1
 .Os
 .Sh NAME
@@ -35,7 +35,7 @@
 .Nd list open sockets
 .Sh SYNOPSIS
 .Nm
-.Op Fl 46cLlu
+.Op Fl 46cLlsu
 .Op Fl j Ar jid
 .Op Fl p Ar ports
 .Op Fl P Ar protocols
@@ -83,6 +83,9 @@ The
 argument is a comma-separated list of protocol names,
 as they are defined in
 .Xr protocols 5 .
+.It Fl s
+Display the protocol state, if applicable.
+This is currently only implemented for TCP.
 .It Fl u
 Show
 .Dv AF_LOCAL

Modified: head/usr.bin/sockstat/sockstat.c
==
--- head/usr.bin/sockstat/sockstat.cThu Jul 16 12:16:42 2015
(r285629)
+++ head/usr.bin/sockstat/sockstat.cThu Jul 16 13:09:21 2015
(r285630)
@@ -45,6 +45,8 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#define TCPSTATES /* load state names */
+#include 
 #include 
 #include 
 #include 
@@ -71,6 +73,7 @@ static int opt_c; /* Show connected so
 static int  opt_j; /* Show specified jail */
 static int  opt_L; /* Don't show IPv4 or IPv6 loopback sockets */
 static int  opt_l; /* Show listening sockets */
+static int  opt_s; /* Show protocol state if applicable */
 static int  opt_u; /* Show Unix domain sockets */
 static int  opt_v; /* Verbose mode */
 
@@ -101,6 +104,7 @@ struct sock {
int vflag;
int family;
int proto;
+   int state;
const char *protoname;
struct addr *laddr;
struct addr *faddr;
@@ -538,9 +542,9 @@ gather_inet(int proto)
const char *varname, *protoname;
size_t len, bufsize;
void *buf;
-   int hash, retry, vflag;
+   int hash, retry, state, vflag;
 
-   vflag = 0;
+   state = vflag = 0;
if (opt_4)
vflag |= INP_IPV4;
if (opt_6)
@@ -604,6 +608,7 @@ gather_inet(int proto)
inp = &xtp->xt_inp;
so = &xtp->xt_socket;
protoname = xtp->xt_tp.t_flags & TF_TOE ? "toe" : "tcp";
+   state = xtp->xt_tp.t_state;
break;
case IPPROTO_UDP:
case IPPROTO_DIVERT:
@@ -670,6 +675,8 @@ gather_inet(int proto)
sock->laddr = laddr;
sock->faddr = faddr;
sock->vflag = inp->inp_vflag;
+   if (proto == IPPROTO_TCP)
+   sock->state = xtp->xt_tp.t_state;
sock->protoname = protoname;
hash = (int)((uintptr_t)sock->socket % HASHSIZE);
sock->next = sockhash[hash];
@@ -977,7 +984,14 @@ displaysock(struct sock *s, int pos)
pos = 0;
}
}
-   xprintf("\n");
+   if (opt_s && s->proto == IPPROTO_TCP) {
+   while (pos < 80)
+   pos += xprintf(" ");
+   if (s->state >= 0 && s->state < TCP_NSTATES)
+   pos += xprintf("%s", tcpstates[s->state]);
+   else
+   pos += xprintf("?");
+   }
 }
 
 static void
@@ -988,9 +1002,12 @@ display(void)
struct sock *s;
int hash, n, pos;
 
-   printf("%-8s %-10s %-5s %-2s %-6s %-21s %-21s\n",
+   printf("%-8s %-10s %-5s %-2s %-6s %-21s %-21s",
"USER", "COMMAND", "PID", "FD", "PROTO",
"LOCAL ADDRESS", "FOREIGN ADDRESS");
+   if (opt_s)
+   printf(" %-12s", "STATE");
+   printf("\n");
setpassent(1);
for (xf = xfiles, n = 0; n < nxfiles; ++n, ++xf) {
if (xf->xf_data == NULL)
@@ -1019,6 +1036,7 @@ display(void)
pos += xprintf(" ");
pos += xprintf("%d ", xf->xf_fd);
displaysock(s, pos);
+   xprintf("\n");
}
}
if (opt_j >= 0)
@@ -1033,6 +1051,7 @@ display(void)
pos += xprintf("%-8s %-10s %-5s %-2s ",
"?", "?", "?", "?");
displaysock(s, pos);
+   xprintf("\n");
}
}
 }
@@ -1061,7 +1080,7 @@ static void
 usage(void)
 {
fprintf(stderr,

svn commit: r285631 - head/sys/arm/include

2015-07-16 Thread Andrew Turner
Author: andrew
Date: Thu Jul 16 13:33:03 2015
New Revision: 285631
URL: https://svnweb.freebsd.org/changeset/base/285631

Log:
  Split out the arm and armv6 parts of atomic.h to new files. While here use
  __ARM_ARCH to determine which revision of the architecture is applicable.
  
  Sponsored by: ABT Systems Ltd

Added:
  head/sys/arm/include/atomic-v4.h
 - copied, changed from r285531, head/sys/arm/include/atomic.h
  head/sys/arm/include/atomic-v6.h
 - copied, changed from r285531, head/sys/arm/include/atomic.h
Modified:
  head/sys/arm/include/atomic.h

Copied and modified: head/sys/arm/include/atomic-v4.h (from r285531, 
head/sys/arm/include/atomic.h)
==
--- head/sys/arm/include/atomic.h   Tue Jul 14 10:49:36 2015
(r285531, copy source)
+++ head/sys/arm/include/atomic-v4.hThu Jul 16 13:33:03 2015
(r285631)
@@ -36,659 +36,25 @@
  * $FreeBSD$
  */
 
-#ifndef_MACHINE_ATOMIC_H_
-#define_MACHINE_ATOMIC_H_
+#ifndef _MACHINE_ATOMIC_V4_H_
+#define_MACHINE_ATOMIC_V4_H_
 
-#include 
-#include 
-
-#ifndef _KERNEL
-#include 
-#else
-#include 
+#ifndef _MACHINE_ATOMIC_H_
+#error Do not include this file directly, use 
 #endif
 
-#if defined (__ARM_ARCH_7__) || defined (__ARM_ARCH_7A__)
-#define isb()  __asm __volatile("isb" : : : "memory")
-#define dsb()  __asm __volatile("dsb" : : : "memory")
-#define dmb()  __asm __volatile("dmb" : : : "memory")
-#elif defined (__ARM_ARCH_6__) || defined (__ARM_ARCH_6J__) || \
-  defined (__ARM_ARCH_6K__) || defined (__ARM_ARCH_6T2__) || \
-  defined (__ARM_ARCH_6Z__) || defined (__ARM_ARCH_6ZK__)
-#define isb()  __asm __volatile("mcr p15, 0, %0, c7, c5, 4" : : "r" (0) : 
"memory")
-#define dsb()  __asm __volatile("mcr p15, 0, %0, c7, c10, 4" : : "r" (0) : 
"memory")
-#define dmb()  __asm __volatile("mcr p15, 0, %0, c7, c10, 5" : : "r" (0) : 
"memory")
-#else
+#if __ARM_ARCH <= 5
 #define isb()  __asm __volatile("mcr p15, 0, %0, c7, c5, 4" : : "r" (0) : 
"memory")
 #define dsb()  __asm __volatile("mcr p15, 0, %0, c7, c10, 4" : : "r" (0) : 
"memory")
 #define dmb()  dsb()
+#else
+#error Only use this file with ARMv5 and earlier
 #endif
 
 #define mb()   dmb()
 #define wmb()  dmb()
 #define rmb()  dmb()
 
-
-
-/*
- * It would be nice to use _HAVE_ARMv6_INSTRUCTIONS from machine/asm.h
- * here, but that header can't be included here because this is C
- * code.  I would like to move the _HAVE_ARMv6_INSTRUCTIONS definition
- * out of asm.h so it can be used in both asm and C code. - kientzle@
- */
-#if defined (__ARM_ARCH_7__) || \
-   defined (__ARM_ARCH_7A__)  || \
-   defined (__ARM_ARCH_6__)   || \
-   defined (__ARM_ARCH_6J__)  || \
-   defined (__ARM_ARCH_6K__)  || \
-   defined (__ARM_ARCH_6T2__) || \
-   defined (__ARM_ARCH_6Z__)  || \
-   defined (__ARM_ARCH_6ZK__)
-#defineARM_HAVE_ATOMIC64
-
-static __inline void
-__do_dmb(void)
-{
-
-#if defined (__ARM_ARCH_7__) || defined (__ARM_ARCH_7A__)
-   __asm __volatile("dmb" : : : "memory");
-#else
-   __asm __volatile("mcr p15, 0, r0, c7, c10, 5" : : : "memory");
-#endif
-}
-
-#define ATOMIC_ACQ_REL_LONG(NAME)  \
-static __inline void   \
-atomic_##NAME##_acq_long(__volatile u_long *p, u_long v)   \
-{  \
-   atomic_##NAME##_long(p, v); \
-   __do_dmb(); \
-}  \
-   \
-static __inline  void  \
-atomic_##NAME##_rel_long(__volatile u_long *p, u_long v)   \
-{  \
-   __do_dmb(); \
-   atomic_##NAME##_long(p, v); \
-}
-
-#defineATOMIC_ACQ_REL(NAME, WIDTH) 
\
-static __inline  void  \
-atomic_##NAME##_acq_##WIDTH(__volatile uint##WIDTH##_t *p, uint##WIDTH##_t v)\
-{  \
-   atomic_##NAME##_##WIDTH(p, v);  \
-   __do_dmb(); \
-}  \
-   \
-static __inline  void  \
-atomic_##NAME##_rel_##WIDTH(__volatile uint##WIDTH##_t *p, uint##WIDTH##_t v)\
-{  \
-   __do_dmb

svn commit: r285632 - in head/sys: cddl/contrib/opensolaris/uts/common/fs kern sys

2015-07-16 Thread Mateusz Guzik
Author: mjg
Date: Thu Jul 16 13:57:05 2015
New Revision: 285632
URL: https://svnweb.freebsd.org/changeset/base/285632

Log:
  vfs: implement v_holdcnt/v_usecount manipulation using atomic ops
  
  Transitions 0->1 and 1->0 (which decide e.g. on putting the vnode on the free
  list) of either counter are still guarded with vnode interlock.
  
  Reviewed by:  kib (earlier version)
  Tested by:pho

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/vnode.c
  head/sys/kern/vfs_cache.c
  head/sys/kern/vfs_hash.c
  head/sys/kern/vfs_subr.c
  head/sys/sys/lockmgr.h
  head/sys/sys/vnode.h

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/vnode.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/vnode.c Thu Jul 16 
13:33:03 2015(r285631)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/vnode.c Thu Jul 16 
13:57:05 2015(r285632)
@@ -99,6 +99,6 @@ vn_rele_async(vnode_t *vp, taskq_t *task
(task_func_t *)vn_rele_inactive, vp, TQ_SLEEP) != 0);
return;
}
-   vp->v_usecount--;
+   refcount_release(&vp->v_usecount);
vdropl(vp);
 }

Modified: head/sys/kern/vfs_cache.c
==
--- head/sys/kern/vfs_cache.c   Thu Jul 16 13:33:03 2015(r285631)
+++ head/sys/kern/vfs_cache.c   Thu Jul 16 13:57:05 2015(r285632)
@@ -661,12 +661,12 @@ success:
ltype = VOP_ISLOCKED(dvp);
VOP_UNLOCK(dvp, 0);
}
-   VI_LOCK(*vpp);
+   vhold(*vpp);
if (wlocked)
CACHE_WUNLOCK();
else
CACHE_RUNLOCK();
-   error = vget(*vpp, cnp->cn_lkflags | LK_INTERLOCK, cnp->cn_thread);
+   error = vget(*vpp, cnp->cn_lkflags | LK_VNHELD, cnp->cn_thread);
if (cnp->cn_flags & ISDOTDOT) {
vn_lock(dvp, ltype | LK_RETRY);
if (dvp->v_iflag & VI_DOOMED) {
@@ -1366,9 +1366,9 @@ vn_dir_dd_ino(struct vnode *vp)
if ((ncp->nc_flag & NCF_ISDOTDOT) != 0)
continue;
ddvp = ncp->nc_dvp;
-   VI_LOCK(ddvp);
+   vhold(ddvp);
CACHE_RUNLOCK();
-   if (vget(ddvp, LK_INTERLOCK | LK_SHARED | LK_NOWAIT, curthread))
+   if (vget(ddvp, LK_SHARED | LK_NOWAIT | LK_VNHELD, curthread))
return (NULL);
return (ddvp);
}

Modified: head/sys/kern/vfs_hash.c
==
--- head/sys/kern/vfs_hash.cThu Jul 16 13:33:03 2015(r285631)
+++ head/sys/kern/vfs_hash.cThu Jul 16 13:57:05 2015(r285632)
@@ -84,9 +84,9 @@ vfs_hash_get(const struct mount *mp, u_i
continue;
if (fn != NULL && fn(vp, arg))
continue;
-   VI_LOCK(vp);
+   vhold(vp);
rw_runlock(&vfs_hash_lock);
-   error = vget(vp, flags | LK_INTERLOCK, td);
+   error = vget(vp, flags | LK_VNHELD, td);
if (error == ENOENT && (flags & LK_NOWAIT) == 0)
break;
if (error)
@@ -128,9 +128,9 @@ vfs_hash_insert(struct vnode *vp, u_int 
continue;
if (fn != NULL && fn(vp2, arg))
continue;
-   VI_LOCK(vp2);
+   vhold(vp2);
rw_wunlock(&vfs_hash_lock);
-   error = vget(vp2, flags | LK_INTERLOCK, td);
+   error = vget(vp2, flags | LK_VNHELD, td);
if (error == ENOENT && (flags & LK_NOWAIT) == 0)
break;
rw_wlock(&vfs_hash_lock);

Modified: head/sys/kern/vfs_subr.c
==
--- head/sys/kern/vfs_subr.cThu Jul 16 13:33:03 2015(r285631)
+++ head/sys/kern/vfs_subr.cThu Jul 16 13:57:05 2015(r285632)
@@ -68,6 +68,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -101,10 +102,8 @@ static int flushbuflist(struct bufv *buf
int slpflag, int slptimeo);
 static voidsyncer_shutdown(void *arg, int howto);
 static int vtryrecycle(struct vnode *vp);
+static voidv_init_counters(struct vnode *);
 static voidv_incr_usecount(struct vnode *);
-static voidv_decr_usecount(struct vnode *);
-static voidv_decr_useonly(struct vnode *);
-static voidv_upgrade_usecount(struct vnode *);
 static voidv_incr_devcount(struct vnode *);
 static voidv_decr_devcount(struct vnode *);
 static voidvnlru_free(

Re: svn commit: r284959 - in head: . share/man/man4 share/man/man9 sys/conf sys/dev/glxsb sys/dev/hifn sys/dev/random sys/dev/rndtest sys/dev/safe sys/dev/syscons sys/dev/ubsec sys/dev/virtio/random s

2015-07-16 Thread Ian Lepore
On Thu, 2015-07-16 at 06:39 +0100, Mark Murray wrote:
> > On 15 Jul 2015, at 23:43, Adrian Chadd  wrote:
> > 
> >>  - Add harvesting of slab allocator events. This needs to be checked for
> >>weighing down the allocator code.
> > 
> > Hi,
> > 
> > Is this really doing it upon every one of those events? eg, for each
> > mbuf alloc through UMA?
> 
> Only if you turn it on!
> 
> M
> 

In random_harvestq_init() I see

 harvest_context.hc_source_mask = RANDOM_HARVEST_EVERYTHING_MASK;

and

#define RANDOM_HARVEST_EVERYTHING_MASK ((1 << (RANDOM_ENVIRONMENTAL_END
+ 1)) - 1)

So doesn't that include the RANDOM_FAST flag that controls harvesting
during every UMA alloc and free call?  And that harvesting appears to be
anything but fast, at least at a glance... it looks like it passes the
entire struct uma_zone to the jenkins hash function... is there really
useful entropy in all the data in that struct?

-- 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"


svn commit: r285633 - in head/sys: kern sys

2015-07-16 Thread Mateusz Guzik
Author: mjg
Date: Thu Jul 16 14:30:11 2015
New Revision: 285633
URL: https://svnweb.freebsd.org/changeset/base/285633

Log:
  Get rid of lim_update_thread and cred_update_thread.
  
  Their primary use was in thread_cow_update to free up old resources.
  Freeing had to be done with proc lock held and _cow_ funcs already knew
  how to free old structs.

Modified:
  head/sys/kern/init_main.c
  head/sys/kern/kern_prot.c
  head/sys/kern/kern_resource.c
  head/sys/kern/kern_thread.c
  head/sys/sys/resourcevar.h
  head/sys/sys/ucred.h

Modified: head/sys/kern/init_main.c
==
--- head/sys/kern/init_main.c   Thu Jul 16 13:57:05 2015(r285632)
+++ head/sys/kern/init_main.c   Thu Jul 16 14:30:11 2015(r285633)
@@ -827,6 +827,7 @@ static void
 create_init(const void *udata __unused)
 {
struct ucred *newcred, *oldcred;
+   struct thread *td;
int error;
 
error = fork1(&thread0, RFFDG | RFPROC | RFSTOPPED, 0, &initproc,
@@ -850,7 +851,9 @@ create_init(const void *udata __unused)
audit_cred_proc1(newcred);
 #endif
proc_set_cred(initproc, newcred);
-   cred_update_thread(FIRST_THREAD_IN_PROC(initproc));
+   td = FIRST_THREAD_IN_PROC(initproc);
+   crfree(td->td_ucred);
+   td->td_ucred = crhold(initproc->p_ucred);
PROC_UNLOCK(initproc);
sx_xunlock(&proctree_lock);
crfree(oldcred);

Modified: head/sys/kern/kern_prot.c
==
--- head/sys/kern/kern_prot.c   Thu Jul 16 13:57:05 2015(r285632)
+++ head/sys/kern/kern_prot.c   Thu Jul 16 14:30:11 2015(r285633)
@@ -1935,24 +1935,6 @@ cru2x(struct ucred *cr, struct xucred *x
 }
 
 /*
- * small routine to swap a thread's current ucred for the correct one taken
- * from the process.
- */
-void
-cred_update_thread(struct thread *td)
-{
-   struct proc *p;
-   struct ucred *cred;
-
-   p = td->td_proc;
-   cred = td->td_ucred;
-   PROC_LOCK_ASSERT(p, MA_OWNED);
-   td->td_ucred = crhold(p->p_ucred);
-   if (cred != NULL)
-   crfree(cred);
-}
-
-/*
  * Set initial process credentials.
  * Callers are responsible for providing the reference for provided 
credentials.
  */

Modified: head/sys/kern/kern_resource.c
==
--- head/sys/kern/kern_resource.c   Thu Jul 16 13:57:05 2015
(r285632)
+++ head/sys/kern/kern_resource.c   Thu Jul 16 14:30:11 2015
(r285633)
@@ -1436,17 +1436,3 @@ chgkqcnt(struct uidinfo *uip, int diff, 
 
return (chglimit(uip, &uip->ui_kqcnt, diff, max, "kqcnt"));
 }
-
-void
-lim_update_thread(struct thread *td)
-{
-   struct proc *p;
-   struct plimit *lim;
-
-   p = td->td_proc;
-   lim = td->td_limit;
-   PROC_LOCK_ASSERT(p, MA_OWNED);
-   td->td_limit = lim_hold(p->p_limit);
-   if (lim != NULL)
-   lim_free(lim);
-}

Modified: head/sys/kern/kern_thread.c
==
--- head/sys/kern/kern_thread.c Thu Jul 16 13:57:05 2015(r285632)
+++ head/sys/kern/kern_thread.c Thu Jul 16 14:30:11 2015(r285633)
@@ -409,9 +409,9 @@ void
 thread_cow_free(struct thread *td)
 {
 
-   if (td->td_ucred)
+   if (td->td_ucred != NULL)
crfree(td->td_ucred);
-   if (td->td_limit)
+   if (td->td_limit != NULL)
lim_free(td->td_limit);
 }
 
@@ -419,15 +419,27 @@ void
 thread_cow_update(struct thread *td)
 {
struct proc *p;
+   struct ucred *oldcred;
+   struct plimit *oldlimit;
 
p = td->td_proc;
+   oldcred = NULL;
+   oldlimit = NULL;
PROC_LOCK(p);
-   if (td->td_ucred != p->p_ucred)
-   cred_update_thread(td);
-   if (td->td_limit != p->p_limit)
-   lim_update_thread(td);
+   if (td->td_ucred != p->p_ucred) {
+   oldcred = td->td_ucred;
+   td->td_ucred = crhold(p->p_ucred);
+   }
+   if (td->td_limit != p->p_limit) {
+   oldlimit = td->td_limit;
+   td->td_limit = lim_hold(p->p_limit);
+   }
td->td_cowgen = p->p_cowgen;
PROC_UNLOCK(p);
+   if (oldcred != NULL)
+   crfree(oldcred);
+   if (oldlimit != NULL)
+   lim_free(oldlimit);
 }
 
 /*

Modified: head/sys/sys/resourcevar.h
==
--- head/sys/sys/resourcevar.h  Thu Jul 16 13:57:05 2015(r285632)
+++ head/sys/sys/resourcevar.h  Thu Jul 16 14:30:11 2015(r285633)
@@ -159,7 +159,5 @@ void ui_racct_foreach(void (*callback)(
void *arg2, void *arg3), void *arg2, void *arg3);
 #endif
 
-void   lim_update_thread(struct thread *td);
-
 #endif /* _KERNEL */
 #endif /* !_SYS_RESOURCEVAR_H_ */

Mo

svn commit: r285636 - head/sys/kern

2015-07-16 Thread Mateusz Guzik
Author: mjg
Date: Thu Jul 16 15:26:37 2015
New Revision: 285636
URL: https://svnweb.freebsd.org/changeset/base/285636

Log:
  fd: partially deduplicate fdescfree and fdescfree_remapped
  
  This also moves vrele of cdir/rdir/jdir vnodes earlier, which should not
  matter.

Modified:
  head/sys/kern/kern_descrip.c

Modified: head/sys/kern/kern_descrip.c
==
--- head/sys/kern/kern_descrip.cThu Jul 16 15:13:17 2015
(r285635)
+++ head/sys/kern/kern_descrip.cThu Jul 16 15:26:37 2015
(r285636)
@@ -2110,18 +2110,46 @@ retry:
 /*
  * Release a filedesc structure.
  */
-void
-fdescfree(struct thread *td)
+static void
+fdescfree_fds(struct thread *td, struct filedesc *fdp, bool needclose)
 {
-   struct proc *p;
struct filedesc0 *fdp0;
-   struct filedesc *fdp;
struct freetable *ft, *tft;
struct filedescent *fde;
struct file *fp;
-   struct vnode *cdir, *jdir, *rdir;
int i;
 
+   for (i = 0; i <= fdp->fd_lastfile; i++) {
+   fde = &fdp->fd_ofiles[i];
+   fp = fde->fde_file;
+   if (fp != NULL) {
+   fdefree_last(fde);
+   if (needclose)
+   (void) closef(fp, td);
+   else
+   fdrop(fp, td);
+   }
+   }
+
+   if (NDSLOTS(fdp->fd_nfiles) > NDSLOTS(NDFILE))
+   free(fdp->fd_map, M_FILEDESC);
+   if (fdp->fd_nfiles > NDFILE)
+   free(fdp->fd_files, M_FILEDESC);
+
+   fdp0 = (struct filedesc0 *)fdp;
+   SLIST_FOREACH_SAFE(ft, &fdp0->fd_free, ft_next, tft)
+   free(ft->ft_table, M_FILEDESC);
+
+   fddrop(fdp);
+}
+
+void
+fdescfree(struct thread *td)
+{
+   struct proc *p;
+   struct filedesc *fdp;
+   struct vnode *cdir, *jdir, *rdir;
+
p = td->td_proc;
fdp = p->p_fd;
MPASS(fdp != NULL);
@@ -2134,7 +2162,7 @@ fdescfree(struct thread *td)
}
 #endif
 
-   if (td->td_proc->p_fdtol != NULL)
+   if (p->p_fdtol != NULL)
fdclearlocks(td);
 
PROC_LOCK(p);
@@ -2153,24 +2181,6 @@ fdescfree(struct thread *td)
fdp->fd_jdir = NULL;
FILEDESC_XUNLOCK(fdp);
 
-   for (i = 0; i <= fdp->fd_lastfile; i++) {
-   fde = &fdp->fd_ofiles[i];
-   fp = fde->fde_file;
-   if (fp != NULL) {
-   fdefree_last(fde);
-   (void) closef(fp, td);
-   }
-   }
-
-   if (NDSLOTS(fdp->fd_nfiles) > NDSLOTS(NDFILE))
-   free(fdp->fd_map, M_FILEDESC);
-   if (fdp->fd_nfiles > NDFILE)
-   free(fdp->fd_files, M_FILEDESC);
-
-   fdp0 = (struct filedesc0 *)fdp;
-   SLIST_FOREACH_SAFE(ft, &fdp0->fd_free, ft_next, tft)
-   free(ft->ft_table, M_FILEDESC);
-
if (cdir != NULL)
vrele(cdir);
if (rdir != NULL)
@@ -2178,35 +2188,12 @@ fdescfree(struct thread *td)
if (jdir != NULL)
vrele(jdir);
 
-   fddrop(fdp);
+   fdescfree_fds(td, fdp, 1);
 }
 
 void
 fdescfree_remapped(struct filedesc *fdp)
 {
-   struct filedesc0 *fdp0;
-   struct filedescent *fde;
-   struct file *fp;
-   struct freetable *ft, *tft;
-   int i;
-
-   for (i = 0; i <= fdp->fd_lastfile; i++) {
-   fde = &fdp->fd_ofiles[i];
-   fp = fde->fde_file;
-   if (fp != NULL) {
-   fdefree_last(fde);
-   (void) closef(fp, NULL);
-   }
-   }
-
-   if (NDSLOTS(fdp->fd_nfiles) > NDSLOTS(NDFILE))
-   free(fdp->fd_map, M_FILEDESC);
-   if (fdp->fd_nfiles > NDFILE)
-   free(fdp->fd_files, M_FILEDESC);
-
-   fdp0 = (struct filedesc0 *)fdp;
-   SLIST_FOREACH_SAFE(ft, &fdp0->fd_free, ft_next, tft)
-   free(ft->ft_table, M_FILEDESC);
 
if (fdp->fd_cdir != NULL)
vrele(fdp->fd_cdir);
@@ -2214,7 +2201,8 @@ fdescfree_remapped(struct filedesc *fdp)
vrele(fdp->fd_rdir);
if (fdp->fd_jdir != NULL)
vrele(fdp->fd_jdir);
-   fddrop(fdp);
+
+   fdescfree_fds(curthread, fdp, 0);
 }
 
 /*
___
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: r285637 - head/share/man/man9

2015-07-16 Thread Ed Schouten
Author: ed
Date: Thu Jul 16 15:43:55 2015
New Revision: 285637
URL: https://svnweb.freebsd.org/changeset/base/285637

Log:
  Fix a small typo: "the the".
  
  Spotted by:   wblock

Modified:
  head/share/man/man9/random.9

Modified: head/share/man/man9/random.9
==
--- head/share/man/man9/random.9Thu Jul 16 15:26:37 2015
(r285636)
+++ head/share/man/man9/random.9Thu Jul 16 15:43:55 2015
(r285637)
@@ -26,7 +26,7 @@
 .\"
 .\" $FreeBSD$
 .\" "
-.Dd July 14, 2015
+.Dd July 16, 2015
 .Dt RANDOM 9
 .Os
 .Sh NAME
@@ -129,7 +129,7 @@ on
 The
 .Fa uio
 argument points to a buffer where random data should be stored.
-This function only returns data if the the random device is seeded.
+This function only returns data if the random device is seeded.
 It blocks if unseeded,
 except when the
 .Fa nonblock
___
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: r285638 - head/sys/dev/usb/controller

2015-07-16 Thread Hans Petter Selasky
Author: hselasky
Date: Thu Jul 16 16:08:40 2015
New Revision: 285638
URL: https://svnweb.freebsd.org/changeset/base/285638

Log:
  Optimise the DWC OTG host mode driver's transmit path:
  
  1) Use the TX FIFO empty interrupts to poll the transmit FIFO usage,
  instead of using own software counters and waiting for SOF
  interrupts. Assume that enough FIFO space is available to execute one
  USB OUT transfer of any kind when the TX FIFO is empty.
  
  2) Use the host channel halted event to asynchronously wait for host
  channels to be disabled instead of waiting for SOF interrupts. This
  results in less turnaround time for re-using host channels and at the
  same time increases the performance.
  
  The network transmit performance measured by "iperf" for the "RPi-B v1
  2011/12" board, increased from 45MBit/s to 65Mbit/s after applying the
  changes above.
  
  No regressions seen using:
   - High Speed (BULK, CONTROL, INTERRUPT)
   - Full Speed (All transfer types)
   - Low Speed (Control and Interrupt)
  
  MFC after:1 month
  Submitted by: Daisuke Aoyama 

Modified:
  head/sys/dev/usb/controller/dwc_otg.c
  head/sys/dev/usb/controller/dwc_otg.h
  head/sys/dev/usb/controller/dwc_otgreg.h

Modified: head/sys/dev/usb/controller/dwc_otg.c
==
--- head/sys/dev/usb/controller/dwc_otg.c   Thu Jul 16 15:43:55 2015
(r285637)
+++ head/sys/dev/usb/controller/dwc_otg.c   Thu Jul 16 16:08:40 2015
(r285638)
@@ -1,5 +1,6 @@
 /* $FreeBSD$ */
 /*-
+ * Copyright (c) 2015 Daisuke Aoyama. All rights reserved.
  * Copyright (c) 2012 Hans Petter Selasky. All rights reserved.
  * Copyright (c) 2010-2011 Aleksandr Rybalko. All rights reserved.
  *
@@ -151,7 +152,6 @@ static void dwc_otg_do_poll(struct usb_b
 static void dwc_otg_standard_done(struct usb_xfer *);
 static void dwc_otg_root_intr(struct dwc_otg_softc *);
 static void dwc_otg_interrupt_poll_locked(struct dwc_otg_softc *);
-static void dwc_otg_host_channel_disable(struct dwc_otg_softc *, uint8_t);
 
 /*
  * Here is a configuration that the chip supports.
@@ -224,7 +224,7 @@ dwc_otg_init_fifo(struct dwc_otg_softc *
/* split equally for IN and OUT */
fifo_size /= 2;
 
-   /* align to 4 bytes boundary */
+   /* Align to 4 bytes boundary (refer to PGM) */
fifo_size &= ~3;
 
/* set global receive FIFO size */
@@ -237,13 +237,6 @@ dwc_otg_init_fifo(struct dwc_otg_softc *
return (EINVAL);
}
 
-   /* disable any leftover host channels */
-   for (x = 0; x != sc->sc_host_ch_max; x++) {
-   if (sc->sc_chan_state[x].wait_sof == 0)
-   continue;
-   dwc_otg_host_channel_disable(sc, x);
-   }
-
if (mode == DWC_MODE_HOST) {
 
/* reset active endpoints */
@@ -252,6 +245,8 @@ dwc_otg_init_fifo(struct dwc_otg_softc *
/* split equally for periodic and non-periodic */
fifo_size /= 2;
 
+   DPRINTF("PTX/NPTX FIFO=%u\n", fifo_size);
+
/* align to 4 bytes boundary */
fifo_size &= ~3;
 
@@ -262,7 +257,7 @@ dwc_otg_init_fifo(struct dwc_otg_softc *
tx_start += fifo_size;
 
for (x = 0; x != sc->sc_host_ch_max; x++) {
-   /* disable all host interrupts */
+   /* enable all host interrupts */
DWC_OTG_WRITE_4(sc, DOTG_HCINTMSK(x),
HCINT_DEFAULT_MASK);
}
@@ -274,13 +269,6 @@ dwc_otg_init_fifo(struct dwc_otg_softc *
/* reset host channel state */
memset(sc->sc_chan_state, 0, sizeof(sc->sc_chan_state));
 
-   /* reset FIFO TX levels */
-   sc->sc_tx_cur_p_level = 0;
-   sc->sc_tx_cur_np_level = 0;
-
-   /* store maximum periodic and non-periodic FIFO TX size */
-   sc->sc_tx_max_size = fifo_size;
-
/* enable all host channel interrupts */
DWC_OTG_WRITE_4(sc, DOTG_HAINTMSK,
(1U << sc->sc_host_ch_max) - 1U);
@@ -358,15 +346,8 @@ dwc_otg_init_fifo(struct dwc_otg_softc *
/* reset active endpoints */
sc->sc_active_rx_ep = 0;
 
-   /* reset periodic and non-periodic FIFO TX size */
-   sc->sc_tx_max_size = fifo_size;
-
/* reset host channel state */
memset(sc->sc_chan_state, 0, sizeof(sc->sc_chan_state));
-
-   /* reset FIFO TX levels */
-   sc->sc_tx_cur_p_level = 0;
-   sc->sc_tx_cur_np_level = 0;
}
return (0);
 }
@@ -612,10 +593,39 @@ dwc_otg_clear_hcint(struct dwc_otg_softc
 }
 
 static uint8_t
-dwc_otg_host_channel_alloc(struct dwc_otg_softc *sc, struct dwc_otg_td *td, 
uint8_t is_out)
+dwc_otg_host_check_fifo_empty(struct dwc_otg_softc *sc, struct dwc_otg_td *td)

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

2015-07-16 Thread Sean Bruno
Author: sbruno
Date: Thu Jul 16 16:32:57 2015
New Revision: 285639
URL: https://svnweb.freebsd.org/changeset/base/285639

Log:
  Add an adapter CORE lock in the DDB hook em_dump_queue to avoid WITNESS
  panic in em_init_locked() while debugging.
  
  MFC after:2 weeks
  Sponsored by: Limelight Networks

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

Modified: head/sys/dev/e1000/if_em.c
==
--- head/sys/dev/e1000/if_em.c  Thu Jul 16 16:08:40 2015(r285638)
+++ head/sys/dev/e1000/if_em.c  Thu Jul 16 16:32:57 2015(r285639)
@@ -5998,7 +5998,9 @@ DB_COMMAND(em_reset_dev, em_ddb_reset_de
dev = devclass_get_device(dc, index);
if (device_get_driver(dev) == &em_driver) {
struct adapter *adapter = device_get_softc(dev);
+   EM_CORE_LOCK(adapter);
em_init_locked(adapter);
+   EM_CORE_UNLOCK(adapter);
}
}
 }
___
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: r285550 - head/usr.bin/w

2015-07-16 Thread Bryan Drewery
On 7/14/15 11:53 AM, Mark Murray wrote:
> Author: markm
> Date: Tue Jul 14 18:53:24 2015
> New Revision: 285550
> URL: https://svnweb.freebsd.org/changeset/base/285550
> 
> Log:
>   Widen the host field so that a full IPv6 address will be seen.

Relnotes: yes!

MFC: Please



-- 
Regards,
Bryan Drewery
___
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: r285639 - head/sys/dev/e1000

2015-07-16 Thread Bruce Evans

On Thu, 16 Jul 2015, Sean Bruno wrote:


Log:
 Add an adapter CORE lock in the DDB hook em_dump_queue to avoid WITNESS
 panic in em_init_locked() while debugging.


It is a bug to lock anything from within ddb.

Witness or something should panic when such a lock is attempted.


Modified: head/sys/dev/e1000/if_em.c
==
--- head/sys/dev/e1000/if_em.c  Thu Jul 16 16:08:40 2015(r285638)
+++ head/sys/dev/e1000/if_em.c  Thu Jul 16 16:32:57 2015(r285639)
@@ -5998,7 +5998,9 @@ DB_COMMAND(em_reset_dev, em_ddb_reset_de


The primary bug is probably existence of this command.  You just can't
call arbitary code from within ddb.  It wanders into locks galore.  It
should detect this and panic, but is usually not that smart.  It is
more likely to deadlock.

The existence of the dump command is an even larger error.

The existence of the panic command is a smaller error.  Panic enters
a separate state, similar to ddb's but not as strong.  Panic is a last
resort, so deadlocks and recursive panics in it are acceptable.  It
has some defense against endless recursion.


dev = devclass_get_device(dc, index);
if (device_get_driver(dev) == &em_driver) {


New-bus calls should be locked by Giant or something like that.  This
is probably not done, and the bug is apparently not detected.


struct adapter *adapter = device_get_softc(dev);
+   EM_CORE_LOCK(adapter);
em_init_locked(adapter);


A bug was previously detected here by an assertion that the lock is held.
Acquiring the lock breaks the the detection.

em's mutex is not recursive, so attempting to acquire it from within ddb
like this gives deadlock if it is already held.

In the previous version, suppose you turn off witness so that the bug is
detected.  Then em's mutext locking just doesn't work.


+   EM_CORE_UNLOCK(adapter);
}
}
}


I used checks like the following in a very old version to detect broken
locking calls from within ddb.  This had to be turned off because there
are too many broken callers:

X diff -u2 kern_mutex.c~ kern_mutex.c
X --- kern_mutex.c~ Wed Apr  7 20:39:12 2004
X +++ kern_mutex.c  Sat Feb  3 04:25:00 2007
X @@ -244,4 +246,9 @@
X  {
X 
X +#ifdef DDB1

X + if (db_active)
X + db_printf("_mtx_lock_flags: called with db_active @ %s:%d\n",
X + file, line);
X +#endif
X   MPASS(curthread != NULL);
X   KASSERT(m->mtx_object.lo_class == &lock_class_mtx_sleep,
X @@ -348,4 +355,10 @@
X  {
X 
X +#ifdef DDB1

X + if (db_active)
X + db_printf(
X + "_mtx_lock_spin_flags: called with db_active @ %s:%d\n",
X + file, line);
X +#endif
X   MPASS(curthread != NULL);
X   KASSERT(m->mtx_object.lo_class == &lock_class_mtx_spin,
X @@ -432,4 +445,9 @@
X  #endif
X 
X +#ifdef DDB1

X + if (db_active)
X + db_printf("_mtx_lock_sleep: called with db_active @ %s:%d\n",
X + file, line);
X +#endif
X   if (mtx_owned(m)) {
X   KASSERT((m->mtx_object.lo_flags & LO_RECURSABLE) != 0,
X @@ -568,4 +585,9 @@
X   int i = 0;
X 
X +#ifdef DDB1

X + if (db_active)
X + db_printf("_mtx_lock_spin: called with db_active @ %s:%d\n",
X + file, line);
X +#endif
X   if (LOCK_LOG_TEST(&m->mtx_object, opts))
X   CTR1(KTR_LOCK, "_mtx_lock_spin: %p spinning", m);

The correct way to implement many ddb commands and all instances of call
commands from within ddb is to use a trampoline like gdb does in userland
(or just like signals are handled in userland).  ddb must be exited from
to run the command, and must regain control after running the command.

The dangers of calling arbitrary code are then more obvious.  The code
is then run without ddb's stopping of other CPUs and masking of
interrupts on the current CPU.  Sometimes that allows it to work, but
sometimes it just races more with other CPUs.  The code acts at it is
run by a trap handler that may be entered by any CPU at any address.

An intermediate mode where ddb exits but keeps other CPUs stopped and
interrupts masked might be useful but is hard to implement.  ddb is
too stupid to implement this even for trace traps.  Single stepping is
implemented by exiting ddb for every step (thus starting other CPUs,
etc., for every step) after setting the trace flag to arrange for a
trap after the next instruction.  It is the normal path of execution
that is exited to, so this is relatively safe, but ddb still loses
all control and other threads and interrupts may change the state that
you are trying to see changed 1 step at a time.

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-unsubs

svn commit: r285640 - head/release/doc/en_US.ISO8859-1/relnotes

2015-07-16 Thread Glen Barber
Author: gjb
Date: Thu Jul 16 17:48:37 2015
New Revision: 285640
URL: https://svnweb.freebsd.org/changeset/base/285640

Log:
  Document r285550, w(1) now displays the full IPv6 address of a remote
  connected host.
  
  Sponsored by: The FreeBSD Foundation

Modified:
  head/release/doc/en_US.ISO8859-1/relnotes/article.xml

Modified: head/release/doc/en_US.ISO8859-1/relnotes/article.xml
==
--- head/release/doc/en_US.ISO8859-1/relnotes/article.xml   Thu Jul 16 
16:32:57 2015(r285639)
+++ head/release/doc/en_US.ISO8859-1/relnotes/article.xml   Thu Jul 16 
17:48:37 2015(r285640)
@@ -391,6 +391,10 @@
sponsor="&scaleengine;">The &man.fstyp.8; utility has been
updated to be able to detect &man.zfs.8; and &man.geli.8;
filesystems.
+
+  The &man.w.1; utility has been updated
+   to display the full IPv6 remote address of the host from which
+   a user is connected.
 
 
 
___
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: r285627 - in head/sys: arm/arm arm/at91 arm/cavium/cns11xx arm/samsung/s3c2xx0 arm/xscale/i80321 arm/xscale/i8134x arm/xscale/ixp425 arm/xscale/pxa arm64/arm64 ddb i386/i386 powerpc/bo

2015-07-16 Thread Benjamin Kaduk
On Thu, Jul 16, 2015 at 6:46 AM, Zbigniew Bodek  wrote:

> Author: zbb
> Date: Thu Jul 16 10:46:52 2015
> New Revision: 285627
> URL: https://svnweb.freebsd.org/changeset/base/285627
>
> Log:
>   Fix KSTACK_PAGES issue when the default value was changed in KERNCONF
>
>   If KSTACK_PAGES was changed to anything alse than the default,
>   the value from param.h was taken instead in some places and
>   the value from KENRCONF in some others. This resulted in
>   inconsistency which caused corruption in SMP envorinment.
>
>   Ensure all places where KSTACK_PAGES are used the opt_kstack_pages.h
>   is included.
>

This leads to the question: why is KSTACK_PAGES defined in param.h at all,
if the value will be incorrect for custom kernel configurations?

-Ben
___
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: r285641 - in head/sys: amd64/cloudabi64 compat/cloudabi conf contrib/cloudabi sys

2015-07-16 Thread Ed Schouten
Author: ed
Date: Thu Jul 16 18:24:06 2015
New Revision: 285641
URL: https://svnweb.freebsd.org/changeset/base/285641

Log:
  Add a sysentvec for CloudABI on x86-64.
  
  Summary:
  For CloudABI we need to put two things on the stack of new processes:
  the argument data (a binary blob; not strings) and a startup data
  structure. The startup data structure contains interesting things such
  as a pointer to the ELF program header, the thread ID of the initial
  thread, a stack smashing protection canary, and a pointer to the
  argument data.
  
  Fetching system call arguments and setting the return value is similar
  to FreeBSD. The only differences are that system call 0 does not exist
  and that we call into cloudabi_convert_errno() to convert the error
  code. We also need this function in a couple of other places, so we'd
  better reuse it here.
  
  Reviewers: dchagin, kib
  
  Reviewed By: kib
  
  Subscribers: imp
  
  Differential Revision: https://reviews.freebsd.org/D3098

Added:
  head/sys/amd64/cloudabi64/
  head/sys/amd64/cloudabi64/cloudabi64_sysvec.c   (contents, props changed)
  head/sys/compat/cloudabi/cloudabi_errno.c   (contents, props changed)
  head/sys/compat/cloudabi/cloudabi_util.h   (contents, props changed)
Modified:
  head/sys/conf/files
  head/sys/conf/files.amd64
  head/sys/contrib/cloudabi/syscalldefs_md.h
  head/sys/contrib/cloudabi/syscalldefs_mi.h
  head/sys/sys/sysent.h

Added: head/sys/amd64/cloudabi64/cloudabi64_sysvec.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/amd64/cloudabi64/cloudabi64_sysvec.c   Thu Jul 16 18:24:06 
2015(r285641)
@@ -0,0 +1,230 @@
+/*-
+ * Copyright (c) 2015 Nuxi, https://nuxi.nl/
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+
+extern const char *cloudabi64_syscallnames[];
+extern struct sysent cloudabi64_sysent[];
+
+static register_t *
+cloudabi64_copyout_strings(struct image_params *imgp)
+{
+   uintptr_t begin;
+   size_t len;
+
+   /* Copy out program arguments. */
+   len = imgp->args->begin_envv - imgp->args->begin_argv;
+   begin = rounddown2(USRSTACK - len, sizeof(register_t));
+   copyout(imgp->args->begin_argv, (void *)begin, len);
+   return ((register_t *)begin);
+}
+
+static int
+cloudabi64_fixup(register_t **stack_base, struct image_params *imgp)
+{
+   char canarybuf[64];
+   Elf64_Auxargs *args;
+   void *argdata, *canary;
+   size_t argdatalen;
+   int error;
+
+   /* Store canary for stack smashing protection. */
+   argdata = *stack_base;
+   arc4rand(canarybuf, sizeof(canarybuf), 0);
+   *stack_base -= howmany(sizeof(canarybuf), sizeof(register_t));
+   canary = *stack_base;
+   error = copyout(canarybuf, canary, sizeof(canarybuf));
+   if (error != 0)
+   return (error);
+
+   /*
+* Compute length of program arguments. As the argument data is
+* binary safe, we had to add a trailing null byte in
+* exec_copyin_data_fds(). Undo this by reducing the length.
+*/
+   args = (Elf64_Auxargs *)imgp->auxargs;
+   argdatalen = imgp->args->begin_envv - imgp->args->begin_argv;
+   if (argdatalen > 0)
+   --argdatalen;
+
+   /* Write out an auxiliary vector. */
+   cloudabi64_auxv_t auxv[] = {
+#defineVAL(type, val)  { .a_type = (type), .a_val =

Re: svn commit: r284959 - in head: . share/man/man4 share/man/man9 sys/conf sys/dev/glxsb sys/dev/hifn sys/dev/random sys/dev/rndtest sys/dev/safe sys/dev/syscons sys/dev/ubsec sys/dev/virtio/random s

2015-07-16 Thread Mark R V Murray

> On 16 Jul 2015, at 15:08, Ian Lepore  wrote:
> 
> On Thu, 2015-07-16 at 06:39 +0100, Mark Murray wrote:
>>> On 15 Jul 2015, at 23:43, Adrian Chadd  wrote:
>>> 
 - Add harvesting of slab allocator events. This needs to be checked for
   weighing down the allocator code.
>>> 
>>> Hi,
>>> 
>>> Is this really doing it upon every one of those events? eg, for each
>>> mbuf alloc through UMA?
>> 
>> Only if you turn it on!
>> 
>> M
>> 
> 
> In random_harvestq_init() I see
> 
> harvest_context.hc_source_mask = RANDOM_HARVEST_EVERYTHING_MASK;
> 
> and
> 
> #define RANDOM_HARVEST_EVERYTHING_MASK ((1 << (RANDOM_ENVIRONMENTAL_END
> + 1)) - 1)
> 
> So doesn't that include the RANDOM_FAST flag that controls harvesting
> during every UMA alloc and free call?  And that harvesting appears to be
> anything but fast, at least at a glance... it looks like it passes the
> entire struct uma_zone to the jenkins hash function... is there really
> useful entropy in all the data in that struct?

Well spotted, but fear not. All sources are on at startup, and this
is to ensure that the generator has maximal access to entropy while
booting.

One of the default duties of etc/rc.d/random is to turn off the UMA
and ATIME sources. These may be turned on if you want them, but by
default on the fully booted system they are off.

See ‘sysctl kern.random.harvest.mask_symbolic’ and note that the
disabled sources are in [].

I have yet to do a full set of benchmarks, but I have discussed
this with RWatson. A silly benchmark (make world) shows little
effect, but I will be doing this properly in coming months.

In answer to you final question - yes. The UMA entropy is a bit
spread out, but it is good.

M
-- 
Mark R V Murray

___
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: r285642 - head/crypto/openssh

2015-07-16 Thread Eric van Gyzen
Author: vangyzen
Date: Thu Jul 16 18:44:18 2015
New Revision: 285642
URL: https://svnweb.freebsd.org/changeset/base/285642

Log:
  ssh: canonicize the host name before looking it up in the host file
  
  Re-apply r99054 by des in 2002.  This was accidentally dropped
  by the update to OpenSSH 6.5p1 (r261320).
  
  This change is actually taken from r387082 of
  ports/security/openssh-portable/files/patch-ssh.c
  
  PR:   198043
  Differential Revision:https://reviews.freebsd.org/D3103
  Reviewed by:  des
  Approved by:  kib (mentor)
  MFC after:3 days
  Relnotes: yes
  Sponsored by: Dell Inc.

Modified:
  head/crypto/openssh/ssh.c

Modified: head/crypto/openssh/ssh.c
==
--- head/crypto/openssh/ssh.c   Thu Jul 16 18:24:06 2015(r285641)
+++ head/crypto/openssh/ssh.c   Thu Jul 16 18:44:18 2015(r285642)
@@ -1001,6 +1001,23 @@ main(int ac, char **av)
shorthost[strcspn(thishost, ".")] = '\0';
snprintf(portstr, sizeof(portstr), "%d", options.port);
 
+   /* Find canonic host name. */
+   if (strchr(host, '.') == 0) {
+   struct addrinfo hints;
+   struct addrinfo *ai = NULL;
+   int errgai;
+   memset(&hints, 0, sizeof(hints));
+   hints.ai_family = options.address_family;
+   hints.ai_flags = AI_CANONNAME;
+   hints.ai_socktype = SOCK_STREAM;
+   errgai = getaddrinfo(host, NULL, &hints, &ai);
+   if (errgai == 0) {
+   if (ai->ai_canonname != NULL)
+   host = xstrdup(ai->ai_canonname);
+   freeaddrinfo(ai);
+   }
+   }
+
if (options.local_command != NULL) {
debug3("expanding LocalCommand: %s", options.local_command);
cp = options.local_command;
___
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: r285643 - in head/sys: amd64/amd64 cddl/dev/dtrace/amd64 cddl/dev/dtrace/i386 i386/i386

2015-07-16 Thread Konstantin Belousov
Author: kib
Date: Thu Jul 16 19:40:18 2015
New Revision: 285643
URL: https://svnweb.freebsd.org/changeset/base/285643

Log:
  When checking for the valid value of the frame pointer, verify that it
  belongs to the kernel stack address range for the thread.  Right now,
  code checks that new frame is not farther then KSTACK_PAGES pages from
  the current frame, which allows the address to point past the top of
  the stack.
  
  Reviewed by:  andrew, emaste, markj
  Differential revision:https://reviews.freebsd.org/D3108
  Sponsored by: The FreeBSD Foundation
  MFC after:2 weeks

Modified:
  head/sys/amd64/amd64/stack_machdep.c
  head/sys/cddl/dev/dtrace/amd64/dtrace_isa.c
  head/sys/cddl/dev/dtrace/i386/dtrace_isa.c
  head/sys/i386/i386/stack_machdep.c

Modified: head/sys/amd64/amd64/stack_machdep.c
==
--- head/sys/amd64/amd64/stack_machdep.cThu Jul 16 18:44:18 2015
(r285642)
+++ head/sys/amd64/amd64/stack_machdep.cThu Jul 16 19:40:18 2015
(r285643)
@@ -40,7 +40,7 @@ __FBSDID("$FreeBSD$");
 #include 
 
 static void
-stack_capture(struct stack *st, register_t rbp)
+stack_capture(struct thread *td, struct stack *st, register_t rbp)
 {
struct amd64_frame *frame;
vm_offset_t callpc;
@@ -56,8 +56,8 @@ stack_capture(struct stack *st, register
if (stack_put(st, callpc) == -1)
break;
if (frame->f_frame <= frame ||
-   (vm_offset_t)frame->f_frame >=
-   (vm_offset_t)rbp + KSTACK_PAGES * PAGE_SIZE)
+   (vm_offset_t)frame->f_frame >= td->td_kstack +
+   td->td_kstack_pages * PAGE_SIZE)
break;
frame = frame->f_frame;
}
@@ -74,7 +74,7 @@ stack_save_td(struct stack *st, struct t
panic("stack_save_td: running");
 
rbp = td->td_pcb->pcb_rbp;
-   stack_capture(st, rbp);
+   stack_capture(td, st, rbp);
 }
 
 void
@@ -83,5 +83,5 @@ stack_save(struct stack *st)
register_t rbp;
 
__asm __volatile("movq %%rbp,%0" : "=r" (rbp));
-   stack_capture(st, rbp);
+   stack_capture(curthread, st, rbp);
 }

Modified: head/sys/cddl/dev/dtrace/amd64/dtrace_isa.c
==
--- head/sys/cddl/dev/dtrace/amd64/dtrace_isa.c Thu Jul 16 18:44:18 2015
(r285642)
+++ head/sys/cddl/dev/dtrace/amd64/dtrace_isa.c Thu Jul 16 19:40:18 2015
(r285643)
@@ -89,8 +89,8 @@ dtrace_getpcstack(pc_t *pcstack, int pcs
}
 
if (frame->f_frame <= frame ||
-   (vm_offset_t)frame->f_frame >=
-   (vm_offset_t)rbp + KSTACK_PAGES * PAGE_SIZE)
+   (vm_offset_t)frame->f_frame >= curthread->td_kstack +
+   curthread->td_kstack_pages * PAGE_SIZE)
break;
frame = frame->f_frame;
}
@@ -469,8 +469,8 @@ dtrace_getstackdepth(int aframes)
break;
depth++;
if (frame->f_frame <= frame ||
-   (vm_offset_t)frame->f_frame >=
-   (vm_offset_t)rbp + KSTACK_PAGES * PAGE_SIZE)
+   (vm_offset_t)frame->f_frame >= curthread->td_kstack +
+   curthread->td_kstack_pages * PAGE_SIZE)
break;
frame = frame->f_frame;
}

Modified: head/sys/cddl/dev/dtrace/i386/dtrace_isa.c
==
--- head/sys/cddl/dev/dtrace/i386/dtrace_isa.c  Thu Jul 16 18:44:18 2015
(r285642)
+++ head/sys/cddl/dev/dtrace/i386/dtrace_isa.c  Thu Jul 16 19:40:18 2015
(r285643)
@@ -92,8 +92,8 @@ dtrace_getpcstack(pc_t *pcstack, int pcs
}
 
if (frame->f_frame <= frame ||
-   (vm_offset_t)frame->f_frame >=
-   (vm_offset_t)ebp + KSTACK_PAGES * PAGE_SIZE)
+   (vm_offset_t)frame->f_frame >= curthread->td_kstack +
+   curthread->td_kstack_pages * PAGE_SIZE)
break;
frame = frame->f_frame;
}
@@ -485,8 +485,8 @@ dtrace_getstackdepth(int aframes)
break;
depth++;
if (frame->f_frame <= frame ||
-   (vm_offset_t)frame->f_frame >=
-   (vm_offset_t)ebp + KSTACK_PAGES * PAGE_SIZE)
+   (vm_offset_t)frame->f_frame >= curthread->td_kstack +
+   curthread->td_kstack_pages * PAGE_SIZE)
break;
frame = frame->f_frame;
}

Modified: head/sys/i386/i386/stack_machdep.c
==
--- head/sys/i386/i386/stack_machdep.c  Thu Jul 16 18:44:18 2015
(r285642)
+++

Re: svn commit: r285550 - head/usr.bin/w

2015-07-16 Thread Ed Schouten
Hi Mark,

2015-07-14 20:53 GMT+02:00 Mark Murray :
> Log:
>   Widen the host field so that a full IPv6 address will be seen.
>
> Modified:
>   head/usr.bin/w/w.c
>
> Modified: head/usr.bin/w/w.c
> ==
> --- head/usr.bin/w/w.c  Tue Jul 14 18:45:15 2015(r285549)
> +++ head/usr.bin/w/w.c  Tue Jul 14 18:53:24 2015(r285550)
> @@ -120,7 +120,7 @@ static struct entry {
>
>  #defineW_DISPUSERSIZE  10
>  #defineW_DISPLINESIZE  8
> -#defineW_DISPHOSTSIZE  24
> +#defineW_DISPHOSTSIZE  40
>
>  static void pr_header(time_t *, int);
>  static struct stat *ttystat(char *);

Quick question: does this column width adjust itself automatically?
The "WHAT" column of w(1) is already pretty narrow.

-- 
Ed Schouten 
Nuxi, 's-Hertogenbosch, the Netherlands
KvK/VAT number: 62051717
___
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: r285550 - head/usr.bin/w

2015-07-16 Thread Mark R V Murray

> On 16 Jul 2015, at 20:46, Ed Schouten  wrote:
> 
> Hi Mark,

Hi!

> 2015-07-14 20:53 GMT+02:00 Mark Murray :
>> Log:
>>  Widen the host field so that a full IPv6 address will be seen.
>> 
> 
> Quick question: does this column width adjust itself automatically?
> The "WHAT" column of w(1) is already pretty narrow.

No. This column is statically sized.

The “what" column” prints arbitrary length lines. I’ve hardly ever
seen anything long in practice though.

M
-- 
Mark R V Murray

___
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: r285550 - head/usr.bin/w

2015-07-16 Thread Mark R V Murray

> On 16 Jul 2015, at 18:35, Bryan Drewery  wrote:
> 
> On 7/14/15 11:53 AM, Mark Murray wrote:
>> Author: markm
>> Date: Tue Jul 14 18:53:24 2015
>> New Revision: 285550
>> URL: https://svnweb.freebsd.org/changeset/base/285550
>> 
>> Log:
>>  Widen the host field so that a full IPv6 address will be seen.
> 
> Relnotes: yes!

Damn you! ;-)

I’ve just had to install the kitchen sink to do this!

(The building is a bit out of date; the optional ports
don’t exist, and installing textproc/fpo resulted in a
tool that did not make a readable PDF).

> MFC: Please

Er, sure!

M
-- 
Mark R V Murray

___
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: r285550 - head/usr.bin/w

2015-07-16 Thread Bryan Drewery
On 7/16/15 12:55 PM, Mark R V Murray wrote:
> 
>> On 16 Jul 2015, at 18:35, Bryan Drewery  wrote:
>>
>> On 7/14/15 11:53 AM, Mark Murray wrote:
>>> Author: markm
>>> Date: Tue Jul 14 18:53:24 2015
>>> New Revision: 285550
>>> URL: https://svnweb.freebsd.org/changeset/base/285550
>>>
>>> Log:
>>>  Widen the host field so that a full IPv6 address will be seen.
>>
>> Relnotes: yes!
> 
> Damn you! ;-)
> 
> I’ve just had to install the kitchen sink to do this!
> 
> (The building is a bit out of date; the optional ports
> don’t exist, and installing textproc/fpo resulted in a
> tool that did not make a readable PDF).
> 

If you put the literal 'Relnotes:   yes' in your commit then gjb/re@ will
document it for you :)

>> MFC: Please
> 
> Er, sure!
> 
> M
> 


-- 
Regards,
Bryan Drewery
___
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: r285644 - head/contrib/sqlite3

2015-07-16 Thread Pedro F. Giffuni
Author: pfg
Date: Thu Jul 16 22:07:13 2015
New Revision: 285644
URL: https://svnweb.freebsd.org/changeset/base/285644

Log:
  sqlite: clean a couple of invocations of memcpy(3)
  
  Found almost accidentally by our native gcc when enhanced with
  FORTIFY_SOURCE.
  
  Submitted by: Oliver Pinter
  Sponosored by:Google Inc. GSoC 2015

Modified:
  head/contrib/sqlite3/sqlite3.c

Modified: head/contrib/sqlite3/sqlite3.c
==
--- head/contrib/sqlite3/sqlite3.c  Thu Jul 16 19:40:18 2015
(r285643)
+++ head/contrib/sqlite3/sqlite3.c  Thu Jul 16 22:07:13 2015
(r285644)
@@ -49487,9 +49487,9 @@ static void walIndexWriteHdr(Wal *pWal){
   pWal->hdr.isInit = 1;
   pWal->hdr.iVersion = WALINDEX_MAX_VERSION;
   walChecksumBytes(1, (u8*)&pWal->hdr, nCksum, 0, pWal->hdr.aCksum);
-  memcpy((void *)&aHdr[1], (void *)&pWal->hdr, sizeof(WalIndexHdr));
+  memcpy((void *)&aHdr[1], (const void *)&pWal->hdr, sizeof(WalIndexHdr));
   walShmBarrier(pWal);
-  memcpy((void *)&aHdr[0], (void *)&pWal->hdr, sizeof(WalIndexHdr));
+  memcpy((void *)&aHdr[0], (const void *)&pWal->hdr, sizeof(WalIndexHdr));
 }
 
 /*
___
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: r285644 - head/contrib/sqlite3

2015-07-16 Thread Baptiste Daroussin
On Thu, Jul 16, 2015 at 10:07:14PM +, Pedro F. Giffuni wrote:
> Author: pfg
> Date: Thu Jul 16 22:07:13 2015
> New Revision: 285644
> URL: https://svnweb.freebsd.org/changeset/base/285644
> 
> Log:
>   sqlite: clean a couple of invocations of memcpy(3)
>   
>   Found almost accidentally by our native gcc when enhanced with
>   FORTIFY_SOURCE.
>   
>   Submitted by:   Oliver Pinter
>   Sponosored by:  Google Inc. GSoC 2015
> 
> Modified:
>   head/contrib/sqlite3/sqlite3.c
> 
> Modified: head/contrib/sqlite3/sqlite3.c
> ==
> --- head/contrib/sqlite3/sqlite3.cThu Jul 16 19:40:18 2015
> (r285643)
> +++ head/contrib/sqlite3/sqlite3.cThu Jul 16 22:07:13 2015
> (r285644)
> @@ -49487,9 +49487,9 @@ static void walIndexWriteHdr(Wal *pWal){
>pWal->hdr.isInit = 1;
>pWal->hdr.iVersion = WALINDEX_MAX_VERSION;
>walChecksumBytes(1, (u8*)&pWal->hdr, nCksum, 0, pWal->hdr.aCksum);
> -  memcpy((void *)&aHdr[1], (void *)&pWal->hdr, sizeof(WalIndexHdr));
> +  memcpy((void *)&aHdr[1], (const void *)&pWal->hdr, sizeof(WalIndexHdr));
>walShmBarrier(pWal);
> -  memcpy((void *)&aHdr[0], (void *)&pWal->hdr, sizeof(WalIndexHdr));
> +  memcpy((void *)&aHdr[0], (const void *)&pWal->hdr, sizeof(WalIndexHdr));
>  }
>  
>  /*
> 
Have you upstreamed that? because given how sqlite3.c file is done it will be a
pain on next update to not drop this change!

Best regards,
Bapt


pgp07UXtNYZHs.pgp
Description: PGP signature


Re: svn commit: r285644 - head/contrib/sqlite3

2015-07-16 Thread Ian Lepore
On Thu, 2015-07-16 at 22:07 +, Pedro F. Giffuni wrote:
> Author: pfg
> Date: Thu Jul 16 22:07:13 2015
> New Revision: 285644
> URL: https://svnweb.freebsd.org/changeset/base/285644
> 
> Log:
>   sqlite: clean a couple of invocations of memcpy(3)
>   
>   Found almost accidentally by our native gcc when enhanced with
>   FORTIFY_SOURCE.
>   
>   Submitted by:   Oliver Pinter
>   Sponosored by:  Google Inc. GSoC 2015
> 
> Modified:
>   head/contrib/sqlite3/sqlite3.c
> 
> Modified: head/contrib/sqlite3/sqlite3.c
> ==
> --- head/contrib/sqlite3/sqlite3.cThu Jul 16 19:40:18 2015
> (r285643)
> +++ head/contrib/sqlite3/sqlite3.cThu Jul 16 22:07:13 2015
> (r285644)
> @@ -49487,9 +49487,9 @@ static void walIndexWriteHdr(Wal *pWal){
>pWal->hdr.isInit = 1;
>pWal->hdr.iVersion = WALINDEX_MAX_VERSION;
>walChecksumBytes(1, (u8*)&pWal->hdr, nCksum, 0, pWal->hdr.aCksum);
> -  memcpy((void *)&aHdr[1], (void *)&pWal->hdr, sizeof(WalIndexHdr));
> +  memcpy((void *)&aHdr[1], (const void *)&pWal->hdr, sizeof(WalIndexHdr));
>walShmBarrier(pWal);
> -  memcpy((void *)&aHdr[0], (void *)&pWal->hdr, sizeof(WalIndexHdr));
> +  memcpy((void *)&aHdr[0], (const void *)&pWal->hdr, sizeof(WalIndexHdr));
>  }
>  
>  /*
> 

Setting aside any "unnecessary divergence with upstream" questions for
the moment, wouldn't the correct fix be to just remove the casting
completely?

-- 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: r285644 - head/contrib/sqlite3

2015-07-16 Thread Pedro Giffuni



On 07/16/15 17:16, Baptiste Daroussin wrote:

On Thu, Jul 16, 2015 at 10:07:14PM +, Pedro F. Giffuni wrote:

Author: pfg
Date: Thu Jul 16 22:07:13 2015
New Revision: 285644
URL: https://svnweb.freebsd.org/changeset/base/285644

Log:
   sqlite: clean a couple of invocations of memcpy(3)
   
   Found almost accidentally by our native gcc when enhanced with

   FORTIFY_SOURCE.
   
   Submitted by:	Oliver Pinter

   Sponosored by:   Google Inc. GSoC 2015

Modified:
   head/contrib/sqlite3/sqlite3.c

Modified: head/contrib/sqlite3/sqlite3.c
==
--- head/contrib/sqlite3/sqlite3.c  Thu Jul 16 19:40:18 2015
(r285643)
+++ head/contrib/sqlite3/sqlite3.c  Thu Jul 16 22:07:13 2015
(r285644)
@@ -49487,9 +49487,9 @@ static void walIndexWriteHdr(Wal *pWal){
pWal->hdr.isInit = 1;
pWal->hdr.iVersion = WALINDEX_MAX_VERSION;
walChecksumBytes(1, (u8*)&pWal->hdr, nCksum, 0, pWal->hdr.aCksum);
-  memcpy((void *)&aHdr[1], (void *)&pWal->hdr, sizeof(WalIndexHdr));
+  memcpy((void *)&aHdr[1], (const void *)&pWal->hdr, sizeof(WalIndexHdr));
walShmBarrier(pWal);
-  memcpy((void *)&aHdr[0], (void *)&pWal->hdr, sizeof(WalIndexHdr));
+  memcpy((void *)&aHdr[0], (const void *)&pWal->hdr, sizeof(WalIndexHdr));
  }
  
  /*



Have you upstreamed that? because given how sqlite3.c file is done it will be a
pain on next update to not drop this change!


I asked Oliver to do it, but I will crosscheck.

Pedro.

___
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: r284959 - in head: . share/man/man4 share/man/man9 sys/conf sys/dev/glxsb sys/dev/hifn sys/dev/random sys/dev/rndtest sys/dev/safe sys/dev/syscons sys/dev/ubsec sys/dev/virtio/random s

2015-07-16 Thread K. Macy
I discovered this when I MFC'd and my kernel wouldn't link because of
unresolved symbols. I thought I had put the issue aside when I added
RANDOM_DUMMY to my kernel config.

However, I just hit this:

while (!random_alg_context.ra_seeded()) {
if (nonblock) {
error = EWOULDBLOCK;
break;
}
tsleep(&random_alg_context, 0, "randseed", hz/10);
/* keep tapping away at the pre-read until we seed/unblock. */
random_alg_context.ra_pre_read();
printf("random: %s unblock wait\n", __func__);
}

My system wouldn't boot because this was endlessly spamming the
console. I don't know what the right default here is. But I can say
that this is not it.

I would also like to observe that a good back of the envelope
per-packet budget is 1000 cycles (stock FreeBSD is much worse than
this - nonetheless it is a reasonable figure to strive for). Many
drivers will for a variety of reasons allocate mbufs and clusters
separately. This means that if you're harvesting on alloc / free, your
function is being called 4 times per-packet. Let's have a hypothetical
that your function takes 50 cycles* - in this case your entropy
collection would be consuming a full 20% of the per-packet budget. At
high-packet rates your entropy is likely to be caused more by
indeterminacy of cache misses and lock contention than any true
randomness in the arrival rate.


* It may be less, it may be much more.


I'm not sure where the workflow fell short in this instance, but I'm
inclined to believe that this could have been handled better.

-K



On Thu, Jul 16, 2015 at 11:29 AM, Mark R V Murray  wrote:
>
>> On 16 Jul 2015, at 15:08, Ian Lepore  wrote:
>>
>> On Thu, 2015-07-16 at 06:39 +0100, Mark Murray wrote:
 On 15 Jul 2015, at 23:43, Adrian Chadd  wrote:

> - Add harvesting of slab allocator events. This needs to be checked for
>   weighing down the allocator code.

 Hi,

 Is this really doing it upon every one of those events? eg, for each
 mbuf alloc through UMA?
>>>
>>> Only if you turn it on!
>>>
>>> M
>>>
>>
>> In random_harvestq_init() I see
>>
>> harvest_context.hc_source_mask = RANDOM_HARVEST_EVERYTHING_MASK;
>>
>> and
>>
>> #define RANDOM_HARVEST_EVERYTHING_MASK ((1 << (RANDOM_ENVIRONMENTAL_END
>> + 1)) - 1)
>>
>> So doesn't that include the RANDOM_FAST flag that controls harvesting
>> during every UMA alloc and free call?  And that harvesting appears to be
>> anything but fast, at least at a glance... it looks like it passes the
>> entire struct uma_zone to the jenkins hash function... is there really
>> useful entropy in all the data in that struct?
>
> Well spotted, but fear not. All sources are on at startup, and this
> is to ensure that the generator has maximal access to entropy while
> booting.
>
> One of the default duties of etc/rc.d/random is to turn off the UMA
> and ATIME sources. These may be turned on if you want them, but by
> default on the fully booted system they are off.
>
> See ‘sysctl kern.random.harvest.mask_symbolic’ and note that the
> disabled sources are in [].
>
> I have yet to do a full set of benchmarks, but I have discussed
> this with RWatson. A silly benchmark (make world) shows little
> effect, but I will be doing this properly in coming months.
>
> In answer to you final question - yes. The UMA entropy is a bit
> spread out, but it is good.
>
> M
> --
> Mark R V Murray
>
> ___
> 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-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: r285644 - head/contrib/sqlite3

2015-07-16 Thread Pedro Giffuni



On 07/16/15 17:22, Ian Lepore wrote:

On Thu, 2015-07-16 at 22:07 +, Pedro F. Giffuni wrote:

Author: pfg
Date: Thu Jul 16 22:07:13 2015
New Revision: 285644
URL: https://svnweb.freebsd.org/changeset/base/285644

Log:
   sqlite: clean a couple of invocations of memcpy(3)
   
   Found almost accidentally by our native gcc when enhanced with

   FORTIFY_SOURCE.
   
   Submitted by:	Oliver Pinter

   Sponosored by:   Google Inc. GSoC 2015

Modified:
   head/contrib/sqlite3/sqlite3.c

Modified: head/contrib/sqlite3/sqlite3.c
==
--- head/contrib/sqlite3/sqlite3.c  Thu Jul 16 19:40:18 2015
(r285643)
+++ head/contrib/sqlite3/sqlite3.c  Thu Jul 16 22:07:13 2015
(r285644)
@@ -49487,9 +49487,9 @@ static void walIndexWriteHdr(Wal *pWal){
pWal->hdr.isInit = 1;
pWal->hdr.iVersion = WALINDEX_MAX_VERSION;
walChecksumBytes(1, (u8*)&pWal->hdr, nCksum, 0, pWal->hdr.aCksum);
-  memcpy((void *)&aHdr[1], (void *)&pWal->hdr, sizeof(WalIndexHdr));
+  memcpy((void *)&aHdr[1], (const void *)&pWal->hdr, sizeof(WalIndexHdr));
walShmBarrier(pWal);
-  memcpy((void *)&aHdr[0], (void *)&pWal->hdr, sizeof(WalIndexHdr));
+  memcpy((void *)&aHdr[0], (const void *)&pWal->hdr, sizeof(WalIndexHdr));
  }
  
  /*



Setting aside any "unnecessary divergence with upstream" questions for
the moment, wouldn't the correct fix be to just remove the casting
completely?


The compiler should know, but it is not wrong to have the casts
match the (standard) implementation. I couldn't say which is
"more" correct.

Pedro.
___
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: r284959 - in head: . share/man/man4 share/man/man9 sys/conf sys/dev/glxsb sys/dev/hifn sys/dev/random sys/dev/rndtest sys/dev/safe sys/dev/syscons sys/dev/ubsec sys/dev/virtio/random s

2015-07-16 Thread K. Macy
On Thu, Jul 16, 2015 at 3:28 PM, K. Macy  wrote:
> I discovered this when I MFC'd and my kernel wouldn't link because of
> unresolved symbols. I thought I had put the issue aside when I added
> RANDOM_DUMMY to my kernel config.
>
> However, I just hit this:
>
> while (!random_alg_context.ra_seeded()) {
> if (nonblock) {
> error = EWOULDBLOCK;
> break;
> }
> tsleep(&random_alg_context, 0, "randseed", hz/10);
> /* keep tapping away at the pre-read until we seed/unblock. */
> random_alg_context.ra_pre_read();
> printf("random: %s unblock wait\n", __func__);
> }
>
> My system wouldn't boot because this was endlessly spamming the
> console. I don't know what the right default here is. But I can say
> that this is not it.


I've also realized that a process blocked here is uninterruptible.
Hence any process reading an insufficiently seeded /dev/random is
unkillable. For example my boot can't proceed past dd doing a read and
I can't ^C it. Did you test RANDOM_DUMMY?


-K
___
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: r285645 - head/bin/dd

2015-07-16 Thread David E. O'Brien
Author: obrien
Date: Thu Jul 16 23:38:12 2015
New Revision: 285645
URL: https://svnweb.freebsd.org/changeset/base/285645

Log:
  Mention the dd-like recoverdisk(1) to help folks find this great BSD command.

Modified:
  head/bin/dd/dd.1

Modified: head/bin/dd/dd.1
==
--- head/bin/dd/dd.1Thu Jul 16 22:07:13 2015(r285644)
+++ head/bin/dd/dd.1Thu Jul 16 23:38:12 2015(r285645)
@@ -416,6 +416,7 @@ if necessary, to a 1MiB boundary:
 .Sh SEE ALSO
 .Xr cp 1 ,
 .Xr mt 1 ,
+.Xr recoverdisk 1 ,
 .Xr tr 1 ,
 .Xr geom 4
 .Sh STANDARDS
___
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: r285627 - in head/sys: arm/arm arm/at91 arm/cavium/cns11xx arm/samsung/s3c2xx0 arm/xscale/i80321 arm/xscale/i8134x arm/xscale/ixp425 arm/xscale/pxa arm64/arm64 ddb i386/i386 powerpc/bo

2015-07-16 Thread Warner Losh

> On Jul 16, 2015, at 12:02 PM, Benjamin Kaduk  wrote:
> 
> On Thu, Jul 16, 2015 at 6:46 AM, Zbigniew Bodek  wrote:
> Author: zbb
> Date: Thu Jul 16 10:46:52 2015
> New Revision: 285627
> URL: https://svnweb.freebsd.org/changeset/base/285627
> 
> Log:
>   Fix KSTACK_PAGES issue when the default value was changed in KERNCONF
> 
>   If KSTACK_PAGES was changed to anything alse than the default,
>   the value from param.h was taken instead in some places and
>   the value from KENRCONF in some others. This resulted in
>   inconsistency which caused corruption in SMP envorinment.
> 
>   Ensure all places where KSTACK_PAGES are used the opt_kstack_pages.h
>   is included.
> 
> This leads to the question: why is KSTACK_PAGES defined in param.h at all, if 
> the value will be incorrect for custom kernel configurations?

It is a work around for the Cavium arm64 kernel. It may or
may not be needed in the fullness of time, but for now it’s needed
to make progress on the port.

Warner



signature.asc
Description: Message signed with OpenPGP using GPGMail


svn commit: r285647 - head/sbin/geom/class/multipath

2015-07-16 Thread Marcelo Araujo
Author: araujo (ports committer)
Date: Fri Jul 17 06:34:46 2015
New Revision: 285647
URL: https://svnweb.freebsd.org/changeset/base/285647

Log:
  Describe how to load gmultipath at boot time.
  
  Differential Revision:D3112
  Reviewed by:  allanjude, bapt
  Sponsored by: gandi.net

Modified:
  head/sbin/geom/class/multipath/gmultipath.8

Modified: head/sbin/geom/class/multipath/gmultipath.8
==
--- head/sbin/geom/class/multipath/gmultipath.8 Fri Jul 17 00:00:04 2015
(r285646)
+++ head/sbin/geom/class/multipath/gmultipath.8 Fri Jul 17 06:34:46 2015
(r285647)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd June 11, 2015
+.Dd July 17, 2015
 .Dt GMULTIPATH 8
 .Os
 .Sh NAME
@@ -350,6 +350,16 @@ GEOM_MULTIPATH: da0 added to FRED
 GEOM_MULTIPATH: da0 is now active path in FRED
 GEOM_MULTIPATH: da2 added to FRED
 .Ed
+.Ed
+.Pp
+To load the
+.Nm
+Module at boot time, add the following entry to
+.Pa /boot/loader.conf:
+.Bd -literal -offset ident
+geom_multipath_load="YES"
+.Ed
+.Ed
 .Sh SEE ALSO
 .Xr geom 4 ,
 .Xr isp 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: r285648 - in head/sys/dev/cxgbe: . common

2015-07-16 Thread Navdeep Parhar
Author: np
Date: Fri Jul 17 06:46:18 2015
New Revision: 285648
URL: https://svnweb.freebsd.org/changeset/base/285648

Log:
  cxgbe(4): Ask the firmware for the start of the RSS slice for a port and
  save it for later.  This enables direct manipulation of the indirection
  tables (although the stock driver doesn't do that right now).
  
  MFC after:1 month

Modified:
  head/sys/dev/cxgbe/adapter.h
  head/sys/dev/cxgbe/common/t4_hw.c

Modified: head/sys/dev/cxgbe/adapter.h
==
--- head/sys/dev/cxgbe/adapter.hFri Jul 17 06:34:46 2015
(r285647)
+++ head/sys/dev/cxgbe/adapter.hFri Jul 17 06:46:18 2015
(r285648)
@@ -233,6 +233,7 @@ struct port_info {
uint16_t viid;
int16_t  xact_addr_filt;/* index of exact MAC address filter */
uint16_t rss_size;  /* size of VI's RSS table slice */
+   uint16_t rss_base;  /* start of VI's RSS table slice */
uint8_t  lport; /* associated offload logical port */
int8_t   mdio_addr;
uint8_t  port_type;

Modified: head/sys/dev/cxgbe/common/t4_hw.c
==
--- head/sys/dev/cxgbe/common/t4_hw.c   Fri Jul 17 06:34:46 2015
(r285647)
+++ head/sys/dev/cxgbe/common/t4_hw.c   Fri Jul 17 06:46:18 2015
(r285648)
@@ -5699,6 +5699,7 @@ int __devinit t4_port_init(struct port_i
struct fw_port_cmd c;
u16 rss_size;
adapter_t *adap = p->adapter;
+   u32 param, val;
 
memset(&c, 0, sizeof(c));
 
@@ -5737,6 +5738,17 @@ int __devinit t4_port_init(struct port_i
 
init_link_config(&p->link_cfg, ntohs(c.u.info.pcap));
 
+   param = V_FW_PARAMS_MNEM(FW_PARAMS_MNEM_DEV) |
+   V_FW_PARAMS_PARAM_X(FW_PARAMS_PARAM_DEV_RSSINFO) |
+   V_FW_PARAMS_PARAM_YZ(p->viid);
+   ret = t4_query_params(adap, mbox, pf, vf, 1, ¶m, &val);
+   if (ret)
+   p->rss_base = 0x;
+   else {
+   /* MPASS((val >> 16) == rss_size); */
+   p->rss_base = val & 0x;
+   }
+
return 0;
 }
 
___
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: r284959 - in head: . share/man/man4 share/man/man9 sys/conf sys/dev/glxsb sys/dev/hifn sys/dev/random sys/dev/rndtest sys/dev/safe sys/dev/syscons sys/dev/ubsec sys/dev/virtio/random s

2015-07-16 Thread Adrian Chadd
hi,

So I'll have to update the AP images that I build, as now I have to
add that sysctl to things.

It also means everyone has to update their /etc after updating or
they'll end up with this particular mode not being disabled.

i think we need to get this better documented so people aren't bitten
when they merge code in from -HEAD or whenever you do MFC this back to
stable/10.



-adrian

On 16 July 2015 at 16:14, K. Macy  wrote:
> On Thu, Jul 16, 2015 at 3:28 PM, K. Macy  wrote:
>> I discovered this when I MFC'd and my kernel wouldn't link because of
>> unresolved symbols. I thought I had put the issue aside when I added
>> RANDOM_DUMMY to my kernel config.
>>
>> However, I just hit this:
>>
>> while (!random_alg_context.ra_seeded()) {
>> if (nonblock) {
>> error = EWOULDBLOCK;
>> break;
>> }
>> tsleep(&random_alg_context, 0, "randseed", hz/10);
>> /* keep tapping away at the pre-read until we seed/unblock. 
>> */
>> random_alg_context.ra_pre_read();
>> printf("random: %s unblock wait\n", __func__);
>> }
>>
>> My system wouldn't boot because this was endlessly spamming the
>> console. I don't know what the right default here is. But I can say
>> that this is not it.
>
>
> I've also realized that a process blocked here is uninterruptible.
> Hence any process reading an insufficiently seeded /dev/random is
> unkillable. For example my boot can't proceed past dd doing a read and
> I can't ^C it. Did you test RANDOM_DUMMY?
>
>
> -K
>
___
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: r284959 - in head: . share/man/man4 share/man/man9 sys/conf sys/dev/glxsb sys/dev/hifn sys/dev/random sys/dev/rndtest sys/dev/safe sys/dev/syscons sys/dev/ubsec sys/dev/virtio/random s

2015-07-16 Thread Mark R V Murray

> On 17 Jul 2015, at 07:47, Adrian Chadd  wrote:
> 
> hi,
> 
> So I'll have to update the AP images that I build, as now I have to
> add that sysctl to things.

Well, measure the effect. It may not be as bad as it may seem! :-)

> It also means everyone has to update their /etc after updating or
> they'll end up with this particular mode not being disabled.

That is usual, right? Do a mergemaster after a make world?

> i think we need to get this better documented so people aren't bitten
> when they merge code in from -HEAD or whenever you do MFC this back to
> stable/10.

I’m not yet planning an MFC to 10.x

> -adrian 

M
— 
Mark R V Murray

___
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"