From owner-svn-src-stable@freebsd.org Sun Aug 23 16:17:02 2015 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8CA7C9C0270; Sun, 23 Aug 2015 16:17:02 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 739161B82; Sun, 23 Aug 2015 16:17:02 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7NGH2G9091222; Sun, 23 Aug 2015 16:17:02 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7NGH1NL091218; Sun, 23 Aug 2015 16:17:01 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201508231617.t7NGH1NL091218@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sun, 23 Aug 2015 16:17:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r287035 - in stable/10: share/man/man4 sys/dev/usb sys/dev/usb/serial X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 23 Aug 2015 16:17:02 -0000 Author: ian Date: Sun Aug 23 16:17:00 2015 New Revision: 287035 URL: https://svnweb.freebsd.org/changeset/base/287035 Log: MFC r264394, r286382, r286385, r286389: Add support to the uftdi driver for reading and writing the serial eeprom that can be attached to the chips, via ioctl() calls. Return the current ftdi bitbang mode with the UFTDIIOC_GET_BITMODE ioctl. Document the recently added get-bitmode and eeprom read/write functionality. Modified: stable/10/share/man/man4/uftdi.4 stable/10/sys/dev/usb/serial/uftdi.c stable/10/sys/dev/usb/serial/uftdi_reg.h stable/10/sys/dev/usb/uftdiio.h Directory Properties: stable/10/ (props changed) Modified: stable/10/share/man/man4/uftdi.4 ============================================================================== --- stable/10/share/man/man4/uftdi.4 Sun Aug 23 15:20:49 2015 (r287034) +++ stable/10/share/man/man4/uftdi.4 Sun Aug 23 16:17:00 2015 (r287035) @@ -29,7 +29,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 31, 2014 +.Dd August 6, 2015 .Dt UFTDI 4 .Os .Sh NAME @@ -110,6 +110,11 @@ The must be one of the .Va uftdi_bitmodes values. +Setting +.Va mode +to +.Dv UFTDI_BITMODE_NONE +returns the channel to standard UART mode. .Bd -literal enum uftdi_bitmodes { @@ -136,20 +141,23 @@ the desired mode, then you .Xr read 2 and .Xr write 2 -data which either reflects pin state or is interpreted +data which either reflects pin state or is interpreted as MPSSE commands and parameters, depending on the mode. .It Dv UFTDIIOC_GET_BITMODE Pq Vt "struct uftdi_bitmode" -Return the state of the bitbang pins at the time of the call in the +Return the current bitbang mode in the +.Va mode +member, and the state of the DBUS0..DBUS7 pins at the time +of the call in the .Va iomask member. -The -.Va mode -member is unused. +The pin state can be read while the chip is in any mode, including +.Dv UFTDI_BITMODE_NONE +(UART) mode. .It Dv UFTDIIOC_SET_ERROR_CHAR Pq Vt int Set the character which is inserted into the buffer to mark the point of an error such as FIFO overflow. .It Dv UFTDIIOC_SET_EVENT_CHAR Pq Vt int -Set the character which causes a partial FIFO full of data +Set the character which causes a partial FIFO full of data to be returned immediately even if the FIFO is not full. .It Dv UFTDIIOC_SET_LATENCY Pq Vt int Set the amount of time to wait for a full FIFO, @@ -164,6 +172,55 @@ This is the .Va bcdDevice value from the .Va usb_device_descriptor . +.It Dv UFTDIIOC_READ_EEPROM Pq Vt "struct uftdi_eeio" +Read one or more words from the configuration eeprom. +The FTDI chip performs eeprom I/O in 16-bit words. +Set +.Va offset +and +.Va length +to values evenly divisible by two before the call, and the +.Va data +array will contain the requested values from eeprom after the call. +.Bd -literal +struct uftdi_eeio +{ + uint16_t offset; + uint16_t length; + uint16_t data[64]; +}; +.Ed +.Pp +The FT232R chip has an internal eeprom. +An external serial eeprom is optional on other FTDI chips. +The eeprom may contain 64, 128, or 256 words, +depending on the part used. +Multiple calls may be needed to read or write the larger parts. +When no eeprom is present, all words in the returned data are 0xffff. +An erased eeprom also reads as all 0xffff. +.It Dv UFTDIIOC_WRITE_EEPROM Pq Vt "struct uftdi_eeio" +Write one or more words to the configuration eeprom. +The +.Va uftdi_eeio +values are as described for +.Dv UFTDIIOC_READ_EEPROM . +.Pp +The FTDI chip does a blind write to the eeprom, and it will appear +to succeed even when no eeprom is present. +To ensure a good write you must read back and verify the data. +It is +.Em not +necessary to erase before writing. +Any position within the eeprom can be overwritten at any time. +.It Dv UFTDIIOC_ERASE_EEPROM Pq Vt int +Erase the entire eeprom. +This is useful primarily for test and debugging, as there is no +need to erase before writing. +To help prevent accidental erasure caused by calling the wrong +ioctl, you must pass the special value +.Dv UFTDI_CONFIRM_ERASE +as the argument to this ioctl. +.El .Sh HARDWARE The .Nm Modified: stable/10/sys/dev/usb/serial/uftdi.c ============================================================================== --- stable/10/sys/dev/usb/serial/uftdi.c Sun Aug 23 15:20:49 2015 (r287034) +++ stable/10/sys/dev/usb/serial/uftdi.c Sun Aug 23 16:17:00 2015 (r287035) @@ -161,6 +161,7 @@ struct uftdi_softc { uint8_t sc_hdrlen; uint8_t sc_msr; uint8_t sc_lsr; + uint8_t sc_bitmode; }; struct uftdi_param_config { @@ -196,7 +197,7 @@ static void uftdi_cfg_get_status(struct uint8_t *); static int uftdi_reset(struct ucom_softc *, int); static int uftdi_set_bitmode(struct ucom_softc *, uint8_t, uint8_t); -static int uftdi_get_bitmode(struct ucom_softc *, uint8_t *); +static int uftdi_get_bitmode(struct ucom_softc *, uint8_t *, uint8_t *); static int uftdi_set_latency(struct ucom_softc *, int); static int uftdi_get_latency(struct ucom_softc *, int *); static int uftdi_set_event_char(struct ucom_softc *, int); @@ -1091,6 +1092,7 @@ uftdi_attach(device_t dev) sc->sc_udev = uaa->device; sc->sc_dev = dev; sc->sc_unit = device_get_unit(dev); + sc->sc_bitmode = UFTDI_BITMODE_NONE; device_set_usb_desc(dev); mtx_init(&sc->sc_mtx, "uftdi", NULL, MTX_DEF); @@ -1682,6 +1684,7 @@ uftdi_set_bitmode(struct ucom_softc *uco { struct uftdi_softc *sc = ucom->sc_parent; usb_device_request_t req; + int rv; req.bmRequestType = UT_WRITE_VENDOR_DEVICE; req.bRequest = FTDI_SIO_SET_BITMODE; @@ -1694,11 +1697,15 @@ uftdi_set_bitmode(struct ucom_softc *uco else USETW2(req.wValue, (1 << bitmode), iomask); - return (usbd_do_request(sc->sc_udev, &sc->sc_mtx, &req, NULL)); + rv = usbd_do_request(sc->sc_udev, &sc->sc_mtx, &req, NULL); + if (rv == USB_ERR_NORMAL_COMPLETION) + sc->sc_bitmode = bitmode; + + return (rv); } static int -uftdi_get_bitmode(struct ucom_softc *ucom, uint8_t *iomask) +uftdi_get_bitmode(struct ucom_softc *ucom, uint8_t *bitmode, uint8_t *iomask) { struct uftdi_softc *sc = ucom->sc_parent; usb_device_request_t req; @@ -1710,6 +1717,7 @@ uftdi_get_bitmode(struct ucom_softc *uco USETW(req.wLength, 1); USETW(req.wValue, 0); + *bitmode = sc->sc_bitmode; return (usbd_do_request(sc->sc_udev, &sc->sc_mtx, &req, iomask)); } @@ -1792,6 +1800,82 @@ uftdi_set_error_char(struct ucom_softc * } static int +uftdi_read_eeprom(struct ucom_softc *ucom, struct uftdi_eeio *eeio) +{ + struct uftdi_softc *sc = ucom->sc_parent; + usb_device_request_t req; + usb_error_t err; + uint16_t widx, wlength, woffset; + + /* Offset and length must both be evenly divisible by two. */ + if ((eeio->offset | eeio->length) & 0x01) + return (EINVAL); + + woffset = eeio->offset / 2U; + wlength = eeio->length / 2U; + for (widx = 0; widx < wlength; widx++) { + req.bmRequestType = UT_READ_VENDOR_DEVICE; + req.bRequest = FTDI_SIO_READ_EEPROM; + USETW(req.wIndex, widx + woffset); + USETW(req.wLength, 2); + USETW(req.wValue, 0); + err = usbd_do_request(sc->sc_udev, &sc->sc_mtx, &req, + &eeio->data[widx]); + if (err != USB_ERR_NORMAL_COMPLETION) + return (err); + } + return (USB_ERR_NORMAL_COMPLETION); +} + +static int +uftdi_write_eeprom(struct ucom_softc *ucom, struct uftdi_eeio *eeio) +{ + struct uftdi_softc *sc = ucom->sc_parent; + usb_device_request_t req; + usb_error_t err; + uint16_t widx, wlength, woffset; + + /* Offset and length must both be evenly divisible by two. */ + if ((eeio->offset | eeio->length) & 0x01) + return (EINVAL); + + woffset = eeio->offset / 2U; + wlength = eeio->length / 2U; + for (widx = 0; widx < wlength; widx++) { + req.bmRequestType = UT_WRITE_VENDOR_DEVICE; + req.bRequest = FTDI_SIO_WRITE_EEPROM; + USETW(req.wIndex, widx + woffset); + USETW(req.wLength, 0); + USETW(req.wValue, eeio->data[widx]); + err = usbd_do_request(sc->sc_udev, &sc->sc_mtx, &req, NULL); + if (err != USB_ERR_NORMAL_COMPLETION) + return (err); + } + return (USB_ERR_NORMAL_COMPLETION); +} + +static int +uftdi_erase_eeprom(struct ucom_softc *ucom, int confirmation) +{ + struct uftdi_softc *sc = ucom->sc_parent; + usb_device_request_t req; + usb_error_t err; + + /* Small effort to prevent accidental erasure. */ + if (confirmation != UFTDI_CONFIRM_ERASE) + return (EINVAL); + + req.bmRequestType = UT_WRITE_VENDOR_DEVICE; + req.bRequest = FTDI_SIO_ERASE_EEPROM; + USETW(req.wIndex, 0); + USETW(req.wLength, 0); + USETW(req.wValue, 0); + err = usbd_do_request(sc->sc_udev, &sc->sc_mtx, &req, NULL); + + return (err); +} + +static int uftdi_ioctl(struct ucom_softc *ucom, uint32_t cmd, caddr_t data, int flag, struct thread *td) { @@ -1816,7 +1900,7 @@ uftdi_ioctl(struct ucom_softc *ucom, uin break; case UFTDIIOC_GET_BITMODE: mode = (struct uftdi_bitmode *)data; - err = uftdi_get_bitmode(ucom, &mode->iomask); + err = uftdi_get_bitmode(ucom, &mode->mode, &mode->iomask); break; case UFTDIIOC_SET_LATENCY: err = uftdi_set_latency(ucom, *((int *)data)); @@ -1834,6 +1918,15 @@ uftdi_ioctl(struct ucom_softc *ucom, uin *(int *)data = sc->sc_bcdDevice; err = 0; break; + case UFTDIIOC_READ_EEPROM: + err = uftdi_read_eeprom(ucom, (struct uftdi_eeio *)data); + break; + case UFTDIIOC_WRITE_EEPROM: + err = uftdi_write_eeprom(ucom, (struct uftdi_eeio *)data); + break; + case UFTDIIOC_ERASE_EEPROM: + err = uftdi_erase_eeprom(ucom, *(int *)data); + break; default: return (ENOIOCTL); } Modified: stable/10/sys/dev/usb/serial/uftdi_reg.h ============================================================================== --- stable/10/sys/dev/usb/serial/uftdi_reg.h Sun Aug 23 15:20:49 2015 (r287034) +++ stable/10/sys/dev/usb/serial/uftdi_reg.h Sun Aug 23 16:17:00 2015 (r287035) @@ -31,7 +31,10 @@ #define FTDI_SIO_SET_LATENCY 9 /* Set the latency timer */ #define FTDI_SIO_GET_LATENCY 10 /* Read the latency timer */ #define FTDI_SIO_SET_BITMODE 11 /* Set the bit bang I/O mode */ -#define FTDI_SIO_GET_BITMODE 12 /* Read pin states in bit bang mode */ +#define FTDI_SIO_GET_BITMODE 12 /* Read pin states from any mode */ +#define FTDI_SIO_READ_EEPROM 144 /* Read eeprom word */ +#define FTDI_SIO_WRITE_EEPROM 145 /* Write eeprom word */ +#define FTDI_SIO_ERASE_EEPROM 146 /* Erase entire eeprom */ /* Port Identifier Table */ #define FTDI_PIT_DEFAULT 0 /* SIOA */ Modified: stable/10/sys/dev/usb/uftdiio.h ============================================================================== --- stable/10/sys/dev/usb/uftdiio.h Sun Aug 23 15:20:49 2015 (r287034) +++ stable/10/sys/dev/usb/uftdiio.h Sun Aug 23 16:17:00 2015 (r287035) @@ -43,7 +43,7 @@ enum uftdi_bitmodes UFTDI_BITMODE_CPU_EMUL = 3, UFTDI_BITMODE_FAST_SERIAL = 4, UFTDI_BITMODE_CBUS = 5, - UFTDI_BITMODE_NONE = 0xff, + UFTDI_BITMODE_NONE = 0xff, /* aka UART mode. */ }; /* @@ -52,8 +52,9 @@ enum uftdi_bitmodes * iomask = Mask of bits enabled for bitbang output. * * For UFTDIIOC_GET_BITMODE: - * mode = Unused. - * iomask = Returned snapshot of bitbang pin states at time of call. + * mode = Mode most recently set using UFTDIIOC_SET_BITMODE. + * iomask = Returned snapshot of DBUS0..DBUS7 pin states at time of call. + * Pin states can be read in any mode, not just bitbang modes. */ struct uftdi_bitmode { @@ -61,6 +62,26 @@ struct uftdi_bitmode uint8_t iomask; }; +/* + * For UFTDIIOC_READ_EEPROM, UFTDIIOC_WRITE_EEPROM: + * + * IO is done in 16-bit words at the chip level; offset and length are in bytes, + * but must each be evenly divisible by two. + * + * It is not necessary to erase before writing. For the FT232R device (only) + * you must set the latency timer to 0x77 before doing a series of eeprom writes + * (and restore it to the prior value when done). + */ +struct uftdi_eeio +{ + uint16_t offset; + uint16_t length; + uint16_t data[64]; +}; + +/* Pass this value to confirm that eeprom erase request is not accidental. */ +#define UFTDI_CONFIRM_ERASE 0x26139108 + #define UFTDIIOC_RESET_IO _IO('c', 0) /* Reset config, flush fifos.*/ #define UFTDIIOC_RESET_RX _IO('c', 1) /* Flush input fifo. */ #define UFTDIIOC_RESET_TX _IO('c', 2) /* Flush output fifo. */ @@ -71,5 +92,8 @@ struct uftdi_bitmode #define UFTDIIOC_SET_LATENCY _IOW('c', 7, int) /* 1-255 ms */ #define UFTDIIOC_GET_LATENCY _IOR('c', 8, int) #define UFTDIIOC_GET_HWREV _IOR('c', 9, int) +#define UFTDIIOC_READ_EEPROM _IOWR('c', 10, struct uftdi_eeio) +#define UFTDIIOC_WRITE_EEPROM _IOW('c', 11, struct uftdi_eeio) +#define UFTDIIOC_ERASE_EEPROM _IOW('c', 12, int) #endif From owner-svn-src-stable@freebsd.org Sun Aug 23 16:22:22 2015 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 51BD39C03BC; Sun, 23 Aug 2015 16:22:22 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 41CF11FE5; Sun, 23 Aug 2015 16:22:22 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7NGMMad095211; Sun, 23 Aug 2015 16:22:22 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7NGMM1D095210; Sun, 23 Aug 2015 16:22:22 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201508231622.t7NGMM1D095210@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sun, 23 Aug 2015 16:22:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r287036 - stable/10/sys/kern X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 23 Aug 2015 16:22:22 -0000 Author: ian Date: Sun Aug 23 16:22:21 2015 New Revision: 287036 URL: https://svnweb.freebsd.org/changeset/base/287036 Log: MFC r286423, r286429: RFC 2783 requires a status of ETIMEDOUT, not EWOULDBLOCK, on a timeout. Only process the PPS event types currently enabled in pps_params.mode. Modified: stable/10/sys/kern/kern_tc.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/kern/kern_tc.c ============================================================================== --- stable/10/sys/kern/kern_tc.c Sun Aug 23 16:17:00 2015 (r287035) +++ stable/10/sys/kern/kern_tc.c Sun Aug 23 16:22:21 2015 (r287036) @@ -1511,8 +1511,12 @@ pps_fetch(struct pps_fetch_args *fapi, s } else { err = tsleep(pps, PCATCH, "ppsfch", timo); } - if (err == EWOULDBLOCK && fapi->timeout.tv_sec == -1) { - continue; + if (err == EWOULDBLOCK) { + if (fapi->timeout.tv_sec == -1) { + continue; + } else { + return (ETIMEDOUT); + } } else if (err != 0) { return (err); } @@ -1668,6 +1672,9 @@ pps_event(struct pps_state *pps, int eve #endif KASSERT(pps != NULL, ("NULL pps pointer in pps_event")); + /* Nothing to do if not currently set to capture this event type. */ + if ((event & pps->ppsparam.mode) == 0) + return; /* If the timecounter was wound up underneath us, bail out. */ if (pps->capgen == 0 || pps->capgen != pps->capth->th_generation) return; From owner-svn-src-stable@freebsd.org Sun Aug 23 17:07:25 2015 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CB45F9C0D19; Sun, 23 Aug 2015 17:07:25 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BA78F1BBA; Sun, 23 Aug 2015 17:07:25 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7NH7PXa013402; Sun, 23 Aug 2015 17:07:25 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7NH7O5W013396; Sun, 23 Aug 2015 17:07:24 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201508231707.t7NH7O5W013396@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sun, 23 Aug 2015 17:07:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r287037 - in stable/10: . share/man/man4 sys/dev/uart X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 23 Aug 2015 17:07:25 -0000 Author: ian Date: Sun Aug 23 17:07:23 2015 New Revision: 287037 URL: https://svnweb.freebsd.org/changeset/base/287037 Log: MFC r286469, r286591, r286595, r286596, r286613: Provide the tty-layer mutex when initializing the pps api. This allows time_pps_fetch() to be used in blocking mode. Allow the choice of PPS signal captured by uart(4) to be runtime-configured, eliminating the need to build a custom kernel to use the CTS signal. Correct the polarity of the PPS assert and clear events with respect to the electrical signals on the serial port. Document the change in polarity of the uart(4) PPS capture. Style fix -- do the braces for switches correctly. Relnotes: yes Modified: stable/10/UPDATING stable/10/share/man/man4/uart.4 stable/10/sys/dev/uart/uart_bus.h stable/10/sys/dev/uart/uart_core.c stable/10/sys/dev/uart/uart_tty.c Directory Properties: stable/10/ (props changed) Modified: stable/10/UPDATING ============================================================================== --- stable/10/UPDATING Sun Aug 23 16:22:21 2015 (r287036) +++ stable/10/UPDATING Sun Aug 23 17:07:23 2015 (r287037) @@ -16,6 +16,20 @@ from older versions of FreeBSD, try WITH stable/10, and then rebuild without this option. The bootstrap process from older version of current is a bit fragile. +20150823: + The polarity of Pulse Per Second (PPS) capture events with the + uart(4) driver has been corrected. Prior to this change the PPS + "assert" event corresponded to the trailing edge of a positive PPS + pulse and the "clear" event was the leading edge of the next pulse. + + As the width of a PPS pulse in a typical GPS receiver is on the + order of 1 millisecond, most users will not notice any significant + difference with this change. + + Anyone who has compensated for the historical polarity reversal by + configuring a negative offset equal to the pulse width will need to + remove that workaround. + 20150822: From legacy ata(4) driver was removed support for SATA controllers supported by more functional drivers ahci(4), siis(4) and mvs(4). Modified: stable/10/share/man/man4/uart.4 ============================================================================== --- stable/10/share/man/man4/uart.4 Sun Aug 23 16:22:21 2015 (r287036) +++ stable/10/share/man/man4/uart.4 Sun Aug 23 17:07:23 2015 (r287037) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 12, 2008 +.Dd August 10, 2015 .Dt UART 4 .Os .Sh NAME @@ -151,6 +151,39 @@ SCC: serial communications controllers s device driver. .El .\" +.Sh Pulse Per Second (PPS) Timing Interface +The +.Nm +driver can capture PPS timing information as defined in RFC 2783. +The API, accessed via +.Xr ioctl 8 , +is available on the tty device. +To use the PPS capture feature with +.Xr ntpd 8 , +symlink the tty device to +.Va /dev/pps0. +.Pp +The +.Va hw.uart.pps_mode +tunable configures the PPS capture mode for all uart devices; +it can be set in +.Xr loader.conf 5 . +The +.Va dev.uart.0.pps_mode +sysctl configures the PPS capture mode for a specific uart device; +it can be set in +.Xr loader.conf 5 +or +.Xr sysctl.conf 5 . +The following capture modes are available: +.Bl -tag -compact -offset "mmmm" -width "mmmm" +.It 0 +Capture disabled. +.It 1 +Capture pulses on the CTS line. +.It 2 +Capture pulses on the DCD line (default). +.El .Sh FILES .Bl -tag -width ".Pa /dev/ttyu?.init" -compact .It Pa /dev/ttyu? Modified: stable/10/sys/dev/uart/uart_bus.h ============================================================================== --- stable/10/sys/dev/uart/uart_bus.h Sun Aug 23 16:22:21 2015 (r287036) +++ stable/10/sys/dev/uart/uart_bus.h Sun Aug 23 17:07:23 2015 (r287037) @@ -48,14 +48,6 @@ #define UART_STAT_OVERRUN 0x0400 #define UART_STAT_PARERR 0x0800 -#ifdef UART_PPS_ON_CTS -#define UART_SIG_DPPS SER_DCTS -#define UART_SIG_PPS SER_CTS -#else -#define UART_SIG_DPPS SER_DDCD -#define UART_SIG_PPS SER_DCD -#endif - /* UART_IOCTL() requests */ #define UART_IOCTL_BREAK 1 #define UART_IOCTL_IFLOW 2 @@ -119,6 +111,7 @@ struct uart_softc { /* Pulse capturing support (PPS). */ struct pps_state sc_pps; + int sc_pps_mode; /* Upper layer data. */ void *sc_softih; @@ -149,6 +142,7 @@ void uart_sched_softih(struct uart_softc int uart_tty_attach(struct uart_softc *); int uart_tty_detach(struct uart_softc *); +struct mtx *uart_tty_getlock(struct uart_softc *); void uart_tty_intr(void *arg); /* Modified: stable/10/sys/dev/uart/uart_core.c ============================================================================== --- stable/10/sys/dev/uart/uart_core.c Sun Aug 23 16:22:21 2015 (r287036) +++ stable/10/sys/dev/uart/uart_core.c Sun Aug 23 17:07:23 2015 (r287037) @@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -64,6 +65,108 @@ static MALLOC_DEFINE(M_UART, "UART", "UA static int uart_poll_freq = UART_POLL_FREQ; TUNABLE_INT("debug.uart_poll_freq", &uart_poll_freq); +#define PPS_MODE_DISABLED 0 +#define PPS_MODE_CTS 1 +#define PPS_MODE_DCD 2 + +static inline int +uart_pps_signal(int pps_mode) +{ + + switch(pps_mode) { + case PPS_MODE_CTS: + return (SER_CTS); + case PPS_MODE_DCD: + return (SER_DCD); + } + return (0); +} +static inline int +uart_pps_mode_valid(int pps_mode) +{ + + switch(pps_mode) { + case PPS_MODE_DISABLED: + case PPS_MODE_CTS: + case PPS_MODE_DCD: + return (true); + } + return (false); +} + +static const char * +uart_pps_mode_name(int pps_mode) +{ + switch(pps_mode) { + case PPS_MODE_DISABLED: + return ("disabled"); + case PPS_MODE_CTS: + return ("CTS"); + case PPS_MODE_DCD: + return ("DCD"); + } + return ("invalid"); +} + +static int +uart_pps_mode_sysctl(SYSCTL_HANDLER_ARGS) +{ + struct uart_softc *sc; + int err, tmp; + + sc = arg1; + tmp = sc->sc_pps_mode; + err = sysctl_handle_int(oidp, &tmp, 0, req); + if (err != 0 || req->newptr == NULL) + return (err); + if (!uart_pps_mode_valid(tmp)) + return (EINVAL); + sc->sc_pps_mode = tmp; + return(0); +} + +static void +uart_pps_init(struct uart_softc *sc) +{ + struct sysctl_ctx_list *ctx; + struct sysctl_oid *tree; + + ctx = device_get_sysctl_ctx(sc->sc_dev); + tree = device_get_sysctl_tree(sc->sc_dev); + + /* + * The historical default for pps capture mode is either DCD or CTS, + * depending on the UART_PPS_ON_CTS kernel option. Start with that, + * then try to fetch the tunable that overrides the mode for all uart + * devices, then try to fetch the sysctl-tunable that overrides the mode + * for one specific device. + */ +#ifdef UART_PPS_ON_CTS + sc->sc_pps_mode = PPS_MODE_CTS; +#else + sc->sc_pps_mode = PPS_MODE_DCD; +#endif + TUNABLE_INT_FETCH("hw.uart.pps_mode", &sc->sc_pps_mode); + SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "pps_mode", + CTLTYPE_INT | CTLFLAG_RWTUN, sc, 0, uart_pps_mode_sysctl, "I", + "pulse capturing mode - 0/1/2 - disabled/CTS/DCD"); + + if (!uart_pps_mode_valid(sc->sc_pps_mode)) { + device_printf(sc->sc_dev, + "Invalid pps_mode %d configured; disabling PPS capture\n", + sc->sc_pps_mode); + sc->sc_pps_mode = PPS_MODE_DISABLED; + } else if (bootverbose) { + device_printf(sc->sc_dev, "PPS capture mode %d (%s)\n", + sc->sc_pps_mode, uart_pps_mode_name(sc->sc_pps_mode)); + } + + sc->sc_pps.ppscap = PPS_CAPTUREBOTH; + sc->sc_pps.driver_mtx = uart_tty_getlock(sc); + sc->sc_pps.driver_abi = PPS_ABI_VERSION; + pps_init_abi(&sc->sc_pps); +} + void uart_add_sysdev(struct uart_devinfo *di) { @@ -199,15 +302,22 @@ static __inline int uart_intr_sigchg(void *arg) { struct uart_softc *sc = arg; - int new, old, sig; + int new, old, pps_sig, sig; sig = UART_GETSIG(sc); + /* + * Time pulse counting support. Note that both CTS and DCD are + * active-low signals. The status bit is high to indicate that + * the signal on the line is low, which corresponds to a PPS + * clear event. + */ if (sc->sc_pps.ppsparam.mode & PPS_CAPTUREBOTH) { - if (sig & UART_SIG_DPPS) { + pps_sig = uart_pps_signal(sc->sc_pps_mode); + if (sig & SER_DELTA(pps_sig)) { pps_capture(&sc->sc_pps); - pps_event(&sc->sc_pps, (sig & UART_SIG_PPS) ? - PPS_CAPTUREASSERT : PPS_CAPTURECLEAR); + pps_event(&sc->sc_pps, (sig & pps_sig) ? + PPS_CAPTURECLEAR : PPS_CAPTUREASSERT); } } @@ -499,9 +609,6 @@ uart_bus_attach(device_t dev) sc->sc_sysdev->stopbits); } - sc->sc_pps.ppscap = PPS_CAPTUREBOTH; - pps_init(&sc->sc_pps); - sc->sc_leaving = 0; sc->sc_testintr = 1; filt = uart_intr(sc); @@ -554,10 +661,14 @@ uart_bus_attach(device_t dev) printf("\n"); } - error = (sc->sc_sysdev != NULL && sc->sc_sysdev->attach != NULL) - ? (*sc->sc_sysdev->attach)(sc) : uart_tty_attach(sc); - if (error) - goto fail; + if (sc->sc_sysdev != NULL && sc->sc_sysdev->attach != NULL) { + if ((error = sc->sc_sysdev->attach(sc)) != 0) + goto fail; + } else { + if ((error = uart_tty_attach(sc)) != 0) + goto fail; + uart_pps_init(sc); + } if (sc->sc_sysdev != NULL) sc->sc_sysdev->hwmtx = sc->sc_hwmtx; Modified: stable/10/sys/dev/uart/uart_tty.c ============================================================================== --- stable/10/sys/dev/uart/uart_tty.c Sun Aug 23 16:22:21 2015 (r287036) +++ stable/10/sys/dev/uart/uart_tty.c Sun Aug 23 17:07:23 2015 (r287037) @@ -410,3 +410,13 @@ uart_tty_detach(struct uart_softc *sc) return (0); } + +struct mtx * +uart_tty_getlock(struct uart_softc *sc) +{ + + if (sc->sc_u.u_tty.tp != NULL) + return (tty_getlock(sc->sc_u.u_tty.tp)); + else + return (NULL); +} From owner-svn-src-stable@freebsd.org Sun Aug 23 17:54:49 2015 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6E1289C1412; Sun, 23 Aug 2015 17:54:49 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 44918EB8; Sun, 23 Aug 2015 17:54:49 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7NHsnjY033477; Sun, 23 Aug 2015 17:54:49 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7NHsndJ033476; Sun, 23 Aug 2015 17:54:49 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201508231754.t7NHsndJ033476@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sun, 23 Aug 2015 17:54:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r287040 - stable/10/sys/arm/ti/am335x X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 23 Aug 2015 17:54:49 -0000 Author: ian Date: Sun Aug 23 17:54:48 2015 New Revision: 287040 URL: https://svnweb.freebsd.org/changeset/base/287040 Log: Always compile in PPS capture. Use the same device name used in 11-current. This is a direct commit to 10-stable because the corresponding changes in 11 are bound up with all the device-tree rework for beaglebone. This somewhat aligns the features between the two branches, from a user's perspective. Modified: stable/10/sys/arm/ti/am335x/am335x_dmtimer.c Modified: stable/10/sys/arm/ti/am335x/am335x_dmtimer.c ============================================================================== --- stable/10/sys/arm/ti/am335x/am335x_dmtimer.c Sun Aug 23 17:53:44 2015 (r287039) +++ stable/10/sys/arm/ti/am335x/am335x_dmtimer.c Sun Aug 23 17:54:48 2015 (r287040) @@ -44,8 +44,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include "opt_ntp.h" - #include #include #include @@ -198,7 +196,6 @@ am335x_dmtimer_et_write_4(struct am335x_ * latched value from the timer. The remaining work (done by pps_event()) is * scheduled to be done later in a non-interrupt context. */ -#ifdef PPS_SYNC #define PPS_CDEV_NAME "dmtpps" @@ -405,7 +402,7 @@ am335x_dmtimer_pps_init(device_t dev, st /* Create the PPS cdev. */ unit = device_get_unit(dev); sc->pps_cdev = make_dev(&am335x_dmtimer_pps_cdevsw, unit, - UID_ROOT, GID_WHEEL, 0600, PPS_CDEV_NAME "%d", unit); + UID_ROOT, GID_WHEEL, 0600, PPS_CDEV_NAME); sc->pps_cdev->si_drv1 = sc; device_printf(dev, "Using DMTimer%d for PPS device /dev/%s%d\n", @@ -414,20 +411,6 @@ am335x_dmtimer_pps_init(device_t dev, st return (timer_num); } -#else /* PPS_SYNC */ - -static int -am335x_dmtimer_pps_init(device_t dev, struct am335x_dmtimer_softc *sc) -{ - - /* - * When PPS support is not compiled in, there's no need to use a timer - * that has an associated capture-input pin, so use the default. - */ - return (DEFAULT_TC_TIMER); -} - -#endif /* PPS_SYNC */ /* * End of PPS driver code. */ From owner-svn-src-stable@freebsd.org Sun Aug 23 18:03:44 2015 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5BF899C157B; Sun, 23 Aug 2015 18:03:44 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3FE131431; Sun, 23 Aug 2015 18:03:44 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7NI3ila037928; Sun, 23 Aug 2015 18:03:44 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7NI3hMU037926; Sun, 23 Aug 2015 18:03:43 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201508231803.t7NI3hMU037926@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sun, 23 Aug 2015 18:03:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r287042 - in stable/10: share/man/man4 sys/kern X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 23 Aug 2015 18:03:44 -0000 Author: ian Date: Sun Aug 23 18:03:43 2015 New Revision: 287042 URL: https://svnweb.freebsd.org/changeset/base/287042 Log: MFC r286701: If a specific timecounter has been chosen via sysctl, and a new timecounter with higher quality registers (presumably in a module that has just been loaded), do not undo the user's choice by switching to the new timecounter. Document that behavior, and also the fact that there is no way to unregister a timecounter (and thus no way to unload a module containing one). Modified: stable/10/share/man/man4/timecounters.4 stable/10/sys/kern/kern_tc.c Modified: stable/10/share/man/man4/timecounters.4 ============================================================================== --- stable/10/share/man/man4/timecounters.4 Sun Aug 23 18:00:19 2015 (r287041) +++ stable/10/share/man/man4/timecounters.4 Sun Aug 23 18:03:43 2015 (r287042) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 12, 2014 +.Dd August 12, 2015 .Dt TIMECOUNTERS 4 .Os .Sh NAME @@ -96,10 +96,16 @@ compared to others. A negative value means this time counter is broken and should not be used. .El .Pp -The time management code of the kernel chooses one time counter from that list. -The current choice can be read and affected via the +The time management code of the kernel automatically switches to a +higher-quality time counter when it registers, unless the .Va kern.timecounter.hardware -tunable/sysctl. +sysctl has been used to choose a specific device. +.Pp +There is no way to unregister a time counter once it has registered +with the kernel. +If a dynamically loaded module contains a time counter you will not +be able to unload that module, even if the time counter it contains +is not the one currently in use. .Sh SEE ALSO .Xr attimer 4 , .Xr eventtimers 4 , Modified: stable/10/sys/kern/kern_tc.c ============================================================================== --- stable/10/sys/kern/kern_tc.c Sun Aug 23 18:00:19 2015 (r287041) +++ stable/10/sys/kern/kern_tc.c Sun Aug 23 18:03:43 2015 (r287042) @@ -133,6 +133,8 @@ SYSCTL_PROC(_kern_timecounter, OID_AUTO, sysctl_kern_timecounter_adjprecision, "I", "Allowed time interval deviation in percents"); +static int tc_chosen; /* Non-zero if a specific tc was chosen via sysctl. */ + static void tc_windup(void); static void cpu_tick_calibrate(int); @@ -1180,10 +1182,13 @@ tc_init(struct timecounter *tc) "quality", CTLFLAG_RD, &(tc->tc_quality), 0, "goodness of time counter"); /* - * Never automatically use a timecounter with negative quality. + * Do not automatically switch if the current tc was specifically + * chosen. Never automatically use a timecounter with negative quality. * Even though we run on the dummy counter, switching here may be - * worse since this timecounter may not be monotonous. + * worse since this timecounter may not be monotonic. */ + if (tc_chosen) + return; if (tc->tc_quality < 0) return; if (tc->tc_quality < timecounter->tc_quality) @@ -1411,9 +1416,12 @@ sysctl_kern_timecounter_hardware(SYSCTL_ strlcpy(newname, tc->tc_name, sizeof(newname)); error = sysctl_handle_string(oidp, &newname[0], sizeof(newname), req); - if (error != 0 || req->newptr == NULL || - strcmp(newname, tc->tc_name) == 0) + if (error != 0 || req->newptr == NULL) return (error); + /* Record that the tc in use now was specifically chosen. */ + tc_chosen = 1; + if (strcmp(newname, tc->tc_name) == 0) + return (0); for (newtc = timecounters; newtc != NULL; newtc = newtc->tc_next) { if (strcmp(newname, newtc->tc_name) != 0) continue; @@ -1434,7 +1442,7 @@ SYSCTL_PROC(_kern_timecounter, OID_AUTO, "Timecounter hardware selected"); -/* Report or change the active timecounter hardware. */ +/* Report the available timecounter hardware. */ static int sysctl_kern_timecounter_choice(SYSCTL_HANDLER_ARGS) { From owner-svn-src-stable@freebsd.org Sun Aug 23 20:16:15 2015 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 08FF19C1AD1; Sun, 23 Aug 2015 20:16:15 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E0A5E1FDC; Sun, 23 Aug 2015 20:16:14 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7NKGEFn093167; Sun, 23 Aug 2015 20:16:14 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7NKGEOE093163; Sun, 23 Aug 2015 20:16:14 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201508232016.t7NKGEOE093163@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sun, 23 Aug 2015 20:16:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r287079 - in stable/10/sys/arm: conf freescale/imx X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 23 Aug 2015 20:16:15 -0000 Author: ian Date: Sun Aug 23 20:16:13 2015 New Revision: 287079 URL: https://svnweb.freebsd.org/changeset/base/287079 Log: MFC r286942, r286943, r286944: imx watchdog fixes... Add compatible strings for all the hardware this driver works with. Also, move the READ/WRITE bus space access macros from the header into the source file, and rename them to RD2/WR2 to make it clear they're 16-bit accessors. (READ/WRITE just don't seem like good names to be in a public header file.) Make the imx watchdog actually work, by setting WDOG_CR_WDE (enable bit). Also, follow the rules from watchdog(9) about what values to return in various situations (especially, don't touch *error when asked to set a non-zero timeout that isn't achievable on the hardware). Enable the watchdog driver on imx6, now that it works. Modified: stable/10/sys/arm/conf/IMX6 stable/10/sys/arm/freescale/imx/imx_wdog.c stable/10/sys/arm/freescale/imx/imx_wdogreg.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/arm/conf/IMX6 ============================================================================== --- stable/10/sys/arm/conf/IMX6 Sun Aug 23 18:34:25 2015 (r287078) +++ stable/10/sys/arm/conf/IMX6 Sun Aug 23 20:16:13 2015 (r287079) @@ -160,5 +160,5 @@ device ffec # Freescale Fast Ethernet device fsliic # Freescale i2c/iic device iic # iic protocol device iicbus # iic bus -#device imxwdt # Watchdog. WARNING: can't be disabled!!! +device imxwdt # Watchdog. WARNING: can't be disabled!!! Modified: stable/10/sys/arm/freescale/imx/imx_wdog.c ============================================================================== --- stable/10/sys/arm/freescale/imx/imx_wdog.c Sun Aug 23 18:34:25 2015 (r287078) +++ stable/10/sys/arm/freescale/imx/imx_wdog.c Sun Aug 23 20:16:13 2015 (r287079) @@ -66,6 +66,20 @@ static struct resource_spec imx_wdog_spe { -1, 0 } }; +static struct ofw_compat_data compat_data[] = { + {"fsl,imx6sx-wdt", 1}, + {"fsl,imx6sl-wdt", 1}, + {"fsl,imx6q-wdt", 1}, + {"fsl,imx53-wdt", 1}, + {"fsl,imx51-wdt", 1}, + {"fsl,imx50-wdt", 1}, + {"fsl,imx35-wdt", 1}, + {"fsl,imx27-wdt", 1}, + {"fsl,imx25-wdt", 1}, + {"fsl,imx21-wdt", 1}, + {NULL, 0} +}; + static void imx_watchdog(void *, u_int, int *); static int imx_wdog_probe(device_t); static int imx_wdog_attach(device_t); @@ -84,46 +98,42 @@ static driver_t imx_wdog_driver = { static devclass_t imx_wdog_devclass; DRIVER_MODULE(imx_wdog, simplebus, imx_wdog_driver, imx_wdog_devclass, 0, 0); +#define RD2(_sc, _r) \ + bus_space_read_2((_sc)->sc_bst, (_sc)->sc_bsh, (_r)) +#define WR2(_sc, _r, _v) \ + bus_space_write_2((_sc)->sc_bst, (_sc)->sc_bsh, (_r), (_v)) static void imx_watchdog(void *arg, u_int cmd, int *error) { struct imx_wdog_softc *sc; uint16_t reg; - int timeout; + u_int timeout; sc = arg; mtx_lock(&sc->sc_mtx); - - /* Refresh counter, since we feels good */ - WRITE(sc, WDOG_SR_REG, WDOG_SR_STEP1); - WRITE(sc, WDOG_SR_REG, WDOG_SR_STEP2); - - /* We don't require precession, so "-10" (/1024) is ok */ - timeout = (1 << ((cmd & WD_INTERVAL) - 10)) / 1000000; - if (timeout > 1 && timeout < 128) { - if (timeout != sc->sc_timeout) { - device_printf(sc->sc_dev, - "WARNING: watchdog can't be disabled!!!"); - sc->sc_timeout = timeout; - reg = READ(sc, WDOG_CR_REG); - reg &= ~WDOG_CR_WT_MASK; - reg |= (timeout << (WDOG_CR_WT_SHIFT + 1)) & - WDOG_CR_WT_MASK; - WRITE(sc, WDOG_CR_REG, reg); + if (cmd == 0) { + if (bootverbose) + device_printf(sc->sc_dev, "Can not be disabled.\n"); + *error = EOPNOTSUPP; + } else { + timeout = (u_int)((1ULL << (cmd & WD_INTERVAL)) / 1000000000U); + if (timeout > 1 && timeout < 128) { + if (timeout != sc->sc_timeout) { + sc->sc_timeout = timeout; + reg = RD2(sc, WDOG_CR_REG); + reg &= ~WDOG_CR_WT_MASK; + reg |= (timeout << (WDOG_CR_WT_SHIFT + 1)) & + WDOG_CR_WT_MASK; + WR2(sc, WDOG_CR_REG, reg | WDOG_CR_WDE); + } /* Refresh counter */ - WRITE(sc, WDOG_SR_REG, WDOG_SR_STEP1); - WRITE(sc, WDOG_SR_REG, WDOG_SR_STEP2); + WR2(sc, WDOG_SR_REG, WDOG_SR_STEP1); + WR2(sc, WDOG_SR_REG, WDOG_SR_STEP2); *error = 0; - } else { - *error = EOPNOTSUPP; } - } else { - device_printf(sc->sc_dev, "Can not be disabled.\n"); - *error = EOPNOTSUPP; } mtx_unlock(&sc->sc_mtx); - } static int @@ -133,11 +143,10 @@ imx_wdog_probe(device_t dev) if (!ofw_bus_status_okay(dev)) return (ENXIO); - if (!ofw_bus_is_compatible(dev, "fsl,imx51-wdt") && - !ofw_bus_is_compatible(dev, "fsl,imx53-wdt")) + if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) return (ENXIO); - device_set_desc(dev, "Freescale i.MX5xx Watchdog Timer"); + device_set_desc(dev, "Freescale i.MX Watchdog"); return (0); } Modified: stable/10/sys/arm/freescale/imx/imx_wdogreg.h ============================================================================== --- stable/10/sys/arm/freescale/imx/imx_wdogreg.h Sun Aug 23 18:34:25 2015 (r287078) +++ stable/10/sys/arm/freescale/imx/imx_wdogreg.h Sun Aug 23 20:16:13 2015 (r287079) @@ -59,7 +59,3 @@ #define WDOG_MCR_REG 0x08 /* Miscellaneous Control Register */ #define WDOG_MCR_PDE (1 << 0) -#define READ(_sc, _r) \ - bus_space_read_2((_sc)->sc_bst, (_sc)->sc_bsh, (_r)) -#define WRITE(_sc, _r, _v) \ - bus_space_write_2((_sc)->sc_bst, (_sc)->sc_bsh, (_r), (_v)) From owner-svn-src-stable@freebsd.org Sun Aug 23 20:39:20 2015 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 749B79C01B6; Sun, 23 Aug 2015 20:39:20 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 650DFDC1; Sun, 23 Aug 2015 20:39:20 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7NKdKHH002806; Sun, 23 Aug 2015 20:39:20 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7NKdJ3w002804; Sun, 23 Aug 2015 20:39:19 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201508232039.t7NKdJ3w002804@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sun, 23 Aug 2015 20:39:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r287080 - stable/10/usr.sbin/watchdogd X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 23 Aug 2015 20:39:20 -0000 Author: ian Date: Sun Aug 23 20:39:19 2015 New Revision: 287080 URL: https://svnweb.freebsd.org/changeset/base/287080 Log: MFC r286947: Add a new exit-timeout option to watchdogd. Modified: stable/10/usr.sbin/watchdogd/watchdogd.8 stable/10/usr.sbin/watchdogd/watchdogd.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.sbin/watchdogd/watchdogd.8 ============================================================================== --- stable/10/usr.sbin/watchdogd/watchdogd.8 Sun Aug 23 20:16:13 2015 (r287079) +++ stable/10/usr.sbin/watchdogd/watchdogd.8 Sun Aug 23 20:39:19 2015 (r287080) @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 18, 2014 +.Dd May 11, 2015 .Dt WATCHDOGD 8 .Os .Sh NAME @@ -46,6 +46,7 @@ .Op Fl s Ar sleep .Op Fl t Ar timeout .Op Fl T Ar script_timeout +.Op Fl x Ar exit_timeout .Sh DESCRIPTION The .Nm @@ -103,14 +104,25 @@ defaults to the value specified by the .Fl s Ar sleep option. .Pp +The +.Fl x Ar exit_timeout +argument is the timeout period (in seconds) to leave in effect when the +program exits. +Using +.Fl x +with a non-zero value protects against lockup during a reboot by +triggering a hardware reset if the software reboot doesn't complete +before the given timeout expires. +.Pp Upon receiving the .Dv SIGTERM or .Dv SIGINT signals, .Nm -will first instruct the kernel to no longer perform watchdog checks and then -will terminate. +will terminate, after first instructing the kernel to either disable the +timeout or reset it to the value given by +.Fl x Ar exit_timeout . .Pp The .Nm Modified: stable/10/usr.sbin/watchdogd/watchdogd.c ============================================================================== --- stable/10/usr.sbin/watchdogd/watchdogd.c Sun Aug 23 20:16:13 2015 (r287079) +++ stable/10/usr.sbin/watchdogd/watchdogd.c Sun Aug 23 20:39:19 2015 (r287080) @@ -77,6 +77,7 @@ static int debugging = 0; static int end_program = 0; static const char *pidfile = _PATH_VARRUN "watchdogd.pid"; static u_int timeout = WD_TO_128SEC; +static u_int exit_timeout = WD_TO_NEVER; static u_int pretimeout = 0; static u_int timeout_sec; static u_int passive = 0; @@ -461,10 +462,10 @@ watchdog_onoff(int onoff) /* pat one more time for good measure */ return watchdog_patpat((timeout|WD_ACTIVE)); } else { - return watchdog_patpat(0); + return watchdog_patpat(exit_timeout); } failsafe: - watchdog_patpat(0); + watchdog_patpat(exit_timeout); return (error); } @@ -476,8 +477,8 @@ usage(void) { if (is_daemon) fprintf(stderr, "usage:\n" -" watchdogd [-dnSw] [-e cmd] [-I file] [-s sleep] [-t timeout]\n" -" [-T script_timeout]\n" +" watchdogd [-dnSw] [-e cmd] [-I pidfile] [-s sleep] [-t timeout]\n" +" [-T script_timeout] [-x exit_timeout]\n" " [--debug]\n" " [--pretimeout seconds] [-pretimeout-action action]\n" " [--softtimeout] [-softtimeout-action action]\n" @@ -697,7 +698,7 @@ parseargs(int argc, char *argv[]) is_daemon = 1; if (is_daemon) - getopt_shortopts = "I:de:ns:t:ST:w?"; + getopt_shortopts = "I:de:ns:t:ST:wx:?"; else getopt_shortopts = "dt:?"; @@ -741,6 +742,11 @@ parseargs(int argc, char *argv[]) case 'w': do_timedog = 1; break; + case 'x': + exit_timeout = parse_timeout_to_pow2ns(c, NULL, optarg); + if (exit_timeout != 0) + exit_timeout |= WD_ACTIVE; + break; case 0: lopt = longopts[longindex].name; if (!strcmp(lopt, "pretimeout")) { From owner-svn-src-stable@freebsd.org Sun Aug 23 20:50:26 2015 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4CCCF9C04D8; Sun, 23 Aug 2015 20:50:26 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 32E10145D; Sun, 23 Aug 2015 20:50:26 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7NKoQr2007520; Sun, 23 Aug 2015 20:50:26 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7NKoNTR007504; Sun, 23 Aug 2015 20:50:23 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201508232050.t7NKoNTR007504@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sun, 23 Aug 2015 20:50:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r287082 - stable/10/sys/arm/conf X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 23 Aug 2015 20:50:26 -0000 Author: ian Date: Sun Aug 23 20:50:22 2015 New Revision: 287082 URL: https://svnweb.freebsd.org/changeset/base/287082 Log: MFC r283547: Ensure that all arm kernel configs contain ALT_BREAK_TO_DEBUGGER and not BREAK_TO_DEBUGGER if they have a serial console (most do). A burst of serial line noise (such as unplugging a usb serial adapter) can look like a break and drop a working system into the debugger. The alt break sequence (~^B) works fine on both serial and non-serial consoles. Modified: stable/10/sys/arm/conf/BEAGLEBONE stable/10/sys/arm/conf/CUBIEBOARD stable/10/sys/arm/conf/CUBIEBOARD2 stable/10/sys/arm/conf/DOCKSTAR stable/10/sys/arm/conf/DREAMPLUG-1001 stable/10/sys/arm/conf/EFIKA_MX stable/10/sys/arm/conf/EXYNOS5.common stable/10/sys/arm/conf/PANDABOARD stable/10/sys/arm/conf/RPI-B stable/10/sys/arm/conf/VYBRID stable/10/sys/arm/conf/ZEDBOARD Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/arm/conf/BEAGLEBONE ============================================================================== --- stable/10/sys/arm/conf/BEAGLEBONE Sun Aug 23 20:44:53 2015 (r287081) +++ stable/10/sys/arm/conf/BEAGLEBONE Sun Aug 23 20:50:22 2015 (r287082) @@ -64,7 +64,7 @@ options VFP # Enable floating point h # Debugging for use in -current makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols -options BREAK_TO_DEBUGGER +options ALT_BREAK_TO_DEBUGGER #options VERBOSE_SYSINIT # Enable verbose sysinit messages options KDB # Enable kernel debugger support # For minimum debugger support (stable branch) use: Modified: stable/10/sys/arm/conf/CUBIEBOARD ============================================================================== --- stable/10/sys/arm/conf/CUBIEBOARD Sun Aug 23 20:44:53 2015 (r287081) +++ stable/10/sys/arm/conf/CUBIEBOARD Sun Aug 23 20:50:22 2015 (r287082) @@ -59,7 +59,7 @@ options VFP # Enable floating point h # Debugging for use in -current makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols -options BREAK_TO_DEBUGGER +options ALT_BREAK_TO_DEBUGGER #options VERBOSE_SYSINIT # Enable verbose sysinit messages options KDB # Enable kernel debugger support # For minimum debugger support (stable branch) use: Modified: stable/10/sys/arm/conf/CUBIEBOARD2 ============================================================================== --- stable/10/sys/arm/conf/CUBIEBOARD2 Sun Aug 23 20:44:53 2015 (r287081) +++ stable/10/sys/arm/conf/CUBIEBOARD2 Sun Aug 23 20:50:22 2015 (r287082) @@ -60,7 +60,7 @@ options SMP # Enable multiple cores # Debugging for use in -current makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols -options BREAK_TO_DEBUGGER +options ALT_BREAK_TO_DEBUGGER #options VERBOSE_SYSINIT # Enable verbose sysinit messages options KDB # Enable kernel debugger support # For minimum debugger support (stable branch) use: Modified: stable/10/sys/arm/conf/DOCKSTAR ============================================================================== --- stable/10/sys/arm/conf/DOCKSTAR Sun Aug 23 20:44:53 2015 (r287081) +++ stable/10/sys/arm/conf/DOCKSTAR Sun Aug 23 20:50:22 2015 (r287082) @@ -140,7 +140,6 @@ options ALTQ_NOPCC # Required if the T # Debugging makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols -options BREAK_TO_DEBUGGER options ALT_BREAK_TO_DEBUGGER options DDB options KDB Modified: stable/10/sys/arm/conf/DREAMPLUG-1001 ============================================================================== --- stable/10/sys/arm/conf/DREAMPLUG-1001 Sun Aug 23 20:44:53 2015 (r287081) +++ stable/10/sys/arm/conf/DREAMPLUG-1001 Sun Aug 23 20:50:22 2015 (r287082) @@ -148,7 +148,6 @@ options ALTQ_NOPCC # Required if the T # Debugging makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols -options BREAK_TO_DEBUGGER options ALT_BREAK_TO_DEBUGGER options DDB options KDB Modified: stable/10/sys/arm/conf/EFIKA_MX ============================================================================== --- stable/10/sys/arm/conf/EFIKA_MX Sun Aug 23 20:44:53 2015 (r287081) +++ stable/10/sys/arm/conf/EFIKA_MX Sun Aug 23 20:50:22 2015 (r287082) @@ -64,7 +64,7 @@ options VFP # Enable floating point h # Debugging for use in -current makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols -options BREAK_TO_DEBUGGER +options ALT_BREAK_TO_DEBUGGER #options VERBOSE_SYSINIT # Enable verbose sysinit messages options KDB # Enable kernel debugger support # For minimum debugger support (stable branch) use: Modified: stable/10/sys/arm/conf/EXYNOS5.common ============================================================================== --- stable/10/sys/arm/conf/EXYNOS5.common Sun Aug 23 20:44:53 2015 (r287081) +++ stable/10/sys/arm/conf/EXYNOS5.common Sun Aug 23 20:50:22 2015 (r287082) @@ -57,7 +57,7 @@ options SMP # Enable multiple cores # Debugging for use in -current makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols -options BREAK_TO_DEBUGGER +options ALT_BREAK_TO_DEBUGGER #options VERBOSE_SYSINIT # Enable verbose sysinit messages options KDB # Enable kernel debugger support # For minimum debugger support (stable branch) use: Modified: stable/10/sys/arm/conf/PANDABOARD ============================================================================== --- stable/10/sys/arm/conf/PANDABOARD Sun Aug 23 20:44:53 2015 (r287081) +++ stable/10/sys/arm/conf/PANDABOARD Sun Aug 23 20:50:22 2015 (r287082) @@ -67,7 +67,7 @@ options SMP # Enable multiple cores # Debugging for use in -current makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols -options BREAK_TO_DEBUGGER +options ALT_BREAK_TO_DEBUGGER #options VERBOSE_SYSINIT # Enable verbose sysinit messages options KDB # Enable kernel debugger support # For minimum debugger support (stable branch) use: Modified: stable/10/sys/arm/conf/RPI-B ============================================================================== --- stable/10/sys/arm/conf/RPI-B Sun Aug 23 20:44:53 2015 (r287081) +++ stable/10/sys/arm/conf/RPI-B Sun Aug 23 20:50:22 2015 (r287082) @@ -59,7 +59,6 @@ options VFP # Enable floating point h # Debugging for use in -current makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols -options BREAK_TO_DEBUGGER options ALT_BREAK_TO_DEBUGGER #options VERBOSE_SYSINIT # Enable verbose sysinit messages options KDB # Enable kernel debugger support Modified: stable/10/sys/arm/conf/VYBRID ============================================================================== --- stable/10/sys/arm/conf/VYBRID Sun Aug 23 20:44:53 2015 (r287081) +++ stable/10/sys/arm/conf/VYBRID Sun Aug 23 20:50:22 2015 (r287082) @@ -61,7 +61,7 @@ options VFP # Enable floating point h # Debugging for use in -current makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols -options BREAK_TO_DEBUGGER +options ALT_BREAK_TO_DEBUGGER #options VERBOSE_SYSINIT # Enable verbose sysinit messages options KDB # Enable kernel debugger support # For minimum debugger support (stable branch) use: Modified: stable/10/sys/arm/conf/ZEDBOARD ============================================================================== --- stable/10/sys/arm/conf/ZEDBOARD Sun Aug 23 20:44:53 2015 (r287081) +++ stable/10/sys/arm/conf/ZEDBOARD Sun Aug 23 20:50:22 2015 (r287082) @@ -59,7 +59,7 @@ options SMP # Enable multiple cores # Debugging for use in -current makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols -#options BREAK_TO_DEBUGGER +options ALT_BREAK_TO_DEBUGGER options KDB # Enable kernel debugger support # For minimum debugger support (stable branch) use: #options KDB_TRACE # Print a stack trace for a panic From owner-svn-src-stable@freebsd.org Sun Aug 23 21:42:30 2015 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5DEF79BF17C; Sun, 23 Aug 2015 21:42:30 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4C6FC1388; Sun, 23 Aug 2015 21:42:30 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7NLgU2h033234; Sun, 23 Aug 2015 21:42:30 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7NLgSXX033227; Sun, 23 Aug 2015 21:42:28 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201508232142.t7NLgSXX033227@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sun, 23 Aug 2015 21:42:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r287084 - in stable/10/usr.sbin/pw: . tests X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 23 Aug 2015 21:42:30 -0000 Author: bapt Date: Sun Aug 23 21:42:27 2015 New Revision: 287084 URL: https://svnweb.freebsd.org/changeset/base/287084 Log: MFC: r285133,r285136,r285137,r285156,r285157,r285158,r285256,r285318,r285395, r285396,r285398,r285401,r285403,r285405,r285406,r285408,r285409,r285411, r285412,r285413,r285415,r285418,r285430,r285433,r285434,r285442,r285948, r285984,r285985,r285989,r285996,r285997,r286045,r286047,r286066,r286150, r286151,r286152,r286154,r286155,r286156,r286157,r286173,r286196,r286197, r286198,r286199,r286200,r286201,r286202,r286203,r286204,r286210,r286211, r286217,r286218,r286258,r286259,r286341,r286775,r286982,r286986,r286991, r286993 Validate most pw inputs. Rewrite the way parsing sub arguments is made to simplify code and improve maintenability Add -y (NIS) to userdel/usermod pw userdel -r now deletes directories in the rootdir Only parse pw.conf when needed Reject usermod and userdel if the user concerned is not on the user database supposed to be manipulated Added: stable/10/usr.sbin/pw/pw_utils.c - copied, changed from r286196, head/usr.sbin/pw/pw_utils.c stable/10/usr.sbin/pw/strtounum.c - copied, changed from r285997, head/usr.sbin/pw/strtounum.c stable/10/usr.sbin/pw/tests/pw_groupadd.sh - copied, changed from r285985, head/usr.sbin/pw/tests/pw_groupadd.sh Deleted: stable/10/usr.sbin/pw/fileupd.c Modified: stable/10/usr.sbin/pw/Makefile stable/10/usr.sbin/pw/cpdir.c stable/10/usr.sbin/pw/grupd.c stable/10/usr.sbin/pw/psdate.c stable/10/usr.sbin/pw/pw.8 stable/10/usr.sbin/pw/pw.c stable/10/usr.sbin/pw/pw.h stable/10/usr.sbin/pw/pw_conf.c stable/10/usr.sbin/pw/pw_group.c stable/10/usr.sbin/pw/pw_log.c stable/10/usr.sbin/pw/pw_nis.c stable/10/usr.sbin/pw/pw_user.c stable/10/usr.sbin/pw/pw_vpw.c stable/10/usr.sbin/pw/pwupd.c stable/10/usr.sbin/pw/pwupd.h stable/10/usr.sbin/pw/rm_r.c stable/10/usr.sbin/pw/tests/Makefile stable/10/usr.sbin/pw/tests/helper_functions.shin stable/10/usr.sbin/pw/tests/pw_groupdel.sh stable/10/usr.sbin/pw/tests/pw_groupmod.sh stable/10/usr.sbin/pw/tests/pw_useradd.sh stable/10/usr.sbin/pw/tests/pw_userdel.sh stable/10/usr.sbin/pw/tests/pw_usermod.sh Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.sbin/pw/Makefile ============================================================================== --- stable/10/usr.sbin/pw/Makefile Sun Aug 23 21:10:20 2015 (r287083) +++ stable/10/usr.sbin/pw/Makefile Sun Aug 23 21:42:27 2015 (r287084) @@ -5,8 +5,8 @@ PROG= pw MAN= pw.conf.5 pw.8 SRCS= pw.c pw_conf.c pw_user.c pw_group.c pw_log.c pw_nis.c pw_vpw.c \ - grupd.c pwupd.c fileupd.c psdate.c \ - bitmap.c cpdir.c rm_r.c + grupd.c pwupd.c psdate.c bitmap.c cpdir.c rm_r.c strtounum.c \ + pw_utils.c WARNS?= 3 Modified: stable/10/usr.sbin/pw/cpdir.c ============================================================================== --- stable/10/usr.sbin/pw/cpdir.c Sun Aug 23 21:10:20 2015 (r287083) +++ stable/10/usr.sbin/pw/cpdir.c Sun Aug 23 21:42:27 2015 (r287084) @@ -29,103 +29,96 @@ static const char rcsid[] = "$FreeBSD$"; #endif /* not lint */ +#include #include #include #include -#include #include -#include #include -#include -#include -#include -#include #include "pw.h" #include "pwupd.h" void -copymkdir(char const * dir, char const * skel, mode_t mode, uid_t uid, gid_t gid) +copymkdir(int rootfd, char const * dir, int skelfd, mode_t mode, uid_t uid, + gid_t gid, int flags) { - char src[MAXPATHLEN]; - char dst[MAXPATHLEN]; - char lnk[MAXPATHLEN]; - int len; + char *p, lnk[MAXPATHLEN], copybuf[4096]; + int len, homefd, srcfd, destfd; + ssize_t sz; + struct stat st; + struct dirent *e; + DIR *d; - if (mkdir(dir, mode) != 0 && errno != EEXIST) { + if (*dir == '/') + dir++; + + if (mkdirat(rootfd, dir, mode) != 0 && errno != EEXIST) { warn("mkdir(%s)", dir); - } else { - int infd, outfd; - struct stat st; - - static char counter = 0; - static char *copybuf = NULL; - - ++counter; - chown(dir, uid, gid); - if (skel != NULL && *skel != '\0') { - DIR *d = opendir(skel); - - if (d != NULL) { - struct dirent *e; - - while ((e = readdir(d)) != NULL) { - char *p = e->d_name; - - if (snprintf(src, sizeof(src), "%s/%s", skel, p) >= (int)sizeof(src)) - warn("warning: pathname too long '%s/%s' (skel not copied)", skel, p); - else if (lstat(src, &st) == 0) { - if (strncmp(p, "dot.", 4) == 0) /* Conversion */ - p += 3; - if (snprintf(dst, sizeof(dst), "%s/%s", dir, p) >= (int)sizeof(dst)) - warn("warning: path too long '%s/%s' (skel file skipped)", dir, p); - else { - if (S_ISDIR(st.st_mode)) { /* Recurse for this */ - if (strcmp(e->d_name, ".") != 0 && strcmp(e->d_name, "..") != 0) - copymkdir(dst, src, st.st_mode & _DEF_DIRMODE, uid, gid); - chflags(dst, st.st_flags); /* propagate flags */ - } else if (S_ISLNK(st.st_mode) && (len = readlink(src, lnk, sizeof(lnk) - 1)) != -1) { - lnk[len] = '\0'; - symlink(lnk, dst); - lchown(dst, uid, gid); - /* - * Note: don't propagate special attributes - * but do propagate file flags - */ - } else if (S_ISREG(st.st_mode) && (outfd = open(dst, O_RDWR | O_CREAT | O_EXCL, st.st_mode)) != -1) { - if ((infd = open(src, O_RDONLY)) == -1) { - close(outfd); - remove(dst); - } else { - int b; - - /* - * Allocate our copy buffer if we need to - */ - if (copybuf == NULL) - copybuf = malloc(4096); - while ((b = read(infd, copybuf, 4096)) > 0) - write(outfd, copybuf, b); - close(infd); - /* - * Propagate special filesystem flags - */ - fchown(outfd, uid, gid); - fchflags(outfd, st.st_flags); - close(outfd); - chown(dst, uid, gid); - } - } - } - } - } - closedir(d); - } + return; + } + fchownat(rootfd, dir, uid, gid, AT_SYMLINK_NOFOLLOW); + if (flags > 0) + chflagsat(rootfd, dir, flags, AT_SYMLINK_NOFOLLOW); + + if (skelfd == -1) + return; + + homefd = openat(rootfd, dir, O_DIRECTORY); + if ((d = fdopendir(skelfd)) == NULL) { + close(skelfd); + close(homefd); + return; + } + + while ((e = readdir(d)) != NULL) { + if (strcmp(e->d_name, ".") == 0 || strcmp(e->d_name, "..") == 0) + continue; + + p = e->d_name; + if (fstatat(skelfd, p, &st, AT_SYMLINK_NOFOLLOW) == -1) + continue; + + if (strncmp(p, "dot.", 4) == 0) /* Conversion */ + p += 3; + + if (S_ISDIR(st.st_mode)) { + copymkdir(homefd, p, openat(skelfd, e->d_name, O_DIRECTORY), + st.st_mode & _DEF_DIRMODE, uid, gid, st.st_flags); + continue; } - if (--counter == 0 && copybuf != NULL) { - free(copybuf); - copybuf = NULL; + + if (S_ISLNK(st.st_mode) && + (len = readlinkat(skelfd, e->d_name, lnk, sizeof(lnk) -1)) + != -1) { + lnk[len] = '\0'; + symlinkat(lnk, homefd, p); + fchownat(homefd, p, uid, gid, AT_SYMLINK_NOFOLLOW); + continue; } + + if (!S_ISREG(st.st_mode)) + continue; + + if ((srcfd = openat(skelfd, e->d_name, O_RDONLY)) == -1) + continue; + destfd = openat(homefd, p, O_RDWR | O_CREAT | O_EXCL, + st.st_mode); + if (destfd == -1) { + close(srcfd); + continue; + } + + while ((sz = read(srcfd, copybuf, sizeof(copybuf))) > 0) + write(destfd, copybuf, sz); + + close(srcfd); + /* + * Propagate special filesystem flags + */ + fchown(destfd, uid, gid); + fchflags(destfd, st.st_flags); + close(destfd); } + closedir(d); } - Modified: stable/10/usr.sbin/pw/grupd.c ============================================================================== --- stable/10/usr.sbin/pw/grupd.c Sun Aug 23 21:10:20 2015 (r287083) +++ stable/10/usr.sbin/pw/grupd.c Sun Aug 23 21:42:27 2015 (r287084) @@ -29,13 +29,11 @@ static const char rcsid[] = "$FreeBSD$"; #endif /* not lint */ +#include #include #include -#include #include #include -#include -#include #include "pwupd.h" Modified: stable/10/usr.sbin/pw/psdate.c ============================================================================== --- stable/10/usr.sbin/pw/psdate.c Sun Aug 23 21:10:20 2015 (r287083) +++ stable/10/usr.sbin/pw/psdate.c Sun Aug 23 21:42:27 2015 (r287084) @@ -29,30 +29,16 @@ static const char rcsid[] = "$FreeBSD$"; #endif /* not lint */ -#include +#include +#include #include #include -#include +#include #include "psdate.h" static int -a2i(char const ** str) -{ - int i = 0; - char const *s = *str; - - if (isdigit((unsigned char)*s)) { - i = atoi(s); - while (isdigit((unsigned char)*s)) - ++s; - *str = s; - } - return i; -} - -static int numerics(char const * str) { int rc = isdigit((unsigned char)*str); @@ -95,61 +81,73 @@ weekday(char const ** str) return aindex(days, str, 3); } -static int -month(char const ** str) -{ - static char const *months[] = - {"jan", "feb", "mar", "apr", "may", "jun", "jul", - "aug", "sep", "oct", "nov", "dec", NULL}; - - return aindex(months, str, 3); -} - static void -parse_time(char const * str, int *hour, int *min, int *sec) +parse_datesub(char const * str, struct tm *t) { - *hour = a2i(&str); - if ((str = strchr(str, ':')) == NULL) - *min = *sec = 0; - else { - ++str; - *min = a2i(&str); - *sec = ((str = strchr(str, ':')) == NULL) ? 0 : atoi(++str); + struct tm tm; + locale_t l; + int i; + char *ret; + const char *valid_formats[] = { + "%d-%b-%y", + "%d-%b-%Y", + "%d-%m-%y", + "%d-%m-%Y", + "%H:%M %d-%b-%y", + "%H:%M %d-%b-%Y", + "%H:%M %d-%m-%y", + "%H:%M %d-%m-%Y", + "%H:%M:%S %d-%b-%y", + "%H:%M:%S %d-%b-%Y", + "%H:%M:%S %d-%m-%y", + "%H:%M:%S %d-%m-%Y", + "%d-%b-%y %H:%M", + "%d-%b-%Y %H:%M", + "%d-%m-%y %H:%M", + "%d-%m-%Y %H:%M", + "%d-%b-%y %H:%M:%S", + "%d-%b-%Y %H:%M:%S", + "%d-%m-%y %H:%M:%S", + "%d-%m-%Y %H:%M:%S", + "%H:%M\t%d-%b-%y", + "%H:%M\t%d-%b-%Y", + "%H:%M\t%d-%m-%y", + "%H:%M\t%d-%m-%Y", + "%H:%M\t%S %d-%b-%y", + "%H:%M\t%S %d-%b-%Y", + "%H:%M\t%S %d-%m-%y", + "%H:%M\t%S %d-%m-%Y", + "%d-%b-%y\t%H:%M", + "%d-%b-%Y\t%H:%M", + "%d-%m-%y\t%H:%M", + "%d-%m-%Y\t%H:%M", + "%d-%b-%y\t%H:%M:%S", + "%d-%b-%Y\t%H:%M:%S", + "%d-%m-%y\t%H:%M:%S", + "%d-%m-%Y\t%H:%M:%S", + NULL, + }; + + l = newlocale(LC_ALL_MASK, "C", NULL); + + memset(&tm, 0, sizeof(tm)); + for (i=0; valid_formats[i] != NULL; i++) { + ret = strptime_l(str, valid_formats[i], &tm, l); + if (ret && *ret == '\0') { + t->tm_mday = tm.tm_mday; + t->tm_mon = tm.tm_mon; + t->tm_year = tm.tm_year; + t->tm_hour = tm.tm_hour; + t->tm_min = tm.tm_min; + t->tm_sec = tm.tm_sec; + freelocale(l); + return; + } } -} - - -static void -parse_datesub(char const * str, int *day, int *mon, int *year) -{ - int i; - static char const nchrs[] = "0123456789 \t,/-."; + freelocale(l); - if ((i = month(&str)) != -1) { - *mon = i; - if ((i = a2i(&str)) != 0) - *day = i; - } else if ((i = a2i(&str)) != 0) { - *day = i; - while (*str && strchr(nchrs + 10, *str) != NULL) - ++str; - if ((i = month(&str)) != -1) - *mon = i; - else if ((i = a2i(&str)) != 0) - *mon = i - 1; - } else - return; - - while (*str && strchr(nchrs + 10, *str) != NULL) - ++str; - if (isdigit((unsigned char)*str)) { - *year = atoi(str); - if (*year > 1900) - *year -= 1900; - else if (*year < 32) - *year += 100; - } + errx(EXIT_FAILURE, "Invalid date"); } @@ -256,39 +254,7 @@ parse_date(time_t dt, char const * str) } } - /* - * See if there is a time hh:mm[:ss] - */ - if ((p = strchr(tmp, ':')) == NULL) { - - /* - * No time string involved - */ - T->tm_hour = T->tm_min = T->tm_sec = 0; - parse_datesub(tmp, &T->tm_mday, &T->tm_mon, &T->tm_year); - } else { - char datestr[64], timestr[64]; - - /* - * Let's chip off the time string - */ - if ((q = strpbrk(p, " \t")) != NULL) { /* Time first? */ - int l = q - str; - - strlcpy(timestr, str, l + 1); - strlcpy(datestr, q + 1, sizeof(datestr)); - parse_time(timestr, &T->tm_hour, &T->tm_min, &T->tm_sec); - parse_datesub(datestr, &T->tm_mday, &T->tm_mon, &T->tm_year); - } else if ((q = strrchr(tmp, ' ')) != NULL) { /* Time last */ - int l = q - tmp; - - strlcpy(timestr, q + 1, sizeof(timestr)); - strlcpy(datestr, tmp, l + 1); - } else /* Bail out */ - return dt; - parse_time(timestr, &T->tm_hour, &T->tm_min, &T->tm_sec); - parse_datesub(datestr, &T->tm_mday, &T->tm_mon, &T->tm_year); - } + parse_datesub(tmp, T); dt = mktime(T); } return dt; Modified: stable/10/usr.sbin/pw/pw.8 ============================================================================== --- stable/10/usr.sbin/pw/pw.8 Sun Aug 23 21:10:20 2015 (r287083) +++ stable/10/usr.sbin/pw/pw.8 Sun Aug 23 21:42:27 2015 (r287084) @@ -35,11 +35,9 @@ .Op Fl R Ar rootdir .Op Fl V Ar etcdir .Ar useradd -.Op name|uid +.Oo Fl n Oc name Oo Fl u Ar uid Oc .Op Fl C Ar config .Op Fl q -.Op Fl n Ar name -.Op Fl u Ar uid .Op Fl c Ar comment .Op Fl d Ar dir .Op Fl e Ar date @@ -61,7 +59,6 @@ .Op Fl R Ar rootdir .Op Fl V Ar etcdir .Ar useradd -.Op name|uid .Fl D .Op Fl C Ar config .Op Fl q @@ -81,27 +78,23 @@ .Op Fl R Ar rootdir .Op Fl V Ar etcdir .Ar userdel -.Op name|uid -.Op Fl n Ar name -.Op Fl u Ar uid +.Oo Fl n Oc name|uid | Fl u Ar uid .Op Fl r .Op Fl Y .Nm .Op Fl R Ar rootdir .Op Fl V Ar etcdir .Ar usermod -.Op name|uid +.Oo Fl n Oc name|uid Oo Fl u Ar newuid Oc | Fl u Ar uid .Op Fl C Ar config .Op Fl q -.Op Fl n Ar name -.Op Fl u Ar uid .Op Fl c Ar comment .Op Fl d Ar dir .Op Fl e Ar date .Op Fl p Ar date .Op Fl g Ar group .Op Fl G Ar grouplist -.Op Fl l Ar name +.Op Fl l Ar newname .Op Fl m .Op Fl M Ar mode .Op Fl k Ar dir @@ -116,9 +109,7 @@ .Op Fl R Ar rootdir .Op Fl V Ar etcdir .Ar usershow -.Op name|uid -.Op Fl n Ar name -.Op Fl u Ar uid +.Oo Fl n Oc name|uid | Fl u Ar uid .Op Fl F .Op Fl P .Op Fl 7 @@ -133,11 +124,9 @@ .Op Fl R Ar rootdir .Op Fl V Ar etcdir .Ar groupadd -.Op group|gid +.Oo Fl n Oc name Oo Fl g Ar gid Oc .Op Fl C Ar config .Op Fl q -.Op Fl n Ar group -.Op Fl g Ar gid .Op Fl M Ar members .Op Fl o .Op Fl h Ar fd | Fl H Ar fd @@ -148,20 +137,16 @@ .Op Fl R Ar rootdir .Op Fl V Ar etcdir .Ar groupdel -.Op group|gid -.Op Fl n Ar name -.Op Fl g Ar gid +.Oo Fl n Oc name|gid | Fl g Ar gid .Op Fl Y .Nm .Op Fl R Ar rootdir .Op Fl V Ar etcdir .Ar groupmod -.Op group|gid +.Oo Fl n Oc name|gid Oo Fl g Ar newgid Oc | Fl g Ar gid .Op Fl C Ar config .Op Fl q -.Op Fl n Ar name -.Op Fl g Ar gid -.Op Fl l Ar name +.Op Fl l Ar newname .Op Fl M Ar members .Op Fl m Ar newmembers .Op Fl d Ar oldmembers @@ -173,9 +158,7 @@ .Op Fl R Ar rootdir .Op Fl V Ar etcdir .Ar groupshow -.Op group|gid -.Op Fl n Ar name -.Op Fl g Ar gid +.Oo Fl n Oc name|gid | Fl g Ar gid .Op Fl F .Op Fl P .Op Fl a @@ -189,14 +172,14 @@ .Op Fl R Ar rootdir .Op Fl V Ar etcdir .Ar lock -.Op name|uid +.Oo Fl n Oc name|uid | Fl u Ar uid .Op Fl C Ar config .Op Fl q .Nm .Op Fl R Ar rootdir .Op Fl V Ar etcdir .Ar unlock -.Op name|uid +.Oo Fl n Oc name|uid | Fl u Ar uid .Op Fl C Ar config .Op Fl q .Sh DESCRIPTION @@ -250,8 +233,9 @@ all mean the same thing.) This flexibility is useful for interactive scripts calling .Nm for user and group database manipulation. -Following these keywords, you may optionally specify the user or group name or numeric -id as an alternative to using the +Following these keywords, +the user or group name or numeric id may be optionally specified as an +alternative to using the .Fl n Ar name , .Fl u Ar uid , .Fl g Ar gid @@ -266,12 +250,13 @@ will operate. Any paths specified will be relative to .Va rootdir . .It Fl V Ar etcdir -This flag sets an alternate location for the password, group and configuration files, -and may be used to maintain a user/group database in an alternate location. +Set an alternate location for the password, group, and configuration files. +Can be used to maintain a user/group database in an alternate location. If this switch is specified, the system .Pa /etc/pw.conf -will not be sourced for default configuration data, but the file pw.conf in the -specified directory will be used instead (or none, if it does not exist). +will not be sourced for default configuration data, +but the file pw.conf in the specified directory will be used instead +.Pq or none, if it does not exist . The .Fl C flag may be used to override this behaviour. @@ -294,7 +279,8 @@ configuration file. .It Fl q Use of this option causes .Nm -to suppress error messages, which may be useful in interactive environments where it +to suppress error messages, +which may be useful in interactive environments where it is preferable to interpret status codes returned by .Nm rather than messing up a carefully formatted display. @@ -338,27 +324,40 @@ and .Ar usermod commands: .Bl -tag -width "-G grouplist" -.It Fl n Ar name +.It Oo Fl n Oc Ar name +Required unless +.Fl u Ar uid +is given. Specify the user/account name. +In the case of +.Ar usermod +can be a uid. .It Fl u Ar uid +Required if +.Ar name +is not given. Specify the user/account numeric id. -.Pp -Usually, you only need to provide one or the other of these options, as the account -name will imply the uid, or vice versa. -However, there are times when you need to provide both. +In the case of +.Ar usermod +if paired with +.Ar name , +changes the numeric id of the named user/account. +.Pp +Usually, only one of these options is required, +as the account name will imply the uid, or vice versa. +However, there are times when both are needed. For example, when changing the uid of an existing user with .Ar usermod , -or overriding the default uid when creating a new account. -If you wish -.Nm -to automatically allocate the uid to a new user with +or overriding the default uid when creating a new account with +.Ar useradd . +To automatically allocate the uid to a new user with .Ar useradd , -then you should +then do .Em not use the .Fl u option. -You may also provide either the account or userid immediately after the +Either the account or userid can also be provided immediately after the .Ar useradd , .Ar userdel , .Ar usermod @@ -372,21 +371,23 @@ options. .El .Bl -tag -width "-G grouplist" .It Fl c Ar comment -This field sets the contents of the passwd GECOS field, which normally contains up -to four comma-separated fields containing the user's full name, office or location, +This field sets the contents of the passwd GECOS field, +which normally contains up to four comma-separated fields containing the +user's full name, office or location, and work and home phone numbers. These sub-fields are used by convention only, however, and are optional. -If this field is to contain spaces, you need to quote the comment itself with double -quotes +If this field is to contain spaces, +the comment must be enclosed in double quotes .Ql \&" . -Avoid using commas in this field as these are used as sub-field separators, and the -colon +Avoid using commas in this field as these are used as sub-field separators, +and the colon .Ql \&: character also cannot be used as this is the field separator for the passwd file itself. .It Fl d Ar dir This option sets the account's home directory. -Normally, you will only use this if the home directory is to be different from the +Normally, +this is only used if the home directory is to be different from the default determined from .Pa /etc/pw.conf - normally @@ -396,13 +397,15 @@ with the account name as a subdirectory. Set the account's expiration date. Format of the date is either a UNIX time in decimal, or a date in .Ql dd-mmm-yy[yy] -format, where dd is the day, mmm is the month, either in numeric or alphabetic format +format, where dd is the day, +mmm is the month, either in numeric or alphabetic format ('Jan', 'Feb', etc) and year is either a two or four digit year. This option also accepts a relative date in the form .Ql \&+n[mhdwoy] where .Ql \&n -is a decimal, octal (leading 0) or hexadecimal (leading 0x) digit followed by the +is a decimal, +octal (leading 0) or hexadecimal (leading 0x) digit followed by the number of Minutes, Hours, Days, Weeks, Months or Years from the current date at which the expiration date is to be set. .It Fl p Ar date @@ -442,8 +445,8 @@ This option instructs to attempt to create the user's home directory. While primarily useful when adding a new account with .Ar useradd , -this may also be of use when moving an existing user's home directory elsewhere on -the file system. +this may also be of use when moving an existing user's home directory elsewhere +on the file system. The new home directory is populated with the contents of the .Ar skeleton directory, which typically contains a set of shell configuration files that the @@ -461,7 +464,8 @@ existing configuration files in the user .Em not overwritten from the skeleton files. .Pp -When a user's home directory is created, it will by default be a subdirectory of the +When a user's home directory is created, +it will by default be a subdirectory of the .Ar basehome directory as specified by the .Fl b @@ -599,10 +603,13 @@ The default value for this is but it may be set elsewhere as desired. .It Fl e Ar days Set the default account expiration period in days. -Unlike use without -.Fl D , -the argument must be numeric, which specifies the number of days after creation when -the account is to expire. +When +.Fl D +is used, the +.Ar days +argument is interpreted differently. +It must be numeric and represents the number of days after creation +that the account expires. A value of 0 suppresses automatic calculation of the expiry date. .It Fl p Ar days Set the default password expiration period in days. @@ -615,8 +622,8 @@ with the same name as their login name. If a group is supplied, either its name or uid may be given as an argument. .It Fl G Ar grouplist Set the default groups in which new users are granted membership. -This is a separate set of groups from the primary group, and you should avoid -nominating the same group as both primary and extra groups. +This is a separate set of groups from the primary group. +Avoid nominating the same group as both primary and extra groups. In other words, these extra groups determine membership in groups .Em other than the primary group. @@ -630,7 +637,8 @@ This option sets the default login class .It Fl k Ar dir Set the default .Em skeleton -directory, from which prototype shell and other initialization files are copied when +directory, +from which prototype shell and other initialization files are copied when .Nm creates a user's home directory. See description of @@ -640,22 +648,24 @@ for naming conventions of these files. .Fl u Ar min , Ns Ar max , .Fl i Ar min , Ns Ar max .Xc -These options set the minimum and maximum user and group ids allocated for new accounts -and groups created by +Set the minimum and maximum user and group ids allocated for new +accounts and groups created by .Nm . The default values for each is 1000 minimum and 32000 maximum. .Ar min and .Ar max -are both numbers, where max must be greater than min, and both must be between 0 -and 32767. -In general, user and group ids less than 100 are reserved for use by the system, -and numbers greater than 32000 may also be reserved for special purposes (used by -some system daemons). +are both numbers, where max must be greater than min, +and both must be between 0 and 32767. +In general, +user and group ids less than 100 are reserved for use by the system, +and numbers greater than 32000 may also be reserved for special purposes +.Pq used by some system daemons . .It Fl w Ar method The .Fl w -option sets the default method used to set passwords for newly created user accounts. +option selects the default method used to set passwords for newly created user +accounts. .Ar method is one of: .Pp @@ -676,9 +686,11 @@ or .Ql \&no methods are the most secure; in the former case, .Nm -generates a password and prints it to stdout, which is suitable where you issue -users with passwords to access their accounts rather than having the user nominate -their own (possibly poorly chosen) password. +generates a password and prints it to stdout, +which is suitable when users are issued passwords rather than being allowed +to select their own +.Pq possibly poorly chosen +password. The .Ql \&no method requires that the superuser use @@ -699,7 +711,7 @@ servers. .Pp The .Ar userdel -command has only three valid options. +command has three distinct options. The .Fl n Ar name and @@ -714,7 +726,8 @@ to remove the user's home directory and The .Nm utility errs on the side of caution when removing files from the system. -Firstly, it will not do so if the uid of the account being removed is also used by +Firstly, +it will not do so if the uid of the account being removed is also used by another account on the system, and the 'home' directory in the password file is a valid path that commences with the character .Ql \&/ . @@ -725,20 +738,20 @@ will be removed. If any additional cleanup work is required, this is left to the administrator. .El .Pp -Mail spool files and crontabs are always removed when an account is deleted as these -are unconditionally attached to the user name. +Mail spool files and crontabs are always removed when an account is deleted as +these are unconditionally attached to the user name. Jobs queued for processing by .Ar at -are also removed if the user's uid is unique and not also used by another account on the -system. +are also removed if the user's uid is unique and not also used by another +account on the system. .Pp The .Ar usermod command adds one additional option: .Bl -tag -width "-G grouplist" -.It Fl l Ar name +.It Fl l Ar newname This option allows changing of an existing account name to -.Ql \&name . +.Ql \&newname . The new name must not already exist, and any attempt to duplicate an existing account name will be rejected. .El @@ -782,10 +795,24 @@ options (explained at the start of the p with the group manipulation commands. Other common options to all group-related commands are: .Bl -tag -width "-m newmembers" -.It Fl n Ar name +.It Oo Fl n Oc Ar name +Required unless +.Fl g Ar gid +is given. Specify the group name. +In the case of +.Ar groupmod +can be a gid. .It Fl g Ar gid +Required if +.Ar name +is not given. Specify the group numeric id. +In the case of +.Ar groupmod +if paired with +.Ar name , +changes the numeric id of the named group. .Pp As with the account name and id fields, you will usually only need to supply one of these, as the group name implies the uid and vice @@ -822,18 +849,19 @@ silently eliminated. also has a .Fl o option that allows allocation of an existing group id to a new group. -The default action is to reject an attempt to add a group, and this option overrides -the check for duplicate group ids. +The default action is to reject an attempt to add a group, +and this option overrides the check for duplicate group ids. There is rarely any need to duplicate a group id. .Pp The .Ar groupmod command adds one additional option: .Bl -tag -width "-m newmembers" -.It Fl l Ar name +.It Fl l Ar newname This option allows changing of an existing group name to -.Ql \&name . -The new name must not already exist, and any attempt to duplicate an existing group +.Ql \&newname . +The new name must not already exist, +and any attempt to duplicate an existing group name will be rejected. .El .Pp Modified: stable/10/usr.sbin/pw/pw.c ============================================================================== --- stable/10/usr.sbin/pw/pw.c Sun Aug 23 21:10:20 2015 (r287083) +++ stable/10/usr.sbin/pw/pw.c Sun Aug 23 21:42:27 2015 (r287084) @@ -32,14 +32,12 @@ static const char rcsid[] = #include #include #include -#include -#include -#include +#include +#include +#include + #include "pw.h" -#if !defined(_PATH_YP) -#define _PATH_YP "/var/yp/" -#endif const char *Modes[] = { "add", "del", "mod", "show", "next", NULL}; @@ -85,71 +83,53 @@ struct pwf VPWF = vgetgrnam, }; -struct pwconf conf; - -static struct cargs arglist; +static int (*cmdfunc[W_NUM][M_NUM])(int argc, char **argv, char *_name) = { + { /* user */ + pw_user_add, + pw_user_del, + pw_user_mod, + pw_user_show, + pw_user_next, + pw_user_lock, + pw_user_unlock, + }, + { /* group */ + pw_group_add, + pw_group_del, + pw_group_mod, + pw_group_show, + pw_group_next, + } +}; -static int getindex(const char *words[], const char *word); -static void cmdhelp(int mode, int which); +struct pwconf conf; +static int getindex(const char *words[], const char *word); +static void cmdhelp(int mode, int which); int main(int argc, char *argv[]) { - int ch; - int mode = -1; - int which = -1; - long id = -1; - char *config = NULL; + int mode = -1, which = -1, tmp; struct stat st; - const char *errstr; - char arg, *name; + char arg, *arg1; bool relocated, nis; - static const char *opts[W_NUM][M_NUM] = - { - { /* user */ - "R:V:C:qn:u:c:d:e:p:g:G:mM:k:s:oL:i:w:h:H:Db:NPy:Y", - "R:V:C:qn:u:rY", - "R:V:C:qn:u:c:d:e:p:g:G:mM:l:k:s:w:L:h:H:FNPY", - "R:V:C:qn:u:FPa7", - "R:V:C:q", - "R:V:C:q", - "R:V:C:q" - }, - { /* grp */ - "R:V:C:qn:g:h:H:M:opNPY", - "R:V:C:qn:g:Y", - "R:V:C:qn:d:g:l:h:H:FM:m:NPY", - "R:V:C:qn:g:FPa", - "R:V:C:q" - } - }; - - static int (*funcs[W_NUM]) (int _mode, char *_name, long _id, - struct cargs * _args) = - { /* Request handlers */ - pw_user, - pw_group - }; - - name = NULL; + arg1 = NULL; relocated = nis = false; memset(&conf, 0, sizeof(conf)); + strlcpy(conf.rootdir, "/", sizeof(conf.rootdir)); strlcpy(conf.etcpath, _PATH_PWD, sizeof(conf.etcpath)); conf.checkduplicate = true; + conf.fd = -1; - LIST_INIT(&arglist); - - (void)setlocale(LC_ALL, ""); + setlocale(LC_ALL, ""); /* *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable@freebsd.org Mon Aug 24 03:41:15 2015 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A10C39C1329; Mon, 24 Aug 2015 03:41:15 +0000 (UTC) (envelope-from julian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 911FD1C41; Mon, 24 Aug 2015 03:41:15 +0000 (UTC) (envelope-from julian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7O3fFuk084300; Mon, 24 Aug 2015 03:41:15 GMT (envelope-from julian@FreeBSD.org) Received: (from julian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7O3fFqa084299; Mon, 24 Aug 2015 03:41:15 GMT (envelope-from julian@FreeBSD.org) Message-Id: <201508240341.t7O3fFqa084299@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: julian set sender to julian@FreeBSD.org using -f From: Julian Elischer Date: Mon, 24 Aug 2015 03:41:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r287090 - stable/10/sys/modules/dtrace/dtraceall X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Aug 2015 03:41:15 -0000 Author: julian Date: Mon Aug 24 03:41:14 2015 New Revision: 287090 URL: https://svnweb.freebsd.org/changeset/base/287090 Log: MFH: r273762 MFH: r276304 Allow loading of dtraceall without nfscl if what you really want is nfsclient Obtained from: Panzura tree and Rick Maclem Modified: stable/10/sys/modules/dtrace/dtraceall/dtraceall.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/modules/dtrace/dtraceall/dtraceall.c ============================================================================== --- stable/10/sys/modules/dtrace/dtraceall/dtraceall.c Mon Aug 24 01:53:18 2015 (r287089) +++ stable/10/sys/modules/dtrace/dtraceall/dtraceall.c Mon Aug 24 03:41:14 2015 (r287090) @@ -66,7 +66,9 @@ MODULE_VERSION(dtraceall, 1); MODULE_DEPEND(dtraceall, opensolaris, 1, 1, 1); MODULE_DEPEND(dtraceall, dtrace, 1, 1, 1); MODULE_DEPEND(dtraceall, dtmalloc, 1, 1, 1); +#if defined(NFSCL) MODULE_DEPEND(dtraceall, dtnfscl, 1, 1, 1); +#endif #if defined(NFSCLIENT) MODULE_DEPEND(dtraceall, dtnfsclient, 1, 1, 1); #endif From owner-svn-src-stable@freebsd.org Mon Aug 24 03:51:19 2015 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A42479C149E; Mon, 24 Aug 2015 03:51:19 +0000 (UTC) (envelope-from julian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9489A20C; Mon, 24 Aug 2015 03:51:19 +0000 (UTC) (envelope-from julian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7O3pJ5W089859; Mon, 24 Aug 2015 03:51:19 GMT (envelope-from julian@FreeBSD.org) Received: (from julian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7O3pJB2089858; Mon, 24 Aug 2015 03:51:19 GMT (envelope-from julian@FreeBSD.org) Message-Id: <201508240351.t7O3pJB2089858@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: julian set sender to julian@FreeBSD.org using -f From: Julian Elischer Date: Mon, 24 Aug 2015 03:51:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r287091 - stable/10/etc X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Aug 2015 03:51:19 -0000 Author: julian Date: Mon Aug 24 03:51:18 2015 New Revision: 287091 URL: https://svnweb.freebsd.org/changeset/base/287091 Log: MFH: r284691 MFH: r284920 Remove 16 rules and replace by 2 by using a table. I've been doing this ever since there were tables. I could make more efficient by using "in recv" and "out xmit" instead of via but I'll leave that. Modified: stable/10/etc/rc.firewall Directory Properties: stable/10/ (props changed) Modified: stable/10/etc/rc.firewall ============================================================================== --- stable/10/etc/rc.firewall Mon Aug 24 03:41:14 2015 (r287090) +++ stable/10/etc/rc.firewall Mon Aug 24 03:51:18 2015 (r287091) @@ -266,6 +266,7 @@ case ${firewall_type} in # firewall_simple_oif_ipv6: Outside IPv6 network interface. # firewall_simple_onet_ipv6: Outside IPv6 network prefix. ############ + BAD_ADDR_TBL=13 # set these to your outside interface network oif="$firewall_simple_oif" @@ -290,19 +291,23 @@ case ${firewall_type} in fi fi + # Define stuff we should never send out or receive in. # Stop RFC1918 nets on the outside interface - ${fwcmd} add deny all from any to 10.0.0.0/8 via ${oif} - ${fwcmd} add deny all from any to 172.16.0.0/12 via ${oif} - ${fwcmd} add deny all from any to 192.168.0.0/16 via ${oif} + ${fwcmd} table ${BAD_ADDR_TBL} flush + ${fwcmd} table ${BAD_ADDR_TBL} add 10.0.0.0/8 + ${fwcmd} table ${BAD_ADDR_TBL} add 172.16.0.0/12 + ${fwcmd} table ${BAD_ADDR_TBL} add 192.168.0.0/16 - # Stop draft-manning-dsua-03.txt (1 May 2000) nets (includes RESERVED-1, + # And stop draft-manning-dsua-03.txt (1 May 2000) nets (includes RESERVED-1, # DHCP auto-configuration, NET-TEST, MULTICAST (class D), and class E) # on the outside interface - ${fwcmd} add deny all from any to 0.0.0.0/8 via ${oif} - ${fwcmd} add deny all from any to 169.254.0.0/16 via ${oif} - ${fwcmd} add deny all from any to 192.0.2.0/24 via ${oif} - ${fwcmd} add deny all from any to 224.0.0.0/4 via ${oif} - ${fwcmd} add deny all from any to 240.0.0.0/4 via ${oif} + ${fwcmd} table ${BAD_ADDR_TBL} add 0.0.0.0/8 + ${fwcmd} table ${BAD_ADDR_TBL} add 169.254.0.0/16 + ${fwcmd} table ${BAD_ADDR_TBL} add 192.0.2.0/24 + ${fwcmd} table ${BAD_ADDR_TBL} add 224.0.0.0/4 + ${fwcmd} table ${BAD_ADDR_TBL} add 240.0.0.0/4 + + ${fwcmd} add deny all from any to "table($BAD_ADDR_TBL)" via ${oif} # Network Address Translation. This rule is placed here deliberately # so that it does not interfere with the surrounding address-checking @@ -319,20 +324,7 @@ case ${firewall_type} in ;; esac - # Stop RFC1918 nets on the outside interface - ${fwcmd} add deny all from 10.0.0.0/8 to any via ${oif} - ${fwcmd} add deny all from 172.16.0.0/12 to any via ${oif} - ${fwcmd} add deny all from 192.168.0.0/16 to any via ${oif} - - # Stop draft-manning-dsua-03.txt (1 May 2000) nets (includes RESERVED-1, - # DHCP auto-configuration, NET-TEST, MULTICAST (class D), and class E) - # on the outside interface - ${fwcmd} add deny all from 0.0.0.0/8 to any via ${oif} - ${fwcmd} add deny all from 169.254.0.0/16 to any via ${oif} - ${fwcmd} add deny all from 192.0.2.0/24 to any via ${oif} - ${fwcmd} add deny all from 224.0.0.0/4 to any via ${oif} - ${fwcmd} add deny all from 240.0.0.0/4 to any via ${oif} - + ${fwcmd} add deny all from "table($BAD_ADDR_TBL)" to any via ${oif} if [ -n "$inet6" ]; then # Stop unique local unicast address on the outside interface ${fwcmd} add deny all from fc00::/7 to any via ${oif6} From owner-svn-src-stable@freebsd.org Mon Aug 24 14:32:58 2015 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2190C9C122B; Mon, 24 Aug 2015 14:32:58 +0000 (UTC) (envelope-from brueffer@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0B70F1657; Mon, 24 Aug 2015 14:32:58 +0000 (UTC) (envelope-from brueffer@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7OEWvxi072295; Mon, 24 Aug 2015 14:32:57 GMT (envelope-from brueffer@FreeBSD.org) Received: (from brueffer@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7OEWv1N072294; Mon, 24 Aug 2015 14:32:57 GMT (envelope-from brueffer@FreeBSD.org) Message-Id: <201508241432.t7OEWv1N072294@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: brueffer set sender to brueffer@FreeBSD.org using -f From: Christian Brueffer Date: Mon, 24 Aug 2015 14:32:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r287110 - stable/10/usr.sbin/bhyve X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Aug 2015 14:32:58 -0000 Author: brueffer Date: Mon Aug 24 14:32:57 2015 New Revision: 287110 URL: https://svnweb.freebsd.org/changeset/base/287110 Log: MFC: r286409 Manpage cleanup. - new sentence -> new line - fix manpage references - fix macro usage - fix a typo Modified: stable/10/usr.sbin/bhyve/bhyve.8 Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.sbin/bhyve/bhyve.8 ============================================================================== --- stable/10/usr.sbin/bhyve/bhyve.8 Mon Aug 24 14:04:44 2015 (r287109) +++ stable/10/usr.sbin/bhyve/bhyve.8 Mon Aug 24 14:32:57 2015 (r287110) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 17, 2014 +.Dd August 7, 2015 .Dt BHYVE 8 .Os .Sh NAME @@ -50,7 +50,7 @@ Parameters such as the number of virtual I/O connectivity can be specified with command-line parameters. .Pp The guest operating system must be loaded with -.Xr bhyveload 4 +.Xr bhyveload 8 or a similar boot loader before running .Nm . .Pp @@ -61,8 +61,8 @@ exit is detected. .Bl -tag -width 10n .It Fl a The guest's local APIC is configured in xAPIC mode. -The xAPIC mode is the default setting so this option is redundant. It will be -deprecated in a future version. +The xAPIC mode is the default setting so this option is redundant. +It will be deprecated in a future version. .It Fl A Generate ACPI tables. Required for @@ -122,7 +122,7 @@ Force the guest virtual CPU to exit when .It Fl s Ar slot,emulation Ns Op , Ns Ar conf Configure a virtual PCI slot and function. .Pp -.Nm bhyve +.Nm provides PCI bus emulation and virtual devices that can be attached to slots on the bus. There are 32 available slots, with the option of providing up to 8 functions @@ -134,11 +134,19 @@ per slot. .Pp The .Ar pcislot -value is 0 to 31. The optional function value is 0 to 7. The optional +value is 0 to 31. +The optional +.Ar function +value is 0 to 7. +The optional .Ar bus value is 0 to 255. -If not specified, the function value defaults to 0. -If not specified, the bus value defaults to 0. +If not specified, the +.Ar function +value defaults to 0. +If not specified, the +.Ar bus +value defaults to 0. .It Ar emulation .Bl -tag -width 10n .It Li hostbridge | Li amd_hostbridge @@ -219,7 +227,9 @@ TTY devices: .Bl -tag -width 10n .It Li stdio Connect the serial port to the standard input and output of -the bhyve process. +the +.Nm +process. .It Pa /dev/xxx Use the host TTY device for serial port I/O. .El @@ -249,7 +259,8 @@ in the guest's System Management BIOS Sy By default a UUID is generated from the host's hostname and .Ar vmname . .It Fl w -Ignore accesses to unimplemented Model Specific Registers (MSRs). This is intended for debug purposes. +Ignore accesses to unimplemented Model Specific Registers (MSRs). +This is intended for debug purposes. .It Fl W Force virtio PCI device emulations to use MSI interrupts instead of MSI-X interrupts. @@ -264,7 +275,7 @@ This should be the same as that created .El .Sh EXAMPLES The guest operating system must have been loaded with -.Xr bhyveload 4 +.Xr bhyveload 8 or a similar boot loader before .Xr bhyve 4 can be run. @@ -292,7 +303,7 @@ Run an 8GB quad-CPU virtual machine with CD-ROM, a single virtio network port, an AMD hostbridge, and the console port connected to an .Xr nmdm 4 -null-model device. +null-modem device. .Bd -literal -offset indent bhyve -c 4 \\ -s 0,amd_hostbridge -s 1,lpc \\ From owner-svn-src-stable@freebsd.org Tue Aug 25 04:03:54 2015 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1529D9C218F; Tue, 25 Aug 2015 04:03:54 +0000 (UTC) (envelope-from marcel@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 01EAB1745; Tue, 25 Aug 2015 04:03:54 +0000 (UTC) (envelope-from marcel@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7P43rWZ007668; Tue, 25 Aug 2015 04:03:53 GMT (envelope-from marcel@FreeBSD.org) Received: (from marcel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7P43p2L007660; Tue, 25 Aug 2015 04:03:51 GMT (envelope-from marcel@FreeBSD.org) Message-Id: <201508250403.t7P43p2L007660@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: marcel set sender to marcel@FreeBSD.org using -f From: Marcel Moolenaar Date: Tue, 25 Aug 2015 04:03:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r287122 - stable/10/usr.bin/mkimg X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Aug 2015 04:03:54 -0000 Author: marcel Date: Tue Aug 25 04:03:51 2015 New Revision: 287122 URL: https://svnweb.freebsd.org/changeset/base/287122 Log: MFC r286660, r286419, r286417, r286395, r286215, r284883 - Add the ntfs alias - Fix the dynamic VHD format to work with qemu - Update manpage MFH: Differential Revision: Modified: stable/10/usr.bin/mkimg/gpt.c stable/10/usr.bin/mkimg/image.c stable/10/usr.bin/mkimg/image.h stable/10/usr.bin/mkimg/mbr.c stable/10/usr.bin/mkimg/mkimg.1 stable/10/usr.bin/mkimg/scheme.c stable/10/usr.bin/mkimg/scheme.h stable/10/usr.bin/mkimg/vhd.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.bin/mkimg/gpt.c ============================================================================== --- stable/10/usr.bin/mkimg/gpt.c Tue Aug 25 01:01:25 2015 (r287121) +++ stable/10/usr.bin/mkimg/gpt.c Tue Aug 25 04:03:51 2015 (r287122) @@ -57,6 +57,7 @@ static uuid_t gpt_uuid_freebsd_ufs = GPT static uuid_t gpt_uuid_freebsd_vinum = GPT_ENT_TYPE_FREEBSD_VINUM; static uuid_t gpt_uuid_freebsd_zfs = GPT_ENT_TYPE_FREEBSD_ZFS; static uuid_t gpt_uuid_mbr = GPT_ENT_TYPE_MBR; +static uuid_t gpt_uuid_ms_basic_data = GPT_ENT_TYPE_MS_BASIC_DATA; static struct mkimg_alias gpt_aliases[] = { { ALIAS_EFI, ALIAS_PTR2TYPE(&gpt_uuid_efi) }, @@ -68,6 +69,7 @@ static struct mkimg_alias gpt_aliases[] { ALIAS_FREEBSD_VINUM, ALIAS_PTR2TYPE(&gpt_uuid_freebsd_vinum) }, { ALIAS_FREEBSD_ZFS, ALIAS_PTR2TYPE(&gpt_uuid_freebsd_zfs) }, { ALIAS_MBR, ALIAS_PTR2TYPE(&gpt_uuid_mbr) }, + { ALIAS_NTFS, ALIAS_PTR2TYPE(&gpt_uuid_ms_basic_data) }, { ALIAS_NONE, 0 } /* Keep last! */ }; Modified: stable/10/usr.bin/mkimg/image.c ============================================================================== --- stable/10/usr.bin/mkimg/image.c Tue Aug 25 01:01:25 2015 (r287121) +++ stable/10/usr.bin/mkimg/image.c Tue Aug 25 04:03:51 2015 (r287122) @@ -517,14 +517,14 @@ image_copyout_memory(int fd, size_t size return (0); } -static int -image_copyout_zeroes(int fd, size_t size) +int +image_copyout_zeroes(int fd, size_t count) { static uint8_t *zeroes = NULL; size_t sz; int error; - if (lseek(fd, (off_t)size, SEEK_CUR) != -1) + if (lseek(fd, (off_t)count, SEEK_CUR) != -1) return (0); /* @@ -537,12 +537,12 @@ image_copyout_zeroes(int fd, size_t size return (ENOMEM); } - while (size > 0) { - sz = (size > secsz) ? secsz : size; + while (count > 0) { + sz = (count > secsz) ? secsz : count; error = image_copyout_memory(fd, sz, zeroes); if (error) return (error); - size -= sz; + count -= sz; } return (0); } Modified: stable/10/usr.bin/mkimg/image.h ============================================================================== --- stable/10/usr.bin/mkimg/image.h Tue Aug 25 01:01:25 2015 (r287121) +++ stable/10/usr.bin/mkimg/image.h Tue Aug 25 04:03:51 2015 (r287122) @@ -35,6 +35,7 @@ int image_copyin(lba_t blk, int fd, uint int image_copyout(int fd); int image_copyout_done(int fd); int image_copyout_region(int fd, lba_t blk, lba_t size); +int image_copyout_zeroes(int fd, size_t count); int image_data(lba_t blk, lba_t size); lba_t image_get_size(void); int image_init(void); Modified: stable/10/usr.bin/mkimg/mbr.c ============================================================================== --- stable/10/usr.bin/mkimg/mbr.c Tue Aug 25 01:01:25 2015 (r287121) +++ stable/10/usr.bin/mkimg/mbr.c Tue Aug 25 04:03:51 2015 (r287122) @@ -51,6 +51,7 @@ static struct mkimg_alias mbr_aliases[] { ALIAS_EFI, ALIAS_INT2TYPE(DOSPTYP_EFI) }, { ALIAS_FAT32, ALIAS_INT2TYPE(DOSPTYP_FAT32) }, { ALIAS_FREEBSD, ALIAS_INT2TYPE(DOSPTYP_386BSD) }, + { ALIAS_NTFS, ALIAS_INT2TYPE(DOSPTYP_NTFS) }, { ALIAS_NONE, 0 } /* Keep last! */ }; Modified: stable/10/usr.bin/mkimg/mkimg.1 ============================================================================== --- stable/10/usr.bin/mkimg/mkimg.1 Tue Aug 25 01:01:25 2015 (r287121) +++ stable/10/usr.bin/mkimg/mkimg.1 Tue Aug 25 04:03:51 2015 (r287122) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 22, 2015 +.Dd August 7, 2015 .Dt MKIMG 1 .Os .Sh NAME @@ -141,7 +141,7 @@ utility will create images that are iden .Pp A set of long options exist to query about the .Nm -utilty itself. +utility itself. Options in this set should be given by themselves because the .Nm utility exits immediately after providing the requested information. @@ -165,6 +165,85 @@ run the .Nm utility without any arguments. This will print a usage message with all the necessary details. +.Sh DISK FORMATS +The +.Nm +utility supports a number of output file formats. +A short description of these is given below. +.Ss QCOW and QCOW2 +QCOW stands for "QEMU Copy On Write". +It's a sparse file format akin to VHD and VMDK and QCOW represents the +first version. +QCOW2 represents version 2 of the file format. +Version 2 is not backward compatible with version 1 and adds support for +snapshots among other things. +The QCOW file formats are natively supported by QEMU and Xen. +To write QCOW, specify +.Fl f Ar qcow +on the command line. +To write version 2 QCOW, specify +.Fl f Ar qcow2 +on the command line. +The preferred file extension is ".qcow" and ".qcow2" for QCOW and QCOW2 +(resp.), but ".qcow" is sometimes used for version 2 files as well. +.Ss RAW file format +This file format is a sector by sector representation of an actual disk. +There is no extra information that describes or relates to the format +itself. The size of the file is the size of the (virtual) disk. +This file format is suitable for being copyied onto a disk with utilities +like +.Nm dd . +To write a raw disk file, either omit the +.Fl f +option, or specify +.Fl f Ar raw +on the command line. +The preferred file extension is one of ".img" or ".raw", but there's no +real convention for it. +.Ss Dynamic VHD and Fixed VHD +Microsoft's "Virtual Hard Disk" file formats. +The dynamic format is a sparse format akin to QCOW and VMDK. +The fixed format is effectively a raw format with a footer appended to the +file and as such it's often indistinguishable from the raw format. +The fixed file format has been added to support Microsoft's Azure platform +and due to inconsistencies in interpretation of the footer is not compatible +with utilities like +.Nm qemu +when it is specifically instructed to interpreted the file as a VHD file. +By default +.Nm qemu +will treat the file as a raw disk file, which mostly works fine. +To have +.Nm +create a dynamic VHD file, specify +.Fl f Ar vhd +on the command line. +To create a fixed VHD file for use by Azure, specify +.Fl f Ar vhdf +on the command line. +The preferred file extension is ".vhd". +.Ss VMDK +VMware's "Virtual Machine Disk" file format. +It's a sparse file format akin to QCOW and VHD and supported by many +virtualization solutions. +To create a VMDK file, specify +.Fl f Ar vmdk +on the command line. +The preferred file extension is ".vmdk". +.Pp +Not all virtualization solutions support all file formats, but often those +virtualization environments have utilities to convert from one format to +another. +Note however that conversion may require that the virtual disk size is +changed to match the constraints of the output format and this may invalidate +the contents of the disk image. +For example, the GUID Partition Table (GPT) scheme has a header in the last +sector on the disk. +When changing the disk size, the GPT must be changed so that the last header +is moved accordingly. +This is typically not part of the conversion process. +If possible, use an output format specifically for the environment in which +the file is intended to be used. .Sh ENVIRONMENT .Bl -tag -width "TMPDIR" -compact .It Ev TMPDIR @@ -235,6 +314,7 @@ utility supports assigning labels to the In the following example the file system partition is labeled as 'backup': .Dl % mkimg -s gpt -p freebsd-ufs/backup:=file-system.ufs -o gpt.img .Sh SEE ALSO +.Xr dd 1 , .Xr gpart 8 , .Xr makefs 8 , .Xr mdconfig 8 , @@ -247,4 +327,5 @@ utility first appeared in .Sh AUTHORS The .Nm -utility and manpage were written by Marcel Moolenaar +utility and manpage were written by +.An Marcel Moolenaar Aq Mt marcelm@juniper.net . Modified: stable/10/usr.bin/mkimg/scheme.c ============================================================================== --- stable/10/usr.bin/mkimg/scheme.c Tue Aug 25 01:01:25 2015 (r287121) +++ stable/10/usr.bin/mkimg/scheme.c Tue Aug 25 04:03:51 2015 (r287122) @@ -59,6 +59,7 @@ static struct { { "freebsd-vinum", ALIAS_FREEBSD_VINUM }, { "freebsd-zfs", ALIAS_FREEBSD_ZFS }, { "mbr", ALIAS_MBR }, + { "ntfs", ALIAS_NTFS }, { NULL, ALIAS_NONE } /* Keep last! */ }; Modified: stable/10/usr.bin/mkimg/scheme.h ============================================================================== --- stable/10/usr.bin/mkimg/scheme.h Tue Aug 25 01:01:25 2015 (r287121) +++ stable/10/usr.bin/mkimg/scheme.h Tue Aug 25 04:03:51 2015 (r287122) @@ -45,6 +45,7 @@ enum alias { ALIAS_FREEBSD_VINUM, ALIAS_FREEBSD_ZFS, ALIAS_MBR, + ALIAS_NTFS, /* end */ ALIAS_COUNT /* Keep last! */ }; Modified: stable/10/usr.bin/mkimg/vhd.c ============================================================================== --- stable/10/usr.bin/mkimg/vhd.c Tue Aug 25 01:01:25 2015 (r287121) +++ stable/10/usr.bin/mkimg/vhd.c Tue Aug 25 04:03:51 2015 (r287122) @@ -159,6 +159,34 @@ vhd_geometry(uint64_t image_size, struct geom->cylinders = cth / geom->heads; } +static uint64_t +vhd_resize(uint64_t origsz) +{ + struct vhd_geom geom; + uint64_t newsz; + + /* + * Round the image size to the pre-determined geometry that + * matches the image size. This circular dependency implies + * that we need to loop to handle boundary conditions. + * The first time, newsz equals origsz and the geometry will + * typically yield a new size that's smaller. We keep adding + * cylinder's worth of sectors to the new size until its + * larger or equal or origsz. But during those iterations, + * the geometry can change, so we need to account for that. + */ + newsz = origsz; + while (1) { + vhd_geometry(newsz, &geom); + newsz = (int64_t)geom.cylinders * geom.heads * + geom.sectors * VHD_SECTOR_SIZE; + if (newsz >= origsz) + break; + newsz += geom.heads * geom.sectors * VHD_SECTOR_SIZE; + } + return (newsz); +} + static uint32_t vhd_timestamp(void) { @@ -256,8 +284,7 @@ vhd_dyn_resize(lba_t imgsz) { uint64_t imagesz; - imagesz = imgsz * secsz; - imagesz = (imagesz + VHD_BLOCK_SIZE - 1) & ~(VHD_BLOCK_SIZE - 1); + imagesz = vhd_resize(imgsz * secsz); return (image_set_size(imagesz / secsz)); } @@ -266,7 +293,7 @@ vhd_dyn_write(int fd) { struct vhd_footer footer; struct vhd_dyn_header header; - uint64_t imgsz; + uint64_t imgsz, rawsz; lba_t blk, blkcnt, nblks; uint32_t *bat; void *bitmap; @@ -274,13 +301,14 @@ vhd_dyn_write(int fd) uint32_t sector; int bat_entries, error, entry; - imgsz = image_get_size() * secsz; - bat_entries = imgsz / VHD_BLOCK_SIZE; + rawsz = image_get_size() * secsz; + imgsz = (rawsz + VHD_BLOCK_SIZE - 1) & ~(VHD_BLOCK_SIZE - 1); - vhd_make_footer(&footer, imgsz, VHD_DISK_TYPE_DYNAMIC, sizeof(footer)); + vhd_make_footer(&footer, rawsz, VHD_DISK_TYPE_DYNAMIC, sizeof(footer)); if (sparse_write(fd, &footer, sizeof(footer)) < 0) return (errno); + bat_entries = imgsz / VHD_BLOCK_SIZE; memset(&header, 0, sizeof(header)); be64enc(&header.cookie, VHD_HEADER_COOKIE); be64enc(&header.data_offset, ~0ULL); @@ -321,7 +349,7 @@ vhd_dyn_write(int fd) blk = 0; blkcnt = VHD_BLOCK_SIZE / secsz; error = 0; - nblks = image_get_size(); + nblks = rawsz / secsz; while (blk < nblks) { if (!image_data(blk, blkcnt)) { blk += blkcnt; @@ -331,15 +359,20 @@ vhd_dyn_write(int fd) error = errno; break; } + /* Handle partial last block */ + if (blk + blkcnt > nblks) + blkcnt = nblks - blk; error = image_copyout_region(fd, blk, blkcnt); if (error) break; blk += blkcnt; } free(bitmap); - if (blk != nblks) + if (error) + return (error); + error = image_copyout_zeroes(fd, imgsz - rawsz); + if (error) return (error); - if (sparse_write(fd, &footer, sizeof(footer)) < 0) return (errno); @@ -362,24 +395,9 @@ FORMAT_DEFINE(vhd_dyn_format); static int vhd_fix_resize(lba_t imgsz) { - struct vhd_geom geom; - int64_t imagesz; + uint64_t imagesz; - /* - * Round the image size to the pre-determined geometry that - * matches the image size. This circular dependency implies - * that we need to loop to handle boundary conditions. - */ - imgsz *= secsz; - imagesz = imgsz; - while (1) { - vhd_geometry(imagesz, &geom); - imagesz = (int64_t)geom.cylinders * geom.heads * - geom.sectors * VHD_SECTOR_SIZE; - if (imagesz >= imgsz) - break; - imagesz += geom.heads * geom.sectors * VHD_SECTOR_SIZE; - } + imagesz = vhd_resize(imgsz * secsz); /* * Azure demands that images are a whole number of megabytes. */ @@ -391,24 +409,24 @@ static int vhd_fix_write(int fd) { struct vhd_footer footer; - uint64_t imgsz; + uint64_t imagesz; int error; error = image_copyout(fd); - if (!error) { - imgsz = image_get_size() * secsz; - vhd_make_footer(&footer, imgsz, VHD_DISK_TYPE_FIXED, ~0ULL); - if (sparse_write(fd, &footer, sizeof(footer)) < 0) - error = errno; - } + if (error) + return (error); + + imagesz = image_get_size() * secsz; + vhd_make_footer(&footer, imagesz, VHD_DISK_TYPE_FIXED, ~0ULL); + error = (sparse_write(fd, &footer, sizeof(footer)) < 0) ? errno : 0; return (error); } static struct mkimg_format vhd_fix_format = { - .name = "vhdf", - .description = "Fixed Virtual Hard Disk", - .resize = vhd_fix_resize, - .write = vhd_fix_write, + .name = "vhdf", + .description = "Fixed Virtual Hard Disk", + .resize = vhd_fix_resize, + .write = vhd_fix_write, }; FORMAT_DEFINE(vhd_fix_format); From owner-svn-src-stable@freebsd.org Tue Aug 25 10:37:05 2015 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6FB0699E542; Tue, 25 Aug 2015 10:37:05 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from cell.glebius.int.ru (glebius.int.ru [81.19.69.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "cell.glebius.int.ru", Issuer "cell.glebius.int.ru" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 57086EBA; Tue, 25 Aug 2015 10:37:04 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from cell.glebius.int.ru (localhost [127.0.0.1]) by cell.glebius.int.ru (8.15.2/8.15.2) with ESMTPS id t7PAb1Vl072290 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 25 Aug 2015 13:37:01 +0300 (MSK) (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by cell.glebius.int.ru (8.15.2/8.15.2/Submit) id t7PAb1Xk072289; Tue, 25 Aug 2015 13:37:01 +0300 (MSK) (envelope-from glebius@FreeBSD.org) X-Authentication-Warning: cell.glebius.int.ru: glebius set sender to glebius@FreeBSD.org using -f Date: Tue, 25 Aug 2015 13:37:01 +0300 From: Gleb Smirnoff To: Alexander Motin Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: Re: svn commit: r287016 - in stable/10: . share/man/man4 sys/arm/mv sys/boot/forth sys/conf sys/dev/ata sys/dev/ata/chipsets sys/modules/ata/atapci/chipsets sys/modules/ata/atapci/chipsets/ataadaptec s... Message-ID: <20150825103701.GL56997@FreeBSD.org> References: <201508220732.t7M7WmJ0053866@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201508220732.t7M7WmJ0053866@repo.freebsd.org> User-Agent: Mutt/1.5.23 (2014-03-12) X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Aug 2015 10:37:05 -0000 On Sat, Aug 22, 2015 at 07:32:48AM +0000, Alexander Motin wrote: A> Author: mav A> Date: Sat Aug 22 07:32:47 2015 A> New Revision: 287016 A> URL: https://svnweb.freebsd.org/changeset/base/287016 A> A> Log: A> MFC r280451: A> Remove from legacy ata(4) driver support for hardware, supported by newer A> and more functional drivers ahci(4), siis(4) and mvs(4). A> A> This removes about 3400 lines of code, unused since FreeBSD 9.0 release. What is the reason to break POLA in stable branch? Don't get me wrong. I'm all for removing stale code from head. But is it worth to hurt someone who runs custom built kernel with 'device ad' and tracks stable/10? -- Totus tuus, Glebius. From owner-svn-src-stable@freebsd.org Tue Aug 25 11:06:14 2015 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id ADBE599A7E0; Tue, 25 Aug 2015 11:06:14 +0000 (UTC) (envelope-from mavbsd@gmail.com) Received: from mail-wi0-x235.google.com (mail-wi0-x235.google.com [IPv6:2a00:1450:400c:c05::235]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4D7DFFF; Tue, 25 Aug 2015 11:06:14 +0000 (UTC) (envelope-from mavbsd@gmail.com) Received: by wicja10 with SMTP id ja10so11465998wic.1; Tue, 25 Aug 2015 04:06:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=ZhTUOcB6eHqawX39vFsTDThSP6hReS+7GxacgeO82A0=; b=hDgeq6t0MmPl1CfLMYTYfom2jB5Pbm2LQ5rVJp/0dFgewGe/Q3LuEcfFsdfxp5kRIr 1aSzoiOugYN18dG12sSs4l93zgbWdnjUJIKq5EOmVqriUo6RdnW2xQ+dcncxWMYApqnU nlDGleo7eKTdmm0FDRfUntiyDy+56kPCdJWpvdhPMR4HmuRYev5J9Svz/TRjng9TUqFz CQTEJsxJu8QMn8uiXl4Bo3UxpBlyTbqoQ0X9d1YwmNFvMIKzigPLMYd9XixdjTJnVs5R 4RxyumoOt0Qfvz+otkjkw96PDs6yzuD2vdQ20yo6LRa4OueXP5r8ORrTJsLw0hFvDY6O 1SYw== X-Received: by 10.180.80.200 with SMTP id t8mr3751557wix.18.1440500772694; Tue, 25 Aug 2015 04:06:12 -0700 (PDT) Received: from mavbook.mavhome.dp.ua ([134.249.139.101]) by smtp.googlemail.com with ESMTPSA id ej5sm27530374wjd.22.2015.08.25.04.06.11 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 25 Aug 2015 04:06:11 -0700 (PDT) Sender: Alexander Motin Message-ID: <55DC4C22.4030501@FreeBSD.org> Date: Tue, 25 Aug 2015 14:06:10 +0300 From: Alexander Motin User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Gleb Smirnoff CC: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: Re: svn commit: r287016 - in stable/10: . share/man/man4 sys/arm/mv sys/boot/forth sys/conf sys/dev/ata sys/dev/ata/chipsets sys/modules/ata/atapci/chipsets sys/modules/ata/atapci/chipsets/ataadaptec s... References: <201508220732.t7M7WmJ0053866@repo.freebsd.org> <20150825103701.GL56997@FreeBSD.org> In-Reply-To: <20150825103701.GL56997@FreeBSD.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Aug 2015 11:06:14 -0000 On 25.08.2015 13:37, Gleb Smirnoff wrote: > On Sat, Aug 22, 2015 at 07:32:48AM +0000, Alexander Motin wrote: > A> Author: mav > A> Date: Sat Aug 22 07:32:47 2015 > A> New Revision: 287016 > A> URL: https://svnweb.freebsd.org/changeset/base/287016 > A> > A> Log: > A> MFC r280451: > A> Remove from legacy ata(4) driver support for hardware, supported by newer > A> and more functional drivers ahci(4), siis(4) and mvs(4). > A> > A> This removes about 3400 lines of code, unused since FreeBSD 9.0 release. > > What is the reason to break POLA in stable branch? Reducing diff from head to make later merges easier. > Don't get me wrong. I'm all for removing stale code from head. But is it > worth to hurt someone who runs custom built kernel with 'device ad' and > tracks stable/10? There never was legacy ATA stack in stable/10, so there is no such users. The only POLA breakage here is that people with custom kernels for some reason having only ata driver may now require ahci, siis or mvs. If such cases exist, they are most likely a configuration bugs, as alternative gives NCQ, hot-plug, etc. for free. -- Alexander Motin From owner-svn-src-stable@freebsd.org Tue Aug 25 14:39:44 2015 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C162899D10F; Tue, 25 Aug 2015 14:39:44 +0000 (UTC) (envelope-from marcel@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id AF91FE41; Tue, 25 Aug 2015 14:39:44 +0000 (UTC) (envelope-from marcel@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7PEdixb071534; Tue, 25 Aug 2015 14:39:44 GMT (envelope-from marcel@FreeBSD.org) Received: (from marcel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7PEdf1B071523; Tue, 25 Aug 2015 14:39:41 GMT (envelope-from marcel@FreeBSD.org) Message-Id: <201508251439.t7PEdf1B071523@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: marcel set sender to marcel@FreeBSD.org using -f From: Marcel Moolenaar Date: Tue, 25 Aug 2015 14:39:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r287126 - in stable/10/sys: amd64/amd64 conf dev/vt/hw/efifb dev/vt/hw/vga i386/i386 x86/include x86/x86 X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Aug 2015 14:39:44 -0000 Author: marcel Date: Tue Aug 25 14:39:40 2015 New Revision: 287126 URL: https://svnweb.freebsd.org/changeset/base/287126 Log: MFC r286667 & r286723 Better support memory mapped console devices, such as VGA and EFI frame buffers and memory mapped UARTs. PR: 191564, 194952, 202276 Added: stable/10/sys/x86/x86/bus_machdep.c - copied unchanged from r286667, head/sys/x86/x86/bus_machdep.c Modified: stable/10/sys/amd64/amd64/machdep.c stable/10/sys/amd64/amd64/pmap.c stable/10/sys/conf/files.amd64 stable/10/sys/conf/files.i386 stable/10/sys/dev/vt/hw/efifb/efifb.c stable/10/sys/dev/vt/hw/vga/vt_vga.c stable/10/sys/dev/vt/hw/vga/vt_vga_reg.h stable/10/sys/i386/i386/machdep.c stable/10/sys/i386/i386/pmap.c stable/10/sys/x86/include/bus.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/amd64/amd64/machdep.c ============================================================================== --- stable/10/sys/amd64/amd64/machdep.c Tue Aug 25 09:16:09 2015 (r287125) +++ stable/10/sys/amd64/amd64/machdep.c Tue Aug 25 14:39:40 2015 (r287126) @@ -1931,38 +1931,6 @@ hammer_time(u_int64_t modulep, u_int64_t MODINFO_METADATA | MODINFOMD_EFI_MAP) != NULL) vty_set_preferred(VTY_VT); - /* - * Initialize the console before we print anything out. - */ - cninit(); - -#ifdef DEV_ISA -#ifdef DEV_ATPIC - elcr_probe(); - atpic_startup(); -#else - /* Reset and mask the atpics and leave them shut down. */ - atpic_reset(); - - /* - * Point the ICU spurious interrupt vectors at the APIC spurious - * interrupt handler. - */ - setidt(IDT_IO_INTS + 7, IDTVEC(spuriousint), SDT_SYSIGT, SEL_KPL, 0); - setidt(IDT_IO_INTS + 15, IDTVEC(spuriousint), SDT_SYSIGT, SEL_KPL, 0); -#endif -#else -#error "have you forgotten the isa device?"; -#endif - - kdb_init(); - -#ifdef KDB - if (boothowto & RB_KDB) - kdb_enter(KDB_WHY_BOOTFLAGS, - "Boot flags requested debugger"); -#endif - identify_cpu(); /* Final stage of CPU initialization */ initializecpu(); /* Initialize CPU registers */ initializecpucache(); @@ -2000,6 +1968,35 @@ hammer_time(u_int64_t modulep, u_int64_t /* now running on new page tables, configured,and u/iom is accessible */ + cninit(); + +#ifdef DEV_ISA +#ifdef DEV_ATPIC + elcr_probe(); + atpic_startup(); +#else + /* Reset and mask the atpics and leave them shut down. */ + atpic_reset(); + + /* + * Point the ICU spurious interrupt vectors at the APIC spurious + * interrupt handler. + */ + setidt(IDT_IO_INTS + 7, IDTVEC(spuriousint), SDT_SYSIGT, SEL_KPL, 0); + setidt(IDT_IO_INTS + 15, IDTVEC(spuriousint), SDT_SYSIGT, SEL_KPL, 0); +#endif +#else +#error "have you forgotten the isa device?"; +#endif + + kdb_init(); + +#ifdef KDB + if (boothowto & RB_KDB) + kdb_enter(KDB_WHY_BOOTFLAGS, + "Boot flags requested debugger"); +#endif + msgbufinit(msgbufp, msgbufsize); fpuinit(); Modified: stable/10/sys/amd64/amd64/pmap.c ============================================================================== --- stable/10/sys/amd64/amd64/pmap.c Tue Aug 25 09:16:09 2015 (r287125) +++ stable/10/sys/amd64/amd64/pmap.c Tue Aug 25 14:39:40 2015 (r287126) @@ -360,6 +360,18 @@ static u_int64_t DMPDphys; /* phys addr static u_int64_t DMPDPphys; /* phys addr of direct mapped level 3 */ static int ndmpdpphys; /* number of DMPDPphys pages */ +/* + * pmap_mapdev support pre initialization (i.e. console) + */ +#define PMAP_PREINIT_MAPPING_COUNT 8 +static struct pmap_preinit_mapping { + vm_paddr_t pa; + vm_offset_t va; + vm_size_t sz; + int mode; +} pmap_preinit_mapping[PMAP_PREINIT_MAPPING_COUNT]; +static int pmap_initialized; + static struct rwlock_padalign pvh_global_lock; /* @@ -1014,6 +1026,7 @@ pmap_page_init(vm_page_t m) void pmap_init(void) { + struct pmap_preinit_mapping *ppim; vm_page_t mpte; vm_size_t s; int i, pv_npg; @@ -1085,6 +1098,22 @@ pmap_init(void) mtx_init(&cpage_lock, "cpage", NULL, MTX_DEF); cpage_a = kva_alloc(PAGE_SIZE); cpage_b = kva_alloc(PAGE_SIZE); + + pmap_initialized = 1; + for (i = 0; i < PMAP_PREINIT_MAPPING_COUNT; i++) { + ppim = pmap_preinit_mapping + i; + if (ppim->va == 0) + continue; + /* Make the direct map consistent */ + if (ppim->pa < dmaplimit && ppim->pa + ppim->sz < dmaplimit) { + (void)pmap_change_attr(PHYS_TO_DMAP(ppim->pa), + ppim->sz, ppim->mode); + } + if (!bootverbose) + continue; + printf("PPIM %u: PA=%#lx, VA=%#lx, size=%#lx, mode=%#x\n", i, + ppim->pa, ppim->va, ppim->sz, ppim->mode); + } } static SYSCTL_NODE(_vm_pmap, OID_AUTO, pde, CTLFLAG_RD, 0, @@ -6231,24 +6260,54 @@ pmap_pde_attr(pd_entry_t *pde, int cache void * pmap_mapdev_attr(vm_paddr_t pa, vm_size_t size, int mode) { + struct pmap_preinit_mapping *ppim; vm_offset_t va, offset; vm_size_t tmpsize; + int i; - /* - * If the specified range of physical addresses fits within the direct - * map window, use the direct map. - */ - if (pa < dmaplimit && pa + size < dmaplimit) { - va = PHYS_TO_DMAP(pa); - if (!pmap_change_attr(va, size, mode)) - return ((void *)va); - } offset = pa & PAGE_MASK; size = round_page(offset + size); - va = kva_alloc(size); - if (!va) - panic("pmap_mapdev: Couldn't alloc kernel virtual memory"); pa = trunc_page(pa); + + if (!pmap_initialized) { + va = 0; + for (i = 0; i < PMAP_PREINIT_MAPPING_COUNT; i++) { + ppim = pmap_preinit_mapping + i; + if (ppim->va == 0) { + ppim->pa = pa; + ppim->sz = size; + ppim->mode = mode; + ppim->va = virtual_avail; + virtual_avail += size; + va = ppim->va; + break; + } + } + if (va == 0) + panic("%s: too many preinit mappings", __func__); + } else { + /* + * If we have a preinit mapping, re-use it. + */ + for (i = 0; i < PMAP_PREINIT_MAPPING_COUNT; i++) { + ppim = pmap_preinit_mapping + i; + if (ppim->pa == pa && ppim->sz == size && + ppim->mode == mode) + return ((void *)(ppim->va + offset)); + } + /* + * If the specified range of physical addresses fits within + * the direct map window, use the direct map. + */ + if (pa < dmaplimit && pa + size < dmaplimit) { + va = PHYS_TO_DMAP(pa); + if (!pmap_change_attr(va, size, mode)) + return ((void *)(va + offset)); + } + va = kva_alloc(size); + if (va == 0) + panic("%s: Couldn't allocate KVA", __func__); + } for (tmpsize = 0; tmpsize < size; tmpsize += PAGE_SIZE) pmap_kenter_attr(va + tmpsize, pa + tmpsize, mode); pmap_invalidate_range(kernel_pmap, va, va + tmpsize); @@ -6273,15 +6332,32 @@ pmap_mapbios(vm_paddr_t pa, vm_size_t si void pmap_unmapdev(vm_offset_t va, vm_size_t size) { - vm_offset_t base, offset; + struct pmap_preinit_mapping *ppim; + vm_offset_t offset; + int i; /* If we gave a direct map region in pmap_mapdev, do nothing */ if (va >= DMAP_MIN_ADDRESS && va < DMAP_MAX_ADDRESS) return; - base = trunc_page(va); offset = va & PAGE_MASK; size = round_page(offset + size); - kva_free(base, size); + va = trunc_page(va); + for (i = 0; i < PMAP_PREINIT_MAPPING_COUNT; i++) { + ppim = pmap_preinit_mapping + i; + if (ppim->va == va && ppim->sz == size) { + if (pmap_initialized) + return; + ppim->pa = 0; + ppim->va = 0; + ppim->sz = 0; + ppim->mode = 0; + if (va + size == virtual_avail) + virtual_avail = va; + return; + } + } + if (pmap_initialized) + kva_free(va, size); } /* Modified: stable/10/sys/conf/files.amd64 ============================================================================== --- stable/10/sys/conf/files.amd64 Tue Aug 25 09:16:09 2015 (r287125) +++ stable/10/sys/conf/files.amd64 Tue Aug 25 14:39:40 2015 (r287126) @@ -588,6 +588,7 @@ x86/isa/nmi.c standard x86/isa/orm.c optional isa x86/pci/pci_bus.c optional pci x86/pci/qpi.c optional pci +x86/x86/bus_machdep.c standard x86/x86/busdma_bounce.c standard x86/x86/busdma_machdep.c standard x86/x86/dump_machdep.c standard Modified: stable/10/sys/conf/files.i386 ============================================================================== --- stable/10/sys/conf/files.i386 Tue Aug 25 09:16:09 2015 (r287125) +++ stable/10/sys/conf/files.i386 Tue Aug 25 14:39:40 2015 (r287126) @@ -589,6 +589,7 @@ x86/isa/nmi.c standard x86/isa/orm.c optional isa x86/pci/pci_bus.c optional pci x86/pci/qpi.c optional pci +x86/x86/bus_machdep.c standard x86/x86/busdma_bounce.c standard x86/x86/busdma_machdep.c standard x86/x86/dump_machdep.c standard Modified: stable/10/sys/dev/vt/hw/efifb/efifb.c ============================================================================== --- stable/10/sys/dev/vt/hw/efifb/efifb.c Tue Aug 25 09:16:09 2015 (r287125) +++ stable/10/sys/dev/vt/hw/efifb/efifb.c Tue Aug 25 14:39:40 2015 (r287126) @@ -53,7 +53,6 @@ __FBSDID("$FreeBSD$"); static vd_init_t vt_efifb_init; static vd_probe_t vt_efifb_probe; -static void vt_efifb_remap(void *efifb_data); static struct vt_driver vt_efifb_driver = { .vd_name = "efifb", @@ -73,8 +72,6 @@ static struct vt_driver vt_efifb_driver static struct fb_info local_info; VT_DRIVER_DECLARE(vt_efifb, vt_efifb_driver); -SYSINIT(efifb_remap, SI_SUB_KMEM, SI_ORDER_ANY, vt_efifb_remap, &local_info); - static int vt_efifb_probe(struct vt_device *vd) { @@ -139,12 +136,8 @@ vt_efifb_init(struct vt_device *vd) info->fb_size = info->fb_height * info->fb_stride; info->fb_pbase = efifb->fb_addr; - /* - * Use the direct map as a crutch until pmap is available. Once pmap - * is online, the framebuffer will be remapped by vt_efifb_remap() - * using pmap_mapdev_attr(). - */ - info->fb_vbase = PHYS_TO_DMAP(efifb->fb_addr); + info->fb_vbase = (intptr_t)pmap_mapdev_attr(info->fb_pbase, + info->fb_size, VM_MEMATTR_WRITE_COMBINING); /* Get pixel storage size. */ info->fb_bpp = info->fb_stride / info->fb_width * 8; @@ -160,22 +153,3 @@ vt_efifb_init(struct vt_device *vd) return (CN_INTERNAL); } - -static void -vt_efifb_remap(void *xinfo) -{ - struct fb_info *info = xinfo; - - if (info->fb_pbase == 0) - return; - - /* - * Remap as write-combining. This massively improves performance and - * happens very early in kernel initialization, when everything is - * still single-threaded and interrupts are off, so replacing the - * mapping address is safe. - */ - info->fb_vbase = (intptr_t)pmap_mapdev_attr(info->fb_pbase, - info->fb_size, VM_MEMATTR_WRITE_COMBINING); -} - Modified: stable/10/sys/dev/vt/hw/vga/vt_vga.c ============================================================================== --- stable/10/sys/dev/vt/hw/vga/vt_vga.c Tue Aug 25 09:16:09 2015 (r287125) +++ stable/10/sys/dev/vt/hw/vga/vt_vga.c Tue Aug 25 14:39:40 2015 (r287126) @@ -42,13 +42,6 @@ __FBSDID("$FreeBSD$"); #include -#if defined(__amd64__) || defined(__i386__) -#include -#include -#include -#include -#endif /* __amd64__ || __i386__ */ - struct vga_softc { bus_space_tag_t vga_fb_tag; bus_space_handle_t vga_fb_handle; @@ -885,9 +878,9 @@ vga_bitblt_text_txtmode(struct vt_device /* Convert colors to VGA attributes. */ attr = bg << 4 | fg; - MEM_WRITE1(sc, 0x18000 + (row * 80 + col) * 2 + 0, + MEM_WRITE1(sc, (row * 80 + col) * 2 + 0, ch); - MEM_WRITE1(sc, 0x18000 + (row * 80 + col) * 2 + 1, + MEM_WRITE1(sc, (row * 80 + col) * 2 + 1, attr); } } @@ -1211,9 +1204,7 @@ vga_init(struct vt_device *vd) #if defined(__amd64__) || defined(__i386__) sc->vga_fb_tag = X86_BUS_SPACE_MEM; - sc->vga_fb_handle = KERNBASE + VGA_MEM_BASE; sc->vga_reg_tag = X86_BUS_SPACE_IO; - sc->vga_reg_handle = VGA_REG_BASE; #elif defined(__ia64__) sc->vga_fb_tag = IA64_BUS_SPACE_MEM; sc->vga_fb_handle = IA64_PHYS_TO_RR6(VGA_MEM_BASE); @@ -1223,14 +1214,21 @@ vga_init(struct vt_device *vd) # error "Architecture not yet supported!" #endif + bus_space_map(sc->vga_reg_tag, VGA_REG_BASE, VGA_REG_SIZE, 0, + &sc->vga_reg_handle); + TUNABLE_INT_FETCH("hw.vga.textmode", &textmode); if (textmode) { vd->vd_flags |= VDF_TEXTMODE; vd->vd_width = 80; vd->vd_height = 25; + bus_space_map(sc->vga_fb_tag, VGA_TXT_BASE, VGA_TXT_SIZE, 0, + &sc->vga_fb_handle); } else { vd->vd_width = VT_VGA_WIDTH; vd->vd_height = VT_VGA_HEIGHT; + bus_space_map(sc->vga_fb_tag, VGA_MEM_BASE, VGA_MEM_SIZE, 0, + &sc->vga_fb_handle); } vga_initialize(vd, textmode); Modified: stable/10/sys/dev/vt/hw/vga/vt_vga_reg.h ============================================================================== --- stable/10/sys/dev/vt/hw/vga/vt_vga_reg.h Tue Aug 25 09:16:09 2015 (r287125) +++ stable/10/sys/dev/vt/hw/vga/vt_vga_reg.h Tue Aug 25 14:39:40 2015 (r287126) @@ -49,6 +49,8 @@ #define VGA_MEM_BASE 0xA0000 #define VGA_MEM_SIZE 0x10000 +#define VGA_TXT_BASE 0xB8000 +#define VGA_TXT_SIZE 0x08000 #define VGA_REG_BASE 0x3c0 #define VGA_REG_SIZE 0x10+0x0c Modified: stable/10/sys/i386/i386/machdep.c ============================================================================== --- stable/10/sys/i386/i386/machdep.c Tue Aug 25 09:16:09 2015 (r287125) +++ stable/10/sys/i386/i386/machdep.c Tue Aug 25 14:39:40 2015 (r287126) @@ -3320,6 +3320,40 @@ init386(first) */ i8254_init(); + finishidentcpu(); /* Final stage of CPU initialization */ + setidt(IDT_UD, &IDTVEC(ill), SDT_SYS386TGT, SEL_KPL, + GSEL(GCODE_SEL, SEL_KPL)); + setidt(IDT_GP, &IDTVEC(prot), SDT_SYS386TGT, SEL_KPL, + GSEL(GCODE_SEL, SEL_KPL)); + initializecpu(); /* Initialize CPU registers */ + initializecpucache(); + + /* pointer to selector slot for %fs/%gs */ + PCPU_SET(fsgs_gdt, &gdt[GUFS_SEL].sd); + + dblfault_tss.tss_esp = dblfault_tss.tss_esp0 = dblfault_tss.tss_esp1 = + dblfault_tss.tss_esp2 = (int)&dblfault_stack[sizeof(dblfault_stack)]; + dblfault_tss.tss_ss = dblfault_tss.tss_ss0 = dblfault_tss.tss_ss1 = + dblfault_tss.tss_ss2 = GSEL(GDATA_SEL, SEL_KPL); +#if defined(PAE) || defined(PAE_TABLES) + dblfault_tss.tss_cr3 = (int)IdlePDPT; +#else + dblfault_tss.tss_cr3 = (int)IdlePTD; +#endif + dblfault_tss.tss_eip = (int)dblfault_handler; + dblfault_tss.tss_eflags = PSL_KERNEL; + dblfault_tss.tss_ds = dblfault_tss.tss_es = + dblfault_tss.tss_gs = GSEL(GDATA_SEL, SEL_KPL); + dblfault_tss.tss_fs = GSEL(GPRIV_SEL, SEL_KPL); + dblfault_tss.tss_cs = GSEL(GCODE_SEL, SEL_KPL); + dblfault_tss.tss_ldt = GSEL(GLDT_SEL, SEL_KPL); + + vm86_initialize(); + getmemsize(first); + init_param2(physmem); + + /* now running on new page tables, configured,and u/iom is accessible */ + /* * Initialize the console before we print anything out. */ @@ -3361,40 +3395,6 @@ init386(first) kdb_enter(KDB_WHY_BOOTFLAGS, "Boot flags requested debugger"); #endif - finishidentcpu(); /* Final stage of CPU initialization */ - setidt(IDT_UD, &IDTVEC(ill), SDT_SYS386TGT, SEL_KPL, - GSEL(GCODE_SEL, SEL_KPL)); - setidt(IDT_GP, &IDTVEC(prot), SDT_SYS386TGT, SEL_KPL, - GSEL(GCODE_SEL, SEL_KPL)); - initializecpu(); /* Initialize CPU registers */ - initializecpucache(); - - /* pointer to selector slot for %fs/%gs */ - PCPU_SET(fsgs_gdt, &gdt[GUFS_SEL].sd); - - dblfault_tss.tss_esp = dblfault_tss.tss_esp0 = dblfault_tss.tss_esp1 = - dblfault_tss.tss_esp2 = (int)&dblfault_stack[sizeof(dblfault_stack)]; - dblfault_tss.tss_ss = dblfault_tss.tss_ss0 = dblfault_tss.tss_ss1 = - dblfault_tss.tss_ss2 = GSEL(GDATA_SEL, SEL_KPL); -#if defined(PAE) || defined(PAE_TABLES) - dblfault_tss.tss_cr3 = (int)IdlePDPT; -#else - dblfault_tss.tss_cr3 = (int)IdlePTD; -#endif - dblfault_tss.tss_eip = (int)dblfault_handler; - dblfault_tss.tss_eflags = PSL_KERNEL; - dblfault_tss.tss_ds = dblfault_tss.tss_es = - dblfault_tss.tss_gs = GSEL(GDATA_SEL, SEL_KPL); - dblfault_tss.tss_fs = GSEL(GPRIV_SEL, SEL_KPL); - dblfault_tss.tss_cs = GSEL(GCODE_SEL, SEL_KPL); - dblfault_tss.tss_ldt = GSEL(GLDT_SEL, SEL_KPL); - - vm86_initialize(); - getmemsize(first); - init_param2(physmem); - - /* now running on new page tables, configured,and u/iom is accessible */ - msgbufinit(msgbufp, msgbufsize); #ifdef DEV_NPX npxinit(true); Modified: stable/10/sys/i386/i386/pmap.c ============================================================================== --- stable/10/sys/i386/i386/pmap.c Tue Aug 25 09:16:09 2015 (r287125) +++ stable/10/sys/i386/i386/pmap.c Tue Aug 25 14:39:40 2015 (r287126) @@ -232,6 +232,18 @@ SYSCTL_INT(_vm_pmap, OID_AUTO, pg_ps_ena #define PAT_INDEX_SIZE 8 static int pat_index[PAT_INDEX_SIZE]; /* cache mode to PAT index conversion */ +/* + * pmap_mapdev support pre initialization (i.e. console) + */ +#define PMAP_PREINIT_MAPPING_COUNT 8 +static struct pmap_preinit_mapping { + vm_paddr_t pa; + vm_offset_t va; + vm_size_t sz; + int mode; +} pmap_preinit_mapping[PMAP_PREINIT_MAPPING_COUNT]; +static int pmap_initialized; + static struct rwlock_padalign pvh_global_lock; /* @@ -731,6 +743,7 @@ pmap_ptelist_init(vm_offset_t *head, voi void pmap_init(void) { + struct pmap_preinit_mapping *ppim; vm_page_t mpte; vm_size_t s; int i, pv_npg; @@ -814,6 +827,17 @@ pmap_init(void) UMA_ZONE_VM | UMA_ZONE_NOFREE); uma_zone_set_allocf(pdptzone, pmap_pdpt_allocf); #endif + + pmap_initialized = 1; + if (!bootverbose) + return; + for (i = 0; i < PMAP_PREINIT_MAPPING_COUNT; i++) { + ppim = pmap_preinit_mapping + i; + if (ppim->va == 0) + continue; + printf("PPIM %u: PA=%#jx, VA=%#x, size=%#x, mode=%#x\n", i, + (uintmax_t)ppim->pa, ppim->va, ppim->sz, ppim->mode); + } } @@ -5162,8 +5186,10 @@ pmap_pde_attr(pd_entry_t *pde, int cache void * pmap_mapdev_attr(vm_paddr_t pa, vm_size_t size, int mode) { + struct pmap_preinit_mapping *ppim; vm_offset_t va, offset; vm_size_t tmpsize; + int i; offset = pa & PAGE_MASK; size = round_page(offset + size); @@ -5171,11 +5197,36 @@ pmap_mapdev_attr(vm_paddr_t pa, vm_size_ if (pa < KERNLOAD && pa + size <= KERNLOAD) va = KERNBASE + pa; - else + else if (!pmap_initialized) { + va = 0; + for (i = 0; i < PMAP_PREINIT_MAPPING_COUNT; i++) { + ppim = pmap_preinit_mapping + i; + if (ppim->va == 0) { + ppim->pa = pa; + ppim->sz = size; + ppim->mode = mode; + ppim->va = virtual_avail; + virtual_avail += size; + va = ppim->va; + break; + } + } + if (va == 0) + panic("%s: too many preinit mappings", __func__); + } else { + /* + * If we have a preinit mapping, re-use it. + */ + for (i = 0; i < PMAP_PREINIT_MAPPING_COUNT; i++) { + ppim = pmap_preinit_mapping + i; + if (ppim->pa == pa && ppim->sz == size && + ppim->mode == mode) + return ((void *)(ppim->va + offset)); + } va = kva_alloc(size); - if (!va) - panic("pmap_mapdev: Couldn't alloc kernel virtual memory"); - + if (va == 0) + panic("%s: Couldn't allocate KVA", __func__); + } for (tmpsize = 0; tmpsize < size; tmpsize += PAGE_SIZE) pmap_kenter_attr(va + tmpsize, pa + tmpsize, mode); pmap_invalidate_range(kernel_pmap, va, va + tmpsize); @@ -5200,14 +5251,31 @@ pmap_mapbios(vm_paddr_t pa, vm_size_t si void pmap_unmapdev(vm_offset_t va, vm_size_t size) { - vm_offset_t base, offset; + struct pmap_preinit_mapping *ppim; + vm_offset_t offset; + int i; if (va >= KERNBASE && va + size <= KERNBASE + KERNLOAD) return; - base = trunc_page(va); offset = va & PAGE_MASK; size = round_page(offset + size); - kva_free(base, size); + va = trunc_page(va); + for (i = 0; i < PMAP_PREINIT_MAPPING_COUNT; i++) { + ppim = pmap_preinit_mapping + i; + if (ppim->va == va && ppim->sz == size) { + if (pmap_initialized) + return; + ppim->pa = 0; + ppim->va = 0; + ppim->sz = 0; + ppim->mode = 0; + if (va + size == virtual_avail) + virtual_avail = va; + return; + } + } + if (pmap_initialized) + kva_free(va, size); } /* Modified: stable/10/sys/x86/include/bus.h ============================================================================== --- stable/10/sys/x86/include/bus.h Tue Aug 25 09:16:09 2015 (r287125) +++ stable/10/sys/x86/include/bus.h Tue Aug 25 14:39:40 2015 (r287126) @@ -130,32 +130,15 @@ * Map a region of device bus space into CPU virtual address space. */ -static __inline int bus_space_map(bus_space_tag_t t, bus_addr_t addr, - bus_size_t size, int flags, - bus_space_handle_t *bshp); - -static __inline int -bus_space_map(bus_space_tag_t t __unused, bus_addr_t addr, - bus_size_t size __unused, int flags __unused, - bus_space_handle_t *bshp) -{ - - *bshp = addr; - return (0); -} +int bus_space_map(bus_space_tag_t tag, bus_addr_t addr, bus_size_t size, + int flags, bus_space_handle_t *bshp); /* * Unmap a region of device bus space. */ -static __inline void bus_space_unmap(bus_space_tag_t t, bus_space_handle_t bsh, - bus_size_t size); - -static __inline void -bus_space_unmap(bus_space_tag_t t __unused, bus_space_handle_t bsh __unused, - bus_size_t size __unused) -{ -} +void bus_space_unmap(bus_space_tag_t tag, bus_space_handle_t bsh, + bus_size_t size); /* * Get a new handle for a subregion of an already-mapped area of bus space. Copied: stable/10/sys/x86/x86/bus_machdep.c (from r286667, head/sys/x86/x86/bus_machdep.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/10/sys/x86/x86/bus_machdep.c Tue Aug 25 14:39:40 2015 (r287126, copy of r286667, head/sys/x86/x86/bus_machdep.c) @@ -0,0 +1,59 @@ +/*- + * Copyright (c) 2015 Marcel Moolenaar + * 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 ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include + +#include +#include + +/* + * Implementation of bus_space_map(), which effectively is a thin + * wrapper around pmap_mapdev() for memory mapped I/O space. It's + * implemented here and not in to avoid pollution. + */ +int +bus_space_map(bus_space_tag_t tag, bus_addr_t addr, bus_size_t size, + int flags __unused, bus_space_handle_t *bshp) +{ + + *bshp = (tag == X86_BUS_SPACE_MEM) + ? (uintptr_t)pmap_mapdev(addr, size) + : addr; + return (0); +} + +void +bus_space_unmap(bus_space_tag_t tag, bus_space_handle_t bsh, bus_size_t size) +{ + + if (tag == X86_BUS_SPACE_MEM) + pmap_unmapdev(bsh, size); +} From owner-svn-src-stable@freebsd.org Tue Aug 25 15:14:53 2015 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F03839C2A37; Tue, 25 Aug 2015 15:14:52 +0000 (UTC) (envelope-from marcel@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D439898; Tue, 25 Aug 2015 15:14:52 +0000 (UTC) (envelope-from marcel@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7PFEqsW092017; Tue, 25 Aug 2015 15:14:52 GMT (envelope-from marcel@FreeBSD.org) Received: (from marcel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7PFEpXX092012; Tue, 25 Aug 2015 15:14:51 GMT (envelope-from marcel@FreeBSD.org) Message-Id: <201508251514.t7PFEpXX092012@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: marcel set sender to marcel@FreeBSD.org using -f From: Marcel Moolenaar Date: Tue, 25 Aug 2015 15:14:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r287128 - in stable/10/sys: amd64/amd64 dev/vt dev/vt/hw/efifb dev/vt/hw/fb X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Aug 2015 15:14:53 -0000 Author: marcel Date: Tue Aug 25 15:14:50 2015 New Revision: 287128 URL: https://svnweb.freebsd.org/changeset/base/287128 Log: MFC r286808, r286809, r286867, r286868 - Improve support for Macs that have a stride not equal to the horizonal resolution (width). - Support frame buffers that are larger than the default screen size. - Support large frame buffers: add 24 more page table pages we allocate on boot-up. PR: 193745 Modified: stable/10/sys/amd64/amd64/pmap.c stable/10/sys/dev/vt/hw/efifb/efifb.c stable/10/sys/dev/vt/hw/fb/vt_fb.c stable/10/sys/dev/vt/vt.h stable/10/sys/dev/vt/vt_core.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/amd64/amd64/pmap.c ============================================================================== --- stable/10/sys/amd64/amd64/pmap.c Tue Aug 25 14:49:11 2015 (r287127) +++ stable/10/sys/amd64/amd64/pmap.c Tue Aug 25 15:14:50 2015 (r287128) @@ -701,8 +701,14 @@ nkpt_init(vm_paddr_t addr) * pmap_growkernel() will need to allocate page table pages to map * the entire 512GB of KVA space which is an unnecessary tax on * physical memory. + * + * Secondly, device memory mapped as part of setting up the low- + * level console(s) is taken from KVA, starting at virtual_avail. + * This is because cninit() is called after pmap_bootstrap() but + * before vm_init() and pmap_init(). 20MB for a frame buffer is + * not uncommon. */ - pt_pages += 8; /* 16MB additional slop for kernel modules */ + pt_pages += 32; /* 64MB additional slop. */ #endif nkpt = pt_pages; } Modified: stable/10/sys/dev/vt/hw/efifb/efifb.c ============================================================================== --- stable/10/sys/dev/vt/hw/efifb/efifb.c Tue Aug 25 14:49:11 2015 (r287127) +++ stable/10/sys/dev/vt/hw/efifb/efifb.c Tue Aug 25 15:14:50 2015 (r287128) @@ -98,7 +98,6 @@ vt_efifb_probe(struct vt_device *vd) static int vt_efifb_init(struct vt_device *vd) { - int depth, d; struct fb_info *info; struct efi_fb *efifb; caddr_t kmdp; @@ -118,16 +117,13 @@ vt_efifb_init(struct vt_device *vd) info->fb_height = efifb->fb_height; info->fb_width = efifb->fb_width; - depth = fls(efifb->fb_mask_red); - d = fls(efifb->fb_mask_green); - depth = d > depth ? d : depth; - d = fls(efifb->fb_mask_blue); - depth = d > depth ? d : depth; - d = fls(efifb->fb_mask_reserved); - depth = d > depth ? d : depth; - info->fb_depth = depth; + info->fb_depth = fls(efifb->fb_mask_red | efifb->fb_mask_green | + efifb->fb_mask_blue | efifb->fb_mask_reserved); + /* Round to a multiple of the bits in a byte. */ + info->fb_bpp = (info->fb_depth + NBBY - 1) & ~(NBBY - 1); - info->fb_stride = efifb->fb_stride * (depth / 8); + /* Stride in bytes, not pixels */ + info->fb_stride = efifb->fb_stride * (info->fb_bpp / NBBY); vt_generate_cons_palette(info->fb_cmap, COLOR_FORMAT_RGB, efifb->fb_mask_red, ffs(efifb->fb_mask_red) - 1, @@ -139,16 +135,6 @@ vt_efifb_init(struct vt_device *vd) info->fb_vbase = (intptr_t)pmap_mapdev_attr(info->fb_pbase, info->fb_size, VM_MEMATTR_WRITE_COMBINING); - /* Get pixel storage size. */ - info->fb_bpp = info->fb_stride / info->fb_width * 8; - - /* - * Early FB driver work with static window buffer, so reduce to minimal - * size, buffer or screen. - */ - info->fb_width = MIN(info->fb_width, VT_FB_DEFAULT_WIDTH); - info->fb_height = MIN(info->fb_height, VT_FB_DEFAULT_HEIGHT); - vt_fb_init(vd); return (CN_INTERNAL); Modified: stable/10/sys/dev/vt/hw/fb/vt_fb.c ============================================================================== --- stable/10/sys/dev/vt/hw/fb/vt_fb.c Tue Aug 25 14:49:11 2015 (r287127) +++ stable/10/sys/dev/vt/hw/fb/vt_fb.c Tue Aug 25 15:14:50 2015 (r287128) @@ -280,6 +280,7 @@ vt_fb_bitblt_bitmap(struct vt_device *vd if (mask != NULL && (mask[byte] & bit) == 0) continue; o = (y + yi) * info->fb_stride + (x + xi) * bpp; + o += vd->vd_transpose; cc = pattern[byte] & bit ? fgc : bgc; switch(bpp) { @@ -397,11 +398,16 @@ int vt_fb_init(struct vt_device *vd) { struct fb_info *info; + u_int margin; int err; info = vd->vd_softc; - vd->vd_height = info->fb_height; - vd->vd_width = info->fb_width; + vd->vd_height = MIN(VT_FB_DEFAULT_HEIGHT, info->fb_height); + margin = (info->fb_height - vd->vd_height) >> 1; + vd->vd_transpose = margin * info->fb_stride; + vd->vd_width = MIN(VT_FB_DEFAULT_WIDTH, info->fb_width); + margin = (info->fb_width - vd->vd_width) >> 1; + vd->vd_transpose += margin * (info->fb_bpp / NBBY); if (info->fb_size == 0) return (CN_DEAD); Modified: stable/10/sys/dev/vt/vt.h ============================================================================== --- stable/10/sys/dev/vt/vt.h Tue Aug 25 14:49:11 2015 (r287127) +++ stable/10/sys/dev/vt/vt.h Tue Aug 25 15:14:50 2015 (r287128) @@ -138,6 +138,7 @@ struct vt_device { uint32_t vd_mstate; /* (?) Mouse state. */ vt_axis_t vd_width; /* (?) Screen width. */ vt_axis_t vd_height; /* (?) Screen height. */ + size_t vd_transpose; /* (?) Screen offset in FB */ struct mtx vd_lock; /* Per-device lock. */ struct cv vd_winswitch; /* (d) Window switch notify. */ struct callout vd_timer; /* (d) Display timer. */ Modified: stable/10/sys/dev/vt/vt_core.c ============================================================================== --- stable/10/sys/dev/vt/vt_core.c Tue Aug 25 14:49:11 2015 (r287127) +++ stable/10/sys/dev/vt/vt_core.c Tue Aug 25 15:14:50 2015 (r287128) @@ -251,8 +251,9 @@ vt_update_static(void *dummy) if (!vty_enabled(VTY_VT)) return; if (main_vd->vd_driver != NULL) - printf("VT: running with driver \"%s\".\n", - main_vd->vd_driver->vd_name); + printf("VT(%s): %s %ux%u\n", main_vd->vd_driver->vd_name, + (main_vd->vd_flags & VDF_TEXTMODE) ? "text" : "resolution", + main_vd->vd_width, main_vd->vd_height); else printf("VT: init without driver.\n"); From owner-svn-src-stable@freebsd.org Tue Aug 25 19:18:38 2015 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C93BD9C2219; Tue, 25 Aug 2015 19:18:38 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B9247DF5; Tue, 25 Aug 2015 19:18:38 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7PJIcg4007625; Tue, 25 Aug 2015 19:18:38 GMT (envelope-from jkim@FreeBSD.org) Received: (from jkim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7PJIcfp007624; Tue, 25 Aug 2015 19:18:38 GMT (envelope-from jkim@FreeBSD.org) Message-Id: <201508251918.t7PJIcfp007624@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jkim set sender to jkim@FreeBSD.org using -f From: Jung-uk Kim Date: Tue, 25 Aug 2015 19:18:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r287139 - in stable: 10/sys/x86/include 9/sys/x86/include X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Aug 2015 19:18:38 -0000 Author: jkim Date: Tue Aug 25 19:18:38 2015 New Revision: 287139 URL: https://svnweb.freebsd.org/changeset/base/287139 Log: MFC: r286265, r286293, r286328 Always define __va_list for amd64 and restore pre-r232261 behavior for i386. Modified: stable/10/sys/x86/include/_types.h Directory Properties: stable/10/ (props changed) Changes in other areas also in this revision: Modified: stable/9/sys/x86/include/_types.h Directory Properties: stable/9/sys/ (props changed) Modified: stable/10/sys/x86/include/_types.h ============================================================================== --- stable/10/sys/x86/include/_types.h Tue Aug 25 17:39:03 2015 (r287138) +++ stable/10/sys/x86/include/_types.h Tue Aug 25 19:18:38 2015 (r287139) @@ -152,8 +152,16 @@ typedef int ___wchar_t; */ #ifdef __GNUCLIKE_BUILTIN_VARARGS typedef __builtin_va_list __va_list; /* internally known to gcc */ -#elif defined(lint) -typedef char * __va_list; /* pretend */ +#else +#ifdef __LP64__ +struct __s_va_list { + __uint32_t _pad1[2]; /* gp_offset, fp_offset */ + __uint64_t _pad2[2]; /* overflow_arg_area, reg_save_area */ +}; +typedef struct __s_va_list __va_list; +#else +typedef char * __va_list; +#endif #endif #if defined(__GNUC_VA_LIST_COMPATIBILITY) && !defined(__GNUC_VA_LIST) \ && !defined(__NO_GNUC_VA_LIST) From owner-svn-src-stable@freebsd.org Tue Aug 25 19:18:39 2015 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 79F8C9C221E; Tue, 25 Aug 2015 19:18:39 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6A25CDF6; Tue, 25 Aug 2015 19:18:39 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7PJIdXO007632; Tue, 25 Aug 2015 19:18:39 GMT (envelope-from jkim@FreeBSD.org) Received: (from jkim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7PJIdud007631; Tue, 25 Aug 2015 19:18:39 GMT (envelope-from jkim@FreeBSD.org) Message-Id: <201508251918.t7PJIdud007631@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jkim set sender to jkim@FreeBSD.org using -f From: Jung-uk Kim Date: Tue, 25 Aug 2015 19:18:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r287139 - in stable: 10/sys/x86/include 9/sys/x86/include X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Aug 2015 19:18:39 -0000 Author: jkim Date: Tue Aug 25 19:18:38 2015 New Revision: 287139 URL: https://svnweb.freebsd.org/changeset/base/287139 Log: MFC: r286265, r286293, r286328 Always define __va_list for amd64 and restore pre-r232261 behavior for i386. Modified: stable/9/sys/x86/include/_types.h Directory Properties: stable/9/sys/ (props changed) Changes in other areas also in this revision: Modified: stable/10/sys/x86/include/_types.h Directory Properties: stable/10/ (props changed) Modified: stable/9/sys/x86/include/_types.h ============================================================================== --- stable/9/sys/x86/include/_types.h Tue Aug 25 17:39:03 2015 (r287138) +++ stable/9/sys/x86/include/_types.h Tue Aug 25 19:18:38 2015 (r287139) @@ -148,8 +148,16 @@ typedef __uint64_t __vm_pindex_t; */ #ifdef __GNUCLIKE_BUILTIN_VARARGS typedef __builtin_va_list __va_list; /* internally known to gcc */ -#elif defined(lint) -typedef char * __va_list; /* pretend */ +#else +#ifdef __LP64__ +struct __s_va_list { + __uint32_t _pad1[2]; /* gp_offset, fp_offset */ + __uint64_t _pad2[2]; /* overflow_arg_area, reg_save_area */ +}; +typedef struct __s_va_list __va_list; +#else +typedef char * __va_list; +#endif #endif #if defined(__GNUC_VA_LIST_COMPATIBILITY) && !defined(__GNUC_VA_LIST) \ && !defined(__NO_GNUC_VA_LIST) From owner-svn-src-stable@freebsd.org Tue Aug 25 20:48:46 2015 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B16B299A684; Tue, 25 Aug 2015 20:48:46 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 96AC1983; Tue, 25 Aug 2015 20:48:46 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7PKmknl050989; Tue, 25 Aug 2015 20:48:46 GMT (envelope-from delphij@FreeBSD.org) Received: (from delphij@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7PKmjeR050985; Tue, 25 Aug 2015 20:48:45 GMT (envelope-from delphij@FreeBSD.org) Message-Id: <201508252048.t7PKmjeR050985@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: delphij set sender to delphij@FreeBSD.org using -f From: Xin LI Date: Tue, 25 Aug 2015 20:48:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r287144 - in stable: 10/crypto/openssh 9/crypto/openssh X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Aug 2015 20:48:46 -0000 Author: delphij Date: Tue Aug 25 20:48:44 2015 New Revision: 287144 URL: https://svnweb.freebsd.org/changeset/base/287144 Log: MFC: Fix OpenSSH multiple vulnerabilities. Security: FreeBSD-SA-15:22.openssh Modified: stable/9/crypto/openssh/monitor.c stable/9/crypto/openssh/monitor_wrap.c stable/9/crypto/openssh/mux.c Changes in other areas also in this revision: Modified: stable/10/crypto/openssh/monitor.c stable/10/crypto/openssh/monitor_wrap.c stable/10/crypto/openssh/mux.c Modified: stable/9/crypto/openssh/monitor.c ============================================================================== --- stable/9/crypto/openssh/monitor.c Tue Aug 25 20:48:37 2015 (r287143) +++ stable/9/crypto/openssh/monitor.c Tue Aug 25 20:48:44 2015 (r287144) @@ -1027,9 +1027,7 @@ extern KbdintDevice sshpam_device; int mm_answer_pam_init_ctx(int sock, Buffer *m) { - debug3("%s", __func__); - authctxt->user = buffer_get_string(m, NULL); sshpam_ctxt = (sshpam_device.init_ctx)(authctxt); sshpam_authok = NULL; buffer_clear(m); @@ -1111,14 +1109,16 @@ mm_answer_pam_respond(int sock, Buffer * int mm_answer_pam_free_ctx(int sock, Buffer *m) { + int r = sshpam_authok != NULL && sshpam_authok == sshpam_ctxt; debug3("%s", __func__); (sshpam_device.free_ctx)(sshpam_ctxt); + sshpam_ctxt = sshpam_authok = NULL; buffer_clear(m); mm_request_send(sock, MONITOR_ANS_PAM_FREE_CTX, m); auth_method = "keyboard-interactive"; auth_submethod = "pam"; - return (sshpam_authok == sshpam_ctxt); + return r; } #endif Modified: stable/9/crypto/openssh/monitor_wrap.c ============================================================================== --- stable/9/crypto/openssh/monitor_wrap.c Tue Aug 25 20:48:37 2015 (r287143) +++ stable/9/crypto/openssh/monitor_wrap.c Tue Aug 25 20:48:44 2015 (r287144) @@ -820,7 +820,6 @@ mm_sshpam_init_ctx(Authctxt *authctxt) debug3("%s", __func__); buffer_init(&m); - buffer_put_cstring(&m, authctxt->user); mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_PAM_INIT_CTX, &m); debug3("%s: waiting for MONITOR_ANS_PAM_INIT_CTX", __func__); mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_PAM_INIT_CTX, &m); Modified: stable/9/crypto/openssh/mux.c ============================================================================== --- stable/9/crypto/openssh/mux.c Tue Aug 25 20:48:37 2015 (r287143) +++ stable/9/crypto/openssh/mux.c Tue Aug 25 20:48:44 2015 (r287144) @@ -635,7 +635,8 @@ process_mux_open_fwd(u_int rid, Channel u_int lport, cport; int i, ret = 0, freefwd = 1; - fwd.listen_host = fwd.connect_host = NULL; + memset(&fwd, 0, sizeof(fwd)); + if (buffer_get_int_ret(&ftype, m) != 0 || (fwd.listen_host = buffer_get_string_ret(m, NULL)) == NULL || buffer_get_int_ret(&lport, m) != 0 || @@ -785,7 +786,8 @@ process_mux_close_fwd(u_int rid, Channel int i, listen_port, ret = 0; u_int lport, cport; - fwd.listen_host = fwd.connect_host = NULL; + memset(&fwd, 0, sizeof(fwd)); + if (buffer_get_int_ret(&ftype, m) != 0 || (fwd.listen_host = buffer_get_string_ret(m, NULL)) == NULL || buffer_get_int_ret(&lport, m) != 0 || From owner-svn-src-stable@freebsd.org Tue Aug 25 20:48:47 2015 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C439B99A68B; Tue, 25 Aug 2015 20:48:47 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id AA79E990; Tue, 25 Aug 2015 20:48:47 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7PKmlmx050999; Tue, 25 Aug 2015 20:48:47 GMT (envelope-from delphij@FreeBSD.org) Received: (from delphij@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7PKmkqT050996; Tue, 25 Aug 2015 20:48:46 GMT (envelope-from delphij@FreeBSD.org) Message-Id: <201508252048.t7PKmkqT050996@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: delphij set sender to delphij@FreeBSD.org using -f From: Xin LI Date: Tue, 25 Aug 2015 20:48:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r287144 - in stable: 10/crypto/openssh 9/crypto/openssh X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Aug 2015 20:48:48 -0000 Author: delphij Date: Tue Aug 25 20:48:44 2015 New Revision: 287144 URL: https://svnweb.freebsd.org/changeset/base/287144 Log: MFC: Fix OpenSSH multiple vulnerabilities. Security: FreeBSD-SA-15:22.openssh Modified: stable/10/crypto/openssh/monitor.c stable/10/crypto/openssh/monitor_wrap.c stable/10/crypto/openssh/mux.c Changes in other areas also in this revision: Modified: stable/9/crypto/openssh/monitor.c stable/9/crypto/openssh/monitor_wrap.c stable/9/crypto/openssh/mux.c Modified: stable/10/crypto/openssh/monitor.c ============================================================================== --- stable/10/crypto/openssh/monitor.c Tue Aug 25 20:48:37 2015 (r287143) +++ stable/10/crypto/openssh/monitor.c Tue Aug 25 20:48:44 2015 (r287144) @@ -1027,9 +1027,7 @@ extern KbdintDevice sshpam_device; int mm_answer_pam_init_ctx(int sock, Buffer *m) { - debug3("%s", __func__); - authctxt->user = buffer_get_string(m, NULL); sshpam_ctxt = (sshpam_device.init_ctx)(authctxt); sshpam_authok = NULL; buffer_clear(m); @@ -1111,14 +1109,16 @@ mm_answer_pam_respond(int sock, Buffer * int mm_answer_pam_free_ctx(int sock, Buffer *m) { + int r = sshpam_authok != NULL && sshpam_authok == sshpam_ctxt; debug3("%s", __func__); (sshpam_device.free_ctx)(sshpam_ctxt); + sshpam_ctxt = sshpam_authok = NULL; buffer_clear(m); mm_request_send(sock, MONITOR_ANS_PAM_FREE_CTX, m); auth_method = "keyboard-interactive"; auth_submethod = "pam"; - return (sshpam_authok == sshpam_ctxt); + return r; } #endif Modified: stable/10/crypto/openssh/monitor_wrap.c ============================================================================== --- stable/10/crypto/openssh/monitor_wrap.c Tue Aug 25 20:48:37 2015 (r287143) +++ stable/10/crypto/openssh/monitor_wrap.c Tue Aug 25 20:48:44 2015 (r287144) @@ -820,7 +820,6 @@ mm_sshpam_init_ctx(Authctxt *authctxt) debug3("%s", __func__); buffer_init(&m); - buffer_put_cstring(&m, authctxt->user); mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_PAM_INIT_CTX, &m); debug3("%s: waiting for MONITOR_ANS_PAM_INIT_CTX", __func__); mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_PAM_INIT_CTX, &m); Modified: stable/10/crypto/openssh/mux.c ============================================================================== --- stable/10/crypto/openssh/mux.c Tue Aug 25 20:48:37 2015 (r287143) +++ stable/10/crypto/openssh/mux.c Tue Aug 25 20:48:44 2015 (r287144) @@ -633,7 +633,8 @@ process_mux_open_fwd(u_int rid, Channel u_int lport, cport; int i, ret = 0, freefwd = 1; - fwd.listen_host = fwd.connect_host = NULL; + memset(&fwd, 0, sizeof(fwd)); + if (buffer_get_int_ret(&ftype, m) != 0 || (fwd.listen_host = buffer_get_string_ret(m, NULL)) == NULL || buffer_get_int_ret(&lport, m) != 0 || @@ -783,7 +784,8 @@ process_mux_close_fwd(u_int rid, Channel int i, listen_port, ret = 0; u_int lport, cport; - fwd.listen_host = fwd.connect_host = NULL; + memset(&fwd, 0, sizeof(fwd)); + if (buffer_get_int_ret(&ftype, m) != 0 || (fwd.listen_host = buffer_get_string_ret(m, NULL)) == NULL || buffer_get_int_ret(&lport, m) != 0 || From owner-svn-src-stable@freebsd.org Wed Aug 26 01:41:57 2015 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2CCF29C3122; Wed, 26 Aug 2015 01:41:57 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1A5BB7C3; Wed, 26 Aug 2015 01:41:57 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7Q1fueJ074175; Wed, 26 Aug 2015 01:41:56 GMT (envelope-from np@FreeBSD.org) Received: (from np@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7Q1fuN8074173; Wed, 26 Aug 2015 01:41:56 GMT (envelope-from np@FreeBSD.org) Message-Id: <201508260141.t7Q1fuN8074173@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: np set sender to np@FreeBSD.org using -f From: Navdeep Parhar Date: Wed, 26 Aug 2015 01:41:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r287149 - stable/10/sys/dev/cxgbe X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Aug 2015 01:41:57 -0000 Author: np Date: Wed Aug 26 01:41:55 2015 New Revision: 287149 URL: https://svnweb.freebsd.org/changeset/base/287149 Log: MFC r286926: cxgbe(4): Save the flags for the last adapter-wide synchronized operation that was initiated successfully. (The caller and thread are already recorded). Modified: stable/10/sys/dev/cxgbe/adapter.h stable/10/sys/dev/cxgbe/t4_main.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/cxgbe/adapter.h ============================================================================== --- stable/10/sys/dev/cxgbe/adapter.h Tue Aug 25 21:55:15 2015 (r287148) +++ stable/10/sys/dev/cxgbe/adapter.h Wed Aug 26 01:41:55 2015 (r287149) @@ -801,6 +801,7 @@ struct adapter { #ifdef INVARIANTS const char *last_op; const void *last_op_thr; + int last_op_flags; #endif int sc_do_rxcopy; Modified: stable/10/sys/dev/cxgbe/t4_main.c ============================================================================== --- stable/10/sys/dev/cxgbe/t4_main.c Tue Aug 25 21:55:15 2015 (r287148) +++ stable/10/sys/dev/cxgbe/t4_main.c Wed Aug 26 01:41:55 2015 (r287149) @@ -1149,6 +1149,7 @@ cxgbe_detach(device_t dev) #ifdef INVARIANTS sc->last_op = "t4detach"; sc->last_op_thr = curthread; + sc->last_op_flags = 0; #endif ADAPTER_UNLOCK(sc); @@ -3109,6 +3110,7 @@ begin_synchronized_op(struct adapter *sc #ifdef INVARIANTS sc->last_op = wmesg; sc->last_op_thr = curthread; + sc->last_op_flags = flags; #endif done: From owner-svn-src-stable@freebsd.org Wed Aug 26 22:59:59 2015 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 66B7E9C3D11; Wed, 26 Aug 2015 22:59:59 +0000 (UTC) (envelope-from avatar@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3A34F3B7; Wed, 26 Aug 2015 22:59:59 +0000 (UTC) (envelope-from avatar@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7QMxxqs001650; Wed, 26 Aug 2015 22:59:59 GMT (envelope-from avatar@FreeBSD.org) Received: (from avatar@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7QMxxHX001649; Wed, 26 Aug 2015 22:59:59 GMT (envelope-from avatar@FreeBSD.org) Message-Id: <201508262259.t7QMxxHX001649@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avatar set sender to avatar@FreeBSD.org using -f From: Tai-hwa Liang Date: Wed, 26 Aug 2015 22:59:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r287180 - stable/10/sys/dev/sound/midi X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Aug 2015 22:59:59 -0000 Author: avatar Date: Wed Aug 26 22:59:58 2015 New Revision: 287180 URL: https://svnweb.freebsd.org/changeset/base/287180 Log: MFC r286886: Fixing typo as well as improving readability of a few comments. Modified: stable/10/sys/dev/sound/midi/midi.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/sound/midi/midi.c ============================================================================== --- stable/10/sys/dev/sound/midi/midi.c Wed Aug 26 22:52:18 2015 (r287179) +++ stable/10/sys/dev/sound/midi/midi.c Wed Aug 26 22:59:58 2015 (r287180) @@ -86,7 +86,7 @@ enum midi_states { }; /* - * The MPU interface current has init() uninit() inqsize(( outqsize() + * The MPU interface current has init() uninit() inqsize() outqsize() * callback() : fiddle with the tx|rx status. */ @@ -160,10 +160,15 @@ DEFINE_CLASS(midisynth, midisynth_method /* * Module Exports & Interface * - * struct midi_chan *midi_init(MPU_CLASS cls, int unit, int chan) int - * midi_uninit(struct snd_midi *) 0 == no error EBUSY or other error int - * Midi_in(struct midi_chan *, char *buf, int count) int Midi_out(struct - * midi_chan *, char *buf, int count) + * struct midi_chan *midi_init(MPU_CLASS cls, int unit, int chan, + * void *cookie) + * int midi_uninit(struct snd_midi *) + * + * 0 == no error + * EBUSY or other error + * + * int midi_in(struct snd_midi *, char *buf, int count) + * int midi_out(struct snd_midi *, char *buf, int count) * * midi_{in,out} return actual size transfered * @@ -388,7 +393,7 @@ err0: mtx_unlock(&midistat_lock); /* * midi_uninit does not call MIDI_UNINIT, as since this is the implementors - * entry point. midi_unint if fact, does not send any methods. A call to + * entry point. midi_uninit if fact, does not send any methods. A call to * midi_uninit is a defacto promise that you won't manipulate ch anymore * */ From owner-svn-src-stable@freebsd.org Thu Aug 27 01:02:02 2015 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 032499C092C; Thu, 27 Aug 2015 01:02:02 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E789E27E; Thu, 27 Aug 2015 01:02:01 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7R121nN054261; Thu, 27 Aug 2015 01:02:01 GMT (envelope-from delphij@FreeBSD.org) Received: (from delphij@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7R121OX054260; Thu, 27 Aug 2015 01:02:01 GMT (envelope-from delphij@FreeBSD.org) Message-Id: <201508270102.t7R121OX054260@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: delphij set sender to delphij@FreeBSD.org using -f From: Xin LI Date: Thu, 27 Aug 2015 01:02:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r287184 - stable/10/cddl/contrib/opensolaris/cmd/ztest X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Aug 2015 01:02:02 -0000 Author: delphij Date: Thu Aug 27 01:02:01 2015 New Revision: 287184 URL: https://svnweb.freebsd.org/changeset/base/287184 Log: MFC r286737: Plug a memory leak. Modified: stable/10/cddl/contrib/opensolaris/cmd/ztest/ztest.c Directory Properties: stable/10/ (props changed) Modified: stable/10/cddl/contrib/opensolaris/cmd/ztest/ztest.c ============================================================================== --- stable/10/cddl/contrib/opensolaris/cmd/ztest/ztest.c Wed Aug 26 23:58:03 2015 (r287183) +++ stable/10/cddl/contrib/opensolaris/cmd/ztest/ztest.c Thu Aug 27 01:02:01 2015 (r287184) @@ -5905,6 +5905,7 @@ ztest_init(ztest_shared_t *zs) } VERIFY3U(0, ==, spa_create(ztest_opts.zo_pool, nvroot, props, NULL)); nvlist_free(nvroot); + nvlist_free(props); VERIFY3U(0, ==, spa_open(ztest_opts.zo_pool, &spa, FTAG)); zs->zs_metaslab_sz = From owner-svn-src-stable@freebsd.org Thu Aug 27 09:06:16 2015 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1C6FB9C4145; Thu, 27 Aug 2015 09:06:16 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0C526FD2; Thu, 27 Aug 2015 09:06:16 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7R96FPv050503; Thu, 27 Aug 2015 09:06:15 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7R96FWr050501; Thu, 27 Aug 2015 09:06:15 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201508270906.t7R96FWr050501@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Thu, 27 Aug 2015 09:06:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r287199 - in stable/10: lib/libc/sys sys/kern X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Aug 2015 09:06:16 -0000 Author: kib Date: Thu Aug 27 09:06:14 2015 New Revision: 287199 URL: https://svnweb.freebsd.org/changeset/base/287199 Log: MFC r286975: Remove the wrong asserts. Modified: stable/10/lib/libc/sys/procctl.2 stable/10/sys/kern/kern_procctl.c Directory Properties: stable/10/ (props changed) Modified: stable/10/lib/libc/sys/procctl.2 ============================================================================== --- stable/10/lib/libc/sys/procctl.2 Thu Aug 27 08:58:03 2015 (r287198) +++ stable/10/lib/libc/sys/procctl.2 Thu Aug 27 09:06:14 2015 (r287199) @@ -29,7 +29,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 29, 2014 +.Dd August 21, 2015 .Dt PROCCTL 2 .Os .Sh NAME @@ -148,7 +148,11 @@ The specified process is the root of the .El The .Fa rs_children -field returns the number of children of the reaper. +field returns the number of children of the reaper among the descendands. +It is possible to have a child which reaper is not the specified process, +since the reaper for the existing children is not reset on the +.Dv PROC_REAP_ACQUIRE +operation. The .Fa rs_descendants field returns the total number of descendants of the reaper(s), Modified: stable/10/sys/kern/kern_procctl.c ============================================================================== --- stable/10/sys/kern/kern_procctl.c Thu Aug 27 08:58:03 2015 (r287198) +++ stable/10/sys/kern/kern_procctl.c Thu Aug 27 09:06:14 2015 (r287199) @@ -187,8 +187,6 @@ reap_status(struct thread *td, struct pr } } else { rs->rs_pid = -1; - KASSERT(LIST_EMPTY(&reap->p_reaplist), ("reap children list")); - KASSERT(LIST_EMPTY(&reap->p_children), ("children list")); } return (0); } From owner-svn-src-stable@freebsd.org Thu Aug 27 13:17:07 2015 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id ED13D9C49AC; Thu, 27 Aug 2015 13:17:06 +0000 (UTC) (envelope-from ken@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DBF3E120D; Thu, 27 Aug 2015 13:17:06 +0000 (UTC) (envelope-from ken@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7RDH6vb053607; Thu, 27 Aug 2015 13:17:06 GMT (envelope-from ken@FreeBSD.org) Received: (from ken@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7RDH6jp053604; Thu, 27 Aug 2015 13:17:06 GMT (envelope-from ken@FreeBSD.org) Message-Id: <201508271317.t7RDH6jp053604@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ken set sender to ken@FreeBSD.org using -f From: "Kenneth D. Merry" Date: Thu, 27 Aug 2015 13:17:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r287203 - in stable/10: sbin/camcontrol sys/cam/scsi X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Aug 2015 13:17:07 -0000 Author: ken Date: Thu Aug 27 13:17:05 2015 New Revision: 287203 URL: https://svnweb.freebsd.org/changeset/base/287203 Log: MFC, r286965: ------------------------------------------------------------------------ r286965 | ken | 2015-08-20 10:07:51 -0600 (Thu, 20 Aug 2015) | 297 lines Revamp camcontrol(8) fwdownload support and add the opcodes subcommand. The significant changes and bugs fixed here are: 1. Fixed a bug in the progress display code: When the user's filename is too big, or his terminal width is too small, the progress code could wind up using a negative number for the length of the "stars" that it uses to indicate progress. This negative value was assigned to an unsigned variable, resulting in a very large positive value. The result is that we wound up writing garbage from memory to the user's terminal. With an 80 column terminal, a file name length of more than 35 characters would generate this problem. To address this, we now set a minimum progress bar length, and truncate the user's file name as needed. This has been tested with large filenames and small terminals, and at least produces reasonable results. If the terminal is too narrow, the progress display takes up an additional line with each update, but this is more user friendly than writing garbage to the tty. 2. SATA drives connected via a SATA controller didn't have SCSI Inquiry data populated in struct cam_device. This meant that the code in fw_get_vendor() in fwdownload.c would try to match a zero-length vendor ID, and so return the first entry in the vendor table. (Which used to be HITACHI.) Fixed by grabbing identify data, passing the identify buffer into fw_get_vendor(), and matching against the model name. 3. SATA drives connected via a SAS controller do have Inquiry data populated. The table included a couple of entries -- "ATA ST" and "ATA HDS", intended to handle Seagate and Hitachi SATA drives attached via a SAS controller. SCSI to ATA translation layers use a vendor ID of "ATA" (which is standard), and then the model name from the ATA identify data as the SCSI product name when they are returning data on SATA disks. The cam_strmatch code will match the first part of the string (because the length it is given is the length of the vendor, "ATA"), and return 0 (i.e. a match). So all SATA drives attached to a SAS controller would be programmed using the Seagate method (WRITE BUFFER mode 7) of SCSI firmware downloading. 4. Issue #2 above covered up a bug in fw_download_img() -- if the maximum packet size in the vendor table was 0, it tried to default to a packet size of 32K. But then it didn't actually succeed in doing that, because it set the packet size to the value that was in the vendor table (0). Now that we actually have ATA attached drives fall use the VENDOR_ATA case, we need a reasonable default packet size. So this is fixed to properly set the default packet size. 5. Add support for downloading firmware to IBM LTO drives, and add a firmware file validation method to make sure that the firmware file matches the drive type. IBM tape drives include a Load ID and RU name in their vendor-specific VPD page 0x3. Those should match the IDs in the header of the firmware file to insure that the proper firmware file is loaded. 6. This also adds a new -q option to the camcontrol fwdownload subcommand to suppress informational output. When -q is used in combination with -y, the firmware upgrade will happen without prompting and without output except if an error condition occurs. 7. Re-add support for printing out SCSI inquiry information when asking the user to confirm that they want to download firmware, and add printing of ATA Identify data if it is a SATA disk. This was removed in r237281 when support for flashing ATA disks was added. 8. Add a new camcontrol(8) "opcodes" subcommand, and use the underlying code to get recommended timeout values for drive firmware downloads. Many SCSI devices support the REPORT SUPPORTED OPERATION CODES command, and some support the optional timeout descriptor that specifies nominal and recommended timeouts for the commands supported by the device. The new camcontrol opcodes subcommand allows displaying all opcodes supported by a drive, information about which fields in a SCSI CDB are actually used by a given SCSI device, and the nominal and recommended timeout values for each command. Since firmware downloads can take a long time in some devices, and the time varies greatly between different types of devices, take advantage of the infrastructure used by the camcontrol opcodes subcommand to determine the best timeout to use for the WRITE BUFFER command in SCSI device firmware downloads. If the device recommends a timeout, it is likely to be more accurate than the default 50 second timeout used by the firmware download code. If the user specifies a timeout, it will override the default or device recommended timeout. If the device doesn't support timeout descriptors, we fall back to the default. 9. Instead of downloading firmware to SATA drives behind a SAS controller using WRITE BUFFER, use the SCSI ATA PASS-THROUGH command to compose an ATA DOWNLOAD MICROCODE command and it to the drive. The previous version of this code attempted to send a SCSI WRITE BUFFER command to SATA drives behind a SAS controller. Although that is part of the SAT-3 spec, it doesn't work with the parameters used with LSI controllers at least. 10.Add a new mechanism for making common ATA passthrough and ATA-behind-SCSI passthrough commands. The existing camcontrol(8) ATA command mechanism checks the device type on every command executed. That works fine for individual commands, but is cumbersome for things like a firmware download that send a number of commands. The fwdownload code detects the device type up front, and then sends the appropriate commands. 11.In simulation mode (-s), if the user specifies the -v flag, print out the SCSI CDB or ATA registers that would be sent to the drive. This will aid in debugging any firmware download issues. sbin/camcontrol/fwdownload.c: Add a device type to the fw_vendor structure, so that we can specify different download methods for different devices from the same vendor. In this case, IBM hard drives (from when they still made hard drives) and tape drives. Add a tur_status field to the fw_vendor structure so that we can specify whether the drive to be upgraded should be ready, not ready, or whether it doesn't matter. Add the corresponding capability in fw_download_img(). Add comments describing each of the vendor table fields. Add HGST and SmrtStor to the supported SCSI vendors list. In fw_get_vendor(), look at ATA identify data if we have a SATA device to try to identify what the drive vendor is. Add IBM firmware file validation. This gets VPD page 0x3, and compares the Load ID and RU name in the page to the values included in the header. The validation code will refuse to load a firmware file if the values don't match. This does allow the user to attempt a downgrade; whether or not it succeeds will likely depend on the drive settings. Add a -q option, and disable all informative output (progress bars, etc.) when this is enabled. Re-add the inquiry in the confirmation dialog so the user has a better idea of which device he is talking to. Add support for displaying ATA identify data. Don't automatically disable confirmation in simulation (-s) mode. This allows the user to see the inquiry or identify data in the dialog, and see exactly what they would see when the command actually runs. Also, in simulation mode, if the user specifies the -v flag, print out the SCSI CDB or ATA registers that would be sent to the drive. This will aid in debugging any firmware download issues. Add a timeout field and timeout type to the firmware download vendor table. This allows specifying a default timeout and allows specifying whether we should attempt to probe for a recommended timeout from the drive. Add a new fuction, fw_get_timeout(), that will determine which timeout to use for the WRITE BUFFER command. If the user specifies a timeout, we always use that. Otherwise, we will use the drive recommended timeout, if available, and fall back to the default when a drive recommended timeout isn't available. When we prompt the user, tell him what timeout we're going to use, and the source of the timeout. Revamp the way SATA devices are handled. In fwdownload(), use the new get_device_type() function to determine what kind of device we're talking to. Allow firmware downloads to any SATA device, but restrict SCSI downloads to known devices. (The latter is not a change in behavior.) Break out the "ready" check from fw_download_img() into a new subfunction, fw_check_device_ready(). This sends the appropriate command to the device in question -- a TEST UNIT READY or an IDENTIFY. The IDENTIFY for SATA devices a SAT layer is done using the SCSI ATA PASS-THROUGH command. Use the new build_ata_cmd() function to build either a SCSI or ATA I/O CCB to issue the DOWNLOAD MICROCODE command to SATA devices. build_ata_cmd() figures looks at the devtype argument and fills in the correct CCB type and CDB or ATA registers. Revamp the vendor table to remove the previous vendor-specific ATA entries and use a generic ATA vendor placeholder. We currently use the same method for all ATA drives, although we may have to add vendor-specific behavior once we test this with more drives. sbin/camcontrol/progress.c: In progress_draw(), make barlength a signed value so that we can easily detect a negative value. If barlength (the length of the progress bar) would wind up negative due to a small TTY width or a large filename, set the bar length to the new minimum (10 stars) and truncate the user's filename. We will truncate it down to 0 characters if necessary. Calculate a new prefix_len variable (user's filename length) and use it as the precision when printing the filename. sbin/camcontrol/camcontrol.c: Implement a new camcontrol(8) subcommand, "opcodes". The opcodes subcommand allows displaying the entire list of SCSI commands supported by a device, or details on an individual command. In either case, it can display nominal and recommended timeout values. Add the scsiopcodes() function, which calls the new scsigetopcodes() function to fetch opcode data from a drive. Add two new functions, scsiprintoneopcode() and scsiprintopcodes(), which print information about one opcode or all opcodes, respectively. Remove the get_disk_type() function. It is no longer used. Add a new function, dev_has_vpd_page(), that fetches the supported INQUIRY VPD list from a device and tells the caller whether the requested VPD page is available. Add a new function, get_device_type(), that returns a more precise device type than the old get_disk_type() function. The get_disk_type() function only distinguished between SCSI and ATA devices, and SATA devices behind a SCSI to ATA translation layer were considered to be "SCSI". get_device_type() offers a third type, CC_DT_ATA_BEHIND_SCSI. We need to know this to know whether to attempt to send ATA passthrough commands. If the device has the ATA Information VPD page (0x89), then it is an ATA device behind a SCSI to ATA translation layer. Remove the type argument from the fwdownload() subcommand. Add a new function, build_ata_cmd(), that will take one set of common arguments and build either a SCSI or ATA I/O CCB, depending on the device type passed in. sbin/camcontrol/camcontrol.h: Add a prototype for scsigetopcodes(). Add a new enumeration, camcontrol_devtype. Add prototypes for dev_has_vpd_page(), get_device_type() and build_ata_cmd(). Remove the type argument from the fwdownload() subcommand. sbin/camcontrol/camcontrol.8 Explain that the fwdownload subcommand will use the drive recommended timeout if available, and that the user can override the timeout. Document the new opcodes subcommand. Explain that we will attempt to download firmware to any SATA device. Document supported SCSI vendors, and models tested if known. Explain the commands used to download firmware for the three different drive and controller combinations. Document that the -v flag in simulation mode for the fwdownload subcommand will print out the SCSI CDBs or ATA registers that would be used. sys/cam/scsi/scsi_all.h: Add new bit definitions for the one opcode descriptor for the REPORT SUPPORTED OPCODES command. Add a function prototype for scsi_report_supported_opcodes(). sys/cam/scsi/scsi_all.c: Add a new CDB building function, scsi_report_supported_opcodes(). Sponsored by: Spectra Logic Modified: stable/10/sbin/camcontrol/camcontrol.8 stable/10/sbin/camcontrol/camcontrol.c stable/10/sbin/camcontrol/camcontrol.h stable/10/sbin/camcontrol/fwdownload.c stable/10/sbin/camcontrol/progress.c stable/10/sys/cam/scsi/scsi_all.c stable/10/sys/cam/scsi/scsi_all.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sbin/camcontrol/camcontrol.8 ============================================================================== --- stable/10/sbin/camcontrol/camcontrol.8 Thu Aug 27 13:08:45 2015 (r287202) +++ stable/10/sbin/camcontrol/camcontrol.8 Thu Aug 27 13:17:05 2015 (r287203) @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 19, 2015 +.Dd August 6, 2015 .Dt CAMCONTROL 8 .Os .Sh NAME @@ -253,8 +253,9 @@ .Op device id .Op generic args .Aq Fl f Ar fw_image -.Op Fl y +.Op Fl q .Op Fl s +.Op Fl y .Nm .Ic security .Op device id @@ -311,6 +312,14 @@ .Op Fl T Ar elem_type .Op Fl V Ar lv_num .Nm +.Ic opcodes +.Op device id +.Op generic args +.Op Fl o Ar opcode +.Op Fl s Ar service_action +.Op Fl N +.Op Fl T +.Nm .Ic help .Sh DESCRIPTION The @@ -1517,24 +1526,41 @@ without prompting for confirmation The password for all HPA commands is limited to 32 characters, longer passwords will fail. .It Ic fwdownload -Program firmware of the named SCSI device using the image file provided. +Program firmware of the named +.Tn SCSI +or ATA device using the image file provided. .Pp -Current list of supported vendors: -.Bl -bullet -offset indent -compact -.It -HITACHI -.It -HP -.It -IBM -.It -PLEXTOR -.It -QUANTUM -.It -SAMSUNG -.It -SEAGATE +If the device is a +.Tn SCSI +device and it provides a recommended timeout for the WRITE BUFFER command +(see the +.Nm +opcodes subcommand), that timeout will be used for the firmware download. +The drive-recommended timeout value may be overridden on the command line +with the +.Fl t +option. +.Pp +Current list of supported vendors for SCSI/SAS drives: +.Bl -tag -width 10n +.It HGST +Tested with 4TB SAS drives, model number HUS724040ALS640. +.It HITACHI +.It HP +.It IBM +Tested with LTO-5 (ULTRIUM-HH5) and LTO-6 (ULTRIUM-HH6) tape drives. +There is a separate table entry for hard drives, because the update method +for hard drives is different than the method for tape drives. +.It PLEXTOR +.It QUALSTAR +.It QUANTUM +.It SAMSUNG +Tested with SM1625 SSDs. +.It SEAGATE +Tested with Constellation ES (ST32000444SS), ES.2 (ST33000651SS) and +ES.3 (ST1000NM0023) drives. +.It SmrtStor +Tested with 400GB Optimus SSDs (TXA2D20400GA6001). .El .Pp .Em WARNING! WARNING! WARNING! @@ -1548,23 +1574,81 @@ Extra caution should be taken when using guarantee it will not break a device from the listed vendors. Ensure that you have a recent backup of the data on the device before performing a firmware update. +.Pp +Note that unknown +.Tn SCSI +protocol devices will not be programmed, since there is little chance of +the firmware download succeeding. +.Pp +.Nm +will currently attempt a firmware download to any +.Tn ATA +or +.Tn SATA +device, since the standard +.Tn ATA +DOWNLOAD MICROCODE command may work. +Firmware downloads to +.Tn ATA +and +.Tn SATA +devices are supported for devices connected +to standard +.Tn ATA +and +.Tn SATA +controllers, and devices connected to SAS controllers +with +.Tn SCSI +to +.Tn ATA +translation capability. +In the latter case, +.Nm +uses the +.Tn SCSI +.Tn ATA +PASS-THROUGH command to send the +.Tn ATA +DOWNLOAD MICROCODE command to the drive. +Some +.Tn SCSI +to +.Tn ATA +translation implementations don't work fully when translating +.Tn SCSI +WRITE BUFFER commands to +.Tn ATA +DOWNLOAD MICROCODE commands, but do support +.Tn ATA +passthrough well enough to do a firmware download. .Bl -tag -width 11n .It Fl f Ar fw_image Path to the firmware image file to be downloaded to the specified device. -.It Fl y -Do not ask for confirmation. +.It Fl q +Do not print informational messages, only print errors. +This option should be used with the +.Fl y +option to suppress all output. .It Fl s Run in simulation mode. -Packet sizes that will be sent are shown, but no actual packet is sent to the -device. -No confirmation is asked in simulation mode. +Device checks are run and the confirmation dialog is shown, but no firmware +download will occur. .It Fl v -Besides showing sense information in case of a failure, the verbose option -causes -.Nm -to output a line for every firmware segment that is sent to the device by the -fwdownload command --- the same as the ones shown in simulation mode. +Show +.Tn SCSI +or +.Tn ATA +errors in the event of a failure. +.Pp +In simulation mode, print out the +.Tn SCSI +CDB +or +.Tn ATA +register values that would be used for the firmware download command. +.It Fl y +Do not ask for confirmation. .El .It Ic persist Persistent reservation support. @@ -1959,6 +2043,52 @@ and Specify the number of the logical volume to operate on. If the media has multiple logical volumes, this will allow displaying or writing attributes on the given logical volume. +.It Ic opcodes +Issue the REPORT SUPPORTED OPCODES service action of the +.Tn SCSI +MAINTENANCE IN +command. +Without arguments, this command will return a list of all +.Tn SCSI +commands supported by the device, including service actions of commands +that support service actions. +It will also include the +.Tn SCSI +CDB (Command Data Block) length for each command, and the description of +each command if it is known. +.Bl -tag -width 18n +.It Fl o Ar opcode +Request information on a specific opcode instead of the list of supported +commands. +If supported, the target will return a CDB-like structure that indicates +the opcode, service action (if any), and a mask of bits that are supported +in that CDB. +.It Fl s Ar service_action +For commands that support a service action, specify the service action to +query. +.It Fl N +If a service action is specified for a given opcode, and the device does +not support the given service action, the device should not return a +.Tn SCSI +error, but rather indicate in the returned parameter data that the command +is not supported. +By default, if a service action is specified for an opcode, and service +actions are not supported for the opcode in question, the device will +return an error. +.It Fl T +Include timeout values. +This option works with the default display, which includes all commands +supported by the device, and with the +.Fl o +and +.Fl s +options, which request information on a specific command and service +action. +This requests that the device report Nominal and Recommended timeout values +for the given command or commands. +The timeout values are in seconds. +The timeout descriptor also includes a command-specific +.El .It Ic help Print out verbose usage information. .El Modified: stable/10/sbin/camcontrol/camcontrol.c ============================================================================== --- stable/10/sbin/camcontrol/camcontrol.c Thu Aug 27 13:08:45 2015 (r287202) +++ stable/10/sbin/camcontrol/camcontrol.c Thu Aug 27 13:17:05 2015 (r287203) @@ -99,7 +99,8 @@ typedef enum { CAM_CMD_PERSIST = 0x00000020, CAM_CMD_APM = 0x00000021, CAM_CMD_AAM = 0x00000022, - CAM_CMD_ATTRIB = 0x00000023 + CAM_CMD_ATTRIB = 0x00000023, + CAM_CMD_OPCODES = 0x00000024 } cam_cmdmask; typedef enum { @@ -221,11 +222,12 @@ static struct camcontrol_opts option_tab {"sleep", CAM_CMD_SLEEP, CAM_ARG_NONE, ""}, {"apm", CAM_CMD_APM, CAM_ARG_NONE, "l:"}, {"aam", CAM_CMD_AAM, CAM_ARG_NONE, "l:"}, - {"fwdownload", CAM_CMD_DOWNLOAD_FW, CAM_ARG_NONE, "f:ys"}, + {"fwdownload", CAM_CMD_DOWNLOAD_FW, CAM_ARG_NONE, "f:qsy"}, {"security", CAM_CMD_SECURITY, CAM_ARG_NONE, "d:e:fh:k:l:qs:T:U:y"}, {"hpa", CAM_CMD_HPA, CAM_ARG_NONE, "Pflp:qs:U:y"}, {"persist", CAM_CMD_PERSIST, CAM_ARG_NONE, "ai:I:k:K:o:ps:ST:U"}, {"attrib", CAM_CMD_ATTRIB, CAM_ARG_NONE, "a:ce:F:p:r:s:T:w:V:"}, + {"opcodes", CAM_CMD_OPCODES, CAM_ARG_NONE, "No:s:T"}, #endif /* MINIMALISTIC */ {"help", CAM_CMD_USAGE, CAM_ARG_NONE, NULL}, {"-?", CAM_CMD_USAGE, CAM_ARG_NONE, NULL}, @@ -264,7 +266,6 @@ static int scsistart(struct cam_device * int retry_count, int timeout); static int scsiinquiry(struct cam_device *device, int retry_count, int timeout); static int scsiserial(struct cam_device *device, int retry_count, int timeout); -static int camxferrate(struct cam_device *device); #endif /* MINIMALISTIC */ static int parse_btl(char *tstr, path_id_t *bus, target_id_t *target, lun_id_t *lun, cam_argmask *arglst); @@ -319,6 +320,14 @@ static int atasecurity(struct cam_device int argc, char **argv, char *combinedopt); static int atahpa(struct cam_device *device, int retry_count, int timeout, int argc, char **argv, char *combinedopt); +static int scsiprintoneopcode(struct cam_device *device, int req_opcode, + int sa_set, int req_sa, uint8_t *buf, + uint32_t valid_len); +static int scsiprintopcodes(struct cam_device *device, int td_req, uint8_t *buf, + uint32_t valid_len); +static int scsiopcodes(struct cam_device *device, int argc, char **argv, + char *combinedopt, int retry_count, int timeout, + int verbose); #endif /* MINIMALISTIC */ #ifndef min @@ -1018,7 +1027,7 @@ scsiserial(struct cam_device *device, in return(0); } -static int +int camxferrate(struct cam_device *device) { struct ccb_pathinq cpi; @@ -2034,7 +2043,7 @@ atahpa_freeze_lock(struct cam_device *de } -static int +int ata_do_identify(struct cam_device *device, int retry_count, int timeout, union ccb *ccb, struct ata_params** ident_bufp) { @@ -4941,26 +4950,173 @@ get_cgd_bailout: return(retval); } -/* return the type of disk (really the command type) */ -static const char * -get_disk_type(struct cam_device *device) -{ - struct ccb_getdev cgd; - - (void) memset(&cgd, 0x0, sizeof(cgd)); - get_cgd(device, &cgd); - switch(cgd.protocol) { +/* + * Returns 1 if the device has the VPD page, 0 if it does not, and -1 on an + * error. + */ +int +dev_has_vpd_page(struct cam_device *dev, uint8_t page_id, int retry_count, + int timeout, int verbosemode) +{ + union ccb *ccb = NULL; + struct scsi_vpd_supported_page_list sup_pages; + int i; + int retval = 0; + + ccb = cam_getccb(dev); + if (ccb == NULL) { + warn("Unable to allocate CCB"); + retval = -1; + goto bailout; + } + + /* cam_getccb cleans up the header, caller has to zero the payload */ + bzero(&(&ccb->ccb_h)[1], + sizeof(struct ccb_scsiio) - sizeof(struct ccb_hdr)); + + bzero(&sup_pages, sizeof(sup_pages)); + + scsi_inquiry(&ccb->csio, + /*retries*/ retry_count, + /*cbfcnp*/ NULL, + /* tag_action */ MSG_SIMPLE_Q_TAG, + /* inq_buf */ (u_int8_t *)&sup_pages, + /* inq_len */ sizeof(sup_pages), + /* evpd */ 1, + /* page_code */ SVPD_SUPPORTED_PAGE_LIST, + /* sense_len */ SSD_FULL_SIZE, + /* timeout */ timeout ? timeout : 5000); + + /* Disable freezing the device queue */ + ccb->ccb_h.flags |= CAM_DEV_QFRZDIS; + + if (retry_count != 0) + ccb->ccb_h.flags |= CAM_PASS_ERR_RECOVER; + + if (cam_send_ccb(dev, ccb) < 0) { + cam_freeccb(ccb); + retval = -1; + goto bailout; + } + + if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { + if (verbosemode != 0) + cam_error_print(dev, ccb, CAM_ESF_ALL, + CAM_EPF_ALL, stderr); + retval = -1; + goto bailout; + } + + for (i = 0; i < sup_pages.length; i++) { + if (sup_pages.list[i] == page_id) { + retval = 1; + goto bailout; + } + } +bailout: + if (ccb != NULL) + cam_freeccb(ccb); + + return (retval); +} + +/* + * devtype is filled in with the type of device. + * Returns 0 for success, non-zero for failure. + */ +int +get_device_type(struct cam_device *dev, int retry_count, int timeout, + int verbosemode, camcontrol_devtype *devtype) +{ + struct ccb_getdev cgd; + int retval = 0; + + retval = get_cgd(dev, &cgd); + if (retval != 0) + goto bailout; + + switch (cgd.protocol) { case PROTO_SCSI: - return "scsi"; + break; case PROTO_ATA: case PROTO_ATAPI: case PROTO_SATAPM: - return "ata"; + *devtype = CC_DT_ATA; + goto bailout; + break; /*NOTREACHED*/ default: - return "unknown"; + *devtype = CC_DT_UNKNOWN; + goto bailout; + break; /*NOTREACHED*/ + } + + /* + * Check for the ATA Information VPD page (0x89). If this is an + * ATA device behind a SCSI to ATA translation layer, this VPD page + * should be present. + * + * If that VPD page isn't present, or we get an error back from the + * INQUIRY command, we'll just treat it as a normal SCSI device. + */ + retval = dev_has_vpd_page(dev, SVPD_ATA_INFORMATION, retry_count, + timeout, verbosemode); + if (retval == 1) + *devtype = CC_DT_ATA_BEHIND_SCSI; + else + *devtype = CC_DT_SCSI; + + retval = 0; + +bailout: + return (retval); +} + +void +build_ata_cmd(union ccb *ccb, uint32_t retry_count, uint32_t flags, + uint8_t tag_action, uint8_t protocol, uint8_t ata_flags, uint16_t features, + uint16_t sector_count, uint64_t lba, uint8_t command, uint8_t *data_ptr, + uint16_t dxfer_len, uint8_t sense_len, uint32_t timeout, + int is48bit, camcontrol_devtype devtype) +{ + if (devtype == CC_DT_ATA) { + cam_fill_ataio(&ccb->ataio, + /*retries*/ retry_count, + /*cbfcnp*/ NULL, + /*flags*/ flags, + /*tag_action*/ tag_action, + /*data_ptr*/ data_ptr, + /*dxfer_len*/ dxfer_len, + /*timeout*/ timeout); + if (is48bit || lba > ATA_MAX_28BIT_LBA) + ata_48bit_cmd(&ccb->ataio, command, features, lba, + sector_count); + else + ata_28bit_cmd(&ccb->ataio, command, features, lba, + sector_count); + } else { + if (is48bit || lba > ATA_MAX_28BIT_LBA) + protocol |= AP_EXTEND; + + scsi_ata_pass_16(&ccb->csio, + /*retries*/ retry_count, + /*cbfcnp*/ NULL, + /*flags*/ flags, + /*tag_action*/ tag_action, + /*protocol*/ protocol, + /*ata_flags*/ ata_flags, + /*features*/ features, + /*sector_count*/ sector_count, + /*lba*/ lba, + /*command*/ command, + /*control*/ 0, + /*data_ptr*/ data_ptr, + /*dxfer_len*/ dxfer_len, + /*sense_len*/ sense_len, + /*timeout*/ timeout); } } + static void cpi_print(struct ccb_pathinq *cpi) { @@ -8051,6 +8207,461 @@ ataaxm(struct cam_device *device, int ar return (retval); } +int +scsigetopcodes(struct cam_device *device, int opcode_set, int opcode, + int show_sa_errors, int sa_set, int service_action, + int timeout_desc, int retry_count, int timeout, int verbosemode, + uint32_t *fill_len, uint8_t **data_ptr) +{ + union ccb *ccb = NULL; + uint8_t *buf = NULL; + uint32_t alloc_len = 0, num_opcodes; + uint32_t valid_len = 0; + uint32_t avail_len = 0; + struct scsi_report_supported_opcodes_all *all_hdr; + struct scsi_report_supported_opcodes_one *one; + int options = 0; + int retval = 0; + + /* + * Make it clear that we haven't yet allocated or filled anything. + */ + *fill_len = 0; + *data_ptr = NULL; + + ccb = cam_getccb(device); + if (ccb == NULL) { + warnx("couldn't allocate CCB"); + retval = 1; + goto bailout; + } + + /* cam_getccb cleans up the header, caller has to zero the payload */ + bzero(&(&ccb->ccb_h)[1], + sizeof(struct ccb_scsiio) - sizeof(struct ccb_hdr)); + + if (opcode_set != 0) { + options |= RSO_OPTIONS_OC; + num_opcodes = 1; + alloc_len = sizeof(*one) + CAM_MAX_CDBLEN; + } else { + num_opcodes = 256; + alloc_len = sizeof(*all_hdr) + (num_opcodes * + sizeof(struct scsi_report_supported_opcodes_descr)); + } + + if (timeout_desc != 0) { + options |= RSO_RCTD; + alloc_len += num_opcodes * + sizeof(struct scsi_report_supported_opcodes_timeout); + } + + if (sa_set != 0) { + options |= RSO_OPTIONS_OC_SA; + if (show_sa_errors != 0) + options &= ~RSO_OPTIONS_OC; + } + +retry_alloc: + if (buf != NULL) { + free(buf); + buf = NULL; + } + + buf = malloc(alloc_len); + if (buf == NULL) { + warn("Unable to allocate %u bytes", alloc_len); + retval = 1; + goto bailout; + } + bzero(buf, alloc_len); + + scsi_report_supported_opcodes(&ccb->csio, + /*retries*/ retry_count, + /*cbfcnp*/ NULL, + /*tag_action*/ MSG_SIMPLE_Q_TAG, + /*options*/ options, + /*req_opcode*/ opcode, + /*req_service_action*/ service_action, + /*data_ptr*/ buf, + /*dxfer_len*/ alloc_len, + /*sense_len*/ SSD_FULL_SIZE, + /*timeout*/ timeout ? timeout : 10000); + + ccb->ccb_h.flags |= CAM_DEV_QFRZDIS; + + if (retry_count != 0) + ccb->ccb_h.flags |= CAM_PASS_ERR_RECOVER; + + if (cam_send_ccb(device, ccb) < 0) { + perror("error sending REPORT SUPPORTED OPERATION CODES"); + retval = 1; + goto bailout; + } + + if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { + if (verbosemode != 0) + cam_error_print(device, ccb, CAM_ESF_ALL, + CAM_EPF_ALL, stderr); + + retval = 1; + goto bailout; + } + + valid_len = ccb->csio.dxfer_len - ccb->csio.resid; + + if (((options & RSO_OPTIONS_MASK) == RSO_OPTIONS_ALL) + && (valid_len >= sizeof(*all_hdr))) { + all_hdr = (struct scsi_report_supported_opcodes_all *)buf; + avail_len = scsi_4btoul(all_hdr->length) + sizeof(*all_hdr); + } else if (((options & RSO_OPTIONS_MASK) != RSO_OPTIONS_ALL) + && (valid_len >= sizeof(*one))) { + uint32_t cdb_length; + + one = (struct scsi_report_supported_opcodes_one *)buf; + cdb_length = scsi_2btoul(one->cdb_length); + avail_len = sizeof(*one) + cdb_length; + if (one->support & RSO_ONE_CTDP) { + struct scsi_report_supported_opcodes_timeout *td; + + td = (struct scsi_report_supported_opcodes_timeout *) + &buf[avail_len]; + if (valid_len >= (avail_len + sizeof(td->length))) { + avail_len += scsi_2btoul(td->length) + + sizeof(td->length); + } else { + avail_len += sizeof(*td); + } + } + } + + /* + * avail_len could be zero if we didn't get enough data back from + * thet target to determine + */ + if ((avail_len != 0) + && (avail_len > valid_len)) { + alloc_len = avail_len; + goto retry_alloc; + } + + *fill_len = valid_len; + *data_ptr = buf; +bailout: + if (retval != 0) + free(buf); + + cam_freeccb(ccb); + + return (retval); +} + +static int +scsiprintoneopcode(struct cam_device *device, int req_opcode, int sa_set, + int req_sa, uint8_t *buf, uint32_t valid_len) +{ + struct scsi_report_supported_opcodes_one *one; + struct scsi_report_supported_opcodes_timeout *td; + uint32_t cdb_len = 0, td_len = 0; + const char *op_desc = NULL; + unsigned int i; + int retval = 0; + + one = (struct scsi_report_supported_opcodes_one *)buf; + + /* + * If we don't have the full single opcode descriptor, no point in + * continuing. + */ + if (valid_len < __offsetof(struct scsi_report_supported_opcodes_one, + cdb_length)) { + warnx("Only %u bytes returned, not enough to verify support", + valid_len); + retval = 1; + goto bailout; + } + + op_desc = scsi_op_desc(req_opcode, &device->inq_data); + + printf("%s (0x%02x)", op_desc != NULL ? op_desc : "UNKNOWN", + req_opcode); + if (sa_set != 0) + printf(", SA 0x%x", req_sa); + printf(": "); + + switch (one->support & RSO_ONE_SUP_MASK) { + case RSO_ONE_SUP_UNAVAIL: + printf("No command support information currently available\n"); + break; + case RSO_ONE_SUP_NOT_SUP: + printf("Command not supported\n"); + retval = 1; + goto bailout; + break; /*NOTREACHED*/ + case RSO_ONE_SUP_AVAIL: + printf("Command is supported, complies with a SCSI standard\n"); + break; + case RSO_ONE_SUP_VENDOR: + printf("Command is supported, vendor-specific " + "implementation\n"); + break; + default: + printf("Unknown command support flags 0x%#x\n", + one->support & RSO_ONE_SUP_MASK); + break; + } + + /* + * If we don't have the CDB length, it isn't exactly an error, the + * command probably isn't supported. + */ + if (valid_len < __offsetof(struct scsi_report_supported_opcodes_one, + cdb_usage)) + goto bailout; + + cdb_len = scsi_2btoul(one->cdb_length); + + /* + * If our valid data doesn't include the full reported length, + * return. The caller should have detected this and adjusted his + * allocation length to get all of the available data. + */ + if (valid_len < sizeof(*one) + cdb_len) { + retval = 1; + goto bailout; + } + + /* + * If all we have is the opcode, there is no point in printing out + * the usage bitmap. + */ + if (cdb_len <= 1) { + retval = 1; + goto bailout; + } + + printf("CDB usage bitmap:"); + for (i = 0; i < cdb_len; i++) { + printf(" %02x", one->cdb_usage[i]); + } + printf("\n"); + + /* + * If we don't have a timeout descriptor, we're done. + */ + if ((one->support & RSO_ONE_CTDP) == 0) + goto bailout; + + /* + * If we don't have enough valid length to include the timeout + * descriptor length, we're done. + */ + if (valid_len < (sizeof(*one) + cdb_len + sizeof(td->length))) + goto bailout; + + td = (struct scsi_report_supported_opcodes_timeout *) + &buf[sizeof(*one) + cdb_len]; + td_len = scsi_2btoul(td->length); + td_len += sizeof(td->length); + + /* + * If we don't have the full timeout descriptor, we're done. + */ + if (td_len < sizeof(*td)) + goto bailout; + + /* + * If we don't have enough valid length to contain the full timeout + * descriptor, we're done. + */ + if (valid_len < (sizeof(*one) + cdb_len + td_len)) + goto bailout; + + printf("Timeout information:\n"); + printf("Command-specific: 0x%02x\n", td->cmd_specific); + printf("Nominal timeout: %u seconds\n", + scsi_4btoul(td->nominal_time)); + printf("Recommended timeout: %u seconds\n", + scsi_4btoul(td->recommended_time)); + +bailout: + return (retval); +} + +static int +scsiprintopcodes(struct cam_device *device, int td_req, uint8_t *buf, + uint32_t valid_len) +{ + struct scsi_report_supported_opcodes_all *hdr; + struct scsi_report_supported_opcodes_descr *desc; + uint32_t avail_len = 0, used_len = 0; + uint8_t *cur_ptr; + int retval = 0; + + if (valid_len < sizeof(*hdr)) { + warnx("%s: not enough returned data (%u bytes) opcode list", + __func__, valid_len); + retval = 1; + goto bailout; + } + hdr = (struct scsi_report_supported_opcodes_all *)buf; + avail_len = scsi_4btoul(hdr->length); + avail_len += sizeof(hdr->length); + /* + * Take the lesser of the amount of data the drive claims is + * available, and the amount of data the HBA says was returned. + */ + avail_len = MIN(avail_len, valid_len); + + used_len = sizeof(hdr->length); + + printf("%-6s %4s %8s ", + "Opcode", "SA", "CDB len" ); + + if (td_req != 0) + printf("%5s %6s %6s ", "CS", "Nom", "Rec"); + printf(" Description\n"); + + while ((avail_len - used_len) > sizeof(*desc)) { + struct scsi_report_supported_opcodes_timeout *td; + uint32_t td_len; + const char *op_desc = NULL; + + cur_ptr = &buf[used_len]; + desc = (struct scsi_report_supported_opcodes_descr *)cur_ptr; + + op_desc = scsi_op_desc(desc->opcode, &device->inq_data); + if (op_desc == NULL) + op_desc = "UNKNOWN"; + + printf("0x%02x %#4x %8u ", desc->opcode, + scsi_2btoul(desc->service_action), + scsi_2btoul(desc->cdb_length)); + + used_len += sizeof(*desc); + + if ((desc->flags & RSO_CTDP) == 0) { + printf(" %s\n", op_desc); + continue; + } + + /* + * If we don't have enough space to fit a timeout + * descriptor, then we're done. + */ + if (avail_len - used_len < sizeof(*td)) { + used_len = avail_len; + printf(" %s\n", op_desc); + continue; + } + cur_ptr = &buf[used_len]; + td = (struct scsi_report_supported_opcodes_timeout *)cur_ptr; + td_len = scsi_2btoul(td->length); + td_len += sizeof(td->length); + + used_len += td_len; + /* + * If the given timeout descriptor length is less than what + * we understand, skip it. + */ + if (td_len < sizeof(*td)) { + printf(" %s\n", op_desc); + continue; + } + + printf(" 0x%02x %6u %6u %s\n", td->cmd_specific, + scsi_4btoul(td->nominal_time), + scsi_4btoul(td->recommended_time), op_desc); + } +bailout: + return (retval); +} + +static int +scsiopcodes(struct cam_device *device, int argc, char **argv, + char *combinedopt, int retry_count, int timeout, int verbosemode) +{ + int c; + uint32_t opcode = 0, service_action = 0; + int td_set = 0, opcode_set = 0, sa_set = 0; + int show_sa_errors = 1; + uint32_t valid_len = 0; + uint8_t *buf = NULL; + char *endptr; + int retval = 0; + + while ((c = getopt(argc, argv, combinedopt)) != -1) { + switch (c) { + case 'N': + show_sa_errors = 0; + break; + case 'o': + opcode = strtoul(optarg, &endptr, 0); + if (*endptr != '\0') { + warnx("Invalid opcode \"%s\", must be a number", + optarg); + retval = 1; + goto bailout; + } + if (opcode > 0xff) { + warnx("Invalid opcode 0x%#x, must be between" + "0 and 0xff inclusive", opcode); + retval = 1; + goto bailout; + } + opcode_set = 1; + break; + case 's': + service_action = strtoul(optarg, &endptr, 0); + if (*endptr != '\0') { + warnx("Invalid service action \"%s\", must " + "be a number", optarg); + retval = 1; + goto bailout; + } + if (service_action > 0xffff) { + warnx("Invalid service action 0x%#x, must " + "be between 0 and 0xffff inclusive", + service_action); + retval = 1; + } + sa_set = 1; + break; + case 'T': + td_set = 1; + break; + default: + break; + } + } + + if ((sa_set != 0) + && (opcode_set == 0)) { + warnx("You must specify an opcode with -o if a service " + "action is given"); + retval = 1; + goto bailout; + } + retval = scsigetopcodes(device, opcode_set, opcode, show_sa_errors, + sa_set, service_action, td_set, retry_count, + timeout, verbosemode, &valid_len, &buf); + if (retval != 0) + goto bailout; + + if ((opcode_set != 0) + || (sa_set != 0)) { + retval = scsiprintoneopcode(device, opcode, sa_set, + service_action, buf, valid_len); + } else { + retval = scsiprintopcodes(device, td_set, buf, valid_len); + } + +bailout: + free(buf); + + return (retval); +} + #endif /* MINIMALISTIC */ void @@ -8110,7 +8721,8 @@ usage(int printlong) " camcontrol sleep [dev_id][generic args]\n" " camcontrol apm [dev_id][generic args][-l level]\n" " camcontrol aam [dev_id][generic args][-l level]\n" -" camcontrol fwdownload [dev_id][generic args] <-f fw_image> [-y][-s]\n" +" camcontrol fwdownload [dev_id][generic args] <-f fw_image> [-q]\n" +" [-s][-y]\n" " camcontrol security [dev_id][generic args]\n" " <-d pwd | -e pwd | -f | -h pwd | -k pwd>\n" " [-l ] [-q] [-s pwd] [-T timeout]\n" @@ -8123,6 +8735,8 @@ usage(int printlong) " camcontrol attrib [dev_id][generic args] <-r action|-w attr>\n" " [-a attr_num][-c][-e elem][-F form1,form1]\n" " [-p part][-s start][-T type][-V vol]\n" +" camcontrol opcodes [dev_id][generic args][-o opcode][-s SA]\n" +" [-N][-T]\n" #endif /* MINIMALISTIC */ " camcontrol help\n"); if (!printlong) @@ -8163,6 +8777,7 @@ usage(int printlong) "security report or send ATA security commands to the named device\n" "persist send the SCSI PERSISTENT RESERVE IN or OUT commands\n" "attrib send the SCSI READ or WRITE ATTRIBUTE commands\n" +"opcodes send the SCSI REPORT SUPPORTED OPCODES command\n" "help this message\n" "Device Identifiers:\n" "bus:target specify the bus and target, lun defaults to 0\n" @@ -8267,9 +8882,10 @@ usage(int printlong) "-t number of seconds before respective state.\n" "fwdownload arguments:\n" "-f fw_image path to firmware image file\n" -"-y don't ask any questions\n" +"-q don't print informational messages, only errors\n" "-s run in simulation mode\n" "-v print info for every firmware segment sent to device\n" +"-y don't ask any questions\n" "security arguments:\n" "-d pwd disable security using the given password for the selected\n" " user\n" @@ -8327,6 +8943,11 @@ usage(int printlong) "-s start_attr request attributes starting at the given number\n" "-T elem_type specify the element type (used with -e)\n" "-V logical_vol specify the logical volume ID\n" *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable@freebsd.org Thu Aug 27 14:07:29 2015 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D4B149C308A; Thu, 27 Aug 2015 14:07:29 +0000 (UTC) (envelope-from loos@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C54A81F2B; Thu, 27 Aug 2015 14:07:29 +0000 (UTC) (envelope-from loos@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7RE7TJk074802; Thu, 27 Aug 2015 14:07:29 GMT (envelope-from loos@FreeBSD.org) Received: (from loos@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7RE7T3T074801; Thu, 27 Aug 2015 14:07:29 GMT (envelope-from loos@FreeBSD.org) Message-Id: <201508271407.t7RE7T3T074801@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: loos set sender to loos@FreeBSD.org using -f From: Luiz Otavio O Souza Date: Thu, 27 Aug 2015 14:07:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r287207 - stable/10/sys/netpfil/pf X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Aug 2015 14:07:29 -0000 Author: loos Date: Thu Aug 27 14:07:28 2015 New Revision: 287207 URL: https://svnweb.freebsd.org/changeset/base/287207 Log: MFC r287119: Reapply r196551 which was accidentally reverted by r223637 (update to OpenBSD pf 4.5). Fix argument ordering to memcpy as well as the size of the copy in the (theoretical) case that pfi_buffer_cnt should be greater than ~_max. This fix the failure when you hit the self table size and force it to be resized. Sponsored by: Rubicon Communications (Netgate) Modified: stable/10/sys/netpfil/pf/pf_if.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/netpfil/pf/pf_if.c ============================================================================== --- stable/10/sys/netpfil/pf/pf_if.c Thu Aug 27 14:00:23 2015 (r287206) +++ stable/10/sys/netpfil/pf/pf_if.c Thu Aug 27 14:07:28 2015 (r287207) @@ -578,7 +578,7 @@ pfi_address_add(struct sockaddr *sa, int __func__, V_pfi_buffer_cnt, PFI_BUFFER_MAX); return; } - memcpy(V_pfi_buffer, p, V_pfi_buffer_cnt * sizeof(*V_pfi_buffer)); + memcpy(p, V_pfi_buffer, V_pfi_buffer_max * sizeof(*V_pfi_buffer)); /* no need to zero buffer */ free(V_pfi_buffer, PFI_MTYPE); V_pfi_buffer = p; From owner-svn-src-stable@freebsd.org Thu Aug 27 15:22:00 2015 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F1EF59C4AAF; Thu, 27 Aug 2015 15:22:00 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C9772A2C; Thu, 27 Aug 2015 15:22:00 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7RFM0i3007303; Thu, 27 Aug 2015 15:22:00 GMT (envelope-from gjb@FreeBSD.org) Received: (from gjb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7RFM0vW007301; Thu, 27 Aug 2015 15:22:00 GMT (envelope-from gjb@FreeBSD.org) Message-Id: <201508271522.t7RFM0vW007301@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gjb set sender to gjb@FreeBSD.org using -f From: Glen Barber Date: Thu, 27 Aug 2015 15:22:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r287210 - in stable: 10/release/doc/share/xml 9/release/doc/share/xml X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Aug 2015 15:22:01 -0000 Author: gjb Date: Thu Aug 27 15:21:58 2015 New Revision: 287210 URL: https://svnweb.freebsd.org/changeset/base/287210 Log: Document SA-15:21, SA-15:22, EN-15:15. Sponsored by: The FreeBSD Foundation Modified: stable/9/release/doc/share/xml/errata.xml stable/9/release/doc/share/xml/security.xml Changes in other areas also in this revision: Modified: stable/10/release/doc/share/xml/errata.xml stable/10/release/doc/share/xml/security.xml Modified: stable/9/release/doc/share/xml/errata.xml ============================================================================== --- stable/9/release/doc/share/xml/errata.xml Thu Aug 27 15:16:41 2015 (r287209) +++ stable/9/release/doc/share/xml/errata.xml Thu Aug 27 15:21:58 2015 (r287210) @@ -100,6 +100,14 @@ 30 June 2015 Fix inconsistency between locale and rune locale states + + + FreeBSD-EN-15:15.pkg + 25 August 2015 + Insufficient check of supported &man.pkg.7; + signature methods. + Modified: stable/9/release/doc/share/xml/security.xml ============================================================================== --- stable/9/release/doc/share/xml/security.xml Thu Aug 27 15:16:41 2015 (r287209) +++ stable/9/release/doc/share/xml/security.xml Thu Aug 27 15:21:58 2015 (r287210) @@ -209,6 +209,21 @@ Fix multiple integer overflows in &man.libbsdxml.3;. + + + FreeBSD-SA-15:21.amd64 + 25 August 2015 + Fix local privilege escalation in IRET + handler. + + + + FreeBSD-SA-15:22.openssh + 25 August 2015 + Multiple vulnerabilities + From owner-svn-src-stable@freebsd.org Thu Aug 27 15:22:00 2015 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3ADA09C4AAA; Thu, 27 Aug 2015 15:22:00 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0F4D1A2B; Thu, 27 Aug 2015 15:22:00 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7RFLxJv007271; Thu, 27 Aug 2015 15:21:59 GMT (envelope-from gjb@FreeBSD.org) Received: (from gjb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7RFLxmG007269; Thu, 27 Aug 2015 15:21:59 GMT (envelope-from gjb@FreeBSD.org) Message-Id: <201508271521.t7RFLxmG007269@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gjb set sender to gjb@FreeBSD.org using -f From: Glen Barber Date: Thu, 27 Aug 2015 15:21:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r287210 - in stable: 10/release/doc/share/xml 9/release/doc/share/xml X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Aug 2015 15:22:00 -0000 Author: gjb Date: Thu Aug 27 15:21:58 2015 New Revision: 287210 URL: https://svnweb.freebsd.org/changeset/base/287210 Log: Document SA-15:21, SA-15:22, EN-15:15. Sponsored by: The FreeBSD Foundation Modified: stable/10/release/doc/share/xml/errata.xml stable/10/release/doc/share/xml/security.xml Changes in other areas also in this revision: Modified: stable/9/release/doc/share/xml/errata.xml stable/9/release/doc/share/xml/security.xml Modified: stable/10/release/doc/share/xml/errata.xml ============================================================================== --- stable/10/release/doc/share/xml/errata.xml Thu Aug 27 15:16:41 2015 (r287209) +++ stable/10/release/doc/share/xml/errata.xml Thu Aug 27 15:21:58 2015 (r287210) @@ -41,6 +41,14 @@ Allow size argument to &man.vidcontrol.1; for &man.syscons.4;. + + + FreeBSD-EN-15:15.pkg + 25 August 2015 + Insufficient check of supported &man.pkg.7; + signature methods. + Modified: stable/10/release/doc/share/xml/security.xml ============================================================================== --- stable/10/release/doc/share/xml/security.xml Thu Aug 27 15:16:41 2015 (r287209) +++ stable/10/release/doc/share/xml/security.xml Thu Aug 27 15:21:58 2015 (r287210) @@ -25,6 +25,13 @@ Fix multiple integer overflows in &man.libbsdxml.3;. + + + FreeBSD-SA-15:22.openssh + 25 August 2015 + Multiple vulnerabilities + From owner-svn-src-stable@freebsd.org Thu Aug 27 16:36:40 2015 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 01DE29C4634; Thu, 27 Aug 2015 16:36:40 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E4F86CD1; Thu, 27 Aug 2015 16:36:39 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7RGadR0035993; Thu, 27 Aug 2015 16:36:39 GMT (envelope-from bdrewery@FreeBSD.org) Received: (from bdrewery@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7RGadDm035992; Thu, 27 Aug 2015 16:36:39 GMT (envelope-from bdrewery@FreeBSD.org) Message-Id: <201508271636.t7RGadDm035992@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bdrewery set sender to bdrewery@FreeBSD.org using -f From: Bryan Drewery Date: Thu, 27 Aug 2015 16:36:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r287215 - stable/10/share/man/man9 X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Aug 2015 16:36:40 -0000 Author: bdrewery Date: Thu Aug 27 16:36:39 2015 New Revision: 287215 URL: https://svnweb.freebsd.org/changeset/base/287215 Log: MFC r286966: Add link for rw_unlock(9) to rwlock(9). Modified: stable/10/share/man/man9/Makefile Directory Properties: stable/10/ (props changed) Modified: stable/10/share/man/man9/Makefile ============================================================================== --- stable/10/share/man/man9/Makefile Thu Aug 27 16:27:51 2015 (r287214) +++ stable/10/share/man/man9/Makefile Thu Aug 27 16:36:39 2015 (r287215) @@ -1127,6 +1127,7 @@ MLINKS+=rwlock.9 rw_assert.9 \ rwlock.9 rw_initialized.9 \ rwlock.9 rw_rlock.9 \ rwlock.9 rw_runlock.9 \ + rwlock.9 rw_unlock.9 \ rwlock.9 rw_sleep.9 \ rwlock.9 RW_SYSINIT.9 \ rwlock.9 rw_try_rlock.9 \ From owner-svn-src-stable@freebsd.org Thu Aug 27 21:52:11 2015 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EE8D59C3687; Thu, 27 Aug 2015 21:52:10 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D2970EA8; Thu, 27 Aug 2015 21:52:10 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7RLqAUr068285; Thu, 27 Aug 2015 21:52:10 GMT (envelope-from delphij@FreeBSD.org) Received: (from delphij@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7RLqA8K068282; Thu, 27 Aug 2015 21:52:10 GMT (envelope-from delphij@FreeBSD.org) Message-Id: <201508272152.t7RLqA8K068282@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: delphij set sender to delphij@FreeBSD.org using -f From: Xin LI Date: Thu, 27 Aug 2015 21:52:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r287223 - stable/10/usr.bin/patch X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Aug 2015 21:52:11 -0000 Author: delphij Date: Thu Aug 27 21:52:09 2015 New Revision: 287223 URL: https://svnweb.freebsd.org/changeset/base/287223 Log: MFC r281800 (pfg): patch(1): small include changes. Mostly to match OpenBSD, no functional change. MFC r286601 + 286617: use posix_spawn(3) instead of fork() and exec() manually as suggested by jmg@. Modified: stable/10/usr.bin/patch/inp.c stable/10/usr.bin/patch/pch.c stable/10/usr.bin/patch/util.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.bin/patch/inp.c ============================================================================== --- stable/10/usr.bin/patch/inp.c Thu Aug 27 21:27:47 2015 (r287222) +++ stable/10/usr.bin/patch/inp.c Thu Aug 27 21:52:09 2015 (r287223) @@ -36,8 +36,10 @@ #include #include #include -#include +#include +#include #include +#include #include #include #include @@ -134,14 +136,13 @@ reallocate_lines(size_t *lines_allocated static bool plan_a(const char *filename) { - int ifd, statfailed, devnull, pstat; + int ifd, statfailed, pstat; char *p, *s, lbuf[INITLINELEN]; struct stat filestat; ptrdiff_t sz; size_t i; size_t iline, lines_allocated; pid_t pid; - char *argp[4] = {NULL}; #ifdef DEBUGGING if (debug & 8) @@ -178,7 +179,9 @@ plan_a(const char *filename) ((filestat.st_mode & 0022) == 0 && filestat.st_uid != getuid())) { char *filebase, *filedir; struct stat cstat; - char *tmp_filename1, *tmp_filename2; + char *tmp_filename1, *tmp_filename2; + char *argp[4] = { NULL }; + posix_spawn_file_actions_t file_actions; tmp_filename1 = strdup(filename); tmp_filename2 = strdup(filename); @@ -188,6 +191,8 @@ plan_a(const char *filename) filebase = basename(tmp_filename1); filedir = dirname(tmp_filename2); + memset(argp, 0, sizeof(argp)); + #define try(f, a1, a2, a3) \ (snprintf(lbuf, sizeof(lbuf), f, a1, a2, a3), stat(lbuf, &cstat) == 0) @@ -213,50 +218,39 @@ plan_a(const char *filename) say("Comparing file %s to default " "RCS version...\n", filename); - switch (pid = fork()) { - case -1: - fatal("can't fork: %s\n", - strerror(errno)); - case 0: - devnull = open("/dev/null", O_RDONLY); - if (devnull == -1) { - fatal("can't open /dev/null: %s", - strerror(errno)); - } - (void)dup2(devnull, STDOUT_FILENO); - argp[0] = strdup(RCSDIFF); - argp[1] = strdup(filename); - execv(RCSDIFF, argp); - exit(127); - } - pid = waitpid(pid, &pstat, 0); - if (pid == -1 || WEXITSTATUS(pstat) != 0) { - fatal("can't check out file %s: " - "differs from default RCS version\n", - filename); - } + argp[0] = __DECONST(char *, RCSDIFF); + argp[1] = __DECONST(char *, filename); + posix_spawn_file_actions_init(&file_actions); + posix_spawn_file_actions_addopen(&file_actions, + STDOUT_FILENO, _PATH_DEVNULL, O_WRONLY, 0); + if (posix_spawn(&pid, RCSDIFF, &file_actions, + NULL, argp, NULL) == 0) { + pid = waitpid(pid, &pstat, 0); + if (pid == -1 || WEXITSTATUS(pstat) != 0) + fatal("can't check out file %s: " + "differs from default RCS version\n", + filename); + } else + fatal("posix_spawn: %s\n", strerror(errno)); + posix_spawn_file_actions_destroy(&file_actions); } if (verbose) say("Checking out file %s from RCS...\n", filename); - switch (pid = fork()) { - case -1: - fatal("can't fork: %s\n", strerror(errno)); - case 0: - argp[0] = strdup(CHECKOUT); - argp[1] = strdup("-l"); - argp[2] = strdup(filename); - execv(CHECKOUT, argp); - exit(127); - } - pid = waitpid(pid, &pstat, 0); - if (pid == -1 || WEXITSTATUS(pstat) != 0 || - stat(filename, &filestat)) { - fatal("can't check out file %s from RCS\n", - filename); - } + argp[0] = __DECONST(char *, CHECKOUT); + argp[1] = __DECONST(char *, "-l"); + argp[2] = __DECONST(char *, filename); + if (posix_spawn(&pid, CHECKOUT, NULL, NULL, argp, + NULL) == 0) { + pid = waitpid(pid, &pstat, 0); + if (pid == -1 || WEXITSTATUS(pstat) != 0 || + stat(filename, &filestat)) + fatal("can't check out file %s from RCS\n", + filename); + } else + fatal("posix_spawn: %s\n", strerror(errno)); } else if (statfailed) { fatal("can't find %s\n", filename); } Modified: stable/10/usr.bin/patch/pch.c ============================================================================== --- stable/10/usr.bin/patch/pch.c Thu Aug 27 21:27:47 2015 (r287222) +++ stable/10/usr.bin/patch/pch.c Thu Aug 27 21:52:09 2015 (r287223) @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include Modified: stable/10/usr.bin/patch/util.c ============================================================================== --- stable/10/usr.bin/patch/util.c Thu Aug 27 21:27:47 2015 (r287222) +++ stable/10/usr.bin/patch/util.c Thu Aug 27 21:52:09 2015 (r287223) @@ -27,13 +27,13 @@ * $FreeBSD$ */ -#include #include #include #include #include #include +#include #include #include #include @@ -96,7 +96,7 @@ int backup_file(const char *orig) { struct stat filestat; - char bakname[MAXPATHLEN], *s, *simplename; + char bakname[PATH_MAX], *s, *simplename; dev_t orig_device; ino_t orig_inode; @@ -406,7 +406,7 @@ fetchname(const char *at, bool *exists, char * checked_in(char *file) { - char *filebase, *filedir, tmpbuf[MAXPATHLEN]; + char *filebase, *filedir, tmpbuf[PATH_MAX]; struct stat filestat; filebase = basename(file); From owner-svn-src-stable@freebsd.org Thu Aug 27 23:46:12 2015 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4A5439C3B66; Thu, 27 Aug 2015 23:46:12 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1C30F2BA; Thu, 27 Aug 2015 23:46:12 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7RNkBZD013877; Thu, 27 Aug 2015 23:46:11 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7RNkB44013876; Thu, 27 Aug 2015 23:46:11 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201508272346.t7RNkB44013876@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Thu, 27 Aug 2015 23:46:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r287226 - stable/10/cddl/contrib/opensolaris/lib/libdtrace/common X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Aug 2015 23:46:12 -0000 Author: markj Date: Thu Aug 27 23:46:11 2015 New Revision: 287226 URL: https://svnweb.freebsd.org/changeset/base/287226 Log: MFC r286169: Perform bounds checking when constructing a format string. PR: 201657 Modified: stable/10/cddl/contrib/opensolaris/lib/libdtrace/common/dt_printf.c Directory Properties: stable/10/ (props changed) Modified: stable/10/cddl/contrib/opensolaris/lib/libdtrace/common/dt_printf.c ============================================================================== --- stable/10/cddl/contrib/opensolaris/lib/libdtrace/common/dt_printf.c Thu Aug 27 23:33:38 2015 (r287225) +++ stable/10/cddl/contrib/opensolaris/lib/libdtrace/common/dt_printf.c Thu Aug 27 23:46:11 2015 (r287226) @@ -1348,6 +1348,7 @@ dt_printf_format(dtrace_hdl_t *dtp, FILE dtrace_aggdesc_t *agg; caddr_t lim = (caddr_t)buf + len, limit; char format[64] = "%"; + size_t ret; int i, aggrec, curagg = -1; uint64_t normal; @@ -1379,7 +1380,9 @@ dt_printf_format(dtrace_hdl_t *dtp, FILE int prec = pfd->pfd_prec; int rval; + const char *start; char *f = format + 1; /* skip initial '%' */ + size_t fmtsz = sizeof(format) - 1; const dtrace_recdesc_t *rec; dt_pfprint_f *func; caddr_t addr; @@ -1536,6 +1539,7 @@ dt_printf_format(dtrace_hdl_t *dtp, FILE break; } + start = f; if (pfd->pfd_flags & DT_PFCONV_ALT) *f++ = '#'; if (pfd->pfd_flags & DT_PFCONV_ZPAD) @@ -1548,6 +1552,7 @@ dt_printf_format(dtrace_hdl_t *dtp, FILE *f++ = '\''; if (pfd->pfd_flags & DT_PFCONV_SPACE) *f++ = ' '; + fmtsz -= f - start; /* * If we're printing a stack and DT_PFCONV_LEFT is set, we @@ -1558,13 +1563,20 @@ dt_printf_format(dtrace_hdl_t *dtp, FILE if (func == pfprint_stack && (pfd->pfd_flags & DT_PFCONV_LEFT)) width = 0; - if (width != 0) - f += snprintf(f, sizeof (format), "%d", ABS(width)); + if (width != 0) { + ret = snprintf(f, fmtsz, "%d", ABS(width)); + f += ret; + fmtsz = MAX(0, fmtsz - ret); + } - if (prec > 0) - f += snprintf(f, sizeof (format), ".%d", prec); + if (prec > 0) { + ret = snprintf(f, fmtsz, ".%d", prec); + f += ret; + fmtsz = MAX(0, fmtsz - ret); + } - (void) strcpy(f, pfd->pfd_fmt); + if (strlcpy(f, pfd->pfd_fmt, fmtsz) >= fmtsz) + return (dt_set_errno(dtp, EDT_COMPILER)); pfd->pfd_rec = rec; if (func(dtp, fp, format, pfd, addr, size, normal) < 0) From owner-svn-src-stable@freebsd.org Thu Aug 27 23:46:46 2015 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 36D279C3BCA; Thu, 27 Aug 2015 23:46:46 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0DF2B639; Thu, 27 Aug 2015 23:46:46 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7RNkjYt014007; Thu, 27 Aug 2015 23:46:45 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7RNkj4A014004; Thu, 27 Aug 2015 23:46:45 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201508272346.t7RNkj4A014004@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Thu, 27 Aug 2015 23:46:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r287228 - stable/9/cddl/contrib/opensolaris/lib/libdtrace/common X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Aug 2015 23:46:46 -0000 Author: markj Date: Thu Aug 27 23:46:45 2015 New Revision: 287228 URL: https://svnweb.freebsd.org/changeset/base/287228 Log: MFC r286169: Perform bounds checking when constructing a format string. PR: 201657 Modified: stable/9/cddl/contrib/opensolaris/lib/libdtrace/common/dt_printf.c Directory Properties: stable/9/cddl/contrib/opensolaris/ (props changed) stable/9/cddl/contrib/opensolaris/lib/libdtrace/common/ (props changed) Modified: stable/9/cddl/contrib/opensolaris/lib/libdtrace/common/dt_printf.c ============================================================================== --- stable/9/cddl/contrib/opensolaris/lib/libdtrace/common/dt_printf.c Thu Aug 27 23:46:42 2015 (r287227) +++ stable/9/cddl/contrib/opensolaris/lib/libdtrace/common/dt_printf.c Thu Aug 27 23:46:45 2015 (r287228) @@ -1348,6 +1348,7 @@ dt_printf_format(dtrace_hdl_t *dtp, FILE dtrace_aggdesc_t *agg; caddr_t lim = (caddr_t)buf + len, limit; char format[64] = "%"; + size_t ret; int i, aggrec, curagg = -1; uint64_t normal; @@ -1379,7 +1380,9 @@ dt_printf_format(dtrace_hdl_t *dtp, FILE int prec = pfd->pfd_prec; int rval; + const char *start; char *f = format + 1; /* skip initial '%' */ + size_t fmtsz = sizeof(format) - 1; const dtrace_recdesc_t *rec; dt_pfprint_f *func; caddr_t addr; @@ -1536,6 +1539,7 @@ dt_printf_format(dtrace_hdl_t *dtp, FILE break; } + start = f; if (pfd->pfd_flags & DT_PFCONV_ALT) *f++ = '#'; if (pfd->pfd_flags & DT_PFCONV_ZPAD) @@ -1548,6 +1552,7 @@ dt_printf_format(dtrace_hdl_t *dtp, FILE *f++ = '\''; if (pfd->pfd_flags & DT_PFCONV_SPACE) *f++ = ' '; + fmtsz -= f - start; /* * If we're printing a stack and DT_PFCONV_LEFT is set, we @@ -1558,13 +1563,20 @@ dt_printf_format(dtrace_hdl_t *dtp, FILE if (func == pfprint_stack && (pfd->pfd_flags & DT_PFCONV_LEFT)) width = 0; - if (width != 0) - f += snprintf(f, sizeof (format), "%d", ABS(width)); + if (width != 0) { + ret = snprintf(f, fmtsz, "%d", ABS(width)); + f += ret; + fmtsz = MAX(0, fmtsz - ret); + } - if (prec > 0) - f += snprintf(f, sizeof (format), ".%d", prec); + if (prec > 0) { + ret = snprintf(f, fmtsz, ".%d", prec); + f += ret; + fmtsz = MAX(0, fmtsz - ret); + } - (void) strcpy(f, pfd->pfd_fmt); + if (strlcpy(f, pfd->pfd_fmt, fmtsz) >= fmtsz) + return (dt_set_errno(dtp, EDT_COMPILER)); pfd->pfd_rec = rec; if (func(dtp, fp, format, pfd, addr, size, normal) < 0) From owner-svn-src-stable@freebsd.org Thu Aug 27 23:52:54 2015 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7480D9C3F55; Thu, 27 Aug 2015 23:52:54 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6198ED4B; Thu, 27 Aug 2015 23:52:54 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7RNqsqU017925; Thu, 27 Aug 2015 23:52:54 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7RNqshh017924; Thu, 27 Aug 2015 23:52:54 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201508272352.t7RNqshh017924@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Thu, 27 Aug 2015 23:52:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r287229 - stable/10/sys/ofed/include/linux X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Aug 2015 23:52:54 -0000 Author: markj Date: Thu Aug 27 23:52:53 2015 New Revision: 287229 URL: https://svnweb.freebsd.org/changeset/base/287229 Log: MFC r286418: ipv4_is_zeronet() and ipv4_is_loopback() expect an address in network order, but IN_ZERONET and IN_LOOPBACK expect it in host order. Modified: stable/10/sys/ofed/include/linux/in.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/ofed/include/linux/in.h ============================================================================== --- stable/10/sys/ofed/include/linux/in.h Thu Aug 27 23:46:45 2015 (r287228) +++ stable/10/sys/ofed/include/linux/in.h Thu Aug 27 23:52:53 2015 (r287229) @@ -37,7 +37,7 @@ #include #include -#define ipv4_is_zeronet IN_ZERONET -#define ipv4_is_loopback IN_LOOPBACK +#define ipv4_is_zeronet(be) IN_ZERONET(ntohl(be)) +#define ipv4_is_loopback(be) IN_LOOPBACK(ntohl(be)) #endif /* _LINUX_IN_H_ */ From owner-svn-src-stable@freebsd.org Thu Aug 27 23:55:47 2015 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 06DB79C4039; Thu, 27 Aug 2015 23:55:47 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E67DFEA4; Thu, 27 Aug 2015 23:55:46 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7RNtkt1018122; Thu, 27 Aug 2015 23:55:46 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7RNtkRZ018121; Thu, 27 Aug 2015 23:55:46 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201508272355.t7RNtkRZ018121@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Thu, 27 Aug 2015 23:55:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r287230 - stable/10/sys/cddl/contrib/opensolaris/uts/common/dtrace X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Aug 2015 23:55:47 -0000 Author: markj Date: Thu Aug 27 23:55:46 2015 New Revision: 287230 URL: https://svnweb.freebsd.org/changeset/base/287230 Log: MFC r286167: Avoid dereferencing curthread->td_proc->p_cred in DTrace probe context. Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c Thu Aug 27 23:52:53 2015 (r287229) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c Thu Aug 27 23:55:46 2015 (r287230) @@ -3510,7 +3510,6 @@ dtrace_dif_variable(dtrace_mstate_t *mst */ if (DTRACE_ANCHORED(mstate->dtms_probe) && CPU_ON_INTR(CPU)) return ((uint64_t)p0.p_cred->cr_uid); -#endif /* * It is always safe to dereference one's own t_procp pointer: @@ -3522,6 +3521,9 @@ dtrace_dif_variable(dtrace_mstate_t *mst * credential, since this is never NULL after process birth. */ return ((uint64_t)curthread->t_procp->p_cred->cr_uid); +#else + return ((uint64_t)curthread->td_ucred->cr_uid); +#endif case DIF_VAR_GID: if (!dtrace_priv_proc(state)) @@ -3533,7 +3535,6 @@ dtrace_dif_variable(dtrace_mstate_t *mst */ if (DTRACE_ANCHORED(mstate->dtms_probe) && CPU_ON_INTR(CPU)) return ((uint64_t)p0.p_cred->cr_gid); -#endif /* * It is always safe to dereference one's own t_procp pointer: @@ -3545,6 +3546,9 @@ dtrace_dif_variable(dtrace_mstate_t *mst * credential, since this is never NULL after process birth. */ return ((uint64_t)curthread->t_procp->p_cred->cr_gid); +#else + return ((uint64_t)curthread->td_ucred->cr_gid); +#endif case DIF_VAR_ERRNO: { #if defined(sun) From owner-svn-src-stable@freebsd.org Fri Aug 28 00:06:32 2015 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9AD019C4669; Fri, 28 Aug 2015 00:06:32 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8B3FF15C7; Fri, 28 Aug 2015 00:06:32 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7S06WVu022324; Fri, 28 Aug 2015 00:06:32 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7S06Wht022323; Fri, 28 Aug 2015 00:06:32 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201508280006.t7S06Wht022323@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Fri, 28 Aug 2015 00:06:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r287231 - stable/10/sys/kern X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Aug 2015 00:06:32 -0000 Author: markj Date: Fri Aug 28 00:06:31 2015 New Revision: 287231 URL: https://svnweb.freebsd.org/changeset/base/287231 Log: MFC r285252: Fix an incorrect assertion in witness. Modified: stable/10/sys/kern/subr_witness.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/kern/subr_witness.c ============================================================================== --- stable/10/sys/kern/subr_witness.c Thu Aug 27 23:55:46 2015 (r287230) +++ stable/10/sys/kern/subr_witness.c Fri Aug 28 00:06:31 2015 (r287231) @@ -1221,7 +1221,7 @@ witness_checkorder(struct lock_object *l for (j = 0, lle = lock_list; lle != NULL; lle = lle->ll_next) { for (i = lle->ll_count - 1; i >= 0; i--, j++) { - MPASS(j < WITNESS_COUNT); + MPASS(j < LOCK_CHILDCOUNT * LOCK_NCHILDREN); lock1 = &lle->ll_children[i]; /* From owner-svn-src-stable@freebsd.org Fri Aug 28 11:56:21 2015 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E13E29C3797; Fri, 28 Aug 2015 11:56:21 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CD6921ACC; Fri, 28 Aug 2015 11:56:21 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7SBuLCK046583; Fri, 28 Aug 2015 11:56:21 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7SBuLjn046582; Fri, 28 Aug 2015 11:56:21 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201508281156.t7SBuLjn046582@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Fri, 28 Aug 2015 11:56:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r287251 - stable/10/sys/dev/md X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Aug 2015 11:56:22 -0000 Author: ae Date: Fri Aug 28 11:56:20 2015 New Revision: 287251 URL: https://svnweb.freebsd.org/changeset/base/287251 Log: MFC r286720: Use g_conf_printf_escaped() to escape illegal symbols in file name. PR: 202289 Modified: stable/10/sys/dev/md/md.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/md/md.c ============================================================================== --- stable/10/sys/dev/md/md.c Fri Aug 28 10:34:37 2015 (r287250) +++ stable/10/sys/dev/md/md.c Fri Aug 28 11:56:20 2015 (r287251) @@ -89,6 +89,7 @@ #include #include +#include #include #include @@ -1621,9 +1622,11 @@ g_md_dumpconf(struct sbuf *sb, const cha "read-only"); sbuf_printf(sb, "%s%s\n", indent, type); - if (mp->type == MD_VNODE && mp->vnode != NULL) - sbuf_printf(sb, "%s%s\n", - indent, mp->file); + if (mp->type == MD_VNODE && mp->vnode != NULL) { + sbuf_printf(sb, "%s", indent); + g_conf_printf_escaped(sb, "%s", mp->file); + sbuf_printf(sb, "\n"); + } } } } From owner-svn-src-stable@freebsd.org Fri Aug 28 12:02:41 2015 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D25029C4023; Fri, 28 Aug 2015 12:02:41 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C2E3C377; Fri, 28 Aug 2015 12:02:41 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7SC2ffM050529; Fri, 28 Aug 2015 12:02:41 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7SC2fYr050528; Fri, 28 Aug 2015 12:02:41 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201508281202.t7SC2fYr050528@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Fri, 28 Aug 2015 12:02:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r287252 - stable/9/sys/dev/md X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Aug 2015 12:02:41 -0000 Author: ae Date: Fri Aug 28 12:02:40 2015 New Revision: 287252 URL: https://svnweb.freebsd.org/changeset/base/287252 Log: MFC r286720: Use g_conf_printf_escaped() to escape illegal symbols in file name. PR: 202289 Modified: stable/9/sys/dev/md/md.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) Modified: stable/9/sys/dev/md/md.c ============================================================================== --- stable/9/sys/dev/md/md.c Fri Aug 28 11:56:20 2015 (r287251) +++ stable/9/sys/dev/md/md.c Fri Aug 28 12:02:40 2015 (r287252) @@ -88,6 +88,7 @@ #include #include +#include #include #include @@ -1540,9 +1541,11 @@ g_md_dumpconf(struct sbuf *sb, const cha indent, (uintmax_t) mp->mediasize); sbuf_printf(sb, "%s%s\n", indent, type); - if (mp->type == MD_VNODE && mp->vnode != NULL) - sbuf_printf(sb, "%s%s\n", - indent, mp->file); + if (mp->type == MD_VNODE && mp->vnode != NULL) { + sbuf_printf(sb, "%s", indent); + g_conf_printf_escaped(sb, "%s", mp->file); + sbuf_printf(sb, "\n"); + } } } } From owner-svn-src-stable@freebsd.org Fri Aug 28 20:53:09 2015 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 67CFD9C4931; Fri, 28 Aug 2015 20:53:09 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3FBCFA8E; Fri, 28 Aug 2015 20:53:09 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7SKr9T4074457; Fri, 28 Aug 2015 20:53:09 GMT (envelope-from jilles@FreeBSD.org) Received: (from jilles@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7SKr8uB074455; Fri, 28 Aug 2015 20:53:08 GMT (envelope-from jilles@FreeBSD.org) Message-Id: <201508282053.t7SKr8uB074455@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jilles set sender to jilles@FreeBSD.org using -f From: Jilles Tjoelker Date: Fri, 28 Aug 2015 20:53:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r287266 - stable/10/usr.bin/find X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Aug 2015 20:53:09 -0000 Author: jilles Date: Fri Aug 28 20:53:08 2015 New Revision: 287266 URL: https://svnweb.freebsd.org/changeset/base/287266 Log: MFC r286344: find: Fix segfault with very long path in -exec/-ok ... {} \;. If the resulting argument is longer than MAXPATHLEN, realloc() was called to extend the space, but the new pointer was not correctly stored. Different from what OpenBSD has done, rewrite brace_subst() to calculate the necessary space first and realloc() at most once. As before, the e_len fields are not updated in case of a realloc. Therefore, a following long argument will do another realloc. PR: 201750 Modified: stable/10/usr.bin/find/extern.h stable/10/usr.bin/find/misc.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.bin/find/extern.h ============================================================================== --- stable/10/usr.bin/find/extern.h Fri Aug 28 20:06:58 2015 (r287265) +++ stable/10/usr.bin/find/extern.h Fri Aug 28 20:53:08 2015 (r287266) @@ -32,7 +32,7 @@ #include -void brace_subst(char *, char **, char *, int); +void brace_subst(char *, char **, char *, size_t); PLAN *find_create(char ***); int find_execute(PLAN *, char **); PLAN *find_formplan(char **); Modified: stable/10/usr.bin/find/misc.c ============================================================================== --- stable/10/usr.bin/find/misc.c Fri Aug 28 20:06:58 2015 (r287265) +++ stable/10/usr.bin/find/misc.c Fri Aug 28 20:53:08 2015 (r287266) @@ -57,23 +57,33 @@ __FBSDID("$FreeBSD$"); * Replace occurrences of {} in s1 with s2 and return the result string. */ void -brace_subst(char *orig, char **store, char *path, int len) +brace_subst(char *orig, char **store, char *path, size_t len) { - int plen; - char ch, *p; + const char *pastorigend, *p, *q; + char *dst; + size_t newlen, plen; plen = strlen(path); - for (p = *store; (ch = *orig) != '\0'; ++orig) - if (ch == '{' && orig[1] == '}') { - while ((p - *store) + plen > len) - if (!(*store = realloc(*store, len *= 2))) - err(1, NULL); - memmove(p, path, plen); - p += plen; - ++orig; - } else - *p++ = ch; - *p = '\0'; + newlen = strlen(orig) + 1; + pastorigend = orig + newlen; + for (p = orig; (q = strstr(p, "{}")) != NULL; p = q + 2) { + if (plen > 2 && newlen + plen - 2 < newlen) + errx(2, "brace_subst overflow"); + newlen += plen - 2; + } + if (newlen > len) { + *store = reallocf(*store, newlen); + if (*store == NULL) + err(2, NULL); + } + dst = *store; + for (p = orig; (q = strstr(p, "{}")) != NULL; p = q + 2) { + memcpy(dst, p, q - p); + dst += q - p; + memcpy(dst, path, plen); + dst += plen; + } + memcpy(dst, p, pastorigend - p); } /* From owner-svn-src-stable@freebsd.org Fri Aug 28 22:42:38 2015 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6E19A9C50A8; Fri, 28 Aug 2015 22:42:38 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5CE84F24; Fri, 28 Aug 2015 22:42:38 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7SMgc5h020153; Fri, 28 Aug 2015 22:42:38 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7SMgcqL020152; Fri, 28 Aug 2015 22:42:38 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <201508282242.t7SMgcqL020152@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Fri, 28 Aug 2015 22:42:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r287267 - stable/10/sys/fs/nfsserver X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Aug 2015 22:42:38 -0000 Author: rmacklem Date: Fri Aug 28 22:42:37 2015 New Revision: 287267 URL: https://svnweb.freebsd.org/changeset/base/287267 Log: MFC: r286790 For the case where an NFSv4.1 ExchangeID operation has the client identifier that already has a confirmed ClientID, the nfsrv_setclient() function would not fill in the clientidp being returned. As such, the value of ClientID returned would be whatever garbage was on the stack. This patch fixes the problem by filling in these fields. Modified: stable/10/sys/fs/nfsserver/nfs_nfsdstate.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/fs/nfsserver/nfs_nfsdstate.c ============================================================================== --- stable/10/sys/fs/nfsserver/nfs_nfsdstate.c Fri Aug 28 20:53:08 2015 (r287266) +++ stable/10/sys/fs/nfsserver/nfs_nfsdstate.c Fri Aug 28 22:42:37 2015 (r287267) @@ -406,9 +406,12 @@ nfsrv_setclient(struct nfsrv_descript *n } /* For NFSv4.1, mark that we found a confirmed clientid. */ - if ((nd->nd_flag & ND_NFSV41) != 0) + if ((nd->nd_flag & ND_NFSV41) != 0) { + clientidp->lval[0] = clp->lc_clientid.lval[0]; + clientidp->lval[1] = clp->lc_clientid.lval[1]; + confirmp->lval[0] = 0; /* Ignored by client */ confirmp->lval[1] = 1; - else { + } else { /* * id and verifier match, so update the net address info * and get rid of any existing callback authentication From owner-svn-src-stable@freebsd.org Sat Aug 29 02:42:01 2015 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 743E29C4503; Sat, 29 Aug 2015 02:42:01 +0000 (UTC) (envelope-from jamie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 63B0A1E94; Sat, 29 Aug 2015 02:42:01 +0000 (UTC) (envelope-from jamie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7T2g1cx029137; Sat, 29 Aug 2015 02:42:01 GMT (envelope-from jamie@FreeBSD.org) Received: (from jamie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7T2g0t5029130; Sat, 29 Aug 2015 02:42:00 GMT (envelope-from jamie@FreeBSD.org) Message-Id: <201508290242.t7T2g0t5029130@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jamie set sender to jamie@FreeBSD.org using -f From: Jamie Gritton Date: Sat, 29 Aug 2015 02:42:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r287269 - in stable/10/bin/pkill: . tests X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 29 Aug 2015 02:42:01 -0000 Author: jamie Date: Sat Aug 29 02:41:59 2015 New Revision: 287269 URL: https://svnweb.freebsd.org/changeset/base/287269 Log: MFC r287012: Make pkill/pgrep -j ARG take jname, not just jid. PR: 201588 Submitted by: Daniel Shahaf Modified: stable/10/bin/pkill/Makefile stable/10/bin/pkill/pkill.1 stable/10/bin/pkill/pkill.c stable/10/bin/pkill/tests/pgrep-j_test.sh stable/10/bin/pkill/tests/pkill-j_test.sh Directory Properties: stable/10/ (props changed) Modified: stable/10/bin/pkill/Makefile ============================================================================== --- stable/10/bin/pkill/Makefile Sat Aug 29 00:05:39 2015 (r287268) +++ stable/10/bin/pkill/Makefile Sat Aug 29 02:41:59 2015 (r287269) @@ -5,8 +5,8 @@ PROG= pkill -DPADD= ${LIBKVM} -LDADD= -lkvm +DPADD= ${LIBKVM} ${LIBJAIL} +LDADD= -lkvm -ljail LINKS= ${BINDIR}/pkill ${BINDIR}/pgrep MLINKS= pkill.1 pgrep.1 Modified: stable/10/bin/pkill/pkill.1 ============================================================================== --- stable/10/bin/pkill/pkill.1 Sat Aug 29 00:05:39 2015 (r287268) +++ stable/10/bin/pkill/pkill.1 Sat Aug 29 02:41:59 2015 (r287269) @@ -29,7 +29,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd August 9, 2013 +.Dd August 21, 2015 .Dt PKILL 1 .Os .Sh NAME @@ -47,7 +47,7 @@ .Op Fl c Ar class .Op Fl d Ar delim .Op Fl g Ar pgrp -.Op Fl j Ar jid +.Op Fl j Ar jail .Op Fl s Ar sid .Op Fl t Ar tty .Op Fl u Ar euid @@ -63,7 +63,7 @@ .Op Fl U Ar uid .Op Fl c Ar class .Op Fl g Ar pgrp -.Op Fl j Ar jid +.Op Fl j Ar jail .Op Fl s Ar sid .Op Fl t Ar tty .Op Fl u Ar euid @@ -149,16 +149,16 @@ or command. .It Fl i Ignore case distinctions in both the process table and the supplied pattern. -.It Fl j Ar jid -Restrict matches to processes inside jails with a jail ID in the comma-separated -list -.Ar jid . -The value +.It Fl j Ar jail +Restrict matches to processes inside the specified jails. +The argument +.Ar jail +may be .Dq Li any -matches processes in any jail. -The value +to match processes in any jail, .Dq Li none -matches processes not in jail. +to match processes not in jail, +or a comma-separated list of jail IDs or names. .It Fl l Long output. For Modified: stable/10/bin/pkill/pkill.c ============================================================================== --- stable/10/bin/pkill/pkill.c Sat Aug 29 00:05:39 2015 (r287268) +++ stable/10/bin/pkill/pkill.c Sat Aug 29 02:41:59 2015 (r287269) @@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #define STATUS_MATCH 0 #define STATUS_NOMATCH 1 @@ -78,7 +79,7 @@ enum listtype { LT_GROUP, LT_TTY, LT_PGRP, - LT_JID, + LT_JAIL, LT_SID, LT_CLASS }; @@ -245,7 +246,7 @@ main(int argc, char **argv) cflags |= REG_ICASE; break; case 'j': - makelist(&jidlist, LT_JID, optarg); + makelist(&jidlist, LT_JAIL, optarg); criteria = 1; break; case 'l': @@ -582,7 +583,7 @@ usage(void) fprintf(stderr, "usage: %s %s [-F pidfile] [-G gid] [-M core] [-N system]\n" - " [-P ppid] [-U uid] [-c class] [-g pgrp] [-j jid]\n" + " [-P ppid] [-U uid] [-c class] [-g pgrp] [-j jail]\n" " [-s sid] [-t tty] [-u euid] pattern ...\n", getprogname(), ustr); @@ -697,7 +698,7 @@ makelist(struct listhead *head, enum lis if (li->li_number == 0) li->li_number = getsid(mypid); break; - case LT_JID: + case LT_JAIL: if (li->li_number < 0) errx(STATUS_BADUSAGE, "Negative jail ID `%s'", sp); @@ -763,15 +764,20 @@ foundtty: if ((st.st_mode & S_IFCHR) == li->li_number = st.st_rdev; break; - case LT_JID: + case LT_JAIL: { + int jid; + if (strcmp(sp, "none") == 0) li->li_number = 0; else if (strcmp(sp, "any") == 0) li->li_number = -1; + else if ((jid = jail_getid(sp)) != -1) + li->li_number = jid; else if (*ep != '\0') errx(STATUS_BADUSAGE, - "Invalid jail ID `%s'", sp); + "Invalid jail ID or name `%s'", sp); break; + } case LT_CLASS: li->li_number = -1; li->li_name = strdup(sp); Modified: stable/10/bin/pkill/tests/pgrep-j_test.sh ============================================================================== --- stable/10/bin/pkill/tests/pgrep-j_test.sh Sat Aug 29 00:05:39 2015 (r287268) +++ stable/10/bin/pkill/tests/pgrep-j_test.sh Sat Aug 29 02:41:59 2015 (r287269) @@ -14,7 +14,7 @@ if [ `id -u` -ne 0 ]; then exit 0 fi -echo "1..3" +echo "1..4" sleep=$(pwd)/sleep.txt ln -sf /bin/sleep $sleep @@ -87,5 +87,30 @@ else fi [ -f ${PWD}/${base}_3_1.pid ] && kill $(cat $PWD/${base}_3_1.pid) [ -f ${PWD}/${base}_3_2.pid ] && kill $(cat $PWD/${base}_3_2.pid) +wait + +# test 4 is like test 1 except with jname instead of jid. +name="pgrep -j " +sleep_amount=8 +jail -c path=/ name=${base}_4_1 ip4.addr=127.0.0.1 \ + command=daemon -p ${PWD}/${base}_4_1.pid $sleep $sleep_amount & + +jail -c path=/ name=${base}_4_2 ip4.addr=127.0.0.1 \ + command=daemon -p ${PWD}/${base}_4_2.pid $sleep $sleep_amount & + +sleep 0.5 + +jname="${base}_4_1,${base}_4_2" +pid1="$(pgrep -f -x -j "$jname" "$sleep $sleep_amount" | sort)" +pid2=$(printf "%s\n%s" "$(cat ${PWD}/${base}_4_1.pid)" \ + $(cat ${PWD}/${base}_4_2.pid) | sort) +if [ "$pid1" = "$pid2" ]; then + echo "ok 4 - $name" +else + echo "not ok 4 - $name # pgrep output: '$(echo $pid1)', pidfile output: '$(echo $pid2)'" +fi +[ -f ${PWD}/${base}_4_1.pid ] && kill $(cat ${PWD}/${base}_4_1.pid) +[ -f ${PWD}/${base}_4_2.pid ] && kill $(cat ${PWD}/${base}_4_2.pid) +wait rm -f $sleep Modified: stable/10/bin/pkill/tests/pkill-j_test.sh ============================================================================== --- stable/10/bin/pkill/tests/pkill-j_test.sh Sat Aug 29 00:05:39 2015 (r287268) +++ stable/10/bin/pkill/tests/pkill-j_test.sh Sat Aug 29 02:41:59 2015 (r287269) @@ -14,7 +14,7 @@ if [ `id -u` -ne 0 ]; then exit 0 fi -echo "1..3" +echo "1..4" sleep=$(pwd)/sleep.txt ln -sf /bin/sleep $sleep @@ -90,5 +90,31 @@ else fi 2>/dev/null [ -f ${PWD}/${base}_3_1.pid ] && kill $(cat ${base}_3_1.pid) [ -f ${PWD}/${base}_3_2.pid ] && kill $(cat ${base}_3_2.pid) +wait + +# test 4 is like test 1 except with jname instead of jid. +name="pkill -j " +sleep_amount=8 +jail -c path=/ name=${base}_4_1 ip4.addr=127.0.0.1 \ + command=daemon -p ${PWD}/${base}_4_1.pid $sleep $sleep_amount & + +jail -c path=/ name=${base}_4_2 ip4.addr=127.0.0.1 \ + command=daemon -p ${PWD}/${base}_4_2.pid $sleep $sleep_amount & + +$sleep $sleep_amount & + +sleep 0.5 + +jname="${base}_4_1,${base}_4_2" +if pkill -f -j "$jname" $sleep && sleep 0.5 && + ! -f ${PWD}/${base}_4_1.pid && + ! -f ${PWD}/${base}_4_2.pid ; then + echo "ok 4 - $name" +else + echo "not ok 4 - $name" +fi 2>/dev/null +[ -f ${PWD}/${base}_4_1.pid ] && kill $(cat ${PWD}/${base}_4_1.pid) +[ -f ${PWD}/${base}_4_2.pid ] && kill $(cat ${PWD}/${base}_4_2.pid) +wait rm -f $sleep From owner-svn-src-stable@freebsd.org Sat Aug 29 06:07:56 2015 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EE91A9C4781; Sat, 29 Aug 2015 06:07:55 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DDD5F110A; Sat, 29 Aug 2015 06:07:55 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7T67tOT025190; Sat, 29 Aug 2015 06:07:55 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7T67tiQ025188; Sat, 29 Aug 2015 06:07:55 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201508290607.t7T67tiQ025188@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Sat, 29 Aug 2015 06:07:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r287271 - stable/10/sys/dev/usb/controller X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 29 Aug 2015 06:07:56 -0000 Author: hselasky Date: Sat Aug 29 06:07:55 2015 New Revision: 287271 URL: https://svnweb.freebsd.org/changeset/base/287271 Log: MFC r283067, r286118, r285638, r285935, r286778, r286780 and r286802: - Make the FIFO configuration a bit more flexible for the DWC OTG in device side mode. - Limit the number of times we loop inside the DWC OTG poll handler to avoid starving other fast interrupts. Fix a comment while at it. - Optimise the DWC OTG host mode driver's transmit path - Optimise the DWC OTG host mode driver's receive path - Minor code refactor to avoid duplicating code. - Handle NYET high speed tokens and predict NAK'ing is up next. - Fixes for HIGH speed ISOCHRONOUS traffic. Modified: stable/10/sys/dev/usb/controller/dwc_otg.c stable/10/sys/dev/usb/controller/dwc_otg.h stable/10/sys/dev/usb/controller/dwc_otgreg.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/usb/controller/dwc_otg.c ============================================================================== --- stable/10/sys/dev/usb/controller/dwc_otg.c Sat Aug 29 04:33:31 2015 (r287270) +++ stable/10/sys/dev/usb/controller/dwc_otg.c Sat Aug 29 06:07:55 2015 (r287271) @@ -1,6 +1,7 @@ /* $FreeBSD$ */ /*- - * Copyright (c) 2012 Hans Petter Selasky. All rights reserved. + * Copyright (c) 2015 Daisuke Aoyama. All rights reserved. + * Copyright (c) 2012-2015 Hans Petter Selasky. All rights reserved. * Copyright (c) 2010-2011 Aleksandr Rybalko. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -152,7 +153,6 @@ static void dwc_otg_do_poll(struct usb_b static void dwc_otg_standard_done(struct usb_xfer *); static void dwc_otg_root_intr(struct dwc_otg_softc *); static void dwc_otg_interrupt_poll_locked(struct dwc_otg_softc *); -static void dwc_otg_host_channel_disable(struct dwc_otg_softc *, uint8_t); /* * Here is a configuration that the chip supports. @@ -225,7 +225,7 @@ dwc_otg_init_fifo(struct dwc_otg_softc * /* split equally for IN and OUT */ fifo_size /= 2; - /* align to 4 bytes boundary */ + /* Align to 4 bytes boundary (refer to PGM) */ fifo_size &= ~3; /* set global receive FIFO size */ @@ -238,13 +238,6 @@ dwc_otg_init_fifo(struct dwc_otg_softc * return (EINVAL); } - /* disable any leftover host channels */ - for (x = 0; x != sc->sc_host_ch_max; x++) { - if (sc->sc_chan_state[x].wait_sof == 0) - continue; - dwc_otg_host_channel_disable(sc, x); - } - if (mode == DWC_MODE_HOST) { /* reset active endpoints */ @@ -253,6 +246,8 @@ dwc_otg_init_fifo(struct dwc_otg_softc * /* split equally for periodic and non-periodic */ fifo_size /= 2; + DPRINTF("PTX/NPTX FIFO=%u\n", fifo_size); + /* align to 4 bytes boundary */ fifo_size &= ~3; @@ -263,7 +258,7 @@ dwc_otg_init_fifo(struct dwc_otg_softc * tx_start += fifo_size; for (x = 0; x != sc->sc_host_ch_max; x++) { - /* disable all host interrupts */ + /* enable all host interrupts */ DWC_OTG_WRITE_4(sc, DOTG_HCINTMSK(x), HCINT_DEFAULT_MASK); } @@ -275,13 +270,6 @@ dwc_otg_init_fifo(struct dwc_otg_softc * /* reset host channel state */ memset(sc->sc_chan_state, 0, sizeof(sc->sc_chan_state)); - /* reset FIFO TX levels */ - sc->sc_tx_cur_p_level = 0; - sc->sc_tx_cur_np_level = 0; - - /* store maximum periodic and non-periodic FIFO TX size */ - sc->sc_tx_max_size = fifo_size; - /* enable all host channel interrupts */ DWC_OTG_WRITE_4(sc, DOTG_HAINTMSK, (1U << sc->sc_host_ch_max) - 1U); @@ -314,32 +302,29 @@ dwc_otg_init_fifo(struct dwc_otg_softc * if (x < sc->sc_dev_in_ep_max) { uint32_t limit; - limit = (x == 1) ? DWC_OTG_MAX_TXN : - (DWC_OTG_MAX_TXN / 2); + limit = (x == 1) ? MIN(DWC_OTG_TX_MAX_FIFO_SIZE, + DWC_OTG_MAX_TXN) : MIN(DWC_OTG_MAX_TXN / 2, + DWC_OTG_TX_MAX_FIFO_SIZE); - if (fifo_size >= limit) { - DWC_OTG_WRITE_4(sc, DOTG_DIEPTXF(x), - ((limit / 4) << 16) | - (tx_start / 4)); - tx_start += limit; - fifo_size -= limit; - pf->usb.max_in_frame_size = 0x200; - pf->usb.support_in = 1; + /* see if there is enough FIFO space */ + if (limit <= fifo_size) { pf->max_buffer = limit; - - } else if (fifo_size >= 0x80) { - DWC_OTG_WRITE_4(sc, DOTG_DIEPTXF(x), - ((0x80 / 4) << 16) | (tx_start / 4)); - tx_start += 0x80; - fifo_size -= 0x80; - pf->usb.max_in_frame_size = 0x40; pf->usb.support_in = 1; - } else { - pf->usb.is_simplex = 1; - DWC_OTG_WRITE_4(sc, DOTG_DIEPTXF(x), - (0x0 << 16) | (tx_start / 4)); + limit = MIN(DWC_OTG_TX_MAX_FIFO_SIZE, 0x40); + if (limit <= fifo_size) { + pf->usb.support_in = 1; + } else { + pf->usb.is_simplex = 1; + limit = 0; + } } + /* set FIFO size */ + DWC_OTG_WRITE_4(sc, DOTG_DIEPTXF(x), + ((limit / 4) << 16) | (tx_start / 4)); + tx_start += limit; + fifo_size -= limit; + pf->usb.max_in_frame_size = limit; } else { pf->usb.is_simplex = 1; } @@ -362,15 +347,8 @@ dwc_otg_init_fifo(struct dwc_otg_softc * /* reset active endpoints */ sc->sc_active_rx_ep = 0; - /* reset periodic and non-periodic FIFO TX size */ - sc->sc_tx_max_size = fifo_size; - /* reset host channel state */ memset(sc->sc_chan_state, 0, sizeof(sc->sc_chan_state)); - - /* reset FIFO TX levels */ - sc->sc_tx_cur_p_level = 0; - sc->sc_tx_cur_np_level = 0; } return (0); } @@ -476,8 +454,12 @@ static void dwc_otg_enable_sof_irq(struct dwc_otg_softc *sc) { /* In device mode we don't use the SOF interrupt */ - if (sc->sc_flags.status_device_mode != 0 || - (sc->sc_irq_mask & GINTMSK_SOFMSK) != 0) + if (sc->sc_flags.status_device_mode != 0) + return; + /* Ensure the SOF interrupt is not disabled */ + sc->sc_needsof = 1; + /* Check if the SOF interrupt is already enabled */ + if ((sc->sc_irq_mask & GINTMSK_SOFMSK) != 0) return; sc->sc_irq_mask |= GINTMSK_SOFMSK; DWC_OTG_WRITE_4(sc, DOTG_GINTMSK, sc->sc_irq_mask); @@ -616,13 +598,48 @@ dwc_otg_clear_hcint(struct dwc_otg_softc } static uint8_t -dwc_otg_host_channel_alloc(struct dwc_otg_softc *sc, struct dwc_otg_td *td, uint8_t is_out) +dwc_otg_host_check_tx_fifo_empty(struct dwc_otg_softc *sc, struct dwc_otg_td *td) +{ + uint32_t temp; + + temp = DWC_OTG_READ_4(sc, DOTG_GINTSTS); + + if (td->ep_type == UE_ISOCHRONOUS) { + /* + * NOTE: USB INTERRUPT transactions are executed like + * USB CONTROL transactions! See the setup standard + * chain function for more information. + */ + if (!(temp & GINTSTS_PTXFEMP)) { + DPRINTF("Periodic TX FIFO is not empty\n"); + if (!(sc->sc_irq_mask & GINTMSK_PTXFEMPMSK)) { + sc->sc_irq_mask |= GINTMSK_PTXFEMPMSK; + DWC_OTG_WRITE_4(sc, DOTG_GINTMSK, sc->sc_irq_mask); + } + return (1); /* busy */ + } + } else { + if (!(temp & GINTSTS_NPTXFEMP)) { + DPRINTF("Non-periodic TX FIFO is not empty\n"); + if (!(sc->sc_irq_mask & GINTMSK_NPTXFEMPMSK)) { + sc->sc_irq_mask |= GINTMSK_NPTXFEMPMSK; + DWC_OTG_WRITE_4(sc, DOTG_GINTMSK, sc->sc_irq_mask); + } + return (1); /* busy */ + } + } + return (0); /* ready for transmit */ +} + +static uint8_t +dwc_otg_host_channel_alloc(struct dwc_otg_softc *sc, + struct dwc_otg_td *td, uint8_t is_out) { - uint32_t tx_p_size; - uint32_t tx_np_size; uint8_t x; + uint8_t y; + uint8_t z; - if (td->channel < DWC_OTG_MAX_CHANNELS) + if (td->channel[0] < DWC_OTG_MAX_CHANNELS) return (0); /* already allocated */ /* check if device is suspended */ @@ -631,45 +648,41 @@ dwc_otg_host_channel_alloc(struct dwc_ot /* compute needed TX FIFO size */ if (is_out != 0) { - if (td->ep_type == UE_ISOCHRONOUS) { - tx_p_size = td->max_packet_size; - tx_np_size = 0; - if (td->hcsplt != 0 && tx_p_size > HCSPLT_XACTLEN_BURST) - tx_p_size = HCSPLT_XACTLEN_BURST; - if ((sc->sc_tx_cur_p_level + tx_p_size) > sc->sc_tx_max_size) { - DPRINTF("Too little FIFO space\n"); - return (1); /* too little FIFO */ - } - } else { - tx_p_size = 0; - tx_np_size = td->max_packet_size; - if (td->hcsplt != 0 && tx_np_size > HCSPLT_XACTLEN_BURST) - tx_np_size = HCSPLT_XACTLEN_BURST; - if ((sc->sc_tx_cur_np_level + tx_np_size) > sc->sc_tx_max_size) { - DPRINTF("Too little FIFO space\n"); - return (1); /* too little FIFO */ - } - } - } else { - /* not a TX transaction */ - tx_p_size = 0; - tx_np_size = 0; + if (dwc_otg_host_check_tx_fifo_empty(sc, td) != 0) + return (1); /* busy - cannot transfer data */ } - - for (x = 0; x != sc->sc_host_ch_max; x++) { + z = td->max_packet_count; + for (x = y = 0; x != sc->sc_host_ch_max; x++) { + /* check if channel is allocated */ if (sc->sc_chan_state[x].allocated != 0) continue; /* check if channel is still enabled */ - if (sc->sc_chan_state[x].wait_sof != 0) + if (sc->sc_chan_state[x].wait_halted != 0) continue; + /* store channel number */ + td->channel[y++] = x; + /* check if we got all channels */ + if (y == z) + break; + } + if (y != z) { + /* reset channel variable */ + td->channel[0] = DWC_OTG_MAX_CHANNELS; + td->channel[1] = DWC_OTG_MAX_CHANNELS; + td->channel[2] = DWC_OTG_MAX_CHANNELS; + /* wait a bit */ + dwc_otg_enable_sof_irq(sc); + return (1); /* busy - not enough channels */ + } + + for (y = 0; y != z; y++) { + x = td->channel[y]; + /* set allocated */ sc->sc_chan_state[x].allocated = 1; - sc->sc_chan_state[x].tx_p_size = tx_p_size; - sc->sc_chan_state[x].tx_np_size = tx_np_size; - /* keep track of used TX FIFO, if any */ - sc->sc_tx_cur_p_level += tx_p_size; - sc->sc_tx_cur_np_level += tx_np_size; + /* set wait halted */ + sc->sc_chan_state[x].wait_halted = 1; /* clear interrupts */ dwc_otg_clear_hcint(sc, x); @@ -679,45 +692,29 @@ dwc_otg_host_channel_alloc(struct dwc_ot /* set active channel */ sc->sc_active_rx_ep |= (1 << x); - - /* set channel */ - td->channel = x; - - return (0); /* allocated */ } - /* wait a bit */ - dwc_otg_enable_sof_irq(sc); - return (1); /* busy */ + return (0); /* allocated */ } static void -dwc_otg_host_channel_free(struct dwc_otg_softc *sc, struct dwc_otg_td *td) +dwc_otg_host_channel_free_sub(struct dwc_otg_softc *sc, struct dwc_otg_td *td, uint8_t index) { + uint32_t hcchar; uint8_t x; - if (td->channel >= DWC_OTG_MAX_CHANNELS) + if (td->channel[index] >= DWC_OTG_MAX_CHANNELS) return; /* already freed */ /* free channel */ - x = td->channel; - td->channel = DWC_OTG_MAX_CHANNELS; + x = td->channel[index]; + td->channel[index] = DWC_OTG_MAX_CHANNELS; DPRINTF("CH=%d\n", x); /* * We need to let programmed host channels run till complete - * else the host channel will stop functioning. Assume that - * after a fixed given amount of time the host channel is no - * longer doing any USB traffic: + * else the host channel will stop functioning. */ - if (td->ep_type == UE_ISOCHRONOUS) { - /* double buffered */ - sc->sc_chan_state[x].wait_sof = DWC_OTG_SLOT_IDLE_MAX; - } else { - /* single buffered */ - sc->sc_chan_state[x].wait_sof = DWC_OTG_SLOT_IDLE_MIN; - } - sc->sc_chan_state[x].allocated = 0; /* ack any pending messages */ @@ -728,17 +725,43 @@ dwc_otg_host_channel_free(struct dwc_otg /* clear active channel */ sc->sc_active_rx_ep &= ~(1 << x); + + /* check if already halted */ + if (sc->sc_chan_state[x].wait_halted == 0) + return; + + /* disable host channel */ + hcchar = DWC_OTG_READ_4(sc, DOTG_HCCHAR(x)); + if (hcchar & HCCHAR_CHENA) { + DPRINTF("Halting channel %d\n", x); + DWC_OTG_WRITE_4(sc, DOTG_HCCHAR(x), + hcchar | HCCHAR_CHDIS); + /* don't write HCCHAR until the channel is halted */ + } else { + sc->sc_chan_state[x].wait_halted = 0; + } +} + +static void +dwc_otg_host_channel_free(struct dwc_otg_softc *sc, struct dwc_otg_td *td) +{ + uint8_t x; + for (x = 0; x != td->max_packet_count; x++) + dwc_otg_host_channel_free_sub(sc, td, x); } static void dwc_otg_host_dump_rx(struct dwc_otg_softc *sc, struct dwc_otg_td *td) { + uint8_t x; /* dump any pending messages */ - if (sc->sc_last_rx_status != 0) { - if (td->channel < DWC_OTG_MAX_CHANNELS && - td->channel == GRXSTSRD_CHNUM_GET(sc->sc_last_rx_status)) { - dwc_otg_common_rx_ack(sc); - } + if (sc->sc_last_rx_status == 0) + return; + for (x = 0; x != td->max_packet_count; x++) { + if (td->channel[x] >= DWC_OTG_MAX_CHANNELS || + td->channel[x] != GRXSTSRD_CHNUM_GET(sc->sc_last_rx_status)) + continue; + dwc_otg_common_rx_ack(sc); } } @@ -752,13 +775,13 @@ dwc_otg_host_setup_tx(struct dwc_otg_sof dwc_otg_host_dump_rx(sc, td); - if (td->channel < DWC_OTG_MAX_CHANNELS) { - hcint = sc->sc_chan_state[td->channel].hcint; + if (td->channel[0] < DWC_OTG_MAX_CHANNELS) { + hcint = sc->sc_chan_state[td->channel[0]].hcint; DPRINTF("CH=%d ST=%d HCINT=0x%08x HCCHAR=0x%08x HCTSIZ=0x%08x\n", - td->channel, td->state, hcint, - DWC_OTG_READ_4(sc, DOTG_HCCHAR(td->channel)), - DWC_OTG_READ_4(sc, DOTG_HCTSIZ(td->channel))); + td->channel[0], td->state, hcint, + DWC_OTG_READ_4(sc, DOTG_HCCHAR(td->channel[0])), + DWC_OTG_READ_4(sc, DOTG_HCTSIZ(td->channel[0]))); } else { hcint = 0; goto check_state; @@ -768,12 +791,12 @@ dwc_otg_host_setup_tx(struct dwc_otg_sof HCINT_ACK | HCINT_NYET)) { /* give success bits priority over failure bits */ } else if (hcint & HCINT_STALL) { - DPRINTF("CH=%d STALL\n", td->channel); + DPRINTF("CH=%d STALL\n", td->channel[0]); td->error_stall = 1; td->error_any = 1; goto complete; } else if (hcint & HCINT_ERRORS) { - DPRINTF("CH=%d ERROR\n", td->channel); + DPRINTF("CH=%d ERROR\n", td->channel[0]); td->errcnt++; if (td->hcsplt != 0 || td->errcnt >= 3) { td->error_any = 1; @@ -794,7 +817,7 @@ check_state: case DWC_CHAN_ST_WAIT_ANE: if (hcint & (HCINT_RETRY | HCINT_ERRORS)) { - td->did_nak++; + td->did_nak = 1; td->tt_scheduled = 0; goto send_pkt; } else if (hcint & (HCINT_ACK | HCINT_NYET)) { @@ -808,7 +831,7 @@ check_state: case DWC_CHAN_ST_WAIT_S_ANE: if (hcint & (HCINT_RETRY | HCINT_ERRORS)) { - td->did_nak++; + td->did_nak = 1; td->tt_scheduled = 0; goto send_pkt; } else if (hcint & (HCINT_ACK | HCINT_NYET)) { @@ -820,7 +843,7 @@ check_state: if (hcint & HCINT_NYET) { goto send_cpkt; } else if (hcint & (HCINT_RETRY | HCINT_ERRORS)) { - td->did_nak++; + td->did_nak = 1; td->tt_scheduled = 0; goto send_pkt; } else if (hcint & HCINT_ACK) { @@ -878,23 +901,23 @@ send_pkt: usbd_copy_out(td->pc, 0, &req, sizeof(req)); - DWC_OTG_WRITE_4(sc, DOTG_HCTSIZ(td->channel), + DWC_OTG_WRITE_4(sc, DOTG_HCTSIZ(td->channel[0]), (sizeof(req) << HCTSIZ_XFERSIZE_SHIFT) | (1 << HCTSIZ_PKTCNT_SHIFT) | (HCTSIZ_PID_SETUP << HCTSIZ_PID_SHIFT)); - DWC_OTG_WRITE_4(sc, DOTG_HCSPLT(td->channel), td->hcsplt); + DWC_OTG_WRITE_4(sc, DOTG_HCSPLT(td->channel[0]), td->hcsplt); hcchar = td->hcchar; hcchar &= ~(HCCHAR_EPDIR_IN | HCCHAR_EPTYPE_MASK); hcchar |= UE_CONTROL << HCCHAR_EPTYPE_SHIFT; /* must enable channel before writing data to FIFO */ - DWC_OTG_WRITE_4(sc, DOTG_HCCHAR(td->channel), hcchar); + DWC_OTG_WRITE_4(sc, DOTG_HCCHAR(td->channel[0]), hcchar); /* transfer data into FIFO */ bus_space_write_region_4(sc->sc_io_tag, sc->sc_io_hdl, - DOTG_DFIFO(td->channel), (uint32_t *)&req, sizeof(req) / 4); + DOTG_DFIFO(td->channel[0]), (uint32_t *)&req, sizeof(req) / 4); /* wait until next slot before trying complete split */ td->tt_complete_slot = sc->sc_last_frame_num + 1; @@ -931,17 +954,17 @@ send_cpkt: td->hcsplt |= HCSPLT_COMPSPLT; td->state = DWC_CHAN_ST_WAIT_C_ANE; - DWC_OTG_WRITE_4(sc, DOTG_HCTSIZ(td->channel), + DWC_OTG_WRITE_4(sc, DOTG_HCTSIZ(td->channel[0]), (HCTSIZ_PID_SETUP << HCTSIZ_PID_SHIFT)); - DWC_OTG_WRITE_4(sc, DOTG_HCSPLT(td->channel), td->hcsplt); + DWC_OTG_WRITE_4(sc, DOTG_HCSPLT(td->channel[0]), td->hcsplt); hcchar = td->hcchar; hcchar &= ~(HCCHAR_EPDIR_IN | HCCHAR_EPTYPE_MASK); hcchar |= UE_CONTROL << HCCHAR_EPTYPE_SHIFT; /* must enable channel before writing data to FIFO */ - DWC_OTG_WRITE_4(sc, DOTG_HCCHAR(td->channel), hcchar); + DWC_OTG_WRITE_4(sc, DOTG_HCCHAR(td->channel[0]), hcchar); busy: return (1); /* busy */ @@ -1075,41 +1098,51 @@ dwc_otg_host_rate_check_interrupt(struct static uint8_t dwc_otg_host_rate_check(struct dwc_otg_softc *sc, struct dwc_otg_td *td) { + uint8_t frame_num = (uint8_t)sc->sc_last_frame_num; + if (td->ep_type == UE_ISOCHRONOUS) { /* non TT isochronous traffic */ - if ((td->tmr_val != 0) || - (sc->sc_last_frame_num & (td->tmr_res - 1))) { + if (frame_num & (td->tmr_res - 1)) goto busy; - } - td->tmr_val = 1; /* executed */ + if ((frame_num ^ td->tmr_val) & td->tmr_res) + goto busy; + td->tmr_val = td->tmr_res + sc->sc_last_frame_num; td->toggle = 0; - + return (0); } else if (td->ep_type == UE_INTERRUPT) { if (!td->tt_scheduled) goto busy; td->tt_scheduled = 0; - } else if (td->did_nak >= DWC_OTG_NAK_MAX) { - goto busy; + return (0); + } else if (td->did_nak != 0) { + /* check if we should pause sending queries for 125us */ + if (td->tmr_res == frame_num) { + /* wait a bit */ + dwc_otg_enable_sof_irq(sc); + goto busy; + } } else if (td->set_toggle) { td->set_toggle = 0; td->toggle = 1; } + /* query for data one more time */ + td->tmr_res = frame_num; + td->did_nak = 0; return (0); busy: return (1); } static uint8_t -dwc_otg_host_data_rx_sub(struct dwc_otg_softc *sc, struct dwc_otg_td *td) +dwc_otg_host_data_rx_sub(struct dwc_otg_softc *sc, struct dwc_otg_td *td, + uint8_t channel) { uint32_t count; - uint8_t channel; /* check endpoint status */ if (sc->sc_last_rx_status == 0) goto busy; - channel = td->channel; if (channel >= DWC_OTG_MAX_CHANNELS) goto busy; @@ -1134,21 +1167,22 @@ dwc_otg_host_data_rx_sub(struct dwc_otg_ /* get the packet byte count */ count = GRXSTSRD_BCNT_GET(sc->sc_last_rx_status); - /* check for isochronous transfer or high-speed bandwidth endpoint */ - if (td->ep_type == UE_ISOCHRONOUS || td->max_packet_count > 1) { - if ((sc->sc_last_rx_status & GRXSTSRD_DPID_MASK) != GRXSTSRD_DPID_DATA0) { + /* check for ISOCHRONOUS endpoint */ + if (td->ep_type == UE_ISOCHRONOUS) { + if ((sc->sc_last_rx_status & GRXSTSRD_DPID_MASK) != + GRXSTSRD_DPID_DATA0) { + /* more data to be received */ td->tt_xactpos = HCSPLT_XACTPOS_MIDDLE; } else { + /* all data received */ td->tt_xactpos = HCSPLT_XACTPOS_BEGIN; - /* verify the packet byte count */ - if (count < td->max_packet_size) { + if (count != td->remainder) { /* we have a short packet */ td->short_pkt = 1; td->got_short = 1; } } - td->toggle = 0; } else { /* verify the packet byte count */ if (count != td->max_packet_size) { @@ -1200,15 +1234,17 @@ complete: static uint8_t dwc_otg_host_data_rx(struct dwc_otg_softc *sc, struct dwc_otg_td *td) { - uint32_t hcint; + uint32_t hcint = 0; uint32_t hcchar; uint8_t delta; uint8_t channel; + uint8_t x; - channel = td->channel; - - if (channel < DWC_OTG_MAX_CHANNELS) { - hcint = sc->sc_chan_state[channel].hcint; + for (x = 0; x != td->max_packet_count; x++) { + channel = td->channel[x]; + if (channel >= DWC_OTG_MAX_CHANNELS) + continue; + hcint |= sc->sc_chan_state[channel].hcint; DPRINTF("CH=%d ST=%d HCINT=0x%08x HCCHAR=0x%08x HCTSIZ=0x%08x\n", channel, td->state, hcint, @@ -1236,19 +1272,17 @@ dwc_otg_host_data_rx(struct dwc_otg_soft } /* check channels for data, if any */ - if (dwc_otg_host_data_rx_sub(sc, td)) + if (dwc_otg_host_data_rx_sub(sc, td, channel)) goto complete; /* refresh interrupt status */ - hcint = sc->sc_chan_state[channel].hcint; + hcint |= sc->sc_chan_state[channel].hcint; if (hcint & (HCINT_ERRORS | HCINT_RETRY | HCINT_ACK | HCINT_NYET)) { if (!(hcint & HCINT_ERRORS)) td->errcnt = 0; } - } else { - hcint = 0; } switch (td->state) { @@ -1275,8 +1309,10 @@ dwc_otg_host_data_rx(struct dwc_otg_soft td->toggle ^= 1; goto receive_pkt; } + } else if (td->ep_type == UE_ISOCHRONOUS) { + goto complete; } - td->did_nak++; + td->did_nak = 1; td->tt_scheduled = 0; if (td->hcsplt != 0) goto receive_spkt; @@ -1298,12 +1334,12 @@ dwc_otg_host_data_rx(struct dwc_otg_soft if (td->ep_type == UE_ISOCHRONOUS) { /* check if we are complete */ - if ((td->remainder == 0) || - (td->tt_xactpos == HCSPLT_XACTPOS_BEGIN)) { + if (td->tt_xactpos == HCSPLT_XACTPOS_BEGIN) { goto complete; + } else { + /* get more packets */ + goto busy; } - /* get another packet */ - goto receive_pkt; } else { /* check if we are complete */ if ((td->remainder == 0) || (td->got_short != 0)) { @@ -1331,7 +1367,7 @@ dwc_otg_host_data_rx(struct dwc_otg_soft * case of interrupt and isochronous transfers: */ if (hcint & (HCINT_RETRY | HCINT_ERRORS)) { - td->did_nak++; + td->did_nak = 1; td->tt_scheduled = 0; goto receive_spkt; } else if (hcint & HCINT_NYET) { @@ -1371,8 +1407,7 @@ receive_pkt: } /* complete split */ td->hcsplt |= HCSPLT_COMPSPLT; - } else if (td->tt_xactpos == HCSPLT_XACTPOS_BEGIN && - dwc_otg_host_rate_check(sc, td)) { + } else if (dwc_otg_host_rate_check(sc, td)) { td->state = DWC_CHAN_ST_WAIT_C_PKT; goto busy; } @@ -1383,8 +1418,6 @@ receive_pkt: goto busy; } - channel = td->channel; - /* set toggle, if any */ if (td->set_toggle) { td->set_toggle = 0; @@ -1393,27 +1426,31 @@ receive_pkt: td->state = DWC_CHAN_ST_WAIT_ANE; - /* receive one packet */ - DWC_OTG_WRITE_4(sc, DOTG_HCTSIZ(channel), - (td->max_packet_size << HCTSIZ_XFERSIZE_SHIFT) | - (1 << HCTSIZ_PKTCNT_SHIFT) | - (td->toggle ? (HCTSIZ_PID_DATA1 << HCTSIZ_PID_SHIFT) : - (HCTSIZ_PID_DATA0 << HCTSIZ_PID_SHIFT))); + for (x = 0; x != td->max_packet_count; x++) { + channel = td->channel[x]; - DWC_OTG_WRITE_4(sc, DOTG_HCSPLT(channel), td->hcsplt); + /* receive one packet */ + DWC_OTG_WRITE_4(sc, DOTG_HCTSIZ(channel), + (td->max_packet_size << HCTSIZ_XFERSIZE_SHIFT) | + (1 << HCTSIZ_PKTCNT_SHIFT) | + (td->toggle ? (HCTSIZ_PID_DATA1 << HCTSIZ_PID_SHIFT) : + (HCTSIZ_PID_DATA0 << HCTSIZ_PID_SHIFT))); - hcchar = td->hcchar; - hcchar |= HCCHAR_EPDIR_IN; + DWC_OTG_WRITE_4(sc, DOTG_HCSPLT(channel), td->hcsplt); - /* receive complete split ASAP */ - if ((sc->sc_last_frame_num & 1) != 0) - hcchar |= HCCHAR_ODDFRM; - else - hcchar &= ~HCCHAR_ODDFRM; + hcchar = td->hcchar; + hcchar |= HCCHAR_EPDIR_IN; - /* must enable channel before data can be received */ - DWC_OTG_WRITE_4(sc, DOTG_HCCHAR(channel), hcchar); + /* receive complete split ASAP */ + if ((sc->sc_last_frame_num & 1) != 0 && + td->ep_type == UE_ISOCHRONOUS) + hcchar |= HCCHAR_ODDFRM; + else + hcchar &= ~HCCHAR_ODDFRM; + /* must enable channel before data can be received */ + DWC_OTG_WRITE_4(sc, DOTG_HCCHAR(channel), hcchar); + } /* wait until next slot before trying complete split */ td->tt_complete_slot = sc->sc_last_frame_num + 1; @@ -1442,7 +1479,7 @@ receive_spkt: goto busy; } - channel = td->channel; + channel = td->channel[0]; td->hcsplt &= ~HCSPLT_COMPSPLT; td->state = DWC_CHAN_ST_WAIT_S_ANE; @@ -1454,7 +1491,8 @@ receive_spkt: DWC_OTG_WRITE_4(sc, DOTG_HCSPLT(channel), td->hcsplt); /* send after next SOF event */ - if ((sc->sc_last_frame_num & 1) == 0) + if ((sc->sc_last_frame_num & 1) == 0 && + td->ep_type == UE_ISOCHRONOUS) td->hcchar |= HCCHAR_ODDFRM; else td->hcchar &= ~HCCHAR_ODDFRM; @@ -1609,10 +1647,12 @@ dwc_otg_host_data_tx(struct dwc_otg_soft uint32_t hcchar; uint8_t delta; uint8_t channel; + uint8_t x; dwc_otg_host_dump_rx(sc, td); - channel = td->channel; + /* check that last channel is complete */ + channel = td->channel[td->npkt]; if (channel < DWC_OTG_MAX_CHANNELS) { hcint = sc->sc_chan_state[channel].hcint; @@ -1655,14 +1695,18 @@ dwc_otg_host_data_tx(struct dwc_otg_soft case DWC_CHAN_ST_WAIT_ANE: if (hcint & (HCINT_RETRY | HCINT_ERRORS)) { - td->did_nak++; + td->did_nak = 1; td->tt_scheduled = 0; goto send_pkt; } else if (hcint & (HCINT_ACK | HCINT_NYET)) { td->offset += td->tx_bytes; td->remainder -= td->tx_bytes; td->toggle ^= 1; - td->did_nak = 0; + /* check if next response will be a NAK */ + if (hcint & HCINT_NYET) + td->did_nak = 1; + else + td->did_nak = 0; td->tt_scheduled = 0; /* check remainder */ @@ -1681,7 +1725,7 @@ dwc_otg_host_data_tx(struct dwc_otg_soft case DWC_CHAN_ST_WAIT_S_ANE: if (hcint & (HCINT_RETRY | HCINT_ERRORS)) { - td->did_nak++; + td->did_nak = 1; td->tt_scheduled = 0; goto send_pkt; } else if (hcint & (HCINT_ACK | HCINT_NYET)) { @@ -1694,7 +1738,7 @@ dwc_otg_host_data_tx(struct dwc_otg_soft if (hcint & HCINT_NYET) { goto send_cpkt; } else if (hcint & (HCINT_RETRY | HCINT_ERRORS)) { - td->did_nak++; + td->did_nak = 1; td->tt_scheduled = 0; goto send_pkt; } else if (hcint & HCINT_ACK) { @@ -1719,33 +1763,13 @@ dwc_otg_host_data_tx(struct dwc_otg_soft goto send_cpkt; case DWC_CHAN_ST_TX_WAIT_ISOC: - - /* Check if isochronous OUT traffic is complete */ + /* Check if ISOCHRONOUS OUT traffic is complete */ if ((hcint & HCINT_HCH_DONE_MASK) == 0) break; td->offset += td->tx_bytes; td->remainder -= td->tx_bytes; - - if (td->hcsplt != 0 || td->remainder == 0) - goto complete; - - /* check for next packet */ - if (td->max_packet_count > 1) - td->tt_xactpos++; - - /* free existing channel, if any */ - dwc_otg_host_channel_free(sc, td); - - td->state = DWC_CHAN_ST_TX_PKT_ISOC; - - /* FALLTHROUGH */ - - case DWC_CHAN_ST_TX_PKT_ISOC: - if (dwc_otg_host_channel_alloc(sc, td, 1)) - break; - channel = td->channel; - goto send_isoc_pkt; + goto complete; default: break; } @@ -1779,8 +1803,6 @@ send_pkt: goto busy; } - channel = td->channel; - /* set toggle, if any */ if (td->set_toggle) { td->set_toggle = 0; @@ -1788,8 +1810,7 @@ send_pkt: } if (td->ep_type == UE_ISOCHRONOUS) { -send_isoc_pkt: - /* Isochronous OUT transfers don't have any ACKs */ + /* ISOCHRONOUS OUT transfers don't have any ACKs */ td->state = DWC_CHAN_ST_TX_WAIT_ISOC; td->hcsplt &= ~HCSPLT_COMPSPLT; if (td->hcsplt != 0) { @@ -1803,122 +1824,110 @@ send_isoc_pkt: /* Update transaction position */ td->hcsplt &= ~HCSPLT_XACTPOS_MASK; td->hcsplt |= (HCSPLT_XACTPOS_ALL << HCSPLT_XACTPOS_SHIFT); - } else { - /* send one packet at a time */ - count = td->max_packet_size; - if (td->remainder < count) { - /* we have a short packet */ - td->short_pkt = 1; - count = td->remainder; - } } } else if (td->hcsplt != 0) { - td->hcsplt &= ~HCSPLT_COMPSPLT; - /* Wait for ACK/NAK/ERR from TT */ td->state = DWC_CHAN_ST_WAIT_S_ANE; - - /* send one packet at a time */ - count = td->max_packet_size; - if (td->remainder < count) { - /* we have a short packet */ - td->short_pkt = 1; - count = td->remainder; - } } else { /* Wait for ACK/NAK/STALL from device */ td->state = DWC_CHAN_ST_WAIT_ANE; + } + + td->tx_bytes = 0; + + for (x = 0; x != td->max_packet_count; x++) { + uint32_t rem_bytes; + + channel = td->channel[x]; /* send one packet at a time */ count = td->max_packet_size; - if (td->remainder < count) { + rem_bytes = td->remainder - td->tx_bytes; + if (rem_bytes < count) { /* we have a short packet */ td->short_pkt = 1; - count = td->remainder; + count = rem_bytes; } - } - - /* check for High-Speed multi-packets */ - if ((td->hcsplt == 0) && (td->max_packet_count > 1)) { - if (td->npkt == 0) { - if (td->remainder >= (3 * td->max_packet_size)) - td->npkt = 3; - else if (td->remainder >= (2 * td->max_packet_size)) - td->npkt = 2; - else - td->npkt = 1; - - if (td->npkt > td->max_packet_count) - td->npkt = td->max_packet_count; - - td->tt_xactpos = 1; /* overload */ - } - if (td->tt_xactpos == td->npkt) { - if (td->npkt == 1) { + if (count == rem_bytes) { + /* last packet */ + switch (x) { + case 0: DWC_OTG_WRITE_4(sc, DOTG_HCTSIZ(channel), (count << HCTSIZ_XFERSIZE_SHIFT) | (1 << HCTSIZ_PKTCNT_SHIFT) | - (HCTSIZ_PID_DATA0 << HCTSIZ_PID_SHIFT)); - } else if (td->npkt == 2) { + (td->toggle ? (HCTSIZ_PID_DATA1 << HCTSIZ_PID_SHIFT) : + (HCTSIZ_PID_DATA0 << HCTSIZ_PID_SHIFT))); + break; + case 1: DWC_OTG_WRITE_4(sc, DOTG_HCTSIZ(channel), (count << HCTSIZ_XFERSIZE_SHIFT) | (1 << HCTSIZ_PKTCNT_SHIFT) | (HCTSIZ_PID_DATA1 << HCTSIZ_PID_SHIFT)); - } else { + break; + default: DWC_OTG_WRITE_4(sc, DOTG_HCTSIZ(channel), (count << HCTSIZ_XFERSIZE_SHIFT) | (1 << HCTSIZ_PKTCNT_SHIFT) | (HCTSIZ_PID_DATA2 << HCTSIZ_PID_SHIFT)); + break; } - td->npkt = 0; - } else { + } else if (td->ep_type == UE_ISOCHRONOUS && + td->max_packet_count > 1) { + /* ISOCHRONOUS multi packet */ DWC_OTG_WRITE_4(sc, DOTG_HCTSIZ(channel), (count << HCTSIZ_XFERSIZE_SHIFT) | (1 << HCTSIZ_PKTCNT_SHIFT) | (HCTSIZ_PID_MDATA << HCTSIZ_PID_SHIFT)); + } else { + /* TODO: HCTSIZ_DOPNG */ + /* standard BULK/INTERRUPT/CONTROL packet */ + DWC_OTG_WRITE_4(sc, DOTG_HCTSIZ(channel), + (count << HCTSIZ_XFERSIZE_SHIFT) | + (1 << HCTSIZ_PKTCNT_SHIFT) | + (td->toggle ? (HCTSIZ_PID_DATA1 << HCTSIZ_PID_SHIFT) : + (HCTSIZ_PID_DATA0 << HCTSIZ_PID_SHIFT))); } - } else { - /* TODO: HCTSIZ_DOPNG */ - DWC_OTG_WRITE_4(sc, DOTG_HCTSIZ(channel), - (count << HCTSIZ_XFERSIZE_SHIFT) | - (1 << HCTSIZ_PKTCNT_SHIFT) | - (td->toggle ? (HCTSIZ_PID_DATA1 << HCTSIZ_PID_SHIFT) : - (HCTSIZ_PID_DATA0 << HCTSIZ_PID_SHIFT))); - } + DWC_OTG_WRITE_4(sc, DOTG_HCSPLT(channel), td->hcsplt); - DWC_OTG_WRITE_4(sc, DOTG_HCSPLT(channel), td->hcsplt); + hcchar = td->hcchar; + hcchar &= ~HCCHAR_EPDIR_IN; - hcchar = td->hcchar; - hcchar &= ~HCCHAR_EPDIR_IN; + /* send after next SOF event */ + if ((sc->sc_last_frame_num & 1) == 0 && + td->ep_type == UE_ISOCHRONOUS) + hcchar |= HCCHAR_ODDFRM; + else + hcchar &= ~HCCHAR_ODDFRM; - /* send after next SOF event */ - if ((sc->sc_last_frame_num & 1) == 0) *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable@freebsd.org Sat Aug 29 06:11:51 2015 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A56729C49B9; Sat, 29 Aug 2015 06:11:51 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9313B1491; Sat, 29 Aug 2015 06:11:51 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7T6BpCY027313; Sat, 29 Aug 2015 06:11:51 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7T6Bpto027107; Sat, 29 Aug 2015 06:11:51 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201508290611.t7T6Bpto027107@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Sat, 29 Aug 2015 06:11:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r287272 - stable/10/sys/dev/usb X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 29 Aug 2015 06:11:51 -0000 Author: hselasky Date: Sat Aug 29 06:11:50 2015 New Revision: 287272 URL: https://svnweb.freebsd.org/changeset/base/287272 Log: MFC r286799: Fix race in USB PF which can happen if we stop tracing exactly when the kernel is tapping an USB transfer. This leads to a NULL pointer access. The solution is to only trace while the USB bus lock is locked. Modified: stable/10/sys/dev/usb/usb_pf.c stable/10/sys/dev/usb/usb_transfer.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/usb/usb_pf.c ============================================================================== --- stable/10/sys/dev/usb/usb_pf.c Sat Aug 29 06:07:55 2015 (r287271) +++ stable/10/sys/dev/usb/usb_pf.c Sat Aug 29 06:11:50 2015 (r287272) @@ -220,7 +220,13 @@ usbpf_clone_destroy(struct if_clone *ifc ubus = ifp->if_softc; unit = ifp->if_dunit; + /* + * Lock USB before clearing the "ifp" pointer, to avoid + * clearing the pointer in the middle of a TAP operation: + */ + USB_BUS_LOCK(ubus); ubus->ifp = NULL; + USB_BUS_UNLOCK(ubus); bpfdetach(ifp); if_detach(ifp); if_free(ifp); Modified: stable/10/sys/dev/usb/usb_transfer.c ============================================================================== --- stable/10/sys/dev/usb/usb_transfer.c Sat Aug 29 06:07:55 2015 (r287271) +++ stable/10/sys/dev/usb/usb_transfer.c Sat Aug 29 06:11:50 2015 (r287272) @@ -2381,8 +2381,11 @@ usbd_callback_wrapper(struct usb_xfer_qu } #if USB_HAVE_PF - if (xfer->usb_state != USB_ST_SETUP) + if (xfer->usb_state != USB_ST_SETUP) { + USB_BUS_LOCK(info->bus); usbpf_xfertap(xfer, USBPF_XFERTAP_DONE); + USB_BUS_UNLOCK(info->bus); + } #endif /* call processing routine */ (xfer->callback) (xfer, xfer->error); From owner-svn-src-stable@freebsd.org Sat Aug 29 06:17:40 2015 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DEB519C4BF5; Sat, 29 Aug 2015 06:17:40 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CBD4D18DD; Sat, 29 Aug 2015 06:17:40 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7T6HeIB029307; Sat, 29 Aug 2015 06:17:40 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7T6HeXG029304; Sat, 29 Aug 2015 06:17:40 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201508290617.t7T6HeXG029304@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Sat, 29 Aug 2015 06:17:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r287273 - stable/9/sys/dev/usb X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 29 Aug 2015 06:17:41 -0000 Author: hselasky Date: Sat Aug 29 06:17:39 2015 New Revision: 287273 URL: https://svnweb.freebsd.org/changeset/base/287273 Log: MFC r286799: Fix race in USB PF which can happen if we stop tracing exactly when the kernel is tapping an USB transfer. This leads to a NULL pointer access. The solution is to only trace while the USB bus lock is locked. Modified: stable/9/sys/dev/usb/usb_pf.c stable/9/sys/dev/usb/usb_transfer.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) Modified: stable/9/sys/dev/usb/usb_pf.c ============================================================================== --- stable/9/sys/dev/usb/usb_pf.c Sat Aug 29 06:11:50 2015 (r287272) +++ stable/9/sys/dev/usb/usb_pf.c Sat Aug 29 06:17:39 2015 (r287273) @@ -103,13 +103,16 @@ usbpf_detach(struct usb_bus *ubus) { struct ifnet *ifp = ubus->ifp; + USB_BUS_LOCK(ubus); + ubus->ifp = NULL; + USB_BUS_UNLOCK(ubus); + if (ifp != NULL) { bpfdetach(ifp); if_down(ifp); if_detach(ifp); if_free(ifp); } - ubus->ifp = NULL; } static uint32_t Modified: stable/9/sys/dev/usb/usb_transfer.c ============================================================================== --- stable/9/sys/dev/usb/usb_transfer.c Sat Aug 29 06:11:50 2015 (r287272) +++ stable/9/sys/dev/usb/usb_transfer.c Sat Aug 29 06:17:39 2015 (r287273) @@ -2292,8 +2292,11 @@ usbd_callback_wrapper(struct usb_xfer_qu } #if USB_HAVE_PF - if (xfer->usb_state != USB_ST_SETUP) + if (xfer->usb_state != USB_ST_SETUP) { + USB_BUS_LOCK(info->bus); usbpf_xfertap(xfer, USBPF_XFERTAP_DONE); + USB_BUS_UNLOCK(info->bus); + } #endif /* call processing routine */ (xfer->callback) (xfer, xfer->error); From owner-svn-src-stable@freebsd.org Sat Aug 29 06:23:44 2015 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F081A9C4F32; Sat, 29 Aug 2015 06:23:43 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D4C931D71; Sat, 29 Aug 2015 06:23:43 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7T6Nhq0033407; Sat, 29 Aug 2015 06:23:43 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7T6Nf8W033399; Sat, 29 Aug 2015 06:23:41 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201508290623.t7T6Nf8W033399@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Sat, 29 Aug 2015 06:23:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r287274 - in stable/10/sys: boot/usb dev/usb dev/usb/controller X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 29 Aug 2015 06:23:44 -0000 Author: hselasky Date: Sat Aug 29 06:23:40 2015 New Revision: 287274 URL: https://svnweb.freebsd.org/changeset/base/287274 Log: MFC r286773: Improve the realtime properties of USB transfers for embedded systems like RPI-B and RPI-2. Modified: stable/10/sys/boot/usb/bsd_kernel.h stable/10/sys/dev/usb/controller/usb_controller.c stable/10/sys/dev/usb/usb_bus.h stable/10/sys/dev/usb/usb_device.c stable/10/sys/dev/usb/usb_hub.c stable/10/sys/dev/usb/usb_process.h stable/10/sys/dev/usb/usb_transfer.c stable/10/sys/dev/usb/usbdi.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/boot/usb/bsd_kernel.h ============================================================================== --- stable/10/sys/boot/usb/bsd_kernel.h Sat Aug 29 06:17:39 2015 (r287273) +++ stable/10/sys/boot/usb/bsd_kernel.h Sat Aug 29 06:23:40 2015 (r287274) @@ -42,7 +42,8 @@ #define M_USBDEV 0 #define USB_PROC_MAX 3 #define USB_BUS_GIANT_PROC(bus) (usb_process + 2) -#define USB_BUS_NON_GIANT_PROC(bus) (usb_process + 2) +#define USB_BUS_NON_GIANT_BULK_PROC(bus) (usb_process + 2) +#define USB_BUS_NON_GIANT_ISOC_PROC(bus) (usb_process + 2) #define USB_BUS_EXPLORE_PROC(bus) (usb_process + 0) #define USB_BUS_CONTROL_XFER_PROC(bus) (usb_process + 1) #define SYSCTL_DECL(...) Modified: stable/10/sys/dev/usb/controller/usb_controller.c ============================================================================== --- stable/10/sys/dev/usb/controller/usb_controller.c Sat Aug 29 06:17:39 2015 (r287273) +++ stable/10/sys/dev/usb/controller/usb_controller.c Sat Aug 29 06:23:40 2015 (r287274) @@ -233,7 +233,8 @@ usb_detach(device_t dev) /* Get rid of USB callback processes */ usb_proc_free(USB_BUS_GIANT_PROC(bus)); - usb_proc_free(USB_BUS_NON_GIANT_PROC(bus)); + usb_proc_free(USB_BUS_NON_GIANT_ISOC_PROC(bus)); + usb_proc_free(USB_BUS_NON_GIANT_BULK_PROC(bus)); /* Get rid of USB explore process */ @@ -397,7 +398,8 @@ usb_bus_explore(struct usb_proc_msg *pm) */ usb_proc_rewakeup(USB_BUS_CONTROL_XFER_PROC(bus)); usb_proc_rewakeup(USB_BUS_GIANT_PROC(bus)); - usb_proc_rewakeup(USB_BUS_NON_GIANT_PROC(bus)); + usb_proc_rewakeup(USB_BUS_NON_GIANT_ISOC_PROC(bus)); + usb_proc_rewakeup(USB_BUS_NON_GIANT_BULK_PROC(bus)); #endif USB_BUS_UNLOCK(bus); @@ -862,9 +864,13 @@ usb_attach_sub(device_t dev, struct usb_ &bus->bus_mtx, device_get_nameunit(dev), USB_PRI_MED)) { device_printf(dev, "WARNING: Creation of USB Giant " "callback process failed.\n"); - } else if (usb_proc_create(USB_BUS_NON_GIANT_PROC(bus), + } else if (usb_proc_create(USB_BUS_NON_GIANT_ISOC_PROC(bus), + &bus->bus_mtx, device_get_nameunit(dev), USB_PRI_HIGHEST)) { + device_printf(dev, "WARNING: Creation of USB non-Giant ISOC " + "callback process failed.\n"); + } else if (usb_proc_create(USB_BUS_NON_GIANT_BULK_PROC(bus), &bus->bus_mtx, device_get_nameunit(dev), USB_PRI_HIGH)) { - device_printf(dev, "WARNING: Creation of USB non-Giant " + device_printf(dev, "WARNING: Creation of USB non-Giant BULK " "callback process failed.\n"); } else if (usb_proc_create(USB_BUS_EXPLORE_PROC(bus), &bus->bus_mtx, device_get_nameunit(dev), USB_PRI_MED)) { Modified: stable/10/sys/dev/usb/usb_bus.h ============================================================================== --- stable/10/sys/dev/usb/usb_bus.h Sat Aug 29 06:17:39 2015 (r287273) +++ stable/10/sys/dev/usb/usb_bus.h Sat Aug 29 06:23:40 2015 (r287274) @@ -57,19 +57,26 @@ struct usb_bus { struct root_hold_token *bus_roothold; #endif +/* convenience macros */ +#define USB_BUS_TT_PROC(bus) USB_BUS_NON_GIANT_ISOC_PROC(bus) +#define USB_BUS_CS_PROC(bus) USB_BUS_NON_GIANT_ISOC_PROC(bus) + #if USB_HAVE_PER_BUS_PROCESS #define USB_BUS_GIANT_PROC(bus) (&(bus)->giant_callback_proc) -#define USB_BUS_NON_GIANT_PROC(bus) (&(bus)->non_giant_callback_proc) +#define USB_BUS_NON_GIANT_ISOC_PROC(bus) (&(bus)->non_giant_isoc_callback_proc) +#define USB_BUS_NON_GIANT_BULK_PROC(bus) (&(bus)->non_giant_bulk_callback_proc) #define USB_BUS_EXPLORE_PROC(bus) (&(bus)->explore_proc) #define USB_BUS_CONTROL_XFER_PROC(bus) (&(bus)->control_xfer_proc) - /* - * There are two callback processes. One for Giant locked - * callbacks. One for non-Giant locked callbacks. This should - * avoid congestion and reduce response time in most cases. + * There are three callback processes. One for Giant locked + * callbacks. One for non-Giant locked non-periodic callbacks + * and one for non-Giant locked periodic callbacks. This + * should avoid congestion and reduce response time in most + * cases. */ struct usb_process giant_callback_proc; - struct usb_process non_giant_callback_proc; + struct usb_process non_giant_isoc_callback_proc; + struct usb_process non_giant_bulk_callback_proc; /* Explore process */ struct usb_process explore_proc; Modified: stable/10/sys/dev/usb/usb_device.c ============================================================================== --- stable/10/sys/dev/usb/usb_device.c Sat Aug 29 06:17:39 2015 (r287273) +++ stable/10/sys/dev/usb/usb_device.c Sat Aug 29 06:23:40 2015 (r287274) @@ -2184,7 +2184,7 @@ usb_free_device(struct usb_device *udev, * anywhere: */ USB_BUS_LOCK(udev->bus); - usb_proc_mwait(USB_BUS_NON_GIANT_PROC(udev->bus), + usb_proc_mwait(USB_BUS_CS_PROC(udev->bus), &udev->cs_msg[0], &udev->cs_msg[1]); USB_BUS_UNLOCK(udev->bus); Modified: stable/10/sys/dev/usb/usb_hub.c ============================================================================== --- stable/10/sys/dev/usb/usb_hub.c Sat Aug 29 06:17:39 2015 (r287273) +++ stable/10/sys/dev/usb/usb_hub.c Sat Aug 29 06:23:40 2015 (r287274) @@ -349,7 +349,7 @@ uhub_tt_buffer_reset_async_locked(struct } up->req_reset_tt = req; /* get reset transfer started */ - usb_proc_msignal(USB_BUS_NON_GIANT_PROC(udev->bus), + usb_proc_msignal(USB_BUS_TT_PROC(udev->bus), &hub->tt_msg[0], &hub->tt_msg[1]); } #endif @@ -1592,7 +1592,7 @@ uhub_detach(device_t dev) #if USB_HAVE_TT_SUPPORT /* Make sure our TT messages are not queued anywhere */ USB_BUS_LOCK(bus); - usb_proc_mwait(USB_BUS_NON_GIANT_PROC(bus), + usb_proc_mwait(USB_BUS_TT_PROC(bus), &hub->tt_msg[0], &hub->tt_msg[1]); USB_BUS_UNLOCK(bus); #endif Modified: stable/10/sys/dev/usb/usb_process.h ============================================================================== --- stable/10/sys/dev/usb/usb_process.h Sat Aug 29 06:17:39 2015 (r287273) +++ stable/10/sys/dev/usb/usb_process.h Sat Aug 29 06:23:40 2015 (r287274) @@ -34,6 +34,7 @@ #endif /* defines */ +#define USB_PRI_HIGHEST PI_SWI(SWI_TTY) #define USB_PRI_HIGH PI_SWI(SWI_NET) #define USB_PRI_MED PI_SWI(SWI_CAMBIO) Modified: stable/10/sys/dev/usb/usb_transfer.c ============================================================================== --- stable/10/sys/dev/usb/usb_transfer.c Sat Aug 29 06:17:39 2015 (r287273) +++ stable/10/sys/dev/usb/usb_transfer.c Sat Aug 29 06:23:40 2015 (r287274) @@ -872,6 +872,19 @@ done: } } +static uint8_t +usbd_transfer_setup_has_bulk(const struct usb_config *setup_start, + uint16_t n_setup) +{ + while (n_setup--) { + uint8_t type = setup_start[n_setup].type; + if (type == UE_BULK || type == UE_BULK_INTR || + type == UE_TYPE_ANY) + return (1); + } + return (0); +} + /*------------------------------------------------------------------------* * usbd_transfer_setup - setup an array of USB transfers * @@ -1013,9 +1026,12 @@ usbd_transfer_setup(struct usb_device *u else if (xfer_mtx == &Giant) info->done_p = USB_BUS_GIANT_PROC(udev->bus); + else if (usbd_transfer_setup_has_bulk(setup_start, n_setup)) + info->done_p = + USB_BUS_NON_GIANT_BULK_PROC(udev->bus); else info->done_p = - USB_BUS_NON_GIANT_PROC(udev->bus); + USB_BUS_NON_GIANT_ISOC_PROC(udev->bus); } /* reset sizes */ @@ -2280,10 +2296,8 @@ usbd_callback_ss_done_defer(struct usb_x * will have a Lock Order Reversal, LOR, if we try to * proceed ! */ - if (usb_proc_msignal(info->done_p, - &info->done_m[0], &info->done_m[1])) { - /* ignore */ - } + (void) usb_proc_msignal(info->done_p, + &info->done_m[0], &info->done_m[1]); } else { /* clear second recurse flag */ pq->recurse_2 = 0; @@ -2307,23 +2321,26 @@ usbd_callback_wrapper(struct usb_xfer_qu struct usb_xfer_root *info = xfer->xroot; USB_BUS_LOCK_ASSERT(info->bus, MA_OWNED); - if (!mtx_owned(info->xfer_mtx) && !SCHEDULER_STOPPED()) { + if ((pq->recurse_3 != 0 || mtx_owned(info->xfer_mtx) == 0) && + SCHEDULER_STOPPED() == 0) { /* * Cases that end up here: * * 5) HW interrupt done callback or other source. + * 6) HW completed transfer during callback */ - DPRINTFN(3, "case 5\n"); + DPRINTFN(3, "case 5 and 6\n"); /* * We have to postpone the callback due to the fact we * will have a Lock Order Reversal, LOR, if we try to - * proceed ! + * proceed! + * + * Postponing the callback also ensures that other USB + * transfer queues get a chance. */ - if (usb_proc_msignal(info->done_p, - &info->done_m[0], &info->done_m[1])) { - /* ignore */ - } + (void) usb_proc_msignal(info->done_p, + &info->done_m[0], &info->done_m[1]); return; } /* @@ -2697,7 +2714,7 @@ usbd_pipe_start(struct usb_xfer_queue *p } else if (udev->ctrl_xfer[1]) { info = udev->ctrl_xfer[1]->xroot; usb_proc_msignal( - USB_BUS_NON_GIANT_PROC(info->bus), + USB_BUS_CS_PROC(info->bus), &udev->cs_msg[0], &udev->cs_msg[1]); } else { /* should not happen */ @@ -3022,9 +3039,11 @@ usb_command_wrapper(struct usb_xfer_queu if (!pq->recurse_1) { - do { + /* clear third recurse flag */ + pq->recurse_3 = 0; - /* set both recurse flags */ + do { + /* set two first recurse flags */ pq->recurse_1 = 1; pq->recurse_2 = 1; @@ -3043,6 +3062,12 @@ usb_command_wrapper(struct usb_xfer_queu (pq->command) (pq); DPRINTFN(6, "cb %p (leave)\n", pq->curr); + /* + * Set third recurse flag to indicate + * recursion happened: + */ + pq->recurse_3 = 1; + } while (!pq->recurse_2); /* clear first recurse flag */ @@ -3318,7 +3343,8 @@ usbd_transfer_poll(struct usb_xfer **ppx USB_BUS_CONTROL_XFER_PROC(udev->bus)->up_msleep = 0; USB_BUS_EXPLORE_PROC(udev->bus)->up_msleep = 0; USB_BUS_GIANT_PROC(udev->bus)->up_msleep = 0; - USB_BUS_NON_GIANT_PROC(udev->bus)->up_msleep = 0; + USB_BUS_NON_GIANT_ISOC_PROC(udev->bus)->up_msleep = 0; + USB_BUS_NON_GIANT_BULK_PROC(udev->bus)->up_msleep = 0; /* poll USB hardware */ (udev->bus->methods->xfer_poll) (udev->bus); Modified: stable/10/sys/dev/usb/usbdi.h ============================================================================== --- stable/10/sys/dev/usb/usbdi.h Sat Aug 29 06:17:39 2015 (r287273) +++ stable/10/sys/dev/usb/usbdi.h Sat Aug 29 06:23:40 2015 (r287274) @@ -128,6 +128,8 @@ struct usb_xfer_queue { void (*command) (struct usb_xfer_queue *pq); uint8_t recurse_1:1; uint8_t recurse_2:1; + uint8_t recurse_3:1; + uint8_t reserved:5; }; /* From owner-svn-src-stable@freebsd.org Sat Aug 29 06:28:49 2015 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BCE569C5138; Sat, 29 Aug 2015 06:28:49 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id AD07A81; Sat, 29 Aug 2015 06:28:49 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7T6Sn13033664; Sat, 29 Aug 2015 06:28:49 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7T6SnHY033662; Sat, 29 Aug 2015 06:28:49 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201508290628.t7T6SnHY033662@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Sat, 29 Aug 2015 06:28:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r287275 - stable/8/sys/dev/usb X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 29 Aug 2015 06:28:49 -0000 Author: hselasky Date: Sat Aug 29 06:28:48 2015 New Revision: 287275 URL: https://svnweb.freebsd.org/changeset/base/287275 Log: MFC r286799: Fix race in USB PF which can happen if we stop tracing exactly when the kernel is tapping an USB transfer. This leads to a NULL pointer access. The solution is to only trace while the USB bus lock is locked. Modified: stable/8/sys/dev/usb/usb_pf.c stable/8/sys/dev/usb/usb_transfer.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/dev/ (props changed) stable/8/sys/dev/usb/ (props changed) Modified: stable/8/sys/dev/usb/usb_pf.c ============================================================================== --- stable/8/sys/dev/usb/usb_pf.c Sat Aug 29 06:23:40 2015 (r287274) +++ stable/8/sys/dev/usb/usb_pf.c Sat Aug 29 06:28:48 2015 (r287275) @@ -103,13 +103,16 @@ usbpf_detach(struct usb_bus *ubus) { struct ifnet *ifp = ubus->ifp; + USB_BUS_LOCK(ubus); + ubus->ifp = NULL; + USB_BUS_UNLOCK(ubus); + if (ifp != NULL) { bpfdetach(ifp); if_down(ifp); if_detach(ifp); if_free(ifp); } - ubus->ifp = NULL; } static uint32_t Modified: stable/8/sys/dev/usb/usb_transfer.c ============================================================================== --- stable/8/sys/dev/usb/usb_transfer.c Sat Aug 29 06:23:40 2015 (r287274) +++ stable/8/sys/dev/usb/usb_transfer.c Sat Aug 29 06:28:48 2015 (r287275) @@ -2291,8 +2291,11 @@ usbd_callback_wrapper(struct usb_xfer_qu } #if USB_HAVE_PF - if (xfer->usb_state != USB_ST_SETUP) + if (xfer->usb_state != USB_ST_SETUP) { + USB_BUS_LOCK(info->bus); usbpf_xfertap(xfer, USBPF_XFERTAP_DONE); + USB_BUS_UNLOCK(info->bus); + } #endif /* call processing routine */ (xfer->callback) (xfer, xfer->error); From owner-svn-src-stable@freebsd.org Sat Aug 29 10:52:18 2015 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1A4459C4EC3; Sat, 29 Aug 2015 10:52:18 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0ABB63C2; Sat, 29 Aug 2015 10:52:18 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7TAqHLg048028; Sat, 29 Aug 2015 10:52:17 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7TAqH0a048026; Sat, 29 Aug 2015 10:52:17 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201508291052.t7TAqH0a048026@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Sat, 29 Aug 2015 10:52:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r287285 - stable/10/sys/dev/ata X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 29 Aug 2015 10:52:18 -0000 Author: mav Date: Sat Aug 29 10:52:16 2015 New Revision: 287285 URL: https://svnweb.freebsd.org/changeset/base/287285 Log: MFC r286814, r286816: Remove UMA allocation of ATA requests. After CAM replaced old ATA stack, this driver processes no more then one request at a time per channel. Using UMA after that is overkill, so replace it with simple preallocation of one request per channel. Modified: stable/10/sys/dev/ata/ata-all.c stable/10/sys/dev/ata/ata-all.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/ata/ata-all.c ============================================================================== --- stable/10/sys/dev/ata/ata-all.c Sat Aug 29 09:27:29 2015 (r287284) +++ stable/10/sys/dev/ata/ata-all.c Sat Aug 29 10:52:16 2015 (r287285) @@ -64,18 +64,15 @@ static void ata_cam_end_transaction(devi static void ata_cam_request_sense(device_t dev, struct ata_request *request); static int ata_check_ids(device_t dev, union ccb *ccb); static void ata_conn_event(void *context, int dummy); -static void ata_init(void); static void ata_interrupt_locked(void *data); static int ata_module_event_handler(module_t mod, int what, void *arg); static void ata_periodic_poll(void *data); static int ata_str2mode(const char *str); -static void ata_uninit(void); /* global vars */ MALLOC_DEFINE(M_ATA, "ata_generic", "ATA driver generic layer"); int (*ata_raid_ioctl_func)(u_long cmd, caddr_t data) = NULL; devclass_t ata_devclass; -uma_zone_t ata_request_zone; int ata_dma_check_80pin = 1; /* sysctl vars */ @@ -651,12 +648,7 @@ ata_cam_begin_transaction(device_t dev, struct ata_channel *ch = device_get_softc(dev); struct ata_request *request; - if (!(request = ata_alloc_request())) { - device_printf(dev, "FAILURE - out of memory in start\n"); - ccb->ccb_h.status = CAM_REQ_INVALID; - xpt_done(ccb); - return; - } + request = &ch->request; bzero(request, sizeof(*request)); /* setup request */ @@ -795,7 +787,6 @@ ata_cam_process_sense(device_t dev, stru ccb->ccb_h.status |= CAM_AUTOSENSE_FAIL; } - ata_free_request(request); xpt_done(ccb); /* Do error recovery if needed. */ if (fatalerr) @@ -866,10 +857,8 @@ ata_cam_end_transaction(device_t dev, st if ((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_SCSI_STATUS_ERROR && (ccb->ccb_h.flags & CAM_DIS_AUTOSENSE) == 0) ata_cam_request_sense(dev, request); - else { - ata_free_request(request); + else xpt_done(ccb); - } /* Do error recovery if needed. */ if (fatalerr) ata_reinit(dev); @@ -1149,18 +1138,3 @@ static moduledata_t ata_moduledata = { " DECLARE_MODULE(ata, ata_moduledata, SI_SUB_CONFIGURE, SI_ORDER_SECOND); MODULE_VERSION(ata, 1); MODULE_DEPEND(ata, cam, 1, 1, 1); - -static void -ata_init(void) -{ - ata_request_zone = uma_zcreate("ata_request", sizeof(struct ata_request), - NULL, NULL, NULL, NULL, 0, 0); -} -SYSINIT(ata_register, SI_SUB_DRIVERS, SI_ORDER_SECOND, ata_init, NULL); - -static void -ata_uninit(void) -{ - uma_zdestroy(ata_request_zone); -} -SYSUNINIT(ata_unregister, SI_SUB_DRIVERS, SI_ORDER_SECOND, ata_uninit, NULL); Modified: stable/10/sys/dev/ata/ata-all.h ============================================================================== --- stable/10/sys/dev/ata/ata-all.h Sat Aug 29 09:27:29 2015 (r287284) +++ stable/10/sys/dev/ata/ata-all.h Sat Aug 29 10:52:16 2015 (r287285) @@ -450,6 +450,7 @@ struct ata_channel { struct ata_cam_device curr[16]; /* Current settings */ int requestsense; /* CCB waiting for SENSE. */ struct callout poll_callout; /* Periodic status poll. */ + struct ata_request request; }; /* disk bay/enclosure related */ @@ -507,14 +508,6 @@ int ata_sata_getrev(device_t dev, int ta int ata_request2fis_h2d(struct ata_request *request, u_int8_t *fis); void ata_pm_identify(device_t dev); -/* macros for alloc/free of struct ata_request */ -extern uma_zone_t ata_request_zone; -#define ata_alloc_request() uma_zalloc(ata_request_zone, M_NOWAIT | M_ZERO) -#define ata_free_request(request) { \ - if (!(request->flags & ATA_R_DANGER2)) \ - uma_zfree(ata_request_zone, request); \ - } - MALLOC_DECLARE(M_ATA); /* misc newbus defines */ From owner-svn-src-stable@freebsd.org Sat Aug 29 10:53:54 2015 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 950379C4FF7; Sat, 29 Aug 2015 10:53:54 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 85C5F7C7; Sat, 29 Aug 2015 10:53:54 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7TArsLX048287; Sat, 29 Aug 2015 10:53:54 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7TArsFp048286; Sat, 29 Aug 2015 10:53:54 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201508291053.t7TArsFp048286@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Sat, 29 Aug 2015 10:53:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r287286 - stable/10/sys/cam/ata X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 29 Aug 2015 10:53:54 -0000 Author: mav Date: Sat Aug 29 10:53:53 2015 New Revision: 287286 URL: https://svnweb.freebsd.org/changeset/base/287286 Log: MFC r287025: Remove some code duplication by using biofinish(). Modified: stable/10/sys/cam/ata/ata_da.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cam/ata/ata_da.c ============================================================================== --- stable/10/sys/cam/ata/ata_da.c Sat Aug 29 10:52:16 2015 (r287285) +++ stable/10/sys/cam/ata/ata_da.c Sat Aug 29 10:53:53 2015 (r287286) @@ -1535,9 +1535,7 @@ adastart(struct cam_periph *periph, unio } else { /* This can happen if DMA was disabled. */ bioq_remove(&softc->trim_queue, bp); - bp->bio_error = EOPNOTSUPP; - bp->bio_flags |= BIO_ERROR; - biodone(bp); + biofinish(bp, NULL, EOPNOTSUPP); xpt_release_ccb(start_ccb); adaschedule(periph); return; @@ -1602,9 +1600,7 @@ adastart(struct cam_periph *periph, unio } } if (fail) { - bp->bio_error = EIO; - bp->bio_flags |= BIO_ERROR; - biodone(bp); + biofinish(bp, NULL, EIO); xpt_release_ccb(start_ccb); adaschedule(periph); return; From owner-svn-src-stable@freebsd.org Sat Aug 29 11:15:55 2015 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 431FA9C5A06; Sat, 29 Aug 2015 11:15:55 +0000 (UTC) (envelope-from avatar@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3381C115B; Sat, 29 Aug 2015 11:15:55 +0000 (UTC) (envelope-from avatar@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7TBFtJ3058745; Sat, 29 Aug 2015 11:15:55 GMT (envelope-from avatar@FreeBSD.org) Received: (from avatar@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7TBFt4J058744; Sat, 29 Aug 2015 11:15:55 GMT (envelope-from avatar@FreeBSD.org) Message-Id: <201508291115.t7TBFt4J058744@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avatar set sender to avatar@FreeBSD.org using -f From: Tai-hwa Liang Date: Sat, 29 Aug 2015 11:15:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r287287 - stable/10/sys/gnu/fs/reiserfs X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 29 Aug 2015 11:15:55 -0000 Author: avatar Date: Sat Aug 29 11:15:54 2015 New Revision: 287287 URL: https://svnweb.freebsd.org/changeset/base/287287 Log: MFC r286888: Using consistent coding style to deal with error inside the loop. Modified: stable/10/sys/gnu/fs/reiserfs/reiserfs_vfsops.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/gnu/fs/reiserfs/reiserfs_vfsops.c ============================================================================== --- stable/10/sys/gnu/fs/reiserfs/reiserfs_vfsops.c Sat Aug 29 10:53:53 2015 (r287286) +++ stable/10/sys/gnu/fs/reiserfs/reiserfs_vfsops.c Sat Aug 29 11:15:54 2015 (r287287) @@ -960,8 +960,8 @@ uint32_t find_hash_out(struct reiserfs_m key.on_disk_key.k_objectid, key.on_disk_key.k_dir_id); retval = search_by_entry_key(sbi, &key, &path, &de); if (retval == IO_ERROR) { - pathrelse(&path); - return (UNSET_HASH); + hash = UNSET_HASH; + break; } if (retval == NAME_NOT_FOUND) de.de_entry_num--; From owner-svn-src-stable@freebsd.org Sat Aug 29 11:15:59 2015 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A2B1A9C5A43; Sat, 29 Aug 2015 11:15:59 +0000 (UTC) (envelope-from avatar@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 65D74117D; Sat, 29 Aug 2015 11:15:59 +0000 (UTC) (envelope-from avatar@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7TBFxOQ058801; Sat, 29 Aug 2015 11:15:59 GMT (envelope-from avatar@FreeBSD.org) Received: (from avatar@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7TBFxnC058800; Sat, 29 Aug 2015 11:15:59 GMT (envelope-from avatar@FreeBSD.org) Message-Id: <201508291115.t7TBFxnC058800@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avatar set sender to avatar@FreeBSD.org using -f From: Tai-hwa Liang Date: Sat, 29 Aug 2015 11:15:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r287288 - stable/9/sys/dev/sound/midi X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 29 Aug 2015 11:15:59 -0000 Author: avatar Date: Sat Aug 29 11:15:58 2015 New Revision: 287288 URL: https://svnweb.freebsd.org/changeset/base/287288 Log: MFC r286886: Fixing typo as well as improving readability of a few comments. Modified: stable/9/sys/dev/sound/midi/midi.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) Modified: stable/9/sys/dev/sound/midi/midi.c ============================================================================== --- stable/9/sys/dev/sound/midi/midi.c Sat Aug 29 11:15:54 2015 (r287287) +++ stable/9/sys/dev/sound/midi/midi.c Sat Aug 29 11:15:58 2015 (r287288) @@ -86,7 +86,7 @@ enum midi_states { }; /* - * The MPU interface current has init() uninit() inqsize(( outqsize() + * The MPU interface current has init() uninit() inqsize() outqsize() * callback() : fiddle with the tx|rx status. */ @@ -160,10 +160,15 @@ DEFINE_CLASS(midisynth, midisynth_method /* * Module Exports & Interface * - * struct midi_chan *midi_init(MPU_CLASS cls, int unit, int chan) int - * midi_uninit(struct snd_midi *) 0 == no error EBUSY or other error int - * Midi_in(struct midi_chan *, char *buf, int count) int Midi_out(struct - * midi_chan *, char *buf, int count) + * struct midi_chan *midi_init(MPU_CLASS cls, int unit, int chan, + * void *cookie) + * int midi_uninit(struct snd_midi *) + * + * 0 == no error + * EBUSY or other error + * + * int midi_in(struct snd_midi *, char *buf, int count) + * int midi_out(struct snd_midi *, char *buf, int count) * * midi_{in,out} return actual size transfered * @@ -388,7 +393,7 @@ err0: mtx_unlock(&midistat_lock); /* * midi_uninit does not call MIDI_UNINIT, as since this is the implementors - * entry point. midi_unint if fact, does not send any methods. A call to + * entry point. midi_uninit if fact, does not send any methods. A call to * midi_uninit is a defacto promise that you won't manipulate ch anymore * */ From owner-svn-src-stable@freebsd.org Sat Aug 29 20:41:10 2015 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 27C1D9C5555; Sat, 29 Aug 2015 20:41:10 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 09971F2; Sat, 29 Aug 2015 20:41:10 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7TKf9bc008178; Sat, 29 Aug 2015 20:41:09 GMT (envelope-from jilles@FreeBSD.org) Received: (from jilles@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7TKf9TO008177; Sat, 29 Aug 2015 20:41:09 GMT (envelope-from jilles@FreeBSD.org) Message-Id: <201508292041.t7TKf9TO008177@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jilles set sender to jilles@FreeBSD.org using -f From: Jilles Tjoelker Date: Sat, 29 Aug 2015 20:41:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r287298 - stable/10/lib/libc/gen X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 29 Aug 2015 20:41:10 -0000 Author: jilles Date: Sat Aug 29 20:41:09 2015 New Revision: 287298 URL: https://svnweb.freebsd.org/changeset/base/287298 Log: MFC r279084,280713: setmode(): Use sysctl kern.proc.umask instead of umask() if possible. The kern.proc.umask. sysctl allows querying the umask without temporarily modifying it. r280713 is the actual change, while r279084 is a whitespace change. Modified: stable/10/lib/libc/gen/setmode.c Directory Properties: stable/10/ (props changed) Modified: stable/10/lib/libc/gen/setmode.c ============================================================================== --- stable/10/lib/libc/gen/setmode.c Sat Aug 29 19:47:20 2015 (r287297) +++ stable/10/lib/libc/gen/setmode.c Sat Aug 29 20:41:09 2015 (r287298) @@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$"); #include "namespace.h" #include #include +#include #include #include @@ -68,6 +69,7 @@ typedef struct bitcmd { #define CMD2_OBITS 0x08 #define CMD2_UBITS 0x10 +static mode_t getumask(void); static BITCMD *addcmd(BITCMD *, mode_t, mode_t, mode_t, mode_t); static void compress_mode(BITCMD *); #ifdef SETMODE_DEBUG @@ -169,7 +171,6 @@ setmode(const char *p) int serrno; char op, *ep; BITCMD *set, *saveset, *endset; - sigset_t sigset, sigoset; mode_t mask, perm, permXbits, who; long perml; int equalopdone; @@ -182,15 +183,9 @@ setmode(const char *p) /* * Get a copy of the mask for the permissions that are mask relative. - * Flip the bits, we want what's not set. Since it's possible that - * the caller is opening files inside a signal handler, protect them - * as best we can. + * Flip the bits, we want what's not set. */ - sigfillset(&sigset); - (void)_sigprocmask(SIG_BLOCK, &sigset, &sigoset); - (void)umask(mask = umask(0)); - mask = ~mask; - (void)_sigprocmask(SIG_SETMASK, &sigoset, NULL); + mask = ~getumask(); setlen = SET_LEN + 2; @@ -346,6 +341,35 @@ out: return NULL; } +static mode_t +getumask(void) +{ + sigset_t sigset, sigoset; + size_t len; + mode_t mask; + u_short smask; + + /* + * First try requesting the umask without temporarily modifying it. + * Note that this does not work if the sysctl + * security.bsd.unprivileged_proc_debug is set to 0. + */ + len = sizeof(smask); + if (sysctl((int[4]){ CTL_KERN, KERN_PROC, KERN_PROC_UMASK, getpid() }, + 4, &smask, &len, NULL, 0) == 0) + return (smask); + + /* + * Since it's possible that the caller is opening files inside a signal + * handler, protect them as best we can. + */ + sigfillset(&sigset); + (void)_sigprocmask(SIG_BLOCK, &sigset, &sigoset); + (void)umask(mask = umask(0)); + (void)_sigprocmask(SIG_SETMASK, &sigoset, NULL); + return (mask); +} + static BITCMD * addcmd(BITCMD *set, mode_t op, mode_t who, mode_t oparg, mode_t mask) {