svn commit: r298624 - head/usr.sbin/bsdinstall/partedit

2016-04-26 Thread Ed Schouten
Author: ed
Date: Tue Apr 26 10:04:06 2016
New Revision: 298624
URL: https://svnweb.freebsd.org/changeset/base/298624

Log:
  Remove unportable calls to basename().
  
  The POSIX version of basename() doesn't use a 'const char *' argument;
  the function may overwrite its input buffer. Instead of copying the
  input string, let's just simplify this code by using our getprogname()
  function that already returns the name of the application in the right
  format.
  
  Reviewed by:  allanjude
  Differential Revision:https://reviews.freebsd.org/D6094

Modified:
  head/usr.sbin/bsdinstall/partedit/partedit.c

Modified: head/usr.sbin/bsdinstall/partedit/partedit.c
==
--- head/usr.sbin/bsdinstall/partedit/partedit.cTue Apr 26 07:47:01 
2016(r298623)
+++ head/usr.sbin/bsdinstall/partedit/partedit.cTue Apr 26 10:04:06 
2016(r298624)
@@ -27,15 +27,15 @@
  */
 
 #include 
-#include 
-#include 
-#include 
-#include 
 
-#include 
-#include 
 #include 
 #include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
 
 #include "diskeditor.h"
 #include "partedit.h"
@@ -71,13 +71,14 @@ int
 main(int argc, const char **argv)
 {
struct partition_metadata *md;
-   const char *prompt;
+   const char *progname, *prompt;
struct partedit_item *items = NULL;
struct gmesh mesh;
int i, op, nitems, nscroll;
int error;
 
-   if (strcmp(basename(argv[0]), "sade") == 0)
+   progname = getprogname();
+   if (strcmp(progname, "sade") == 0)
sade_mode = 1;
 
TAILQ_INIT(&part_metadata);
@@ -93,7 +94,7 @@ main(int argc, const char **argv)
/* Revert changes on SIGINT */
signal(SIGINT, sigint_handler);
 
-   if (strcmp(basename(argv[0]), "autopart") == 0) { /* Guided */
+   if (strcmp(progname, "autopart") == 0) { /* Guided */
prompt = "Please review the disk setup. When complete, press "
"the Finish button.";
/* Experimental ZFS autopartition support */
@@ -102,7 +103,7 @@ main(int argc, const char **argv)
} else {
part_wizard("ufs");
}
-   } else if (strcmp(basename(argv[0]), "scriptedpart") == 0) {
+   } else if (strcmp(progname, "scriptedpart") == 0) {
error = scripted_editor(argc, argv);
prompt = NULL;
if (error != 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: r298625 - in head/sys/arm: allwinner allwinner/a10 conf

2016-04-26 Thread Emmanuel Vadot
Author: manu
Date: Tue Apr 26 11:15:48 2016
New Revision: 298625
URL: https://svnweb.freebsd.org/changeset/base/298625

Log:
  Convert A10 interrupt controller to INTRNG
  
  Reviewed by:  skra
  Approved by:  cognet (mentor)
  Differential Revision:https://reviews.freebsd.org/D5573

Added:
  head/sys/arm/allwinner/a10/
  head/sys/arm/allwinner/a10/a10_intc.c
 - copied, changed from r298624, head/sys/arm/allwinner/aintc.c
Deleted:
  head/sys/arm/allwinner/aintc.c
Modified:
  head/sys/arm/allwinner/files.a10
  head/sys/arm/conf/A10

Copied and modified: head/sys/arm/allwinner/a10/a10_intc.c (from r298624, 
head/sys/arm/allwinner/aintc.c)
==
--- head/sys/arm/allwinner/aintc.c  Tue Apr 26 10:04:06 2016
(r298624, copy source)
+++ head/sys/arm/allwinner/a10/a10_intc.c   Tue Apr 26 11:15:48 2016
(r298625)
@@ -1,5 +1,6 @@
 /*-
  * Copyright (c) 2012 Ganbold Tsagaankhuu 
+ * Copyright (c) 2016 Emmanuel Vadot 
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -27,13 +28,24 @@
 #include 
 __FBSDID("$FreeBSD$");
 
-#include 
-#include 
+#include "opt_platform.h"
+
+#include 
 #include 
+#include 
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
+#include 
 #include 
+#include 
+#include 
+#ifdef INTRNG
+#include 
+#endif
 #include 
 #include 
 
@@ -42,63 +54,288 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
+#ifdef INTRNG
+#include "pic_if.h"
+#endif
+
 /**
  * Interrupt controller registers
  *
  */
-#define SW_INT_VECTOR_REG  0x00
-#define SW_INT_BASE_ADR_REG0x04
-#define SW_INT_PROTECTION_REG  0x08
-#define SW_INT_NMI_CTRL_REG0x0c
-
-#define SW_INT_IRQ_PENDING_REG00x10
-#define SW_INT_IRQ_PENDING_REG10x14
-#define SW_INT_IRQ_PENDING_REG20x18
-
-#define SW_INT_FIQ_PENDING_REG00x20
-#define SW_INT_FIQ_PENDING_REG10x24
-#define SW_INT_FIQ_PENDING_REG20x28
-
-#define SW_INT_SELECT_REG0 0x30
-#define SW_INT_SELECT_REG1 0x34
-#define SW_INT_SELECT_REG2 0x38
-
-#define SW_INT_ENABLE_REG0 0x40
-#define SW_INT_ENABLE_REG1 0x44
-#define SW_INT_ENABLE_REG2 0x48
-
-#define SW_INT_MASK_REG0   0x50
-#define SW_INT_MASK_REG1   0x54
-#define SW_INT_MASK_REG2   0x58
-
-#define SW_INT_IRQNO_ENMI  0
-
-#define SW_INT_IRQ_PENDING_REG(_b) (0x10 + ((_b) * 4))
-#define SW_INT_FIQ_PENDING_REG(_b) (0x20 + ((_b) * 4))
-#define SW_INT_SELECT_REG(_b)  (0x30 + ((_b) * 4))
-#define SW_INT_ENABLE_REG(_b)  (0x40 + ((_b) * 4))
-#define SW_INT_MASK_REG(_b)(0x50 + ((_b) * 4))
-
-static struct ofw_compat_data compat_data[] = {
-   {"allwinner,sun4i-a10-ic", 1},
-   {"allwinner,sun7i-a20-sc-nmi", 1},
-   {NULL, 0}
+#defineSW_INT_VECTOR_REG   0x00
+#defineSW_INT_BASE_ADR_REG 0x04
+#defineSW_INT_PROTECTION_REG   0x08
+#defineSW_INT_NMI_CTRL_REG 0x0c
+
+#defineSW_INT_IRQ_PENDING_REG0 0x10
+#defineSW_INT_IRQ_PENDING_REG1 0x14
+#defineSW_INT_IRQ_PENDING_REG2 0x18
+
+#defineSW_INT_FIQ_PENDING_REG0 0x20
+#defineSW_INT_FIQ_PENDING_REG1 0x24
+#defineSW_INT_FIQ_PENDING_REG2 0x28
+
+#defineSW_INT_SELECT_REG0  0x30
+#defineSW_INT_SELECT_REG1  0x34
+#defineSW_INT_SELECT_REG2  0x38
+
+#defineSW_INT_ENABLE_REG0  0x40
+#defineSW_INT_ENABLE_REG1  0x44
+#defineSW_INT_ENABLE_REG2  0x48
+
+#defineSW_INT_MASK_REG00x50
+#defineSW_INT_MASK_REG10x54
+#defineSW_INT_MASK_REG20x58
+
+#defineSW_INT_IRQNO_ENMI   0
+
+#defineA10_INTR_MAX_NIRQS  81
+
+#defineSW_INT_IRQ_PENDING_REG(_b)  (0x10 + ((_b) * 4))
+#defineSW_INT_FIQ_PENDING_REG(_b)  (0x20 + ((_b) * 4))
+#defineSW_INT_SELECT_REG(_b)   (0x30 + ((_b) * 4))
+#defineSW_INT_ENABLE_REG(_b)   (0x40 + ((_b) * 4))
+#defineSW_INT_MASK_REG(_b) (0x50 + ((_b) * 4))
+
+#ifdef INTRNG
+struct a10_intr_irqsrc {
+   struct intr_irqsrc  isrc;
+   u_int   irq;
 };
+#endif
 
 struct a10_aintc_softc {
device_tsc_dev;
struct resource *   aintc_res;
bus_space_tag_t aintc_bst;
bus_space_handle_t  aintc_bsh;
-   uint8_t ver;
+   struct mtx  mtx;
+#ifdef INTRNG
+   struct a10_intr_irqsrc  isrcs[A10_INTR_MAX_NIRQS];
+#endif
 };
 
+#defineaintc_rea

svn commit: r298626 - head/bin/csh

2016-04-26 Thread Andrew Turner
Author: andrew
Date: Tue Apr 26 11:39:32 2016
New Revision: 298626
URL: https://svnweb.freebsd.org/changeset/base/298626

Log:
  Stop using sbrk in csh. This is a legacy interface and its use within csh
  is invalid. It is used to find the size of allocated memory. As malloc may
  allocate memory with mmap it will fail to take this memory into account.
  
  Obtained from:brooks

Modified:
  head/bin/csh/config.h

Modified: head/bin/csh/config.h
==
--- head/bin/csh/config.h   Tue Apr 26 11:15:48 2016(r298625)
+++ head/bin/csh/config.h   Tue Apr 26 11:39:32 2016(r298626)
@@ -99,7 +99,7 @@
 #define HAVE_PATHS_H 1
 
 /* Define to 1 if you have the `sbrk' function. */
-#define HAVE_SBRK 1
+/* #undef HAVE_SBRK 1 */
 
 /* Define to 1 if you have the `setpgid' function. */
 #define HAVE_SETPGID 1
___
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: r298627 - in head/sys: arm/allwinner arm/altera/socfpga arm/amlogic/aml8726 arm/annapurna/alpine arm/arm arm/at91 arm/broadcom/bcm2835 arm/cavium/cns11xx arm/freescale arm/freescale/imx...

2016-04-26 Thread Ruslan Bukin
Author: br
Date: Tue Apr 26 11:53:37 2016
New Revision: 298627
URL: https://svnweb.freebsd.org/changeset/base/298627

Log:
  Move arm's devmap to some generic place, so it can be used
  by other architectures.
  
  Reviewed by:  imp
  Differential Revision:https://reviews.freebsd.org/D6091
  Sponsored by: DARPA, AFRL
  Sponsored by: HEIF5

Added:
  head/sys/kern/subr_devmap.c
 - copied, changed from r298626, head/sys/arm/arm/devmap.c
  head/sys/sys/devmap.h
 - copied, changed from r298581, head/sys/arm/include/devmap.h
Deleted:
  head/sys/arm/arm/devmap.c
  head/sys/arm/include/devmap.h
  head/sys/arm64/include/devmap.h
  head/sys/riscv/riscv/devmap.c
Modified:
  head/sys/arm/allwinner/allwinner_machdep.c
  head/sys/arm/altera/socfpga/socfpga_machdep.c
  head/sys/arm/amlogic/aml8726/aml8726_machdep.c
  head/sys/arm/annapurna/alpine/alpine_machdep.c
  head/sys/arm/arm/bus_space_generic.c
  head/sys/arm/arm/machdep.c
  head/sys/arm/at91/at91.c
  head/sys/arm/at91/at91_common.c
  head/sys/arm/at91/at91_machdep.c
  head/sys/arm/broadcom/bcm2835/bcm2835_machdep.c
  head/sys/arm/cavium/cns11xx/econa_machdep.c
  head/sys/arm/freescale/fsl_ocotp.c
  head/sys/arm/freescale/imx/imx51_machdep.c
  head/sys/arm/freescale/imx/imx53_machdep.c
  head/sys/arm/freescale/imx/imx6_machdep.c
  head/sys/arm/freescale/imx/imx_machdep.c
  head/sys/arm/freescale/vybrid/vf_machdep.c
  head/sys/arm/include/vmparam.h
  head/sys/arm/lpc/lpc_machdep.c
  head/sys/arm/mv/mv_common.c
  head/sys/arm/mv/mv_localbus.c
  head/sys/arm/mv/mv_machdep.c
  head/sys/arm/mv/mv_pci.c
  head/sys/arm/mv/mvvar.h
  head/sys/arm/mv/orion/db88f5xxx.c
  head/sys/arm/nvidia/tegra124/tegra124_machdep.c
  head/sys/arm/nvidia/tegra_pcie.c
  head/sys/arm/qemu/virt_machdep.c
  head/sys/arm/rockchip/rk30xx_machdep.c
  head/sys/arm/samsung/exynos/exynos5_machdep.c
  head/sys/arm/ti/ti_machdep.c
  head/sys/arm/versatile/versatile_machdep.c
  head/sys/arm/xilinx/zy7_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/machdep.c
  head/sys/arm64/include/vmparam.h
  head/sys/conf/files.arm
  head/sys/conf/files.arm64
  head/sys/conf/files.riscv
  head/sys/riscv/include/vmparam.h

Modified: head/sys/arm/allwinner/allwinner_machdep.c
==
--- head/sys/arm/allwinner/allwinner_machdep.c  Tue Apr 26 11:39:32 2016
(r298626)
+++ head/sys/arm/allwinner/allwinner_machdep.c  Tue Apr 26 11:53:37 2016
(r298627)
@@ -39,12 +39,12 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
 
 #include 
-#include 
 #include 
 #include 
 
@@ -98,7 +98,7 @@ static vm_offset_t
 allwinner_lastaddr(platform_t plat)
 {
 
-   return (arm_devmap_lastaddr());
+   return (devmap_lastaddr());
 }
 
 /*
@@ -115,7 +115,7 @@ static int
 allwinner_devmap_init(platform_t plat)
 {
 
-   arm_devmap_add_entry(0x01C0, 0x0040); /* 4MB */
+   devmap_add_entry(0x01C0, 0x0040); /* 4MB */
 
return (0);
 }

Modified: head/sys/arm/altera/socfpga/socfpga_machdep.c
==
--- head/sys/arm/altera/socfpga/socfpga_machdep.c   Tue Apr 26 11:39:32 
2016(r298626)
+++ head/sys/arm/altera/socfpga/socfpga_machdep.c   Tue Apr 26 11:53:37 
2016(r298627)
@@ -38,12 +38,12 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
 #include 
 #include 
-#include 
 #include 
 #include 
 
@@ -51,7 +51,7 @@ vm_offset_t
 platform_lastaddr(void)
 {
 
-   return (arm_devmap_lastaddr());
+   return (devmap_lastaddr());
 }
 
 void
@@ -77,7 +77,7 @@ platform_devmap_init(void)
 {
 
/* UART */
-   arm_devmap_add_entry(0xffc0, 0x10);
+   devmap_add_entry(0xffc0, 0x10);
 
/*
 * USB OTG
@@ -87,16 +87,16 @@ platform_devmap_init(void)
 * It might be caused due to some power save options being turned
 * on or something else.
 */
-   arm_devmap_add_entry(0xffb0, 0x10);
+   devmap_add_entry(0xffb0, 0x10);
 
/* dwmmc */
-   arm_devmap_add_entry(0xff70, 0x10);
+   devmap_add_entry(0xff70, 0x10);
 
/* scu */
-   arm_devmap_add_entry(0xfff0, 0x10);
+   devmap_add_entry(0xfff0, 0x10);
 
/* FPGA memory window, 256MB */
-   arm_devmap_add_entry(0xd000, 0x1000);
+   devmap_add_entry(0xd000, 0x1000);
 
return (0);
 }

Modified: head/sys/arm/amlogic/aml8726/aml8726_machdep.c
==
--- head/sys/arm/amlogic/aml8726/aml8726_machdep.c  Tue Apr 26 11:39:32 
2016(r298626)
+++ head/sys/arm/amlogic/aml8726/aml8726_machdep.c  Tue Apr 26 11:53:37 
2016(r298627)
@@ 

svn commit: r298630 - head/sys/arm/allwinner

2016-04-26 Thread Jared McNeill
Author: jmcneill
Date: Tue Apr 26 12:02:36 2016
New Revision: 298630
URL: https://svnweb.freebsd.org/changeset/base/298630

Log:
  Add support for 8-bit eMMC.
  
  Set MMC_CAP_4_BIT_DATA and MMC_CAP_8_BIT_DATA based on the "bus-width"
  DT property and reduce maximum bus frequency from 52MHz to 50MHz to match
  the capabilities of the clock provider.
  
  Tested on a BananaPi BPI-M3 (A83T).

Modified:
  head/sys/arm/allwinner/a10_mmc.c

Modified: head/sys/arm/allwinner/a10_mmc.c
==
--- head/sys/arm/allwinner/a10_mmc.cTue Apr 26 12:00:04 2016
(r298629)
+++ head/sys/arm/allwinner/a10_mmc.cTue Apr 26 12:02:36 2016
(r298630)
@@ -152,8 +152,11 @@ a10_mmc_attach(device_t dev)
struct a10_mmc_softc *sc;
struct sysctl_ctx_list *ctx;
struct sysctl_oid_list *tree;
+   uint32_t bus_width;
+   phandle_t node;
int error;
 
+   node = ofw_bus_get_node(dev);
sc = device_get_softc(dev);
sc->a10_dev = dev;
sc->a10_req = NULL;
@@ -251,11 +254,18 @@ a10_mmc_attach(device_t dev)
device_printf(sc->a10_dev, "DMA status: %s\n",
a10_mmc_pio_mode ? "disabled" : "enabled");
 
+   if (OF_getencprop(node, "bus-width", &bus_width, sizeof(uint32_t)) <= 0)
+   bus_width = 1;
+
sc->a10_host.f_min = 40;
-   sc->a10_host.f_max = 5200;
+   sc->a10_host.f_max = 5000;
sc->a10_host.host_ocr = MMC_OCR_320_330 | MMC_OCR_330_340;
-   sc->a10_host.caps = MMC_CAP_4_BIT_DATA | MMC_CAP_HSPEED;
sc->a10_host.mode = mode_sd;
+   sc->a10_host.caps = MMC_CAP_HSPEED;
+   if (bus_width >= 4)
+   sc->a10_host.caps |= MMC_CAP_4_BIT_DATA;
+   if (bus_width >= 8)
+   sc->a10_host.caps |= MMC_CAP_8_BIT_DATA;
 
child = device_add_child(dev, "mmc", -1);
if (child == NULL) {
___
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: r298631 - head/sys/kern

2016-04-26 Thread Ruslan Bukin
Author: br
Date: Tue Apr 26 12:29:47 2016
New Revision: 298631
URL: https://svnweb.freebsd.org/changeset/base/298631

Log:
  Add support for RISC-V.

Modified:
  head/sys/kern/subr_devmap.c

Modified: head/sys/kern/subr_devmap.c
==
--- head/sys/kern/subr_devmap.c Tue Apr 26 12:02:36 2016(r298630)
+++ head/sys/kern/subr_devmap.c Tue Apr 26 12:29:47 2016(r298631)
@@ -56,7 +56,7 @@ static struct devmap_entryakva_devmap_e
 static u_int   akva_devmap_idx;
 static vm_offset_t akva_devmap_vaddr = DEVMAP_MAX_VADDR;
 
-#ifdef __aarch64__
+#if defined(__aarch64__) || defined(__riscv__)
 extern int early_boot;
 #endif
 
@@ -200,7 +200,7 @@ devmap_bootstrap(vm_offset_t l1pt, const
pmap_map_chunk(l1pt, pd->pd_va, pd->pd_pa, pd->pd_size,
VM_PROT_READ | VM_PROT_WRITE, PTE_DEVICE);
 #endif
-#elif defined(__aarch64__)
+#elif defined(__aarch64__) || defined(__riscv__)
pmap_kenter_device(pd->pd_va, pd->pd_size, pd->pd_pa);
 #endif
}
@@ -273,7 +273,7 @@ pmap_mapdev(vm_offset_t pa, vm_size_t si
pa = trunc_page(pa);
size = round_page(size + offset);
 
-#ifdef __aarch64__
+#if defined(__aarch64__) || defined(__riscv__)
if (early_boot) {
akva_devmap_vaddr = trunc_page(akva_devmap_vaddr - size);
va = akva_devmap_vaddr;
___
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: r298632 - head/sys/dev/uart

2016-04-26 Thread Ruslan Bukin
Author: br
Date: Tue Apr 26 12:31:23 2016
New Revision: 298632
URL: https://svnweb.freebsd.org/changeset/base/298632

Log:
  Do not include fdt.h on RISC-V.

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

Modified: head/sys/dev/uart/uart_cpu_fdt.c
==
--- head/sys/dev/uart/uart_cpu_fdt.cTue Apr 26 12:29:47 2016
(r298631)
+++ head/sys/dev/uart/uart_cpu_fdt.cTue Apr 26 12:31:23 2016
(r298632)
@@ -42,7 +42,7 @@ __FBSDID("$FreeBSD$");
 #include 
 
 #include 
-#ifndef __aarch64__
+#if !defined(__aarch64__) && !defined(__riscv__)
 #include 
 #endif
 
___
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: r298633 - head/sys/riscv/riscv

2016-04-26 Thread Ruslan Bukin
Author: br
Date: Tue Apr 26 12:33:25 2016
New Revision: 298633
URL: https://svnweb.freebsd.org/changeset/base/298633

Log:
  Add the implementation of OF_decode_addr().

Added:
  head/sys/riscv/riscv/ofw_machdep.c   (contents, props changed)

Added: head/sys/riscv/riscv/ofw_machdep.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/riscv/riscv/ofw_machdep.c  Tue Apr 26 12:33:25 2016
(r298633)
@@ -0,0 +1,58 @@
+/*-
+ * Copyright (c) 2015 Ian Lepore 
+ * 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.
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+
+extern struct bus_space memmap_bus;
+
+int
+OF_decode_addr(phandle_t dev, int regno, bus_space_tag_t *tag,
+bus_space_handle_t *handle, bus_size_t *sz)
+{
+   bus_addr_t addr;
+   bus_size_t size;
+   int err;
+
+   err = ofw_reg_to_paddr(dev, regno, &addr, &size, NULL);
+   if (err != 0)
+   return (err);
+
+   *tag = &memmap_bus;
+
+   if (sz != NULL)
+   *sz = size;
+
+   return (bus_space_map(*tag, addr, size, 0, handle));
+}
___
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: r298634 - head/sys/arm/allwinner/clk

2016-04-26 Thread Jared McNeill
Author: jmcneill
Date: Tue Apr 26 12:36:12 2016
New Revision: 298634
URL: https://svnweb.freebsd.org/changeset/base/298634

Log:
  Fix calculation of LCD CH1 SCLK1 output frequency when SCLK2 /2 is used
  as source.
  
  PR:   208680
  Reported by:  David Binderman 

Modified:
  head/sys/arm/allwinner/clk/aw_lcdclk.c

Modified: head/sys/arm/allwinner/clk/aw_lcdclk.c
==
--- head/sys/arm/allwinner/clk/aw_lcdclk.c  Tue Apr 26 12:33:25 2016
(r298633)
+++ head/sys/arm/allwinner/clk/aw_lcdclk.c  Tue Apr 26 12:36:12 2016
(r298634)
@@ -266,7 +266,7 @@ static int
 aw_lcdclk_recalc_freq(struct clknode *clk, uint64_t *freq)
 {
struct aw_lcdclk_softc *sc;
-   uint32_t val, m;
+   uint32_t val, m, src_sel;
 
sc = clknode_get_softc(clk);
 
@@ -281,7 +281,8 @@ aw_lcdclk_recalc_freq(struct clknode *cl
*freq = *freq / m;
 
if (sc->id == CLK_IDX_CH1_SCLK1) {
-   if ((val & CH1_SCLK1_SEL) == CH1_SCLK1_SEL_SCLK2_DIV2)
+   src_sel = (val & CH1_SCLK1_SEL) >> CH1_SCLK1_SEL_SHIFT;
+   if (src_sel == CH1_SCLK1_SEL_SCLK2_DIV2)
*freq /= 2;
}
 
___
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: r298635 - head/sys/riscv/riscv

2016-04-26 Thread Ruslan Bukin
Author: br
Date: Tue Apr 26 12:45:01 2016
New Revision: 298635
URL: https://svnweb.freebsd.org/changeset/base/298635

Log:
  Add the implementation of basic bus_space_read/write functions.
  
  Sponsored by: DARPA, AFRL
  Sponsored by: HEIF5

Added:
  head/sys/riscv/riscv/bus_space_asm.S   (contents, props changed)
Modified:
  head/sys/riscv/riscv/bus_machdep.c

Modified: head/sys/riscv/riscv/bus_machdep.c
==
--- head/sys/riscv/riscv/bus_machdep.c  Tue Apr 26 12:36:12 2016
(r298634)
+++ head/sys/riscv/riscv/bus_machdep.c  Tue Apr 26 12:45:01 2016
(r298635)
@@ -1,4 +1,5 @@
 /*-
+ * Copyright (c) 2014 Andrew Turner
  * Copyright (c) 2015 Ruslan Bukin 
  * All rights reserved.
  *
@@ -42,27 +43,108 @@ __FBSDID("$FreeBSD$");
 
 #include 
 
+uint8_t  generic_bs_r_1(void *, bus_space_handle_t, bus_size_t);
+uint16_t generic_bs_r_2(void *, bus_space_handle_t, bus_size_t);
+uint32_t generic_bs_r_4(void *, bus_space_handle_t, bus_size_t);
+uint64_t generic_bs_r_8(void *, bus_space_handle_t, bus_size_t);
+
+void generic_bs_rm_1(void *, bus_space_handle_t, bus_size_t, uint8_t *,
+bus_size_t);
+void generic_bs_rm_2(void *, bus_space_handle_t, bus_size_t, uint16_t *,
+bus_size_t);
+void generic_bs_rm_4(void *, bus_space_handle_t, bus_size_t, uint32_t *,
+bus_size_t);
+void generic_bs_rm_8(void *, bus_space_handle_t, bus_size_t, uint64_t *,
+bus_size_t);
+
+void generic_bs_rr_1(void *, bus_space_handle_t, bus_size_t, uint8_t *,
+bus_size_t);
+void generic_bs_rr_2(void *, bus_space_handle_t, bus_size_t, uint16_t *,
+bus_size_t);
+void generic_bs_rr_4(void *, bus_space_handle_t, bus_size_t, uint32_t *,
+bus_size_t);
+void generic_bs_rr_8(void *, bus_space_handle_t, bus_size_t, uint64_t *,
+bus_size_t);
+
+void generic_bs_w_1(void *, bus_space_handle_t, bus_size_t, uint8_t);
+void generic_bs_w_2(void *, bus_space_handle_t, bus_size_t, uint16_t);
+void generic_bs_w_4(void *, bus_space_handle_t, bus_size_t, uint32_t);
+void generic_bs_w_8(void *, bus_space_handle_t, bus_size_t, uint64_t);
+
+void generic_bs_wm_1(void *, bus_space_handle_t, bus_size_t, const uint8_t *,
+bus_size_t);
+void generic_bs_wm_2(void *, bus_space_handle_t, bus_size_t, const uint16_t *,
+bus_size_t);
+void generic_bs_wm_4(void *, bus_space_handle_t, bus_size_t, const uint32_t *,
+bus_size_t);
+void generic_bs_wm_8(void *, bus_space_handle_t, bus_size_t, const uint64_t *,
+bus_size_t);
+
+void generic_bs_wr_1(void *, bus_space_handle_t, bus_size_t, const uint8_t *,
+bus_size_t);
+void generic_bs_wr_2(void *, bus_space_handle_t, bus_size_t, const uint16_t *,
+bus_size_t);
+void generic_bs_wr_4(void *, bus_space_handle_t, bus_size_t, const uint32_t *,
+bus_size_t);
+void generic_bs_wr_8(void *, bus_space_handle_t, bus_size_t, const uint64_t *,
+bus_size_t);
+
+static int
+generic_bs_map(void *t, bus_addr_t bpa, bus_size_t size, int flags,
+bus_space_handle_t *bshp)
+{
+   void *va;
+
+   va = pmap_mapdev(bpa, size);
+   if (va == NULL)
+   return (ENOMEM);
+   *bshp = (bus_space_handle_t)va;
+   return (0);
+}
+
+static void
+generic_bs_unmap(void *t, bus_space_handle_t bsh, bus_size_t size)
+{
+
+   pmap_unmapdev(bsh, size);
+}
+
+static void
+generic_bs_barrier(void *t, bus_space_handle_t bsh, bus_size_t offset,
+bus_size_t size, int flags)
+{
+}
+
+static int
+generic_bs_subregion(void *t, bus_space_handle_t bsh, bus_size_t offset,
+bus_size_t size, bus_space_handle_t *nbshp)
+{
+
+   *nbshp = bsh + offset;
+   return (0);
+}
+
 struct bus_space memmap_bus = {
/* cookie */
.bs_cookie = NULL,
 
/* mapping/unmapping */
-   .bs_map = NULL,
-   .bs_unmap = NULL,
-   .bs_subregion = NULL,
+   .bs_map = generic_bs_map,
+   .bs_unmap = generic_bs_unmap,
+   .bs_subregion = generic_bs_subregion,
 
/* allocation/deallocation */
.bs_alloc = NULL,
.bs_free = NULL,
 
/* barrier */
-   .bs_barrier = NULL,
+   .bs_barrier = generic_bs_barrier,
 
/* read single */
-   .bs_r_1 = NULL,
-   .bs_r_2 = NULL,
-   .bs_r_4 = NULL,
-   .bs_r_8 = NULL,
+   .bs_r_1 = generic_bs_r_1,
+   .bs_r_2 = generic_bs_r_2,
+   .bs_r_4 = generic_bs_r_4,
+   .bs_r_8 = generic_bs_r_8,
 
/* read multiple */
.bs_rm_1 = NULL,
@@ -71,10 +153,10 @@ struct bus_space memmap_bus = {
.bs_rm_8 = NULL,
 
/* write single */
-   .bs_w_1 = NULL,
-   .bs_w_2 = NULL,
-   .bs_w_4 = NULL,
-   .bs_w_8 = NULL,
+   .bs_w_1 = generic_bs_w_1,
+   .bs_w_2 = generic_bs_w_2,
+   .bs_w_4 = generic_bs_w_4,
+   .bs_w_8 = generic_bs_w_8,
 
/* write multiple */
.bs_wm_1 = NULL,
@@ -142,3 +224,7 @@ struct bus_space memmap_bus = {
.bs_wr_4_s = NULL,
.bs_wr_8_s = NULL,
 };
+
+#ifdef FDT
+bus_spac

svn commit: r298636 - in head/sys/riscv: include riscv

2016-04-26 Thread Ruslan Bukin
Author: br
Date: Tue Apr 26 12:56:44 2016
New Revision: 298636
URL: https://svnweb.freebsd.org/changeset/base/298636

Log:
  Add the non-standard "IO interrupt" vector used by lowRISC.
  For now they provide UART irq only.
  
  Sponsored by: DARPA, AFRL
  Sponsored by: HEIF5

Modified:
  head/sys/riscv/include/intr.h
  head/sys/riscv/include/riscvreg.h
  head/sys/riscv/riscv/exception.S
  head/sys/riscv/riscv/intr_machdep.c

Modified: head/sys/riscv/include/intr.h
==
--- head/sys/riscv/include/intr.h   Tue Apr 26 12:45:01 2016
(r298635)
+++ head/sys/riscv/include/intr.h   Tue Apr 26 12:56:44 2016
(r298636)
@@ -60,6 +60,8 @@ enum {
IRQ_SOFTWARE,
IRQ_TIMER,
IRQ_HTIF,
+   IRQ_COP,/* lowRISC only */
+   IRQ_UART,   /* lowRISC only */
NIRQS
 };
 

Modified: head/sys/riscv/include/riscvreg.h
==
--- head/sys/riscv/include/riscvreg.h   Tue Apr 26 12:45:01 2016
(r298635)
+++ head/sys/riscv/include/riscvreg.h   Tue Apr 26 12:56:44 2016
(r298636)
@@ -47,7 +47,8 @@
 #defineECALL_SEND_IPI  0x07
 #defineECALL_CLEAR_IPI 0x08
 #defineECALL_HTIF_LOWPUTC  0x09
-#defineECALL_MIE_SET   0x10
+#defineECALL_MIE_SET   0x0a
+#defineECALL_IO_IRQ_MASK   0x0b
 
 #defineEXCP_SHIFT  0
 #defineEXCP_MASK   (0xf << EXCP_SHIFT)
@@ -119,6 +120,7 @@
 
 #defineNCSRS   4096
 #defineCSR_IPI 0x783
+#defineCSR_IO_IRQ  0x7c0   /* lowRISC only? */
 #defineXLEN8
 #defineINSN_SIZE   4
 

Modified: head/sys/riscv/riscv/exception.S
==
--- head/sys/riscv/riscv/exception.STue Apr 26 12:45:01 2016
(r298635)
+++ head/sys/riscv/riscv/exception.STue Apr 26 12:56:44 2016
(r298636)
@@ -270,18 +270,27 @@ supervisor_trap:
 machine_interrupt:
/* Type of interrupt ? */
csrrt0, mcause
-   andit0, t0, 3
+   andit0, t0, EXCP_MASK
li  t1, 0
beq t1, t0, software_interrupt
li  t1, 1
beq t1, t0, timer_interrupt
li  t1, 2
beq t1, t0, htif_interrupt
+   li  t1, 4
+   beq t1, t0, io_interrupt/* lowRISC only */
 
/* not reached */
 1:
j   1b
 
+io_interrupt:
+   /* Disable IO interrupts so we can go to supervisor mode */
+   csrwi   CSR_IO_IRQ, 0
+
+   /* Handle the trap in supervisor mode */
+   j   exit_mrts
+
 software_interrupt:
li  t0, MIP_MSIP
csrcmip, t0
@@ -307,7 +316,7 @@ software_interrupt:
j   exit
 
 1:
-   /* Serve a trap in supervisor mode */
+   /* Handle the trap in supervisor mode */
j   exit_mrts
 
 timer_interrupt:
@@ -415,6 +424,12 @@ supervisor_call:
beq t5, t4, htif_lowputc
li  t4, ECALL_MIE_SET
beq t5, t4, mie_set
+   li  t4, ECALL_IO_IRQ_MASK
+   beq t5, t4, io_irq_mask
+   j   exit_next_instr
+
+io_irq_mask:
+   csrwCSR_IO_IRQ, t6
j   exit_next_instr
 
 mie_set:

Modified: head/sys/riscv/riscv/intr_machdep.c
==
--- head/sys/riscv/riscv/intr_machdep.c Tue Apr 26 12:45:01 2016
(r298635)
+++ head/sys/riscv/riscv/intr_machdep.c Tue Apr 26 12:56:44 2016
(r298636)
@@ -101,6 +101,9 @@ riscv_mask_irq(void *source)
case IRQ_SOFTWARE:
csr_clear(sie, SIE_SSIE);
break;
+   case IRQ_UART:
+   machine_command(ECALL_IO_IRQ_MASK, 0);
+   break;
default:
panic("Unknown irq %d\n", irq);
}
@@ -120,6 +123,9 @@ riscv_unmask_irq(void *source)
case IRQ_SOFTWARE:
csr_set(sie, SIE_SSIE);
break;
+   case IRQ_UART:
+   machine_command(ECALL_IO_IRQ_MASK, 1);
+   break;
default:
panic("Unknown irq %d\n", irq);
}
@@ -203,6 +209,7 @@ riscv_cpu_intr(struct trapframe *frame)
active_irq = (frame->tf_scause & EXCP_MASK);
 
switch (active_irq) {
+   case IRQ_UART:
case IRQ_SOFTWARE:
case IRQ_TIMER:
event = intr_events[active_irq];
___
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: r298637 - head/sys/dev/uart

2016-04-26 Thread Andrew Turner
Author: andrew
Date: Tue Apr 26 13:16:45 2016
New Revision: 298637
URL: https://svnweb.freebsd.org/changeset/base/298637

Log:
  Stop including machine/fdt.h from the fdt uart code, it's unneeded.
  
  Sponsored by: ABT Systems Ltd

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

Modified: head/sys/dev/uart/uart_cpu_fdt.c
==
--- head/sys/dev/uart/uart_cpu_fdt.cTue Apr 26 12:56:44 2016
(r298636)
+++ head/sys/dev/uart/uart_cpu_fdt.cTue Apr 26 13:16:45 2016
(r298637)
@@ -42,9 +42,6 @@ __FBSDID("$FreeBSD$");
 #include 
 
 #include 
-#if !defined(__aarch64__) && !defined(__riscv__)
-#include 
-#endif
 
 #include 
 #include 
___
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: r298638 - in head/sys: boot/fdt/dts/riscv conf riscv/conf

2016-04-26 Thread Ruslan Bukin
Author: br
Date: Tue Apr 26 13:22:08 2016
New Revision: 298638
URL: https://svnweb.freebsd.org/changeset/base/298638

Log:
  o Add device tree files and kernel configuration files
for RISC-V cpus synthesized on FPGA hardware.
  o Include new files to the build.

Added:
  head/sys/boot/fdt/dts/riscv/lowrisc.dts   (contents, props changed)
  head/sys/boot/fdt/dts/riscv/rocket.dts   (contents, props changed)
  head/sys/riscv/conf/LOWRISC   (contents, props changed)
  head/sys/riscv/conf/LOWRISC.hints   (contents, props changed)
  head/sys/riscv/conf/ROCKET   (contents, props changed)
Modified:
  head/sys/conf/files.riscv
  head/sys/riscv/conf/GENERIC
  head/sys/riscv/conf/QEMU
  head/sys/riscv/conf/SPIKE

Added: head/sys/boot/fdt/dts/riscv/lowrisc.dts
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/boot/fdt/dts/riscv/lowrisc.dts Tue Apr 26 13:22:08 2016
(r298638)
@@ -0,0 +1,108 @@
+/*-
+ * Copyright (c) 2016 Ruslan Bukin 
+ * All rights reserved.
+ *
+ * Portions of this software were developed by SRI International and the
+ * University of Cambridge Computer Laboratory under DARPA/AFRL contract
+ * FA8750-10-C-0237 ("CTSRD"), as part of the DARPA CRASH research programme.
+ *
+ * Portions of this software were developed by the University of Cambridge
+ * Computer Laboratory as part of the CTSRD Project, with support from the
+ * UK Higher Education Innovation Fund (HEIF).
+ *
+ * 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$
+ */
+
+/dts-v1/;
+
+/ {
+   model = "UC Berkeley Spike Simulator RV64I";
+   compatible = "riscv,rv64i";
+   #address-cells = <1>;
+   #size-cells = <1>;
+   #interrupt-cells = <1>;
+
+   cpus {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   cpu@0 {
+   device_type = "cpu";
+   compatible = "riscv,rv64i";
+   reg = <0x40002000>;
+   };
+   };
+
+   aliases {
+   serial0 = &serial0;
+   };
+
+   memory {
+   device_type = "memory";
+   reg = <0x0 0x800>; /* 128MB at 0x0 */
+   };
+
+   soc {
+   #address-cells = <1>;
+   #size-cells = <1>;
+   #interrupt-cells = <1>;
+
+   compatible = "simple-bus";
+   ranges;
+
+   pic0: pic@0 {
+   compatible = "riscv,pic";
+   interrupt-controller;
+   };
+
+   serial0: serial@80001000 {
+   compatible = "ns16550";
+   reg = <0x80001000 0x1000>;
+   reg-shift = <2>;
+   interrupts = < 4 >;
+   interrupt-parent = <&pic0>;
+   current-speed = <115200>;
+   clock-frequency = < 100 >;
+   status = "okay";
+   };
+
+   spi0: spi@8001 {
+   compatible = "xlnx,xps-spi-3.2";
+   reg = <0x8001 0x1000>;
+   };
+
+   timer0: timer@0 {
+   compatible = "riscv,timer";
+   interrupts = < 1 >;
+   interrupt-parent = < &pic0 >;
+   clock-frequency = < 100 >;
+   };
+   };
+
+   chosen {
+   bootargs = "-v";
+   stdin = "serial0";
+   stdout = "serial0";
+   };
+};

Added: head/sys/boot/fdt/dts/riscv/rocket.dts
=

Re: svn commit: r298612 - head/sys/dev/iwm

2016-04-26 Thread Adrian Chadd
You're right in all counts; this was just a first cut to at least get
it done and working. We can iterate over it and tidy things up.

(It's creepy being able to use iwm now and have it magically "work"..)


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


Re: svn commit: r298612 - head/sys/dev/iwm

2016-04-26 Thread Adrian Chadd
it's a dirty habit I learnt from linux.

Seeing the '!!' says "it's always 1 or 0". I get into that habit so
the same thing happens when you do bit masking, eg:

do_stop = (foo & 0x10) ;

is 0x10 or 0, but

do_stop = !! (foo & 0x10);

is 1 or 0.



-adrian


On 25 April 2016 at 21:45, Ravi Pokala  wrote:
>> do_stop = !! (sc->sc_ic.ic_nrunning > 0);
>
> Why the double-negation? Isn't
>
> do_stop = (sc->sc_ic.ic_nrunning > 0);
>
> equivalent?
>
> -Ravi (rpokala@)
>
>
>
> -Original Message-
> From:  on behalf of Adrian Chadd 
> 
> Date: 2016-04-25, Monday at 21:40
> To: , , 
> 
> Subject: svn commit: r298612 - head/sys/dev/iwm
>
>>Author: adrian
>>Date: Tue Apr 26 04:40:59 2016
>>New Revision: 298612
>>URL: https://svnweb.freebsd.org/changeset/base/298612
>>
>>Log:
>>  [iwm] implement suspend/resume through ieee80211_{suspend,resume}_all
>>
>>  This allows wifi to associate correctly after a suspend/resume cycle.
>>
>>  Yes, I'm using this now day to day.
>>
>>  Tested:
>>
>>  * Intel 7260AC, STA mode
>>
>>Modified:
>>  head/sys/dev/iwm/if_iwm.c
>>  head/sys/dev/iwm/if_iwmvar.h
>>
>>Modified: head/sys/dev/iwm/if_iwm.c
>>==
>>--- head/sys/dev/iwm/if_iwm.c  Tue Apr 26 03:24:28 2016(r298611)
>>+++ head/sys/dev/iwm/if_iwm.c  Tue Apr 26 04:40:59 2016(r298612)
>>@@ -4934,6 +4934,8 @@ iwm_init_task(void *arg1)
>> static int
>> iwm_resume(device_t dev)
>> {
>>+  struct iwm_softc *sc = device_get_softc(dev);
>>+  int do_reinit = 0;
>>   uint16_t reg;
>>
>>   /* Clear device-specific "PCI retry timeout" register (41h). */
>>@@ -4941,17 +4943,33 @@ iwm_resume(device_t dev)
>>   pci_write_config(dev, 0x40, reg & ~0xff00, sizeof(reg));
>>   iwm_init_task(device_get_softc(dev));
>>
>>+  IWM_LOCK(sc);
>>+  if (sc->sc_flags & IWM_FLAG_DORESUME) {
>>+  sc->sc_flags &= ~IWM_FLAG_DORESUME;
>>+  do_reinit = 1;
>>+  }
>>+  IWM_UNLOCK(sc);
>>+
>>+  if (do_reinit)
>>+  ieee80211_resume_all(&sc->sc_ic);
>>+
>>   return 0;
>> }
>>
>> static int
>> iwm_suspend(device_t dev)
>> {
>>+  int do_stop = 0;
>>   struct iwm_softc *sc = device_get_softc(dev);
>>
>>-  if (sc->sc_ic.ic_nrunning > 0) {
>>+  do_stop = !! (sc->sc_ic.ic_nrunning > 0);
>>+
>>+  ieee80211_suspend_all(&sc->sc_ic);
>>+
>>+  if (do_stop) {
>>   IWM_LOCK(sc);
>>   iwm_stop(sc);
>>+  sc->sc_flags |= IWM_FLAG_DORESUME;
>>   IWM_UNLOCK(sc);
>>   }
>>
>>
>>Modified: head/sys/dev/iwm/if_iwmvar.h
>>==
>>--- head/sys/dev/iwm/if_iwmvar.h   Tue Apr 26 03:24:28 2016
>>(r298611)
>>+++ head/sys/dev/iwm/if_iwmvar.h   Tue Apr 26 04:40:59 2016
>>(r298612)
>>@@ -405,6 +405,7 @@ struct iwm_softc {
>> #define IWM_FLAG_STOPPED  (1 << 2)
>> #define IWM_FLAG_RFKILL   (1 << 3)
>> #define IWM_FLAG_BUSY (1 << 4)
>>+#define   IWM_FLAG_DORESUME   (1 << 5)
>>
>>   struct intr_config_hook sc_preinit_hook;
>>   struct callout  sc_watchdog_to;
>>
>
___
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: r298639 - head/sys/arm64/conf

2016-04-26 Thread Andrew Turner
Author: andrew
Date: Tue Apr 26 14:21:39 2016
New Revision: 298639
URL: https://svnweb.freebsd.org/changeset/base/298639

Log:
  Disable ACPI on arm64 ad it has only had minimal testing and is causing
  boot issues when booting with FDT. It is planned to re-enable this at a
  later date.
  
  Obtained from:ABT Systems Ltd
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/arm64/conf/GENERIC

Modified: head/sys/arm64/conf/GENERIC
==
--- head/sys/arm64/conf/GENERIC Tue Apr 26 13:22:08 2016(r298638)
+++ head/sys/arm64/conf/GENERIC Tue Apr 26 14:21:39 2016(r298639)
@@ -153,7 +153,7 @@ device  bpf # Berkeley packet filter
 optionsTHUNDERX_PASS_1_1_ERRATA
 
 optionsFDT
-device acpi
+#deviceacpi
 
 # The crypto framework is required by IPSEC
 device crypto  # Required by IPSEC
___
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: r298640 - head/bin/ed

2016-04-26 Thread Pedro F. Giffuni
Author: pfg
Date: Tue Apr 26 14:31:48 2016
New Revision: 298640
URL: https://svnweb.freebsd.org/changeset/base/298640

Log:
  ed(1): switch two statements so we check the index before dereferencing.
  
  This is related to r270256 but was missed in that occasion.
  
  MFC after:3 days

Modified:
  head/bin/ed/cbc.c

Modified: head/bin/ed/cbc.c
==
--- head/bin/ed/cbc.c   Tue Apr 26 14:21:39 2016(r298639)
+++ head/bin/ed/cbc.c   Tue Apr 26 14:31:48 2016(r298640)
@@ -257,7 +257,7 @@ expand_des_key(char *obuf, char *kbuf)
/*
 * now translate it, bombing on any illegal binary digit
 */
-   for (i = 0; kbuf[i] && i < 16; i++)
+   for (i = 0; i < 16 && kbuf[i]; i++)
if ((nbuf[i] = hex_to_binary((int) kbuf[i], 2)) == -1)
des_error("bad binary digit in key");
while (i < 64)
___
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: r298641 - in head/sys/riscv: include riscv

2016-04-26 Thread Ruslan Bukin
Author: br
Date: Tue Apr 26 14:38:18 2016
New Revision: 298641
URL: https://svnweb.freebsd.org/changeset/base/298641

Log:
  Rework the list of all pmaps: embed the list link into pmap.

Modified:
  head/sys/riscv/include/pmap.h
  head/sys/riscv/riscv/pmap.c

Modified: head/sys/riscv/include/pmap.h
==
--- head/sys/riscv/include/pmap.h   Tue Apr 26 14:31:48 2016
(r298640)
+++ head/sys/riscv/include/pmap.h   Tue Apr 26 14:38:18 2016
(r298641)
@@ -74,18 +74,12 @@ struct pv_addr {
vm_paddr_t  pv_pa;
 };
 
-/* An entry in the list of all pmaps */
-struct pmap_list_entry {
-   SLIST_ENTRY(pmap_list_entry) pmap_link;
-   struct pmap *pmap;
-};
-
 struct pmap {
struct mtx  pm_mtx;
struct pmap_statistics  pm_stats;   /* pmap statictics */
pd_entry_t  *pm_l1;
TAILQ_HEAD(,pv_chunk)   pm_pvchunk; /* list of mappings in pmap */
-   struct pmap_list_entry  *p_entry; /* Place in the list of all pmaps */
+   LIST_ENTRY(pmap)pm_list;/* List of all pmaps */
 };
 
 typedef struct pv_entry {

Modified: head/sys/riscv/riscv/pmap.c
==
--- head/sys/riscv/riscv/pmap.c Tue Apr 26 14:31:48 2016(r298640)
+++ head/sys/riscv/riscv/pmap.c Tue Apr 26 14:38:18 2016(r298641)
@@ -207,9 +207,9 @@ __FBSDID("$FreeBSD$");
 #defineVM_PAGE_TO_PV_LIST_LOCK(m)  \
PHYS_TO_PV_LIST_LOCK(VM_PAGE_TO_PHYS(m))
 
-/* The list of all the pmaps */
-static SLIST_HEAD(, pmap_list_entry) pmap_list =
-SLIST_HEAD_INITIALIZER(pmap_list);
+/* The list of all the user pmaps */
+LIST_HEAD(pmaplist, pmap);
+static struct pmaplist allpmaps;
 
 static MALLOC_DEFINE(M_VMPMAP, "pmap", "PMAP L1");
 
@@ -416,7 +416,6 @@ static void
 pmap_distribute_l1(struct pmap *pmap, vm_pindex_t l1index,
 pt_entry_t entry)
 {
-   struct pmap_list_entry *p_entry;
struct pmap *user_pmap;
pd_entry_t *l1;
 
@@ -424,8 +423,7 @@ pmap_distribute_l1(struct pmap *pmap, vm
if (pmap != kernel_pmap)
return;
 
-   SLIST_FOREACH(p_entry, &pmap_list, pmap_link) {
-   user_pmap = p_entry->pmap;
+   LIST_FOREACH(user_pmap, &allpmaps, pm_list) {
l1 = &user_pmap->pm_l1[l1index];
if (entry)
pmap_load_store(l1, entry);
@@ -569,6 +567,8 @@ pmap_bootstrap(vm_offset_t l1pt, vm_padd
 */
rw_init(&pvh_global_lock, "pmap pv global");
 
+   LIST_INIT(&allpmaps);
+
/* Assume the address we were loaded to is a valid physical address */
min_pa = KERNBASE - kern_delta;
 
@@ -1177,7 +1177,6 @@ pmap_pinit0(pmap_t pmap)
 int
 pmap_pinit(pmap_t pmap)
 {
-   struct pmap_list_entry *p_entry;
vm_paddr_t l1phys;
vm_page_t l1pt;
 
@@ -1199,12 +1198,8 @@ pmap_pinit(pmap_t pmap)
/* Install kernel pagetables */
memcpy(pmap->pm_l1, kernel_pmap->pm_l1, PAGE_SIZE);
 
-   p_entry = malloc(sizeof(struct pmap_list_entry), M_VMPMAP, M_WAITOK);
-   p_entry->pmap = pmap;
-   pmap->p_entry = p_entry;
-
-   /* Add to the list of all pmaps */
-   SLIST_INSERT_HEAD(&pmap_list, p_entry, pmap_link);
+   /* Add to the list of all user pmaps */
+   LIST_INSERT_HEAD(&allpmaps, pmap, pm_list);
 
return (1);
 }
@@ -1374,12 +1369,11 @@ pmap_release(pmap_t pmap)
atomic_subtract_int(&vm_cnt.v_wire_count, 1);
vm_page_free_zero(m);
 
+   /* Remove pmap from the allpmaps list */
+   LIST_REMOVE(pmap, pm_list);
+
/* Remove kernel pagetables */
bzero(pmap->pm_l1, PAGE_SIZE);
-
-   /* Remove pmap from the all pmaps list */
-   SLIST_REMOVE(&pmap_list, pmap->p_entry,
-   pmap_list_entry, pmap_link);
 }
 
 #if 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"


Re: svn commit: r298580 - in head/sys/riscv: include riscv

2016-04-26 Thread Ruslan Bukin
On Mon, Apr 25, 2016 at 06:50:44PM +0300, Konstantin Belousov wrote:
> On Mon, Apr 25, 2016 at 02:47:51PM +, Ruslan Bukin wrote:
> > +/* An entry in the list of all pmaps */
> > +struct pmap_list_entry {
> > +   SLIST_ENTRY(pmap_list_entry) pmap_link;
> > +   struct pmap *pmap;
> > +};
> 
> This is weird. Why do you need separate structure to track the all
> pmaps list, instead of embedding the list link into pmap itself ? In
> particular, the pmap_list_entry.pmap pointing to the pmap looks strange.
> 
> And why do you use single-linked list for the container where you need
> to remove elements ?  The cost is the iteration over the whole container
> on removal, vs. additional pointer in each pmap.
> 

Many thanks. I have committed the fix (same way as i386 do).

Ruslan
___
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: r298642 - in head/sys/powerpc: booke mpc85xx powerpc

2016-04-26 Thread Pedro F. Giffuni
Author: pfg
Date: Tue Apr 26 14:44:49 2016
New Revision: 298642
URL: https://svnweb.freebsd.org/changeset/base/298642

Log:
  sys/powerpc: make use of the howmany() macro when available.
  
  We have a howmany() macro in the  header that is
  convenient to re-use as it makes things easier to read.

Modified:
  head/sys/powerpc/booke/pmap.c
  head/sys/powerpc/mpc85xx/fsl_sdhc.c
  head/sys/powerpc/powerpc/clock.c

Modified: head/sys/powerpc/booke/pmap.c
==
--- head/sys/powerpc/booke/pmap.c   Tue Apr 26 14:38:18 2016
(r298641)
+++ head/sys/powerpc/booke/pmap.c   Tue Apr 26 14:44:49 2016
(r298642)
@@ -1115,8 +1115,8 @@ mmu_booke_bootstrap(mmu_t mmu, vm_offset
 
/* Allocate PTE tables for kernel KVA. */
kernel_pdir = data_end;
-   kernel_ptbls = (VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS +
-   PDIR_SIZE - 1) / PDIR_SIZE;
+   kernel_ptbls = howmany(VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS,
+   PDIR_SIZE);
data_end += kernel_ptbls * PTBL_PAGES * PAGE_SIZE;
debugf(" kernel ptbls: %d\n", kernel_ptbls);
debugf(" kernel pdir at 0x%08x end = 0x%08x\n", kernel_pdir, data_end);

Modified: head/sys/powerpc/mpc85xx/fsl_sdhc.c
==
--- head/sys/powerpc/mpc85xx/fsl_sdhc.c Tue Apr 26 14:38:18 2016
(r298641)
+++ head/sys/powerpc/mpc85xx/fsl_sdhc.c Tue Apr 26 14:44:49 2016
(r298642)
@@ -271,7 +271,7 @@ set_clock(struct fsl_sdhc_softc *sc, uin
 * divisor = ceil(base_clock / clock)
 * TODO: Reconsider symmetric rounding here instead of ceiling.
 */
-   divisor = (base_clock + clock - 1) / clock;
+   divisor = howmany(base_clock, clock);
 
while (divisor > 16) {
round = divisor & 0x1;

Modified: head/sys/powerpc/powerpc/clock.c
==
--- head/sys/powerpc/powerpc/clock.cTue Apr 26 14:38:18 2016
(r298641)
+++ head/sys/powerpc/powerpc/clock.cTue Apr 26 14:44:49 2016
(r298642)
@@ -301,7 +301,7 @@ DELAY(int n)
u_quad_ttb, ttb;
 
tb = mftb();
-   ttb = tb + (n * 1000 + ns_per_tick - 1) / ns_per_tick;
+   ttb = tb + howmany(n * 1000, ns_per_tick);
while (tb < ttb)
tb = mftb();
 }
___
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: r298643 - in head/sys/arm: arm at91 freescale/imx nvidia

2016-04-26 Thread Pedro F. Giffuni
Author: pfg
Date: Tue Apr 26 14:47:52 2016
New Revision: 298643
URL: https://svnweb.freebsd.org/changeset/base/298643

Log:
  sys/arm: make use of the howmany() macro when available.
  
  We have a howmany() macro in the  header that is
  convenient to re-use as it makes things easier to read.

Modified:
  head/sys/arm/arm/pmap-v4.c
  head/sys/arm/at91/at91_pit.c
  head/sys/arm/freescale/imx/imx_i2c.c
  head/sys/arm/nvidia/as3722_regulators.c

Modified: head/sys/arm/arm/pmap-v4.c
==
--- head/sys/arm/arm/pmap-v4.c  Tue Apr 26 14:44:49 2016(r298642)
+++ head/sys/arm/arm/pmap-v4.c  Tue Apr 26 14:47:52 2016(r298643)
@@ -2285,7 +2285,7 @@ pmap_bootstrap(vm_offset_t firstaddr, st
round_page(size * L2_TABLE_SIZE_REAL) / PAGE_SIZE,
&pmap_kernel_l2ptp_kva, NULL);
 
-   size = (size + (L2_BUCKET_SIZE - 1)) / L2_BUCKET_SIZE;
+   size = howmany(size, L2_BUCKET_SIZE);
pmap_alloc_specials(&virtual_avail,
round_page(size * sizeof(struct l2_dtable)) / PAGE_SIZE,
&pmap_kernel_l2dtable_kva, NULL);

Modified: head/sys/arm/at91/at91_pit.c
==
--- head/sys/arm/at91/at91_pit.cTue Apr 26 14:44:49 2016
(r298642)
+++ head/sys/arm/at91/at91_pit.cTue Apr 26 14:47:52 2016
(r298643)
@@ -98,7 +98,7 @@ at91_pit_delay(int us)
 
/* Max delay ~= 260s. @ 133Mhz */
pit_freq = at91_master_clock / PIT_PRESCALE;
-   cnt  = ((pit_freq * us) + (mhz -1)) / mhz;
+   cnt  = howmany(pit_freq * us, mhz);
cnt  = (cnt <= 0) ? 1 : cnt;
 
while (cnt > 0) {

Modified: head/sys/arm/freescale/imx/imx_i2c.c
==
--- head/sys/arm/freescale/imx/imx_i2c.cTue Apr 26 14:44:49 2016
(r298642)
+++ head/sys/arm/freescale/imx/imx_i2c.cTue Apr 26 14:47:52 2016
(r298643)
@@ -388,7 +388,7 @@ i2c_reset(device_t dev, u_char speed, u_
 */
ipgfreq = imx_ccm_ipg_hz();
busfreq = IICBUS_GET_FREQUENCY(sc->iicbus, speed);
-   div = (ipgfreq + busfreq - 1) / busfreq;
+   div = howmany(ipgfreq, busfreq);
for (i = 0; i < nitems(clkdiv_table); i++) {
if (clkdiv_table[i].divisor >= div)
break;

Modified: head/sys/arm/nvidia/as3722_regulators.c
==
--- head/sys/arm/nvidia/as3722_regulators.c Tue Apr 26 14:44:49 2016
(r298642)
+++ head/sys/arm/nvidia/as3722_regulators.c Tue Apr 26 14:47:52 2016
(r298643)
@@ -48,7 +48,7 @@ __FBSDID("$FreeBSD$");
 
 MALLOC_DEFINE(M_AS3722_REG, "AS3722 regulator", "AS3722 power regulator");
 
-#defineDIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
+#defineDIV_ROUND_UP(n,d) howmany(n, d)
 
 enum as3722_reg_id {
AS3722_REG_ID_SD0,
___
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: r298644 - head/sbin/devd

2016-04-26 Thread Alan Somers
Author: asomers
Date: Tue Apr 26 14:48:58 2016
New Revision: 298644
URL: https://svnweb.freebsd.org/changeset/base/298644

Log:
  Add GEOM::physpath documentation to devd.conf(5)
  
  Suggested by: trasz
  Reviewed by:  trasz
  MFC after:4 weeks
  Sponsored by: Spectra Logic Corp
  Differential Revision:https://reviews.freebsd.org/D6063

Modified:
  head/sbin/devd/devd.conf.5

Modified: head/sbin/devd/devd.conf.5
==
--- head/sbin/devd/devd.conf.5  Tue Apr 26 14:47:52 2016(r298643)
+++ head/sbin/devd/devd.conf.5  Tue Apr 26 14:48:58 2016(r298644)
@@ -433,6 +433,8 @@ device node is created.
 A
 .Xr geom 4
 device node is destroyed.
+.It Li GEOM::physpath
+The physical path of a device has changed.
 .It Li MEDIACHANGE
 Physical media has changed.
 .El
___
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: r298645 - in head/sys/boot: common powerpc/ps3 sparc64/boot1

2016-04-26 Thread Pedro F. Giffuni
Author: pfg
Date: Tue Apr 26 14:51:58 2016
New Revision: 298645
URL: https://svnweb.freebsd.org/changeset/base/298645

Log:
  sys/boot: make use of the howmany() macro when available.
  
  We have a howmany() macro in the  header that is
  convenient to re-use as it makes things easier to read.

Modified:
  head/sys/boot/common/part.c
  head/sys/boot/powerpc/ps3/main.c
  head/sys/boot/sparc64/boot1/boot1.c

Modified: head/sys/boot/common/part.c
==
--- head/sys/boot/common/part.c Tue Apr 26 14:48:58 2016(r298644)
+++ head/sys/boot/common/part.c Tue Apr 26 14:51:58 2016(r298645)
@@ -257,8 +257,9 @@ ptable_gptread(struct ptable *table, voi
table->sectorsize);
if (phdr != NULL) {
/* Read the primary GPT table. */
-   size = MIN(MAXTBLSZ, (phdr->hdr_entries * phdr->hdr_entsz +
-   table->sectorsize - 1) / table->sectorsize);
+   size = MIN(MAXTBLSZ,
+   howmany(phdr->hdr_entries * phdr->hdr_entsz,
+   table->sectorsize));
if (dread(dev, tbl, size, phdr->hdr_lba_table) == 0 &&
gpt_checktbl(phdr, tbl, size * table->sectorsize,
table->sectors - 1) == 0) {
@@ -290,9 +291,9 @@ ptable_gptread(struct ptable *table, voi
hdr.hdr_entsz != phdr->hdr_entsz ||
hdr.hdr_crc_table != phdr->hdr_crc_table) {
/* Read the backup GPT table. */
-   size = MIN(MAXTBLSZ, (phdr->hdr_entries *
-   phdr->hdr_entsz + table->sectorsize - 1) /
-   table->sectorsize);
+   size = MIN(MAXTBLSZ,
+  howmany(phdr->hdr_entries * phdr->hdr_entsz,
+  table->sectorsize));
if (dread(dev, tbl, size, phdr->hdr_lba_table) == 0 &&
gpt_checktbl(phdr, tbl, size * table->sectorsize,
table->sectors - 1) == 0) {

Modified: head/sys/boot/powerpc/ps3/main.c
==
--- head/sys/boot/powerpc/ps3/main.cTue Apr 26 14:48:58 2016
(r298644)
+++ head/sys/boot/powerpc/ps3/main.cTue Apr 26 14:51:58 2016
(r298645)
@@ -174,7 +174,7 @@ delay(int usecs)
uint64_t tb,ttb;
tb = mftb();
 
-   ttb = tb + (usecs * 1000 + ns_per_tick - 1) / ns_per_tick;
+   ttb = tb + howmany(usecs * 1000, ns_per_tick);
while (tb < ttb)
tb = mftb();
 }

Modified: head/sys/boot/sparc64/boot1/boot1.c
==
--- head/sys/boot/sparc64/boot1/boot1.c Tue Apr 26 14:48:58 2016
(r298644)
+++ head/sys/boot/sparc64/boot1/boot1.c Tue Apr 26 14:51:58 2016
(r298645)
@@ -390,7 +390,7 @@ zbread(char *buf, off_t off, size_t byte
 
p = buf;
soff = VDEV_BOOT_OFFSET + off;
-   lb = (soff + bytes + DEV_BSIZE - 1) / DEV_BSIZE;
+   lb = howmany(soff + bytes, DEV_BSIZE);
poff = soff;
while (poff < soff + bytes) {
nb = lb - poff / DEV_BSIZE;
___
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: r298646 - in head/sys/dev: age amr bwn cy fatm fb jme mcd mfi mlx mmc/host ncr patm ral sbni scd sfxge siba sound/usb sym usb usb/controller usb/wlan vt/hw/vga xen/grant_table xen/netback

2016-04-26 Thread Pedro F. Giffuni
Author: pfg
Date: Tue Apr 26 15:03:15 2016
New Revision: 298646
URL: https://svnweb.freebsd.org/changeset/base/298646

Log:
  sys/dev: extend use of the howmany() macro when available.
  
  We have a howmany() macro in the  header that is
  convenient to re-use as it makes things easier to read.

Modified:
  head/sys/dev/age/if_age.c
  head/sys/dev/amr/amr.c
  head/sys/dev/bwn/if_bwn.c
  head/sys/dev/cy/cy.c
  head/sys/dev/fatm/if_fatm.c
  head/sys/dev/fb/vga.c
  head/sys/dev/jme/if_jme.c
  head/sys/dev/mcd/mcd.c
  head/sys/dev/mfi/mfi.c
  head/sys/dev/mlx/mlx.c
  head/sys/dev/mmc/host/dwmmc.c
  head/sys/dev/ncr/ncr.c
  head/sys/dev/patm/if_patm_tx.c
  head/sys/dev/ral/rt2560.c
  head/sys/dev/ral/rt2661.c
  head/sys/dev/sbni/if_sbni.c
  head/sys/dev/scd/scd.c
  head/sys/dev/sfxge/sfxge_tx.c
  head/sys/dev/siba/siba_core.c
  head/sys/dev/sound/usb/uaudio.c
  head/sys/dev/sym/sym_hipd.c
  head/sys/dev/usb/controller/ehci.c
  head/sys/dev/usb/controller/ohci.c
  head/sys/dev/usb/controller/xhci.c
  head/sys/dev/usb/usb_transfer.c
  head/sys/dev/usb/wlan/if_rum.c
  head/sys/dev/usb/wlan/if_ural.c
  head/sys/dev/vt/hw/vga/vt_vga.c
  head/sys/dev/xen/grant_table/grant_table.c
  head/sys/dev/xen/netback/netback.c

Modified: head/sys/dev/age/if_age.c
==
--- head/sys/dev/age/if_age.c   Tue Apr 26 14:51:58 2016(r298645)
+++ head/sys/dev/age/if_age.c   Tue Apr 26 15:03:15 2016(r298646)
@@ -2486,7 +2486,7 @@ age_rxintr(struct age_softc *sc, int rr_
 * I'm not sure whether this check is really needed.
 */
pktlen = AGE_RX_BYTES(le32toh(rxrd->len));
-   if (nsegs != (pktlen + (AGE_RX_BUF_SIZE - 1)) / AGE_RX_BUF_SIZE)
+   if (nsegs != howmany(pktlen, AGE_RX_BUF_SIZE))
break;
 
/* Received a frame. */

Modified: head/sys/dev/amr/amr.c
==
--- head/sys/dev/amr/amr.c  Tue Apr 26 14:51:58 2016(r298645)
+++ head/sys/dev/amr/amr.c  Tue Apr 26 15:03:15 2016(r298646)
@@ -1316,7 +1316,7 @@ amr_bio_command(struct amr_softc *sc, st
 }
 amrd = (struct amrd_softc *)bio->bio_disk->d_drv1;
 driveno = amrd->amrd_drive - sc->amr_drive;
-blkcount = (bio->bio_bcount + AMR_BLKSIZE - 1) / AMR_BLKSIZE;
+blkcount = howmany(bio->bio_bcount, AMR_BLKSIZE);
 
 ac->ac_mailbox.mb_command = cmd;
 if (bio->bio_cmd == BIO_READ || bio->bio_cmd == BIO_WRITE) {

Modified: head/sys/dev/bwn/if_bwn.c
==
--- head/sys/dev/bwn/if_bwn.c   Tue Apr 26 14:51:58 2016(r298645)
+++ head/sys/dev/bwn/if_bwn.c   Tue Apr 26 15:03:15 2016(r298646)
@@ -11166,7 +11166,7 @@ bwn_phy_lp_b2063_switch_channel(struct b
tmp[2] = ((41 * (val[2] - 3000)) /1200) + 27;
tmp[3] = bwn_phy_lp_roundup(132000 * tmp[0], 8451, 16);
 
-   if ((tmp[3] + tmp[2] - 1) / tmp[2] > 60) {
+   if (howmany(tmp[3], tmp[2]) > 60) {
scale = 1;
tmp[4] = ((tmp[3] + tmp[2]) / (tmp[2] << 1)) - 8;
} else {

Modified: head/sys/dev/cy/cy.c
==
--- head/sys/dev/cy/cy.cTue Apr 26 14:51:58 2016(r298645)
+++ head/sys/dev/cy/cy.cTue Apr 26 15:03:15 2016(r298646)
@@ -1347,7 +1347,7 @@ cyparam(struct tty *tp, struct termios *
/*
 * Set receive time-out period, normally to max(one char time, 5 ms).
 */
-   itimeout = (1000 * bits + t->c_ispeed - 1) / t->c_ispeed;
+   itimeout = howmany(1000 * bits, t->c_ispeed);
 #ifdef SOFT_HOTCHAR
 #defineMIN_RTP 1
 #else

Modified: head/sys/dev/fatm/if_fatm.c
==
--- head/sys/dev/fatm/if_fatm.c Tue Apr 26 14:51:58 2016(r298645)
+++ head/sys/dev/fatm/if_fatm.c Tue Apr 26 15:03:15 2016(r298646)
@@ -1085,7 +1085,7 @@ fatm_supply_small_buffers(struct fatm_so
nbufs = min(nbufs, SMALL_POOL_SIZE);
nbufs -= sc->small_cnt;
 
-   nblocks = (nbufs + SMALL_SUPPLY_BLKSIZE - 1) / SMALL_SUPPLY_BLKSIZE;
+   nblocks = howmany(nbufs, SMALL_SUPPLY_BLKSIZE);
for (cnt = 0; cnt < nblocks; cnt++) {
q = GET_QUEUE(sc->s1queue, struct supqueue, sc->s1queue.head);
 
@@ -1174,7 +1174,7 @@ fatm_supply_large_buffers(struct fatm_so
nbufs = min(nbufs, LARGE_POOL_SIZE);
nbufs -= sc->large_cnt;
 
-   nblocks = (nbufs + LARGE_SUPPLY_BLKSIZE - 1) / LARGE_SUPPLY_BLKSIZE;
+   nblocks = howmany(nbufs, LARGE_SUPPLY_BLKSIZE);
 
for (cnt = 0; cnt < nblocks; cnt++) {
q = GET_QUEUE(sc->l1queue, struct supqueue, sc->l1queue.head);

Modified: head/sys/dev/fb/vga.c
===

svn commit: r298648 - head/sys/arm/arm

2016-04-26 Thread Bjoern A. Zeeb
Author: bz
Date: Tue Apr 26 15:34:00 2016
New Revision: 298648
URL: https://svnweb.freebsd.org/changeset/base/298648

Log:
  Mark the unused period argument __unused.
  
  Reviewed by:  andrew
  MFC after:2 weeks
  Sponsored by: DARPA/AFRL

Modified:
  head/sys/arm/arm/generic_timer.c

Modified: head/sys/arm/arm/generic_timer.c
==
--- head/sys/arm/arm/generic_timer.cTue Apr 26 15:33:53 2016
(r298647)
+++ head/sys/arm/arm/generic_timer.cTue Apr 26 15:34:00 2016
(r298648)
@@ -221,7 +221,8 @@ arm_tmr_get_timecount(struct timecounter
 }
 
 static int
-arm_tmr_start(struct eventtimer *et, sbintime_t first, sbintime_t period)
+arm_tmr_start(struct eventtimer *et, sbintime_t first,
+sbintime_t period __unused)
 {
struct arm_tmr_softc *sc;
int counts, ctrl;
___
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: r298647 - head/sys/boot/usb

2016-04-26 Thread Hans Petter Selasky
Author: hselasky
Date: Tue Apr 26 15:33:53 2016
New Revision: 298647
URL: https://svnweb.freebsd.org/changeset/base/298647

Log:
  Add function needed for linking USB test application.

Modified:
  head/sys/boot/usb/bsd_usbloader_test.c

Modified: head/sys/boot/usb/bsd_usbloader_test.c
==
--- head/sys/boot/usb/bsd_usbloader_test.c  Tue Apr 26 15:03:15 2016
(r298646)
+++ head/sys/boot/usb/bsd_usbloader_test.c  Tue Apr 26 15:33:53 2016
(r298647)
@@ -57,6 +57,12 @@ DELAY(unsigned int delay)
usleep(delay);
 }
 
+void
+delay(unsigned int delay)
+{
+   usleep(delay);
+}
+
 int
 pause(const char *what, int timeout)
 {
___
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: r298649 - in head/sys: cam/ata cam/scsi compat/ndis fs/msdosfs geom/part geom/raid geom/uzip kern kgssapi/krb5 net netgraph

2016-04-26 Thread Pedro F. Giffuni
Author: pfg
Date: Tue Apr 26 15:38:17 2016
New Revision: 298649
URL: https://svnweb.freebsd.org/changeset/base/298649

Log:
  sys: extend use of the howmany() macro when available.
  
  We have a howmany() macro in the  header that is
  convenient to re-use as it makes things easier to read.

Modified:
  head/sys/cam/ata/ata_da.c
  head/sys/cam/scsi/scsi_da.c
  head/sys/compat/ndis/subr_ntoskrnl.c
  head/sys/fs/msdosfs/msdosfs_vfsops.c
  head/sys/geom/part/g_part_gpt.c
  head/sys/geom/part/g_part_ldm.c
  head/sys/geom/raid/md_ddf.c
  head/sys/geom/raid/md_intel.c
  head/sys/geom/uzip/g_uzip.c
  head/sys/kern/kern_clock.c
  head/sys/kern/kern_synch.c
  head/sys/kern/kern_time.c
  head/sys/kern/kern_timeout.c
  head/sys/kern/subr_pctrie.c
  head/sys/kern/sys_pipe.c
  head/sys/kern/sysv_msg.c
  head/sys/kern/uipc_shm.c
  head/sys/kern/vfs_subr.c
  head/sys/kgssapi/krb5/kcrypto.c
  head/sys/net/if_arcsubr.c
  head/sys/netgraph/ng_pptpgre.c

Modified: head/sys/cam/ata/ata_da.c
==
--- head/sys/cam/ata/ata_da.c   Tue Apr 26 15:34:00 2016(r298648)
+++ head/sys/cam/ata/ata_da.c   Tue Apr 26 15:38:17 2016(r298649)
@@ -1699,12 +1699,10 @@ ada_dsmtrim(struct ada_softc *softc, str
CAM_DIR_OUT,
0,
req->data,
-   ((ranges + ATA_DSM_BLK_RANGES - 1) /
-   ATA_DSM_BLK_RANGES) * ATA_DSM_BLK_SIZE,
+   howmany(ranges, ATA_DSM_BLK_RANGES) * ATA_DSM_BLK_SIZE,
ada_default_timeout * 1000);
ata_48bit_cmd(ataio, ATA_DATA_SET_MANAGEMENT,
-   ATA_DSM_TRIM, 0, (ranges + ATA_DSM_BLK_RANGES -
-   1) / ATA_DSM_BLK_RANGES);
+   ATA_DSM_TRIM, 0, howmany(ranges, ATA_DSM_BLK_RANGES));
 }
 
 static void
@@ -1720,13 +1718,12 @@ ada_ncq_dsmtrim(struct ada_softc *softc,
CAM_DIR_OUT,
0,
req->data,
-   ((ranges + ATA_DSM_BLK_RANGES - 1) /
-   ATA_DSM_BLK_RANGES) * ATA_DSM_BLK_SIZE,
+   howmany(ranges, ATA_DSM_BLK_RANGES) * ATA_DSM_BLK_SIZE,
ada_default_timeout * 1000);
ata_ncq_cmd(ataio,
ATA_SEND_FPDMA_QUEUED,
0,
-   (ranges + ATA_DSM_BLK_RANGES - 1) / ATA_DSM_BLK_RANGES);
+   howmany(ranges, ATA_DSM_BLK_RANGES));
ataio->cmd.sector_count_exp = ATA_SFPDMA_DSM;
ataio->ata_flags |= ATA_FLAG_AUX;
ataio->aux = 1;

Modified: head/sys/cam/scsi/scsi_da.c
==
--- head/sys/cam/scsi/scsi_da.c Tue Apr 26 15:34:00 2016(r298648)
+++ head/sys/cam/scsi/scsi_da.c Tue Apr 26 15:38:17 2016(r298649)
@@ -2868,7 +2868,7 @@ da_delete_trim(struct cam_periph *periph
}
} while (1);
 
-   block_count = (ranges + ATA_DSM_BLK_RANGES - 1) / ATA_DSM_BLK_RANGES;
+   block_count = howmany(ranges, ATA_DSM_BLK_RANGES);
scsi_ata_trim(&ccb->csio,
  /*retries*/da_retry_count,
  /*cbfcnp*/dadone,

Modified: head/sys/compat/ndis/subr_ntoskrnl.c
==
--- head/sys/compat/ndis/subr_ntoskrnl.cTue Apr 26 15:34:00 2016
(r298648)
+++ head/sys/compat/ndis/subr_ntoskrnl.cTue Apr 26 15:38:17 2016
(r298649)
@@ -4207,7 +4207,7 @@ KeQueryInterruptTime(void)
 
ticks = tvtohz(&tv);
 
-   return ticks * ((1000 + hz - 1) / hz);
+   return ticks * howmany(1000, hz);
 }
 
 static struct thread *

Modified: head/sys/fs/msdosfs/msdosfs_vfsops.c
==
--- head/sys/fs/msdosfs/msdosfs_vfsops.cTue Apr 26 15:34:00 2016
(r298648)
+++ head/sys/fs/msdosfs/msdosfs_vfsops.cTue Apr 26 15:38:17 2016
(r298649)
@@ -606,9 +606,8 @@ mountmsdosfs(struct vnode *devvp, struct
} else {
pmp->pm_rootdirblk = pmp->pm_fatblk +
(pmp->pm_FATs * pmp->pm_FATsecs);
-   pmp->pm_rootdirsize = (pmp->pm_RootDirEnts * sizeof(struct 
direntry)
-  + DEV_BSIZE - 1)
-   / DEV_BSIZE; /* in blocks */
+   pmp->pm_rootdirsize = howmany(pmp->pm_RootDirEnts *
+   sizeof(struct direntry), DEV_BSIZE); /* in blocks */
pmp->pm_firstcluster = pmp->pm_rootdirblk + pmp->pm_rootdirsize;
}
 

Modified: head/sys/geom/part/g_part_gpt.c
==
--- head/sys/geom/part/g_part_gpt.c Tue Apr 26 15:34:00 2016
(r298648)
+++ head/sys/geom/part/g_part_gpt.c Tue Apr 26 15:38:17 2016
(r298649)
@@ -472,8 +472,7 @@ gpt_read_hdr(struct g_part_gpt_table *ta
hdr->hdr_lba_table <= hdr->hdr_lba_end)
goto fail;
lba = hdr->hdr_lba_table +
-   (h

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

2016-04-26 Thread Hans Petter Selasky
Author: hselasky
Date: Tue Apr 26 15:41:31 2016
New Revision: 298650
URL: https://svnweb.freebsd.org/changeset/base/298650

Log:
  Build fix. Add howmany() and nitems() macros to bootloader kernel shim.

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

Modified: head/sys/boot/kshim/bsd_kernel.h
==
--- head/sys/boot/kshim/bsd_kernel.hTue Apr 26 15:38:17 2016
(r298649)
+++ head/sys/boot/kshim/bsd_kernel.hTue Apr 26 15:41:31 2016
(r298650)
@@ -35,6 +35,8 @@
 #include 
 #include 
 
+#definehowmany(x, y)   (((x)+((y)-1))/(y))
+#definenitems(x)   (sizeof((x)) / sizeof((x)[0]))
 #defineisalpha(x) (((x) >= 'a' && (x) <= 'z') || ((x) >= 'A' && (x) <= 
'Z'))
 #defineisdigit(x) ((x) >= '0' && (x) <= '9')
 #definepanic(...) do { printf("USB PANIC: " __VA_ARGS__); while (1) ; 
} while (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"


Re: svn commit: r298650 - head/sys/boot/kshim

2016-04-26 Thread Pedro Giffuni

Thank you, and sorry for breakage!

Pedro.

On 04/26/16 10:41, Hans Petter Selasky wrote:

Author: hselasky
Date: Tue Apr 26 15:41:31 2016
New Revision: 298650
URL: https://svnweb.freebsd.org/changeset/base/298650

Log:
  Build fix. Add howmany() and nitems() macros to bootloader kernel shim.

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

Modified: head/sys/boot/kshim/bsd_kernel.h
==
--- head/sys/boot/kshim/bsd_kernel.hTue Apr 26 15:38:17 2016
(r298649)
+++ head/sys/boot/kshim/bsd_kernel.hTue Apr 26 15:41:31 2016
(r298650)
@@ -35,6 +35,8 @@
 #include 
 #include 

+#definehowmany(x, y)   (((x)+((y)-1))/(y))
+#definenitems(x)   (sizeof((x)) / sizeof((x)[0]))
 #defineisalpha(x) (((x) >= 'a' && (x) <= 'z') || ((x) >= 'A' && (x) <= 
'Z'))
 #defineisdigit(x) ((x) >= '0' && (x) <= '9')
 #definepanic(...) do { printf("USB PANIC: " __VA_ARGS__); while (1) ; 
} while (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"


Re: svn commit: r298650 - head/sys/boot/kshim

2016-04-26 Thread Hans Petter Selasky

On 04/26/16 17:44, Pedro Giffuni wrote:

Thank you, and sorry for breakage!



No problem. Fix is trivial.

--HPS

___
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: r298651 - head/sys/dev/spibus

2016-04-26 Thread Ruslan Bukin
Author: br
Date: Tue Apr 26 16:02:13 2016
New Revision: 298651
URL: https://svnweb.freebsd.org/changeset/base/298651

Log:
  Fix the parameter type according to method declaration.
  This fixes compilation on riscv with GCC 5.2.0

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

Modified: head/sys/dev/spibus/spibus.c
==
--- head/sys/dev/spibus/spibus.cTue Apr 26 15:41:31 2016
(r298650)
+++ head/sys/dev/spibus/spibus.cTue Apr 26 16:02:13 2016
(r298651)
@@ -139,7 +139,7 @@ spibus_child_pnpinfo_str(device_t bus, d
 }
 
 static int
-spibus_read_ivar(device_t bus, device_t child, int which, u_int *result)
+spibus_read_ivar(device_t bus, device_t child, int which, uintptr_t *result)
 {
struct spibus_ivar *devi = SPIBUS_IVAR(child);
 
___
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: r298652 - head/sys/mips/mips

2016-04-26 Thread Adrian Chadd
Author: adrian
Date: Tue Apr 26 16:40:04 2016
New Revision: 298652
URL: https://svnweb.freebsd.org/changeset/base/298652

Log:
  [mips] correctly represent memory region allocations >> 2^^31
  
  Without this, it'd get promoted incorrectly and fail allocation.
  
  Submitted by: Mori Hiroki 
  Reviewed by:  imp

Modified:
  head/sys/mips/mips/nexus.c

Modified: head/sys/mips/mips/nexus.c
==
--- head/sys/mips/mips/nexus.c  Tue Apr 26 16:02:13 2016(r298651)
+++ head/sys/mips/mips/nexus.c  Tue Apr 26 16:40:04 2016(r298652)
@@ -566,8 +566,8 @@ nexus_hinted_child(device_t bus, const c
__func__, device_get_nameunit(child),
(void *)(intptr_t)maddr, msize);
 
-   result = bus_set_resource(child, SYS_RES_MEMORY, 0, maddr, 
-   msize);
+   result = bus_set_resource(child, SYS_RES_MEMORY, 0,
+   (u_long) maddr, msize);
if (result != 0) {
device_printf(bus, 
"warning: bus_set_resource() failed\n");
___
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"


Re: svn commit: r298585 - in head: sys/kern usr.sbin/jail

2016-04-26 Thread Konstantin Belousov
On Mon, Apr 25, 2016 at 05:06:50PM +, Jamie Gritton wrote:
> Author: jamie
> Date: Mon Apr 25 17:06:50 2016
> New Revision: 298585
> URL: https://svnweb.freebsd.org/changeset/base/298585
> 
> Log:
>   Encapsulate SYSV IPC objects in jails.  Define per-module parameters
>   sysvmsg, sysvsem, and sysvshm, with the following bahavior:

I got the following:

lock order reversal: (sleepable after non-sleepable)
 1st 0xf80005635678 process lock (process lock) @ 
/usr/home/kostik/work/build/bsd/DEV/src/sys/kern/kern_exit.c:496
 2nd 0x80aebae8 allprison (allprison) @ 
/usr/home/kostik/work/build/bsd/DEV/src/sys/kern/kern_jail.c:2642
stack backtrace:
#0 0x803cf0c0 at witness_debugger+0x70
#1 0x803cefb4 at witness_checkorder+0xe54
#2 0x80378466 at _sx_slock+0x76
#3 0x8033dcd1 at prison_deref+0x101
#4 0x80331a68 at exit1+0xa08
#5 0x8033105d at sys_sys_exit+0xd
#6 0x805c5c84 at ia32_syscall+0x324
#7 0x80586f35 at Xint0x80_syscall+0x95

lock order reversal: (sleepable after non-sleepable)
 1st 0xf80005635678 process lock (process lock) @ 
/usr/home/kostik/work/build/bsd/DEV/src/sys/kern/kern_exit.c:496
 2nd 0x8114d700 sysvshmsx (sysvshmsx) @ 
/usr/home/kostik/work/build/bsd/DEV/src/sys/modules/sysvipc/sysvshm/../../../kern/sysv_shm.c:1199
stack backtrace:
#0 0x803cf0c0 at witness_debugger+0x70
#1 0x803cefb4 at witness_checkorder+0xe54
#2 0x80378755 at _sx_xlock+0x75
#3 0x8114c5fa at shm_prison_remove+0x2a
#4 0x803598d1 at osd_call+0xb1
#5 0x8033dd04 at prison_deref+0x134
#6 0x80331a68 at exit1+0xa08
#7 0x8033105d at sys_sys_exit+0xd
#8 0x805c5c84 at ia32_syscall+0x324
#9 0x80586f35 at Xint0x80_syscall+0x95

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


Re: svn commit: r298585 - in head: sys/kern usr.sbin/jail

2016-04-26 Thread Ulrich Spörlein
2016-04-25 10:06 GMT-07:00 Jamie Gritton :
> Author: jamie
> Date: Mon Apr 25 17:06:50 2016
> New Revision: 298585
> URL: https://svnweb.freebsd.org/changeset/base/298585
>
> Log:
>   Encapsulate SYSV IPC objects in jails.  Define per-module parameters
>   sysvmsg, sysvsem, and sysvshm, with the following bahavior:
>
>   inherit: allow full access to the IPC primitives.  This is the same as
>   the current setup with allow.sysvipc is on.  Jails and the base system
>   can see (and moduly) each other's objects, which is generally considered
>   a bad thing (though may be useful in some circumstances).
>
>   disable: all no access, same as the current setup with allow.sysvipc off.
>
>   new: A jail may see use the IPC objects that it has created.  It also
>   gets its own IPC key namespace, so different jails may have their own
>   objects using the same key value.  The parent jail (or base system) can
>   see the jail's IPC objects, but not its keys.
>
>   PR:   48471
>   Submitted by: based on work by kikucha...@gmail.com
>   MFC after:5 days
>
> Modified:
>   head/sys/kern/sysv_msg.c
>   head/sys/kern/sysv_sem.c
>   head/sys/kern/sysv_shm.c
>   head/usr.sbin/jail/jail.8

Looks like some bad sbuf_deletes, see the recent Coverity report (are
you folks getting these emails?)

*** CID 1354974:  Memory - corruptions  (BAD_FREE)
/sys/kern/sysv_shm.c: 1043 in sysctl_shmsegs()
1037shmseg->u.shm_perm.key = IPC_PRIVATE;
1038}
1039
1040sbuf_bcat(&sb, shmseg, sizeof(*shmseg));
1041}
1042error = sbuf_finish(&sb);
>>> CID 1354974:  Memory - corruptions  (BAD_FREE)
>>> "sbuf_delete" frees address of "sb".
1043sbuf_delete(&sb);
1044
1045 done:
1046SYSVSHM_UNLOCK();
1047return (error);
1048 }

** CID 1354975:  Memory - corruptions  (BAD_FREE)

and one in sysv_msg.c
___
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: r298654 - head

2016-04-26 Thread Bryan Drewery
Author: bdrewery
Date: Tue Apr 26 18:08:51 2016
New Revision: 298654
URL: https://svnweb.freebsd.org/changeset/base/298654

Log:
  WITH_META_MODE: Allow buildkernel to create .meta files with curdir==objdir.
  
  Without this the incremental build was broken since .depend.* are not
  generated with .MAKE.MODE=meta and .meta files were not created to
  track dependencies.  Typically meta mode does not create .meta files
  when building with curdir==objdir but the kernel build is special.
  
  Reported by:  Nikolai Lifanov 
  Sponsored by: EMC / Isilon Storage Division

Modified:
  head/Makefile.inc1

Modified: head/Makefile.inc1
==
--- head/Makefile.inc1  Tue Apr 26 17:39:54 2016(r298653)
+++ head/Makefile.inc1  Tue Apr 26 18:08:51 2016(r298654)
@@ -531,6 +531,11 @@ IMAKE_MTREE=   MTREE_CMD="mtree ${MTREEFLA
 # kernel stage
 KMAKEENV=  ${WMAKEENV}
 KMAKE= ${KMAKEENV} ${MAKE} ${.MAKEFLAGS} ${KERNEL_FLAGS} 
KERNEL=${INSTKERNNAME}
+.if ${MK_META_MODE} == "yes"
+# meta mode normally is disallowed when building from curdir==objdir, but we
+# want to allow it for the kernel build.
+KMAKE+=.MAKE.MODE="${.MAKE.MODE} curdirOk=yes"
+.endif
 
 #
 # buildworld
___
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: r298655 - head/sys/kgssapi

2016-04-26 Thread Conrad E. Meyer
Author: cem
Date: Tue Apr 26 18:11:45 2016
New Revision: 298655
URL: https://svnweb.freebsd.org/changeset/base/298655

Log:
  kgssapi: Don't leak memory in error cases
  
  Reported by:  Coverity
  CIDs: 1007046, 1007047, 1007048
  Sponsored by: EMC / Isilon Storage Division

Modified:
  head/sys/kgssapi/gssd_prot.c

Modified: head/sys/kgssapi/gssd_prot.c
==
--- head/sys/kgssapi/gssd_prot.cTue Apr 26 18:08:51 2016
(r298654)
+++ head/sys/kgssapi/gssd_prot.cTue Apr 26 18:11:45 2016
(r298655)
@@ -101,8 +101,10 @@ xdr_gss_OID(XDR *xdrs, gss_OID *oidp)
} else {
oid = mem_alloc(sizeof(gss_OID_desc));
memset(oid, 0, sizeof(*oid));
-   if (!xdr_gss_OID_desc(xdrs, oid))
+   if (!xdr_gss_OID_desc(xdrs, oid)) {
+   mem_free(oid, sizeof(gss_OID_desc));
return (FALSE);
+   }
*oidp = oid;
}
break;
@@ -164,8 +166,10 @@ xdr_gss_OID_set(XDR *xdrs, gss_OID_set *
} else {
set = mem_alloc(sizeof(gss_OID_set_desc));
memset(set, 0, sizeof(*set));
-   if (!xdr_gss_OID_set_desc(xdrs, set))
+   if (!xdr_gss_OID_set_desc(xdrs, set)) {
+   mem_free(set, sizeof(gss_OID_set_desc));
return (FALSE);
+   }
*setp = set;
}
break;
@@ -224,8 +228,10 @@ xdr_gss_channel_bindings_t(XDR *xdrs, gs
|| !xdr_gss_buffer_desc(xdrs,
&ch->acceptor_address)
|| !xdr_gss_buffer_desc(xdrs,
-   &ch->application_data))
+   &ch->application_data)) {
+   mem_free(ch, sizeof(*ch));
return (FALSE);
+   }
*chp = ch;
}
break;
___
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: r298656 - head/sys/kern

2016-04-26 Thread Jamie Gritton
Author: jamie
Date: Tue Apr 26 18:17:44 2016
New Revision: 298656
URL: https://svnweb.freebsd.org/changeset/base/298656

Log:
  Redo the changes to the SYSV IPC sysctl functions from r298585, so they
  don't (mis)use sbufs.
  
  PR:   48471

Modified:
  head/sys/kern/sysv_msg.c
  head/sys/kern/sysv_sem.c
  head/sys/kern/sysv_shm.c

Modified: head/sys/kern/sysv_msg.c
==
--- head/sys/kern/sysv_msg.cTue Apr 26 18:11:45 2016(r298655)
+++ head/sys/kern/sysv_msg.cTue Apr 26 18:17:44 2016(r298656)
@@ -65,7 +65,6 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -1423,38 +1422,28 @@ sys_msgrcv(td, uap)
 static int
 sysctl_msqids(SYSCTL_HANDLER_ARGS)
 {
-   struct sbuf sb;
-   struct msqid_kernel tmp, empty;
-   struct msqid_kernel *msqkptr;
-   struct prison *rpr;
+   struct msqid_kernel tmsqk;
+   struct prison *pr, *rpr;
int error, i;
 
-   error = sysctl_wire_old_buffer(req, 0);
-   if (error != 0)
-   goto done;
+   pr = req->td->td_ucred->cr_prison;
rpr = msg_find_prison(req->td->td_ucred);
-   sbuf_new_for_sysctl(&sb, NULL, sizeof(struct msqid_kernel) *
-   msginfo.msgmni, req);
-
-   bzero(&empty, sizeof(empty));
+   error = 0;
for (i = 0; i < msginfo.msgmni; i++) {
-   msqkptr = &msqids[i];
-   if (msqkptr->u.msg_qbytes == 0 || rpr == NULL ||
-   msq_prison_cansee(rpr, msqkptr) != 0) {
-   msqkptr = ∅
-   } else if (req->td->td_ucred->cr_prison !=
-   msqkptr->cred->cr_prison) {
-   bcopy(msqkptr, &tmp, sizeof(tmp));
-   msqkptr = &tmp;
-   msqkptr->u.msg_perm.key = IPC_PRIVATE;
+   mtx_lock(&msq_mtx);
+   if (msqids[i].u.msg_qbytes == 0 || rpr == NULL ||
+   msq_prison_cansee(rpr, &msqids[i]) != 0)
+   bzero(&tmsqk, sizeof(tmsqk));
+   else {
+   tmsqk = msqids[i];
+   if (tmsqk.cred->cr_prison != pr)
+   tmsqk.u.msg_perm.key = IPC_PRIVATE;
}
-
-   sbuf_bcat(&sb, msqkptr, sizeof(*msqkptr));
+   mtx_unlock(&msq_mtx);
+   error = SYSCTL_OUT(req, &tmsqk, sizeof(tmsqk));
+   if (error != 0)
+   break;
}
-   error = sbuf_finish(&sb);
-   sbuf_delete(&sb);
-
-done:
return (error);
 }
 
@@ -1470,7 +1459,8 @@ SYSCTL_INT(_kern_ipc, OID_AUTO, msgssz, 
 "Size of a message segment");
 SYSCTL_INT(_kern_ipc, OID_AUTO, msgseg, CTLFLAG_RDTUN, &msginfo.msgseg, 0,
 "Number of message segments");
-SYSCTL_PROC(_kern_ipc, OID_AUTO, msqids, CTLTYPE_OPAQUE | CTLFLAG_RD,
+SYSCTL_PROC(_kern_ipc, OID_AUTO, msqids,
+CTLTYPE_OPAQUE | CTLFLAG_RD | CTLFLAG_MPSAFE,
 NULL, 0, sysctl_msqids, "", "Message queue IDs");
 
 static int

Modified: head/sys/kern/sysv_sem.c
==
--- head/sys/kern/sysv_sem.cTue Apr 26 18:11:45 2016(r298655)
+++ head/sys/kern/sysv_sem.cTue Apr 26 18:17:44 2016(r298656)
@@ -52,7 +52,6 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -220,7 +219,8 @@ SYSCTL_INT(_kern_ipc, OID_AUTO, semvmx, 
 "Semaphore maximum value");
 SYSCTL_INT(_kern_ipc, OID_AUTO, semaem, CTLFLAG_RWTUN, &seminfo.semaem, 0,
 "Adjust on exit max value");
-SYSCTL_PROC(_kern_ipc, OID_AUTO, sema, CTLTYPE_OPAQUE | CTLFLAG_RD,
+SYSCTL_PROC(_kern_ipc, OID_AUTO, sema,
+CTLTYPE_OPAQUE | CTLFLAG_RD | CTLFLAG_MPSAFE,
 NULL, 0, sysctl_sema, "", "Semaphore id pool");
 
 static struct syscall_helper_data sem_syscalls[] = {
@@ -1465,38 +1465,28 @@ semexit_myhook(void *arg, struct proc *p
 static int
 sysctl_sema(SYSCTL_HANDLER_ARGS)
 {
-   struct prison *rpr;
-   struct sbuf sb;
-   struct semid_kernel tmp, empty;
-   struct semid_kernel *semakptr;
+   struct prison *pr, *rpr;
+   struct semid_kernel tsemak;
int error, i;
 
-   error = sysctl_wire_old_buffer(req, 0);
-   if (error != 0)
-   goto done;
+   pr = req->td->td_ucred->cr_prison;
rpr = sem_find_prison(req->td->td_ucred);
-   sbuf_new_for_sysctl(&sb, NULL, sizeof(struct semid_kernel) *
-   seminfo.semmni, req);
-
-   bzero(&empty, sizeof(empty));
+   error = 0;
for (i = 0; i < seminfo.semmni; i++) {
-   semakptr = &sema[i];
-   if ((semakptr->u.sem_perm.mode & SEM_ALLOC) == 0 ||
-   rpr == NULL || sem_prison_cansee(rpr, semakptr) != 0) {
-   semakptr = ∅
-   } else if (req->td->td_ucred->cr_prison !=
- 

svn commit: r298657 - head/sys/dev/sound/pci

2016-04-26 Thread Conrad E. Meyer
Author: cem
Date: Tue Apr 26 18:20:41 2016
New Revision: 298657
URL: https://svnweb.freebsd.org/changeset/base/298657

Log:
  emu10kx: Don't iterate beyond array bounds
  
  Reported by:  Coverity
  CID:  1354978
  Sponsored by: EMC / Isilon Storage Division

Modified:
  head/sys/dev/sound/pci/emu10kx.c

Modified: head/sys/dev/sound/pci/emu10kx.c
==
--- head/sys/dev/sound/pci/emu10kx.cTue Apr 26 18:17:44 2016
(r298656)
+++ head/sys/dev/sound/pci/emu10kx.cTue Apr 26 18:20:41 2016
(r298657)
@@ -587,7 +587,7 @@ emu_getcard(device_t dev)
}
}
 
-   for (i = 0; i < nitems(emu_cards); i++) {
+   for (i = 0; i < nitems(emu_bad_cards); i++) {
if (device == emu_bad_cards[i].device) {
if (subdevice == emu_bad_cards[i].subdevice) {
thiscard = 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"


Re: svn commit: r298585 - in head: sys/kern usr.sbin/jail

2016-04-26 Thread NGie Cooper

> On Apr 26, 2016, at 11:03, Ulrich Spörlein  wrote:
> 
> 2016-04-25 10:06 GMT-07:00 Jamie Gritton :
>> Author: jamie
>> Date: Mon Apr 25 17:06:50 2016
>> New Revision: 298585
>> URL: https://svnweb.freebsd.org/changeset/base/298585
>> 
>> Log:
>>  Encapsulate SYSV IPC objects in jails.  Define per-module parameters
>>  sysvmsg, sysvsem, and sysvshm, with the following bahavior:
>> 
>>  inherit: allow full access to the IPC primitives.  This is the same as
>>  the current setup with allow.sysvipc is on.  Jails and the base system
>>  can see (and moduly) each other's objects, which is generally considered
>>  a bad thing (though may be useful in some circumstances).
>> 
>>  disable: all no access, same as the current setup with allow.sysvipc off.
>> 
>>  new: A jail may see use the IPC objects that it has created.  It also
>>  gets its own IPC key namespace, so different jails may have their own
>>  objects using the same key value.  The parent jail (or base system) can
>>  see the jail's IPC objects, but not its keys.
>> 
>>  PR:   48471
>>  Submitted by: based on work by kikucha...@gmail.com
>>  MFC after:5 days
>> 
>> Modified:
>>  head/sys/kern/sysv_msg.c
>>  head/sys/kern/sysv_sem.c
>>  head/sys/kern/sysv_shm.c
>>  head/usr.sbin/jail/jail.8
> 
> Looks like some bad sbuf_deletes, see the recent Coverity report (are
> you folks getting these emails?)
> 
> *** CID 1354974:  Memory - corruptions  (BAD_FREE)
> /sys/kern/sysv_shm.c: 1043 in sysctl_shmsegs()
> 1037shmseg->u.shm_perm.key = IPC_PRIVATE;
> 1038}
> 1039
> 1040sbuf_bcat(&sb, shmseg, sizeof(*shmseg));
> 1041}
> 1042error = sbuf_finish(&sb);
CID 1354974:  Memory - corruptions  (BAD_FREE)
"sbuf_delete" frees address of "sb".
> 1043sbuf_delete(&sb);
> 1044
> 1045 done:
> 1046SYSVSHM_UNLOCK();
> 1047return (error);
> 1048 }
> 
> ** CID 1354975:  Memory - corruptions  (BAD_FREE)
> 
> and one in sysv_msg.c

cem and I hashed this out recently with ntb on phrabricator. The issue is that 
our sbuf implementation is "clever" and has different code paths for stack vs 
heap allocation -- this pattern is ok per stack allocation, but not heap 
allocation... Coverity only knows about how to instrument the latter.

Thanks,
-Ngie
___
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"

Re: svn commit: r298657 - head/sys/dev/sound/pci

2016-04-26 Thread Pedro Giffuni



On 04/26/16 13:20, Conrad E. Meyer wrote:

Author: cem
Date: Tue Apr 26 18:20:41 2016
New Revision: 298657
URL: https://svnweb.freebsd.org/changeset/base/298657

Log:
  emu10kx: Don't iterate beyond array bounds

  Reported by:  Coverity
  CID:  1354978
  Sponsored by: EMC / Isilon Storage Division

Modified:
  head/sys/dev/sound/pci/emu10kx.c

Modified: head/sys/dev/sound/pci/emu10kx.c
==
--- head/sys/dev/sound/pci/emu10kx.cTue Apr 26 18:17:44 2016
(r298656)
+++ head/sys/dev/sound/pci/emu10kx.cTue Apr 26 18:20:41 2016
(r298657)
@@ -587,7 +587,7 @@ emu_getcard(device_t dev)
}
}

-   for (i = 0; i < nitems(emu_cards); i++) {
+   for (i = 0; i < nitems(emu_bad_cards); i++) {
if (device == emu_bad_cards[i].device) {
if (subdevice == emu_bad_cards[i].subdevice) {
thiscard = 0;



Hmm sadly interesting.
This was not a script or an old bug; it was pilot error.

Pointyhat:  pfg

Thanks!

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


Re: svn commit: r298585 - in head: sys/kern usr.sbin/jail

2016-04-26 Thread Conrad Meyer
Right.  False positive.  Coverity doesn't grok sbuf memory management fully.

On Tue, Apr 26, 2016 at 11:22 AM, NGie Cooper  wrote:

>
> > On Apr 26, 2016, at 11:03, Ulrich Spörlein  wrote:
> >
> > 2016-04-25 10:06 GMT-07:00 Jamie Gritton :
> >> Author: jamie
> >> Date: Mon Apr 25 17:06:50 2016
> >> New Revision: 298585
> >> URL: https://svnweb.freebsd.org/changeset/base/298585
> >>
> >> Log:
> >>  Encapsulate SYSV IPC objects in jails.  Define per-module parameters
> >>  sysvmsg, sysvsem, and sysvshm, with the following bahavior:
> >>
> >>  inherit: allow full access to the IPC primitives.  This is the same as
> >>  the current setup with allow.sysvipc is on.  Jails and the base system
> >>  can see (and moduly) each other's objects, which is generally
> considered
> >>  a bad thing (though may be useful in some circumstances).
> >>
> >>  disable: all no access, same as the current setup with allow.sysvipc
> off.
> >>
> >>  new: A jail may see use the IPC objects that it has created.  It also
> >>  gets its own IPC key namespace, so different jails may have their own
> >>  objects using the same key value.  The parent jail (or base system) can
> >>  see the jail's IPC objects, but not its keys.
> >>
> >>  PR:   48471
> >>  Submitted by: based on work by kikucha...@gmail.com
> >>  MFC after:5 days
> >>
> >> Modified:
> >>  head/sys/kern/sysv_msg.c
> >>  head/sys/kern/sysv_sem.c
> >>  head/sys/kern/sysv_shm.c
> >>  head/usr.sbin/jail/jail.8
> >
> > Looks like some bad sbuf_deletes, see the recent Coverity report (are
> > you folks getting these emails?)
> >
> > *** CID 1354974:  Memory - corruptions  (BAD_FREE)
> > /sys/kern/sysv_shm.c: 1043 in sysctl_shmsegs()
> > 1037shmseg->u.shm_perm.key = IPC_PRIVATE;
> > 1038}
> > 1039
> > 1040sbuf_bcat(&sb, shmseg, sizeof(*shmseg));
> > 1041}
> > 1042error = sbuf_finish(&sb);
> CID 1354974:  Memory - corruptions  (BAD_FREE)
> "sbuf_delete" frees address of "sb".
> > 1043sbuf_delete(&sb);
> > 1044
> > 1045 done:
> > 1046SYSVSHM_UNLOCK();
> > 1047return (error);
> > 1048 }
> >
> > ** CID 1354975:  Memory - corruptions  (BAD_FREE)
> >
> > and one in sysv_msg.c
>
> cem and I hashed this out recently with ntb on phrabricator. The issue is
> that our sbuf implementation is "clever" and has different code paths for
> stack vs heap allocation -- this pattern is ok per stack allocation, but
> not heap allocation... Coverity only knows about how to instrument the
> latter.
>
> Thanks,
> -Ngie
>
___
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"

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

2016-04-26 Thread Conrad Meyer
The sbuf use here was fine before.

Best,
Conrad

On Tue, Apr 26, 2016 at 11:17 AM, Jamie Gritton  wrote:

> Author: jamie
> Date: Tue Apr 26 18:17:44 2016
> New Revision: 298656
> URL: https://svnweb.freebsd.org/changeset/base/298656
>
> Log:
>   Redo the changes to the SYSV IPC sysctl functions from r298585, so they
>   don't (mis)use sbufs.
>
>   PR:   48471
>
> Modified:
>   head/sys/kern/sysv_msg.c
>   head/sys/kern/sysv_sem.c
>   head/sys/kern/sysv_shm.c
>
> Modified: head/sys/kern/sysv_msg.c
>
> ==
> --- head/sys/kern/sysv_msg.cTue Apr 26 18:11:45 2016(r298655)
> +++ head/sys/kern/sysv_msg.cTue Apr 26 18:17:44 2016(r298656)
> @@ -65,7 +65,6 @@ __FBSDID("$FreeBSD$");
>  #include 
>  #include 
>  #include 
> -#include 
>  #include 
>  #include 
>  #include 
> @@ -1423,38 +1422,28 @@ sys_msgrcv(td, uap)
>  static int
>  sysctl_msqids(SYSCTL_HANDLER_ARGS)
>  {
> -   struct sbuf sb;
> -   struct msqid_kernel tmp, empty;
> -   struct msqid_kernel *msqkptr;
> -   struct prison *rpr;
> +   struct msqid_kernel tmsqk;
> +   struct prison *pr, *rpr;
> int error, i;
>
> -   error = sysctl_wire_old_buffer(req, 0);
> -   if (error != 0)
> -   goto done;
> +   pr = req->td->td_ucred->cr_prison;
> rpr = msg_find_prison(req->td->td_ucred);
> -   sbuf_new_for_sysctl(&sb, NULL, sizeof(struct msqid_kernel) *
> -   msginfo.msgmni, req);
> -
> -   bzero(&empty, sizeof(empty));
> +   error = 0;
> for (i = 0; i < msginfo.msgmni; i++) {
> -   msqkptr = &msqids[i];
> -   if (msqkptr->u.msg_qbytes == 0 || rpr == NULL ||
> -   msq_prison_cansee(rpr, msqkptr) != 0) {
> -   msqkptr = ∅
> -   } else if (req->td->td_ucred->cr_prison !=
> -   msqkptr->cred->cr_prison) {
> -   bcopy(msqkptr, &tmp, sizeof(tmp));
> -   msqkptr = &tmp;
> -   msqkptr->u.msg_perm.key = IPC_PRIVATE;
> +   mtx_lock(&msq_mtx);
> +   if (msqids[i].u.msg_qbytes == 0 || rpr == NULL ||
> +   msq_prison_cansee(rpr, &msqids[i]) != 0)
> +   bzero(&tmsqk, sizeof(tmsqk));
> +   else {
> +   tmsqk = msqids[i];
> +   if (tmsqk.cred->cr_prison != pr)
> +   tmsqk.u.msg_perm.key = IPC_PRIVATE;
> }
> -
> -   sbuf_bcat(&sb, msqkptr, sizeof(*msqkptr));
> +   mtx_unlock(&msq_mtx);
> +   error = SYSCTL_OUT(req, &tmsqk, sizeof(tmsqk));
> +   if (error != 0)
> +   break;
> }
> -   error = sbuf_finish(&sb);
> -   sbuf_delete(&sb);
> -
> -done:
> return (error);
>  }
>
> @@ -1470,7 +1459,8 @@ SYSCTL_INT(_kern_ipc, OID_AUTO, msgssz,
>  "Size of a message segment");
>  SYSCTL_INT(_kern_ipc, OID_AUTO, msgseg, CTLFLAG_RDTUN, &msginfo.msgseg, 0,
>  "Number of message segments");
> -SYSCTL_PROC(_kern_ipc, OID_AUTO, msqids, CTLTYPE_OPAQUE | CTLFLAG_RD,
> +SYSCTL_PROC(_kern_ipc, OID_AUTO, msqids,
> +CTLTYPE_OPAQUE | CTLFLAG_RD | CTLFLAG_MPSAFE,
>  NULL, 0, sysctl_msqids, "", "Message queue IDs");
>
>  static int
>
> Modified: head/sys/kern/sysv_sem.c
>
> ==
> --- head/sys/kern/sysv_sem.cTue Apr 26 18:11:45 2016(r298655)
> +++ head/sys/kern/sysv_sem.cTue Apr 26 18:17:44 2016(r298656)
> @@ -52,7 +52,6 @@ __FBSDID("$FreeBSD$");
>  #include 
>  #include 
>  #include 
> -#include 
>  #include 
>  #include 
>  #include 
> @@ -220,7 +219,8 @@ SYSCTL_INT(_kern_ipc, OID_AUTO, semvmx,
>  "Semaphore maximum value");
>  SYSCTL_INT(_kern_ipc, OID_AUTO, semaem, CTLFLAG_RWTUN, &seminfo.semaem, 0,
>  "Adjust on exit max value");
> -SYSCTL_PROC(_kern_ipc, OID_AUTO, sema, CTLTYPE_OPAQUE | CTLFLAG_RD,
> +SYSCTL_PROC(_kern_ipc, OID_AUTO, sema,
> +CTLTYPE_OPAQUE | CTLFLAG_RD | CTLFLAG_MPSAFE,
>  NULL, 0, sysctl_sema, "", "Semaphore id pool");
>
>  static struct syscall_helper_data sem_syscalls[] = {
> @@ -1465,38 +1465,28 @@ semexit_myhook(void *arg, struct proc *p
>  static int
>  sysctl_sema(SYSCTL_HANDLER_ARGS)
>  {
> -   struct prison *rpr;
> -   struct sbuf sb;
> -   struct semid_kernel tmp, empty;
> -   struct semid_kernel *semakptr;
> +   struct prison *pr, *rpr;
> +   struct semid_kernel tsemak;
> int error, i;
>
> -   error = sysctl_wire_old_buffer(req, 0);
> -   if (error != 0)
> -   goto done;
> +   pr = req->td->td_ucred->cr_prison;
> rpr = sem_find_prison(req->td->td_ucred);
> -   sbuf_new_for_sysctl(&sb, NULL, sizeof(struct semid_kernel) *
> -   seminfo.semmni, req);
> -
> -   bzero(&empty, sizeof(empt

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

2016-04-26 Thread James Gritton
 

It turns out I was just about to commit that anyway, so the only
difference is I didn't need to put "(mis)" in the comment :-). ipcs(1)
was prone to allocation errors that I could bypass by rewriting the
sysctls without sbufs. 

So false positive, but for the best anyway. 

- Jamie 

On 2016-04-26 12:46, Conrad Meyer wrote: 

> The sbuf use here was fine before.
> 
> Best, Conrad 
> 
> On Tue, Apr 26, 2016 at 11:17 AM, Jamie Gritton  wrote:
> 
>> Author: jamie
>> Date: Tue Apr 26 18:17:44 2016
>> New Revision: 298656
>> URL: https://svnweb.freebsd.org/changeset/base/298656 [1]
>> 
>> Log:
>> Redo the changes to the SYSV IPC sysctl functions from r298585, so they
>> don't (mis)use sbufs.
>> 
>> PR: 48471
>> 
>> Modified:
>> head/sys/kern/sysv_msg.c
>> head/sys/kern/sysv_sem.c
>> head/sys/kern/sysv_shm.c
>> 
>> Modified: head/sys/kern/sysv_msg.c
>> ==
>> --- head/sys/kern/sysv_msg.c Tue Apr 26 18:11:45 2016 (r298655)
>> +++ head/sys/kern/sysv_msg.c Tue Apr 26 18:17:44 2016 (r298656)
>> @@ -65,7 +65,6 @@ __FBSDID("$FreeBSD$");
>> #include 
>> #include 
>> #include 
>> -#include 
>> #include 
>> #include 
>> #include 
>> @@ -1423,38 +1422,28 @@ sys_msgrcv(td, uap)
>> static int
>> sysctl_msqids(SYSCTL_HANDLER_ARGS)
>> {
>> - struct sbuf sb;
>> - struct msqid_kernel tmp, empty;
>> - struct msqid_kernel *msqkptr;
>> - struct prison *rpr;
>> + struct msqid_kernel tmsqk;
>> + struct prison *pr, *rpr;
>> int error, i;
>> 
>> - error = sysctl_wire_old_buffer(req, 0);
>> - if (error != 0)
>> - goto done;
>> + pr = req->td->td_ucred->cr_prison;
>> rpr = msg_find_prison(req->td->td_ucred);
>> - sbuf_new_for_sysctl(&sb, NULL, sizeof(struct msqid_kernel) *
>> - msginfo.msgmni, req);
>> -
>> - bzero(&empty, sizeof(empty));
>> + error = 0;
>> for (i = 0; i < msginfo.msgmni; i++) {
>> - msqkptr = &msqids[i];
>> - if (msqkptr->u.msg_qbytes == 0 || rpr == NULL ||
>> - msq_prison_cansee(rpr, msqkptr) != 0) {
>> - msqkptr = ∅
>> - } else if (req->td->td_ucred->cr_prison !=
>> - msqkptr->cred->cr_prison) {
>> - bcopy(msqkptr, &tmp, sizeof(tmp));
>> - msqkptr = &tmp;
>> - msqkptr->u.msg_perm.key = IPC_PRIVATE;
>> + mtx_lock(&msq_mtx);
>> + if (msqids[i].u.msg_qbytes == 0 || rpr == NULL ||
>> + msq_prison_cansee(rpr, &msqids[i]) != 0)
>> + bzero(&tmsqk, sizeof(tmsqk));
>> + else {
>> + tmsqk = msqids[i];
>> + if (tmsqk.cred->cr_prison != pr)
>> + tmsqk.u.msg_perm.key = IPC_PRIVATE;
>> }
>> -
>> - sbuf_bcat(&sb, msqkptr, sizeof(*msqkptr));
>> + mtx_unlock(&msq_mtx);
>> + error = SYSCTL_OUT(req, &tmsqk, sizeof(tmsqk));
>> + if (error != 0)
>> + break;
>> }
>> - error = sbuf_finish(&sb);
>> - sbuf_delete(&sb);
>> -
>> -done:
>> return (error);
>> }
>> 
>> @@ -1470,7 +1459,8 @@ SYSCTL_INT(_kern_ipc, OID_AUTO, msgssz,
>> "Size of a message segment");
>> SYSCTL_INT(_kern_ipc, OID_AUTO, msgseg, CTLFLAG_RDTUN, &msginfo.msgseg, 0,
>> "Number of message segments");
>> -SYSCTL_PROC(_kern_ipc, OID_AUTO, msqids, CTLTYPE_OPAQUE | CTLFLAG_RD,
>> +SYSCTL_PROC(_kern_ipc, OID_AUTO, msqids,
>> + CTLTYPE_OPAQUE | CTLFLAG_RD | CTLFLAG_MPSAFE,
>> NULL, 0, sysctl_msqids, "", "Message queue IDs");
>> 
>> static int
>> 
>> Modified: head/sys/kern/sysv_sem.c
>> ==
>> --- head/sys/kern/sysv_sem.c Tue Apr 26 18:11:45 2016 (r298655)
>> +++ head/sys/kern/sysv_sem.c Tue Apr 26 18:17:44 2016 (r298656)
>> @@ -52,7 +52,6 @@ __FBSDID("$FreeBSD$");
>> #include 
>> #include 
>> #include 
>> -#include 
>> #include 
>> #include 
>> #include 
>> @@ -220,7 +219,8 @@ SYSCTL_INT(_kern_ipc, OID_AUTO, semvmx,
>> "Semaphore maximum value");
>> SYSCTL_INT(_kern_ipc, OID_AUTO, semaem, CTLFLAG_RWTUN, &seminfo.semaem, 0,
>> "Adjust on exit max value");
>> -SYSCTL_PROC(_kern_ipc, OID_AUTO, sema, CTLTYPE_OPAQUE | CTLFLAG_RD,
>> +SYSCTL_PROC(_kern_ipc, OID_AUTO, sema,
>> + CTLTYPE_OPAQUE | CTLFLAG_RD | CTLFLAG_MPSAFE,
>> NULL, 0, sysctl_sema, "", "Semaphore id pool");
>> 
>> static struct syscall_helper_data sem_syscalls[] = {
>> @@ -1465,38 +1465,28 @@ semexit_myhook(void *arg, struct proc *p
>> static int
>> sysctl_sema(SYSCTL_HANDLER_ARGS)
>> {
>> - struct prison *rpr;
>> - struct sbuf sb;
>> - struct semid_kernel tmp, empty;
>> - struct semid_kernel *semakptr;
>> + struct prison *pr, *rpr;
>> + struct semid_kernel tsemak;
>> int error, i;
>> 
>> - error = sysctl_wire_old_buffer(req, 0);
>> - if (error != 0)
>> - goto done;
>> + pr = req->td->td_ucred->cr_prison;
>> rpr = sem_find_prison(req->td->td_ucred);
>> - sbuf_new_for_sysctl(&sb, NULL, sizeof(struct semid_kernel) *
>> - seminfo.semmni, req);
>> -
>> - bzero(&empty, sizeof(empty));
>> + error = 0;
>> for (i = 0; i < seminfo.semmni; i++) {
>> - semakptr = &sema[i];
>> - if ((semakptr->u.sem_perm.mode & SEM_ALLOC) == 0 ||
>> - rpr == NULL || sem_prison_cansee(rpr, semakptr) != 0) {
>> - semakptr = ∅
>> - } else if (req->td->td_ucred->cr_prison !=
>> - semakptr->cred->cr_pri

svn commit: r298658 - head/usr.sbin/etcupdate

2016-04-26 Thread Bjoern Heidotting
Author: bhd (doc committer)
Date: Tue Apr 26 18:54:44 2016
New Revision: 298658
URL: https://svnweb.freebsd.org/changeset/base/298658

Log:
  Remove redundant word.
  
  Reviewed by:   bjk, bcr
  Differential Revision:https://reviews.freebsd.org/D6064

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

Modified: head/usr.sbin/etcupdate/etcupdate.8
==
--- head/usr.sbin/etcupdate/etcupdate.8 Tue Apr 26 18:20:41 2016
(r298657)
+++ head/usr.sbin/etcupdate/etcupdate.8 Tue Apr 26 18:54:44 2016
(r298658)
@@ -870,7 +870,7 @@ utility was written by
 Rerunning a merge does not automatically delete conflicts left over from a
 previous merge.
 Any conflicts must be resolved before the merge can be rerun.
-It it is not clear if this is a feature or a bug.
+It is not clear if this is a feature or a bug.
 .Pp
 There is no way to easily automate conflict resolution for specific files.
 For example, one can imagine a syntax along the lines of
___
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"


Re: svn commit: r298655 - head/sys/kgssapi

2016-04-26 Thread Alan Somers
Nice catch.  Will you be MFCing this to stable/10?

On Tue, Apr 26, 2016 at 12:11 PM, Conrad E. Meyer  wrote:

> Author: cem
> Date: Tue Apr 26 18:11:45 2016
> New Revision: 298655
> URL: https://svnweb.freebsd.org/changeset/base/298655
>
> Log:
>   kgssapi: Don't leak memory in error cases
>
>   Reported by:  Coverity
>   CIDs: 1007046, 1007047, 1007048
>   Sponsored by: EMC / Isilon Storage Division
>
> Modified:
>   head/sys/kgssapi/gssd_prot.c
>
> Modified: head/sys/kgssapi/gssd_prot.c
>
> ==
> --- head/sys/kgssapi/gssd_prot.cTue Apr 26 18:08:51 2016
> (r298654)
> +++ head/sys/kgssapi/gssd_prot.cTue Apr 26 18:11:45 2016
> (r298655)
> @@ -101,8 +101,10 @@ xdr_gss_OID(XDR *xdrs, gss_OID *oidp)
> } else {
> oid = mem_alloc(sizeof(gss_OID_desc));
> memset(oid, 0, sizeof(*oid));
> -   if (!xdr_gss_OID_desc(xdrs, oid))
> +   if (!xdr_gss_OID_desc(xdrs, oid)) {
> +   mem_free(oid, sizeof(gss_OID_desc));
> return (FALSE);
> +   }
> *oidp = oid;
> }
> break;
> @@ -164,8 +166,10 @@ xdr_gss_OID_set(XDR *xdrs, gss_OID_set *
> } else {
> set = mem_alloc(sizeof(gss_OID_set_desc));
> memset(set, 0, sizeof(*set));
> -   if (!xdr_gss_OID_set_desc(xdrs, set))
> +   if (!xdr_gss_OID_set_desc(xdrs, set)) {
> +   mem_free(set, sizeof(gss_OID_set_desc));
> return (FALSE);
> +   }
> *setp = set;
> }
> break;
> @@ -224,8 +228,10 @@ xdr_gss_channel_bindings_t(XDR *xdrs, gs
> || !xdr_gss_buffer_desc(xdrs,
> &ch->acceptor_address)
> || !xdr_gss_buffer_desc(xdrs,
> -   &ch->application_data))
> +   &ch->application_data)) {
> +   mem_free(ch, sizeof(*ch));
> return (FALSE);
> +   }
> *chp = ch;
> }
> break;
>
>
___
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: r298659 - head/sys/dev/iwm

2016-04-26 Thread Conrad E. Meyer
Author: cem
Date: Tue Apr 26 19:06:28 2016
New Revision: 298659
URL: https://svnweb.freebsd.org/changeset/base/298659

Log:
  iwm(4): Don't dereference potentially NULL pointer before NULL check
  
  Introduced in r298594.  There is no path before the 'vap == NULL' check where
  vap is not already dereferenced.
  
  Reported by:  Coverity
  CID:  1354979
  Sponsored by: EMC / Isilon Storage Division

Modified:
  head/sys/dev/iwm/if_iwm.c

Modified: head/sys/dev/iwm/if_iwm.c
==
--- head/sys/dev/iwm/if_iwm.c   Tue Apr 26 18:54:44 2016(r298658)
+++ head/sys/dev/iwm/if_iwm.c   Tue Apr 26 19:06:28 2016(r298659)
@@ -4377,7 +4377,7 @@ iwm_intr(void *arg)
device_printf(sc->sc_dev,
"  rx ring: cur=%d\n", sc->rxq.cur);
device_printf(sc->sc_dev,
-   "  802.11 state %d\n", vap->iv_state);
+   "  802.11 state %d\n", (vap == NULL) ? -1 : vap->iv_state);
 
/* Don't stop the device; just do a VAP restart */
IWM_UNLOCK(sc);
___
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: r298660 - head/contrib/netbsd-tests/lib/libc/ssp

2016-04-26 Thread Garrett Cooper
Author: ngie
Date: Tue Apr 26 19:21:35 2016
New Revision: 298660
URL: https://svnweb.freebsd.org/changeset/base/298660

Log:
  Fix up r298368
  
  Remove the semicolon accidentally added after the new conditional that tests
  that /dev/zero is opened successfully.
  
  MFC after: 1 week
  X-MFC with: r298368
  Pointhat to: ngie
  Reported by: Coverity
  CID: 1354980
  Sponsored by: EMC / Isilon Storage Division

Modified:
  head/contrib/netbsd-tests/lib/libc/ssp/h_read.c

Modified: head/contrib/netbsd-tests/lib/libc/ssp/h_read.c
==
--- head/contrib/netbsd-tests/lib/libc/ssp/h_read.c Tue Apr 26 19:06:28 
2016(r298659)
+++ head/contrib/netbsd-tests/lib/libc/ssp/h_read.c Tue Apr 26 19:21:35 
2016(r298660)
@@ -47,7 +47,7 @@ main(int argc, char *argv[])
int fd, n;
size_t len = atoi(argv[1]);
 
-   if ((fd = open(_PATH_DEVZERO, O_RDONLY)) == -1);
+   if ((fd = open(_PATH_DEVZERO, O_RDONLY)) == -1)
abort();
if ((n = read(fd, b, len)) == -1)
abort();
___
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"


Re: svn commit: r298655 - head/sys/kgssapi

2016-04-26 Thread Conrad Meyer
Nope!  I don't do stable/.

On Tue, Apr 26, 2016 at 12:06 PM, Alan Somers  wrote:

> Nice catch.  Will you be MFCing this to stable/10?
>
> On Tue, Apr 26, 2016 at 12:11 PM, Conrad E. Meyer  wrote:
>
>> Author: cem
>> Date: Tue Apr 26 18:11:45 2016
>> New Revision: 298655
>> URL: https://svnweb.freebsd.org/changeset/base/298655
>>
>> Log:
>>   kgssapi: Don't leak memory in error cases
>>
>>   Reported by:  Coverity
>>   CIDs: 1007046, 1007047, 1007048
>>   Sponsored by: EMC / Isilon Storage Division
>>
>> Modified:
>>   head/sys/kgssapi/gssd_prot.c
>>
>> Modified: head/sys/kgssapi/gssd_prot.c
>>
>> ==
>> --- head/sys/kgssapi/gssd_prot.cTue Apr 26 18:08:51 2016
>> (r298654)
>> +++ head/sys/kgssapi/gssd_prot.cTue Apr 26 18:11:45 2016
>> (r298655)
>> @@ -101,8 +101,10 @@ xdr_gss_OID(XDR *xdrs, gss_OID *oidp)
>> } else {
>> oid = mem_alloc(sizeof(gss_OID_desc));
>> memset(oid, 0, sizeof(*oid));
>> -   if (!xdr_gss_OID_desc(xdrs, oid))
>> +   if (!xdr_gss_OID_desc(xdrs, oid)) {
>> +   mem_free(oid, sizeof(gss_OID_desc));
>> return (FALSE);
>> +   }
>> *oidp = oid;
>> }
>> break;
>> @@ -164,8 +166,10 @@ xdr_gss_OID_set(XDR *xdrs, gss_OID_set *
>> } else {
>> set = mem_alloc(sizeof(gss_OID_set_desc));
>> memset(set, 0, sizeof(*set));
>> -   if (!xdr_gss_OID_set_desc(xdrs, set))
>> +   if (!xdr_gss_OID_set_desc(xdrs, set)) {
>> +   mem_free(set, sizeof(gss_OID_set_desc));
>> return (FALSE);
>> +   }
>> *setp = set;
>> }
>> break;
>> @@ -224,8 +228,10 @@ xdr_gss_channel_bindings_t(XDR *xdrs, gs
>> || !xdr_gss_buffer_desc(xdrs,
>> &ch->acceptor_address)
>> || !xdr_gss_buffer_desc(xdrs,
>> -   &ch->application_data))
>> +   &ch->application_data)) {
>> +   mem_free(ch, sizeof(*ch));
>> return (FALSE);
>> +   }
>> *chp = ch;
>> }
>> break;
>>
>>
>
___
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: r298661 - in head: share/man/man9 sys/compat/linux sys/kern sys/sys

2016-04-26 Thread Conrad E. Meyer
Author: cem
Date: Tue Apr 26 19:57:35 2016
New Revision: 298661
URL: https://svnweb.freebsd.org/changeset/base/298661

Log:
  osd(9): Change array pointer to array pointer type from void*
  
  This is a minor follow-up to r297422, prompted by a Coverity warning.  (It's
  not a real defect, just a code smell.)  OSD slot array reservations are an
  array of pointers (void **) but were cast to void* and back unnecessarily.
  Keep the correct type from reservation to use.
  
  osd.9 is updated to match, along with a few trivial igor fixes.
  
  Reported by:  Coverity
  CID:  1353811
  Sponsored by: EMC / Isilon Storage Division

Modified:
  head/share/man/man9/osd.9
  head/sys/compat/linux/linux_mib.c
  head/sys/kern/kern_osd.c
  head/sys/kern/sysv_msg.c
  head/sys/kern/sysv_sem.c
  head/sys/kern/sysv_shm.c
  head/sys/sys/osd.h

Modified: head/share/man/man9/osd.9
==
--- head/share/man/man9/osd.9   Tue Apr 26 19:21:35 2016(r298660)
+++ head/share/man/man9/osd.9   Tue Apr 26 19:57:35 2016(r298661)
@@ -25,7 +25,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd March 30, 2016
+.Dd April 26, 2016
 .Dt OSD 9
 .Os
 .Sh NAME
@@ -65,7 +65,7 @@
 .Fa "u_int slot"
 .Fa "void *value"
 .Fc
-.Ft void *
+.Ft void **
 .Fo osd_reserve
 .Fa "u_int slot"
 .Fc
@@ -74,12 +74,12 @@
 .Fa "u_int type"
 .Fa "struct osd *osd"
 .Fa "u_int slot"
-.Fa "void *rsv"
+.Fa "void **rsv"
 .Fa "void *value"
 .Fc
 .Ft void
 .Fo osd_free_reserved
-.Fa "void *rsv"
+.Fa "void **rsv"
 .Fc
 .Ft void *
 .Fo osd_get
@@ -314,8 +314,8 @@ the external data associated with a kern
 .Vt struct osd
 member.
 The type identifier is used as the index into the outer array, and the slot
-identifier is used as the index into the inner array. To set or retrieve a data
-pointer for a given type/slot identifier pair,
+identifier is used as the index into the inner array.
+To set or retrieve a data pointer for a given type/slot identifier pair,
 .Fn osd_set
 and
 .Fn osd_get
@@ -341,7 +341,7 @@ is used to grow the array to the appropr
 can be used.
 To maximise the efficiency of any code which calls
 .Fn osd_set
-sequentially on a number of different slot identifiers (e.g. during an
+sequentially on a number of different slot identifiers (e.g., during an
 initialisation phase) one should loop through the slot identifiers in 
descending
 order from highest to lowest.
 This will result in only a single
@@ -354,7 +354,8 @@ calls.
 .Pp
 It is possible for
 .Fn osd_set
-to fail to allocate this array.  To ensure that such allocation succeeds,
+to fail to allocate this array.
+To ensure that such allocation succeeds,
 .Fn osd_reserve
 may be called (in a non-blocking context), and it will pre-allocate the
 memory via

Modified: head/sys/compat/linux/linux_mib.c
==
--- head/sys/compat/linux/linux_mib.c   Tue Apr 26 19:21:35 2016
(r298660)
+++ head/sys/compat/linux/linux_mib.c   Tue Apr 26 19:57:35 2016
(r298661)
@@ -192,7 +192,7 @@ linux_alloc_prison(struct prison *pr, st
 {
struct prison *ppr;
struct linux_prison *lpr, *nlpr;
-   void *rsv;
+   void **rsv;
 
/* If this prison already has Linux info, return that. */
lpr = linux_find_prison(pr, &ppr);

Modified: head/sys/kern/kern_osd.c
==
--- head/sys/kern/kern_osd.cTue Apr 26 19:21:35 2016(r298660)
+++ head/sys/kern/kern_osd.cTue Apr 26 19:57:35 2016(r298661)
@@ -202,7 +202,7 @@ osd_set(u_int type, struct osd *osd, u_i
return (osd_set_reserved(type, osd, slot, NULL, value));
 }
 
-void *
+void **
 osd_reserve(u_int slot)
 {
 
@@ -213,7 +213,7 @@ osd_reserve(u_int slot)
 }
 
 int
-osd_set_reserved(u_int type, struct osd *osd, u_int slot, void *rsv,
+osd_set_reserved(u_int type, struct osd *osd, u_int slot, void **rsv,
 void *value)
 {
struct rm_priotracker tracker;
@@ -224,7 +224,7 @@ osd_set_reserved(u_int type, struct osd 
 
rm_rlock(&osdm[type].osd_object_lock, &tracker);
if (slot > osd->osd_nslots) {
-   void *newptr;
+   void **newptr;
 
if (value == NULL) {
OSD_DEBUG(
@@ -283,7 +283,7 @@ osd_set_reserved(u_int type, struct osd 
 }
 
 void
-osd_free_reserved(void *rsv)
+osd_free_reserved(void **rsv)
 {
 
OSD_DEBUG("Discarding reserved slot array.");

Modified: head/sys/kern/sysv_msg.c
==
--- head/sys/kern/sysv_msg.cTue Apr 26 19:21:35 2016(r298660)
+++ head/sys/kern/sysv_msg.cTue Apr 26 19:57:35 2016(r298661)
@@ -206,7 +206,7 @@ static int
 msginit()
 {
struct prison *pr;
-   void *rsv;
+   void **rsv;
int i, error;
osd_method_t methods[PR_MAXMETHOD] = {
[PR_METHO

svn commit: r298662 - head/sys/dev/pci

2016-04-26 Thread Conrad E. Meyer
Author: cem
Date: Tue Apr 26 20:06:35 2016
New Revision: 298662
URL: https://svnweb.freebsd.org/changeset/base/298662

Log:
  PCI Enhanced Allocation: Annotate an intentional switch fallthrough
  
  This is a trivial follow-up to r296308.  Annotate the intentional fallthrough
  to make it clear for future readers and linters.
  
  Reported by:  Coverity
  CID:  1352716
  Discussed with:   jhb
  Sponsored by: EMC / Isilon Storage Division

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

Modified: head/sys/dev/pci/pci.c
==
--- head/sys/dev/pci/pci.c  Tue Apr 26 19:57:35 2016(r298661)
+++ head/sys/dev/pci/pci.c  Tue Apr 26 20:06:35 2016(r298662)
@@ -3691,6 +3691,7 @@ pci_add_resources_ea(device_t bus, devic
case PCIM_EA_P_MEM_PREFETCH:
case PCIM_EA_P_VF_MEM_PREFETCH:
flags = RF_PREFETCHABLE;
+   /* FALLTHROUGH */
case PCIM_EA_P_VF_MEM:
case PCIM_EA_P_MEM:
type = SYS_RES_MEMORY;
___
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"


Re: svn commit: r298655 - head/sys/kgssapi

2016-04-26 Thread Alan Somers
You really ought to.  When you MFC yourself, it reduces the likelihood of
errors, because you understand the change best.  When someone else does it,
it's more likely he'll make a mistake, because he may not know the fine
details behind the change.  In fact, it's hard for anybody else to even
know that a given change should or shouldn't be MFCed.  The MFC reminder
emails only go to the committer, not to everyone.  And when someone
unfamiliar with kgssapi looks at a commit message like the one below, he
doesn't know whether there's no MFC tag because the change isn't applicable
to stable/10, or because the committer forgot it, or because the committer
just "doesn't do stable".

Please help maintain stable/10.  It's everyone's job.
-Alan

On Tue, Apr 26, 2016 at 1:23 PM, Conrad Meyer  wrote:

> Nope!  I don't do stable/.
>
> On Tue, Apr 26, 2016 at 12:06 PM, Alan Somers  wrote:
>
>> Nice catch.  Will you be MFCing this to stable/10?
>>
>> On Tue, Apr 26, 2016 at 12:11 PM, Conrad E. Meyer 
>> wrote:
>>
>>> Author: cem
>>> Date: Tue Apr 26 18:11:45 2016
>>> New Revision: 298655
>>> URL: https://svnweb.freebsd.org/changeset/base/298655
>>>
>>> Log:
>>>   kgssapi: Don't leak memory in error cases
>>>
>>>   Reported by:  Coverity
>>>   CIDs: 1007046, 1007047, 1007048
>>>   Sponsored by: EMC / Isilon Storage Division
>>>
>>> Modified:
>>>   head/sys/kgssapi/gssd_prot.c
>>>
>>> Modified: head/sys/kgssapi/gssd_prot.c
>>>
>>> ==
>>> --- head/sys/kgssapi/gssd_prot.cTue Apr 26 18:08:51 2016
>>> (r298654)
>>> +++ head/sys/kgssapi/gssd_prot.cTue Apr 26 18:11:45 2016
>>> (r298655)
>>> @@ -101,8 +101,10 @@ xdr_gss_OID(XDR *xdrs, gss_OID *oidp)
>>> } else {
>>> oid = mem_alloc(sizeof(gss_OID_desc));
>>> memset(oid, 0, sizeof(*oid));
>>> -   if (!xdr_gss_OID_desc(xdrs, oid))
>>> +   if (!xdr_gss_OID_desc(xdrs, oid)) {
>>> +   mem_free(oid, sizeof(gss_OID_desc));
>>> return (FALSE);
>>> +   }
>>> *oidp = oid;
>>> }
>>> break;
>>> @@ -164,8 +166,10 @@ xdr_gss_OID_set(XDR *xdrs, gss_OID_set *
>>> } else {
>>> set = mem_alloc(sizeof(gss_OID_set_desc));
>>> memset(set, 0, sizeof(*set));
>>> -   if (!xdr_gss_OID_set_desc(xdrs, set))
>>> +   if (!xdr_gss_OID_set_desc(xdrs, set)) {
>>> +   mem_free(set, sizeof(gss_OID_set_desc));
>>> return (FALSE);
>>> +   }
>>> *setp = set;
>>> }
>>> break;
>>> @@ -224,8 +228,10 @@ xdr_gss_channel_bindings_t(XDR *xdrs, gs
>>> || !xdr_gss_buffer_desc(xdrs,
>>> &ch->acceptor_address)
>>> || !xdr_gss_buffer_desc(xdrs,
>>> -   &ch->application_data))
>>> +   &ch->application_data)) {
>>> +   mem_free(ch, sizeof(*ch));
>>> return (FALSE);
>>> +   }
>>> *chp = ch;
>>> }
>>> break;
>>>
>>>
>>
>
___
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: r298663 - head/sys/net

2016-04-26 Thread Conrad E. Meyer
Author: cem
Date: Tue Apr 26 20:27:17 2016
New Revision: 298663
URL: https://svnweb.freebsd.org/changeset/base/298663

Log:
  radix_mpath: Don't derefence a NULL pointer in for loop iteration
  
  It seems rn_dupedkey may be NULL, because of the NULL check inside the loop.
  (Also, the rt gets assigned from rn_dupedkey and NULL checked at top of loop.)
  However, the for-loop update condition happens before the top-of-loop check 
and
  dereferences 'rt' unconditionally.
  
  Instead, NULL-check before dereferencing.
  
  If rn_dupedkey cannot in fact be NULL, or something else protects this, feel
  free to revert this and add an ASSERT of some kind instead.
  
  This was introduced in r191080 (2009) and moved around slightly in r293657.
  
  Reported by:  Coverity
  CID:  1348482
  Sponsored by: EMC / Isilon Storage Division

Modified:
  head/sys/net/radix_mpath.c

Modified: head/sys/net/radix_mpath.c
==
--- head/sys/net/radix_mpath.c  Tue Apr 26 20:06:35 2016(r298662)
+++ head/sys/net/radix_mpath.c  Tue Apr 26 20:27:17 2016(r298663)
@@ -223,7 +223,7 @@ rt_mpath_selectrte(struct rtentry *rte, 
hash %= total_weight;
for (weight = abs((int32_t)hash);
 rt != NULL && weight >= rt->rt_weight; 
-weight -= rt->rt_weight) {
+weight -= (rt == NULL) ? 0 : rt->rt_weight) {

/* stay within the multipath routes */
if (rn->rn_dupedkey && rn->rn_mask != rn->rn_dupedkey->rn_mask)
___
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: r298664 - head/sys/fs/msdosfs

2016-04-26 Thread Kristof Provost
Author: kp
Date: Tue Apr 26 20:36:32 2016
New Revision: 298664
URL: https://svnweb.freebsd.org/changeset/base/298664

Log:
  msdosfs: Prevent buffer overflow when expanding win95 names
  
  In win2unixfn() we expand Windows 95 style long names. In some cases that
  requires moving the data in the nbp->nb_buf buffer backwards to make room. 
That
  code failed to check for overflows, leading to a stack overflow in 
win2unixfn().
  
  We now check for this event, and mark the entire conversion as failed in that
  case. This means we present the 8 character, dos style, name instead.
  
  PR: 204643
  Differential Revision:https://reviews.freebsd.org/D6015

Modified:
  head/sys/fs/msdosfs/direntry.h
  head/sys/fs/msdosfs/msdosfs_conv.c

Modified: head/sys/fs/msdosfs/direntry.h
==
--- head/sys/fs/msdosfs/direntry.h  Tue Apr 26 20:27:17 2016
(r298663)
+++ head/sys/fs/msdosfs/direntry.h  Tue Apr 26 20:36:32 2016
(r298664)
@@ -145,7 +145,7 @@ struct msdosfsmount;
 
 char   *mbnambuf_flush(struct mbnambuf *nbp, struct dirent *dp);
 void   mbnambuf_init(struct mbnambuf *nbp);
-void   mbnambuf_write(struct mbnambuf *nbp, char *name, int id);
+intmbnambuf_write(struct mbnambuf *nbp, char *name, int id);
 intdos2unixfn(u_char dn[11], u_char *un, int lower,
struct msdosfsmount *pmp);
 intunix2dosfn(const u_char *un, u_char dn[12], size_t unlen, u_int gen,

Modified: head/sys/fs/msdosfs/msdosfs_conv.c
==
--- head/sys/fs/msdosfs/msdosfs_conv.c  Tue Apr 26 20:27:17 2016
(r298663)
+++ head/sys/fs/msdosfs/msdosfs_conv.c  Tue Apr 26 20:36:32 2016
(r298664)
@@ -658,7 +658,9 @@ win2unixfn(struct mbnambuf *nbp, struct 
switch (code) {
case 0:
*np = '\0';
-   mbnambuf_write(nbp, name, (wep->weCnt & WIN_CNT) - 1);
+   if (mbnambuf_write(nbp, name,
+   (wep->weCnt & WIN_CNT) - 1) != 0)
+   return -1;
return chksum;
case '/':
*np = '\0';
@@ -676,7 +678,9 @@ win2unixfn(struct mbnambuf *nbp, struct 
switch (code) {
case 0:
*np = '\0';
-   mbnambuf_write(nbp, name, (wep->weCnt & WIN_CNT) - 1);
+   if (mbnambuf_write(nbp, name,
+   (wep->weCnt & WIN_CNT) - 1) != 0)
+   return -1;
return chksum;
case '/':
*np = '\0';
@@ -694,7 +698,9 @@ win2unixfn(struct mbnambuf *nbp, struct 
switch (code) {
case 0:
*np = '\0';
-   mbnambuf_write(nbp, name, (wep->weCnt & WIN_CNT) - 1);
+   if (mbnambuf_write(nbp, name,
+   (wep->weCnt & WIN_CNT) - 1) != 0)
+   return -1;
return chksum;
case '/':
*np = '\0';
@@ -708,7 +714,8 @@ win2unixfn(struct mbnambuf *nbp, struct 
cp += 2;
}
*np = '\0';
-   mbnambuf_write(nbp, name, (wep->weCnt & WIN_CNT) - 1);
+   if (mbnambuf_write(nbp, name, (wep->weCnt & WIN_CNT) - 1) != 0)
+   return -1;
return chksum;
 }
 
@@ -1005,7 +1012,7 @@ mbnambuf_init(struct mbnambuf *nbp)
  * This only penalizes portions of substrings that contain more than
  * WIN_CHARS bytes when they are first encountered.
  */
-void
+int
 mbnambuf_write(struct mbnambuf *nbp, char *name, int id)
 {
char *slot;
@@ -1016,7 +1023,7 @@ mbnambuf_write(struct mbnambuf *nbp, cha
printf("msdosfs: non-decreasing id: id %d, last id %d\n",
id, nbp->nb_last_id);
 #endif
-   return;
+   return (EINVAL);
}
 
/* Will store this substring in a WIN_CHARS-aligned slot. */
@@ -1027,17 +1034,24 @@ mbnambuf_write(struct mbnambuf *nbp, cha
 #ifdef MSDOSFS_DEBUG
printf("msdosfs: file name length %zu too large\n", newlen);
 #endif
-   return;
+   return (ENAMETOOLONG);
}
 
/* Shift suffix upwards by the amount length exceeds WIN_CHARS. */
-   if (count > WIN_CHARS && nbp->nb_len != 0)
+   if (count > WIN_CHARS && nbp->nb_len != 0) {
+   if ((id * WIN_CHARS + count + nbp->nb_len) >
+   sizeof(nbp->nb_buf))
+   return (ENAMETOOLONG);
+
bcopy(slot + WIN_CHARS, slot + count, nbp->nb_len);
+   }
 
/* Copy in the substring to its slot and update length so far. */
bcopy(name, slot, count);
nbp->nb_len = newlen;
nbp->nb_last_id = id;
+
+

Re: svn commit: r298655 - head/sys/kgssapi

2016-04-26 Thread Conrad Meyer
I don't do stable, and that's my choice to make (and final decision).

It would be appropriate to ask, "I'd like to MFC this to stable if it makes
sense to do so.  Does it make sense?"

But I think it is totally inappropriate to try to tell me it is my job to
push petty fixes to stable/10, a branch I do not use.

You don't pay me to work on stable/10 and neither does anybody else.  It's
not my job.  I do FreeBSD for fun.

Conrad


On Tue, Apr 26, 2016 at 1:24 PM, Alan Somers  wrote:

> You really ought to.  When you MFC yourself, it reduces the likelihood of
> errors, because you understand the change best.  When someone else does it,
> it's more likely he'll make a mistake, because he may not know the fine
> details behind the change.  In fact, it's hard for anybody else to even
> know that a given change should or shouldn't be MFCed.  The MFC reminder
> emails only go to the committer, not to everyone.  And when someone
> unfamiliar with kgssapi looks at a commit message like the one below, he
> doesn't know whether there's no MFC tag because the change isn't applicable
> to stable/10, or because the committer forgot it, or because the committer
> just "doesn't do stable".
>
> Please help maintain stable/10.  It's everyone's job.
> -Alan
>
> On Tue, Apr 26, 2016 at 1:23 PM, Conrad Meyer  wrote:
>
>> Nope!  I don't do stable/.
>>
>> On Tue, Apr 26, 2016 at 12:06 PM, Alan Somers 
>> wrote:
>>
>>> Nice catch.  Will you be MFCing this to stable/10?
>>>
>>> On Tue, Apr 26, 2016 at 12:11 PM, Conrad E. Meyer 
>>> wrote:
>>>
 Author: cem
 Date: Tue Apr 26 18:11:45 2016
 New Revision: 298655
 URL: https://svnweb.freebsd.org/changeset/base/298655

 Log:
   kgssapi: Don't leak memory in error cases

   Reported by:  Coverity
   CIDs: 1007046, 1007047, 1007048
   Sponsored by: EMC / Isilon Storage Division

 Modified:
   head/sys/kgssapi/gssd_prot.c

 Modified: head/sys/kgssapi/gssd_prot.c

 ==
 --- head/sys/kgssapi/gssd_prot.cTue Apr 26 18:08:51 2016
 (r298654)
 +++ head/sys/kgssapi/gssd_prot.cTue Apr 26 18:11:45 2016
 (r298655)
 @@ -101,8 +101,10 @@ xdr_gss_OID(XDR *xdrs, gss_OID *oidp)
 } else {
 oid = mem_alloc(sizeof(gss_OID_desc));
 memset(oid, 0, sizeof(*oid));
 -   if (!xdr_gss_OID_desc(xdrs, oid))
 +   if (!xdr_gss_OID_desc(xdrs, oid)) {
 +   mem_free(oid, sizeof(gss_OID_desc));
 return (FALSE);
 +   }
 *oidp = oid;
 }
 break;
 @@ -164,8 +166,10 @@ xdr_gss_OID_set(XDR *xdrs, gss_OID_set *
 } else {
 set = mem_alloc(sizeof(gss_OID_set_desc));
 memset(set, 0, sizeof(*set));
 -   if (!xdr_gss_OID_set_desc(xdrs, set))
 +   if (!xdr_gss_OID_set_desc(xdrs, set)) {
 +   mem_free(set, sizeof(gss_OID_set_desc));
 return (FALSE);
 +   }
 *setp = set;
 }
 break;
 @@ -224,8 +228,10 @@ xdr_gss_channel_bindings_t(XDR *xdrs, gs
 || !xdr_gss_buffer_desc(xdrs,
 &ch->acceptor_address)
 || !xdr_gss_buffer_desc(xdrs,
 -   &ch->application_data))
 +   &ch->application_data)) {
 +   mem_free(ch, sizeof(*ch));
 return (FALSE);
 +   }
 *chp = ch;
 }
 break;


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


Re: svn commit: r298585 - in head: sys/kern usr.sbin/jail

2016-04-26 Thread Ulrich Spörlein
On Apr 26, 2016 11:44 AM, "Conrad Meyer"  wrote:
>
> Right.  False positive.  Coverity doesn't grok sbuf memory management
fully.
>

If someone can explain it to me in very simple words, I can update the
model to make these go away ... maybe.
___
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"


Re: svn commit: r298585 - in head: sys/kern usr.sbin/jail

2016-04-26 Thread Conrad Meyer
I'll borrow my explanation from the NTB review:

There is the sbuf itself, and there is some buffer for data. Either
can be on the stack or the heap independently. This is controlled with
the DYNSTRUCT and DYNAMIC flags respectively.

sbuf_new() just initializes an sbuf. Depending on the inputs passed in
to it, it can allocate an sbuf on the heap (setting DYNSTRUCT) or not,
and allocate a buffer on the heap (setting DYNAMIC) or not.

Coverity is specifically complaining about freeing the sbuf memory
itself—not the heap buffer. Since this sbuf was initialized as *not*
DYNSTRUCT, sbuf_delete will never free the sbuf memory itself. This is
purely a false positive.

So, any stack sbuf will pass a non-NULL pointer to sbuf-new, making it
!DYNSTRUCT.  sbuf_delete on this pointer is valid because it won't try
to free a !DYNSTRUCT sbuf.  Coverity warns about it because it doesn't
understand the 1:1 relationship between stack sbufs and DYNSTRUCT.

Best,
Conrad


On Tue, Apr 26, 2016 at 1:45 PM, Ulrich Spörlein  wrote:
> On Apr 26, 2016 11:44 AM, "Conrad Meyer"  wrote:
>>
>> Right.  False positive.  Coverity doesn't grok sbuf memory management
>> fully.
>>
>
> If someone can explain it to me in very simple words, I can update the model
> to make these go away ... maybe.
___
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: r298665 - head/sys/dev/aacraid

2016-04-26 Thread Conrad E. Meyer
Author: cem
Date: Tue Apr 26 20:59:21 2016
New Revision: 298665
URL: https://svnweb.freebsd.org/changeset/base/298665

Log:
  aacraid(4): Fix some mostly trivial buffer overruns
  
  strcpy(3) emits a trailing nul byte, trampling fields after the intended
  destination.  Instead, use strncpy(3), intentionally leaving these fields
  not nul-terminated.
  
  Reported by:  Coverity
  CIDs: 1031024, 1305463, 1305494, 1305545
  Sponsored by: EMC / Isilon Storage Division

Modified:
  head/sys/dev/aacraid/aacraid_cam.c

Modified: head/sys/dev/aacraid/aacraid_cam.c
==
--- head/sys/dev/aacraid/aacraid_cam.c  Tue Apr 26 20:36:32 2016
(r298664)
+++ head/sys/dev/aacraid/aacraid_cam.c  Tue Apr 26 20:59:21 2016
(r298665)
@@ -568,9 +568,11 @@ aac_container_special_command(struct cam
p->additional_length = 31;
p->flags = SID_WBus16|SID_Sync|SID_CmdQue;
/* OEM Vendor defines */
-   strcpy(p->vendor,"Adaptec ");
-   strcpy(p->product,"Array   ");
-   strcpy(p->revision,"V1.0");
+   strncpy(p->vendor, "Adaptec ", 
sizeof(p->vendor));
+   strncpy(p->product, "Array   ",
+   sizeof(p->product));
+   strncpy(p->revision, "V1.0",
+   sizeof(p->revision));
}   
} else {
if (inq->page_code == SVPD_SUPPORTED_PAGE_LIST) {
___
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"


Re: svn commit: r298664 - head/sys/fs/msdosfs

2016-04-26 Thread Shawn Webb
On Tue, Apr 26, 2016 at 08:36:32PM +, Kristof Provost wrote:
> Author: kp
> Date: Tue Apr 26 20:36:32 2016
> New Revision: 298664
> URL: https://svnweb.freebsd.org/changeset/base/298664
> 
> Log:
>   msdosfs: Prevent buffer overflow when expanding win95 names
>   
>   In win2unixfn() we expand Windows 95 style long names. In some cases that
>   requires moving the data in the nbp->nb_buf buffer backwards to make room. 
> That
>   code failed to check for overflows, leading to a stack overflow in 
> win2unixfn().
>   
>   We now check for this event, and mark the entire conversion as failed in 
> that
>   case. This means we present the 8 character, dos style, name instead.
>   
>   PR: 204643
>   Differential Revision:  https://reviews.freebsd.org/D6015

Will this be MFC'd? Since it's triggerable as non-root, should this have
a CVE? Though the commit log shows technical comments, it doesn't show
related security information.

Thanks,

-- 
Shawn Webb
HardenedBSD

GPG Key ID:  0x6A84658F52456EEE
GPG Key Fingerprint: 2ABA B6BD EF6A F486 BE89  3D9E 6A84 658F 5245 6EEE


signature.asc
Description: PGP signature


Re: svn commit: r298664 - head/sys/fs/msdosfs

2016-04-26 Thread Kristof Provost

> On 26 Apr 2016, at 23:01, Shawn Webb  wrote:
> 
> On Tue, Apr 26, 2016 at 08:36:32PM +, Kristof Provost wrote:
>> Author: kp
>> Date: Tue Apr 26 20:36:32 2016
>> New Revision: 298664
>> URL: https://svnweb.freebsd.org/changeset/base/298664
>> 
>> Log:
>>  msdosfs: Prevent buffer overflow when expanding win95 names
>> 
>>  In win2unixfn() we expand Windows 95 style long names. In some cases that
>>  requires moving the data in the nbp->nb_buf buffer backwards to make room. 
>> That
>>  code failed to check for overflows, leading to a stack overflow in 
>> win2unixfn().
>> 
>>  We now check for this event, and mark the entire conversion as failed in 
>> that
>>  case. This means we present the 8 character, dos style, name instead.
>> 
>>  PR: 204643
>>  Differential Revision:  https://reviews.freebsd.org/D6015
> 
> Will this be MFC'd? Since it's triggerable as non-root, should this have
> a CVE? Though the commit log shows technical comments, it doesn't show
> related security information.

Yes, I’ll put MFCing this on my todo list.

I have to admit that I’ve not given the security implications much thought. The 
bug has always been caught by the stack canary on my test systems, without that 
it could potentially be quite dangerous.
(Given constraints of having to be able to mount arbitrary file systems as 
non-root of course.)

Regards,
Kristof


signature.asc
Description: Message signed with OpenPGP using GPGMail


Re: svn commit: r298664 - head/sys/fs/msdosfs

2016-04-26 Thread Conrad Meyer
On Tue, Apr 26, 2016 at 2:01 PM, Shawn Webb  wrote:
> On Tue, Apr 26, 2016 at 08:36:32PM +, Kristof Provost wrote:
>> Author: kp
>> Date: Tue Apr 26 20:36:32 2016
>> New Revision: 298664
>> URL: https://svnweb.freebsd.org/changeset/base/298664
>>
>> Log:
>>   msdosfs: Prevent buffer overflow when expanding win95 names
>>
>> ...
>
> Will this be MFC'd? Since it's triggerable as non-root, should this have
> a CVE? Though the commit log shows technical comments, it doesn't show
> related security information.

Is it triggerable as non-root?  Don't you need to write a malicious
filesystem image and persuade FreeBSD to mount it?

Best,
Conrad
___
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: r298666 - head/sys/modules/dtb/zynq

2016-04-26 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Tue Apr 26 21:11:01 2016
New Revision: 298666
URL: https://svnweb.freebsd.org/changeset/base/298666

Log:
  Add dtb/zynq to generate dtb files for Zynq-based boards
  
  It seems that the only way to supply dtb to loader on Zynq-based
  SoCs is to manually generate dtb and place it to pre-defined location
  on SD card or TFTP server where loader can pick it up.  More modern
  approach is to add modules/dtb/%soc% module and let installworld
  target generate dtb and copy them to /boot/dtb/ where they can be
  loaded by ubldr

Added:
  head/sys/modules/dtb/zynq/
  head/sys/modules/dtb/zynq/Makefile   (contents, props changed)

Added: head/sys/modules/dtb/zynq/Makefile
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/modules/dtb/zynq/Makefile  Tue Apr 26 21:11:01 2016
(r298666)
@@ -0,0 +1,7 @@
+# $FreeBSD$
+# All the dts files for Zynq systems we support.
+DTS=   \
+   zedboard.dts \
+zybo.dts
+
+.include 
___
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: r298667 - head/sys/arm/conf

2016-04-26 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Tue Apr 26 21:11:52 2016
New Revision: 298667
URL: https://svnweb.freebsd.org/changeset/base/298667

Log:
  Add dtb/zynq to the list of extra modules required by Zedboard

Modified:
  head/sys/arm/conf/ZEDBOARD

Modified: head/sys/arm/conf/ZEDBOARD
==
--- head/sys/arm/conf/ZEDBOARD  Tue Apr 26 21:11:01 2016(r298666)
+++ head/sys/arm/conf/ZEDBOARD  Tue Apr 26 21:11:52 2016(r298667)
@@ -24,6 +24,8 @@ ident ZEDBOARD
 include"std.armv6"
 include"../xilinx/std.zynq7"
 
+makeoptionsMODULES_EXTRA="dtb/zynq"
+
 optionsSCHED_ULE   # ULE scheduler
 #options   NFSSD   # Network Filesystem Server
 optionsSMP # Enable multiple cores
___
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"


Re: svn commit: r298664 - head/sys/fs/msdosfs

2016-04-26 Thread Adrian Chadd
You mean "hotplug mount a malicious USB disk via some installed
graphical enviornment?"

NOone does that... :)


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


Re: svn commit: r298664 - head/sys/fs/msdosfs

2016-04-26 Thread Conrad Meyer
On Tue, Apr 26, 2016 at 2:13 PM, Adrian Chadd  wrote:
> You mean "hotplug mount a malicious USB disk via some installed
> graphical enviornment?"
>
> NOone does that... :)

Sure, but there the vulnerability is (IMO) that users are allowed to
arbitrarily mount stuff.  That's a huge attack surface and this fix
only scratches the surface.

We do need to make filesystems more resilient to malice.  AFL?

Best,
Conrad
___
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"


Re: svn commit: r298664 - head/sys/fs/msdosfs

2016-04-26 Thread Shawn Webb
On Tue, Apr 26, 2016 at 11:05:38PM +0200, Kristof Provost wrote:
> 
> > On 26 Apr 2016, at 23:01, Shawn Webb  wrote:
> > 
> > On Tue, Apr 26, 2016 at 08:36:32PM +, Kristof Provost wrote:
> >> Author: kp
> >> Date: Tue Apr 26 20:36:32 2016
> >> New Revision: 298664
> >> URL: https://svnweb.freebsd.org/changeset/base/298664
> >> 
> >> Log:
> >>  msdosfs: Prevent buffer overflow when expanding win95 names
> >> 
> >>  In win2unixfn() we expand Windows 95 style long names. In some cases that
> >>  requires moving the data in the nbp->nb_buf buffer backwards to make 
> >> room. That
> >>  code failed to check for overflows, leading to a stack overflow in 
> >> win2unixfn().
> >> 
> >>  We now check for this event, and mark the entire conversion as failed in 
> >> that
> >>  case. This means we present the 8 character, dos style, name instead.
> >> 
> >>  PR: 204643
> >>  Differential Revision:https://reviews.freebsd.org/D6015
> > 
> > Will this be MFC'd? Since it's triggerable as non-root, should this have
> > a CVE? Though the commit log shows technical comments, it doesn't show
> > related security information.
> 
> Yes, I???ll put MFCing this on my todo list.
> 
> I have to admit that I???ve not given the security implications much thought. 
> The bug has always been caught by the stack canary on my test systems, 
> without that it could potentially be quite dangerous.
> (Given constraints of having to be able to mount arbitrary file systems as 
> non-root of course.)
> 
> Regards,
> Kristof

Was secteam@ even involved, then? Seems like a user-facing kernel buffer
overflow ought to have involved secteam@.

Also, the differential revision link you posted is incorrect.

Thanks,

-- 
Shawn Webb
HardenedBSD

GPG Key ID:  0x6A84658F52456EEE
GPG Key Fingerprint: 2ABA B6BD EF6A F486 BE89  3D9E 6A84 658F 5245 6EEE


signature.asc
Description: PGP signature


svn commit: r298668 - head/sys/kern

2016-04-26 Thread Jamie Gritton
Author: jamie
Date: Tue Apr 26 21:19:12 2016
New Revision: 298668
URL: https://svnweb.freebsd.org/changeset/base/298668

Log:
  Use crcopysafe in jail_attach.

Modified:
  head/sys/kern/kern_jail.c

Modified: head/sys/kern/kern_jail.c
==
--- head/sys/kern/kern_jail.c   Tue Apr 26 21:11:52 2016(r298667)
+++ head/sys/kern/kern_jail.c   Tue Apr 26 21:19:12 2016(r298668)
@@ -2405,7 +2405,6 @@ sys_jail_attach(struct thread *td, struc
 static int
 do_jail_attach(struct thread *td, struct prison *pr)
 {
-   struct prison *ppr;
struct proc *p;
struct ucred *newcred, *oldcred;
int error;
@@ -2433,7 +2432,6 @@ do_jail_attach(struct thread *td, struct
/*
 * Reparent the newly attached process to this jail.
 */
-   ppr = td->td_ucred->cr_prison;
p = td->td_proc;
error = cpuset_setproc_update_set(p, pr->pr_cpuset);
if (error)
@@ -2452,23 +2450,23 @@ do_jail_attach(struct thread *td, struct
 
newcred = crget();
PROC_LOCK(p);
-   oldcred = p->p_ucred;
-   setsugid(p);
-   crcopy(newcred, oldcred);
+   oldcred = crcopysafe(p, newcred);
newcred->cr_prison = pr;
proc_set_cred(p, newcred);
+   setsugid(p);
PROC_UNLOCK(p);
 #ifdef RACCT
racct_proc_ucred_changed(p, oldcred, newcred);
 #endif
+   prison_deref(oldcred->cr_prison, PD_DEREF | PD_DEUREF);
crfree(oldcred);
-   prison_deref(ppr, PD_DEREF | PD_DEUREF);
return (0);
+
  e_unlock:
VOP_UNLOCK(pr->pr_root, 0);
  e_revert_osd:
/* Tell modules this thread is still in its old jail after all. */
-   (void)osd_jail_call(ppr, PR_METHOD_ATTACH, td);
+   (void)osd_jail_call(td->td_ucred->cr_prison, PR_METHOD_ATTACH, td);
prison_deref(pr, PD_DEREF | PD_DEUREF);
return (error);
 }
___
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"


Re: svn commit: r298664 - head/sys/fs/msdosfs

2016-04-26 Thread Kristof Provost

> On 26 Apr 2016, at 23:18, Shawn Webb  wrote:
> Was secteam@ even involved, then? Seems like a user-facing kernel buffer
> overflow ought to have involved secteam@.
> 
No, it wasn’t. This bug had been open for quite a while, and I just happend to 
see the report and look at it.

> Also, the differential revision link you posted is incorrect.
You’re right, copy/paste from the wrong phab e-mail.

https://reviews.freebsd.org/D5977  is the 
right one.

Regards,
Kristof


signature.asc
Description: Message signed with OpenPGP using GPGMail


Re: svn commit: r298664 - head/sys/fs/msdosfs

2016-04-26 Thread Shawn Webb
On Tue, Apr 26, 2016 at 11:22:32PM +0200, Kristof Provost wrote:
> 
> > On 26 Apr 2016, at 23:18, Shawn Webb  wrote:
> > Was secteam@ even involved, then? Seems like a user-facing kernel buffer
> > overflow ought to have involved secteam@.
> > 
> No, it wasn???t. This bug had been open for quite a while, and I just happend 
> to see the report and look at it.

Now CC'ing secteam@. I'm wondering if a CVE should be filed. Or, at the
very least, a FreeBSD Security Advisory.

Thanks,

-- 
Shawn Webb
HardenedBSD

GPG Key ID:  0x6A84658F52456EEE
GPG Key Fingerprint: 2ABA B6BD EF6A F486 BE89  3D9E 6A84 658F 5245 6EEE


signature.asc
Description: PGP signature


Re: svn commit: r298664 - head/sys/fs/msdosfs

2016-04-26 Thread Ngie Cooper
On Tue, Apr 26, 2016 at 2:26 PM, Shawn Webb  wrote:
> On Tue, Apr 26, 2016 at 11:22:32PM +0200, Kristof Provost wrote:
>>
>> > On 26 Apr 2016, at 23:18, Shawn Webb  wrote:
>> > Was secteam@ even involved, then? Seems like a user-facing kernel buffer
>> > overflow ought to have involved secteam@.
>> >
>> No, it wasn???t. This bug had been open for quite a while, and I just 
>> happend to see the report and look at it.
>
> Now CC'ing secteam@. I'm wondering if a CVE should be filed. Or, at the
> very least, a FreeBSD Security Advisory.

I've CCed secteam on the bug and added "security" to the keywords.
Thanks,
-Ngie
___
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"


Re: svn commit: r298664 - head/sys/fs/msdosfs

2016-04-26 Thread Shawn Webb
On Tue, Apr 26, 2016 at 11:05:38PM +0200, Kristof Provost wrote:
> 
> > On 26 Apr 2016, at 23:01, Shawn Webb  wrote:
> > 
> > On Tue, Apr 26, 2016 at 08:36:32PM +, Kristof Provost wrote:
> >> Author: kp
> >> Date: Tue Apr 26 20:36:32 2016
> >> New Revision: 298664
> >> URL: https://svnweb.freebsd.org/changeset/base/298664
> >> 
> >> Log:
> >>  msdosfs: Prevent buffer overflow when expanding win95 names
> >> 
> >>  In win2unixfn() we expand Windows 95 style long names. In some cases that
> >>  requires moving the data in the nbp->nb_buf buffer backwards to make 
> >> room. That
> >>  code failed to check for overflows, leading to a stack overflow in 
> >> win2unixfn().
> >> 
> >>  We now check for this event, and mark the entire conversion as failed in 
> >> that
> >>  case. This means we present the 8 character, dos style, name instead.
> >> 
> >>  PR: 204643
> >>  Differential Revision:https://reviews.freebsd.org/D6015
> > 
> > Will this be MFC'd? Since it's triggerable as non-root, should this have
> > a CVE? Though the commit log shows technical comments, it doesn't show
> > related security information.
> 
> Yes, I???ll put MFCing this on my todo list.

When do you plan to MFC?

-- 
Shawn Webb
HardenedBSD

GPG Key ID:  0x6A84658F52456EEE
GPG Key Fingerprint: 2ABA B6BD EF6A F486 BE89  3D9E 6A84 658F 5245 6EEE


signature.asc
Description: PGP signature


Re: svn commit: r298664 - head/sys/fs/msdosfs

2016-04-26 Thread Kristof Provost

> On 26 Apr 2016, at 23:37, Shawn Webb  wrote:
> 
> On Tue, Apr 26, 2016 at 11:05:38PM +0200, Kristof Provost wrote:
>> 
>>> On 26 Apr 2016, at 23:01, Shawn Webb  wrote:
>>> 
>>> On Tue, Apr 26, 2016 at 08:36:32PM +, Kristof Provost wrote:
 Author: kp
 Date: Tue Apr 26 20:36:32 2016
 New Revision: 298664
 URL: https://svnweb.freebsd.org/changeset/base/298664
 
 Log:
 msdosfs: Prevent buffer overflow when expanding win95 names
 
 In win2unixfn() we expand Windows 95 style long names. In some cases that
 requires moving the data in the nbp->nb_buf buffer backwards to make room. 
 That
 code failed to check for overflows, leading to a stack overflow in 
 win2unixfn().
 
 We now check for this event, and mark the entire conversion as failed in 
 that
 case. This means we present the 8 character, dos style, name instead.
 
 PR: 204643
 Differential Revision: https://reviews.freebsd.org/D6015
>>> 
>>> Will this be MFC'd? Since it's triggerable as non-root, should this have
>>> a CVE? Though the commit log shows technical comments, it doesn't show
>>> related security information.
>> 
>> Yes, I???ll put MFCing this on my todo list.
> 
> When do you plan to MFC?

I’d originally planned to do so around Monday, but I can try to do it earlier.
Iirc. the usual minimal period is 3 days, so that’d be Friday evening (for me).

I’m travelling Friday/Saturday/Sunday, so it’s hard to give solid promises.

(Unless secteam judges this to be more urgent of course, in which case I’d be 
happy to do it earlier.)

Regards,
Kristof



signature.asc
Description: Message signed with OpenPGP using GPGMail


svn commit: r298669 - head/sys/dev/iscsi_initiator

2016-04-26 Thread Conrad E. Meyer
Author: cem
Date: Tue Apr 26 21:44:08 2016
New Revision: 298669
URL: https://svnweb.freebsd.org/changeset/base/298669

Log:
  iscsi_initiator(4): Fix use-after-free, double-free
  
  ism_stop() already destroys and frees 'sp', including a call to ic_destroy().
  Don't dereference 'sp' after ism_stop() and don't invoke ic_destroy() on the
  freed memory either.
  
  Reported by:  Coverity
  CIDs: 1006109, 1304861
  Sponsored by: EMC / Isilon Storage Division

Modified:
  head/sys/dev/iscsi_initiator/iscsi.c

Modified: head/sys/dev/iscsi_initiator/iscsi.c
==
--- head/sys/dev/iscsi_initiator/iscsi.cTue Apr 26 21:19:12 2016
(r298668)
+++ head/sys/dev/iscsi_initiator/iscsi.cTue Apr 26 21:44:08 2016
(r298669)
@@ -804,8 +804,6 @@ iscsi_stop(void)
  TAILQ_FOREACH_SAFE(sp, &isc->isc_sess, sp_link, sp_tmp) {
  //XXX: check for activity ...
  ism_stop(sp);
- if(sp->cam_sim != NULL)
-  ic_destroy(sp);
  }
  mtx_destroy(&isc->isc_mtx);
  sx_destroy(&isc->unit_sx);
___
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"


Re: svn commit: r298664 - head/sys/fs/msdosfs

2016-04-26 Thread Oliver Pinter
On 4/26/16, Kristof Provost  wrote:
>
>> On 26 Apr 2016, at 23:37, Shawn Webb  wrote:
>>
>> On Tue, Apr 26, 2016 at 11:05:38PM +0200, Kristof Provost wrote:
>>>
 On 26 Apr 2016, at 23:01, Shawn Webb 
 wrote:

 On Tue, Apr 26, 2016 at 08:36:32PM +, Kristof Provost wrote:
> Author: kp
> Date: Tue Apr 26 20:36:32 2016
> New Revision: 298664
> URL: https://svnweb.freebsd.org/changeset/base/298664
>
> Log:
> msdosfs: Prevent buffer overflow when expanding win95 names
>
> In win2unixfn() we expand Windows 95 style long names. In some cases
> that
> requires moving the data in the nbp->nb_buf buffer backwards to make
> room. That
> code failed to check for overflows, leading to a stack overflow in
> win2unixfn().
>
> We now check for this event, and mark the entire conversion as failed
> in that
> case. This means we present the 8 character, dos style, name instead.
>
> PR: 204643
> Differential Revision:https://reviews.freebsd.org/D6015

 Will this be MFC'd? Since it's triggerable as non-root, should this
 have
 a CVE? Though the commit log shows technical comments, it doesn't show
 related security information.
>>>
>>> Yes, I???ll put MFCing this on my todo list.
>>
>> When do you plan to MFC?
>
> I’d originally planned to do so around Monday, but I can try to do it
> earlier.
> Iirc. the usual minimal period is 3 days, so that’d be Friday evening (for
> me).
>
> I’m travelling Friday/Saturday/Sunday, so it’s hard to give solid promises.
>
> (Unless secteam judges this to be more urgent of course, in which case I’d
> be happy to do it earlier.)

Cool! Thank you Kristof. We test them now in HardenedBSD with more
updates from 11-CURRENT.

https://github.com/HardenedBSD/hardenedBSD/commits/hardened/10-stable/master

>
> Regards,
> Kristof
>
>
___
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"

Re: svn commit: r298669 - head/sys/dev/iscsi_initiator

2016-04-26 Thread Oliver Pinter
On Tue, Apr 26, 2016 at 11:44 PM, Conrad E. Meyer  wrote:
> Author: cem
> Date: Tue Apr 26 21:44:08 2016
> New Revision: 298669
> URL: https://svnweb.freebsd.org/changeset/base/298669
>
> Log:
>   iscsi_initiator(4): Fix use-after-free, double-free
>
>   ism_stop() already destroys and frees 'sp', including a call to 
> ic_destroy().
>   Don't dereference 'sp' after ism_stop() and don't invoke ic_destroy() on the
>   freed memory either.
>
>   Reported by:  Coverity
>   CIDs: 1006109, 1304861
>   Sponsored by: EMC / Isilon Storage Division

MFC of this commit?

>
> Modified:
>   head/sys/dev/iscsi_initiator/iscsi.c
>
> Modified: head/sys/dev/iscsi_initiator/iscsi.c
> ==
> --- head/sys/dev/iscsi_initiator/iscsi.cTue Apr 26 21:19:12 2016  
>   (r298668)
> +++ head/sys/dev/iscsi_initiator/iscsi.cTue Apr 26 21:44:08 2016  
>   (r298669)
> @@ -804,8 +804,6 @@ iscsi_stop(void)
>   TAILQ_FOREACH_SAFE(sp, &isc->isc_sess, sp_link, sp_tmp) {
>   //XXX: check for activity ...
>   ism_stop(sp);
> - if(sp->cam_sim != NULL)
> -  ic_destroy(sp);
>   }
>   mtx_destroy(&isc->isc_mtx);
>   sx_destroy(&isc->unit_sx);
> ___
> 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-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: r298670 - head/sys/dev/ciss

2016-04-26 Thread Conrad E. Meyer
Author: cem
Date: Tue Apr 26 22:01:07 2016
New Revision: 298670
URL: https://svnweb.freebsd.org/changeset/base/298670

Log:
  ciss(4): Fix overrun of array
  
  The softc member 'ciss_logical' is an array of 'ciss_max_logical_bus' members.
  Most of the time it is iterated correctly.  This patch fixes the two instances
  where the driver iterated off the end of the array.
  
  Reported by:  Coverity
  CID:  1305492
  Sponsored by: EMC / Isilon Storage Division

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

Modified: head/sys/dev/ciss/ciss.c
==
--- head/sys/dev/ciss/ciss.cTue Apr 26 21:44:08 2016(r298669)
+++ head/sys/dev/ciss/ciss.cTue Apr 26 22:01:07 2016(r298670)
@@ -1431,7 +1431,7 @@ ciss_init_logical(struct ciss_softc *sc)
goto out;
 }
 
-for (i = 0; i <= sc->ciss_max_logical_bus; i++) {
+for (i = 0; i < sc->ciss_max_logical_bus; i++) {
sc->ciss_logical[i] =
malloc(sc->ciss_cfg->max_logical_supported *
   sizeof(struct ciss_ldrive),
@@ -2030,7 +2030,7 @@ ciss_free(struct ciss_softc *sc)
 if (sc->ciss_parent_dmat)
bus_dma_tag_destroy(sc->ciss_parent_dmat);
 if (sc->ciss_logical) {
-   for (i = 0; i <= sc->ciss_max_logical_bus; i++) {
+   for (i = 0; i < sc->ciss_max_logical_bus; i++) {
for (j = 0; j < sc->ciss_cfg->max_logical_supported; j++) {
if (sc->ciss_logical[i][j].cl_ldrive)
free(sc->ciss_logical[i][j].cl_ldrive, CISS_MALLOC_CLASS);
___
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"


Re: svn commit: r298669 - head/sys/dev/iscsi_initiator

2016-04-26 Thread Conrad Meyer
On Tue, Apr 26, 2016 at 2:59 PM, Oliver Pinter
 wrote:
> On Tue, Apr 26, 2016 at 11:44 PM, Conrad E. Meyer  wrote:
>> Author: cem
>> Date: Tue Apr 26 21:44:08 2016
>> New Revision: 298669
>> URL: https://svnweb.freebsd.org/changeset/base/298669
>> ...
>
> MFC of this commit?

You can do it whenever you want.

Best,
Conrad
___
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"


Re: svn commit: r298664 - head/sys/fs/msdosfs

2016-04-26 Thread Pedro Giffuni



On 04/26/16 16:17, Conrad Meyer wrote:

On Tue, Apr 26, 2016 at 2:13 PM, Adrian Chadd  wrote:

You mean "hotplug mount a malicious USB disk via some installed
graphical enviornment?"

NOone does that... :)


Sure, but there the vulnerability is (IMO) that users are allowed to
arbitrarily mount stuff.  That's a huge attack surface and this fix
only scratches the surface.



This is a plain bug, it may be nasty but not really a security
vulnerability.

If you give physical access to your system to an attacker you
probably have bigger problems than this.


We do need to make filesystems more resilient to malice.  AFL?



That is a good idea.

For reference:

https://lwn.net/Articles/637151/

Cheers,

Pedro.
___
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: r298671 - head/sys/geom/part

2016-04-26 Thread Conrad E. Meyer
Author: cem
Date: Tue Apr 26 22:30:54 2016
New Revision: 298671
URL: https://svnweb.freebsd.org/changeset/base/298671

Log:
  g_part_bsd64: Check for valid on-disk npartitions value
  
  This value is u32 on disk, but assigned to an int in memory.  After we do the
  implicit conversion via assignment, check that the result is at least one[1]
  (non-negative[2]).
  
  1. The subsequent for-loop iterates from gpt_entries minus one, down, until
 reaching zero.  A negative or zero initial index results in undefined 
signed
 integer overflow.
  2. It is also used to index into arrays later.
  
  In practice, we expected non-malicious disks to contain small positive values.
  
  Reported by:  Coverity
  CID:  1223202
  Sponsored by: EMC / Isilon Storage Division

Modified:
  head/sys/geom/part/g_part_bsd64.c

Modified: head/sys/geom/part/g_part_bsd64.c
==
--- head/sys/geom/part/g_part_bsd64.c   Tue Apr 26 22:01:07 2016
(r298670)
+++ head/sys/geom/part/g_part_bsd64.c   Tue Apr 26 22:30:54 2016
(r298671)
@@ -509,7 +509,8 @@ g_part_bsd64_read(struct g_part_table *b
 
dlp = (struct disklabel64 *)buf;
basetable->gpt_entries = le32toh(dlp->d_npartitions);
-   if (basetable->gpt_entries > MAXPARTITIONS64)
+   if (basetable->gpt_entries > MAXPARTITIONS64 ||
+   basetable->gpt_entries < 1)
goto invalid_label;
v32 = le32toh(dlp->d_crc);
dlp->d_crc = 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: r298672 - head/sys/geom/part

2016-04-26 Thread Conrad E. Meyer
Author: cem
Date: Tue Apr 26 22:32:33 2016
New Revision: 298672
URL: https://svnweb.freebsd.org/changeset/base/298672

Log:
  g_part_bsd64: Delete duplicate/dead code
  
  RAW_PART is handled earlier in the loop.
  
  Reported by:  Coverity
  CID:  1223201
  Sponsored by: EMC / Isilon Storage Division

Modified:
  head/sys/geom/part/g_part_bsd64.c

Modified: head/sys/geom/part/g_part_bsd64.c
==
--- head/sys/geom/part/g_part_bsd64.c   Tue Apr 26 22:30:54 2016
(r298671)
+++ head/sys/geom/part/g_part_bsd64.c   Tue Apr 26 22:32:33 2016
(r298672)
@@ -563,8 +563,6 @@ g_part_bsd64_read(struct g_part_table *b
le_uuid_dec(&dlp->d_partitions[index].p_stor_uuid,
&entry->stor_uuid);
entry->fstype = dlp->d_partitions[index].p_fstype;
-   if (index == RAW_PART)
-   baseentry->gpe_internal = 1;
}
bcopy(dlp->d_reserved0, table->d_reserved0,
sizeof(table->d_reserved0));
___
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: r298673 - head/sys/netinet

2016-04-26 Thread Conrad E. Meyer
Author: cem
Date: Tue Apr 26 23:02:18 2016
New Revision: 298673
URL: https://svnweb.freebsd.org/changeset/base/298673

Log:
  tcp_usrreq: Free allocated buffer in relock case
  
  The disgusting macro INP_WLOCK_RECHECK may early-return.  In
  tcp_default_ctloutput() the TCP_CCALGOOPT case allocates memory before 
invoking
  this macro, which may leak memory.
  
  Add a _CLEANUP variant that takes a code argument to perform variable cleanup
  in the early return path.  Use it to free the 'pbuf' allocated in
  tcp_default_ctloutput().
  
  I am not especially happy with this macro, but I reckon it's not any worse 
than
  INP_WLOCK_RECHECK already was.
  
  Reported by:  Coverity
  CID:  1350286
  Sponsored by: EMC / Isilon Storage Division

Modified:
  head/sys/netinet/tcp_usrreq.c

Modified: head/sys/netinet/tcp_usrreq.c
==
--- head/sys/netinet/tcp_usrreq.c   Tue Apr 26 22:32:33 2016
(r298672)
+++ head/sys/netinet/tcp_usrreq.c   Tue Apr 26 23:02:18 2016
(r298673)
@@ -1361,14 +1361,16 @@ tcp_fill_info(struct tcpcb *tp, struct t
  * has to revalidate that the connection is still valid for the socket
  * option.
  */
-#define INP_WLOCK_RECHECK(inp) do {\
+#define INP_WLOCK_RECHECK_CLEANUP(inp, cleanup) do {   \
INP_WLOCK(inp); \
if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) {\
INP_WUNLOCK(inp);   \
+   cleanup;\
return (ECONNRESET);\
}   \
tp = intotcpcb(inp);\
 } while(0)
+#define INP_WLOCK_RECHECK(inp) INP_WLOCK_RECHECK_CLEANUP((inp), /* noop */)
 
 int
 tcp_ctloutput(struct socket *so, struct sockopt *sopt)
@@ -1497,7 +1499,7 @@ tcp_default_ctloutput(struct socket *so,
free(pbuf, M_TEMP);
return (error);
}
-   INP_WLOCK_RECHECK(inp);
+   INP_WLOCK_RECHECK_CLEANUP(inp, free(pbuf, M_TEMP));
if (CC_ALGO(tp)->ctl_output != NULL)
error = CC_ALGO(tp)->ctl_output(tp->ccv, sopt, pbuf);
else
@@ -1838,6 +1840,7 @@ unlock_and_done:
return (error);
 }
 #undef INP_WLOCK_RECHECK
+#undef INP_WLOCK_RECHECK_CLEANUP
 
 /*
  * Attach TCP protocol to socket, allocating
___
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: r298674 - in head/sys: boot/fdt/dts/arm dev/cadence

2016-04-26 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Tue Apr 26 23:09:47 2016
New Revision: 298674
URL: https://svnweb.freebsd.org/changeset/base/298674

Log:
  Refactor DTS files for Zynq-based SoCs
  
  - Factor out common part to zynq-7000.dtsi
  - Fix problem with Zynq interrupts by using interrupt "triples"
  in .dtsi file to differentiate between edge-triggered and
  level-triggered interrupts
  - cgem driver now recognizes "status" property
  
  Submitted by: Thomas Skibo 
  Differential Revision:https://reviews.freebsd.org/D6095

Added:
  head/sys/boot/fdt/dts/arm/zynq-7000.dtsi   (contents, props changed)
Modified:
  head/sys/boot/fdt/dts/arm/zedboard.dts
  head/sys/boot/fdt/dts/arm/zybo.dts
  head/sys/dev/cadence/if_cgem.c

Modified: head/sys/boot/fdt/dts/arm/zedboard.dts
==
--- head/sys/boot/fdt/dts/arm/zedboard.dts  Tue Apr 26 23:02:18 2016
(r298673)
+++ head/sys/boot/fdt/dts/arm/zedboard.dts  Tue Apr 26 23:09:47 2016
(r298674)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2012 The FreeBSD Foundation
+ * Copyright (c) 2016 The FreeBSD Foundation
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -25,24 +25,12 @@
  * 
  * $FreeBSD$
  */
-
 /dts-v1/;
+/include/ "zynq-7000.dtsi"
 
 / {
model = "zedboard";
compatible = "digilent,zedboard";
-   #address-cells = <1>;
-   #size-cells = <1>;
-   interrupt-parent = <&GIC>;
-
-   // cpus {
-   //  #address-cells = <1>;
-   //  #size-cells = <0>;
-   //  cpu@0 {
-   //  device-type = "cpu";
-   //  model = "ARM Cortex-A9";
-   //  };
-   // };
 
memory {
// First megabyte isn't accessible by all interconnect masters.
@@ -50,168 +38,34 @@
reg = <0x10 0x1ff0>;/* 511MB RAM at 0x10 */
};
 
-   // Zynq PS System registers.
-   //
-   ps7sys@f800 {
-   device_type = "soc";
-   compatible = "simple-bus";
-   #address-cells = <1>;
-   #size-cells = <1>;
-   ranges = <0x0 0xf800 0xf1>;
-
-   // SLCR block
-   slcr: slcr@7000 {
-   compatible = "xlnx,zy7_slcr";
-   reg = <0x0 0x1000>;
-   clock-frequency = <>; // 33Mhz PS_CLK
-   };
-
-   // Interrupt controller
-   GIC: gic {
-   compatible = "arm,gic";
-   interrupt-controller;
-   #address-cells = <0>;
-   #interrupt-cells = <1>;
-   reg = <0xf01000 0x1000>, // distributer registers
- <0xf00100 0x0100>; // CPU if registers
-   };
-
-   // L2 cache controller
-   pl310@f02000 {
-   compatible = "arm,pl310";
-   reg = <0xf02000 0x1000>;
-   interrupts = <34>;
-   interrupt-parent = <&GIC>;
-   };
-
-   // Device Config
-   devcfg: devcfg@7000 {
-   compatible = "xlnx,zy7_devcfg";
-   reg = <0x7000 0x1000>;
-   interrupts = <40>;
-   interrupt-parent = <&GIC>;
-   };
-
-   // triple timer counters0,1
-   ttc0: ttc@1000 {
-   compatible = "xlnx,ttc";
-   reg = <0x1000 0x1000>;
-   };
-   ttc1: ttc@2000 {
-   compatible = "xlnx,ttc";
-   reg = <0x2000 0x1000>;
-   };
-
-   // ARM Cortex A9 TWD Timer
-   timer@f00600 {
-   compatible = "arm,mpcore-timers";
-   clock-frequency = <3>; // 333Mhz
-   #address-cells = <1>;
-   #size-cells = <0>;
-   reg = <0xf00200 0x100>, // Global Timer Regs
- <0xf00600 0x20>;  // Private Timer Regs
-   interrupts = < 27 29 >;
-   interrupt-parent = <&GIC>;
-   };
-
-   // system watch-dog timer
-   swdt@5000 {
-   device_type = "watchdog";
-   compatible = "xlnx,zy7_wdt";
-   reg = <0x5000 0x1000>;
-   interrupts = <41>;
-   interrupt-parent = <&GIC>;
-   };
-
-   scuwdt@f00620 {
-   device_type = "watchdog";
-   compatible = "arm,mpcore_wdt";
-   reg = <0xf00620 0x20>;
-   interrupts = <30>;
-   interrupt-parent = <&GIC>;
-   

svn commit: r298675 - in head/sys: netinet netinet6

2016-04-26 Thread Conrad E. Meyer
Author: cem
Date: Tue Apr 26 23:13:48 2016
New Revision: 298675
URL: https://svnweb.freebsd.org/changeset/base/298675

Log:
  in_lltable_alloc and in6 copy: Don't leak LLE in error path
  
  Fix a memory leak in error conditions introduced in r292978.
  
  Reported by:  Coverity
  CIDs: 1347009, 1347010
  Sponsored by: EMC / Isilon Storage Division

Modified:
  head/sys/netinet/in.c
  head/sys/netinet6/in6.c

Modified: head/sys/netinet/in.c
==
--- head/sys/netinet/in.c   Tue Apr 26 23:09:47 2016(r298674)
+++ head/sys/netinet/in.c   Tue Apr 26 23:13:48 2016(r298675)
@@ -1004,6 +1004,17 @@ struct in_llentry {
 
 /*
  * Do actual deallocation of @lle.
+ */
+static void
+in_lltable_destroy_lle_unlocked(struct llentry *lle)
+{
+
+   LLE_LOCK_DESTROY(lle);
+   LLE_REQ_DESTROY(lle);
+   free(lle, M_LLTABLE);
+}
+
+/*
  * Called by LLE_FREE_LOCKED when number of references
  * drops to zero.
  */
@@ -1012,9 +1023,7 @@ in_lltable_destroy_lle(struct llentry *l
 {
 
LLE_WUNLOCK(lle);
-   LLE_LOCK_DESTROY(lle);
-   LLE_REQ_DESTROY(lle);
-   free(lle, M_LLTABLE);
+   in_lltable_destroy_lle_unlocked(lle);
 }
 
 static struct llentry *
@@ -1277,8 +1286,10 @@ in_lltable_alloc(struct lltable *llt, u_
if ((flags & LLE_IFADDR) == LLE_IFADDR) {
linkhdrsize = LLE_MAX_LINKHDR;
if (lltable_calc_llheader(ifp, AF_INET, IF_LLADDR(ifp),
-   linkhdr, &linkhdrsize, &lladdr_off) != 0)
+   linkhdr, &linkhdrsize, &lladdr_off) != 0) {
+   in_lltable_destroy_lle_unlocked(lle);
return (NULL);
+   }
lltable_set_entry_addr(ifp, lle, linkhdr, linkhdrsize,
lladdr_off);
lle->la_flags |= LLE_STATIC;

Modified: head/sys/netinet6/in6.c
==
--- head/sys/netinet6/in6.c Tue Apr 26 23:09:47 2016(r298674)
+++ head/sys/netinet6/in6.c Tue Apr 26 23:13:48 2016(r298675)
@@ -2056,6 +2056,17 @@ struct in6_llentry {
 
 /*
  * Do actual deallocation of @lle.
+ */
+static void
+in6_lltable_destroy_lle_unlocked(struct llentry *lle)
+{
+
+   LLE_LOCK_DESTROY(lle);
+   LLE_REQ_DESTROY(lle);
+   free(lle, M_LLTABLE);
+}
+
+/*
  * Called by LLE_FREE_LOCKED when number of references
  * drops to zero.
  */
@@ -2064,9 +2075,7 @@ in6_lltable_destroy_lle(struct llentry *
 {
 
LLE_WUNLOCK(lle);
-   LLE_LOCK_DESTROY(lle);
-   LLE_REQ_DESTROY(lle);
-   free(lle, M_LLTABLE);
+   in6_lltable_destroy_lle_unlocked(lle);
 }
 
 static struct llentry *
@@ -2270,8 +2279,10 @@ in6_lltable_alloc(struct lltable *llt, u
if ((flags & LLE_IFADDR) == LLE_IFADDR) {
linkhdrsize = LLE_MAX_LINKHDR;
if (lltable_calc_llheader(ifp, AF_INET6, IF_LLADDR(ifp),
-   linkhdr, &linkhdrsize, &lladdr_off) != 0)
+   linkhdr, &linkhdrsize, &lladdr_off) != 0) {
+   in6_lltable_destroy_lle_unlocked(lle);
return (NULL);
+   }
lltable_set_entry_addr(ifp, lle, linkhdr, linkhdrsize,
lladdr_off);
lle->la_flags |= LLE_STATIC;
___
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: r298676 - head/sys/netipsec

2016-04-26 Thread Conrad E. Meyer
Author: cem
Date: Tue Apr 26 23:23:44 2016
New Revision: 298676
URL: https://svnweb.freebsd.org/changeset/base/298676

Log:
  netipsec: Don't leak memory when deep copy fails
  
  Reported by:  Coverity
  CID:  1331693
  Sponsored by: EMC / Isilon Storage Division

Modified:
  head/sys/netipsec/ipsec.c

Modified: head/sys/netipsec/ipsec.c
==
--- head/sys/netipsec/ipsec.c   Tue Apr 26 23:13:48 2016(r298675)
+++ head/sys/netipsec/ipsec.c   Tue Apr 26 23:23:44 2016(r298676)
@@ -977,6 +977,7 @@ fail:
ipsec_delisr(p);
p = NULL;
}
+   KEY_FREESP(&dst);
return (NULL);
 }
 
___
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: r298677 - head/sys/kern

2016-04-26 Thread Conrad E. Meyer
Author: cem
Date: Tue Apr 26 23:58:55 2016
New Revision: 298677
URL: https://svnweb.freebsd.org/changeset/base/298677

Log:
  subr_mbpool: Don't free bogus pointer in error paths
  
  An mbpool is allocated with a contiguous array of mbpages.  Freeing an
  individual mbpage has never been valid.  Don't do it.
  
  This bug has been present since this code was introduced in r117624 (2003).
  
  Reported by:  Coverity
  CID:  1009687
  Sponsored by: EMC / Isilon Storage Division

Modified:
  head/sys/kern/subr_mbpool.c

Modified: head/sys/kern/subr_mbpool.c
==
--- head/sys/kern/subr_mbpool.c Tue Apr 26 23:23:44 2016(r298676)
+++ head/sys/kern/subr_mbpool.c Tue Apr 26 23:58:55 2016(r298677)
@@ -210,16 +210,13 @@ mbp_alloc_page(struct mbpool *p)
pg = &p->pages[p->npages];
 
error = bus_dmamem_alloc(p->dmat, &pg->va, BUS_DMA_NOWAIT, &pg->map);
-   if (error != 0) {
-   free(pg, M_MBPOOL);
+   if (error != 0)
return;
-   }
 
error = bus_dmamap_load(p->dmat, pg->map, pg->va, p->page_size,
mbp_callback, &pg->phy, 0);
if (error != 0) {
bus_dmamem_free(p->dmat, pg->va, pg->map);
-   free(pg, M_MBPOOL);
return;
}
 
___
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: r298678 - head/sys/kern

2016-04-26 Thread Conrad E. Meyer
Author: cem
Date: Wed Apr 27 00:10:32 2016
New Revision: 298678
URL: https://svnweb.freebsd.org/changeset/base/298678

Log:
  posix4_mib: Don't overrun facility_initialized array
  
  The facility_initialized and facility arrays are the same size and were
  intended to be indexed the same.  I believe this mismatch was just a
  typo/braino in r208731.
  
  Reported by:  Coverity
  CID:  1017430
  Sponsored by: EMC / Isilon Storage Division

Modified:
  head/sys/kern/posix4_mib.c

Modified: head/sys/kern/posix4_mib.c
==
--- head/sys/kern/posix4_mib.c  Tue Apr 26 23:58:55 2016(r298677)
+++ head/sys/kern/posix4_mib.c  Wed Apr 27 00:10:32 2016(r298678)
@@ -113,9 +113,9 @@ p31b_sysctl_proc(SYSCTL_HANDLER_ARGS)
num = arg2;
if (!P31B_VALID(num))
return (EINVAL);
-   val = facility_initialized[num] ? facility[num - 1] : 0;
+   val = facility_initialized[num - 1] ? facility[num - 1] : 0;
error = sysctl_handle_int(oidp, &val, 0, req);
-   if (error == 0 && req->newptr != NULL && facility_initialized[num])
+   if (error == 0 && req->newptr != NULL && facility_initialized[num - 1])
facility[num - 1] = val;
return (error);
 }
@@ -137,7 +137,7 @@ p31b_unsetcfg(int num)
 {
 
facility[num - 1] = 0;
-   facility_initialized[num -1] = 0;
+   facility_initialized[num - 1] = 0;
 }
 
 int
___
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: r298679 - head/sbin/fsck_ffs

2016-04-26 Thread Pedro F. Giffuni
Author: pfg
Date: Wed Apr 27 01:32:11 2016
New Revision: 298679
URL: https://svnweb.freebsd.org/changeset/base/298679

Log:
  fsck_ffs: Revert partially the unsigned changes.
  
  Any value of uint16_t will be internally promoted to int so
  changing them to an unsigned value doesn't help.
  
  Make clear we want to use uint32_t for closedisk()
  
  X-MFC with:   r298551

Modified:
  head/sbin/fsck_ffs/suj.c

Modified: head/sbin/fsck_ffs/suj.c
==
--- head/sbin/fsck_ffs/suj.cWed Apr 27 00:10:32 2016(r298678)
+++ head/sbin/fsck_ffs/suj.cWed Apr 27 01:32:11 2016(r298679)
@@ -217,7 +217,7 @@ static void
 closedisk(const char *devnam)
 {
struct csum *cgsum;
-   u_int i;
+   uint32_t i;
 
/*
 * Recompute the fs summary info from correct cs summaries.
@@ -2252,7 +2252,7 @@ suj_build(void)
struct suj_seg *seg;
union jrec *rec;
int off;
-   u_int i;
+   int i;
 
TAILQ_FOREACH(seg, &allsegs, ss_next) {
if (debug)
@@ -2540,7 +2540,7 @@ suj_read(void)
struct jsegrec *rec;
ufs2_daddr_t blk;
int readsize;
-   u_int blocks;
+   int blocks;
int recsize;
int size;
u_int i;
___
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: r298680 - head/sbin/fsck_ffs

2016-04-26 Thread Pedro F. Giffuni
Author: pfg
Date: Wed Apr 27 01:36:25 2016
New Revision: 298680
URL: https://svnweb.freebsd.org/changeset/base/298680

Log:
  fsck_ffs: Revert partially the unsigned changes.
  
  Any value of uint16_t will be internally promoted to int so
  changing them to an unsigned value doesn't help.
  
  Missing revert value in suj_read().
  
  X-MFC with:   r298551

Modified:
  head/sbin/fsck_ffs/suj.c

Modified: head/sbin/fsck_ffs/suj.c
==
--- head/sbin/fsck_ffs/suj.cWed Apr 27 01:32:11 2016(r298679)
+++ head/sbin/fsck_ffs/suj.cWed Apr 27 01:36:25 2016(r298680)
@@ -2543,7 +2543,7 @@ suj_read(void)
int blocks;
int recsize;
int size;
-   u_int i;
+   int i;
 
/*
 * Read records until we exhaust the journal space.  If we find
___
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: r298681 - head/sbin/ifconfig

2016-04-26 Thread Marcelo Araujo
Author: araujo
Date: Wed Apr 27 02:02:44 2016
New Revision: 298681
URL: https://svnweb.freebsd.org/changeset/base/298681

Log:
  Use macro MIN() from sys/param.h.
  
  MFC after:2 weeks.

Modified:
  head/sbin/ifconfig/sfp.c

Modified: head/sbin/ifconfig/sfp.c
==
--- head/sbin/ifconfig/sfp.cWed Apr 27 01:36:25 2016(r298680)
+++ head/sbin/ifconfig/sfp.cWed Apr 27 02:02:44 2016(r298681)
@@ -738,7 +738,7 @@ read_i2c(struct i2c_info *ii, uint8_t ad
req.len = len;
 
while (len > 0) {
-   l = (len > sizeof(req.data)) ? sizeof(req.data) : len;
+   l = MIN(sizeof(req.data), len);
req.len = l;
if (ioctl(ii->fd, SIOCGI2C, ii->ifr) != 0) {
ii->error = errno;
@@ -762,7 +762,7 @@ dump_i2c_data(struct i2c_info *ii, uint8
 
while (len > 0) {
memset(buf, 0, sizeof(buf));
-   read = (len > sizeof(buf)) ? sizeof(buf) : len;
+   read = MIN(sizeof(buf), len);
read_i2c(ii, addr, off, read, buf);
if (ii->error != 0) {
fprintf(stderr, "Error reading i2c info\n");
___
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: r298682 - head/usr.bin/quota

2016-04-26 Thread Marcelo Araujo
Author: araujo
Date: Wed Apr 27 02:13:57 2016
New Revision: 298682
URL: https://svnweb.freebsd.org/changeset/base/298682

Log:
  Use MIN() macro from sys/param.h.
  
  MFC after:2 weeks.

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

Modified: head/usr.bin/quota/quota.c
==
--- head/usr.bin/quota/quota.c  Wed Apr 27 02:02:44 2016(r298681)
+++ head/usr.bin/quota/quota.c  Wed Apr 27 02:13:57 2016(r298682)
@@ -266,8 +266,8 @@ prthumanval(int len, u_int64_t bytes)
/*
 * Limit the width to 5 bytes as that is what users expect.
 */
-   humanize_number(buf, sizeof(buf) < 5 ? sizeof(buf) : 5, bytes, "",
-   HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL);
+   humanize_number(buf, MIN(sizeof(buf), 5), bytes, "",
+   HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL);
 
(void)printf(" %*s", len, buf);
 }
___
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: r298683 - in head/sys: kern sys

2016-04-26 Thread Jamie Gritton
Author: jamie
Date: Wed Apr 27 02:25:21 2016
New Revision: 298683
URL: https://svnweb.freebsd.org/changeset/base/298683

Log:
  Delay revmoing the last jail reference in prison_proc_free, and instead
  put it off into the pr_task.  This is similar to prison_free, and in fact
  uses the same task even though they do something slightly different.
  
  This resolves a LOR between the process lock and allprison_lock, which
  came about in r298565.
  
  PR:   48471

Modified:
  head/sys/kern/kern_jail.c
  head/sys/sys/jail.h

Modified: head/sys/kern/kern_jail.c
==
--- head/sys/kern/kern_jail.c   Wed Apr 27 02:13:57 2016(r298682)
+++ head/sys/kern/kern_jail.c   Wed Apr 27 02:25:21 2016(r298683)
@@ -1328,6 +1328,7 @@ kern_jail_set(struct thread *td, struct 
 
LIST_INIT(&pr->pr_children);
mtx_init(&pr->pr_mtx, "jail mutex", NULL, MTX_DEF | MTX_DUPOK);
+   TASK_INIT(&pr->pr_task, 0, prison_complete, pr);
 
 #ifdef VIMAGE
/* Allocate a new vnet if specified. */
@@ -2575,16 +2576,13 @@ prison_allow(struct ucred *cred, unsigne
 void
 prison_free_locked(struct prison *pr)
 {
+   int ref;
 
mtx_assert(&pr->pr_mtx, MA_OWNED);
-   pr->pr_ref--;
-   if (pr->pr_ref == 0) {
-   mtx_unlock(&pr->pr_mtx);
-   TASK_INIT(&pr->pr_task, 0, prison_complete, pr);
-   taskqueue_enqueue(taskqueue_thread, &pr->pr_task);
-   return;
-   }
+   ref = --pr->pr_ref;
mtx_unlock(&pr->pr_mtx);
+   if (ref == 0)
+   taskqueue_enqueue(taskqueue_thread, &pr->pr_task);
 }
 
 void
@@ -2595,11 +2593,17 @@ prison_free(struct prison *pr)
prison_free_locked(pr);
 }
 
+/*
+ * Complete a call to either prison_free or prison_proc_free.
+ */
 static void
 prison_complete(void *context, int pending)
 {
+   struct prison *pr = context;
 
-   prison_deref((struct prison *)context, 0);
+   mtx_lock(&pr->pr_mtx);
+   prison_deref(pr, pr->pr_uref
+   ? PD_DEREF | PD_DEUREF | PD_LOCKED : PD_LOCKED);
 }
 
 /*
@@ -2618,6 +2622,9 @@ prison_deref(struct prison *pr, int flag
mtx_lock(&pr->pr_mtx);
for (;;) {
if (flags & PD_DEUREF) {
+   KASSERT(pr->pr_uref > 0,
+   ("prison_deref PD_DEUREF on a dead prison (jid=%d)",
+pr->pr_id));
pr->pr_uref--;
lasturef = pr->pr_uref == 0;
if (lasturef)
@@ -2625,8 +2632,12 @@ prison_deref(struct prison *pr, int flag
KASSERT(prison0.pr_uref != 0, ("prison0 pr_uref=0"));
} else
lasturef = 0;
-   if (flags & PD_DEREF)
+   if (flags & PD_DEREF) {
+   KASSERT(pr->pr_ref > 0,
+   ("prison_deref PD_DEREF on a dead prison (jid=%d)",
+pr->pr_id));
pr->pr_ref--;
+   }
ref = pr->pr_ref;
mtx_unlock(&pr->pr_mtx);
 
@@ -2740,7 +2751,20 @@ prison_proc_free(struct prison *pr)
mtx_lock(&pr->pr_mtx);
KASSERT(pr->pr_uref > 0,
("Trying to kill a process in a dead prison (jid=%d)", pr->pr_id));
-   prison_deref(pr, PD_DEUREF | PD_LOCKED);
+   if (pr->pr_uref > 1)
+   pr->pr_uref--;
+   else {
+   /*
+* Don't remove the last user reference in this context, which
+* is expected to be a process that is not only locked, but
+* also half dead.
+*/
+   pr->pr_ref++;
+   mtx_unlock(&pr->pr_mtx);
+   taskqueue_enqueue(taskqueue_thread, &pr->pr_task);
+   return;
+   }
+   mtx_unlock(&pr->pr_mtx);
 }
 
 

Modified: head/sys/sys/jail.h
==
--- head/sys/sys/jail.h Wed Apr 27 02:13:57 2016(r298682)
+++ head/sys/sys/jail.h Wed Apr 27 02:25:21 2016(r298683)
@@ -149,7 +149,6 @@ struct prison_racct;
  *   (p) locked by pr_mtx
  *   (c) set only during creation before the structure is shared, no mutex
  *   required to read
- *   (d) set only during destruction of jail, no mutex needed
  */
 struct prison {
TAILQ_ENTRY(prison) pr_list;/* (a) all prisons */
@@ -161,7 +160,7 @@ struct prison {
LIST_ENTRY(prison) pr_sibling;  /* (a) next in parent's 
list */
struct prison   *pr_parent; /* (c) containing jail 
*/
struct mtx   pr_mtx;
-   struct task  pr_task;   /* (d) destroy task */
+   struct task  pr_task;   /* (c) destroy task */
struct osd   pr_osd; 

svn commit: r298684 - head/usr.bin/systat

2016-04-26 Thread Marcelo Araujo
Author: araujo
Date: Wed Apr 27 02:26:31 2016
New Revision: 298684
URL: https://svnweb.freebsd.org/changeset/base/298684

Log:
  Use macro MIN() from sys/param.h.
  
  MFC after:2 weeks.

Modified:
  head/usr.bin/systat/main.c

Modified: head/usr.bin/systat/main.c
==
--- head/usr.bin/systat/main.c  Wed Apr 27 02:25:21 2016(r298683)
+++ head/usr.bin/systat/main.c  Wed Apr 27 02:26:31 2016(r298684)
@@ -276,7 +276,7 @@ display(void)
c = '|';
dellave = avenrun[0];
wmove(wload, 0, 0); wclrtoeol(wload);
-   for (i = (j > 50) ? 50 : j; i > 0; i--)
+   for (i = MIN(j, 50); i > 0; i--)
waddch(wload, c);
if (j > 50)
wprintw(wload, " %4.1f", avenrun[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: r298685 - head/usr.bin/tftp

2016-04-26 Thread Marcelo Araujo
Author: araujo
Date: Wed Apr 27 02:34:25 2016
New Revision: 298685
URL: https://svnweb.freebsd.org/changeset/base/298685

Log:
  Use MIN() macro from sys/param.h.
  
  MFC after:2 weeks.

Modified:
  head/usr.bin/tftp/main.c

Modified: head/usr.bin/tftp/main.c
==
--- head/usr.bin/tftp/main.cWed Apr 27 02:26:31 2016(r298684)
+++ head/usr.bin/tftp/main.cWed Apr 27 02:34:25 2016(r298685)
@@ -727,7 +727,7 @@ command(void)
if (vrbose) {
 if ((bp = el_gets(el, &num)) == NULL || num == 0)
 exit(0);
-len = (num > MAXLINE) ? MAXLINE : num;
+len = MIN(MAXLINE, num);
 memcpy(line, bp, len);
 line[len] = '\0';
 history(hist, &he, H_ENTER, bp);
___
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: r298686 - head/usr.bin/top

2016-04-26 Thread Marcelo Araujo
Author: araujo
Date: Wed Apr 27 02:44:10 2016
New Revision: 298686
URL: https://svnweb.freebsd.org/changeset/base/298686

Log:
  Use MIN() macro from sys/param.h.
  
  MFC after:2 weeks.

Modified:
  head/usr.bin/top/machine.c

Modified: head/usr.bin/top/machine.c
==
--- head/usr.bin/top/machine.c  Wed Apr 27 02:34:25 2016(r298685)
+++ head/usr.bin/top/machine.c  Wed Apr 27 02:44:10 2016(r298686)
@@ -1023,7 +1023,7 @@ format_next_process(caddr_t handle, char
continue;
len = (argbuflen - (dst - argbuf) - 1) / 4;
strvisx(dst, src,
-   strlen(src) < len ? strlen(src) : len,
+   MIN(strlen(src), len),
VIS_NL | VIS_CSTYLE);
while (*dst != '\0')
dst++;
___
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: r298687 - head/usr.sbin/config

2016-04-26 Thread Marcelo Araujo
Author: araujo
Date: Wed Apr 27 03:06:53 2016
New Revision: 298687
URL: https://svnweb.freebsd.org/changeset/base/298687

Log:
  For pointers use NULL instead of 0.
  
  Reviewed by:  rpaulo
  MFC after:2 weeks.
  Differential Revision:https://reviews.freebsd.org/D5946

Modified:
  head/usr.sbin/config/mkmakefile.c
  head/usr.sbin/config/mkoptions.c

Modified: head/usr.sbin/config/mkmakefile.c
==
--- head/usr.sbin/config/mkmakefile.c   Wed Apr 27 02:44:10 2016
(r298686)
+++ head/usr.sbin/config/mkmakefile.c   Wed Apr 27 03:06:53 2016
(r298687)
@@ -111,11 +111,11 @@ open_makefile_template(void)
 
snprintf(line, sizeof(line), "../../conf/Makefile.%s", machinename);
ifp = fopen(line, "r");
-   if (ifp == 0) {
+   if (ifp == NULL) {
snprintf(line, sizeof(line), "Makefile.%s", machinename);
ifp = fopen(line, "r");
}
-   if (ifp == 0)
+   if (ifp == NULL)
err(1, "%s", line);
return (ifp);
 }
@@ -133,7 +133,7 @@ makefile(void)
read_files();
ifp = open_makefile_template();
ofp = fopen(path("Makefile.new"), "w");
-   if (ofp == 0)
+   if (ofp == NULL)
err(1, "%s", path("Makefile.new"));
fprintf(ofp, "KERN_IDENT=%s\n", ident);
fprintf(ofp, "MACHINE=%s\n", machinename);
@@ -313,7 +313,7 @@ read_file(char *fname)
imp_rule, no_obj, before_depend, nowerror;
 
fp = fopen(fname, "r");
-   if (fp == 0)
+   if (fp == NULL)
err(1, "%s", fname);
 next:
/*
@@ -330,7 +330,7 @@ next:
(void) fclose(fp);
return;
} 
-   if (wd == 0)
+   if (wd == NULL)
goto next;
if (wd[0] == '#')
{
@@ -340,7 +340,7 @@ next:
}
if (eq(wd, "include")) {
wd = get_quoted_word(fp);
-   if (wd == (char *)EOF || wd == 0)
+   if (wd == (char *)EOF || wd == NULL)
errout("%s: missing include filename.\n", fname);
(void) snprintf(ifname, sizeof(ifname), "../../%s", wd);
read_file(ifname);
@@ -352,7 +352,7 @@ next:
wd = get_word(fp);
if (wd == (char *)EOF)
return;
-   if (wd == 0)
+   if (wd == NULL)
errout("%s: No type for %s.\n", fname, this);
tp = fl_lookup(this);
compile = 0;
@@ -396,7 +396,7 @@ next:
continue;
}
if (eq(wd, "no-implicit-rule")) {
-   if (compilewith == 0)
+   if (compilewith == NULL)
errout("%s: alternate rule required when "
   "\"no-implicit-rule\" is specified for"
   " %s.\n",
@@ -410,7 +410,7 @@ next:
}
if (eq(wd, "dependency")) {
wd = get_quoted_word(fp);
-   if (wd == (char *)EOF || wd == 0)
+   if (wd == (char *)EOF || wd == NULL)
errout("%s: %s missing dependency string.\n",
   fname, this);
depends = ns(wd);
@@ -418,7 +418,7 @@ next:
}
if (eq(wd, "clean")) {
wd = get_quoted_word(fp);
-   if (wd == (char *)EOF || wd == 0)
+   if (wd == (char *)EOF || wd == NULL)
errout("%s: %s missing clean file list.\n",
   fname, this);
clean = ns(wd);
@@ -426,7 +426,7 @@ next:
}
if (eq(wd, "compile-with")) {
wd = get_quoted_word(fp);
-   if (wd == (char *)EOF || wd == 0)
+   if (wd == (char *)EOF || wd == NULL)
errout("%s: %s missing compile command 
string.\n",
   fname, this);
compilewith = ns(wd);
@@ -434,7 +434,7 @@ next:
}
if (eq(wd, "warning")) {
wd = get_quoted_word(fp);
-   if (wd == (char *)EOF || wd == 0)
+   if (wd == (char *)EOF || wd == NULL)
errout("%s: %s missing warning text string.\n",
   fname, this);
warning = ns(wd);
@@ -442,7 +442,7 @@ next:
}
if (eq(wd, "obj-prefix")) {
wd = get_quoted_word(fp);
-   if (wd == (char *)EOF || wd == 0)
+   if (wd == (char *)EOF || wd == NULL)
errout("%s: %s missing

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

2016-04-26 Thread Sepherosa Ziehau
Author: sephe
Date: Wed Apr 27 04:51:28 2016
New Revision: 298688
URL: https://svnweb.freebsd.org/changeset/base/298688

Log:
  hyperv/hn: Restart sending earlier once we gathered some free TX descs
  
  This greatly reduces the oqdrops under heavy workload.
  
  For TCP send/recv test (10K concurrent connections):
  oqdrops is reduced by 17% on sending side, and 57% on receiving side.
  
  For nginx-1.8/wrk-4 1KB object test (10K concurrent connections,
  4 requests/connection):
  oqdrops is reduced by 44% on nginx side, and 10% on wrk side.
  
  MFC after:1 week
  Sponsored by: Microsoft OSTC

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

Modified: head/sys/dev/hyperv/netvsc/hv_net_vsc.h
==
--- head/sys/dev/hyperv/netvsc/hv_net_vsc.h Wed Apr 27 03:06:53 2016
(r298687)
+++ head/sys/dev/hyperv/netvsc/hv_net_vsc.h Wed Apr 27 04:51:28 2016
(r298688)
@@ -1185,7 +1185,8 @@ struct hn_tx_ring {
 #endif
int hn_txdesc_cnt;
int hn_txdesc_avail;
-   int hn_has_txeof;
+   u_short hn_has_txeof;
+   u_short hn_txdone_cnt;
 
int hn_sched_tx;
void(*hn_txeof)(struct hn_tx_ring *);

Modified: head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
==
--- head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c  Wed Apr 27 03:06:53 
2016(r298687)
+++ head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c  Wed Apr 27 04:51:28 
2016(r298688)
@@ -155,6 +155,8 @@ __FBSDID("$FreeBSD$");
 
 #define HN_DIRECT_TX_SIZE_DEF  128
 
+#define HN_EARLY_TXEOF_THRESH  8
+
 struct hn_txdesc {
 #ifndef HN_USE_TXDESC_BUFRING
SLIST_ENTRY(hn_txdesc) link;
@@ -793,6 +795,13 @@ hn_txdesc_hold(struct hn_txdesc *txd)
atomic_add_int(&txd->refs, 1);
 }
 
+static __inline void
+hn_txeof(struct hn_tx_ring *txr)
+{
+   txr->hn_has_txeof = 0;
+   txr->hn_txeof(txr);
+}
+
 static void
 hn_tx_done(struct hv_vmbus_channel *chan, void *xpkt)
 {
@@ -811,6 +820,13 @@ hn_tx_done(struct hv_vmbus_channel *chan
 
txr->hn_has_txeof = 1;
hn_txdesc_put(txr, txd);
+
+   ++txr->hn_txdone_cnt;
+   if (txr->hn_txdone_cnt >= HN_EARLY_TXEOF_THRESH) {
+   txr->hn_txdone_cnt = 0;
+   if (txr->hn_oactive)
+   hn_txeof(txr);
+   }
 }
 
 void
@@ -831,8 +847,8 @@ netvsc_channel_rollup(struct hv_vmbus_ch
if (txr == NULL || !txr->hn_has_txeof)
return;
 
-   txr->hn_has_txeof = 0;
-   txr->hn_txeof(txr);
+   txr->hn_txdone_cnt = 0;
+   hn_txeof(txr);
 }
 
 /*
___
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: r298689 - head/sys/dev/hyperv/netvsc

2016-04-26 Thread Sepherosa Ziehau
Author: sephe
Date: Wed Apr 27 05:05:54 2016
New Revision: 298689
URL: https://svnweb.freebsd.org/changeset/base/298689

Log:
  hyperv/hn: Remove unapplied comment.
  
  Chimney sending buffers are shared across channels.
  
  MFC after:1 week
  Sponsored by: Microsoft OSTC

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

Modified: head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
==
--- head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c  Wed Apr 27 04:51:28 
2016(r298688)
+++ head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c  Wed Apr 27 05:05:54 
2016(r298689)
@@ -998,8 +998,6 @@ hn_encap(struct hn_tx_ring *txr, struct 
 
/*
 * Chimney send, if the packet could fit into one chimney buffer.
-*
-* TODO: vRSS, chimney buffer should be per-channel.
 */
if (packet->tot_data_buf_len < txr->hn_tx_chimney_size) {
netvsc_dev *net_dev = txr->hn_sc->net_dev;
___
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: r298690 - head/sys/dev/hyperv/netvsc

2016-04-26 Thread Sepherosa Ziehau
Author: sephe
Date: Wed Apr 27 05:18:04 2016
New Revision: 298690
URL: https://svnweb.freebsd.org/changeset/base/298690

Log:
  hyperv/hn: Mark sysctls MPSAFE
  
  MFC after:1 week
  Sponsored by: Microsoft OSTC

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

Modified: head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
==
--- head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c  Wed Apr 27 05:05:54 
2016(r298689)
+++ head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c  Wed Apr 27 05:18:04 
2016(r298690)
@@ -214,7 +214,8 @@ struct hn_txdesc {
 
 int hv_promisc_mode = 0;/* normal mode by default */
 
-SYSCTL_NODE(_hw, OID_AUTO, hn, CTLFLAG_RD, NULL, "Hyper-V network interface");
+SYSCTL_NODE(_hw, OID_AUTO, hn, CTLFLAG_RD | CTLFLAG_MPSAFE, NULL,
+"Hyper-V network interface");
 
 /* Trust tcp segements verification on host side. */
 static int hn_trust_hosttcp = 1;
@@ -2170,7 +2171,7 @@ hn_create_rx_data(struct hn_softc *sc, i
 
/* Create dev.hn.UNIT.rx sysctl tree */
sc->hn_rx_sysctl_tree = SYSCTL_ADD_NODE(ctx, child, OID_AUTO, "rx",
-   CTLFLAG_RD, 0, "");
+   CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "");
 
for (i = 0; i < sc->hn_rx_ring_cnt; ++i) {
struct hn_rx_ring *rxr = &sc->hn_rx_ring[i];
@@ -2210,7 +2211,7 @@ hn_create_rx_data(struct hn_softc *sc, i
snprintf(name, sizeof(name), "%d", i);
rxr->hn_rx_sysctl_tree = SYSCTL_ADD_NODE(ctx,
SYSCTL_CHILDREN(sc->hn_rx_sysctl_tree),
-   OID_AUTO, name, CTLFLAG_RD, 0, "");
+   OID_AUTO, name, CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "");
 
if (rxr->hn_rx_sysctl_tree != NULL) {
SYSCTL_ADD_ULONG(ctx,
@@ -,59 +2223,61 @@ hn_create_rx_data(struct hn_softc *sc, i
}
 
SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "lro_queued",
-   CTLTYPE_U64 | CTLFLAG_RW, sc,
+   CTLTYPE_U64 | CTLFLAG_RW | CTLFLAG_MPSAFE, sc,
__offsetof(struct hn_rx_ring, hn_lro.lro_queued),
hn_rx_stat_u64_sysctl, "LU", "LRO queued");
SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "lro_flushed",
-   CTLTYPE_U64 | CTLFLAG_RW, sc,
+   CTLTYPE_U64 | CTLFLAG_RW | CTLFLAG_MPSAFE, sc,
__offsetof(struct hn_rx_ring, hn_lro.lro_flushed),
hn_rx_stat_u64_sysctl, "LU", "LRO flushed");
SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "lro_tried",
-   CTLTYPE_ULONG | CTLFLAG_RW, sc,
+   CTLTYPE_ULONG | CTLFLAG_RW | CTLFLAG_MPSAFE, sc,
__offsetof(struct hn_rx_ring, hn_lro_tried),
hn_rx_stat_ulong_sysctl, "LU", "# of LRO tries");
 #if __FreeBSD_version >= 1100099
SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "lro_length_lim",
-   CTLTYPE_UINT | CTLFLAG_RW, sc, 0, hn_lro_lenlim_sysctl, "IU",
+   CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_MPSAFE, sc, 0,
+   hn_lro_lenlim_sysctl, "IU",
"Max # of data bytes to be aggregated by LRO");
SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "lro_ackcnt_lim",
-   CTLTYPE_INT | CTLFLAG_RW, sc, 0, hn_lro_ackcnt_sysctl, "I",
+   CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, sc, 0,
+   hn_lro_ackcnt_sysctl, "I",
"Max # of ACKs to be aggregated by LRO");
 #endif
SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "trust_hosttcp",
-   CTLTYPE_INT | CTLFLAG_RW, sc, HN_TRUST_HCSUM_TCP,
+   CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, sc, HN_TRUST_HCSUM_TCP,
hn_trust_hcsum_sysctl, "I",
"Trust tcp segement verification on host side, "
"when csum info is missing");
SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "trust_hostudp",
-   CTLTYPE_INT | CTLFLAG_RW, sc, HN_TRUST_HCSUM_UDP,
+   CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, sc, HN_TRUST_HCSUM_UDP,
hn_trust_hcsum_sysctl, "I",
"Trust udp datagram verification on host side, "
"when csum info is missing");
SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "trust_hostip",
-   CTLTYPE_INT | CTLFLAG_RW, sc, HN_TRUST_HCSUM_IP,
+   CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, sc, HN_TRUST_HCSUM_IP,
hn_trust_hcsum_sysctl, "I",
"Trust ip packet verification on host side, "
"when csum info is missing");
SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "csum_ip",
-   CTLTYPE_ULONG | CTLFLAG_RW, sc,
+   CTLTYPE_ULONG | CTLFLAG_RW | CTLFLAG_MPSAFE, sc,
__offsetof(struct hn_rx_ring, hn_csum_ip),
hn_rx_stat_ulong_sysctl, "LU", "RXCSUM IP");
SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "csum_tcp",
-   CTLTYPE_ULONG | CTLFLAG_RW, sc,
+   CTLTYPE_ULONG | CTLFLAG_RW | CTLFLAG_MPSAFE, sc,
__offsetof(struct hn_rx_ring, hn_csum_tcp),
h

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

2016-04-26 Thread Sepherosa Ziehau
Author: sephe
Date: Wed Apr 27 05:45:14 2016
New Revision: 298693
URL: https://svnweb.freebsd.org/changeset/base/298693

Log:
  hyperv/vmbus: Mark sysctls MPSAFE
  
  MFC after:1 week
  Sponsored by: Microsoft OSTC

Modified:
  head/sys/dev/hyperv/vmbus/hv_channel.c
  head/sys/dev/hyperv/vmbus/hv_ring_buffer.c

Modified: head/sys/dev/hyperv/vmbus/hv_channel.c
==
--- head/sys/dev/hyperv/vmbus/hv_channel.c  Wed Apr 27 05:38:47 2016
(r298692)
+++ head/sys/dev/hyperv/vmbus/hv_channel.c  Wed Apr 27 05:45:14 2016
(r298693)
@@ -118,21 +118,21 @@ vmbus_channel_sysctl_create(hv_vmbus_cha
/* This creates dev.DEVNAME.DEVUNIT.channel tree */
devch_sysctl = SYSCTL_ADD_NODE(ctx,
SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
-   OID_AUTO, "channel", CTLFLAG_RD, 0, "");
+   OID_AUTO, "channel", CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "");
/* This creates dev.DEVNAME.DEVUNIT.channel.CHANID tree */
snprintf(name, sizeof(name), "%d", ch_id);
devch_id_sysctl = SYSCTL_ADD_NODE(ctx,
SYSCTL_CHILDREN(devch_sysctl),
-   OID_AUTO, name, CTLFLAG_RD, 0, "");
+   OID_AUTO, name, CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "");
 
if (primary_ch != NULL) {
devch_sub_sysctl = SYSCTL_ADD_NODE(ctx,
SYSCTL_CHILDREN(devch_id_sysctl),
-   OID_AUTO, "sub", CTLFLAG_RD, 0, "");
+   OID_AUTO, "sub", CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "");
snprintf(name, sizeof(name), "%d", sub_ch_id);
devch_id_sysctl = SYSCTL_ADD_NODE(ctx,
SYSCTL_CHILDREN(devch_sub_sysctl),
-   OID_AUTO, name, CTLFLAG_RD, 0, "");
+   OID_AUTO, name, CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "");
 
SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(devch_id_sysctl),
OID_AUTO, "chanid", CTLFLAG_RD,
@@ -141,20 +141,20 @@ vmbus_channel_sysctl_create(hv_vmbus_cha
SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(devch_id_sysctl), OID_AUTO,
"cpu", CTLFLAG_RD, &channel->target_cpu, 0, "owner CPU id");
SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(devch_id_sysctl), OID_AUTO,
-   "monitor_allocated", CTLTYPE_INT | CTLFLAG_RD, channel, 0,
-   vmbus_channel_sysctl_monalloc, "I",
+   "monitor_allocated", CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE,
+   channel, 0, vmbus_channel_sysctl_monalloc, "I",
"is monitor allocated to this channel");
 
devch_id_in_sysctl = SYSCTL_ADD_NODE(ctx,
 SYSCTL_CHILDREN(devch_id_sysctl),
 OID_AUTO,
"in",
-   CTLFLAG_RD, 0, "");
+   CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "");
devch_id_out_sysctl = SYSCTL_ADD_NODE(ctx,
 SYSCTL_CHILDREN(devch_id_sysctl),
 OID_AUTO,
"out",
-   CTLFLAG_RD, 0, "");
+   CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "");
hv_ring_buffer_stat(ctx,
SYSCTL_CHILDREN(devch_id_in_sysctl),
&(channel->inbound),

Modified: head/sys/dev/hyperv/vmbus/hv_ring_buffer.c
==
--- head/sys/dev/hyperv/vmbus/hv_ring_buffer.c  Wed Apr 27 05:38:47 2016
(r298692)
+++ head/sys/dev/hyperv/vmbus/hv_ring_buffer.c  Wed Apr 27 05:45:14 2016
(r298693)
@@ -76,7 +76,7 @@ hv_ring_buffer_stat(
 {
SYSCTL_ADD_PROC(ctx, tree_node, OID_AUTO,
"ring_buffer_stats",
-   CTLTYPE_STRING|CTLFLAG_RD, rbi, 0,
+   CTLTYPE_STRING|CTLFLAG_RD|CTLFLAG_MPSAFE, rbi, 0,
hv_rbi_sysctl_stats, "A", desc);
 }
 /**
___
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: r298694 - head/sys/dev/hyperv/netvsc

2016-04-26 Thread Sepherosa Ziehau
Author: sephe
Date: Wed Apr 27 06:49:16 2016
New Revision: 298694
URL: https://svnweb.freebsd.org/changeset/base/298694

Log:
  hyperv/hn: Add stat for # of chimney sending tries
  
  MFC after:1 week
  Sponsored by: Microsoft OSTC

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

Modified: head/sys/dev/hyperv/netvsc/hv_net_vsc.h
==
--- head/sys/dev/hyperv/netvsc/hv_net_vsc.h Wed Apr 27 05:45:14 2016
(r298693)
+++ head/sys/dev/hyperv/netvsc/hv_net_vsc.h Wed Apr 27 06:49:16 2016
(r298694)
@@ -1211,6 +1211,7 @@ struct hn_tx_ring {
u_long  hn_send_failed;
u_long  hn_txdma_failed;
u_long  hn_tx_collapsed;
+   u_long  hn_tx_chimney_tried;
u_long  hn_tx_chimney;
u_long  hn_pkts;
 

Modified: head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
==
--- head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c  Wed Apr 27 05:45:14 
2016(r298693)
+++ head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c  Wed Apr 27 06:49:16 
2016(r298694)
@@ -1004,6 +1004,7 @@ hn_encap(struct hn_tx_ring *txr, struct 
netvsc_dev *net_dev = txr->hn_sc->net_dev;
uint32_t send_buf_section_idx;
 
+   txr->hn_tx_chimney_tried++;
send_buf_section_idx =
hv_nv_get_next_send_section(net_dev);
if (send_buf_section_idx !=
@@ -2595,6 +2596,10 @@ hn_create_tx_data(struct hn_softc *sc, i
CTLTYPE_ULONG | CTLFLAG_RW | CTLFLAG_MPSAFE, sc,
__offsetof(struct hn_tx_ring, hn_tx_chimney),
hn_tx_stat_ulong_sysctl, "LU", "# of chimney send");
+   SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "tx_chimney_tried",
+   CTLTYPE_ULONG | CTLFLAG_RW | CTLFLAG_MPSAFE, sc,
+   __offsetof(struct hn_tx_ring, hn_tx_chimney_tried),
+   hn_tx_stat_ulong_sysctl, "LU", "# of chimney send tries");
SYSCTL_ADD_INT(ctx, child, OID_AUTO, "txdesc_cnt",
CTLFLAG_RD, &sc->hn_tx_ring[0].hn_txdesc_cnt, 0,
"# of total TX descs");
___
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"