From laffer1 at midnightbsd.org Tue Jan 28 15:46:47 2020 From: laffer1 at midnightbsd.org (laffer1 at midnightbsd.org) Date: Tue, 28 Jan 2020 15:46:47 -0500 (EST) Subject: [Midnightbsd-cvs] src [12294] trunk/lib/libfetch/fetch.c: fix a buffer overflow in libfetch Message-ID: <202001282046.00SKkl1B063614@stargazer.midnightbsd.org> Revision: 12294 http://svnweb.midnightbsd.org/src/?rev=12294 Author: laffer1 Date: 2020-01-28 15:46:46 -0500 (Tue, 28 Jan 2020) Log Message: ----------- fix a buffer overflow in libfetch Modified Paths: -------------- trunk/lib/libfetch/fetch.c Modified: trunk/lib/libfetch/fetch.c =================================================================== --- trunk/lib/libfetch/fetch.c 2020-01-01 00:05:39 UTC (rev 12293) +++ trunk/lib/libfetch/fetch.c 2020-01-28 20:46:46 UTC (rev 12294) @@ -329,6 +329,8 @@ } if (dlen-- > 0) *dst++ = c; + else + return (NULL); } return (s); } @@ -376,11 +378,15 @@ if (p && *p == '@') { /* username */ q = fetch_pctdecode(u->user, URL, URL_USERLEN); + if (q == NULL) + goto ouch; /* password */ - if (*q == ':') + if (*q == ':') { q = fetch_pctdecode(u->pwd, q + 1, URL_PWDLEN); - + if (q == NULL) + goto ouch; + } p++; } else { p = URL; From laffer1 at midnightbsd.org Tue Jan 28 15:47:10 2020 From: laffer1 at midnightbsd.org (laffer1 at midnightbsd.org) Date: Tue, 28 Jan 2020 15:47:10 -0500 (EST) Subject: [Midnightbsd-cvs] src [12295] stable/1.2/lib/libfetch/fetch.c: fix a buffer overflow in libfetch Message-ID: <202001282047.00SKlAqF063691@stargazer.midnightbsd.org> Revision: 12295 http://svnweb.midnightbsd.org/src/?rev=12295 Author: laffer1 Date: 2020-01-28 15:47:09 -0500 (Tue, 28 Jan 2020) Log Message: ----------- fix a buffer overflow in libfetch Modified Paths: -------------- stable/1.2/lib/libfetch/fetch.c Modified: stable/1.2/lib/libfetch/fetch.c =================================================================== --- stable/1.2/lib/libfetch/fetch.c 2020-01-28 20:46:46 UTC (rev 12294) +++ stable/1.2/lib/libfetch/fetch.c 2020-01-28 20:47:09 UTC (rev 12295) @@ -329,6 +329,8 @@ } if (dlen-- > 0) *dst++ = c; + else + return (NULL); } return (s); } @@ -376,11 +378,15 @@ if (p && *p == '@') { /* username */ q = fetch_pctdecode(u->user, URL, URL_USERLEN); + if (q == NULL) + goto ouch; /* password */ - if (*q == ':') + if (*q == ':') { q = fetch_pctdecode(u->pwd, q + 1, URL_PWDLEN); - + if (q == NULL) + goto ouch; + } p++; } else { p = URL; From laffer1 at midnightbsd.org Sun Feb 2 16:19:41 2020 From: laffer1 at midnightbsd.org (laffer1 at midnightbsd.org) Date: Sun, 2 Feb 2020 16:19:41 -0500 (EST) Subject: [Midnightbsd-cvs] src [12296] trunk/sys/dev/usb/wlan: update includes Message-ID: <202002022119.012LJfbe013175@stargazer.midnightbsd.org> Revision: 12296 http://svnweb.midnightbsd.org/src/?rev=12296 Author: laffer1 Date: 2020-02-02 16:19:40 -0500 (Sun, 02 Feb 2020) Log Message: ----------- update includes Modified Paths: -------------- trunk/sys/dev/usb/wlan/if_rsu.c trunk/sys/dev/usb/wlan/if_rum.c trunk/sys/dev/usb/wlan/if_run.c trunk/sys/dev/usb/wlan/if_uath.c trunk/sys/dev/usb/wlan/if_upgt.c trunk/sys/dev/usb/wlan/if_ural.c Modified: trunk/sys/dev/usb/wlan/if_rsu.c =================================================================== --- trunk/sys/dev/usb/wlan/if_rsu.c 2020-01-28 20:47:09 UTC (rev 12295) +++ trunk/sys/dev/usb/wlan/if_rsu.c 2020-02-02 21:19:40 UTC (rev 12296) @@ -17,7 +17,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include -__FBSDID("$FreeBSD: stable/10/sys/dev/usb/wlan/if_rsu.c 321981 2017-08-03 07:56:39Z hselasky $"); +__FBSDID("$FreeBSD: stable/10/sys/dev/usb/wlan/if_rsu.c 343760 2019-02-05 03:01:10Z avos $"); /* * Driver for Realtek RTL8188SU/RTL8191SU/RTL8192SU. @@ -36,13 +36,9 @@ #include #include #include -#include #include #include -#include -#include - #include #include #include Modified: trunk/sys/dev/usb/wlan/if_rum.c =================================================================== --- trunk/sys/dev/usb/wlan/if_rum.c 2020-01-28 20:47:09 UTC (rev 12295) +++ trunk/sys/dev/usb/wlan/if_rum.c 2020-02-02 21:19:40 UTC (rev 12296) @@ -1,5 +1,5 @@ /* $MidnightBSD$ */ -/* $FreeBSD: stable/10/sys/dev/usb/wlan/if_rum.c 269266 2014-07-29 21:59:24Z hselasky $ */ +/* $FreeBSD: stable/10/sys/dev/usb/wlan/if_rum.c 343760 2019-02-05 03:01:10Z avos $ */ /*- * Copyright (c) 2005-2007 Damien Bergamini @@ -20,7 +20,7 @@ */ #include -__FBSDID("$FreeBSD: stable/10/sys/dev/usb/wlan/if_rum.c 269266 2014-07-29 21:59:24Z hselasky $"); +__FBSDID("$FreeBSD: stable/10/sys/dev/usb/wlan/if_rum.c 343760 2019-02-05 03:01:10Z avos $"); /*- * Ralink Technology RT2501USB/RT2601USB chipset driver @@ -42,10 +42,6 @@ #include #include -#include -#include -#include - #include #include #include Modified: trunk/sys/dev/usb/wlan/if_run.c =================================================================== --- trunk/sys/dev/usb/wlan/if_run.c 2020-01-28 20:47:09 UTC (rev 12295) +++ trunk/sys/dev/usb/wlan/if_run.c 2020-02-02 21:19:40 UTC (rev 12296) @@ -19,7 +19,7 @@ */ #include -__FBSDID("$FreeBSD: stable/10/sys/dev/usb/wlan/if_run.c 292183 2015-12-14 09:24:40Z hselasky $"); +__FBSDID("$FreeBSD: stable/10/sys/dev/usb/wlan/if_run.c 343821 2019-02-06 02:18:11Z avos $"); /*- * Ralink Technology RT2700U/RT2800U/RT3000U/RT3900E chipset driver. @@ -43,10 +43,6 @@ #include #include -#include -#include -#include - #include #include #include @@ -1992,7 +1988,8 @@ static struct ieee80211_node * run_node_alloc(struct ieee80211vap *vap, const uint8_t mac[IEEE80211_ADDR_LEN]) { - return malloc(sizeof (struct run_node), M_DEVBUF, M_NOWAIT | M_ZERO); + return malloc(sizeof (struct run_node), M_80211_NODE, + M_NOWAIT | M_ZERO); } static int Modified: trunk/sys/dev/usb/wlan/if_uath.c =================================================================== --- trunk/sys/dev/usb/wlan/if_uath.c 2020-01-28 20:47:09 UTC (rev 12295) +++ trunk/sys/dev/usb/wlan/if_uath.c 2020-02-02 21:19:40 UTC (rev 12296) @@ -50,7 +50,7 @@ */ #include -__FBSDID("$FreeBSD: stable/10/sys/dev/usb/wlan/if_uath.c 262007 2014-02-17 01:36:53Z kevlo $"); +__FBSDID("$FreeBSD: stable/10/sys/dev/usb/wlan/if_uath.c 343760 2019-02-05 03:01:10Z avos $"); /*- * Driver for Atheros AR5523 USB parts. @@ -81,10 +81,6 @@ #include #include -#include -#include -#include - #include #include #include Modified: trunk/sys/dev/usb/wlan/if_upgt.c =================================================================== --- trunk/sys/dev/usb/wlan/if_upgt.c 2020-01-28 20:47:09 UTC (rev 12295) +++ trunk/sys/dev/usb/wlan/if_upgt.c 2020-02-02 21:19:40 UTC (rev 12296) @@ -1,6 +1,6 @@ /* $MidnightBSD$ */ /* $OpenBSD: if_upgt.c,v 1.35 2008/04/16 18:32:15 damien Exp $ */ -/* $FreeBSD: stable/10/sys/dev/usb/wlan/if_upgt.c 292183 2015-12-14 09:24:40Z hselasky $ */ +/* $FreeBSD: stable/10/sys/dev/usb/wlan/if_upgt.c 343816 2019-02-06 01:42:26Z avos $ */ /* * Copyright (c) 2007 Marcus Glocker @@ -39,7 +39,6 @@ #include #include -#include #include #include @@ -1702,7 +1701,7 @@ data_cmd->buflen = bsize; upgt_bulk_tx(sc, data_cmd); - DPRINTF(sc, UPGT_DEBUG_FW, "FW offset=%d, read=%d, sent=%d\n", + DPRINTF(sc, UPGT_DEBUG_FW, "FW offset=%zu, read=%d, sent=%d\n", offset, n, bsize); bsize = n; } @@ -1859,7 +1858,7 @@ } DPRINTF(sc, UPGT_DEBUG_FW, - "firmware Boot Record Area found at offset %d\n", offset); + "firmware Boot Record Area found at offset %zu\n", offset); /* * Parse Boot Record Area (BRA) options. Modified: trunk/sys/dev/usb/wlan/if_ural.c =================================================================== --- trunk/sys/dev/usb/wlan/if_ural.c 2020-01-28 20:47:09 UTC (rev 12295) +++ trunk/sys/dev/usb/wlan/if_ural.c 2020-02-02 21:19:40 UTC (rev 12296) @@ -1,5 +1,5 @@ /* $MidnightBSD$ */ -/* $FreeBSD: stable/10/sys/dev/usb/wlan/if_ural.c 269266 2014-07-29 21:59:24Z hselasky $ */ +/* $FreeBSD: stable/10/sys/dev/usb/wlan/if_ural.c 343760 2019-02-05 03:01:10Z avos $ */ /*- * Copyright (c) 2005, 2006 @@ -22,7 +22,7 @@ */ #include -__FBSDID("$FreeBSD: stable/10/sys/dev/usb/wlan/if_ural.c 269266 2014-07-29 21:59:24Z hselasky $"); +__FBSDID("$FreeBSD: stable/10/sys/dev/usb/wlan/if_ural.c 343760 2019-02-05 03:01:10Z avos $"); /*- * Ralink Technology RT2500USB chipset driver @@ -44,10 +44,6 @@ #include #include -#include -#include -#include - #include #include #include From laffer1 at midnightbsd.org Sun Feb 2 16:21:14 2020 From: laffer1 at midnightbsd.org (laffer1 at midnightbsd.org) Date: Sun, 2 Feb 2020 16:21:14 -0500 (EST) Subject: [Midnightbsd-cvs] src [12297] trunk/sys/dev/usb/serial: add additional device. Message-ID: <202002022121.012LLEno014040@stargazer.midnightbsd.org> Revision: 12297 http://svnweb.midnightbsd.org/src/?rev=12297 Author: laffer1 Date: 2020-02-02 16:21:13 -0500 (Sun, 02 Feb 2020) Log Message: ----------- add additional device. Modified Paths: -------------- trunk/sys/dev/usb/serial/u3g.c trunk/sys/dev/usb/serial/uchcom.c trunk/sys/dev/usb/serial/uplcom.c Modified: trunk/sys/dev/usb/serial/u3g.c =================================================================== --- trunk/sys/dev/usb/serial/u3g.c 2020-02-02 21:19:40 UTC (rev 12296) +++ trunk/sys/dev/usb/serial/u3g.c 2020-02-02 21:21:13 UTC (rev 12297) @@ -17,7 +17,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $FreeBSD: stable/10/sys/dev/usb/serial/u3g.c 329304 2018-02-15 08:57:14Z hselasky $ + * $FreeBSD: stable/10/sys/dev/usb/serial/u3g.c 342037 2018-12-13 10:34:26Z hselasky $ */ /* @@ -214,6 +214,7 @@ U3G_DEV(ALINK, 3G, 0), U3G_DEV(ALINK, 3GU, 0), U3G_DEV(ALINK, DWM652U5, 0), + U3G_DEV(ALINK, SIM7600E, 0), U3G_DEV(AMOI, H01, 0), U3G_DEV(AMOI, H01A, 0), U3G_DEV(AMOI, H02, 0), Modified: trunk/sys/dev/usb/serial/uchcom.c =================================================================== --- trunk/sys/dev/usb/serial/uchcom.c 2020-02-02 21:19:40 UTC (rev 12296) +++ trunk/sys/dev/usb/serial/uchcom.c 2020-02-02 21:21:13 UTC (rev 12297) @@ -57,7 +57,7 @@ */ #include -__FBSDID("$FreeBSD: stable/10/sys/dev/usb/serial/uchcom.c 263687 2014-03-24 13:48:04Z emaste $"); +__FBSDID("$FreeBSD: stable/10/sys/dev/usb/serial/uchcom.c 335627 2018-06-25 08:57:03Z avg $"); /* * Driver for WinChipHead CH341/340, the worst USB-serial chip in the @@ -121,11 +121,11 @@ #define UCHCOM_REG_BPS_MOD 0x14 #define UCHCOM_REG_BPS_PAD 0x0F #define UCHCOM_REG_BREAK1 0x05 -#define UCHCOM_REG_BREAK2 0x18 #define UCHCOM_REG_LCR1 0x18 #define UCHCOM_REG_LCR2 0x25 #define UCHCOM_VER_20 0x20 +#define UCHCOM_VER_30 0x30 #define UCHCOM_BASE_UNKNOWN 0 #define UCHCOM_BPS_MOD_BASE 20000000 @@ -134,12 +134,14 @@ #define UCHCOM_DTR_MASK 0x20 #define UCHCOM_RTS_MASK 0x40 -#define UCHCOM_BRK1_MASK 0x01 -#define UCHCOM_BRK2_MASK 0x40 +#define UCHCOM_BRK_MASK 0x01 #define UCHCOM_LCR1_MASK 0xAF #define UCHCOM_LCR2_MASK 0x07 -#define UCHCOM_LCR1_PARENB 0x80 +#define UCHCOM_LCR1_RX 0x80 +#define UCHCOM_LCR1_TX 0x40 +#define UCHCOM_LCR1_PARENB 0x08 +#define UCHCOM_LCR1_CS8 0x03 #define UCHCOM_LCR2_PAREVEN 0x07 #define UCHCOM_LCR2_PARODD 0x06 #define UCHCOM_LCR2_PARMARK 0x05 @@ -321,13 +323,17 @@ sc->sc_udev = uaa->device; - switch (uaa->info.bcdDevice) { - case UCHCOM_REV_CH340: + switch (uaa->info.idProduct) { + case USB_PRODUCT_WCH2_CH341SER: device_printf(dev, "CH340 detected\n"); break; - default: + case USB_PRODUCT_WCH2_CH341SER_2: device_printf(dev, "CH341 detected\n"); break; + default: + device_printf(dev, "New CH340/CH341 product 0x%04x detected\n", + uaa->info.idProduct); + break; } iface_index = UCHCOM_IFACE_INDEX; @@ -411,6 +417,8 @@ USETW(req.wIndex, index); USETW(req.wLength, 0); + DPRINTF("WR REQ 0x%02X VAL 0x%04X IDX 0x%04X\n", + reqno, value, index); ucom_cfg_do_request(sc->sc_udev, &sc->sc_ucom, &req, NULL, 0, 1000); } @@ -427,6 +435,8 @@ USETW(req.wIndex, index); USETW(req.wLength, buflen); + DPRINTF("RD REQ 0x%02X VAL 0x%04X IDX 0x%04X LEN %d\n", + reqno, value, index, buflen); ucom_cfg_do_request(sc->sc_udev, &sc->sc_ucom, &req, buf, USB_SHORT_XFER_OK, 1000); } @@ -501,6 +511,7 @@ uchcom_update_version(struct uchcom_softc *sc) { uchcom_get_version(sc, &sc->sc_version); + DPRINTF("Chip version: 0x%02x\n", sc->sc_version); } static void @@ -546,17 +557,17 @@ uint8_t brk1; uint8_t brk2; - uchcom_read_reg(sc, UCHCOM_REG_BREAK1, &brk1, UCHCOM_REG_BREAK2, &brk2); + uchcom_read_reg(sc, UCHCOM_REG_BREAK1, &brk1, UCHCOM_REG_LCR1, &brk2); if (onoff) { /* on - clear bits */ - brk1 &= ~UCHCOM_BRK1_MASK; - brk2 &= ~UCHCOM_BRK2_MASK; + brk1 &= ~UCHCOM_BRK_MASK; + brk2 &= ~UCHCOM_LCR1_TX; } else { /* off - set bits */ - brk1 |= UCHCOM_BRK1_MASK; - brk2 |= UCHCOM_BRK2_MASK; + brk1 |= UCHCOM_BRK_MASK; + brk2 |= UCHCOM_LCR1_TX; } - uchcom_write_reg(sc, UCHCOM_REG_BREAK1, brk1, UCHCOM_REG_BREAK2, brk2); + uchcom_write_reg(sc, UCHCOM_REG_BREAK1, brk1, UCHCOM_REG_LCR1, brk2); } static int @@ -608,8 +619,12 @@ if (uchcom_calc_divider_settings(&dv, rate)) return; + /* + * According to linux code we need to set bit 7 of UCHCOM_REG_BPS_PRE, + * otherwise the chip will buffer data. + */ uchcom_write_reg(sc, - UCHCOM_REG_BPS_PRE, dv.dv_prescaler, + UCHCOM_REG_BPS_PRE, dv.dv_prescaler | 0x80, UCHCOM_REG_BPS_DIV, dv.dv_div); uchcom_write_reg(sc, UCHCOM_REG_BPS_MOD, dv.dv_mod, @@ -674,6 +689,10 @@ default: return (EIO); } + if ((t->c_cflag & CSTOPB) != 0) + return (EIO); + if ((t->c_cflag & PARENB) != 0) + return (EIO); if (uchcom_calc_divider_settings(&dv, t->c_ospeed)) { return (EIO); @@ -686,11 +705,26 @@ { struct uchcom_softc *sc = ucom->sc_parent; - uchcom_get_version(sc, 0); + uchcom_get_version(sc, NULL); uchcom_ctrl_write(sc, UCHCOM_REQ_RESET, 0, 0); uchcom_set_baudrate(sc, t->c_ospeed); - uchcom_read_reg(sc, 0x18, 0, 0x25, 0); - uchcom_write_reg(sc, 0x18, 0x50, 0x25, 0x00); + if (sc->sc_version < UCHCOM_VER_30) { + uchcom_read_reg(sc, UCHCOM_REG_LCR1, NULL, + UCHCOM_REG_LCR2, NULL); + uchcom_write_reg(sc, UCHCOM_REG_LCR1, 0x50, + UCHCOM_REG_LCR2, 0x00); + } else { + /* + * Set up line control: + * - enable transmit and receive + * - set 8n1 mode + * To do: support other sizes, parity, stop bits. + */ + uchcom_write_reg(sc, + UCHCOM_REG_LCR1, + UCHCOM_LCR1_RX | UCHCOM_LCR1_TX | UCHCOM_LCR1_CS8, + UCHCOM_REG_LCR2, 0x00); + } uchcom_update_status(sc); uchcom_ctrl_write(sc, UCHCOM_REQ_RESET, 0x501f, 0xd90a); uchcom_set_baudrate(sc, t->c_ospeed); Modified: trunk/sys/dev/usb/serial/uplcom.c =================================================================== --- trunk/sys/dev/usb/serial/uplcom.c 2020-02-02 21:19:40 UTC (rev 12296) +++ trunk/sys/dev/usb/serial/uplcom.c 2020-02-02 21:21:13 UTC (rev 12297) @@ -2,7 +2,7 @@ /* $NetBSD: uplcom.c,v 1.21 2001/11/13 06:24:56 lukem Exp $ */ #include -__FBSDID("$FreeBSD: stable/10/sys/dev/usb/serial/uplcom.c 305557 2016-09-07 19:21:52Z dim $"); +__FBSDID("$FreeBSD: stable/10/sys/dev/usb/serial/uplcom.c 339853 2018-10-29 12:11:27Z hselasky $"); /*- * Copyright (c) 2001-2003, 2005 Shunsuke Akiyama . @@ -133,12 +133,20 @@ #define UPLCOM_SET_CRTSCTS 0x41 #define UPLCOM_SET_CRTSCTS_PL2303X 0x61 #define RSAQ_STATUS_CTS 0x80 +#define RSAQ_STATUS_OVERRUN_ERROR 0x40 +#define RSAQ_STATUS_PARITY_ERROR 0x20 +#define RSAQ_STATUS_FRAME_ERROR 0x10 +#define RSAQ_STATUS_RING 0x08 +#define RSAQ_STATUS_BREAK_ERROR 0x04 #define RSAQ_STATUS_DSR 0x02 #define RSAQ_STATUS_DCD 0x01 #define TYPE_PL2303 0 #define TYPE_PL2303HX 1 +#define TYPE_PL2303HXD 2 +#define UPLCOM_STATE_INDEX 8 + enum { UPLCOM_BULK_DT_WR, UPLCOM_BULK_DT_RD, @@ -367,18 +375,49 @@ sc->sc_udev = uaa->device; - /* Determine the chip type. This algorithm is taken from Linux. */ dd = usbd_get_device_descriptor(sc->sc_udev); - if (dd->bDeviceClass == 0x02) - sc->sc_chiptype = TYPE_PL2303; - else if (dd->bMaxPacketSize == 0x40) + + switch (UGETW(dd->bcdDevice)) { + case 0x0300: sc->sc_chiptype = TYPE_PL2303HX; - else - sc->sc_chiptype = TYPE_PL2303; + /* or TA, that is HX with external crystal */ + break; + case 0x0400: + sc->sc_chiptype = TYPE_PL2303HXD; + /* or EA, that is HXD with ESD protection */ + /* or RA, that has internal voltage level converter that works only up to 1Mbaud (!) */ + break; + case 0x0500: + sc->sc_chiptype = TYPE_PL2303HXD; + /* in fact it's TB, that is HXD with external crystal */ + break; + default: + /* NOTE: I have no info about the bcdDevice for the base PL2303 (up to 1.2Mbaud, + only fixed rates) and for PL2303SA (8-pin chip, up to 115200 baud */ + /* Determine the chip type. This algorithm is taken from Linux. */ + if (dd->bDeviceClass == 0x02) + sc->sc_chiptype = TYPE_PL2303; + else if (dd->bMaxPacketSize == 0x40) + sc->sc_chiptype = TYPE_PL2303HX; + else + sc->sc_chiptype = TYPE_PL2303; + break; + } - DPRINTF("chiptype: %s\n", - (sc->sc_chiptype == TYPE_PL2303HX) ? - "2303X" : "2303"); + switch (sc->sc_chiptype) { + case TYPE_PL2303: + DPRINTF("chiptype: 2303\n"); + break; + case TYPE_PL2303HX: + DPRINTF("chiptype: 2303HX/TA\n"); + break; + case TYPE_PL2303HXD: + DPRINTF("chiptype: 2303HXD/TB/RA/EA\n"); + break; + default: + DPRINTF("chiptype: unknown %d\n", sc->sc_chiptype); + break; + } /* * USB-RSAQ1 has two interface @@ -427,7 +466,7 @@ goto detach; } - if (sc->sc_chiptype != TYPE_PL2303HX) { + if (sc->sc_chiptype == TYPE_PL2303) { /* HX variants seem to lock up after a clear stall request. */ mtx_lock(&sc->sc_mtx); usbd_xfer_set_stall(sc->sc_xfer[UPLCOM_BULK_DT_WR]); @@ -434,6 +473,7 @@ usbd_xfer_set_stall(sc->sc_xfer[UPLCOM_BULK_DT_RD]); mtx_unlock(&sc->sc_mtx); } else { + /* reset upstream data pipes */ if (uplcom_pl2303_do(sc->sc_udev, UT_WRITE_VENDOR_DEVICE, UPLCOM_SET_REQUEST, 8, 0, 0) || uplcom_pl2303_do(sc->sc_udev, UT_WRITE_VENDOR_DEVICE, @@ -552,7 +592,7 @@ || uplcom_pl2303_do(udev, UT_WRITE_VENDOR_DEVICE, UPLCOM_SET_REQUEST, 1, 0, 0)) return (EIO); - if (chiptype == TYPE_PL2303HX) + if (chiptype != TYPE_PL2303) err = uplcom_pl2303_do(udev, UT_WRITE_VENDOR_DEVICE, UPLCOM_SET_REQUEST, 2, 0x44, 0); else err = uplcom_pl2303_do(udev, UT_WRITE_VENDOR_DEVICE, UPLCOM_SET_REQUEST, 2, 0x24, 0); @@ -632,23 +672,52 @@ &req, NULL, 0, 1000); } +/* + * NOTE: These baud rates are officially supported, they can be written + * directly into dwDTERate register. + * + * Free baudrate setting is not supported by the base PL2303, and on + * other models it requires writing a divisor value to dwDTERate instead + * of the raw baudrate. The formula for divisor calculation is not published + * by the vendor, so it is speculative, though the official product homepage + * refers to the Linux module source as a reference implementation. + */ static const uint32_t uplcom_rates[] = { - 75, 150, 300, 600, 1200, 1800, 2400, 3600, 4800, 7200, 9600, 14400, - 19200, 28800, 38400, 57600, 115200, /* - * Higher speeds are probably possible. PL2303X supports up to - * 6Mb and can set any rate + * Basic 'standard' speed rates, supported by all models + * NOTE: 900 and 56000 actually works as well */ - 230400, 460800, 614400, 921600, 1228800 + 75, 150, 300, 600, 900, 1200, 1800, 2400, 3600, 4800, 7200, 9600, 14400, + 19200, 28800, 38400, 56000, 57600, 115200, + /* + * Advanced speed rates up to 6Mbs, supported by HX/TA and HXD/TB/EA/RA + * NOTE: regardless of the spec, 256000 does not work + */ + 128000, 134400, 161280, 201600, 230400, 268800, 403200, 460800, 614400, + 806400, 921600, 1228800, 2457600, 3000000, 6000000, + /* + * Advanced speed rates up to 12, supported by HXD/TB/EA/RA + */ + 12000000 }; #define N_UPLCOM_RATES (sizeof(uplcom_rates)/sizeof(uplcom_rates[0])) static int +uplcom_baud_supported(unsigned int speed) +{ + int i; + for (i = 0; i < N_UPLCOM_RATES; i++) { + if (uplcom_rates[i] == speed) + return 1; + } + return 0; +} + +static int uplcom_pre_param(struct ucom_softc *ucom, struct termios *t) { struct uplcom_softc *sc = ucom->sc_parent; - uint8_t i; DPRINTF("\n"); @@ -656,20 +725,27 @@ * Check requested baud rate. * * The PL2303 can only set specific baud rates, up to 1228800 baud. - * The PL2303X can set any baud rate up to 6Mb. + * The PL2303HX can set any baud rate up to 6Mb. * The PL2303HX rev. D can set any baud rate up to 12Mb. * - * XXX: We currently cannot identify the PL2303HX rev. D, so treat - * it the same as the PL2303X. */ - if (sc->sc_chiptype != TYPE_PL2303HX) { - for (i = 0; i < N_UPLCOM_RATES; i++) { - if (uplcom_rates[i] == t->c_ospeed) + + /* accept raw divisor data, if someone wants to do the math in user domain */ + if (t->c_ospeed & 0x80000000) + return 0; + switch (sc->sc_chiptype) { + case TYPE_PL2303HXD: + if (t->c_ospeed <= 12000000) return (0); - } - } else { - if (t->c_ospeed <= 6000000) - return (0); + break; + case TYPE_PL2303HX: + if (t->c_ospeed <= 6000000) + return (0); + break; + default: + if (uplcom_baud_supported(t->c_ospeed)) + return (0); + break; } DPRINTF("uplcom_param: bad baud rate (%d)\n", t->c_ospeed); @@ -676,6 +752,48 @@ return (EIO); } +static unsigned int +uplcom_encode_baud_rate_divisor(uint8_t *buf, unsigned int baud) +{ + unsigned int baseline, mantissa, exponent; + + /* Determine the baud rate divisor. This algorithm is taken from Linux. */ + /* + * Apparently the formula is: + * baudrate = baseline / (mantissa * 4^exponent) + * where + * mantissa = buf[8:0] + * exponent = buf[11:9] + */ + if (baud == 0) + baud = 1; + baseline = 383385600; + mantissa = baseline / baud; + if (mantissa == 0) + mantissa = 1; + exponent = 0; + while (mantissa >= 512) { + if (exponent < 7) { + mantissa >>= 2; /* divide by 4 */ + exponent++; + } else { + /* Exponent is maxed. Trim mantissa and leave. This gives approx. 45.8 baud */ + mantissa = 511; + break; + } + } + + buf[3] = 0x80; + buf[2] = 0; + buf[1] = exponent << 1 | mantissa >> 8; + buf[0] = mantissa & 0xff; + + /* Calculate and return the exact baud rate. */ + baud = (baseline / mantissa) >> (exponent << 1); + DPRINTF("real baud rate will be %u\n", baud); + + return baud; +} static void uplcom_cfg_param(struct ucom_softc *ucom, struct termios *t) { @@ -687,10 +805,24 @@ memset(&ls, 0, sizeof(ls)); - USETDW(ls.dwDTERate, t->c_ospeed); + /* + * NOTE: If unsupported baud rates are set directly, the PL2303* uses 9600 baud. + */ + if ((t->c_ospeed & 0x80000000) || uplcom_baud_supported(t->c_ospeed)) + USETDW(ls.dwDTERate, t->c_ospeed); + else + t->c_ospeed = uplcom_encode_baud_rate_divisor((uint8_t*)&ls.dwDTERate, t->c_ospeed); if (t->c_cflag & CSTOPB) { - ls.bCharFormat = UCDC_STOP_BIT_2; + if ((t->c_cflag & CSIZE) == CS5) { + /* + * NOTE: Comply with "real" UARTs / RS232: + * use 1.5 instead of 2 stop bits with 5 data bits + */ + ls.bCharFormat = UCDC_STOP_BIT_1_5; + } else { + ls.bCharFormat = UCDC_STOP_BIT_2; + } } else { ls.bCharFormat = UCDC_STOP_BIT_1; } @@ -720,7 +852,7 @@ break; } - DPRINTF("rate=%d fmt=%d parity=%d bits=%d\n", + DPRINTF("rate=0x%08x fmt=%d parity=%d bits=%d\n", UGETDW(ls.dwDTERate), ls.bCharFormat, ls.bParityType, ls.bDataBits); @@ -741,7 +873,7 @@ req.bmRequestType = UT_WRITE_VENDOR_DEVICE; req.bRequest = UPLCOM_SET_REQUEST; USETW(req.wValue, 0); - if (sc->sc_chiptype == TYPE_PL2303HX) + if (sc->sc_chiptype != TYPE_PL2303) USETW(req.wIndex, UPLCOM_SET_CRTSCTS_PL2303X); else USETW(req.wIndex, UPLCOM_SET_CRTSCTS); @@ -831,18 +963,33 @@ pc = usbd_xfer_get_frame(xfer, 0); usbd_copy_out(pc, 0, buf, sizeof(buf)); - DPRINTF("status = 0x%02x\n", buf[8]); + DPRINTF("status = 0x%02x\n", buf[UPLCOM_STATE_INDEX]); sc->sc_lsr = 0; sc->sc_msr = 0; - if (buf[8] & RSAQ_STATUS_CTS) { + if (buf[UPLCOM_STATE_INDEX] & RSAQ_STATUS_CTS) { sc->sc_msr |= SER_CTS; } - if (buf[8] & RSAQ_STATUS_DSR) { + if (buf[UPLCOM_STATE_INDEX] & RSAQ_STATUS_OVERRUN_ERROR) { + sc->sc_lsr |= ULSR_OE; + } + if (buf[UPLCOM_STATE_INDEX] & RSAQ_STATUS_PARITY_ERROR) { + sc->sc_lsr |= ULSR_PE; + } + if (buf[UPLCOM_STATE_INDEX] & RSAQ_STATUS_FRAME_ERROR) { + sc->sc_lsr |= ULSR_FE; + } + if (buf[UPLCOM_STATE_INDEX] & RSAQ_STATUS_RING) { + sc->sc_msr |= SER_RI; + } + if (buf[UPLCOM_STATE_INDEX] & RSAQ_STATUS_BREAK_ERROR) { + sc->sc_lsr |= ULSR_BI; + } + if (buf[UPLCOM_STATE_INDEX] & RSAQ_STATUS_DSR) { sc->sc_msr |= SER_DSR; } - if (buf[8] & RSAQ_STATUS_DCD) { + if (buf[UPLCOM_STATE_INDEX] & RSAQ_STATUS_DCD) { sc->sc_msr |= SER_DCD; } ucom_status_change(&sc->sc_ucom); From laffer1 at midnightbsd.org Sun Feb 2 16:21:48 2020 From: laffer1 at midnightbsd.org (laffer1 at midnightbsd.org) Date: Sun, 2 Feb 2020 16:21:48 -0500 (EST) Subject: [Midnightbsd-cvs] src [12298] trunk/sys/dev/usb/net: add attack wait Message-ID: <202002022121.012LLmYN014143@stargazer.midnightbsd.org> Revision: 12298 http://svnweb.midnightbsd.org/src/?rev=12298 Author: laffer1 Date: 2020-02-02 16:21:47 -0500 (Sun, 02 Feb 2020) Log Message: ----------- add attack wait Modified Paths: -------------- trunk/sys/dev/usb/net/usb_ethernet.c trunk/sys/dev/usb/net/usb_ethernet.h Modified: trunk/sys/dev/usb/net/usb_ethernet.c =================================================================== --- trunk/sys/dev/usb/net/usb_ethernet.c 2020-02-02 21:21:13 UTC (rev 12297) +++ trunk/sys/dev/usb/net/usb_ethernet.c 2020-02-02 21:21:47 UTC (rev 12298) @@ -1,5 +1,5 @@ /* $MidnightBSD$ */ -/* $FreeBSD: stable/10/sys/dev/usb/net/usb_ethernet.c 262436 2014-02-24 08:50:06Z rodrigc $ */ +/* $FreeBSD: stable/10/sys/dev/usb/net/usb_ethernet.c 334758 2018-06-07 07:33:46Z hselasky $ */ /*- * Copyright (c) 2009 Andrew Thompson (thompsa at FreeBSD.org) * @@ -26,7 +26,7 @@ */ #include -__FBSDID("$FreeBSD: stable/10/sys/dev/usb/net/usb_ethernet.c 262436 2014-02-24 08:50:06Z rodrigc $"); +__FBSDID("$FreeBSD: stable/10/sys/dev/usb/net/usb_ethernet.c 334758 2018-06-07 07:33:46Z hselasky $"); #include #include @@ -188,6 +188,17 @@ return (error); } +void +uether_ifattach_wait(struct usb_ether *ue) +{ + + UE_LOCK(ue); + usb_proc_mwait(&ue->ue_tq, + &ue->ue_sync_task[0].hdr, + &ue->ue_sync_task[1].hdr); + UE_UNLOCK(ue); +} + static void ue_attach_post_task(struct usb_proc_msg *_task) { Modified: trunk/sys/dev/usb/net/usb_ethernet.h =================================================================== --- trunk/sys/dev/usb/net/usb_ethernet.h 2020-02-02 21:21:13 UTC (rev 12297) +++ trunk/sys/dev/usb/net/usb_ethernet.h 2020-02-02 21:21:47 UTC (rev 12298) @@ -1,5 +1,5 @@ /* $MidnightBSD$ */ -/* $FreeBSD: stable/10/sys/dev/usb/net/usb_ethernet.h 226709 2011-10-24 23:38:11Z yongari $ */ +/* $FreeBSD: stable/10/sys/dev/usb/net/usb_ethernet.h 334758 2018-06-07 07:33:46Z hselasky $ */ /*- * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. * @@ -24,7 +24,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: stable/10/sys/dev/usb/net/usb_ethernet.h 226709 2011-10-24 23:38:11Z yongari $ + * $FreeBSD: stable/10/sys/dev/usb/net/usb_ethernet.h 334758 2018-06-07 07:33:46Z hselasky $ */ #ifndef _USB_ETHERNET_H_ @@ -112,6 +112,7 @@ struct mii_data *uether_getmii(struct usb_ether *); void *uether_getsc(struct usb_ether *); int uether_ifattach(struct usb_ether *); +void uether_ifattach_wait(struct usb_ether *); void uether_ifdetach(struct usb_ether *); int uether_ifmedia_upd(struct ifnet *); void uether_init(void *); From laffer1 at midnightbsd.org Sun Feb 2 16:27:12 2020 From: laffer1 at midnightbsd.org (laffer1 at midnightbsd.org) Date: Sun, 2 Feb 2020 16:27:12 -0500 (EST) Subject: [Midnightbsd-cvs] src [12299] trunk/lib/libusb: sync libusb with freebsd 10 stable Message-ID: <202002022127.012LRCCl015476@stargazer.midnightbsd.org> Revision: 12299 http://svnweb.midnightbsd.org/src/?rev=12299 Author: laffer1 Date: 2020-02-02 16:27:11 -0500 (Sun, 02 Feb 2020) Log Message: ----------- sync libusb with freebsd 10 stable Modified Paths: -------------- trunk/lib/libusb/Makefile trunk/lib/libusb/libusb-0.1.pc trunk/lib/libusb/libusb-1.0.pc trunk/lib/libusb/libusb-2.0.pc trunk/lib/libusb/libusb10.c trunk/lib/libusb/libusb10.h trunk/lib/libusb/libusb10_hotplug.c trunk/lib/libusb/libusb10_io.c trunk/lib/libusb/libusb20.3 trunk/lib/libusb/libusb20.c trunk/lib/libusb/libusb20.h trunk/lib/libusb/libusb20_int.h trunk/lib/libusb/libusb20_ugen20.c Modified: trunk/lib/libusb/Makefile =================================================================== --- trunk/lib/libusb/Makefile 2020-02-02 21:21:47 UTC (rev 12298) +++ trunk/lib/libusb/Makefile 2020-02-02 21:27:11 UTC (rev 12299) @@ -1,6 +1,6 @@ # $MidnightBSD$ # -# $FreeBSD: stable/10/lib/libusb/Makefile 302275 2016-06-29 10:58:36Z hselasky $ +# $FreeBSD: stable/10/lib/libusb/Makefile 356399 2020-01-06 09:22:33Z hselasky $ # # Makefile for the FreeBSD specific LibUSB 2.0 # @@ -223,6 +223,7 @@ MLINKS += libusb20.3 libusb20_dev_get_info.3 MLINKS += libusb20.3 libusb20_dev_get_iface_desc.3 MLINKS += libusb20.3 libusb20_dev_get_desc.3 +MLINKS += libusb20.3 libusb20_dev_get_stats.3 MLINKS += libusb20.3 libusb20_dev_close.3 MLINKS += libusb20.3 libusb20_dev_detach_kernel_driver.3 MLINKS += libusb20.3 libusb20_dev_set_config_index.3 Modified: trunk/lib/libusb/libusb-0.1.pc =================================================================== --- trunk/lib/libusb/libusb-0.1.pc 2020-02-02 21:21:47 UTC (rev 12298) +++ trunk/lib/libusb/libusb-0.1.pc 2020-02-02 21:27:11 UTC (rev 12299) @@ -1,5 +1,4 @@ # $MidnightBSD$ -# $FreeBSD: stable/10/lib/libusb/libusb-0.1.pc 253637 2013-07-25 03:54:08Z rpaulo $ prefix=/usr exec_prefix=${prefix} libdir=${exec_prefix}/lib Modified: trunk/lib/libusb/libusb-1.0.pc =================================================================== --- trunk/lib/libusb/libusb-1.0.pc 2020-02-02 21:21:47 UTC (rev 12298) +++ trunk/lib/libusb/libusb-1.0.pc 2020-02-02 21:27:11 UTC (rev 12299) @@ -1,5 +1,4 @@ # $MidnightBSD$ -# $FreeBSD: stable/10/lib/libusb/libusb-1.0.pc 253637 2013-07-25 03:54:08Z rpaulo $ prefix=/usr exec_prefix=${prefix} libdir=${exec_prefix}/lib Modified: trunk/lib/libusb/libusb-2.0.pc =================================================================== --- trunk/lib/libusb/libusb-2.0.pc 2020-02-02 21:21:47 UTC (rev 12298) +++ trunk/lib/libusb/libusb-2.0.pc 2020-02-02 21:27:11 UTC (rev 12299) @@ -1,5 +1,4 @@ # $MidnightBSD$ -# $FreeBSD: stable/10/lib/libusb/libusb-2.0.pc 253637 2013-07-25 03:54:08Z rpaulo $ prefix=/usr exec_prefix=${prefix} libdir=${exec_prefix}/lib Modified: trunk/lib/libusb/libusb10.c =================================================================== --- trunk/lib/libusb/libusb10.c 2020-02-02 21:21:47 UTC (rev 12298) +++ trunk/lib/libusb/libusb10.c 2020-02-02 21:27:11 UTC (rev 12299) @@ -1,5 +1,5 @@ /* $MidnightBSD$ */ -/* $FreeBSD: stable/10/lib/libusb/libusb10.c 302275 2016-06-29 10:58:36Z hselasky $ */ +/* $FreeBSD: stable/10/lib/libusb/libusb10.c 345541 2019-03-26 13:46:47Z hselasky $ */ /*- * Copyright (c) 2009 Sylvestre Gallon. All rights reserved. * Copyright (c) 2009 Hans Petter Selasky. All rights reserved. @@ -113,6 +113,19 @@ fcntl(f, F_SETFL, flags); } +static void +libusb10_wakeup_event_loop(libusb_context *ctx) +{ + uint8_t dummy = 0; + int err; + + err = write(ctx->ctrl_pipe[1], &dummy, sizeof(dummy)); + if (err < (int)sizeof(dummy)) { + /* ignore error, if any */ + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "Waking up event loop failed!"); + } +} + int libusb_init(libusb_context **context) { @@ -483,7 +496,6 @@ { libusb_context *ctx = dev->ctx; struct libusb20_device *pdev = dev->os_priv; - uint8_t dummy; int err; if (devh == NULL) @@ -505,12 +517,8 @@ POLLOUT | POLLRDNORM | POLLWRNORM); /* make sure our event loop detects the new device */ - dummy = 0; - err = write(ctx->ctrl_pipe[1], &dummy, sizeof(dummy)); - if (err < (int)sizeof(dummy)) { - /* ignore error, if any */ - DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_open write failed!"); - } + libusb10_wakeup_event_loop(ctx); + *devh = pdev; return (0); @@ -530,7 +538,7 @@ if (ctx == NULL) return (NULL); /* be NULL safe */ - DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_open_device_width_vid_pid enter"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_open_device_with_vid_pid enter"); if ((i = libusb_get_device_list(ctx, &devs)) < 0) return (NULL); @@ -554,7 +562,7 @@ } libusb_free_device_list(devs, 1); - DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_open_device_width_vid_pid leave"); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_open_device_with_vid_pid leave"); return (pdev); } @@ -563,8 +571,6 @@ { libusb_context *ctx; struct libusb_device *dev; - uint8_t dummy; - int err; if (pdev == NULL) return; /* be NULL safe */ @@ -580,12 +586,7 @@ libusb_unref_device(dev); /* make sure our event loop detects the closed device */ - dummy = 0; - err = write(ctx->ctrl_pipe[1], &dummy, sizeof(dummy)); - if (err < (int)sizeof(dummy)) { - /* ignore error, if any */ - DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_close write failed!"); - } + libusb10_wakeup_event_loop(ctx); } libusb_device * @@ -1320,7 +1321,6 @@ int buffsize; int maxframe; int temp; - uint8_t dummy; dev = libusb_get_device(pdev); @@ -1421,10 +1421,8 @@ failure: libusb10_complete_transfer(pxfer0, sxfer, LIBUSB_TRANSFER_ERROR); - /* make sure our event loop spins the done handler */ - dummy = 0; - err = write(dev->ctx->ctrl_pipe[1], &dummy, sizeof(dummy)); + libusb10_wakeup_event_loop(dev->ctx); } /* The following function must be called unlocked */ @@ -1465,6 +1463,8 @@ (libusb20_tr_get_priv_sc1(pxfer0) == sxfer) || (libusb20_tr_get_priv_sc1(pxfer1) == sxfer)) { err = LIBUSB_ERROR_BUSY; + } else if (dev->device_is_gone != 0) { + err = LIBUSB_ERROR_NO_DEVICE; } else { /* set pending state */ @@ -1496,6 +1496,7 @@ struct libusb20_transfer *pxfer1; struct libusb_super_transfer *sxfer; struct libusb_device *dev; + struct libusb_device_handle *devh; uint8_t endpoint; int retval; @@ -1503,12 +1504,12 @@ return (LIBUSB_ERROR_INVALID_PARAM); /* check if not initialised */ - if (uxfer->dev_handle == NULL) + if ((devh = uxfer->dev_handle) == NULL) return (LIBUSB_ERROR_NOT_FOUND); endpoint = uxfer->endpoint; - dev = libusb_get_device(uxfer->dev_handle); + dev = libusb_get_device(devh); DPRINTF(dev->ctx, LIBUSB_DEBUG_FUNCTION, "libusb_cancel_transfer enter"); @@ -1519,8 +1520,8 @@ CTX_LOCK(dev->ctx); - pxfer0 = libusb10_get_transfer(uxfer->dev_handle, endpoint, 0); - pxfer1 = libusb10_get_transfer(uxfer->dev_handle, endpoint, 1); + pxfer0 = libusb10_get_transfer(devh, endpoint, 0); + pxfer1 = libusb10_get_transfer(devh, endpoint, 1); if (sxfer->state != LIBUSB_SUPER_XFER_ST_PEND) { /* only update the transfer status */ @@ -1532,6 +1533,8 @@ sxfer->entry.tqe_prev = NULL; libusb10_complete_transfer(NULL, sxfer, LIBUSB_TRANSFER_CANCELLED); + /* make sure our event loop spins the done handler */ + libusb10_wakeup_event_loop(dev->ctx); } else if (pxfer0 == NULL || pxfer1 == NULL) { /* not started */ retval = LIBUSB_ERROR_NOT_FOUND; @@ -1538,17 +1541,30 @@ } else if (libusb20_tr_get_priv_sc1(pxfer0) == sxfer) { libusb10_complete_transfer(pxfer0, sxfer, LIBUSB_TRANSFER_CANCELLED); - libusb20_tr_stop(pxfer0); - /* make sure the queue doesn't stall */ - libusb10_submit_transfer_sub( - uxfer->dev_handle, endpoint); + if (dev->device_is_gone != 0) { + /* clear transfer pointer */ + libusb20_tr_set_priv_sc1(pxfer0, NULL); + /* make sure our event loop spins the done handler */ + libusb10_wakeup_event_loop(dev->ctx); + } else { + libusb20_tr_stop(pxfer0); + /* make sure the queue doesn't stall */ + libusb10_submit_transfer_sub(devh, endpoint); + } } else if (libusb20_tr_get_priv_sc1(pxfer1) == sxfer) { libusb10_complete_transfer(pxfer1, sxfer, LIBUSB_TRANSFER_CANCELLED); - libusb20_tr_stop(pxfer1); - /* make sure the queue doesn't stall */ - libusb10_submit_transfer_sub( - uxfer->dev_handle, endpoint); + /* check if handle is still active */ + if (dev->device_is_gone != 0) { + /* clear transfer pointer */ + libusb20_tr_set_priv_sc1(pxfer1, NULL); + /* make sure our event loop spins the done handler */ + libusb10_wakeup_event_loop(dev->ctx); + } else { + libusb20_tr_stop(pxfer1); + /* make sure the queue doesn't stall */ + libusb10_submit_transfer_sub(devh, endpoint); + } } else { /* not started */ retval = LIBUSB_ERROR_NOT_FOUND; @@ -1577,6 +1593,35 @@ } } +UNEXPORTED void +libusb10_cancel_all_transfer_locked(struct libusb20_device *pdev, struct libusb_device *dev) +{ + struct libusb_super_transfer *sxfer; + unsigned x; + + for (x = 0; x != LIBUSB_NUM_SW_ENDPOINTS; x++) { + struct libusb20_transfer *xfer; + + xfer = libusb20_tr_get_pointer(pdev, x); + if (xfer == NULL) + continue; + if (libusb20_tr_pending(xfer) == 0) + continue; + sxfer = libusb20_tr_get_priv_sc1(xfer); + if (sxfer == NULL) + continue; + /* complete pending transfer */ + libusb10_complete_transfer(xfer, sxfer, LIBUSB_TRANSFER_ERROR); + } + + while ((sxfer = TAILQ_FIRST(&dev->tr_head))) { + TAILQ_REMOVE(&dev->tr_head, sxfer, entry); + + /* complete pending transfer */ + libusb10_complete_transfer(NULL, sxfer, LIBUSB_TRANSFER_ERROR); + } +} + uint16_t libusb_cpu_to_le16(uint16_t x) { Modified: trunk/lib/libusb/libusb10.h =================================================================== --- trunk/lib/libusb/libusb10.h 2020-02-02 21:21:47 UTC (rev 12298) +++ trunk/lib/libusb/libusb10.h 2020-02-02 21:27:11 UTC (rev 12299) @@ -1,5 +1,5 @@ /* $MidnightBSD$ */ -/* $FreeBSD: stable/10/lib/libusb/libusb10.h 302275 2016-06-29 10:58:36Z hselasky $ */ +/* $FreeBSD: stable/10/lib/libusb/libusb10.h 349669 2019-07-03 18:26:07Z hselasky $ */ /*- * Copyright (c) 2009 Sylvestre Gallon. All rights reserved. * @@ -40,22 +40,24 @@ #define HOTPLUG_LOCK(ctx) pthread_mutex_lock(&(ctx)->hotplug_lock) #define HOTPLUG_UNLOCK(ctx) pthread_mutex_unlock(&(ctx)->hotplug_lock) -#define DPRINTF(ctx, dbg, format, args...) do { \ - if ((ctx)->debug == dbg) { \ - switch (dbg) { \ - case LIBUSB_DEBUG_FUNCTION: \ - printf("LIBUSB_FUNCTION: " \ - format "\n", ## args); \ - break; \ - case LIBUSB_DEBUG_TRANSFER: \ - printf("LIBUSB_TRANSFER: " \ - format "\n", ## args); \ - break; \ - default: \ - break; \ - } \ - } \ -} while(0) +#define DPRINTF(ctx, dbg, format, ...) do { \ + switch (dbg) { \ + case LIBUSB_DEBUG_FUNCTION: \ + if ((ctx)->debug & LIBUSB_DEBUG_FUNCTION) { \ + printf("LIBUSB_FUNCTION: " \ + format "\n", ## __VA_ARGS__); \ + } \ + break; \ + case LIBUSB_DEBUG_TRANSFER: \ + if ((ctx)->debug & LIBUSB_DEBUG_TRANSFER) { \ + printf("LIBUSB_TRANSFER: " \ + format "\n", ## __VA_ARGS__); \ + } \ + break; \ + default: \ + break; \ + } \ +} while (0) /* internal structures */ @@ -86,6 +88,8 @@ void *user_data; }; +TAILQ_HEAD(libusb_device_head, libusb_device); + struct libusb_context { int debug; int debug_fixed; @@ -103,7 +107,7 @@ TAILQ_HEAD(, libusb_super_pollfd) pollfds; TAILQ_HEAD(, libusb_super_transfer) tr_done; TAILQ_HEAD(, libusb_hotplug_callback_handle_struct) hotplug_cbh; - TAILQ_HEAD(, libusb_device) hotplug_devs; + struct libusb_device_head hotplug_devs; struct libusb_super_pollfd ctx_poll; @@ -115,6 +119,8 @@ struct libusb_device { int refcnt; + int device_is_gone; + uint32_t claimed_interfaces; struct libusb_super_pollfd dev_poll; @@ -133,5 +139,6 @@ void libusb10_add_pollfd(libusb_context *ctx, struct libusb_super_pollfd *pollfd, struct libusb20_device *pdev, int fd, short events); void libusb10_remove_pollfd(libusb_context *ctx, struct libusb_super_pollfd *pollfd); void libusb10_cancel_all_transfer(libusb_device *dev); +void libusb10_cancel_all_transfer_locked(struct libusb20_device *pdev, struct libusb_device *dev); #endif /* __LIBUSB10_H__ */ Modified: trunk/lib/libusb/libusb10_hotplug.c =================================================================== --- trunk/lib/libusb/libusb10_hotplug.c 2020-02-02 21:21:47 UTC (rev 12298) +++ trunk/lib/libusb/libusb10_hotplug.c 2020-02-02 21:27:11 UTC (rev 12299) @@ -1,7 +1,7 @@ /* $MidnightBSD$ */ -/* $FreeBSD: stable/10/lib/libusb/libusb10_hotplug.c 302275 2016-06-29 10:58:36Z hselasky $ */ +/* $FreeBSD: stable/10/lib/libusb/libusb10_hotplug.c 349669 2019-07-03 18:26:07Z hselasky $ */ /*- - * Copyright (c) 2016 Hans Petter Selasky. All rights reserved. + * Copyright (c) 2016-2019 Hans Petter Selasky. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -86,20 +86,35 @@ return (pcbh->fn(ctx, dev, event, pcbh->user_data)); } +static int +libusb_hotplug_enumerate(libusb_context *ctx, struct libusb_device_head *phead) +{ + libusb_device **ppdev; + ssize_t count; + ssize_t x; + + count = libusb_get_device_list(ctx, &ppdev); + if (count < 0) + return (-1); + + for (x = 0; x != count; x++) + TAILQ_INSERT_TAIL(phead, ppdev[x], hotplug_entry); + + libusb_free_device_list(ppdev, 0); + return (0); +} + static void * libusb_hotplug_scan(void *arg) { - TAILQ_HEAD(, libusb_device) hotplug_devs; + struct libusb_device_head hotplug_devs; libusb_hotplug_callback_handle acbh; libusb_hotplug_callback_handle bcbh; libusb_context *ctx = arg; - libusb_device **ppdev; libusb_device *temp; libusb_device *adev; libusb_device *bdev; unsigned do_loop = 1; - ssize_t count; - ssize_t x; while (do_loop) { usleep(4000000); @@ -109,14 +124,8 @@ TAILQ_INIT(&hotplug_devs); if (ctx->hotplug_handler != NO_THREAD) { - count = libusb_get_device_list(ctx, &ppdev); - if (count < 0) + if (libusb_hotplug_enumerate(ctx, &hotplug_devs) < 0) continue; - for (x = 0; x != count; x++) { - TAILQ_INSERT_TAIL(&hotplug_devs, ppdev[x], - hotplug_entry); - } - libusb_free_device_list(ppdev, 0); } else { do_loop = 0; } @@ -192,6 +201,8 @@ HOTPLUG_LOCK(ctx); if (ctx->hotplug_handler == NO_THREAD) { + libusb_hotplug_enumerate(ctx, &ctx->hotplug_devs); + if (pthread_create(&ctx->hotplug_handler, NULL, &libusb_hotplug_scan, ctx) != 0) ctx->hotplug_handler = NO_THREAD; Modified: trunk/lib/libusb/libusb10_io.c =================================================================== --- trunk/lib/libusb/libusb10_io.c 2020-02-02 21:21:47 UTC (rev 12298) +++ trunk/lib/libusb/libusb10_io.c 2020-02-02 21:27:11 UTC (rev 12299) @@ -1,5 +1,5 @@ /* $MidnightBSD$ */ -/* $FreeBSD: stable/10/lib/libusb/libusb10_io.c 302275 2016-06-29 10:58:36Z hselasky $ */ +/* $FreeBSD: stable/10/lib/libusb/libusb10_io.c 339190 2018-10-05 07:50:44Z hselasky $ */ /*- * Copyright (c) 2009 Sylvestre Gallon. All rights reserved. * @@ -160,17 +160,19 @@ if (ppdev[i] != NULL) { dev = libusb_get_device(ppdev[i]); - if (fds[i].revents == 0) - err = 0; /* nothing to do */ - else + if (fds[i].revents != 0) { err = libusb20_dev_process(ppdev[i]); - if (err) { - /* cancel all transfers - device is gone */ - libusb10_cancel_all_transfer(dev); + if (err) { + /* set device is gone */ + dev->device_is_gone = 1; - /* remove USB device from polling loop */ - libusb10_remove_pollfd(dev->ctx, &dev->dev_poll); + /* remove USB device from polling loop */ + libusb10_remove_pollfd(dev->ctx, &dev->dev_poll); + + /* cancel all pending transfers */ + libusb10_cancel_all_transfer_locked(ppdev[i], dev); + } } CTX_UNLOCK(ctx); libusb_unref_device(dev); @@ -179,10 +181,8 @@ } else { uint8_t dummy; - while (1) { - if (read(fds[i].fd, &dummy, 1) != 1) - break; - } + while (read(fds[i].fd, &dummy, 1) == 1) + ; } } @@ -311,6 +311,9 @@ if (tv == NULL) { pthread_cond_wait(&ctx->ctx_cond, &ctx->ctx_lock); + /* try to grab polling of actual events, if any */ + if (ctx->ctx_handler == NO_THREAD) + ctx->ctx_handler = pthread_self(); return (0); } err = clock_gettime(CLOCK_MONOTONIC, &ts); @@ -329,6 +332,9 @@ } err = pthread_cond_timedwait(&ctx->ctx_cond, &ctx->ctx_lock, &ts); + /* try to grab polling of actual events, if any */ + if (ctx->ctx_handler == NO_THREAD) + ctx->ctx_handler = pthread_self(); if (err == ETIMEDOUT) return (1); @@ -488,6 +494,19 @@ return (actlen); } +static libusb_context * +libusb10_get_context_by_device_handle(libusb_device_handle *devh) +{ + libusb_context *ctx; + + if (devh != NULL) + ctx = libusb_get_device(devh)->ctx; + else + ctx = NULL; + + return (GET_CONTEXT(ctx)); +} + static void libusb10_do_transfer_cb(struct libusb_transfer *transfer) { @@ -494,7 +513,7 @@ libusb_context *ctx; int *pdone; - ctx = GET_CONTEXT(NULL); + ctx = libusb10_get_context_by_device_handle(transfer->dev_handle); DPRINTF(ctx, LIBUSB_DEBUG_TRANSFER, "sync I/O done"); @@ -584,7 +603,8 @@ libusb_context *ctx; int ret; - ctx = GET_CONTEXT(NULL); + ctx = libusb10_get_context_by_device_handle(devh); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_bulk_transfer enter"); ret = libusb10_do_transfer(devh, endpoint, data, length, transferred, @@ -602,7 +622,8 @@ libusb_context *ctx; int ret; - ctx = GET_CONTEXT(NULL); + ctx = libusb10_get_context_by_device_handle(devh); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_interrupt_transfer enter"); ret = libusb10_do_transfer(devh, endpoint, data, length, transferred, Modified: trunk/lib/libusb/libusb20.3 =================================================================== --- trunk/lib/libusb/libusb20.3 2020-02-02 21:21:47 UTC (rev 12298) +++ trunk/lib/libusb/libusb20.3 2020-02-02 21:27:11 UTC (rev 12299) @@ -1,6 +1,6 @@ .\" $MidnightBSD$ .\" -.\" Copyright (c) 2008 Hans Petter Selasky +.\" Copyright (c) 2008-2019 Hans Petter Selasky .\" .\" All rights reserved. .\" @@ -25,9 +25,9 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD: stable/10/lib/libusb/libusb20.3 250582 2013-05-12 22:22:12Z joel $ +.\" $FreeBSD: stable/10/lib/libusb/libusb20.3 356399 2020-01-06 09:22:33Z hselasky $ .\" -.Dd May 3, 2013 +.Dd December 27, 2019 .Dt LIBUSB20 3 .Os .Sh NAME @@ -123,6 +123,8 @@ .Ft const char * .Fn libusb20_dev_get_desc "struct libusb20_device *pdev" .Ft int +.Fn libusb20_dev_get_stats "struct libusb20_device *pdev" "struct libusb20_device_stats *pstats" +.Ft int .Fn libusb20_dev_close "struct libusb20_device *pdev" .Ft int .Fn libusb20_dev_detach_kernel_driver "struct libusb20_device *pdev" "uint8_t iface_index" @@ -598,6 +600,14 @@ . .Pp . +.Fn libusb20_dev_get_stats +retrieves the device statistics into the structure pointed to by the +.Fa pstats +argument. +This function returns zero on success else a LIBUSB20_ERROR value is returned. +. +.Pp +. .Fn libusb20_dev_close will close the given USB device. . Modified: trunk/lib/libusb/libusb20.c =================================================================== --- trunk/lib/libusb/libusb20.c 2020-02-02 21:21:47 UTC (rev 12298) +++ trunk/lib/libusb/libusb20.c 2020-02-02 21:27:11 UTC (rev 12299) @@ -1,5 +1,5 @@ /* $MidnightBSD$ */ -/* $FreeBSD: stable/10/lib/libusb/libusb20.c 305641 2016-09-09 06:27:25Z hselasky $ */ +/* $FreeBSD: stable/10/lib/libusb/libusb20.c 356399 2020-01-06 09:22:33Z hselasky $ */ /*- * Copyright (c) 2008-2009 Hans Petter Selasky. All rights reserved. * @@ -78,6 +78,7 @@ #define dummy_get_power_mode (void *)dummy_int #define dummy_get_port_path (void *)dummy_int #define dummy_get_power_usage (void *)dummy_int +#define dummy_get_stats (void *)dummy_int #define dummy_kernel_driver_active (void *)dummy_int #define dummy_detach_kernel_driver (void *)dummy_int #define dummy_do_request_sync (void *)dummy_int @@ -795,6 +796,7 @@ { struct LIBUSB20_CONTROL_SETUP_DECODED req; int error; + int flags; /* make sure memory is initialised */ memset(ptr, 0, len); @@ -821,22 +823,24 @@ error = libusb20_dev_request_sync(pdev, &req, ptr, NULL, 1000, LIBUSB20_TRANSFER_SINGLE_SHORT_NOT_OK); if (error) { - return (error); + /* try to request full string */ + req.wLength = 255; + flags = 0; + } else { + /* extract length and request full string */ + req.wLength = *(uint8_t *)ptr; + flags = LIBUSB20_TRANSFER_SINGLE_SHORT_NOT_OK; } - req.wLength = *(uint8_t *)ptr; /* bytes */ if (req.wLength > len) { /* partial string read */ req.wLength = len; } - error = libusb20_dev_request_sync(pdev, &req, - ptr, NULL, 1000, LIBUSB20_TRANSFER_SINGLE_SHORT_NOT_OK); + error = libusb20_dev_request_sync(pdev, &req, ptr, NULL, 1000, flags); + if (error) + return (error); - if (error) { - return (error); - } - if (((uint8_t *)ptr)[1] != LIBUSB20_DT_STRING) { + if (((uint8_t *)ptr)[1] != LIBUSB20_DT_STRING) return (LIBUSB20_ERROR_OTHER); - } return (0); /* success */ } @@ -933,6 +937,14 @@ uint8_t do_close; int error; + /* + * Catch invalid configuration descriptor reads early on to + * avoid issues with devices that don't check for a valid USB + * configuration read request. + */ + if (configIndex >= pdev->ddesc.bNumConfigurations) + return (NULL); + if (!pdev->is_opened) { error = libusb20_dev_open(pdev, 0); if (error) { @@ -1019,6 +1031,31 @@ return (pdev->usb_speed); } +int +libusb20_dev_get_stats(struct libusb20_device *pdev, struct libusb20_device_stats *pstats) +{ + uint8_t do_close; + int error; + + if (!pdev->is_opened) { + error = libusb20_dev_open(pdev, 0); + if (error == 0) { + do_close = 1; + } else { + do_close = 0; + } + } else { + do_close = 0; + } + + error = pdev->methods->get_stats(pdev, pstats); + + if (do_close) + (void) libusb20_dev_close(pdev); + + return (error); +} + /* if this function returns an error, the device is gone */ int libusb20_dev_process(struct libusb20_device *pdev) Modified: trunk/lib/libusb/libusb20.h =================================================================== --- trunk/lib/libusb/libusb20.h 2020-02-02 21:21:47 UTC (rev 12298) +++ trunk/lib/libusb/libusb20.h 2020-02-02 21:27:11 UTC (rev 12299) @@ -1,5 +1,5 @@ /* $MidnightBSD$ */ -/* $FreeBSD: stable/10/lib/libusb/libusb20.h 250201 2013-05-03 07:44:58Z hselasky $ */ +/* $FreeBSD: stable/10/lib/libusb/libusb20.h 356399 2020-01-06 09:22:33Z hselasky $ */ /*- * Copyright (c) 2008-2009 Hans Petter Selasky. All rights reserved. * Copyright (c) 2007-2008 Daniel Drake. All rights reserved. @@ -194,6 +194,12 @@ char quirkname[64 - 12]; }; +struct libusb20_device_stats { + uint64_t xfer_ok[4]; /* sorted by USB transfer type, UE_XXX */ + uint64_t xfer_fail[4]; /* sorted by USB transfer type, UE_XXX */ + uint64_t xfer_reserved[24]; /* reserved */ +}; + #define LIBUSB20_MAX_FRAME_PRE_SCALE (1U << 31) /* USB transfer operations */ @@ -242,6 +248,7 @@ int libusb20_dev_set_config_index(struct libusb20_device *pdev, uint8_t configIndex); int libusb20_dev_get_debug(struct libusb20_device *pdev); int libusb20_dev_get_fd(struct libusb20_device *pdev); +int libusb20_dev_get_stats(struct libusb20_device *pdev, struct libusb20_device_stats *pstat); int libusb20_dev_kernel_driver_active(struct libusb20_device *pdev, uint8_t iface_index); int libusb20_dev_open(struct libusb20_device *pdev, uint16_t transfer_max); int libusb20_dev_process(struct libusb20_device *pdev); Modified: trunk/lib/libusb/libusb20_int.h =================================================================== --- trunk/lib/libusb/libusb20_int.h 2020-02-02 21:21:47 UTC (rev 12298) +++ trunk/lib/libusb/libusb20_int.h 2020-02-02 21:27:11 UTC (rev 12299) @@ -1,5 +1,5 @@ /* $MidnightBSD$ */ -/* $FreeBSD: stable/10/lib/libusb/libusb20_int.h 302275 2016-06-29 10:58:36Z hselasky $ */ +/* $FreeBSD: stable/10/lib/libusb/libusb20_int.h 356399 2020-01-06 09:22:33Z hselasky $ */ /*- * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. * @@ -108,10 +108,12 @@ typedef int (libusb20_get_power_mode_t)(struct libusb20_device *pdev, uint8_t *power_mode); typedef int (libusb20_get_port_path_t)(struct libusb20_device *pdev, uint8_t *buf, uint8_t bufsize); typedef int (libusb20_get_power_usage_t)(struct libusb20_device *pdev, uint16_t *power_usage); +typedef int (libusb20_get_stats_t)(struct libusb20_device *pdev, struct libusb20_device_stats *pstats); typedef int (libusb20_set_alt_index_t)(struct libusb20_device *pdev, uint8_t iface_index, uint8_t alt_index); typedef int (libusb20_set_config_index_t)(struct libusb20_device *pdev, uint8_t index); typedef int (libusb20_check_connected_t)(struct libusb20_device *pdev); + /* USB transfer specific */ typedef int (libusb20_tr_open_t)(struct libusb20_transfer *xfer, uint32_t MaxBufSize, uint32_t MaxFrameCount, uint8_t ep_no, uint16_t stream_id, uint8_t pre_scale); typedef int (libusb20_tr_close_t)(struct libusb20_transfer *xfer); @@ -132,6 +134,7 @@ m(n, get_power_mode) \ m(n, get_port_path) \ m(n, get_power_usage) \ + m(n, get_stats) \ m(n, set_alt_index) \ m(n, set_config_index) \ m(n, tr_cancel_async) \ Modified: trunk/lib/libusb/libusb20_ugen20.c =================================================================== --- trunk/lib/libusb/libusb20_ugen20.c 2020-02-02 21:21:47 UTC (rev 12298) +++ trunk/lib/libusb/libusb20_ugen20.c 2020-02-02 21:27:11 UTC (rev 12299) @@ -1,5 +1,5 @@ /* $MidnightBSD$ */ -/* $FreeBSD: stable/10/lib/libusb/libusb20_ugen20.c 310280 2016-12-19 18:26:26Z trasz $ */ +/* $FreeBSD: stable/10/lib/libusb/libusb20_ugen20.c 356399 2020-01-06 09:22:33Z hselasky $ */ /*- * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. * @@ -80,6 +80,7 @@ static libusb20_get_power_mode_t ugen20_get_power_mode; static libusb20_get_port_path_t ugen20_get_port_path; static libusb20_get_power_usage_t ugen20_get_power_usage; +static libusb20_get_stats_t ugen20_get_stats; static libusb20_kernel_driver_active_t ugen20_kernel_driver_active; static libusb20_detach_kernel_driver_t ugen20_detach_kernel_driver; static libusb20_do_request_sync_t ugen20_do_request_sync; @@ -678,6 +679,29 @@ } static int +ugen20_get_stats(struct libusb20_device *pdev, struct libusb20_device_stats *pstats) +{ + struct usb_device_stats st; + + if (ioctl(pdev->file_ctrl, IOUSB(USB_DEVICESTATS), &st)) + return (LIBUSB20_ERROR_OTHER); + + memset(pstats, 0, sizeof(*pstats)); + + pstats->xfer_ok[0] = st.uds_requests_ok[0]; + pstats->xfer_ok[1] = st.uds_requests_ok[1]; + pstats->xfer_ok[2] = st.uds_requests_ok[2]; + pstats->xfer_ok[3] = st.uds_requests_ok[3]; + + pstats->xfer_fail[0] = st.uds_requests_fail[0]; + pstats->xfer_fail[1] = st.uds_requests_fail[1]; + pstats->xfer_fail[2] = st.uds_requests_fail[2]; + pstats->xfer_fail[3] = st.uds_requests_fail[3]; + + return (0); /* success */ +} + +static int ugen20_kernel_driver_active(struct libusb20_device *pdev, uint8_t iface_index) { From laffer1 at midnightbsd.org Sun Feb 2 16:31:29 2020 From: laffer1 at midnightbsd.org (laffer1 at midnightbsd.org) Date: Sun, 2 Feb 2020 16:31:29 -0500 (EST) Subject: [Midnightbsd-cvs] src [12300] trunk/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/raise: fix raise tests Message-ID: <202002022131.012LVTq4016621@stargazer.midnightbsd.org> Revision: 12300 http://svnweb.midnightbsd.org/src/?rev=12300 Author: laffer1 Date: 2020-02-02 16:31:28 -0500 (Sun, 02 Feb 2020) Log Message: ----------- fix raise tests Modified Paths: -------------- trunk/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/raise/tst.raise1.c trunk/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/raise/tst.raise1.d trunk/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/raise/tst.raise2.c trunk/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/raise/tst.raise2.d trunk/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/raise/tst.raise3.c trunk/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/raise/tst.raise3.d Modified: trunk/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/raise/tst.raise1.c =================================================================== --- trunk/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/raise/tst.raise1.c 2020-02-02 21:27:11 UTC (rev 12299) +++ trunk/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/raise/tst.raise1.c 2020-02-02 21:31:28 UTC (rev 12300) @@ -36,13 +36,13 @@ sigset_t ss; (void) sigemptyset(&ss); - (void) sigaddset(&ss, SIGINT); + (void) sigaddset(&ss, SIGUSR1); (void) sigprocmask(SIG_BLOCK, &ss, NULL); do { (void) getpid(); (void) sigpending(&ss); - } while (!sigismember(&ss, SIGINT)); + } while (!sigismember(&ss, SIGUSR1)); return (0); } Modified: trunk/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/raise/tst.raise1.d =================================================================== --- trunk/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/raise/tst.raise1.d 2020-02-02 21:27:11 UTC (rev 12299) +++ trunk/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/raise/tst.raise1.d 2020-02-02 21:31:28 UTC (rev 12300) @@ -1,3 +1,4 @@ +/* $MidnightBSD$ */ /* * CDDL HEADER START * @@ -47,7 +48,7 @@ /pid == $1/ { trace("raised"); - raise(SIGINT); + raise(SIGUSR1); /* * Wait no more than half a second for the process to die. */ @@ -55,6 +56,7 @@ } syscall::exit:entry +/pid == $1/ { exit(0); } Modified: trunk/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/raise/tst.raise2.c =================================================================== --- trunk/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/raise/tst.raise2.c 2020-02-02 21:27:11 UTC (rev 12299) +++ trunk/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/raise/tst.raise2.c 2020-02-02 21:31:28 UTC (rev 12300) @@ -46,7 +46,7 @@ sigemptyset(&sa.sa_mask); sa.sa_flags = 0; - (void) sigaction(SIGINT, &sa, NULL); + (void) sigaction(SIGUSR1, &sa, NULL); for (;;) { (void) getpid(); Modified: trunk/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/raise/tst.raise2.d =================================================================== --- trunk/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/raise/tst.raise2.d 2020-02-02 21:27:11 UTC (rev 12299) +++ trunk/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/raise/tst.raise2.d 2020-02-02 21:31:28 UTC (rev 12300) @@ -1,3 +1,4 @@ +/* $MidnightBSD$ */ /* * CDDL HEADER START * @@ -47,7 +48,7 @@ /pid == $1/ { trace("raised"); - raise(SIGINT); + raise(SIGUSR1); /* * Wait no more than half a second for the process to die. */ @@ -55,6 +56,7 @@ } syscall::exit:entry +/pid == $1/ { exit(0); } Modified: trunk/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/raise/tst.raise3.c =================================================================== --- trunk/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/raise/tst.raise3.c 2020-02-02 21:27:11 UTC (rev 12299) +++ trunk/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/raise/tst.raise3.c 2020-02-02 21:31:28 UTC (rev 12300) @@ -46,7 +46,7 @@ sigemptyset(&sa.sa_mask); sa.sa_flags = 0; - (void) sigaction(SIGINT, &sa, NULL); + (void) sigaction(SIGUSR1, &sa, NULL); for (;;) { (void) getpid(); Modified: trunk/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/raise/tst.raise3.d =================================================================== --- trunk/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/raise/tst.raise3.d 2020-02-02 21:27:11 UTC (rev 12299) +++ trunk/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/raise/tst.raise3.d 2020-02-02 21:31:28 UTC (rev 12300) @@ -1,3 +1,4 @@ +/* $MidnightBSD$ */ /* * CDDL HEADER START * @@ -47,7 +48,7 @@ /pid == $1/ { trace("raised"); - raise(SIGINT); + raise(SIGUSR1); /* * Wait no more than half a second for the process to die. */ @@ -55,6 +56,7 @@ } syscall::exit:entry +/pid == $1/ { exit(0); }