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

2017-03-17 Thread Hans Petter Selasky
Author: hselasky
Date: Fri Mar 17 08:02:46 2017
New Revision: 315442
URL: https://svnweb.freebsd.org/changeset/base/315442

Log:
  Add comment describing the use of pagefault_disable() and
  pagefault_enable() in the LinuxKPI.
  
  Suggested by: rpokala@
  MFC after:1 week
  Sponsored by: Mellanox Technologies

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

Modified: head/sys/compat/linuxkpi/common/include/linux/uaccess.h
==
--- head/sys/compat/linuxkpi/common/include/linux/uaccess.h Fri Mar 17 
07:56:20 2017(r315441)
+++ head/sys/compat/linuxkpi/common/include/linux/uaccess.h Fri Mar 17 
08:02:46 2017(r315442)
@@ -67,6 +67,13 @@ extern int linux_copyout(const void *kad
 extern size_t linux_clear_user(void *uaddr, size_t len);
 extern int linux_access_ok(int rw, const void *uaddr, size_t len);
 
+/*
+ * NOTE: Each pagefault_disable() call must have a corresponding
+ * pagefault_enable() call in the same scope. The former creates a new
+ * block and defines a temporary variable, and the latter uses the
+ * temporary variable and closes the block. Failure to balance the
+ * calls will result in a compile-time error.
+ */
 #definepagefault_disable(void) do {\
int __saved_pflags =\
vm_fault_disable_pagefaults()
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


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

2017-03-17 Thread Hans Petter Selasky
Author: hselasky
Date: Fri Mar 17 10:30:06 2017
New Revision: 315443
URL: https://svnweb.freebsd.org/changeset/base/315443

Log:
  Implement minimalistic memory mapping structure, struct mm_struct, and
  some associated helper functions in the LinuxKPI. Let the existing
  linux_alloc_current() function allocate and initialize the new
  structure and let linux_free_current() drop the refcount on the memory
  mapping structure. When the mm_struct's refcount reaches zero, the
  structure is freed.
  
  Obtained from:kmacy @
  MFC after:1 week
  Sponsored by: Mellanox Technologies

Added:
  head/sys/compat/linuxkpi/common/include/linux/mm_types.h   (contents, props 
changed)
Modified:
  head/sys/compat/linuxkpi/common/include/linux/mm.h
  head/sys/compat/linuxkpi/common/include/linux/sched.h
  head/sys/compat/linuxkpi/common/src/linux_current.c

Modified: head/sys/compat/linuxkpi/common/include/linux/mm.h
==
--- head/sys/compat/linuxkpi/common/include/linux/mm.h  Fri Mar 17 08:02:46 
2017(r315442)
+++ head/sys/compat/linuxkpi/common/include/linux/mm.h  Fri Mar 17 10:30:06 
2017(r315443)
@@ -36,6 +36,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #definePAGE_ALIGN(x)   ALIGN(x, PAGE_SIZE)
 

Added: head/sys/compat/linuxkpi/common/include/linux/mm_types.h
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/compat/linuxkpi/common/include/linux/mm_types.hFri Mar 17 
10:30:06 2017(r315443)
@@ -0,0 +1,71 @@
+/*-
+ * Copyright (c) 2017 Mellanox Technologies, Ltd.
+ * All rights reserved.
+ *
+ * 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 unmodified, 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 ``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 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.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _LINUX_MM_TYPES_H_
+#define_LINUX_MM_TYPES_H_
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+struct vm_area_struct;
+struct task_struct;
+struct vmspace;
+
+struct mm_struct {
+   struct vm_area_struct *mmap;
+   struct vmspace *vmspace;
+   atomic_t mm_count;
+   atomic_t mm_users;
+   size_t pinned_vm;
+   struct rw_semaphore mmap_sem;
+};
+
+extern void linux_mm_dtor(struct mm_struct *mm);
+
+static inline void
+mmdrop(struct mm_struct *mm)
+{
+   if (__predict_false(atomic_dec_and_test(&mm->mm_count)))
+   linux_mm_dtor(mm);
+}
+
+static inline void
+mmput(struct mm_struct *mm)
+{
+   if (__predict_false(atomic_dec_and_test(&mm->mm_users)))
+   mmdrop(mm);
+}
+
+extern struct mm_struct *linux_get_task_mm(struct task_struct *);
+#defineget_task_mm(task) linux_get_task_mm(task)
+
+#endif /* _LINUX_MM_TYPES_H_ */

Modified: head/sys/compat/linuxkpi/common/include/linux/sched.h
==
--- head/sys/compat/linuxkpi/common/include/linux/sched.h   Fri Mar 17 
08:02:46 2017(r315442)
+++ head/sys/compat/linuxkpi/common/include/linux/sched.h   Fri Mar 17 
10:30:06 2017(r315443)
@@ -40,6 +40,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -54,6 +55,7 @@
 
 struct task_struct {
struct thread *task_thread;
+   struct mm_struct *mm;
linux_task_fn_t *task_fn;
void   *task_data;
int task_ret;

Modified: head/sys/compat/linuxkpi/common/src/linux_current.c
==
--- head/sys/compat/linuxkpi/common/src/linux_current.c Fri Mar 17 08:02:46 
2017(r315442)
+++ head/sys/compat/linuxkpi/common/src/linux_current.c Fri Mar 17 10:30:06 
2017(r31544

svn commit: r315447 - head/usr.sbin/bsdinstall/scripts

2017-03-17 Thread Bartek Rutkowski
Author: robak (ports committer)
Date: Fri Mar 17 11:45:46 2017
New Revision: 315447
URL: https://svnweb.freebsd.org/changeset/base/315447

Log:
  Revert changes introduced in r314036 on demand by jhb and bapt.
  
  Approved by:  bapt, jhb

Modified:
  head/usr.sbin/bsdinstall/scripts/hardening

Modified: head/usr.sbin/bsdinstall/scripts/hardening
==
--- head/usr.sbin/bsdinstall/scripts/hardening  Fri Mar 17 11:45:16 2017
(r315446)
+++ head/usr.sbin/bsdinstall/scripts/hardening  Fri Mar 17 11:45:46 2017
(r315447)
@@ -36,15 +36,15 @@ FEATURES=$( dialog --backtitle "FreeBSD 
 --title "System Hardening" --nocancel --separate-output \
 --checklist "Choose system security hardening options:" \
 0 0 0 \
-   "0 hide_uids" "Hide processes running as other users" ${hide_uids:-on} \
-   "1 hide_gids" "Hide processes running as other groups" ${hide_gids:-on} 
\
-   "2 read_msgbuf" "Disable reading kernel message buffer for unprivileged 
users" ${read_msgbuf:-on} \
-   "3 proc_debug" "Disable process debugging facilities for unprivileged 
users" ${proc_debug:-on} \
-   "4 random_pid" "Randomize the PID of newly created processes" 
${random_pid:-on} \
-   "5 stack_guard" "Insert stack guard page ahead of the growable 
segments" ${stack_guard:-on} \
-   "6 clear_tmp" "Clean the /tmp filesystem on system startup" 
${clear_tmp:-on} \
-   "7 disable_syslogd" "Disable opening Syslogd network socket (disables 
remote logging)" ${disable_syslogd:-on} \
-   "8 disable_sendmail" "Disable Sendmail service" ${disable_sendmail:-on} 
\
+   "0 hide_uids" "Hide processes running as other users" ${hide_uids:-off} 
\
+   "1 hide_gids" "Hide processes running as other groups" 
${hide_gids:-off} \
+   "2 read_msgbuf" "Disable reading kernel message buffer for unprivileged 
users" ${read_msgbuf:-off} \
+   "3 proc_debug" "Disable process debugging facilities for unprivileged 
users" ${proc_debug:-off} \
+   "4 random_pid" "Randomize the PID of newly created processes" 
${random_pid:-off} \
+   "5 stack_guard" "Insert stack guard page ahead of the growable 
segments" ${stack_guard:-off} \
+   "6 clear_tmp" "Clean the /tmp filesystem on system startup" 
${clear_tmp:-off} \
+   "7 disable_syslogd" "Disable opening Syslogd network socket (disables 
remote logging)" ${disable_syslogd:-off} \
+   "8 disable_sendmail" "Disable Sendmail service" 
${disable_sendmail:-off} \
 2>&1 1>&3 )
 exec 3>&-
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r315448 - in head/sys/arm: conf freescale/imx

2017-03-17 Thread Andrew Turner
Author: andrew
Date: Fri Mar 17 12:34:56 2017
New Revision: 315448
URL: https://svnweb.freebsd.org/changeset/base/315448

Log:
  Move the IMX6 kernels to use PLATFORM_SMP. This is the last SMP config to
  be migrated to this and will allow the removal of this option.
  
  Reviewed by:  ian
  Sponsored by: ABT Systems Ltd
  Differential Revision:https://reviews.freebsd.org/D9907

Added:
  head/sys/arm/freescale/imx/imx6_mp.h   (contents, props changed)
Modified:
  head/sys/arm/conf/IMX6
  head/sys/arm/freescale/imx/imx6_machdep.c
  head/sys/arm/freescale/imx/imx6_mp.c

Modified: head/sys/arm/conf/IMX6
==
--- head/sys/arm/conf/IMX6  Fri Mar 17 11:45:46 2017(r315447)
+++ head/sys/arm/conf/IMX6  Fri Mar 17 12:34:56 2017(r315448)
@@ -30,6 +30,7 @@ options   SCHED_ULE   # ULE scheduler
 #options   NFSD# Network Filesystem Server
 optionsINCLUDE_CONFIG_FILE # Include this file in kernel
 optionsPLATFORM
+optionsPLATFORM_SMP
 optionsSMP # Enable multiple cores
 
 # NFS root from boopt/dhcp

Modified: head/sys/arm/freescale/imx/imx6_machdep.c
==
--- head/sys/arm/freescale/imx/imx6_machdep.c   Fri Mar 17 11:45:46 2017
(r315447)
+++ head/sys/arm/freescale/imx/imx6_machdep.c   Fri Mar 17 12:34:56 2017
(r315448)
@@ -50,6 +50,8 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
+#include 
+
 #include "platform_if.h"
 
 static uint32_t gpio1_node;
@@ -346,6 +348,11 @@ static platform_method_t imx6_methods[] 
PLATFORMMETHOD(platform_late_init,  imx6_late_init),
PLATFORMMETHOD(platform_cpu_reset,  imx6_cpu_reset),
 
+#ifdef SMP
+   PLATFORMMETHOD(platform_mp_start_ap,imx6_mp_start_ap),
+   PLATFORMMETHOD(platform_mp_setmaxid,imx6_mp_setmaxid),
+#endif
+
PLATFORMMETHOD_END,
 };
 

Modified: head/sys/arm/freescale/imx/imx6_mp.c
==
--- head/sys/arm/freescale/imx/imx6_mp.cFri Mar 17 11:45:46 2017
(r315447)
+++ head/sys/arm/freescale/imx/imx6_mp.cFri Mar 17 12:34:56 2017
(r315448)
@@ -41,6 +41,10 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
+#include 
+
+#include 
 
 #defineSCU_PHYSBASE0x00a0
 #defineSCU_SIZE0x1000
@@ -67,7 +71,7 @@ __FBSDID("$FreeBSD$");
 #defineSRC_GPR1_C1ARG  0x24/* Register for Core 1 
entry arg */
 
 void
-platform_mp_setmaxid(void)
+imx6_mp_setmaxid(platform_t plat)
 {
bus_space_handle_t scu;
int hwcpu, ncpu;
@@ -92,8 +96,8 @@ platform_mp_setmaxid(void)
mp_maxid = ncpu - 1;
 }
 
-void
-platform_mp_start_ap(void)
+void
+imx6_mp_start_ap(platform_t plat)
 {
bus_space_handle_t scu;
bus_space_handle_t src;

Added: head/sys/arm/freescale/imx/imx6_mp.h
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/arm/freescale/imx/imx6_mp.hFri Mar 17 12:34:56 2017
(r315448)
@@ -0,0 +1,35 @@
+/*-
+ * Copyright (c) 2017 Andrew Turner
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef IMX6_MP_H
+#defineIMX6_MP_H
+
+void imx6_mp_start_ap(platform_t);
+void imx6_mp_setmaxid(platform_t);
+
+#endif /* IMX6_MP_H */
___
svn-src-head@freebsd.org mailing list
http

svn commit: r315449 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2017-03-17 Thread Steven Hartland
Author: smh
Date: Fri Mar 17 12:34:57 2017
New Revision: 315449
URL: https://svnweb.freebsd.org/changeset/base/315449

Log:
  Reduce ARC fragmentation threshold
  
  As ZFS can request up to SPA_MAXBLOCKSIZE memory block e.g. during zfs recv,
  update the threshold at which we start agressive reclamation to use
  SPA_MAXBLOCKSIZE (16M) instead of the lower zfs_max_recordsize which
  defaults to 1M.
  
  PR:   194513
  Reviewed by:  avg, mav
  MFC after:1 month
  Sponsored by: Multiplay
  Differential Revision:https://reviews.freebsd.org/D10012

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c   Fri Mar 17 
12:34:56 2017(r315448)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c   Fri Mar 17 
12:34:57 2017(r315449)
@@ -3978,7 +3978,7 @@ arc_available_memory(void)
 * Start aggressive reclamation if too little sequential KVA left.
 */
if (lowest > 0) {
-   n = (vmem_size(heap_arena, VMEM_MAXFREE) < zfs_max_recordsize) ?
+   n = (vmem_size(heap_arena, VMEM_MAXFREE) < SPA_MAXBLOCKSIZE) ?
-((int64_t)vmem_size(heap_arena, VMEM_ALLOC) >> 4) :
INT64_MAX;
if (n < lowest) {
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r315450 - in head/sys: arm/qemu dev/fdt

2017-03-17 Thread Andrew Turner
Author: andrew
Date: Fri Mar 17 12:45:53 2017
New Revision: 315450
URL: https://svnweb.freebsd.org/changeset/base/315450

Log:
  Make the default FDT implementation of platform_mp_setmaxid use the cpu
  nodes from the DTB by default. This will allow us to enumerate the CPUs
  without hard coding the CPU count into code.
  
  Reviewed by:  br
  Sponsored by: ABT Systems Ltd
  Differential Revision:https://reviews.freebsd.org/D9827

Modified:
  head/sys/arm/qemu/virt_machdep.c
  head/sys/arm/qemu/virt_mp.c
  head/sys/dev/fdt/fdt_arm_platform.c

Modified: head/sys/arm/qemu/virt_machdep.c
==
--- head/sys/arm/qemu/virt_machdep.cFri Mar 17 12:34:57 2017
(r315449)
+++ head/sys/arm/qemu/virt_machdep.cFri Mar 17 12:45:53 2017
(r315450)
@@ -60,7 +60,6 @@ static platform_method_t virt_methods[] 
 
 #ifdef SMP
PLATFORMMETHOD(platform_mp_start_ap,virt_mp_start_ap),
-   PLATFORMMETHOD(platform_mp_setmaxid,virt_mp_setmaxid),
 #endif
 
PLATFORMMETHOD_END,

Modified: head/sys/arm/qemu/virt_mp.c
==
--- head/sys/arm/qemu/virt_mp.c Fri Mar 17 12:34:57 2017(r315449)
+++ head/sys/arm/qemu/virt_mp.c Fri Mar 17 12:45:53 2017(r315450)
@@ -50,27 +50,6 @@ __FBSDID("$FreeBSD$");
 static int running_cpus;
 
 static boolean_t
-virt_maxid(u_int id, phandle_t node, u_int addr_cells, pcell_t *reg)
-{
-
-   if (mp_maxid < id)
-   mp_maxid = id;
-
-   return (true);
-}
-
-void
-virt_mp_setmaxid(platform_t plat)
-{
-
-   mp_maxid = PCPU_GET(cpuid);
-   mp_ncpus = ofw_cpu_early_foreach(virt_maxid, true);
-   if (mp_ncpus < 1)
-   mp_ncpus = 1;
-   mp_ncpus = MIN(mp_ncpus, MAXCPU);
-}
-
-static boolean_t
 virt_start_ap(u_int id, phandle_t node, u_int addr_cells, pcell_t *reg)
 {
int err;

Modified: head/sys/dev/fdt/fdt_arm_platform.c
==
--- head/sys/dev/fdt/fdt_arm_platform.c Fri Mar 17 12:34:57 2017
(r315449)
+++ head/sys/dev/fdt/fdt_arm_platform.c Fri Mar 17 12:45:53 2017
(r315450)
@@ -30,12 +30,14 @@
 __FBSDID("$FreeBSD$");
 
 #include 
+#include 
 
 #include 
 #include 
 
 #include 
 #include 
+#include 
 #include 
 
 #include "platform_if.h"
@@ -43,6 +45,10 @@ __FBSDID("$FreeBSD$");
 #defineFDT_PLATFORM(plat)  \
 ((fdt_platform_def_t *)(plat)->cls->baseclasses[0])
 
+#if defined(SMP)
+static platform_mp_setmaxid_t fdt_platform_mp_setmaxid;
+#endif
+
 static int
 fdt_platform_probe(platform_t plat)
 {
@@ -66,8 +72,36 @@ fdt_platform_probe(platform_t plat)
return 1;
 }
 
+#if defined(SMP)
+static boolean_t
+fdt_platform_maxid(u_int id, phandle_t node, u_int addr_cells, pcell_t *reg)
+{
+
+   if (mp_maxid < id)
+   mp_maxid = id;
+
+   return (true);
+}
+
+static void
+fdt_platform_mp_setmaxid(platform_t plat)
+{
+
+   mp_maxid = PCPU_GET(cpuid);
+   mp_ncpus = ofw_cpu_early_foreach(fdt_platform_maxid, true);
+   if (mp_ncpus < 1)
+   mp_ncpus = 1;
+   mp_ncpus = MIN(mp_ncpus, MAXCPU);
+}
+#endif
+
 platform_method_t fdt_platform_methods[] = {
PLATFORMMETHOD(platform_probe,  fdt_platform_probe),
+
+#if defined(SMP)
+   PLATFORMMETHOD(platform_mp_setmaxid, fdt_platform_mp_setmaxid),
+#endif
+
PLATFORMMETHOD_END
 };
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r315451 - in head/sys: arm/mv conf

2017-03-17 Thread Andrew Turner
Author: andrew
Date: Fri Mar 17 12:59:16 2017
New Revision: 315451
URL: https://svnweb.freebsd.org/changeset/base/315451

Log:
  Remove code for Marvell SoCs that lack a kernel config.
  
  It seems to be old code from the armv6 project branch that never had a
  kernel config.
  
  Reviewed by:  mmel
  Sponsored by: ABT Systems Lrd
  Differential Revision:https://reviews.freebsd.org/D7166

Modified:
  head/sys/arm/mv/mv_common.c
  head/sys/arm/mv/mv_machdep.c
  head/sys/arm/mv/mvreg.h
  head/sys/arm/mv/mvwin.h
  head/sys/conf/options.arm

Modified: head/sys/arm/mv/mv_common.c
==
--- head/sys/arm/mv/mv_common.c Fri Mar 17 12:45:53 2017(r315450)
+++ head/sys/arm/mv/mv_common.c Fri Mar 17 12:59:16 2017(r315451)
@@ -76,9 +76,7 @@ MALLOC_DEFINE(M_IDMA, "idma", "idma dma 
 
 static int win_eth_can_remap(int i);
 
-#ifndef SOC_MV_FREY
 static int decode_win_cpu_valid(void);
-#endif
 static int decode_win_usb_valid(void);
 static int decode_win_usb3_valid(void);
 static int decode_win_eth_valid(void);
@@ -88,9 +86,7 @@ static int decode_win_sata_valid(void);
 static int decode_win_idma_valid(void);
 static int decode_win_xor_valid(void);
 
-#ifndef SOC_MV_FREY
 static void decode_win_cpu_setup(void);
-#endif
 #ifdef SOC_MV_ARMADAXP
 static int decode_win_sdram_fixup(void);
 #endif
@@ -359,7 +355,7 @@ uint32_t
 soc_power_ctrl_get(uint32_t mask)
 {
 
-#if !defined(SOC_MV_ORION) && !defined(SOC_MV_LOKIPLUS) && 
!defined(SOC_MV_FREY)
+#if !defined(SOC_MV_ORION)
if (mask != CPU_PM_CTRL_NONE)
mask &= read_cpu_ctrl(CPU_PM_CTRL);
 
@@ -377,7 +373,7 @@ void
 soc_power_ctrl_set(uint32_t mask)
 {
 
-#if !defined(SOC_MV_ORION) && !defined(SOC_MV_LOKIPLUS)
+#if !defined(SOC_MV_ORION)
if (mask != CPU_PM_CTRL_NONE)
write_cpu_ctrl(CPU_PM_CTRL, mask);
 #endif
@@ -569,7 +565,6 @@ soc_decode_win(void)
return(err);
 #endif
 
-#ifndef SOC_MV_FREY
if (!decode_win_cpu_valid() || !decode_win_usb_valid() ||
!decode_win_eth_valid() || !decode_win_idma_valid() ||
!decode_win_pcie_valid() || !decode_win_sata_valid() ||
@@ -577,13 +572,6 @@ soc_decode_win(void)
return (EINVAL);
 
decode_win_cpu_setup();
-#else
-   if (!decode_win_usb_valid() ||
-   !decode_win_eth_valid() || !decode_win_idma_valid() ||
-   !decode_win_pcie_valid() || !decode_win_sata_valid() ||
-   !decode_win_xor_valid() || !decode_win_usb3_valid())
-   return (EINVAL);
-#endif
if (MV_DUMP_WIN)
soc_dump_decode_win();
 
@@ -598,7 +586,6 @@ soc_decode_win(void)
 /**
  * Decode windows registers accessors
  **/
-#if !defined(SOC_MV_FREY)
 WIN_REG_IDX_RD(win_cpu, cr, MV_WIN_CPU_CTRL, MV_MBUS_BRIDGE_BASE)
 WIN_REG_IDX_RD(win_cpu, br, MV_WIN_CPU_BASE, MV_MBUS_BRIDGE_BASE)
 WIN_REG_IDX_RD(win_cpu, remap_l, MV_WIN_CPU_REMAP_LO, MV_MBUS_BRIDGE_BASE)
@@ -607,7 +594,6 @@ WIN_REG_IDX_WR(win_cpu, cr, MV_WIN_CPU_C
 WIN_REG_IDX_WR(win_cpu, br, MV_WIN_CPU_BASE, MV_MBUS_BRIDGE_BASE)
 WIN_REG_IDX_WR(win_cpu, remap_l, MV_WIN_CPU_REMAP_LO, MV_MBUS_BRIDGE_BASE)
 WIN_REG_IDX_WR(win_cpu, remap_h, MV_WIN_CPU_REMAP_HI, MV_MBUS_BRIDGE_BASE)
-#endif
 
 WIN_REG_BASE_IDX_RD(win_usb, cr, MV_WIN_USB_CTRL)
 WIN_REG_BASE_IDX_RD(win_usb, br, MV_WIN_USB_BASE)
@@ -712,7 +698,6 @@ static inline uint32_t ddr_sz_read(int i
 }
 #endif
 
-#if !defined(SOC_MV_FREY)
 /**
  * Decode windows helper routines
  **/
@@ -935,7 +920,6 @@ decode_win_cpu_setup(void)
cpu_wins[i].size, cpu_wins[i].remap);
 
 }
-#endif
 
 #ifdef SOC_MV_ARMADAXP
 static int
@@ -1294,11 +1278,7 @@ decode_win_eth_dump(u_long base)
win_eth_epap_read(base));
 }
 
-#if defined(SOC_MV_LOKIPLUS)
-#define MV_WIN_ETH_DDR_TRGT(n) 0
-#else
 #define MV_WIN_ETH_DDR_TRGT(n) ddr_target(n)
-#endif
 
 static void
 decode_win_eth_setup(u_long base)

Modified: head/sys/arm/mv/mv_machdep.c
==
--- head/sys/arm/mv/mv_machdep.cFri Mar 17 12:45:53 2017
(r315450)
+++ head/sys/arm/mv/mv_machdep.cFri Mar 17 12:59:16 2017
(r315451)
@@ -244,14 +244,9 @@ platform_late_init(void)
/*
 * Re-initialise decode windows
 */
-#if !defined(SOC_MV_FREY)
if (soc_decode_win() != 0)
printf("WARNING: could not re-initialise decode windows! "
"Running with existing settings...\n");
-#else
-   /* Disable watchdog and timers */
-   write_cpu_ctrl(CPU_TIMERS_BASE + CPU_TIMER_CONTROL, 0);
-#endif
 #if defined(SOC_

svn commit: r315452 - head/sys/boot/efi/loader/arch/arm64

2017-03-17 Thread Andrew Turner
Author: andrew
Date: Fri Mar 17 13:31:24 2017
New Revision: 315452
URL: https://svnweb.freebsd.org/changeset/base/315452

Log:
  Mark the EFI PE header as allocated. While ld.bfd doesn't seem to care
  about not having this flag ld.lld fails to link without it.
  
  Sponsored by: DARPA, AFRL

Modified:
  head/sys/boot/efi/loader/arch/arm64/start.S

Modified: head/sys/boot/efi/loader/arch/arm64/start.S
==
--- head/sys/boot/efi/loader/arch/arm64/start.S Fri Mar 17 12:59:16 2017
(r315451)
+++ head/sys/boot/efi/loader/arch/arm64/start.S Fri Mar 17 13:31:24 2017
(r315452)
@@ -40,7 +40,7 @@
 #defineIMAGE_SCN_MEM_EXECUTE   0x2000
 #defineIMAGE_SCN_MEM_READ  0x4000
 
-   .section .peheader
+   .section .peheader,"a"
 efi_start:
/* The MS-DOS Stub, only used to get the offset of the COFF header */
.ascii  "MZ"
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r315453 - head/sys/kern

2017-03-17 Thread Konstantin Belousov
Author: kib
Date: Fri Mar 17 13:37:37 2017
New Revision: 315453
URL: https://svnweb.freebsd.org/changeset/base/315453

Log:
  When clearing altsigstack settings on exec, do it to the right thread.
  
  Diagnosed by: smh
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week

Modified:
  head/sys/kern/kern_sig.c

Modified: head/sys/kern/kern_sig.c
==
--- head/sys/kern/kern_sig.cFri Mar 17 13:31:24 2017(r315452)
+++ head/sys/kern/kern_sig.cFri Mar 17 13:37:37 2017(r315453)
@@ -976,7 +976,6 @@ execsigs(struct proc *p)
 * and are now ignored by default).
 */
PROC_LOCK_ASSERT(p, MA_OWNED);
-   td = FIRST_THREAD_IN_PROC(p);
ps = p->p_sigacts;
mtx_lock(&ps->ps_mtx);
while (SIGNOTEMPTY(ps->ps_sigcatch)) {
@@ -1007,6 +1006,8 @@ execsigs(struct proc *p)
 * Reset stack state to the user stack.
 * Clear set of signals caught on the signal stack.
 */
+   td = curthread;
+   MPASS(td->td_proc == p);
td->td_sigstk.ss_flags = SS_DISABLE;
td->td_sigstk.ss_size = 0;
td->td_sigstk.ss_sp = 0;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r315454 - in head/sys: amd64/amd64 amd64/include i386/i386 i386/include

2017-03-17 Thread Bruce Evans
Author: bde
Date: Fri Mar 17 13:49:05 2017
New Revision: 315454
URL: https://svnweb.freebsd.org/changeset/base/315454

Log:
  Don't access the reserved registers %dr4 and %dr5 on i386.
  
  On the original i386, %dr[4-5] were unimplemented but not very clearly
  reserved, so debuggers read them to print them.  i386 was still doing
  this.
  
  On the original athlon64, %dr[4-5] are documented as reserved but are
  aliased to %dr[6-7] unless CR4_DE is set, when accessing them traps.
  
  On 2 of my systems, accessing %dr[4-5] trapped sometimes.  On my Haswell
  system, the apparent randomness was because the boot CPU starts with
  CR4_DE set while all other CPUs start with CR4_DE clear.  FreeBSD
  doesn't support the data breakpoints enabled by CR4_DE and it never
  changes this flag, so the flag remains different across CPUs and
  the behaviour seemed inconsistent except while booting when the CPU
  doesn't change.
  
  The invalid accesses broke:
  - read access for printing the registers in ddb "show watches" on CPUs
with CR4_DE set
  - read accesses in fill_dbregs() on CPUs with CR4_DE set.  This didn't
implement panic(3) since the user case always skipped %dr[4-5].
  - write accesses in set_dbregs().  This also didn't affect userland.
When it didn't trap, the aliasing made it fragile.
  
  Don't print the dummy (zero) values of %dr[4-5] in "show watches" for
  i386 or amd64.  Fix style bugs near this printing.
  
  amd64 also has space in the dbregs struct for the reserved %dr[8-15]
  and already didn't print the dummy values for these, and never accessed
  any of the 10 reserved debug registers.
  
  Remove cpufuncs for making the invalid accesses.  Even amd64 had these.

Modified:
  head/sys/amd64/amd64/db_trace.c
  head/sys/amd64/include/cpufunc.h
  head/sys/i386/i386/db_trace.c
  head/sys/i386/i386/machdep.c
  head/sys/i386/include/cpufunc.h

Modified: head/sys/amd64/amd64/db_trace.c
==
--- head/sys/amd64/amd64/db_trace.c Fri Mar 17 13:37:37 2017
(r315453)
+++ head/sys/amd64/amd64/db_trace.c Fri Mar 17 13:49:05 2017
(r315454)
@@ -575,7 +575,7 @@ watchtype_str(type)
 
 
 void
-db_md_list_watchpoints()
+db_md_list_watchpoints(void)
 {
struct dbreg d;
int i, len, type;
@@ -595,7 +595,7 @@ db_md_list_watchpoints()
len++;
db_printf("  %-5d  %-8s  %10s  %3d  ",
i, "enabled", watchtype_str(type), len);
-   db_printsym((db_addr_t)DBREG_DRX((&d), i), DB_STGY_ANY);
+   db_printsym((db_addr_t)DBREG_DRX(&d, i), DB_STGY_ANY);
db_printf("\n");
} else {
db_printf("  %-5d  disabled\n", i);
@@ -603,9 +603,9 @@ db_md_list_watchpoints()
}
 
db_printf("\ndebug register values:\n");
-   for (i = 0; i < 8; i++) {
-   db_printf("  dr%d 0x%016lx\n", i, DBREG_DRX((&d), i));
-   }
+   for (i = 0; i < 8; i++)
+   if (i != 4 && i != 5)
+   db_printf("  dr%d 0x%016lx\n", i, DBREG_DRX(&d, i));
db_printf("\n");
 }
 

Modified: head/sys/amd64/include/cpufunc.h
==
--- head/sys/amd64/include/cpufunc.hFri Mar 17 13:37:37 2017
(r315453)
+++ head/sys/amd64/include/cpufunc.hFri Mar 17 13:49:05 2017
(r315454)
@@ -759,34 +759,6 @@ load_dr3(uint64_t dr3)
 }
 
 static __inline uint64_t
-rdr4(void)
-{
-   uint64_t data;
-   __asm __volatile("movq %%dr4,%0" : "=r" (data));
-   return (data);
-}
-
-static __inline void
-load_dr4(uint64_t dr4)
-{
-   __asm __volatile("movq %0,%%dr4" : : "r" (dr4));
-}
-
-static __inline uint64_t
-rdr5(void)
-{
-   uint64_t data;
-   __asm __volatile("movq %%dr5,%0" : "=r" (data));
-   return (data);
-}
-
-static __inline void
-load_dr5(uint64_t dr5)
-{
-   __asm __volatile("movq %0,%%dr5" : : "r" (dr5));
-}
-
-static __inline uint64_t
 rdr6(void)
 {
uint64_t data;
@@ -863,8 +835,6 @@ voidload_dr0(uint64_t dr0);
 void   load_dr1(uint64_t dr1);
 void   load_dr2(uint64_t dr2);
 void   load_dr3(uint64_t dr3);
-void   load_dr4(uint64_t dr4);
-void   load_dr5(uint64_t dr5);
 void   load_dr6(uint64_t dr6);
 void   load_dr7(uint64_t dr7);
 void   load_fs(u_short sel);
@@ -887,8 +857,6 @@ uint64_t rdr0(void);
 uint64_t rdr1(void);
 uint64_t rdr2(void);
 uint64_t rdr3(void);
-uint64_t rdr4(void);
-uint64_t rdr5(void);
 uint64_t rdr6(void);
 uint64_t rdr7(void);
 uint64_t rdtsc(void);

Modified: head/sys/i386/i386/db_trace.c
==
--- head/sys/i386/i386/db_trace.c   Fri Mar 17 13:37:37 2017
(r315453)
+++ head/sys/i386/i386/db_trace.c   Fri Mar 17 13:49:05 2017
(r315454)
@@ -735,7 +735,7 @@ wa

svn commit: r315455 - head/lib/libfetch

2017-03-17 Thread Dag-Erling Smørgrav
Author: des
Date: Fri Mar 17 14:18:52 2017
New Revision: 315455
URL: https://svnweb.freebsd.org/changeset/base/315455

Log:
  r308996 broke IP literals by assuming that a colon could only occur as
  a separator between host and port, and using strchr() to search for it.
  Rewrite fetch_resolve() so it handles bracketed literals correctly, and
  remove similar code elsewhere to avoid passing unbracketed literals to
  fetch_resolve().  Remove #ifdef INET6 so we still parse IP literals
  correctly even if we do not have the ability to connect to them.
  
  While there, fix an off-by-one error which caused HTTP 400 errors to be
  misinterpreted as redirects.
  
  PR:   217723
  MFC after:1 week
  Reported by:  bapt, bz, cem, ngie

Modified:
  head/lib/libfetch/common.c
  head/lib/libfetch/fetch.c
  head/lib/libfetch/http.c

Modified: head/lib/libfetch/common.c
==
--- head/lib/libfetch/common.c  Fri Mar 17 13:49:05 2017(r315454)
+++ head/lib/libfetch/common.c  Fri Mar 17 14:18:52 2017(r315455)
@@ -248,37 +248,51 @@ fetch_resolve(const char *addr, int port
 {
char hbuf[256], sbuf[8];
struct addrinfo hints, *res;
-   const char *sep, *host, *service;
+   const char *hb, *he, *sep;
+   const char *host, *service;
int err, len;
 
-   /* split address if necessary */
-   err = EAI_SYSTEM;
-   if ((sep = strchr(addr, ':')) != NULL) {
+   /* first, check for a bracketed IPv6 address */
+   if (*addr == '[') {
+   hb = addr + 1;
+   if ((sep = strchr(hb, ']')) == NULL) {
+   errno = EINVAL;
+   goto syserr;
+   }
+   he = sep++;
+   } else {
+   hb = addr;
+   sep = strchrnul(hb, ':');
+   he = sep;
+   }
+
+   /* see if we need to copy the host name */
+   if (*he != '\0') {
len = snprintf(hbuf, sizeof(hbuf),
-   "%.*s", (int)(sep - addr), addr);
+   "%.*s", (int)(he - hb), hb);
if (len < 0)
-   return (NULL);
+   goto syserr;
if (len >= (int)sizeof(hbuf)) {
errno = ENAMETOOLONG;
-   fetch_syserr();
-   return (NULL);
+   goto syserr;
}
host = hbuf;
-   service = sep + 1;
-   } else if (port != 0) {
+   } else {
+   host = hb;
+   }
+
+   /* was it followed by a service name? */
+   if (*sep == '\0' && port != 0) {
if (port < 1 || port > 65535) {
errno = EINVAL;
-   fetch_syserr();
-   return (NULL);
-   }
-   if (snprintf(sbuf, sizeof(sbuf), "%d", port) < 0) {
-   fetch_syserr();
-   return (NULL);
+   goto syserr;
}
-   host = addr;
+   if (snprintf(sbuf, sizeof(sbuf), "%d", port) < 0)
+   goto syserr;
service = sbuf;
+   } else if (*sep != '\0') {
+   service = sep;
} else {
-   host = addr;
service = NULL;
}
 
@@ -292,6 +306,9 @@ fetch_resolve(const char *addr, int port
return (NULL);
}
return (res);
+syserr:
+   fetch_syserr();
+   return (NULL);
 }
 
 

Modified: head/lib/libfetch/fetch.c
==
--- head/lib/libfetch/fetch.c   Fri Mar 17 13:49:05 2017(r315454)
+++ head/lib/libfetch/fetch.c   Fri Mar 17 14:18:52 2017(r315455)
@@ -386,18 +386,17 @@ fetchParseURL(const char *URL)
}
 
/* hostname */
-#ifdef INET6
if (*p == '[' && (q = strchr(p + 1, ']')) != NULL &&
(*++q == '\0' || *q == '/' || *q == ':')) {
-   if ((i = q - p - 2) > MAXHOSTNAMELEN)
+   if ((i = q - p) > MAXHOSTNAMELEN)
i = MAXHOSTNAMELEN;
-   strncpy(u->host, ++p, i);
+   strncpy(u->host, p, i);
p = q;
-   } else
-#endif
+   } else {
for (i = 0; *p && (*p != '/') && (*p != ':'); p++)
if (i < MAXHOSTNAMELEN)
u->host[i++] = *p;
+   }
 
/* port */
if (*p == ':') {
@@ -444,12 +443,12 @@ nohost:
}
 
DEBUG(fprintf(stderr,
- "scheme:   [%s]\n"
- "user: [%s]\n"
- "password: [%s]\n"
- "host: [%s]\n"
- "port: [%d]\n"
- "document: [%s]\n",
+ "scheme:   \"%s\"\n"
+ "user: \"%s\"\n"
+

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

2017-03-17 Thread Hans Petter Selasky
Author: hselasky
Date: Fri Mar 17 15:40:24 2017
New Revision: 315457
URL: https://svnweb.freebsd.org/changeset/base/315457

Log:
  Implement get_pid_task(), pid_task() and some other PID helper
  functions in the LinuxKPI. Add a usage atomic to the task_struct
  structure to facilitate refcounting the task structure when returned
  from get_pid_task(). The get_task_struct() and put_task_struct()
  function is used to manage atomic refcounting. After this change the
  task_struct should only be freed through put_task_struct().
  
  Obtained from:kmacy @
  MFC after:1 week
  Sponsored by: Mellanox Technologies

Added:
  head/sys/compat/linuxkpi/common/include/linux/pid.h   (contents, props 
changed)
Modified:
  head/sys/compat/linuxkpi/common/include/linux/sched.h
  head/sys/compat/linuxkpi/common/src/linux_current.c
  head/sys/compat/linuxkpi/common/src/linux_kthread.c

Added: head/sys/compat/linuxkpi/common/include/linux/pid.h
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/compat/linuxkpi/common/include/linux/pid.h Fri Mar 17 15:40:24 
2017(r315457)
@@ -0,0 +1,65 @@
+/*-
+ * Copyright (c) 2017 Mellanox Technologies, Ltd.
+ * All rights reserved.
+ *
+ * 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 unmodified, 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 ``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 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.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef_LINUX_PID_H_
+#define_LINUX_PID_H_
+
+#include 
+#include 
+#include 
+
+enum pid_type {
+   PIDTYPE_PID,
+   PIDTYPE_PGID,
+   PIDTYPE_SID,
+   PIDTYPE_MAX
+};
+
+#definepid_nr(n) (n)
+#definepid_vnr(n) (n)
+#definefrom_kuid_munged(a, uid) (uid)
+
+#definepid_task(pid, type) ({  \
+   struct task_struct *__ts;   \
+   CTASSERT((type) == PIDTYPE_PID);\
+   __ts = linux_pid_task(pid); \
+   __ts;   \
+})
+
+#defineget_pid_task(pid, type) ({  \
+   struct task_struct *__ts;   \
+   CTASSERT((type) == PIDTYPE_PID);\
+   __ts = linux_get_pid_task(pid); \
+   __ts;   \
+})
+
+struct task_struct;
+extern struct task_struct *linux_pid_task(pid_t);
+extern struct task_struct *linux_get_pid_task(pid_t);
+
+#endif /* _LINUX_PID_H_ */

Modified: head/sys/compat/linuxkpi/common/include/linux/sched.h
==
--- head/sys/compat/linuxkpi/common/include/linux/sched.h   Fri Mar 17 
14:54:10 2017(r315456)
+++ head/sys/compat/linuxkpi/common/include/linux/sched.h   Fri Mar 17 
15:40:24 2017(r315457)
@@ -38,7 +38,9 @@
 #include 
 
 #include 
+#include 
 #include 
+#include 
 #include 
 #include 
 
@@ -59,9 +61,10 @@ struct task_struct {
linux_task_fn_t *task_fn;
void   *task_data;
int task_ret;
+   atomic_t usage;
int state;
atomic_t kthread_flags;
-   pid_t   pid;
+   pid_t   pid;/* BSD thread ID */
const char*comm;
void   *bsd_ioctl_data;
unsigned bsd_ioctl_len;
@@ -71,16 +74,30 @@ struct task_struct {
 
 #definecurrent ((struct task_struct *)curthread->td_lkpi_task)
 
-#definetask_pid(task)  ((task)->task_thread->td_proc->p_pid)
-#definetask_pid_nr(task)   ((task)->task_thread->td_tid)
-#defineget_pid(x) (x)
-#defineput_pid(x)
+#definetask_pid_group_leader(task) \
+   FIRST_THREAD_IN_PROC((task)->task_thread->td_proc)->td_tid
+#definetask_pid(task)  ((task)->pid)
+#define 

svn commit: r315458 - in head: sys/netinet6 tests/sys/netinet

2017-03-17 Thread Alan Somers
Author: asomers
Date: Fri Mar 17 16:50:37 2017
New Revision: 315458
URL: https://svnweb.freebsd.org/changeset/base/315458

Log:
  Constrain IPv6 routes to single FIBs when net.add_addr_allfibs=0
  
  sys/netinet6/icmp6.c
Use the interface's FIB for source address selection in ICMPv6 error
responses.
  
  sys/netinet6/in6.c
In in6_newaddrmsg, announce arrival of local addresses on the
interface's FIB only.  In in6_lltable_rtcheck, use a per-fib ND6
cache instead of a single cache.
  
  sys/netinet6/in6_src.c
In in6_selectsrc, use the caller's fib instead of the default fib.
In in6_selectsrc_socket, remove a superfluous check.
  
  sys/netinet6/nd6.c
In nd6_lle_event, use the interface's fib for routing socket
messages.  In nd6_is_new_addr_neighbor, check all FIBs when trying
to determine whether an address is a neighbor.  Also, simplify the
code for point to point interfaces.
  
  sys/netinet6/nd6.h
  sys/netinet6/nd6.c
  sys/netinet6/nd6_rtr.c
Make defrouter_select fib-aware, and make all of its callers pass in
the interface fib.
  
  sys/netinet6/nd6_nbr.c
When inputting a Neighbor Solicitation packet, consider the
interface fib instead of the default fib for DAD.  Output NS and
Neighbor Advertisement packets on the correct fib.
  
  sys/netinet6/nd6_rtr.c
Allow installing the same host route on different interfaces in
different FIBs.  If rt_add_addr_allfibs=0, only install or delete
the prefix route on the interface fib.
  
  tests/sys/netinet/fibs_test.sh
Clear some expected failures, but add a skip for the newly revealed
BUG217871.
  
  PR:   196361
  Submitted by: Erick Turnquist 
  Reported by:  Jason Healy 
  Reviewed by:  asomers
  MFC after:3 weeks
  Sponsored by: Spectra Logic Corp
  Differential Revision:https://reviews.freebsd.org/D9451

Modified:
  head/sys/netinet6/icmp6.c
  head/sys/netinet6/in6.c
  head/sys/netinet6/in6_src.c
  head/sys/netinet6/nd6.c
  head/sys/netinet6/nd6.h
  head/sys/netinet6/nd6_nbr.c
  head/sys/netinet6/nd6_rtr.c
  head/tests/sys/netinet/fibs_test.sh

Modified: head/sys/netinet6/icmp6.c
==
--- head/sys/netinet6/icmp6.c   Fri Mar 17 15:40:24 2017(r315457)
+++ head/sys/netinet6/icmp6.c   Fri Mar 17 16:50:37 2017(r315458)
@@ -2147,7 +2147,7 @@ icmp6_reflect(struct mbuf *m, size_t off
 * source address of the erroneous packet.
 */
in6_splitscope(&ip6->ip6_src, &dst6, &scopeid);
-   error = in6_selectsrc_addr(RT_DEFAULT_FIB, &dst6,
+   error = in6_selectsrc_addr(M_GETFIB(m), &dst6,
scopeid, NULL, &src6, &hlim);
 
if (error) {
@@ -2289,7 +2289,7 @@ icmp6_redirect_input(struct mbuf *m, int
uint32_t scopeid;
 
in6_splitscope(&reddst6, &kdst, &scopeid);
-   if (fib6_lookup_nh_basic(RT_DEFAULT_FIB, &kdst, scopeid, 0, 0,&nh6)==0){
+   if (fib6_lookup_nh_basic(ifp->if_fib, &kdst, scopeid, 0, 0,&nh6)==0){
if ((nh6.nh_flags & NHF_GATEWAY) == 0) {
nd6log((LOG_ERR,
"ICMP6 redirect rejected; no route "

Modified: head/sys/netinet6/in6.c
==
--- head/sys/netinet6/in6.c Fri Mar 17 15:40:24 2017(r315457)
+++ head/sys/netinet6/in6.c Fri Mar 17 16:50:37 2017(r315458)
@@ -159,6 +159,7 @@ in6_newaddrmsg(struct in6_ifaddr *ia, in
struct sockaddr_dl gateway;
struct sockaddr_in6 mask, addr;
struct rtentry rt;
+   int fibnum;
 
/*
 * initialize for rtmsg generation
@@ -176,8 +177,9 @@ in6_newaddrmsg(struct in6_ifaddr *ia, in
rt.rt_flags = RTF_HOST | RTF_STATIC;
if (cmd == RTM_ADD)
rt.rt_flags |= RTF_UP;
-   /* Announce arrival of local address to all FIBs. */
-   rt_newaddrmsg(cmd, &ia->ia_ifa, 0, &rt);
+   fibnum = V_rt_add_addr_allfibs ? RT_ALL_FIBS : 
ia62ifa(ia)->ifa_ifp->if_fib;
+   /* Announce arrival of local address to this FIB. */
+   rt_newaddrmsg_fib(cmd, &ia->ia_ifa, 0, &rt, fibnum);
 }
 
 int
@@ -2117,15 +2119,15 @@ in6_lltable_rtcheck(struct ifnet *ifp,
uint32_t scopeid;
int error;
char ip6buf[INET6_ADDRSTRLEN];
+   int fibnum;
 
KASSERT(l3addr->sa_family == AF_INET6,
("sin_family %d", l3addr->sa_family));
 
-   /* Our local addresses are always only installed on the default FIB. */
-
sin6 = (const struct sockaddr_in6 *)l3addr;
in6_splitscope(&sin6->sin6_addr, &dst, &scopeid);
-   error = fib6_lookup_nh_basic(RT_DEFAULT_FIB, &dst, scopeid, 0, 0, &nh6);
+   fibnum = V_rt_add_addr_allfibs ? RT_DEFAULT_FIB : ifp->if_fib;
+   error = fib6_lookup

svn commit: r315459 - head/sys/conf

2017-03-17 Thread Bryan Drewery
Author: bdrewery
Date: Fri Mar 17 18:08:00 2017
New Revision: 315459
URL: https://svnweb.freebsd.org/changeset/base/315459

Log:
  kmod: Fix depending on ILINKS for tracked DEPENDOBJS.
  
  The objects that may be in the dependency graph may not match
  ${OBJS}.  Ensure the ilink link is added as a dependency for
  all of them when a .depend file is missing for that objfile.
  
  MFC after:2 weeks
  Sponsored by: Dell EMC Isilon

Modified:
  head/sys/conf/kmod.mk

Modified: head/sys/conf/kmod.mk
==
--- head/sys/conf/kmod.mk   Fri Mar 17 16:50:37 2017(r315458)
+++ head/sys/conf/kmod.mk   Fri Mar 17 18:08:00 2017(r315459)
@@ -274,7 +274,7 @@ beforebuild: ${_ILINKS}
 # causes all the modules to be rebuilt when the directory pointed to changes.
 .for _link in ${_ILINKS}
 .if !exists(${.OBJDIR}/${_link})
-${OBJS}: ${_link}
+OBJS_DEPEND_GUESS+=${_link}
 .endif
 .endfor
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r315460 - head/sys/conf

2017-03-17 Thread Bryan Drewery
Author: bdrewery
Date: Fri Mar 17 18:08:33 2017
New Revision: 315460
URL: https://svnweb.freebsd.org/changeset/base/315460

Log:
  kmod: Fix building assym.o not building missing dependencies.
  
  For instance, in the dtrace/dtrace module, building dtrace_asm.o wants
  to build genassym.o first, but it doesn't build the missing ilinks
  and if_*.h headers which are part of the OBJS_DEPEND_GUESS list
  of dependencies to build if a .depend file is missing.
  
  MFC after:1 week
  Sponsored by: Dell EMC Isilon

Modified:
  head/sys/conf/kmod.mk

Modified: head/sys/conf/kmod.mk
==
--- head/sys/conf/kmod.mk   Fri Mar 17 18:08:00 2017(r315459)
+++ head/sys/conf/kmod.mk   Fri Mar 17 18:08:33 2017(r315460)
@@ -453,6 +453,7 @@ acpi_quirks.h: ${SYSDIR}/tools/acpi_quir
 
 .if !empty(SRCS:Massym.s)
 CLEANFILES+=   assym.s genassym.o
+DEPENDOBJS+=   genassym.o
 assym.s: genassym.o
 .if defined(KERNBUILDDIR)
 genassym.o: opt_global.h
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r315461 - head/share/mk

2017-03-17 Thread Bryan Drewery
Author: bdrewery
Date: Fri Mar 17 18:08:36 2017
New Revision: 315461
URL: https://svnweb.freebsd.org/changeset/base/315461

Log:
  META_MODE: Fix not using .depend files when no OBJDIR is present.
  
  By default bmake does not allow meta mode to work unless an OBJDIR is
  present.  It allows this if curdirok= is set with a value not starting
  with [0NnFf], but usually it is "yes".
  
  MFC after:2 weeks
  Sponsored by: Dell EMC Isilon

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

Modified: head/share/mk/bsd.dep.mk
==
--- head/share/mk/bsd.dep.mkFri Mar 17 18:08:33 2017(r315460)
+++ head/share/mk/bsd.dep.mkFri Mar 17 18:08:36 2017(r315461)
@@ -75,6 +75,13 @@ tags: ${SRCS}
 .if !empty(.MAKE.MODE:Mmeta) && empty(.MAKE.MODE:Mnofilemon)
 _meta_filemon= 1
 .endif
+# By default META_MODE is disabled in bmake if there is no OBJDIR
+# unless .MAKE.MODE contains "curdirOk=[^0nNfF]"
+.if defined(_meta_filemon) && ${.OBJDIR} == ${.CURDIR} && \
+(empty(.MAKE.MODE:tl:Mcurdirok=*) || \
+!empty(.MAKE.MODE:tl:Mcurdirok=[0NnFf]*))
+.undef _meta_filemon
+.endif
 
 # Skip reading .depend when not needed to speed up tree-walks and simple
 # lookups.  See _SKIP_BUILD logic in bsd.init.mk for more details.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r315464 - in head/sys/powerpc: booke conf include powerpc

2017-03-17 Thread Justin Hibbits
Author: jhibbits
Date: Fri Mar 17 21:40:14 2017
New Revision: 315464
URL: https://svnweb.freebsd.org/changeset/base/315464

Log:
  Introduce 64-bit PowerPC Book-E support
  
  Extend the Book-E pmap to support 64-bit operation.  Much of this was taken 
from
  Juniper's Junos FreeBSD port.  It uses a 3-level page table (page directory
  list -- PP2D, page directory, page table), but has gaps in the page directory
  list where regions will repeat, due to the design of the PP2D hash (a 20-bit 
gap
  between the two parts of the index).  In practice this may not be a problem
  given the expanded address space.  However, an alternative to this would be to
  use a 4-level page table, like Linux, and possibly reduce the available 
address
  space; Linux appears to use a 46-bit address space.  Alternatively, a cache of
  page directory pointers could be used to keep the overall design as-is, but
  remove the gaps in the address space.
  
  This includes a new kernel config for 64-bit QorIQ SoCs, based on MPC85XX, 
with
  the following notes:
  * The DPAA driver has not yet been ported to 64-bit so is not included in the
kernel config.
  * This has been tested on the AmigaOne X5000, using a MD_ROOT compiled in
(total size kernel+mdroot must be under 64MB).
  * This can run both 32-bit and 64-bit processes, and has even been tested to 
run
a 32-bit init with 64-bit children.
  
  Many thanks to stevek and marcel for getting Juniper's FreeBSD patches open
  sourced to be used here, and to stevek for reviewing, and providing some
  historical contexts on quirks of the code.
  
  Reviewed by:  stevek
  Obtained from:Juniper (in part)
  MFC after:2 months
  Relnotes: yes
  Differential Revision:https://reviews.freebsd.org/D9433

Added:
  head/sys/powerpc/conf/QORIQ64   (contents, props changed)
Modified:
  head/sys/powerpc/booke/booke_machdep.c
  head/sys/powerpc/booke/locore.S
  head/sys/powerpc/booke/mp_cpudep.c
  head/sys/powerpc/booke/pmap.c
  head/sys/powerpc/booke/trap_subr.S
  head/sys/powerpc/include/asm.h
  head/sys/powerpc/include/pcpu.h
  head/sys/powerpc/include/pmap.h
  head/sys/powerpc/include/psl.h
  head/sys/powerpc/include/pte.h
  head/sys/powerpc/include/spr.h
  head/sys/powerpc/include/tlb.h
  head/sys/powerpc/include/vmparam.h
  head/sys/powerpc/powerpc/db_interface.c
  head/sys/powerpc/powerpc/exec_machdep.c
  head/sys/powerpc/powerpc/genassym.c

Modified: head/sys/powerpc/booke/booke_machdep.c
==
--- head/sys/powerpc/booke/booke_machdep.c  Fri Mar 17 21:24:09 2017
(r315463)
+++ head/sys/powerpc/booke/booke_machdep.c  Fri Mar 17 21:40:14 2017
(r315464)
@@ -216,7 +216,7 @@ void
 ivor_setup(void)
 {
 
-   mtspr(SPR_IVPR, ((uintptr_t)&interrupt_vector_base) & 0x);
+   mtspr(SPR_IVPR, ((uintptr_t)&interrupt_vector_base) & ~0xUL);
 
SET_TRAP(SPR_IVOR0, int_critical_input);
SET_TRAP(SPR_IVOR1, int_machine_check);
@@ -250,6 +250,11 @@ ivor_setup(void)
SET_TRAP(SPR_IVOR32, int_vec);
break;
}
+
+#ifdef __powerpc64__
+   /* Set 64-bit interrupt mode. */
+   mtspr(SPR_EPCR, mfspr(SPR_EPCR) | EPCR_ICM);
+#endif
 }
 
 static int
@@ -353,7 +358,7 @@ booke_init(u_long arg1, u_long arg2)
 }
 
 #define RES_GRANULE 32
-extern uint32_t tlb0_miss_locks[];
+extern uintptr_t tlb0_miss_locks[];
 
 /* Initialise a struct pcpu. */
 void
@@ -363,8 +368,8 @@ cpu_pcpu_init(struct pcpu *pcpu, int cpu
pcpu->pc_tid_next = TID_MIN;
 
 #ifdef SMP
-   uint32_t *ptr;
-   int words_per_gran = RES_GRANULE / sizeof(uint32_t);
+   uintptr_t *ptr;
+   int words_per_gran = RES_GRANULE / sizeof(uintptr_t);
 
ptr = &tlb0_miss_locks[cpuid * words_per_gran];
pcpu->pc_booke_tlb_lock = ptr;

Modified: head/sys/powerpc/booke/locore.S
==
--- head/sys/powerpc/booke/locore.S Fri Mar 17 21:24:09 2017
(r315463)
+++ head/sys/powerpc/booke/locore.S Fri Mar 17 21:40:14 2017
(r315464)
@@ -41,6 +41,39 @@
 
 #define TMPSTACKSZ 16384
 
+#ifdef __powerpc64__
+#define GET_TOCBASE(r)  \
+   mfspr   r, SPR_SPRG8
+#defineTOC_RESTORE nop
+#defineCMPIcmpdi
+#defineCMPLcmpld
+#defineLOADld
+#defineLOADX   ldarx
+#defineSTORE   std
+#defineSTOREX  stdcx.
+#defineSTU stdu
+#defineCALLSIZE48
+#defineREDZONE 288
+#defineTHREAD_REG  %r13
+#defineADDR(x) \
+   .llong  x
+#else
+#defineGET_TOCBASE(r)
+#defineTOC_RESTORE
+#defineCMPIcmpwi
+#defineCMPLcmplw
+#defineLOADlwz
+#defineLOADX   lwarx
+#defineSTOREX  stwcx.
+#defineSTORE   stw
+#defineSTU stwu
+#defineCALLSIZE8
+#d

svn commit: r315465 - head/sys/mips/broadcom

2017-03-17 Thread Landon J. Fuller
Author: landonf
Date: Fri Mar 17 22:02:02 2017
New Revision: 315465
URL: https://svnweb.freebsd.org/changeset/base/315465

Log:
  Add MIPS boot support for the BCM4706/Northstar ChipCommon core.
  
  This adds support for matching against a core lookup table when performing
  early boot core lookup, and includes the BCM4706/Northstar-specific
  ChipCommon core ID in the set of supported ChipCommon cores.
  
  Approved by:  adrian (mentor)
  Differential Revision:https://reviews.freebsd.org/D10033

Modified:
  head/sys/mips/broadcom/bcm_machdep.c

Modified: head/sys/mips/broadcom/bcm_machdep.c
==
--- head/sys/mips/broadcom/bcm_machdep.cFri Mar 17 21:40:14 2017
(r315464)
+++ head/sys/mips/broadcom/bcm_machdep.cFri Mar 17 22:02:02 2017
(r315465)
@@ -98,9 +98,9 @@ __FBSDID("$FreeBSD$");
 
 static int bcm_init_platform_data(struct bcm_platform *bp);
 
-static int bcm_find_core(struct bcm_platform *bp, uint16_t vendor,
-   uint16_t device, int unit, struct bhnd_core_info *info,
-   uintptr_t *addr);
+static int bcm_find_core(struct bcm_platform *bp,
+   const struct bhnd_core_match *descs, size_t num_descs,
+   struct bhnd_core_info *info, uintptr_t *addr);
 
 static int bcm_erom_probe_and_attach(bhnd_erom_class_t **erom_cls,
kobj_ops_t erom_ops, bhnd_erom_t *erom, size_t esize,
@@ -112,6 +112,15 @@ extern int *end;
 static struct bcm_platform  bcm_platform_data;
 static bool bcm_platform_data_avail = false;
 
+static const struct bhnd_core_match bcm_chipc_cores[] = {
+   { BHND_MATCH_CORE(BHND_MFGID_BCM,   BHND_COREID_CC) },
+   { BHND_MATCH_CORE(BHND_MFGID_BCM,   BHND_COREID_4706_CC)},
+};
+
+static const struct bhnd_core_match bcm_pmu_cores[] = {
+   { BHND_MATCH_CORE(BHND_MFGID_BCM,   BHND_COREID_PMU)},
+};
+
 struct bcm_platform *
 bcm_get_platform(void)
 {
@@ -133,39 +142,41 @@ bcm_get_bus_addr(void)
 }
 
 /**
- * Search the device enumeration table for a core matching @p vendor,
- * @p device, and @p unit.
+ * Search the device enumeration table for a core matching @p descs,
  * 
  * @param  bp  Platform state containing a valid EROM parser.
- * @param  vendor  The core's required vendor.
- * @param  device  The core's required device id.
- * @param  unitThe core's required unit number.
+ * @param  descs   The core match descriptor table.
+ * @param  num_descs   The number of match descriptors in @p descs.
  * @param[out] infoIf non-NULL, will be populated with the core
  * info.
  * @param[out] addrIf non-NULL, will be populated with the core's
  * physical register address.
  */
 static int
-bcm_find_core(struct bcm_platform *bp, uint16_t vendor, uint16_t device,
-int unit, struct bhnd_core_info *info, uintptr_t *addr)
+bcm_find_core(struct bcm_platform *bp, const struct bhnd_core_match *descs,
+size_t num_descs, struct bhnd_core_info *info, uintptr_t *addr)
 {
-   struct bhnd_core_match  md;
bhnd_addr_t b_addr;
bhnd_size_t b_size;
int error;
 
-   md = (struct bhnd_core_match) {
-   BHND_MATCH_CORE_VENDOR(vendor),
-   BHND_MATCH_CORE_ID(BHND_COREID_CC),
-   BHND_MATCH_CORE_UNIT(0)
-   };
-
/* Fetch core info */
-   error = bhnd_erom_lookup_core_addr(&bp->erom.obj, &md, BHND_PORT_DEVICE,
-   0, 0, info, &b_addr, &b_size);
-   if (error)
-   return (error);
+   for (size_t i = 0; i < num_descs; i++) {
+   error = bhnd_erom_lookup_core_addr(&bp->erom.obj, &descs[i],
+   BHND_PORT_DEVICE, 0, 0, info, &b_addr, &b_size);
+
+   /* Terminate search on first match */
+   if (error == 0)
+   break;
 
+   /* Terminate on first error (other than core not found) */
+   if (error != ENOENT)
+   return (error);
+
+   /* Continue search ... */
+   }
+
+   /* Provide the core's base address */
if (addr != NULL && b_addr > UINTPTR_MAX) {
BCM_ERR("core address %#jx overflows native address width\n",
(uintmax_t)b_addr);
@@ -286,8 +297,8 @@ bcm_init_platform_data(struct bcm_platfo
}
 
/* Fetch chipcommon core info */
-   error = bcm_find_core(bp, BHND_MFGID_BCM, BHND_COREID_CC, 0, &bp->cc_id,
-   &bp->cc_addr);
+   error = bcm_find_core(bp, bcm_chipc_cores, nitems(bcm_chipc_cores),
+   &bp->cc_id, &bp->cc_addr);
if (error) {
BCM_ERR("error locating chipc core: %d\n", error);

svn commit: r315466 - in head/sys/dev: mmc sdhci

2017-03-17 Thread Marius Strobl
Author: marius
Date: Fri Mar 17 22:57:37 2017
New Revision: 315466
URL: https://svnweb.freebsd.org/changeset/base/315466

Log:
  Again, fixes regarding style(4), to comments, includes and unused
  parameters.

Modified:
  head/sys/dev/mmc/bridge.h
  head/sys/dev/mmc/mmc.c
  head/sys/dev/mmc/mmcbr_if.m
  head/sys/dev/sdhci/sdhci.c
  head/sys/dev/sdhci/sdhci_acpi.c
  head/sys/dev/sdhci/sdhci_if.m
  head/sys/dev/sdhci/sdhci_pci.c

Modified: head/sys/dev/mmc/bridge.h
==
--- head/sys/dev/mmc/bridge.h   Fri Mar 17 22:02:02 2017(r315465)
+++ head/sys/dev/mmc/bridge.h   Fri Mar 17 22:57:37 2017(r315466)
@@ -111,7 +111,7 @@ enum mmc_bus_timing {
 
 struct mmc_ios {
uint32_tclock;  /* Speed of the clock in Hz to move data */
-   enum mmc_vddvdd;/* Voltage to apply to the power pins/ */
+   enum mmc_vddvdd;/* Voltage to apply to the power pins */
enum mmc_bus_mode bus_mode;
enum mmc_chip_select chip_select;
enum mmc_bus_width bus_width;

Modified: head/sys/dev/mmc/mmc.c
==
--- head/sys/dev/mmc/mmc.c  Fri Mar 17 22:02:02 2017(r315465)
+++ head/sys/dev/mmc/mmc.c  Fri Mar 17 22:57:37 2017(r315466)
@@ -792,6 +792,7 @@ mmc_get_bits(uint32_t *bits, int bit_len
const int i = (bit_len / 32) - (start / 32) - 1;
const int shift = start & 31;
uint32_t retval = bits[i] >> shift;
+
if (size + shift > 32)
retval |= bits[i - 1] << (32 - shift);
return (retval & ((1llu << size) - 1));
@@ -1464,7 +1465,7 @@ mmc_rescan_cards(struct mmc_softc *sc)
return;
for (i = 0; i < devcount; i++) {
ivar = device_get_ivars(devlist[i]);
-   if (mmc_select_card(sc, ivar->rca)) {
+   if (mmc_select_card(sc, ivar->rca) != MMC_ERR_NONE) {
if (bootverbose || mmc_debug)
device_printf(sc->dev,
"Card at relative address %d lost.\n",

Modified: head/sys/dev/mmc/mmcbr_if.m
==
--- head/sys/dev/mmc/mmcbr_if.m Fri Mar 17 22:02:02 2017(r315465)
+++ head/sys/dev/mmc/mmcbr_if.m Fri Mar 17 22:57:37 2017(r315466)
@@ -65,8 +65,9 @@
 INTERFACE mmcbr;
 
 #
-# Called by the mmcbus to setup the IO pins correctly, the voltage to use
-# for the card, the type of selects, power modes and bus width.
+# Called by the mmcbus to set up the IO pins correctly, the common/core
+# supply voltage (VDD/VCC) to use for the device, the clock frequency, the
+# type of SPI chip select, power mode and bus width.
 #
 METHOD int update_ios {
device_tbrdev;
@@ -76,8 +77,8 @@ METHOD int update_ios {
 #
 # Called by the mmcbus or its children to schedule a mmc request.  These
 # requests are queued.  Time passes.  The bridge then gets notification
-# of the status of request, who then notifies the requesting device via
-# the xfer_done mmcbus method.
+# of the status of the request, who then notifies the requesting device
+# by calling the completion function supplied as part of the request.
 #
 METHOD int request {
device_tbrdev;

Modified: head/sys/dev/sdhci/sdhci.c
==
--- head/sys/dev/sdhci/sdhci.c  Fri Mar 17 22:02:02 2017(r315465)
+++ head/sys/dev/sdhci/sdhci.c  Fri Mar 17 22:57:37 2017(r315466)
@@ -309,9 +309,8 @@ sdhci_set_clock(struct sdhci_slot *slot,
}
/* Divider 1:1 is 0x00, 2:1 is 0x01, 256:1 is 0x80 ... */
div >>= 1;
-   }
-   else {
-   /* Version 3.0 divisors are multiples of two up to 1023*2 */
+   } else {
+   /* Version 3.0 divisors are multiples of two up to 1023 * 2 */
if (clock >= clk_base)
div = 0;
else {
@@ -1349,7 +1348,7 @@ sdhci_data_irq(struct sdhci_slot *slot, 
if (intmask & SDHCI_INT_DMA_END) {
data = slot->curcmd->data;
 
-   /* Unload DMA buffer... */
+   /* Unload DMA buffer ... */
left = data->len - slot->offset;
if (data->flags & MMC_DATA_READ) {
bus_dmamap_sync(slot->dmatag, slot->dmamap,

Modified: head/sys/dev/sdhci/sdhci_acpi.c
==
--- head/sys/dev/sdhci/sdhci_acpi.c Fri Mar 17 22:02:02 2017
(r315465)
+++ head/sys/dev/sdhci/sdhci_acpi.c Fri Mar 17 22:57:37 2017
(r315466)
@@ -87,7 +87,8 @@ static void sdhci_acpi_intr(void *arg);
 static int sdhci_acpi_detach(device_t dev);
 
 static uint8_t
-sdhci_acpi_read_1(device_t dev, struct sdhci_slot *slot, bu

Re: svn commit: r315466 - in head/sys/dev: mmc sdhci

2017-03-17 Thread Ian Lepore
On Fri, 2017-03-17 at 22:57 +, Marius Strobl wrote:
> Author: marius
> Date: Fri Mar 17 22:57:37 2017
> New Revision: 315466
> URL: https://svnweb.freebsd.org/changeset/base/315466
> 
> Log:
>   Again, fixes regarding style(4), to comments, includes and unused
>   parameters.
> 
> Modified:
>   head/sys/dev/mmc/bridge.h
>   head/sys/dev/mmc/mmc.c
>   head/sys/dev/mmc/mmcbr_if.m
>   head/sys/dev/sdhci/sdhci.c
>   head/sys/dev/sdhci/sdhci_acpi.c
>   head/sys/dev/sdhci/sdhci_if.m
>   head/sys/dev/sdhci/sdhci_pci.c
> 
> Modified: head/sys/dev/mmc/bridge.h
> =
> =
> --- head/sys/dev/mmc/bridge.h Fri Mar 17 22:02:02 2017
> (r315465)
> +++ head/sys/dev/mmc/bridge.h Fri Mar 17 22:57:37 2017
> (r315466)
> @@ -111,7 +111,7 @@ enum mmc_bus_timing {
>  
>  struct mmc_ios {
>   uint32_tclock;  /* Speed of the clock in Hz to
> move data */
> - enum mmc_vddvdd;/* Voltage to apply to the
> power pins/ */
> + enum mmc_vddvdd;/* Voltage to apply to the
> power pins */
>   enum mmc_bus_mode bus_mode;
>   enum mmc_chip_select chip_select;
>   enum mmc_bus_width bus_width;
> 
> Modified: head/sys/dev/mmc/mmc.c
> =
> =
> --- head/sys/dev/mmc/mmc.cFri Mar 17 22:02:02 2017(r3
> 15465)
> +++ head/sys/dev/mmc/mmc.cFri Mar 17 22:57:37 2017(r3
> 15466)
> @@ -792,6 +792,7 @@ mmc_get_bits(uint32_t *bits, int bit_len
>   const int i = (bit_len / 32) - (start / 32) - 1;
>   const int shift = start & 31;
>   uint32_t retval = bits[i] >> shift;
> +
>   if (size + shift > 32)
>   retval |= bits[i - 1] << (32 - shift);
>   return (retval & ((1llu << size) - 1));
> @@ -1464,7 +1465,7 @@ mmc_rescan_cards(struct mmc_softc *sc)
>   return;
>   for (i = 0; i < devcount; i++) {
>   ivar = device_get_ivars(devlist[i]);
> - if (mmc_select_card(sc, ivar->rca)) {
> + if (mmc_select_card(sc, ivar->rca) != MMC_ERR_NONE)
> {
>   if (bootverbose || mmc_debug)
>   device_printf(sc->dev,
>   "Card at relative address %d
> lost.\n",
> 
> Modified: head/sys/dev/mmc/mmcbr_if.m
> =
> =
> --- head/sys/dev/mmc/mmcbr_if.m   Fri Mar 17 22:02:02 2017
> (r315465)
> +++ head/sys/dev/mmc/mmcbr_if.m   Fri Mar 17 22:57:37 2017
> (r315466)
> @@ -65,8 +65,9 @@
>  INTERFACE mmcbr;
>  
>  #
> -# Called by the mmcbus to setup the IO pins correctly, the voltage
> to use
> -# for the card, the type of selects, power modes and bus width.
> +# Called by the mmcbus to set up the IO pins correctly, the
> common/core
> +# supply voltage (VDD/VCC) to use for the device, the clock
> frequency, the
> +# type of SPI chip select, power mode and bus width.
>  #
>  METHOD int update_ios {
>   device_tbrdev;
> @@ -76,8 +77,8 @@ METHOD int update_ios {
>  #
>  # Called by the mmcbus or its children to schedule a mmc
> request.  These
>  # requests are queued.  Time passes.  The bridge then gets
> notification
> -# of the status of request, who then notifies the requesting device
> via
> -# the xfer_done mmcbus method.
> +# of the status of the request, who then notifies the requesting
> device
> +# by calling the completion function supplied as part of the
> request.
>  #
>  METHOD int request {
>   device_tbrdev;
> 
> Modified: head/sys/dev/sdhci/sdhci.c
> =
> =
> --- head/sys/dev/sdhci/sdhci.cFri Mar 17 22:02:02 2017
> (r315465)
> +++ head/sys/dev/sdhci/sdhci.cFri Mar 17 22:57:37 2017
> (r315466)
> @@ -309,9 +309,8 @@ sdhci_set_clock(struct sdhci_slot *slot,
>   }
>   /* Divider 1:1 is 0x00, 2:1 is 0x01, 256:1 is 0x80
> ... */
>   div >>= 1;
> - }
> - else {
> - /* Version 3.0 divisors are multiples of two up to
> 1023*2 */
> + } else {
> + /* Version 3.0 divisors are multiples of two up to
> 1023 * 2 */
>   if (clock >= clk_base)
>   div = 0;
>   else {
> @@ -1349,7 +1348,7 @@ sdhci_data_irq(struct sdhci_slot *slot, 
>   if (intmask & SDHCI_INT_DMA_END) {
>   data = slot->curcmd->data;
>  
> - /* Unload DMA buffer... */
> + /* Unload DMA buffer ... */

All this churn in the driver for meaningless style fixes and __unused
markup and so on is bad enough, especially considering that you know
people are doing out-of-tree work on this and have to deal with all the
 merge conflicts this is causing, but changes to comments that actually
change correct grammar and punctuation to incorrect, such as this, just
serves 

Re: svn commit: r315466 - in head/sys/dev: mmc sdhci

2017-03-17 Thread Marius Strobl
On Sat, Mar 18, 2017 at 12:39:47AM +0100, Marius Strobl wrote:
> On Fri, Mar 17, 2017 at 05:09:26PM -0600, Ian Lepore wrote:
> > On Fri, 2017-03-17 at 22:57 +, Marius Strobl wrote:
> > > Author: marius
> > > Date: Fri Mar 17 22:57:37 2017
> > > New Revision: 315466
> > > URL: https://svnweb.freebsd.org/changeset/base/315466
> > > 
> > > Log:
> > >   Again, fixes regarding style(4), to comments, includes and unused
> > >   parameters.
> > > 
> > > Modified:
> > >   head/sys/dev/mmc/bridge.h
> > >   head/sys/dev/mmc/mmc.c
> > >   head/sys/dev/mmc/mmcbr_if.m
> > >   head/sys/dev/sdhci/sdhci.c
> > >   head/sys/dev/sdhci/sdhci_acpi.c
> > >   head/sys/dev/sdhci/sdhci_if.m
> > >   head/sys/dev/sdhci/sdhci_pci.c
> > > 
> > > Modified: head/sys/dev/mmc/bridge.h
> > > =
> > > =
> > > --- head/sys/dev/mmc/bridge.h Fri Mar 17 22:02:02 2017
> > > (r315465)
> > > +++ head/sys/dev/mmc/bridge.h Fri Mar 17 22:57:37 2017
> > > (r315466)
> > > @@ -111,7 +111,7 @@ enum mmc_bus_timing {
> > >  
> > >  struct mmc_ios {
> > >   uint32_tclock;  /* Speed of the clock in Hz to
> > > move data */
> > > - enum mmc_vddvdd;/* Voltage to apply to the
> > > power pins/ */
> > > + enum mmc_vddvdd;/* Voltage to apply to the
> > > power pins */
> > >   enum mmc_bus_mode bus_mode;
> > >   enum mmc_chip_select chip_select;
> > >   enum mmc_bus_width bus_width;
> > > 
> > > Modified: head/sys/dev/mmc/mmc.c
> > > =
> > > =
> > > --- head/sys/dev/mmc/mmc.cFri Mar 17 22:02:02 2017(r3
> > > 15465)
> > > +++ head/sys/dev/mmc/mmc.cFri Mar 17 22:57:37 2017(r3
> > > 15466)
> > > @@ -792,6 +792,7 @@ mmc_get_bits(uint32_t *bits, int bit_len
> > >   const int i = (bit_len / 32) - (start / 32) - 1;
> > >   const int shift = start & 31;
> > >   uint32_t retval = bits[i] >> shift;
> > > +
> > >   if (size + shift > 32)
> > >   retval |= bits[i - 1] << (32 - shift);
> > >   return (retval & ((1llu << size) - 1));
> > > @@ -1464,7 +1465,7 @@ mmc_rescan_cards(struct mmc_softc *sc)
> > >   return;
> > >   for (i = 0; i < devcount; i++) {
> > >   ivar = device_get_ivars(devlist[i]);
> > > - if (mmc_select_card(sc, ivar->rca)) {
> > > + if (mmc_select_card(sc, ivar->rca) != MMC_ERR_NONE)
> > > {
> > >   if (bootverbose || mmc_debug)
> > >   device_printf(sc->dev,
> > >   "Card at relative address %d
> > > lost.\n",
> > > 
> > > Modified: head/sys/dev/mmc/mmcbr_if.m
> > > =
> > > =
> > > --- head/sys/dev/mmc/mmcbr_if.m   Fri Mar 17 22:02:02 2017
> > > (r315465)
> > > +++ head/sys/dev/mmc/mmcbr_if.m   Fri Mar 17 22:57:37 2017
> > > (r315466)
> > > @@ -65,8 +65,9 @@
> > >  INTERFACE mmcbr;
> > >  
> > >  #
> > > -# Called by the mmcbus to setup the IO pins correctly, the voltage
> > > to use
> > > -# for the card, the type of selects, power modes and bus width.
> > > +# Called by the mmcbus to set up the IO pins correctly, the
> > > common/core
> > > +# supply voltage (VDD/VCC) to use for the device, the clock
> > > frequency, the
> > > +# type of SPI chip select, power mode and bus width.
> > >  #
> > >  METHOD int update_ios {
> > >   device_tbrdev;
> > > @@ -76,8 +77,8 @@ METHOD int update_ios {
> > >  #
> > >  # Called by the mmcbus or its children to schedule a mmc
> > > request.  These
> > >  # requests are queued.  Time passes.  The bridge then gets
> > > notification
> > > -# of the status of request, who then notifies the requesting device
> > > via
> > > -# the xfer_done mmcbus method.
> > > +# of the status of the request, who then notifies the requesting
> > > device
> > > +# by calling the completion function supplied as part of the
> > > request.
> > >  #
> > >  METHOD int request {
> > >   device_tbrdev;
> > > 
> > > Modified: head/sys/dev/sdhci/sdhci.c
> > > =
> > > =
> > > --- head/sys/dev/sdhci/sdhci.cFri Mar 17 22:02:02 2017
> > > (r315465)
> > > +++ head/sys/dev/sdhci/sdhci.cFri Mar 17 22:57:37 2017
> > > (r315466)
> > > @@ -309,9 +309,8 @@ sdhci_set_clock(struct sdhci_slot *slot,
> > >   }
> > >   /* Divider 1:1 is 0x00, 2:1 is 0x01, 256:1 is 0x80
> > > ... */
> > >   div >>= 1;
> > > - }
> > > - else {
> > > - /* Version 3.0 divisors are multiples of two up to
> > > 1023*2 */
> > > + } else {
> > > + /* Version 3.0 divisors are multiples of two up to
> > > 1023 * 2 */
> > >   if (clock >= clk_base)
> > >   div = 0;
> > >   else {
> > > @@ -1349,7 +1348,7 @@ sdhci_data_irq(struct sdhci_slot *slot, 
> > >   if (intmask & SDHCI_INT_DMA

Re: svn commit: r315466 - in head/sys/dev: mmc sdhci

2017-03-17 Thread Marius Strobl
On Fri, Mar 17, 2017 at 05:09:26PM -0600, Ian Lepore wrote:
> On Fri, 2017-03-17 at 22:57 +, Marius Strobl wrote:
> > Author: marius
> > Date: Fri Mar 17 22:57:37 2017
> > New Revision: 315466
> > URL: https://svnweb.freebsd.org/changeset/base/315466
> > 
> > Log:
> >   Again, fixes regarding style(4), to comments, includes and unused
> >   parameters.
> > 
> > Modified:
> >   head/sys/dev/mmc/bridge.h
> >   head/sys/dev/mmc/mmc.c
> >   head/sys/dev/mmc/mmcbr_if.m
> >   head/sys/dev/sdhci/sdhci.c
> >   head/sys/dev/sdhci/sdhci_acpi.c
> >   head/sys/dev/sdhci/sdhci_if.m
> >   head/sys/dev/sdhci/sdhci_pci.c
> > 
> > Modified: head/sys/dev/mmc/bridge.h
> > =
> > =
> > --- head/sys/dev/mmc/bridge.h   Fri Mar 17 22:02:02 2017
> > (r315465)
> > +++ head/sys/dev/mmc/bridge.h   Fri Mar 17 22:57:37 2017
> > (r315466)
> > @@ -111,7 +111,7 @@ enum mmc_bus_timing {
> >  
> >  struct mmc_ios {
> >     uint32_tclock;  /* Speed of the clock in Hz to
> > move data */
> > -   enum mmc_vddvdd;/* Voltage to apply to the
> > power pins/ */
> > +   enum mmc_vddvdd;/* Voltage to apply to the
> > power pins */
> >     enum mmc_bus_mode bus_mode;
> >     enum mmc_chip_select chip_select;
> >     enum mmc_bus_width bus_width;
> > 
> > Modified: head/sys/dev/mmc/mmc.c
> > =
> > =
> > --- head/sys/dev/mmc/mmc.c  Fri Mar 17 22:02:02 2017(r3
> > 15465)
> > +++ head/sys/dev/mmc/mmc.c  Fri Mar 17 22:57:37 2017(r3
> > 15466)
> > @@ -792,6 +792,7 @@ mmc_get_bits(uint32_t *bits, int bit_len
> >     const int i = (bit_len / 32) - (start / 32) - 1;
> >     const int shift = start & 31;
> >     uint32_t retval = bits[i] >> shift;
> > +
> >     if (size + shift > 32)
> >     retval |= bits[i - 1] << (32 - shift);
> >     return (retval & ((1llu << size) - 1));
> > @@ -1464,7 +1465,7 @@ mmc_rescan_cards(struct mmc_softc *sc)
> >     return;
> >     for (i = 0; i < devcount; i++) {
> >     ivar = device_get_ivars(devlist[i]);
> > -   if (mmc_select_card(sc, ivar->rca)) {
> > +   if (mmc_select_card(sc, ivar->rca) != MMC_ERR_NONE)
> > {
> >     if (bootverbose || mmc_debug)
> >     device_printf(sc->dev,
> >     "Card at relative address %d
> > lost.\n",
> > 
> > Modified: head/sys/dev/mmc/mmcbr_if.m
> > =
> > =
> > --- head/sys/dev/mmc/mmcbr_if.m Fri Mar 17 22:02:02 2017
> > (r315465)
> > +++ head/sys/dev/mmc/mmcbr_if.m Fri Mar 17 22:57:37 2017
> > (r315466)
> > @@ -65,8 +65,9 @@
> >  INTERFACE mmcbr;
> >  
> >  #
> > -# Called by the mmcbus to setup the IO pins correctly, the voltage
> > to use
> > -# for the card, the type of selects, power modes and bus width.
> > +# Called by the mmcbus to set up the IO pins correctly, the
> > common/core
> > +# supply voltage (VDD/VCC) to use for the device, the clock
> > frequency, the
> > +# type of SPI chip select, power mode and bus width.
> >  #
> >  METHOD int update_ios {
> >     device_tbrdev;
> > @@ -76,8 +77,8 @@ METHOD int update_ios {
> >  #
> >  # Called by the mmcbus or its children to schedule a mmc
> > request.  These
> >  # requests are queued.  Time passes.  The bridge then gets
> > notification
> > -# of the status of request, who then notifies the requesting device
> > via
> > -# the xfer_done mmcbus method.
> > +# of the status of the request, who then notifies the requesting
> > device
> > +# by calling the completion function supplied as part of the
> > request.
> >  #
> >  METHOD int request {
> >     device_tbrdev;
> > 
> > Modified: head/sys/dev/sdhci/sdhci.c
> > =
> > =
> > --- head/sys/dev/sdhci/sdhci.c  Fri Mar 17 22:02:02 2017
> > (r315465)
> > +++ head/sys/dev/sdhci/sdhci.c  Fri Mar 17 22:57:37 2017
> > (r315466)
> > @@ -309,9 +309,8 @@ sdhci_set_clock(struct sdhci_slot *slot,
> >     }
> >     /* Divider 1:1 is 0x00, 2:1 is 0x01, 256:1 is 0x80
> > ... */
> >     div >>= 1;
> > -   }
> > -   else {
> > -   /* Version 3.0 divisors are multiples of two up to
> > 1023*2 */
> > +   } else {
> > +   /* Version 3.0 divisors are multiples of two up to
> > 1023 * 2 */
> >     if (clock >= clk_base)
> >     div = 0;
> >     else {
> > @@ -1349,7 +1348,7 @@ sdhci_data_irq(struct sdhci_slot *slot, 
> >     if (intmask & SDHCI_INT_DMA_END) {
> >     data = slot->curcmd->data;
> >  
> > -   /* Unload DMA buffer... */
> > +   /* Unload DMA buffer ... */
> 
> All this churn in the driver for meaningless style fixes and __unused
> markup and so on is bad enough, es

svn commit: r315467 - head/lib/libc/string

2017-03-17 Thread Ed Maste
Author: emaste
Date: Sat Mar 18 00:51:39 2017
New Revision: 315467
URL: https://svnweb.freebsd.org/changeset/base/315467

Log:
  libc: Use musl's O(n) memmem and strstr
  
  It is O(n) in the length of the haystack (big) string, and has special
  cases for short needle (little) strings, of one to four bytes, to avoid
  excessive overhead.
  
  There are a small set of nearly trivial cases where the startup overhead
  of the musl implementation makes it slightly slower -- for example, a 31
  byte needle that matches the beginning of the haystack.  It's faster for
  non-trivial cases, and significantly so for inputs that trigger worst-
  case behaviour of the previous implementation.  As an example, in my
  tests a 16K needle that matches the end of a 64K haystack is nearly
  2000x faster with this implementation.
  
  Reviewed by:  bapt (earlier), ed (earlier)
  Obtained from:musl (snapshot at commit c718f9fc)
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D2601

Modified:
  head/lib/libc/string/memmem.3
  head/lib/libc/string/memmem.c
  head/lib/libc/string/strstr.c

Modified: head/lib/libc/string/memmem.3
==
--- head/lib/libc/string/memmem.3   Fri Mar 17 22:57:37 2017
(r315466)
+++ head/lib/libc/string/memmem.3   Sat Mar 18 00:51:39 2017
(r315467)
@@ -26,7 +26,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd May 26, 2015
+.Dd March 17, 2017
 .Dt MEMMEM 3
 .Os
 .Sh NAME
@@ -77,8 +77,11 @@ The
 .Fn memmem
 function first appeared in
 .Fx 6.0 .
-.Sh AUTHORS
+It was replaced with an optimized O(n) implementation from the musl libc
+project in
+.Fx 12.0 .
 .An Pascal Gloor Aq Mt pascal.gl...@spale.com
+provided this man page along with the previous implementation.
 .Sh BUGS
 This function was broken in Linux libc up to and including version 5.0.9
 and in GNU libc prior to version 2.1.

Modified: head/lib/libc/string/memmem.c
==
--- head/lib/libc/string/memmem.c   Fri Mar 17 22:57:37 2017
(r315466)
+++ head/lib/libc/string/memmem.c   Sat Mar 18 00:51:39 2017
(r315467)
@@ -1,65 +1,173 @@
 /*-
- * Copyright (c) 2005 Pascal Gloor 
+ * Copyright (c) 2005-2014 Rich Felker, et al.
  *
- * 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.
- * 3. The name of the author may not be used to endorse or promote
- *products derived from this software without specific prior written
- *permission.
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
  *
- * 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.
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
-
 #include 
 __FBSDID("$FreeBSD$");
 
 #include 
+#include 
 
-/*
- * Find the fir

svn commit: r315468 - head/lib/libc/string

2017-03-17 Thread Ed Maste
Author: emaste
Date: Sat Mar 18 00:53:24 2017
New Revision: 315468
URL: https://svnweb.freebsd.org/changeset/base/315468

Log:
  libc: add reference to two-way algorithm and bad shift table in memmem/strstr
  
  Requested by: ed

Modified:
  head/lib/libc/string/memmem.c
  head/lib/libc/string/strstr.c

Modified: head/lib/libc/string/memmem.c
==
--- head/lib/libc/string/memmem.c   Sat Mar 18 00:51:39 2017
(r315467)
+++ head/lib/libc/string/memmem.c   Sat Mar 18 00:53:24 2017
(r315468)
@@ -58,6 +58,14 @@ static char *fourbyte_memmem(const unsig
 #define BITOP(a,b,op) \
  ((a)[(size_t)(b)/(8*sizeof *(a))] op (size_t)1<<((size_t)(b)%(8*sizeof *(a
 
+/*
+ * Two Way string search algorithm, with a bad shift table applied to the last
+ * byte of the window. A bit array marks which entries in the shift table are
+ * initialized to avoid fully initializing a 1kb/2kb table.
+ *
+ * Reference: CROCHEMORE M., PERRIN D., 1991, Two-way string-matching,
+ * Journal of the ACM 38(3):651-675
+ */
 static char *twoway_memmem(const unsigned char *h, const unsigned char *z, 
const unsigned char *n, size_t l)
 {
size_t i, ip, jp, k, p, ms, p0, mem, mem0;

Modified: head/lib/libc/string/strstr.c
==
--- head/lib/libc/string/strstr.c   Sat Mar 18 00:51:39 2017
(r315467)
+++ head/lib/libc/string/strstr.c   Sat Mar 18 00:53:24 2017
(r315468)
@@ -55,6 +55,14 @@ static char *fourbyte_strstr(const unsig
 #define BITOP(a,b,op) \
  ((a)[(size_t)(b)/(8*sizeof *(a))] op (size_t)1<<((size_t)(b)%(8*sizeof *(a
 
+/*
+ * Two Way string search algorithm, with a bad shift table applied to the last
+ * byte of the window. A bit array marks which entries in the shift table are
+ * initialized to avoid fully initializing a 1kb/2kb table.
+ *
+ * Reference: CROCHEMORE M., PERRIN D., 1991, Two-way string-matching,
+ * Journal of the ACM 38(3):651-675
+ */
 static char *twoway_strstr(const unsigned char *h, const unsigned char *n)
 {
const unsigned char *z;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r315469 - head/sys/netpfil/pf

2017-03-17 Thread Kristof Provost
Author: kp
Date: Sat Mar 18 01:37:20 2017
New Revision: 315469
URL: https://svnweb.freebsd.org/changeset/base/315469

Log:
  pf: Fix memory leak on vnet shutdown or unload
  
  Rules are unlinked in shutdown_pf(), so we must call
  pf_unload_vnet_purge(), which frees unlinked rules, after that, not
  before.
  
  Reviewed by:  eri, bz
  Differential Revision:https://reviews.freebsd.org/D10040

Modified:
  head/sys/netpfil/pf/pf_ioctl.c

Modified: head/sys/netpfil/pf/pf_ioctl.c
==
--- head/sys/netpfil/pf/pf_ioctl.c  Sat Mar 18 00:53:24 2017
(r315468)
+++ head/sys/netpfil/pf/pf_ioctl.c  Sat Mar 18 01:37:20 2017
(r315469)
@@ -3766,12 +3766,12 @@ pf_unload_vnet(void)
return;
}
 
-   pf_unload_vnet_purge();
-
PF_RULES_WLOCK();
shutdown_pf();
PF_RULES_WUNLOCK();
 
+   pf_unload_vnet_purge();
+
pf_normalize_cleanup();
PF_RULES_WLOCK();
pfi_cleanup_vnet();
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"