From owner-svn-src-stable-11@freebsd.org Sun Mar 10 00:56:40 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 41C6C153E97D; Sun, 10 Mar 2019 00:56:40 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D945C83451; Sun, 10 Mar 2019 00:56:39 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CEB651B469; Sun, 10 Mar 2019 00:56:39 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2A0udmO013437; Sun, 10 Mar 2019 00:56:39 GMT (envelope-from kp@FreeBSD.org) Received: (from kp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2A0ud2j013436; Sun, 10 Mar 2019 00:56:39 GMT (envelope-from kp@FreeBSD.org) Message-Id: <201903100056.x2A0ud2j013436@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kp set sender to kp@FreeBSD.org using -f From: Kristof Provost Date: Sun, 10 Mar 2019 00:56:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r344975 - stable/11/sys/netpfil/pf X-SVN-Group: stable-11 X-SVN-Commit-Author: kp X-SVN-Commit-Paths: stable/11/sys/netpfil/pf X-SVN-Commit-Revision: 344975 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: D945C83451 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.96)[-0.957,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Mar 2019 00:56:40 -0000 Author: kp Date: Sun Mar 10 00:56:39 2019 New Revision: 344975 URL: https://svnweb.freebsd.org/changeset/base/344975 Log: pf: Small performance tweak Because fetching a counter is a rather expansive function we should use counter_u64_fetch() in pf_state_expires() only when necessary. A "rdr pass" rule should not cause more effort than separate "rdr" and "pass" rules. For rules with adaptive timeout values the call of counter_u64_fetch() should be accepted, but otherwise not. From the man page: The adaptive timeout values can be defined both globally and for each rule. When used on a per-rule basis, the values relate to the number of states created by the rule, otherwise to the total number of states. This handling of adaptive timeouts is done in pf_state_expires(). The calculation needs three values: start, end and states. 1. Normal rules "pass .." without adaptive setting meaning "start = 0" runs in the else-section and therefore takes "start" and "end" from the global default settings and sets "states" to pf_status.states (= total number of states). 2. Special rules like "pass .. keep state (adaptive.start 500 adaptive.end 1000)" have start != 0, run in the if-section and take "start" and "end" from the rule and set "states" to the number of states created by their rule using counter_u64_fetch(). Thats all ok, but there is a third case without special handling in the above code snippet: 3. All "rdr/nat pass .." statements use together the pf_default_rule. Therefore we have "start != 0" in this case and we run the if-section but we better should run the else-section in this case and do not fetch the counter of the pf_default_rule but take the total number of states. Submitted by: Andreas Longwitz Modified: stable/11/sys/netpfil/pf/pf.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/netpfil/pf/pf.c ============================================================================== --- stable/11/sys/netpfil/pf/pf.c Sun Mar 10 00:56:38 2019 (r344974) +++ stable/11/sys/netpfil/pf/pf.c Sun Mar 10 00:56:39 2019 (r344975) @@ -1548,7 +1548,7 @@ pf_state_expires(const struct pf_state *state) if (!timeout) timeout = V_pf_default_rule.timeout[state->timeout]; start = state->rule.ptr->timeout[PFTM_ADAPTIVE_START]; - if (start) { + if (start && state->rule.ptr != &V_pf_default_rule) { end = state->rule.ptr->timeout[PFTM_ADAPTIVE_END]; states = counter_u64_fetch(state->rule.ptr->states_cur); } else { From owner-svn-src-stable-11@freebsd.org Sun Mar 10 20:58:25 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6C5511541ABE; Sun, 10 Mar 2019 20:58:25 +0000 (UTC) (envelope-from wulf@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 0D42C8DF8C; Sun, 10 Mar 2019 20:58:25 +0000 (UTC) (envelope-from wulf@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id F1E4C993; Sun, 10 Mar 2019 20:58:24 +0000 (UTC) (envelope-from wulf@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2AKwOQa050412; Sun, 10 Mar 2019 20:58:24 GMT (envelope-from wulf@FreeBSD.org) Received: (from wulf@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2AKwOmF050410; Sun, 10 Mar 2019 20:58:24 GMT (envelope-from wulf@FreeBSD.org) Message-Id: <201903102058.x2AKwOmF050410@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: wulf set sender to wulf@FreeBSD.org using -f From: Vladimir Kondratyev Date: Sun, 10 Mar 2019 20:58:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r344984 - in stable/11: sbin/sysctl sys/dev/evdev X-SVN-Group: stable-11 X-SVN-Commit-Author: wulf X-SVN-Commit-Paths: in stable/11: sbin/sysctl sys/dev/evdev X-SVN-Commit-Revision: 344984 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 0D42C8DF8C X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-0.99)[-0.994,0]; NEURAL_HAM_SHORT(-0.97)[-0.974,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Mar 2019 20:58:25 -0000 Author: wulf Date: Sun Mar 10 20:58:24 2019 New Revision: 344984 URL: https://svnweb.freebsd.org/changeset/base/344984 Log: MFC r344494,r344495: evdev: export event device properties through sysctl interface A big security advantage of Wayland is not allowing applications to read input devices all the time. Having /dev/input/* accessible to the user account subverts this advantage. libudev-devd was opening the evdev devices to detect their types (mouse, keyboard, touchpad, etc). This don't work if /dev/input/* is inaccessible. With the kernel exposing this information as sysctls (kern.evdev.input.*), we can work w/o /dev/input/* access, preserving the Wayland security model. Submitted by: Greg V Reviewed by: wulf, imp Differential Revision: https://reviews.freebsd.org/D18694 Modified: stable/11/sbin/sysctl/sysctl.c stable/11/sys/dev/evdev/evdev.c stable/11/sys/dev/evdev/evdev_private.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/sysctl/sysctl.c ============================================================================== --- stable/11/sbin/sysctl/sysctl.c Sun Mar 10 20:43:08 2019 (r344983) +++ stable/11/sbin/sysctl/sysctl.c Sun Mar 10 20:58:24 2019 (r344984) @@ -47,6 +47,7 @@ static const char rcsid[] = #include #include #include +#include #ifdef __amd64__ #include @@ -678,6 +679,22 @@ S_vmtotal(size_t l2, void *p) return (0); } +static int +S_input_id(size_t l2, void *p) +{ + struct input_id *id = p; + + if (l2 != sizeof(*id)) { + warnx("S_input_id %zu != %zu", l2, sizeof(*id)); + return (1); + } + + printf("{ bustype = 0x%04x, vendor = 0x%04x, " + "product = 0x%04x, version = 0x%04x }", + id->bustype, id->vendor, id->product, id->version); + return (0); +} + #ifdef __amd64__ static int S_efi_map(size_t l2, void *p) @@ -1097,6 +1114,8 @@ show_var(int *oid, int nlen) func = S_loadavg; else if (strcmp(fmt, "S,vmtotal") == 0) func = S_vmtotal; + else if (strcmp(fmt, "S,input_id") == 0) + func = S_input_id; #ifdef __amd64__ else if (strcmp(fmt, "S,efi_map_header") == 0) func = S_efi_map; Modified: stable/11/sys/dev/evdev/evdev.c ============================================================================== --- stable/11/sys/dev/evdev/evdev.c Sun Mar 10 20:43:08 2019 (r344983) +++ stable/11/sys/dev/evdev/evdev.c Sun Mar 10 20:58:24 2019 (r344984) @@ -67,14 +67,16 @@ MALLOC_DEFINE(M_EVDEV, "evdev", "evdev memory"); int evdev_rcpt_mask = EVDEV_RCPT_SYSMOUSE | EVDEV_RCPT_KBDMUX; int evdev_sysmouse_t_axis = 0; -#ifdef EVDEV_SUPPORT SYSCTL_NODE(_kern, OID_AUTO, evdev, CTLFLAG_RW, 0, "Evdev args"); +#ifdef EVDEV_SUPPORT SYSCTL_INT(_kern_evdev, OID_AUTO, rcpt_mask, CTLFLAG_RW, &evdev_rcpt_mask, 0, "Who is receiving events: bit0 - sysmouse, bit1 - kbdmux, " "bit2 - mouse hardware, bit3 - keyboard hardware"); SYSCTL_INT(_kern_evdev, OID_AUTO, sysmouse_t_axis, CTLFLAG_RW, &evdev_sysmouse_t_axis, 0, "Extract T-axis from 0-none, 1-ums, 2-psm"); #endif +SYSCTL_NODE(_kern_evdev, OID_AUTO, input, CTLFLAG_RD, 0, + "Evdev input devices"); static void evdev_start_repeat(struct evdev_dev *, uint16_t); static void evdev_stop_repeat(struct evdev_dev *); @@ -194,6 +196,87 @@ evdev_estimate_report_size(struct evdev_dev *evdev) return (size); } +static void +evdev_sysctl_create(struct evdev_dev *evdev) +{ + struct sysctl_oid *ev_sysctl_tree; + char ev_unit_str[8]; + + snprintf(ev_unit_str, sizeof(ev_unit_str), "%d", evdev->ev_unit); + sysctl_ctx_init(&evdev->ev_sysctl_ctx); + + ev_sysctl_tree = SYSCTL_ADD_NODE_WITH_LABEL(&evdev->ev_sysctl_ctx, + SYSCTL_STATIC_CHILDREN(_kern_evdev_input), OID_AUTO, + ev_unit_str, CTLFLAG_RD, NULL, "", "device index"); + + SYSCTL_ADD_STRING(&evdev->ev_sysctl_ctx, + SYSCTL_CHILDREN(ev_sysctl_tree), OID_AUTO, "name", CTLFLAG_RD, + evdev->ev_name, 0, + "Input device name"); + + SYSCTL_ADD_STRUCT(&evdev->ev_sysctl_ctx, + SYSCTL_CHILDREN(ev_sysctl_tree), OID_AUTO, "id", CTLFLAG_RD, + &evdev->ev_id, input_id, + "Input device identification"); + + /* ioctl returns ENOENT if phys is not set. sysctl returns "" here */ + SYSCTL_ADD_STRING(&evdev->ev_sysctl_ctx, + SYSCTL_CHILDREN(ev_sysctl_tree), OID_AUTO, "phys", CTLFLAG_RD, + evdev->ev_shortname, 0, + "Input device short name"); + + /* ioctl returns ENOENT if uniq is not set. sysctl returns "" here */ + SYSCTL_ADD_STRING(&evdev->ev_sysctl_ctx, + SYSCTL_CHILDREN(ev_sysctl_tree), OID_AUTO, "uniq", CTLFLAG_RD, + evdev->ev_serial, 0, + "Input device unique number"); + + SYSCTL_ADD_OPAQUE(&evdev->ev_sysctl_ctx, + SYSCTL_CHILDREN(ev_sysctl_tree), OID_AUTO, "props", CTLFLAG_RD, + evdev->ev_prop_flags, sizeof(evdev->ev_prop_flags), "", + "Input device properties"); + + SYSCTL_ADD_OPAQUE(&evdev->ev_sysctl_ctx, + SYSCTL_CHILDREN(ev_sysctl_tree), OID_AUTO, "type_bits", CTLFLAG_RD, + evdev->ev_type_flags, sizeof(evdev->ev_type_flags), "", + "Input device supported events types"); + + SYSCTL_ADD_OPAQUE(&evdev->ev_sysctl_ctx, + SYSCTL_CHILDREN(ev_sysctl_tree), OID_AUTO, "key_bits", CTLFLAG_RD, + evdev->ev_key_flags, sizeof(evdev->ev_key_flags), + "", "Input device supported keys"); + + SYSCTL_ADD_OPAQUE(&evdev->ev_sysctl_ctx, + SYSCTL_CHILDREN(ev_sysctl_tree), OID_AUTO, "rel_bits", CTLFLAG_RD, + evdev->ev_rel_flags, sizeof(evdev->ev_rel_flags), "", + "Input device supported relative events"); + + SYSCTL_ADD_OPAQUE(&evdev->ev_sysctl_ctx, + SYSCTL_CHILDREN(ev_sysctl_tree), OID_AUTO, "abs_bits", CTLFLAG_RD, + evdev->ev_abs_flags, sizeof(evdev->ev_abs_flags), "", + "Input device supported absolute events"); + + SYSCTL_ADD_OPAQUE(&evdev->ev_sysctl_ctx, + SYSCTL_CHILDREN(ev_sysctl_tree), OID_AUTO, "msc_bits", CTLFLAG_RD, + evdev->ev_msc_flags, sizeof(evdev->ev_msc_flags), "", + "Input device supported miscellaneous events"); + + SYSCTL_ADD_OPAQUE(&evdev->ev_sysctl_ctx, + SYSCTL_CHILDREN(ev_sysctl_tree), OID_AUTO, "led_bits", CTLFLAG_RD, + evdev->ev_led_flags, sizeof(evdev->ev_led_flags), "", + "Input device supported LED events"); + + SYSCTL_ADD_OPAQUE(&evdev->ev_sysctl_ctx, + SYSCTL_CHILDREN(ev_sysctl_tree), OID_AUTO, "snd_bits", CTLFLAG_RD, + evdev->ev_snd_flags, sizeof(evdev->ev_snd_flags), "", + "Input device supported sound events"); + + SYSCTL_ADD_OPAQUE(&evdev->ev_sysctl_ctx, + SYSCTL_CHILDREN(ev_sysctl_tree), OID_AUTO, "sw_bits", CTLFLAG_RD, + evdev->ev_sw_flags, sizeof(evdev->ev_sw_flags), "", + "Input device supported switch events"); +} + static int evdev_register_common(struct evdev_dev *evdev) { @@ -233,6 +316,12 @@ evdev_register_common(struct evdev_dev *evdev) /* Create char device node */ ret = evdev_cdev_create(evdev); + if (ret != 0) + goto bail_out; + + /* Create sysctls (for device enumeration without /dev/input access rights) */ + evdev_sysctl_create(evdev); + bail_out: return (ret); } @@ -269,6 +358,8 @@ evdev_unregister(struct evdev_dev *evdev) int ret; debugf(evdev, "%s: unregistered evdev provider: %s\n", evdev->ev_shortname, evdev->ev_name); + + sysctl_ctx_free(&evdev->ev_sysctl_ctx); EVDEV_LOCK(evdev); evdev->ev_cdev->si_drv1 = NULL; Modified: stable/11/sys/dev/evdev/evdev_private.h ============================================================================== --- stable/11/sys/dev/evdev/evdev_private.h Sun Mar 10 20:43:08 2019 (r344983) +++ stable/11/sys/dev/evdev/evdev_private.h Sun Mar 10 20:58:24 2019 (r344984) @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -127,6 +128,9 @@ struct evdev_dev /* Parent driver callbacks: */ const struct evdev_methods * ev_methods; void * ev_softc; + + /* Sysctl: */ + struct sysctl_ctx_list ev_sysctl_ctx; LIST_ENTRY(evdev_dev) ev_link; LIST_HEAD(, evdev_client) ev_clients; From owner-svn-src-stable-11@freebsd.org Sun Mar 10 16:13:01 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9C81A15386BA; Sun, 10 Mar 2019 16:13:01 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 404808340E; Sun, 10 Mar 2019 16:13:01 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2D407258E0; Sun, 10 Mar 2019 16:13:01 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2AGD19s001982; Sun, 10 Mar 2019 16:13:01 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2AGD0nY001981; Sun, 10 Mar 2019 16:13:00 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201903101613.x2AGD0nY001981@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Enji Cooper Date: Sun, 10 Mar 2019 16:13:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r344977 - stable/11/lib/libc/tests/sys X-SVN-Group: stable-11 X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: stable/11/lib/libc/tests/sys X-SVN-Commit-Revision: 344977 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 404808340E X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.96)[-0.965,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Mar 2019 16:13:01 -0000 Author: ngie Date: Sun Mar 10 16:13:00 2019 New Revision: 344977 URL: https://svnweb.freebsd.org/changeset/base/344977 Log: MFC r343362,r343365,r343367,r343368,r343461,r343751,r344310: r343362: Add [initial] functional tests for sendfile(2) as lib/libc/sys/sendfile These testcases exercise a number of functional requirements for sendfile(2). The testcases use IPv4 and IPv6 domain sockets with TCP, and were confirmed functional on UFS and ZFS. UDP address family sockets cannot be used per the sendfile(2) contract, thus using UDP sockets is outside the scope of testing the syscall in positive cases. As seen in `:s_negative_udp_socket_test`, UDP is used to test the sendfile(2) contract to ensure that EINVAL is returned by sendfile(2). The testcases added explicitly avoid testing out `SF_SYNC` due to the complexity of verifying that support. However, this is a good next logical item to verify. The `hdtr_positive*` testcases work to a certain degree (the header testcases pass), but the trailer testcases do not work (it is an expected failure). In particular, the value received by the mock server doesn't match the expected value, and instead looks something like the following (using python array notation): `trailer[:]message[1:]` instead of: `message[:]trailer[:]` This makes me think there's a buffer overrun issue or problem with the offset somewhere in the sendfile(2) system call, but I need to do some other testing first to verify that the code is indeed sane, and my assumptions/code isn't buggy. The `sbytes_negative` testcases that check `sbytes` being set to an invalid value resulting in `EFAULT` fails today as the other change (which checks `copyout(9)`) has not been committed [1]. Thus, it should remain an expected failure (see bug 232210 for more details on this item). Next steps for testing sendfile(2): 1. Fix the header/trailer testcases so that they pass. 2. Setup if_tap interface and test with it, instead of using "localhost", per @asomers's suggestion. 3. Handle short recv(2)'s in `server_cat(..)`. 4. Add `SF_SYNC` support. 5. Add some more negative tests outside the scope of the functional contract. PR: 232210 r343365: Unbreak the gcc build with sendfile_test after r343362 gcc 8.x is more pedantic than clang 7.x with format strings and the tests passed `void*` variables while supplying `%s` (which is technically incorrect). Make the affected `void*` variables use `char*` storage instead to address this issue, as the compiler will upcast the values to `char*`. MFC with: r343362 r343367: Unbreak the build on architectures where size_t isn't synonymous with uintmax_t I should have used `%zu` instead of `%ju` with `size_t` types. MFC with: r343362, r343365 Pointyhat to: ngie r343368: Fix up r343367 I should have only changed the format qualifier with the `size_t` value, `length`, not the other [`off_t`] value, `dest_file_size`. MFC with: r343362, r343365, r343367 r343461: Fix reporting errors with `gai_strerror(..)` The return value (`err`) should be checked; not the `errno` value. PR: 235200 MFC with: r343362, r343365, r343367-r343368 r343751: Avoid the DNS lookup for "localhost" ci.FreeBSD.org does not have access to a DNS resolver/network (unlike my test VM), so in order for the test to pass on the host, it needs to avoid the DNS lookup by using the numeric host address representation. PR: 235200 MFC with: r343362, r343365, r343367-r343368, r343461 r344310: Make `server_cat(..)` handle short receives In short, the prior code was far too simplistic when it came to calling recv(2) and failed intermittently (or in the case of Jenkins, deterministically). Handle short recv(2)s by checking the return code and incrementing the window into the buffer by the number of received bytes. If the number of received bytes <= 0, then bail out of the loop, and test the total number of received bytes vs the expected number of bytes sent for equality, and base whether or not the test passes/fails on that fact. Remove the expected failure, now that the hdtr testcases deterministically pass on my host after this change [1]. PR: 234809 [1], 235200 Approved by: emaste (mentor) Differential Revision: https://reviews.freebsd.org/D19524 Added: stable/11/lib/libc/tests/sys/sendfile_test.c - copied, changed from r343362, head/lib/libc/tests/sys/sendfile_test.c Modified: stable/11/lib/libc/tests/sys/Makefile Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libc/tests/sys/Makefile ============================================================================== --- stable/11/lib/libc/tests/sys/Makefile Sun Mar 10 04:41:30 2019 (r344976) +++ stable/11/lib/libc/tests/sys/Makefile Sun Mar 10 16:13:00 2019 (r344977) @@ -5,6 +5,7 @@ PACKAGE= tests .include ATF_TESTS_C+= queue_test +ATF_TESTS_C+= sendfile_test # TODO: clone, lwp_create, lwp_ctl, posix_fadvise, recvmmsg, # swapcontext Copied and modified: stable/11/lib/libc/tests/sys/sendfile_test.c (from r343362, head/lib/libc/tests/sys/sendfile_test.c) ============================================================================== --- head/lib/libc/tests/sys/sendfile_test.c Wed Jan 23 22:00:17 2019 (r343362, copy source) +++ stable/11/lib/libc/tests/sys/sendfile_test.c Sun Mar 10 16:13:00 2019 (r344977) @@ -97,24 +97,33 @@ generate_random_port(int seed) static void resolve_localhost(struct addrinfo **res, int domain, int type, int port) { + const char *host; char *serv; struct addrinfo hints; int error; - ATF_REQUIRE_MSG(domain == AF_INET || domain == AF_INET6, - "unhandled domain: %d", domain); + switch (domain) { + case AF_INET: + host = "127.0.0.1"; + break; + case AF_INET6: + host = "::1"; + break; + default: + atf_tc_fail("unhandled domain: %d", domain); + } ATF_REQUIRE_MSG(asprintf(&serv, "%d", port) >= 0, "asprintf failed: %s", strerror(errno)); memset(&hints, 0, sizeof(hints)); hints.ai_family = domain; - hints.ai_flags = AI_ADDRCONFIG|AI_NUMERICSERV; + hints.ai_flags = AI_ADDRCONFIG|AI_NUMERICSERV|AI_NUMERICHOST; hints.ai_socktype = type; - error = getaddrinfo("localhost", serv, &hints, res); + error = getaddrinfo(host, serv, &hints, res); ATF_REQUIRE_EQ_MSG(error, 0, - "getaddrinfo failed: %s", gai_strerror(errno)); + "getaddrinfo failed: %s", gai_strerror(error)); free(serv); } @@ -147,6 +156,8 @@ setup_client(int domain, int type, int port) "Will try to connect to host='%s', address_family=%d, " "socket_type=%d\n", host, res->ai_family, res->ai_socktype); + /* Avoid a double print when forked by flushing. */ + fflush(stdout); sock = make_socket(res->ai_family, res->ai_socktype, res->ai_protocol); error = connect(sock, (struct sockaddr*)res->ai_addr, res->ai_addrlen); freeaddrinfo(res); @@ -178,6 +189,8 @@ setup_server(int domain, int type, int port) "Will try to bind socket to host='%s', address_family=%d, " "socket_type=%d\n", host, res->ai_family, res->ai_socktype); + /* Avoid a double print when forked by flushing. */ + fflush(stdout); error = bind(sock, res->ai_addr, res->ai_addrlen); freeaddrinfo(res); ATF_REQUIRE_EQ_MSG(error, 0, "bind failed: %s", strerror(errno)); @@ -195,11 +208,17 @@ setup_server(int domain, int type, int port) static void server_cat(const char *dest_filename, int server_sock, size_t len) { - void *buffer; + char *buffer, *buf_window_ptr; int recv_sock; - ssize_t received_bytes; + size_t buffer_size; + ssize_t received_bytes, recv_ret; - buffer = calloc(len + 1, sizeof(char)); + /* + * Ensure that there isn't excess data sent across the wire by + * capturing 10 extra bytes (plus 1 for nul). + */ + buffer_size = len + 10 + 1; + buffer = calloc(buffer_size, sizeof(char)); if (buffer == NULL) err(1, "malloc failed"); @@ -207,32 +226,26 @@ server_cat(const char *dest_filename, int server_sock, if (recv_sock == -1) err(1, "accept failed"); - /* - * XXX: this assumes the simplest case where all data is received in a - * single recv(2) call. - */ - if (recv(recv_sock, buffer, len, 0) == -1) - err(1, "recv failed"); + buf_window_ptr = buffer; + received_bytes = 0; + do { + recv_ret = recv(recv_sock, buf_window_ptr, + buffer_size - received_bytes, 0); + if (recv_ret <= 0) + break; + buf_window_ptr += recv_ret; + received_bytes += recv_ret; + } while (received_bytes < buffer_size); atf_utils_create_file(dest_filename, "%s", buffer); - /* - * This recv(2) call helps ensure the amount of sent data is exactly - * what was specified by `len`. - */ - received_bytes = recv(recv_sock, buffer, len, 0); - switch (received_bytes) { - case -1: - err(1, "recv failed"); - case 0: - break; - default: - errx(1, "received unexpected data: %s", buffer); - } - (void)close(recv_sock); (void)close(server_sock); free(buffer); + + if (received_bytes != len) + errx(1, "received unexpected data: %zd != %zd", received_bytes, + len); } static int @@ -268,7 +281,7 @@ static void verify_source_and_dest(const char* dest_filename, int src_fd, off_t offset, size_t nbytes) { - void *dest_pointer, *src_pointer; + char *dest_pointer, *src_pointer; off_t dest_file_size, src_file_size; size_t length; int dest_fd; @@ -290,7 +303,7 @@ verify_source_and_dest(const char* dest_filename, int ATF_REQUIRE_EQ_MSG(dest_file_size, length, "number of bytes written out to %s (%ju) doesn't match the " - "expected number of bytes (%ju)", dest_filename, dest_file_size, + "expected number of bytes (%zu)", dest_filename, dest_file_size, length); ATF_REQUIRE_EQ_MSG(0, lseek(src_fd, offset, SEEK_SET), @@ -384,7 +397,7 @@ ATF_TC_BODY(fd_positive_file_v6, tc) static void fd_positive_shm_test(int domain) { - void *shm_pointer; + char *shm_pointer; off_t offset; size_t nbytes, pattern_size; pid_t server_pid; @@ -658,10 +671,6 @@ hdtr_positive_test(int domain) offset = 0; nbytes = 0; - atf_tc_expect_fail( - "The header/trailer testcases fail today with a data mismatch; " - "bug # 234809"); - for (i = 0; i < nitems(testcases); i++) { struct sf_hdtr hdtr; char *pattern; @@ -687,9 +696,9 @@ hdtr_positive_test(int domain) client_sock = setup_tcp_client(domain, port); rc = asprintf(&pattern, "%s%s%s", - testcases[i].include_headers ? headers[0].iov_base : "", + testcases[i].include_headers ? (char *)headers[0].iov_base : "", DETERMINISTIC_PATTERN, - testcases[i].include_trailers ? trailers[0].iov_base : ""); + testcases[i].include_trailers ? (char *)trailers[0].iov_base : ""); ATF_REQUIRE_MSG(rc != -1, "asprintf failed: %s", strerror(errno)); atf_utils_create_file(SOURCE_FILE ".full", "%s", pattern); From owner-svn-src-stable-11@freebsd.org Sun Mar 10 21:31:11 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 169761542955; Sun, 10 Mar 2019 21:31:11 +0000 (UTC) (envelope-from vladimir@kondratyev.su) Received: from corp.infotel.ru (corp.infotel.ru [195.170.219.3]) by mx1.freebsd.org (Postfix) with ESMTP id 9C71F8F416; Sun, 10 Mar 2019 21:31:10 +0000 (UTC) (envelope-from vladimir@kondratyev.su) Received: from corp (corp.infotel.ru [195.170.219.3]) by corp.infotel.ru (Postfix) with ESMTP id A4C755B22B; Mon, 11 Mar 2019 00:31:01 +0300 (MSK) X-Virus-Scanned: amavisd-new at corp.infotel.ru Received: from corp.infotel.ru ([195.170.219.3]) by corp (corp.infotel.ru [195.170.219.3]) (amavisd-new, port 10024) with ESMTP id Jmo7czPR77Gx; Mon, 11 Mar 2019 00:30:58 +0300 (MSK) Received: from mail.cicgroup.ru (unknown [195.170.219.74]) by corp.infotel.ru (Postfix) with ESMTP id B92555B223; Mon, 11 Mar 2019 00:30:58 +0300 (MSK) Received: from mail.cicgroup.ru (localhost [127.0.0.1]) by mail.cicgroup.ru (Postfix) with ESMTP id AB928422120; Mon, 11 Mar 2019 00:30:50 +0300 (MSK) X-Virus-Scanned: amavisd-new at cicgroup.ru Received: from mail.cicgroup.ru ([127.0.0.1]) by mail.cicgroup.ru (mail.cicgroup.ru [127.0.0.1]) (amavisd-new, port 10024) with SMTP id 9y1sdiQmbLyx; Mon, 11 Mar 2019 00:30:48 +0300 (MSK) Received: from localhost (localhost [127.0.0.1]) by mail.cicgroup.ru (Postfix) with ESMTPA id ED05C42211C; Mon, 11 Mar 2019 00:30:47 +0300 (MSK) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Mon, 11 Mar 2019 00:30:47 +0300 From: Vladimir Kondratyev To: Konstantin Belousov Cc: Vladimir Kondratyev , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org, owner-src-committers@freebsd.org Subject: Re: svn commit: r344984 - in stable/11: sbin/sysctl sys/dev/evdev In-Reply-To: <20190310212201.GS2492@kib.kiev.ua> References: <201903102058.x2AKwOmF050410@repo.freebsd.org> <20190310212201.GS2492@kib.kiev.ua> Message-ID: <2a79d8b442f1187123a82ec5859a64ba@kondratyev.su> X-Sender: vladimir@kondratyev.su User-Agent: Roundcube Webmail/1.3.5 X-Rspamd-Queue-Id: 9C71F8F416 X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.96 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-0.996,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; REPLY(-4.00)[]; NEURAL_HAM_SHORT(-0.97)[-0.968,0] X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Mar 2019 21:31:11 -0000 On 2019-03-11 00:22, Konstantin Belousov wrote: > On Sun, Mar 10, 2019 at 08:58:24PM +0000, Vladimir Kondratyev wrote: >> Author: wulf >> Date: Sun Mar 10 20:58:24 2019 >> New Revision: 344984 >> URL: https://svnweb.freebsd.org/changeset/base/344984 >> >> Log: >> MFC r344494,r344495: >> >> + ev_sysctl_tree = SYSCTL_ADD_NODE_WITH_LABEL(&evdev->ev_sysctl_ctx, >> + SYSCTL_STATIC_CHILDREN(_kern_evdev_input), OID_AUTO, >> + ev_unit_str, CTLFLAG_RD, NULL, "", "device index"); > This change depends on r310051 which was not merged to stable/11. I will fix it soon. Sorry for breakage. -- WBR Vladimir Kondratyev From owner-svn-src-stable-11@freebsd.org Sun Mar 10 21:43:14 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BD7841543065; Sun, 10 Mar 2019 21:43:14 +0000 (UTC) (envelope-from wulf@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5DE8B8FCF2; Sun, 10 Mar 2019 21:43:14 +0000 (UTC) (envelope-from wulf@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4E8171227; Sun, 10 Mar 2019 21:43:14 +0000 (UTC) (envelope-from wulf@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2ALhEch075983; Sun, 10 Mar 2019 21:43:14 GMT (envelope-from wulf@FreeBSD.org) Received: (from wulf@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2ALhEnM075982; Sun, 10 Mar 2019 21:43:14 GMT (envelope-from wulf@FreeBSD.org) Message-Id: <201903102143.x2ALhEnM075982@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: wulf set sender to wulf@FreeBSD.org using -f From: Vladimir Kondratyev Date: Sun, 10 Mar 2019 21:43:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r344986 - stable/11/sys/dev/evdev X-SVN-Group: stable-11 X-SVN-Commit-Author: wulf X-SVN-Commit-Paths: stable/11/sys/dev/evdev X-SVN-Commit-Revision: 344986 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 5DE8B8FCF2 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-0.99)[-0.994,0]; NEURAL_HAM_SHORT(-0.97)[-0.973,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Mar 2019 21:43:14 -0000 Author: wulf Date: Sun Mar 10 21:43:13 2019 New Revision: 344986 URL: https://svnweb.freebsd.org/changeset/base/344986 Log: Fix build breakage caused by r344984 This is a direct commit to stable/11 Modified: stable/11/sys/dev/evdev/evdev.c Modified: stable/11/sys/dev/evdev/evdev.c ============================================================================== --- stable/11/sys/dev/evdev/evdev.c Sun Mar 10 20:58:59 2019 (r344985) +++ stable/11/sys/dev/evdev/evdev.c Sun Mar 10 21:43:13 2019 (r344986) @@ -205,9 +205,9 @@ evdev_sysctl_create(struct evdev_dev *evdev) snprintf(ev_unit_str, sizeof(ev_unit_str), "%d", evdev->ev_unit); sysctl_ctx_init(&evdev->ev_sysctl_ctx); - ev_sysctl_tree = SYSCTL_ADD_NODE_WITH_LABEL(&evdev->ev_sysctl_ctx, + ev_sysctl_tree = SYSCTL_ADD_NODE(&evdev->ev_sysctl_ctx, SYSCTL_STATIC_CHILDREN(_kern_evdev_input), OID_AUTO, - ev_unit_str, CTLFLAG_RD, NULL, "", "device index"); + ev_unit_str, CTLFLAG_RD, NULL, ""); SYSCTL_ADD_STRING(&evdev->ev_sysctl_ctx, SYSCTL_CHILDREN(ev_sysctl_tree), OID_AUTO, "name", CTLFLAG_RD, From owner-svn-src-stable-11@freebsd.org Mon Mar 11 01:12:24 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 616401526A53; Mon, 11 Mar 2019 01:12:24 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B285870B73; Mon, 11 Mar 2019 01:12:23 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9E54E37AB; Mon, 11 Mar 2019 01:12:23 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2B1CNBU085056; Mon, 11 Mar 2019 01:12:23 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2B1CNAk085055; Mon, 11 Mar 2019 01:12:23 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201903110112.x2B1CNAk085055@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Mon, 11 Mar 2019 01:12:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r344989 - stable/11/sys/geom/eli X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/11/sys/geom/eli X-SVN-Commit-Revision: 344989 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: B285870B73 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.95 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-0.99)[-0.994,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.96)[-0.957,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Mar 2019 01:12:24 -0000 Author: kevans Date: Mon Mar 11 01:12:23 2019 New Revision: 344989 URL: https://svnweb.freebsd.org/changeset/base/344989 Log: MFC r336255: Only define g_eli_key_cmp in the kernel Modified: stable/11/sys/geom/eli/g_eli_key_cache.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/geom/eli/g_eli_key_cache.c ============================================================================== --- stable/11/sys/geom/eli/g_eli_key_cache.c Mon Mar 11 00:52:55 2019 (r344988) +++ stable/11/sys/geom/eli/g_eli_key_cache.c Mon Mar 11 01:12:23 2019 (r344989) @@ -59,8 +59,6 @@ static uint64_t g_eli_key_cache_misses; SYSCTL_UQUAD(_kern_geom_eli, OID_AUTO, key_cache_misses, CTLFLAG_RW, &g_eli_key_cache_misses, 0, "Key cache misses"); -#endif /* _KERNEL */ - static int g_eli_key_cmp(const struct g_eli_key *a, const struct g_eli_key *b) { @@ -71,6 +69,7 @@ g_eli_key_cmp(const struct g_eli_key *a, const struct return (-1); return (0); } +#endif /* _KERNEL */ void g_eli_key_fill(struct g_eli_softc *sc, struct g_eli_key *key, uint64_t keyno) From owner-svn-src-stable-11@freebsd.org Sun Mar 10 21:22:15 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7ACC21542614; Sun, 10 Mar 2019 21:22:15 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (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 917838F04B; Sun, 10 Mar 2019 21:22:14 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id x2ALM1l7040649 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 10 Mar 2019 23:22:05 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua x2ALM1l7040649 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id x2ALM1DQ040648; Sun, 10 Mar 2019 23:22:01 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Sun, 10 Mar 2019 23:22:01 +0200 From: Konstantin Belousov To: Vladimir Kondratyev Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: Re: svn commit: r344984 - in stable/11: sbin/sysctl sys/dev/evdev Message-ID: <20190310212201.GS2492@kib.kiev.ua> References: <201903102058.x2AKwOmF050410@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201903102058.x2AKwOmF050410@repo.freebsd.org> User-Agent: Mutt/1.11.3 (2019-02-01) X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on tom.home X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Mar 2019 21:22:15 -0000 On Sun, Mar 10, 2019 at 08:58:24PM +0000, Vladimir Kondratyev wrote: > Author: wulf > Date: Sun Mar 10 20:58:24 2019 > New Revision: 344984 > URL: https://svnweb.freebsd.org/changeset/base/344984 > > Log: > MFC r344494,r344495: > > evdev: export event device properties through sysctl interface > > A big security advantage of Wayland is not allowing applications to read > input devices all the time. Having /dev/input/* accessible to the user > account subverts this advantage. > > libudev-devd was opening the evdev devices to detect their types (mouse, > keyboard, touchpad, etc). This don't work if /dev/input/* is inaccessible. > With the kernel exposing this information as sysctls (kern.evdev.input.*), > we can work w/o /dev/input/* access, preserving the Wayland security model. > > Submitted by: Greg V > Reviewed by: wulf, imp > Differential Revision: https://reviews.freebsd.org/D18694 > > Modified: > stable/11/sbin/sysctl/sysctl.c > stable/11/sys/dev/evdev/evdev.c > stable/11/sys/dev/evdev/evdev_private.h > Directory Properties: > stable/11/ (props changed) > > Modified: stable/11/sbin/sysctl/sysctl.c > ============================================================================== > --- stable/11/sbin/sysctl/sysctl.c Sun Mar 10 20:43:08 2019 (r344983) > +++ stable/11/sbin/sysctl/sysctl.c Sun Mar 10 20:58:24 2019 (r344984) > @@ -47,6 +47,7 @@ static const char rcsid[] = > #include > #include > #include > +#include > > #ifdef __amd64__ > #include > @@ -678,6 +679,22 @@ S_vmtotal(size_t l2, void *p) > return (0); > } > > +static int > +S_input_id(size_t l2, void *p) > +{ > + struct input_id *id = p; > + > + if (l2 != sizeof(*id)) { > + warnx("S_input_id %zu != %zu", l2, sizeof(*id)); > + return (1); > + } > + > + printf("{ bustype = 0x%04x, vendor = 0x%04x, " > + "product = 0x%04x, version = 0x%04x }", > + id->bustype, id->vendor, id->product, id->version); > + return (0); > +} > + > #ifdef __amd64__ > static int > S_efi_map(size_t l2, void *p) > @@ -1097,6 +1114,8 @@ show_var(int *oid, int nlen) > func = S_loadavg; > else if (strcmp(fmt, "S,vmtotal") == 0) > func = S_vmtotal; > + else if (strcmp(fmt, "S,input_id") == 0) > + func = S_input_id; > #ifdef __amd64__ > else if (strcmp(fmt, "S,efi_map_header") == 0) > func = S_efi_map; > > Modified: stable/11/sys/dev/evdev/evdev.c > ============================================================================== > --- stable/11/sys/dev/evdev/evdev.c Sun Mar 10 20:43:08 2019 (r344983) > +++ stable/11/sys/dev/evdev/evdev.c Sun Mar 10 20:58:24 2019 (r344984) > @@ -67,14 +67,16 @@ MALLOC_DEFINE(M_EVDEV, "evdev", "evdev memory"); > int evdev_rcpt_mask = EVDEV_RCPT_SYSMOUSE | EVDEV_RCPT_KBDMUX; > int evdev_sysmouse_t_axis = 0; > > -#ifdef EVDEV_SUPPORT > SYSCTL_NODE(_kern, OID_AUTO, evdev, CTLFLAG_RW, 0, "Evdev args"); > +#ifdef EVDEV_SUPPORT > SYSCTL_INT(_kern_evdev, OID_AUTO, rcpt_mask, CTLFLAG_RW, &evdev_rcpt_mask, 0, > "Who is receiving events: bit0 - sysmouse, bit1 - kbdmux, " > "bit2 - mouse hardware, bit3 - keyboard hardware"); > SYSCTL_INT(_kern_evdev, OID_AUTO, sysmouse_t_axis, CTLFLAG_RW, > &evdev_sysmouse_t_axis, 0, "Extract T-axis from 0-none, 1-ums, 2-psm"); > #endif > +SYSCTL_NODE(_kern_evdev, OID_AUTO, input, CTLFLAG_RD, 0, > + "Evdev input devices"); > > static void evdev_start_repeat(struct evdev_dev *, uint16_t); > static void evdev_stop_repeat(struct evdev_dev *); > @@ -194,6 +196,87 @@ evdev_estimate_report_size(struct evdev_dev *evdev) > return (size); > } > > +static void > +evdev_sysctl_create(struct evdev_dev *evdev) > +{ > + struct sysctl_oid *ev_sysctl_tree; > + char ev_unit_str[8]; > + > + snprintf(ev_unit_str, sizeof(ev_unit_str), "%d", evdev->ev_unit); > + sysctl_ctx_init(&evdev->ev_sysctl_ctx); > + > + ev_sysctl_tree = SYSCTL_ADD_NODE_WITH_LABEL(&evdev->ev_sysctl_ctx, > + SYSCTL_STATIC_CHILDREN(_kern_evdev_input), OID_AUTO, > + ev_unit_str, CTLFLAG_RD, NULL, "", "device index"); This change depends on r310051 which was not merged to stable/11. From owner-svn-src-stable-11@freebsd.org Mon Mar 11 01:44:39 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D13AB15279FC; Mon, 11 Mar 2019 01:44:38 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6D02371FA8; Mon, 11 Mar 2019 01:44:38 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 57D8A3D8B; Mon, 11 Mar 2019 01:44:38 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2B1ic3P001752; Mon, 11 Mar 2019 01:44:38 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2B1ib8J001750; Mon, 11 Mar 2019 01:44:37 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201903110144.x2B1ib8J001750@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Mon, 11 Mar 2019 01:44:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r344992 - stable/11/sys/cam/ctl X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/cam/ctl X-SVN-Commit-Revision: 344992 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 6D02371FA8 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-0.99)[-0.994,0]; NEURAL_HAM_SHORT(-0.96)[-0.964,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Mar 2019 01:44:39 -0000 Author: mav Date: Mon Mar 11 01:44:37 2019 New Revision: 344992 URL: https://svnweb.freebsd.org/changeset/base/344992 Log: MFC r344489: Free some space in struct ctl_io_hdr for better use. - Collapse original_sc and serializing_sc fields into one, since they are never used simultanously, we have only one local I/O and one remote. - Move remote_sglist and local_sglist fields into CTL_PRIV_BACKEND, since they are used only on Originating SC in XFER mode, where requests don't ever reach backends, so we can reuse backend's private storage. Modified: stable/11/sys/cam/ctl/ctl.c stable/11/sys/cam/ctl/ctl_io.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cam/ctl/ctl.c ============================================================================== --- stable/11/sys/cam/ctl/ctl.c Mon Mar 11 01:44:18 2019 (r344991) +++ stable/11/sys/cam/ctl/ctl.c Mon Mar 11 01:44:37 2019 (r344992) @@ -645,7 +645,7 @@ ctl_ha_datamove(union ctl_io *io) memset(&msg.dt, 0, sizeof(msg.dt)); msg.hdr.msg_type = CTL_MSG_DATAMOVE; - msg.hdr.original_sc = io->io_hdr.original_sc; + msg.hdr.original_sc = io->io_hdr.remote_io; msg.hdr.serializing_sc = io; msg.hdr.nexus = io->io_hdr.nexus; msg.hdr.status = io->io_hdr.status; @@ -760,7 +760,7 @@ ctl_ha_done(union ctl_io *io) if (io->io_hdr.io_type == CTL_IO_SCSI) { memset(&msg, 0, sizeof(msg)); msg.hdr.msg_type = CTL_MSG_FINISH_IO; - msg.hdr.original_sc = io->io_hdr.original_sc; + msg.hdr.original_sc = io->io_hdr.remote_io; msg.hdr.nexus = io->io_hdr.nexus; msg.hdr.status = io->io_hdr.status; msg.scsi.scsi_status = io->scsiio.scsi_status; @@ -1433,7 +1433,7 @@ ctl_isc_event_handler(ctl_ha_channel channel, ctl_ha_e // populate ctsio from msg io->io_hdr.io_type = CTL_IO_SCSI; io->io_hdr.msg_type = CTL_MSG_SERIALIZE; - io->io_hdr.original_sc = msg->hdr.original_sc; + io->io_hdr.remote_io = msg->hdr.original_sc; io->io_hdr.flags |= CTL_FLAG_FROM_OTHER_SC | CTL_FLAG_IO_ACTIVE; /* @@ -1489,7 +1489,7 @@ ctl_isc_event_handler(ctl_ha_channel channel, ctl_ha_e * Keep track of this, we need to send it back over * when the datamove is complete. */ - io->io_hdr.serializing_sc = msg->hdr.serializing_sc; + io->io_hdr.remote_io = msg->hdr.serializing_sc; if (msg->hdr.status == CTL_SUCCESS) io->io_hdr.status = msg->hdr.status; @@ -1502,9 +1502,8 @@ ctl_isc_event_handler(ctl_ha_channel channel, ctl_ha_e CTL_HA_DATAMOVE_SEGMENT + 1; sgl = malloc(sizeof(*sgl) * i, M_CTL, M_WAITOK | M_ZERO); - io->io_hdr.remote_sglist = sgl; - io->io_hdr.local_sglist = - &sgl[msg->dt.kern_sg_entries]; + CTL_RSGL(io) = sgl; + CTL_LSGL(io) = &sgl[msg->dt.kern_sg_entries]; io->scsiio.kern_data_ptr = (uint8_t *)sgl; @@ -1591,7 +1590,7 @@ ctl_isc_event_handler(ctl_ha_channel channel, ctl_ha_e } io->io_hdr.flags |= CTL_FLAG_IO_ACTIVE; io->io_hdr.msg_type = CTL_MSG_R2R; - io->io_hdr.serializing_sc = msg->hdr.serializing_sc; + io->io_hdr.remote_io = msg->hdr.serializing_sc; ctl_enqueue_isc(io); break; @@ -2362,7 +2361,7 @@ ctl_serialize_other_sc_cmd(struct ctl_scsiio *ctsio) mtx_unlock(&lun->lun_lock); /* send msg back to other side */ - msg_info.hdr.original_sc = ctsio->io_hdr.original_sc; + msg_info.hdr.original_sc = ctsio->io_hdr.remote_io; msg_info.hdr.serializing_sc = (union ctl_io *)ctsio; msg_info.hdr.msg_type = CTL_MSG_R2R; ctl_ha_msg_send(CTL_HA_CHAN_CTL, &msg_info, @@ -2388,7 +2387,7 @@ ctl_serialize_other_sc_cmd(struct ctl_scsiio *ctsio) /*retry_count*/ 0); badjuju: ctl_copy_sense_data_back((union ctl_io *)ctsio, &msg_info); - msg_info.hdr.original_sc = ctsio->io_hdr.original_sc; + msg_info.hdr.original_sc = ctsio->io_hdr.remote_io; msg_info.hdr.serializing_sc = NULL; msg_info.hdr.msg_type = CTL_MSG_BAD_JUJU; ctl_ha_msg_send(CTL_HA_CHAN_CTL, &msg_info, @@ -11075,7 +11074,7 @@ ctl_check_blocked(struct ctl_lun *lun) cur_blocked->io_hdr.flags &= ~CTL_FLAG_IO_ACTIVE; msg_info.hdr.original_sc = - cur_blocked->io_hdr.original_sc; + cur_blocked->io_hdr.remote_io; msg_info.hdr.serializing_sc = cur_blocked; msg_info.hdr.msg_type = CTL_MSG_R2R; ctl_ha_msg_send(CTL_HA_CHAN_CTL, &msg_info, @@ -12512,7 +12511,7 @@ ctl_send_datamove_done(union ctl_io *io, int have_lock memset(&msg, 0, sizeof(msg)); msg.hdr.msg_type = CTL_MSG_DATAMOVE_DONE; msg.hdr.original_sc = io; - msg.hdr.serializing_sc = io->io_hdr.serializing_sc; + msg.hdr.serializing_sc = io->io_hdr.remote_io; msg.hdr.nexus = io->io_hdr.nexus; msg.hdr.status = io->io_hdr.status; msg.scsi.kern_data_resid = io->scsiio.kern_data_resid; @@ -12563,10 +12562,10 @@ ctl_datamove_remote_write_cb(struct ctl_ha_dt_req *rq) ctl_dt_req_free(rq); for (i = 0; i < io->scsiio.kern_sg_entries; i++) - free(io->io_hdr.local_sglist[i].addr, M_CTL); - free(io->io_hdr.remote_sglist, M_CTL); - io->io_hdr.remote_sglist = NULL; - io->io_hdr.local_sglist = NULL; + free(CTL_LSGLT(io)[i].addr, M_CTL); + free(CTL_RSGL(io), M_CTL); + CTL_RSGL(io) = NULL; + CTL_LSGL(io) = NULL; /* * The data is in local and remote memory, so now we need to send @@ -12606,7 +12605,7 @@ ctl_datamove_remote_write(union ctl_io *io) return; /* Switch the pointer over so the FETD knows what to do */ - io->scsiio.kern_data_ptr = (uint8_t *)io->io_hdr.local_sglist; + io->scsiio.kern_data_ptr = (uint8_t *)CTL_LSGL(io); /* * Use a custom move done callback, since we need to send completion @@ -12629,10 +12628,10 @@ ctl_datamove_remote_dm_read_cb(union ctl_io *io) uint32_t i; for (i = 0; i < io->scsiio.kern_sg_entries; i++) - free(io->io_hdr.local_sglist[i].addr, M_CTL); - free(io->io_hdr.remote_sglist, M_CTL); - io->io_hdr.remote_sglist = NULL; - io->io_hdr.local_sglist = NULL; + free(CTL_LSGLT(io)[i].addr, M_CTL); + free(CTL_RSGL(io), M_CTL); + CTL_RSGL(io) = NULL; + CTL_LSGL(io) = NULL; #if 0 scsi_path_string(io, path_str, sizeof(path_str)); @@ -12679,7 +12678,7 @@ ctl_datamove_remote_read_cb(struct ctl_ha_dt_req *rq) ctl_dt_req_free(rq); /* Switch the pointer over so the FETD knows what to do */ - io->scsiio.kern_data_ptr = (uint8_t *)io->io_hdr.local_sglist; + io->scsiio.kern_data_ptr = (uint8_t *)CTL_LSGL(io); /* * Use a custom move done callback, since we need to send completion @@ -12702,7 +12701,7 @@ ctl_datamove_remote_sgl_setup(union ctl_io *io) int i; retval = 0; - local_sglist = io->io_hdr.local_sglist; + local_sglist = CTL_LSGL(io); len_to_go = io->scsiio.kern_data_len; /* @@ -12773,8 +12772,8 @@ ctl_datamove_remote_xfer(union ctl_io *io, unsigned co return (1); } - local_sglist = io->io_hdr.local_sglist; - remote_sglist = io->io_hdr.remote_sglist; + local_sglist = CTL_LSGL(io); + remote_sglist = CTL_RSGL(io); local_used = 0; remote_used = 0; total_used = 0; @@ -12887,10 +12886,10 @@ ctl_datamove_remote_read(union ctl_io *io) * error if there is a problem. */ for (i = 0; i < io->scsiio.kern_sg_entries; i++) - free(io->io_hdr.local_sglist[i].addr, M_CTL); - free(io->io_hdr.remote_sglist, M_CTL); - io->io_hdr.remote_sglist = NULL; - io->io_hdr.local_sglist = NULL; + free(CTL_LSGLT(io)[i].addr, M_CTL); + free(CTL_RSGL(io), M_CTL); + CTL_RSGL(io) = NULL; + CTL_LSGL(io) = NULL; } } @@ -13153,7 +13152,7 @@ bailout: (io->io_hdr.flags & CTL_FLAG_SENT_2OTHER_SC)) { memset(&msg, 0, sizeof(msg)); msg.hdr.msg_type = CTL_MSG_FINISH_IO; - msg.hdr.serializing_sc = io->io_hdr.serializing_sc; + msg.hdr.serializing_sc = io->io_hdr.remote_io; msg.hdr.nexus = io->io_hdr.nexus; ctl_ha_msg_send(CTL_HA_CHAN_CTL, &msg, sizeof(msg.scsi) - sizeof(msg.scsi.sense_data), Modified: stable/11/sys/cam/ctl/ctl_io.h ============================================================================== --- stable/11/sys/cam/ctl/ctl_io.h Mon Mar 11 01:44:18 2019 (r344991) +++ stable/11/sys/cam/ctl/ctl_io.h Mon Mar 11 01:44:37 2019 (r344992) @@ -165,6 +165,15 @@ union ctl_priv { #define CTL_PORT(io) (((struct ctl_softc *)CTL_SOFTC(io))-> \ ctl_ports[(io)->io_hdr.nexus.targ_port]) +/* + * These are used only on Originating SC in XFER mode, where requests don't + * ever reach backends, so we can reuse backend's private storage. + */ +#define CTL_RSGL(io) ((io)->io_hdr.ctl_private[CTL_PRIV_BACKEND].ptrs[0]) +#define CTL_LSGL(io) ((io)->io_hdr.ctl_private[CTL_PRIV_BACKEND].ptrs[1]) +#define CTL_RSGLT(io) ((struct ctl_sg_entry *)CTL_RSGL(io)) +#define CTL_LSGLT(io) ((struct ctl_sg_entry *)CTL_LSGL(io)) + #define CTL_INVALID_PORTNAME 0xFF #define CTL_UNMAPPED_IID 0xFF @@ -227,12 +236,12 @@ struct ctl_io_hdr { struct bintime dma_bt; /* DMA total ticks */ #endif /* CTL_TIME_IO */ uint32_t num_dmas; /* Number of DMAs */ - union ctl_io *original_sc; - union ctl_io *serializing_sc; + union ctl_io *remote_io; /* I/O counterpart on remote HA side */ + void *pad1; void *pool; /* I/O pool */ union ctl_priv ctl_private[CTL_NUM_PRIV];/* CTL private area */ - struct ctl_sg_entry *remote_sglist; - struct ctl_sg_entry *local_sglist; + void *pad2; + void *pad3; STAILQ_ENTRY(ctl_io_hdr) links; /* linked list pointer */ TAILQ_ENTRY(ctl_io_hdr) ooa_links; TAILQ_ENTRY(ctl_io_hdr) blocked_links; From owner-svn-src-stable-11@freebsd.org Mon Mar 11 13:56:52 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id ADE351543F4E; Mon, 11 Mar 2019 13:56:52 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 52E52971C4; Mon, 11 Mar 2019 13:56:52 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 43F47BA7B; Mon, 11 Mar 2019 13:56:52 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2BDuq5S088119; Mon, 11 Mar 2019 13:56:52 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2BDupJh088116; Mon, 11 Mar 2019 13:56:51 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201903111356.x2BDupJh088116@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Mon, 11 Mar 2019 13:56:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r345007 - stable/11/sys/cam/ctl X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/cam/ctl X-SVN-Commit-Revision: 345007 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 52E52971C4 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.95 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-0.99)[-0.995,0]; NEURAL_HAM_SHORT(-0.96)[-0.958,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Mar 2019 13:56:52 -0000 Author: mav Date: Mon Mar 11 13:56:51 2019 New Revision: 345007 URL: https://svnweb.freebsd.org/changeset/base/345007 Log: MFC r344743: Reduce CTL threads priority to about PUSER. Since in most configurations CTL serves as network service, we found that this change improves local system interactivity under heavy load. Priority of main threads is set slightly higher then worker taskqueues to make them quickly sort incoming requests not creating bottlenecks, while plenty of worker taskqueues should be less sensitive to latency. Modified: stable/11/sys/cam/ctl/ctl.c stable/11/sys/cam/ctl/ctl_backend_block.c stable/11/sys/cam/ctl/ctl_backend_ramdisk.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cam/ctl/ctl.c ============================================================================== --- stable/11/sys/cam/ctl/ctl.c Mon Mar 11 13:55:47 2019 (r345006) +++ stable/11/sys/cam/ctl/ctl.c Mon Mar 11 13:56:51 2019 (r345007) @@ -62,6 +62,8 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include #include #include @@ -13343,6 +13345,9 @@ ctl_work_thread(void *arg) int retval; CTL_DEBUG_PRINT(("ctl_work_thread starting\n")); + thread_lock(curthread); + sched_prio(curthread, PUSER - 1); + thread_unlock(curthread); while (!softc->shutdown) { /* @@ -13392,7 +13397,7 @@ ctl_work_thread(void *arg) } /* Sleep until we have something to do. */ - mtx_sleep(thr, &thr->queue_lock, PDROP | PRIBIO, "-", 0); + mtx_sleep(thr, &thr->queue_lock, PDROP, "-", 0); } thr->thread = NULL; kthread_exit(); @@ -13405,6 +13410,9 @@ ctl_lun_thread(void *arg) struct ctl_be_lun *be_lun; CTL_DEBUG_PRINT(("ctl_lun_thread starting\n")); + thread_lock(curthread); + sched_prio(curthread, PUSER - 1); + thread_unlock(curthread); while (!softc->shutdown) { mtx_lock(&softc->ctl_lock); @@ -13418,7 +13426,7 @@ ctl_lun_thread(void *arg) /* Sleep until we have something to do. */ mtx_sleep(&softc->pending_lun_queue, &softc->ctl_lock, - PDROP | PRIBIO, "-", 0); + PDROP, "-", 0); } softc->lun_thread = NULL; kthread_exit(); @@ -13436,6 +13444,9 @@ ctl_thresh_thread(void *arg) int i, e, set; CTL_DEBUG_PRINT(("ctl_thresh_thread starting\n")); + thread_lock(curthread); + sched_prio(curthread, PUSER - 1); + thread_unlock(curthread); while (!softc->shutdown) { mtx_lock(&softc->ctl_lock); @@ -13523,7 +13534,7 @@ ctl_thresh_thread(void *arg) } } mtx_sleep(&softc->thresh_thread, &softc->ctl_lock, - PDROP | PRIBIO, "-", CTL_LBP_PERIOD * hz); + PDROP, "-", CTL_LBP_PERIOD * hz); } softc->thresh_thread = NULL; kthread_exit(); Modified: stable/11/sys/cam/ctl/ctl_backend_block.c ============================================================================== --- stable/11/sys/cam/ctl/ctl_backend_block.c Mon Mar 11 13:55:47 2019 (r345006) +++ stable/11/sys/cam/ctl/ctl_backend_block.c Mon Mar 11 13:56:51 2019 (r345007) @@ -2378,7 +2378,7 @@ ctl_be_block_create(struct ctl_be_block_softc *softc, */ retval = taskqueue_start_threads(&be_lun->io_taskqueue, /*num threads*/num_threads, - /*priority*/PWAIT, + /*priority*/PUSER, /*thread name*/ "%s taskq", be_lun->lunname); Modified: stable/11/sys/cam/ctl/ctl_backend_ramdisk.c ============================================================================== --- stable/11/sys/cam/ctl/ctl_backend_ramdisk.c Mon Mar 11 13:55:47 2019 (r345006) +++ stable/11/sys/cam/ctl/ctl_backend_ramdisk.c Mon Mar 11 13:56:51 2019 (r345007) @@ -1145,7 +1145,7 @@ ctl_backend_ramdisk_create(struct ctl_be_ramdisk_softc retval = taskqueue_start_threads(&be_lun->io_taskqueue, /*num threads*/1, - /*priority*/PWAIT, + /*priority*/PUSER, /*thread name*/ "%s taskq", be_lun->lunname); if (retval != 0) From owner-svn-src-stable-11@freebsd.org Mon Mar 11 18:17:13 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7A04C1528A0D; Mon, 11 Mar 2019 18:17:13 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 1BF2A74266; Mon, 11 Mar 2019 18:17:13 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 08BD6E81F; Mon, 11 Mar 2019 18:17:13 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2BIHCdq027186; Mon, 11 Mar 2019 18:17:12 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2BIHCVm027185; Mon, 11 Mar 2019 18:17:12 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201903111817.x2BIHCVm027185@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Enji Cooper Date: Mon, 11 Mar 2019 18:17:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r345015 - stable/11/usr.bin/getconf X-SVN-Group: stable-11 X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: stable/11/usr.bin/getconf X-SVN-Commit-Revision: 345015 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 1BF2A74266 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.95 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-0.99)[-0.995,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.95)[-0.952,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Mar 2019 18:17:13 -0000 Author: ngie Date: Mon Mar 11 18:17:12 2019 New Revision: 345015 URL: https://svnweb.freebsd.org/changeset/base/345015 Log: MFC r342952: Add Linux compatibility support for `SC_NPROCESSORS_{CONF,ONLN}` as `_SC_NPROCESSORS_{CONF,ONLN}` The goal of this change is to make it easier to use getconf to query the number of available processors. Sadly it's unclear per POSIX, which form (with a preceding _ or lacking it) is correct. I will bring this up on the Austin Group list so this point is clarified for implementors that might rely on this getconf variable in future POSIX spec versions. This is something I noticed when trying to import GoogleTest to FreeBSD as one of the CI scripts uses this variable on Linux. Approved by: emaste (mentor) Differential Revision: https://reviews.freebsd.org/D19527 Modified: stable/11/usr.bin/getconf/sysconf.gperf Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/getconf/sysconf.gperf ============================================================================== --- stable/11/usr.bin/getconf/sysconf.gperf Mon Mar 11 17:39:09 2019 (r345014) +++ stable/11/usr.bin/getconf/sysconf.gperf Mon Mar 11 18:17:12 2019 (r345015) @@ -63,6 +63,8 @@ SYMLOOP_MAX, _SC_SYMLOOP_MAX TIMER_MAX, _SC_TIMER_MAX TTY_NAME_MAX, _SC_TTY_NAME_MAX TZNAME_MAX, _SC_TZNAME_MAX +_NPROCESSORS_CONF, _SC_NPROCESSORS_CONF +_NPROCESSORS_ONLN, _SC_NPROCESSORS_ONLN _POSIX2_CHAR_TERM, _SC_2_CHAR_TERM _POSIX2_C_BIND, _SC_2_C_BIND _POSIX2_C_DEV, _SC_2_C_DEV From owner-svn-src-stable-11@freebsd.org Mon Mar 11 21:35:58 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EDA29152F7A2; Mon, 11 Mar 2019 21:35:57 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 813F884EB4; Mon, 11 Mar 2019 21:35:57 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6CFA918A60; Mon, 11 Mar 2019 21:35:57 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2BLZvAf039143; Mon, 11 Mar 2019 21:35:57 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2BLZuA8039141; Mon, 11 Mar 2019 21:35:56 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201903112135.x2BLZuA8039141@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Mon, 11 Mar 2019 21:35:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r345027 - in stable/11: share/man/man4 sys/opencrypto X-SVN-Group: stable-11 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: in stable/11: share/man/man4 sys/opencrypto X-SVN-Commit-Revision: 345027 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 813F884EB4 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_SHORT(-0.97)[-0.975,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_MEDIUM(-0.99)[-0.995,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Mar 2019 21:35:58 -0000 Author: jhb Date: Mon Mar 11 21:35:56 2019 New Revision: 345027 URL: https://svnweb.freebsd.org/changeset/base/345027 Log: MFC 323891,323892: Support EtA requests via /dev/crypto. 323891: Add a new COP_F_CIPHER_FIRST flag for struct crypt_op. This requests that the cipher be performed before rather than after the HMAC when both are specified for a single operation. 323892: Support AEAD requests with non-GCM algorithms. In particular, support chaining an AES cipher with an HMAC for a request including AAD. This permits submitting requests from userland to encrypt objects like IPSec packets using these algorithms. In the non-GCM case, the authentication crypto descriptor covers both the AAD and the ciphertext. The GCM case remains unchanged. This matches the requests created internally in IPSec. For the non-GCM case, the COP_F_CIPHER_FIRST is also supported since the ordering matters. Note that while this can be used to simulate IPSec requests from userland, this ioctl cannot currently be used to perform TLS requests using AES-CBC and MAC-before-encrypt. Sponsored by: Chelsio Communications Modified: stable/11/share/man/man4/crypto.4 stable/11/sys/opencrypto/cryptodev.c stable/11/sys/opencrypto/cryptodev.h Directory Properties: stable/11/ (props changed) Modified: stable/11/share/man/man4/crypto.4 ============================================================================== --- stable/11/share/man/man4/crypto.4 Mon Mar 11 21:00:58 2019 (r345026) +++ stable/11/share/man/man4/crypto.4 Mon Mar 11 21:35:56 2019 (r345027) @@ -60,7 +60,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 15, 2015 +.Dd September 21, 2017 .Dt CRYPTO 4 .Os .Sh NAME @@ -127,7 +127,9 @@ Asymmetric operations do not use sessions. .It Submit requests, synchronously with .Dv CIOCCRYPT -(symmetric) +(symmetric), +.Dv CIOCCRYPTAEAD +(symmetric), or .Dv CIOCKEY (asymmetric). @@ -279,6 +281,16 @@ supplies the length of the input buffer; the fields .Fa cr_op-\*[Gt]iv supply the addresses of the input buffer, output buffer, one-way hash, and initialization vector, respectively. +If a session is using both a privacy algorithm and a hash algorithm, +the request will generate a hash of the input buffer before +generating the output buffer by default. +If the +.Dv COP_F_CIPHER_FIRST +flag is included in the +.Fa cr_op-\*[Gt]flags +field, +then the request will generate a hash of the output buffer after +executing the privacy algorithm. .It Dv CIOCCRYPTAEAD Fa struct crypt_aead *cr_aead .Bd -literal struct crypt_aead { Modified: stable/11/sys/opencrypto/cryptodev.c ============================================================================== --- stable/11/sys/opencrypto/cryptodev.c Mon Mar 11 21:00:58 2019 (r345026) +++ stable/11/sys/opencrypto/cryptodev.c Mon Mar 11 21:35:56 2019 (r345027) @@ -755,18 +755,22 @@ cryptodev_op( goto bail; } - if (cse->thash) { - crda = crp->crp_desc; - if (cse->txform) - crde = crda->crd_next; - } else { - if (cse->txform) + if (cse->thash && cse->txform) { + if (cop->flags & COP_F_CIPHER_FIRST) { crde = crp->crp_desc; - else { - SDT_PROBE1(opencrypto, dev, ioctl, error, __LINE__); - error = EINVAL; - goto bail; + crda = crde->crd_next; + } else { + crda = crp->crp_desc; + crde = crda->crd_next; } + } else if (cse->thash) { + crda = crp->crp_desc; + } else if (cse->txform) { + crde = crp->crp_desc; + } else { + SDT_PROBE1(opencrypto, dev, ioctl, error, __LINE__); + error = EINVAL; + goto bail; } if ((error = copyin(cop->src, cse->uio.uio_iov[0].iov_base, @@ -941,8 +945,13 @@ cryptodev_aead( goto bail; } - crda = crp->crp_desc; - crde = crda->crd_next; + if (caead->flags & COP_F_CIPHER_FIRST) { + crde = crp->crp_desc; + crda = crde->crd_next; + } else { + crda = crp->crp_desc; + crde = crda->crd_next; + } if ((error = copyin(caead->aad, cse->uio.uio_iov[0].iov_base, caead->aadlen))) { @@ -956,8 +965,16 @@ cryptodev_aead( goto bail; } + /* + * For GCM, crd_len covers only the AAD. For other ciphers + * chained with an HMAC, crd_len covers both the AAD and the + * cipher text. + */ crda->crd_skip = 0; - crda->crd_len = caead->aadlen; + if (cse->cipher == CRYPTO_AES_NIST_GCM_16) + crda->crd_len = caead->aadlen; + else + crda->crd_len = caead->aadlen + caead->len; crda->crd_inject = caead->aadlen + caead->len; crda->crd_alg = cse->mac; Modified: stable/11/sys/opencrypto/cryptodev.h ============================================================================== --- stable/11/sys/opencrypto/cryptodev.h Mon Mar 11 21:00:58 2019 (r345026) +++ stable/11/sys/opencrypto/cryptodev.h Mon Mar 11 21:35:56 2019 (r345027) @@ -238,7 +238,8 @@ struct crypt_op { #define COP_ENCRYPT 1 #define COP_DECRYPT 2 u_int16_t flags; -#define COP_F_BATCH 0x0008 /* Batch op if possible */ +#define COP_F_CIPHER_FIRST 0x0001 /* Cipher before MAC. */ +#define COP_F_BATCH 0x0008 /* Batch op if possible */ u_int len; c_caddr_t src; /* become iov[] inside kernel */ caddr_t dst; From owner-svn-src-stable-11@freebsd.org Mon Mar 11 21:38:00 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 220B7152F82C; Mon, 11 Mar 2019 21:38:00 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B9FC48501D; Mon, 11 Mar 2019 21:37:59 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id AB3F518A62; Mon, 11 Mar 2019 21:37:59 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2BLbxFD039303; Mon, 11 Mar 2019 21:37:59 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2BLbx9k039302; Mon, 11 Mar 2019 21:37:59 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201903112137.x2BLbx9k039302@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Mon, 11 Mar 2019 21:37:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r345028 - stable/11/tools/tools/crypto X-SVN-Group: stable-11 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: stable/11/tools/tools/crypto X-SVN-Commit-Revision: 345028 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: B9FC48501D X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-0.99)[-0.995,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.975,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Mar 2019 21:38:00 -0000 Author: jhb Date: Mon Mar 11 21:37:58 2019 New Revision: 345028 URL: https://svnweb.freebsd.org/changeset/base/345028 Log: MFC 331417,331597: Add the cryptocheck test tool. 331417: Bring in JHB's cryptocheck tool It can be used to validate basic algorithm correctness on a variety of inputs, by comarison to openssl. While here, add some sanity to the crypto/Makefile. The tool may not be perfect, but getting it in tree where collaboration can happen is a nice first step. The pace of development outside of svn seems to have slowed down mid-2017. 331597: Update the license to note my work on cryptocheck was sponsored. Sponsored by: Chelsio Communications Added: stable/11/tools/tools/crypto/cryptocheck.c - copied, changed from r331417, head/tools/tools/crypto/cryptocheck.c Modified: stable/11/tools/tools/crypto/Makefile Directory Properties: stable/11/ (props changed) Modified: stable/11/tools/tools/crypto/Makefile ============================================================================== --- stable/11/tools/tools/crypto/Makefile Mon Mar 11 21:35:56 2019 (r345027) +++ stable/11/tools/tools/crypto/Makefile Mon Mar 11 21:37:58 2019 (r345028) @@ -1,5 +1,6 @@ # $FreeBSD$ # +# Copyright (c) 2018 Conrad Meyer # Copyright (c) 2002, 2003 Sam Leffler, Errno Consulting # All rights reserved. # @@ -25,40 +26,23 @@ # SUCH DAMAGE. # -ALL= cryptotest cryptokeytest cryptostats \ +PROGS= cryptocheck cryptotest cryptokeytest cryptostats \ ubsecstats hifnstats ipsecstats safestats -BINDIR= /usr/local/bin +MAN= +BINDIR?= /usr/local/bin -all: ${ALL} +# cryptocheck: test symmetric crypto functions +LIBADD.cryptocheck+= crypto ssl util -# program to test asymmetric crypto functions -cryptokeytest: cryptokeytest.c - ${CC} -o cryptokeytest cryptokeytest.c -lcrypto +# cryptokeytest: test asymmetric crypto functions +LIBADD.cryptokeytest+= crypto -# program to dump statistics kept by the core crypto code -cryptostats: cryptostats.c - ${CC} -o cryptostats cryptostats.c +# cryptostats: dump statistics kept by the core crypto code +# ubsecstats: print statistics kept by the Broadcom driver +# hifnstats: print statistics kept by the HIFN driver +# safestats: statistics kept by the SafeNet driver +# ipsecstats: print statistics kept by fast ipsec -# program to print statistics kept by the Broadcom driver -ubsecstats: ubsecstats.c - ${CC} -o ubsecstats ubsecstats.c +CLEANFILES+= core a.out -# program to print statistics kept by the HIFN driver -hifnstats: hifnstats.c - ${CC} -o hifnstats hifnstats.c - -# program to print statistics kept by the SafeNet driver -safestats: safestats.c - ${CC} -o safestats safestats.c - -# program to print statistics kept by fast ipsec -ipsecstats: ipsecstats.c - ${CC} -o ipsecstats ipsecstats.c - -clean: - rm -f ${ALL} core a.out - -install: ${ALL} - for i in ${ALL}; do \ - install $$i ${DESTDIR}${BINDIR}; \ - done +.include Copied and modified: stable/11/tools/tools/crypto/cryptocheck.c (from r331417, head/tools/tools/crypto/cryptocheck.c) ============================================================================== --- head/tools/tools/crypto/cryptocheck.c Fri Mar 23 04:31:19 2018 (r331417, copy source) +++ stable/11/tools/tools/crypto/cryptocheck.c Mon Mar 11 21:37:58 2019 (r345028) @@ -1,5 +1,30 @@ /*- - * Copyright (c) 2017 John Baldwin, + * Copyright (c) 2017 Chelsio Communications, Inc. + * All rights reserved. + * Written by: John Baldwin + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ +/*- * Copyright (c) 2004 Sam Leffler, Errno Consulting * All rights reserved. * From owner-svn-src-stable-11@freebsd.org Mon Mar 11 21:51:16 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 81552152FEED; Mon, 11 Mar 2019 21:51:16 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 24B3C85C52; Mon, 11 Mar 2019 21:51:16 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0EC2318C3D; Mon, 11 Mar 2019 21:51:16 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2BLpF94045434; Mon, 11 Mar 2019 21:51:15 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2BLpFsj045433; Mon, 11 Mar 2019 21:51:15 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201903112151.x2BLpFsj045433@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Mon, 11 Mar 2019 21:51:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r345030 - stable/11/sys/opencrypto X-SVN-Group: stable-11 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: stable/11/sys/opencrypto X-SVN-Commit-Revision: 345030 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 24B3C85C52 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-0.99)[-0.995,0]; NEURAL_HAM_SHORT(-0.97)[-0.973,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Mar 2019 21:51:16 -0000 Author: jhb Date: Mon Mar 11 21:51:15 2019 New Revision: 345030 URL: https://svnweb.freebsd.org/changeset/base/345030 Log: MFC 327839: Change the type of 'crp_opaque' from caddr_t to void *. Opaque pointers should be void *. Note that this does not go through the tree removing all of the now-unnecessary casts. Sponsored by: Chelsio Communications Modified: stable/11/sys/opencrypto/cryptodev.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/opencrypto/cryptodev.h ============================================================================== --- stable/11/sys/opencrypto/cryptodev.h Mon Mar 11 21:49:44 2019 (r345029) +++ stable/11/sys/opencrypto/cryptodev.h Mon Mar 11 21:51:15 2019 (r345030) @@ -422,7 +422,7 @@ struct cryptop { #define CRYPTO_F_CBIFSYNC 0x0040 /* Do CBIMM if op is synchronous */ caddr_t crp_buf; /* Data to be processed */ - caddr_t crp_opaque; /* Opaque pointer, passed along */ + void * crp_opaque; /* Opaque pointer, passed along */ struct cryptodesc *crp_desc; /* Linked list of processing descriptors */ int (*crp_callback)(struct cryptop *); /* Callback function */ From owner-svn-src-stable-11@freebsd.org Mon Mar 11 21:56:36 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 22ACE153034D; Mon, 11 Mar 2019 21:56:36 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B940386174; Mon, 11 Mar 2019 21:56:35 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A356918DAF; Mon, 11 Mar 2019 21:56:35 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2BLuZck049794; Mon, 11 Mar 2019 21:56:35 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2BLuZuZ049793; Mon, 11 Mar 2019 21:56:35 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201903112156.x2BLuZuZ049793@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Mon, 11 Mar 2019 21:56:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r345031 - stable/11/sys/opencrypto X-SVN-Group: stable-11 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: stable/11/sys/opencrypto X-SVN-Commit-Revision: 345031 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: B940386174 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-0.99)[-0.995,0]; NEURAL_HAM_SHORT(-0.97)[-0.973,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Mar 2019 21:56:36 -0000 Author: jhb Date: Mon Mar 11 21:56:35 2019 New Revision: 345031 URL: https://svnweb.freebsd.org/changeset/base/345031 Log: MFC 328057: Split crp_buf into a union. This adds explicit crp_mbuf and crp_uio pointers of the right type to replace casts of crp_buf. This does not sweep through changing existing code, but new code should use the correct fields instead of casts. Sponsored by: Chelsio Communications Modified: stable/11/sys/opencrypto/cryptodev.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/opencrypto/cryptodev.h ============================================================================== --- stable/11/sys/opencrypto/cryptodev.h Mon Mar 11 21:51:15 2019 (r345030) +++ stable/11/sys/opencrypto/cryptodev.h Mon Mar 11 21:56:35 2019 (r345031) @@ -421,7 +421,11 @@ struct cryptop { #define CRYPTO_F_DONE 0x0020 /* Operation completed */ #define CRYPTO_F_CBIFSYNC 0x0040 /* Do CBIMM if op is synchronous */ - caddr_t crp_buf; /* Data to be processed */ + union { + caddr_t crp_buf; /* Data to be processed */ + struct mbuf *crp_mbuf; + struct uio *crp_uio; + }; void * crp_opaque; /* Opaque pointer, passed along */ struct cryptodesc *crp_desc; /* Linked list of processing descriptors */ @@ -522,5 +526,6 @@ extern void crypto_copydata(int flags, caddr_t buf, in caddr_t out); extern int crypto_apply(int flags, caddr_t buf, int off, int len, int (*f)(void *, void *, u_int), void *arg); + #endif /* _KERNEL */ #endif /* _CRYPTO_CRYPTO_H_ */ From owner-svn-src-stable-11@freebsd.org Mon Mar 11 22:17:54 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1D2751530956; Mon, 11 Mar 2019 22:17:54 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B539D86BAD; Mon, 11 Mar 2019 22:17:53 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9926A1915B; Mon, 11 Mar 2019 22:17:53 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2BMHrYB060527; Mon, 11 Mar 2019 22:17:53 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2BMHrwo060526; Mon, 11 Mar 2019 22:17:53 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201903112217.x2BMHrwo060526@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Mon, 11 Mar 2019 22:17:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r345033 - stable/11/sys/opencrypto X-SVN-Group: stable-11 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: stable/11/sys/opencrypto X-SVN-Commit-Revision: 345033 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: B539D86BAD X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-0.99)[-0.995,0]; NEURAL_HAM_SHORT(-0.98)[-0.975,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Mar 2019 22:17:54 -0000 Author: jhb Date: Mon Mar 11 22:17:53 2019 New Revision: 345033 URL: https://svnweb.freebsd.org/changeset/base/345033 Log: MFC 328453: Move per-operation data out of the csession structure. Create a struct cryptop_data which contains state needed for a single symmetric crypto operation and move that state out of the session. This closes a race with the CRYPTO_F_DONE flag that can result in use after free. While here, remove the 'cse->error' member. It was just a copy of 'crp->crp_etype' and cryptodev_op() and cryptodev_aead() checked both 'crp->crp_etype' and 'cse->error'. Similarly, do not check for an error from mtx_sleep() since it is not used with PCATCH or a timeout so cannot fail with an error. PR: 218597 Sponsored by: Chelsio Communications Modified: stable/11/sys/opencrypto/cryptodev.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/opencrypto/cryptodev.c ============================================================================== --- stable/11/sys/opencrypto/cryptodev.c Mon Mar 11 22:05:34 2019 (r345032) +++ stable/11/sys/opencrypto/cryptodev.c Mon Mar 11 22:17:53 2019 (r345033) @@ -281,10 +281,14 @@ struct csession { caddr_t mackey; int mackeylen; +}; - struct iovec iovec; +struct cryptop_data { + struct csession *cse; + + struct iovec iovec[1]; struct uio uio; - int error; + bool done; }; struct fcrypt { @@ -707,9 +711,37 @@ bail: #undef SES2 } -static int cryptodev_cb(void *); +static int cryptodev_cb(struct cryptop *); +static struct cryptop_data * +cod_alloc(struct csession *cse, size_t len, struct thread *td) +{ + struct cryptop_data *cod; + struct uio *uio; + cod = malloc(sizeof(struct cryptop_data), M_XDATA, M_WAITOK | M_ZERO); + + cod->cse = cse; + uio = &cod->uio; + uio->uio_iov = cod->iovec; + uio->uio_iovcnt = 1; + uio->uio_resid = len; + uio->uio_segflg = UIO_SYSSPACE; + uio->uio_rw = UIO_WRITE; + uio->uio_td = td; + uio->uio_iov[0].iov_len = len; + uio->uio_iov[0].iov_base = malloc(len, M_XDATA, M_WAITOK); + return (cod); +} + +static void +cod_free(struct cryptop_data *cod) +{ + + free(cod->uio.uio_iov[0].iov_base, M_XDATA); + free(cod, M_XDATA); +} + static int cryptodev_op( struct csession *cse, @@ -717,6 +749,7 @@ cryptodev_op( struct ucred *active_cred, struct thread *td) { + struct cryptop_data *cod = NULL; struct cryptop *crp = NULL; struct cryptodesc *crde = NULL, *crda = NULL; int error; @@ -733,20 +766,10 @@ cryptodev_op( } } - cse->uio.uio_iov = &cse->iovec; - cse->uio.uio_iovcnt = 1; - cse->uio.uio_offset = 0; - cse->uio.uio_resid = cop->len; - cse->uio.uio_segflg = UIO_SYSSPACE; - cse->uio.uio_rw = UIO_WRITE; - cse->uio.uio_td = td; - cse->uio.uio_iov[0].iov_len = cop->len; - if (cse->thash) { - cse->uio.uio_iov[0].iov_len += cse->thash->hashsize; - cse->uio.uio_resid += cse->thash->hashsize; - } - cse->uio.uio_iov[0].iov_base = malloc(cse->uio.uio_iov[0].iov_len, - M_XDATA, M_WAITOK); + if (cse->thash) + cod = cod_alloc(cse, cop->len + cse->thash->hashsize, td); + else + cod = cod_alloc(cse, cop->len, td); crp = crypto_getreq((cse->txform != NULL) + (cse->thash != NULL)); if (crp == NULL) { @@ -773,7 +796,7 @@ cryptodev_op( goto bail; } - if ((error = copyin(cop->src, cse->uio.uio_iov[0].iov_base, + if ((error = copyin(cop->src, cod->uio.uio_iov[0].iov_base, cop->len))) { SDT_PROBE1(opencrypto, dev, ioctl, error, __LINE__); goto bail; @@ -805,10 +828,10 @@ cryptodev_op( crp->crp_ilen = cop->len; crp->crp_flags = CRYPTO_F_IOV | CRYPTO_F_CBIMM | (cop->flags & COP_F_BATCH); - crp->crp_buf = (caddr_t)&cse->uio; - crp->crp_callback = (int (*) (struct cryptop *)) cryptodev_cb; + crp->crp_uio = &cod->uio; + crp->crp_callback = cryptodev_cb; crp->crp_sid = cse->sid; - crp->crp_opaque = (void *)cse; + crp->crp_opaque = cod; if (cop->iv) { if (crde == NULL) { @@ -851,19 +874,20 @@ again: * entry and the crypto_done callback into us. */ error = crypto_dispatch(crp); - mtx_lock(&cse->lock); - if (error == 0 && (crp->crp_flags & CRYPTO_F_DONE) == 0) - error = msleep(crp, &cse->lock, PWAIT, "crydev", 0); - mtx_unlock(&cse->lock); - if (error != 0) { SDT_PROBE1(opencrypto, dev, ioctl, error, __LINE__); goto bail; } + mtx_lock(&cse->lock); + while (!cod->done) + mtx_sleep(cod, &cse->lock, PWAIT, "crydev", 0); + mtx_unlock(&cse->lock); + if (crp->crp_etype == EAGAIN) { crp->crp_etype = 0; crp->crp_flags &= ~CRYPTO_F_DONE; + cod->done = false; goto again; } @@ -873,21 +897,15 @@ again: goto bail; } - if (cse->error) { - SDT_PROBE1(opencrypto, dev, ioctl, error, __LINE__); - error = cse->error; - goto bail; - } - if (cop->dst && - (error = copyout(cse->uio.uio_iov[0].iov_base, cop->dst, + (error = copyout(cod->uio.uio_iov[0].iov_base, cop->dst, cop->len))) { SDT_PROBE1(opencrypto, dev, ioctl, error, __LINE__); goto bail; } if (cop->mac && - (error = copyout((caddr_t)cse->uio.uio_iov[0].iov_base + cop->len, + (error = copyout((caddr_t)cod->uio.uio_iov[0].iov_base + cop->len, cop->mac, cse->thash->hashsize))) { SDT_PROBE1(opencrypto, dev, ioctl, error, __LINE__); goto bail; @@ -896,8 +914,8 @@ again: bail: if (crp) crypto_freereq(crp); - if (cse->uio.uio_iov[0].iov_base) - free(cse->uio.uio_iov[0].iov_base, M_XDATA); + if (cod) + cod_free(cod); return (error); } @@ -909,7 +927,7 @@ cryptodev_aead( struct ucred *active_cred, struct thread *td) { - struct uio *uio; + struct cryptop_data *cod = NULL; struct cryptop *crp = NULL; struct cryptodesc *crde = NULL, *crda = NULL; int error; @@ -925,19 +943,9 @@ cryptodev_aead( return (EINVAL); } - uio = &cse->uio; - uio->uio_iov = &cse->iovec; - uio->uio_iovcnt = 1; - uio->uio_offset = 0; - uio->uio_resid = caead->aadlen + caead->len + cse->thash->hashsize; - uio->uio_segflg = UIO_SYSSPACE; - uio->uio_rw = UIO_WRITE; - uio->uio_td = td; - uio->uio_iov[0].iov_len = uio->uio_resid; + cod = cod_alloc(cse, caead->aadlen + caead->len + cse->thash->hashsize, + td); - uio->uio_iov[0].iov_base = malloc(uio->uio_iov[0].iov_len, - M_XDATA, M_WAITOK); - crp = crypto_getreq(2); if (crp == NULL) { error = ENOMEM; @@ -953,13 +961,13 @@ cryptodev_aead( crde = crda->crd_next; } - if ((error = copyin(caead->aad, cse->uio.uio_iov[0].iov_base, + if ((error = copyin(caead->aad, cod->uio.uio_iov[0].iov_base, caead->aadlen))) { SDT_PROBE1(opencrypto, dev, ioctl, error, __LINE__); goto bail; } - if ((error = copyin(caead->src, (char *)cse->uio.uio_iov[0].iov_base + + if ((error = copyin(caead->src, (char *)cod->uio.uio_iov[0].iov_base + caead->aadlen, caead->len))) { SDT_PROBE1(opencrypto, dev, ioctl, error, __LINE__); goto bail; @@ -996,10 +1004,10 @@ cryptodev_aead( crp->crp_ilen = caead->aadlen + caead->len; crp->crp_flags = CRYPTO_F_IOV | CRYPTO_F_CBIMM | (caead->flags & COP_F_BATCH); - crp->crp_buf = (caddr_t)&cse->uio.uio_iov; - crp->crp_callback = (int (*) (struct cryptop *)) cryptodev_cb; + crp->crp_uio = &cod->uio; + crp->crp_callback = cryptodev_cb; crp->crp_sid = cse->sid; - crp->crp_opaque = (void *)cse; + crp->crp_opaque = cod; if (caead->iv) { if (caead->ivlen > sizeof(crde->crd_iv)) { @@ -1019,7 +1027,7 @@ cryptodev_aead( crde->crd_len -= cse->txform->blocksize; } - if ((error = copyin(caead->tag, (caddr_t)cse->uio.uio_iov[0].iov_base + + if ((error = copyin(caead->tag, (caddr_t)cod->uio.uio_iov[0].iov_base + caead->len + caead->aadlen, cse->thash->hashsize))) { SDT_PROBE1(opencrypto, dev, ioctl, error, __LINE__); goto bail; @@ -1033,19 +1041,20 @@ again: * entry and the crypto_done callback into us. */ error = crypto_dispatch(crp); - mtx_lock(&cse->lock); - if (error == 0 && (crp->crp_flags & CRYPTO_F_DONE) == 0) - error = msleep(crp, &cse->lock, PWAIT, "crydev", 0); - mtx_unlock(&cse->lock); - if (error != 0) { SDT_PROBE1(opencrypto, dev, ioctl, error, __LINE__); goto bail; } + mtx_lock(&cse->lock); + while (!cod->done) + mtx_sleep(cod, &cse->lock, PWAIT, "crydev", 0); + mtx_unlock(&cse->lock); + if (crp->crp_etype == EAGAIN) { crp->crp_etype = 0; crp->crp_flags &= ~CRYPTO_F_DONE; + cod->done = false; goto again; } @@ -1055,20 +1064,14 @@ again: goto bail; } - if (cse->error) { - error = cse->error; - SDT_PROBE1(opencrypto, dev, ioctl, error, __LINE__); - goto bail; - } - if (caead->dst && (error = copyout( - (caddr_t)cse->uio.uio_iov[0].iov_base + caead->aadlen, caead->dst, + (caddr_t)cod->uio.uio_iov[0].iov_base + caead->aadlen, caead->dst, caead->len))) { SDT_PROBE1(opencrypto, dev, ioctl, error, __LINE__); goto bail; } - if ((error = copyout((caddr_t)cse->uio.uio_iov[0].iov_base + + if ((error = copyout((caddr_t)cod->uio.uio_iov[0].iov_base + caead->aadlen + caead->len, caead->tag, cse->thash->hashsize))) { SDT_PROBE1(opencrypto, dev, ioctl, error, __LINE__); goto bail; @@ -1076,21 +1079,26 @@ again: bail: crypto_freereq(crp); - free(cse->uio.uio_iov[0].iov_base, M_XDATA); + if (cod) + cod_free(cod); return (error); } static int -cryptodev_cb(void *op) +cryptodev_cb(struct cryptop *crp) { - struct cryptop *crp = (struct cryptop *) op; - struct csession *cse = (struct csession *)crp->crp_opaque; + struct cryptop_data *cod = crp->crp_opaque; - mtx_lock(&cse->lock); - cse->error = crp->crp_etype; - wakeup_one(crp); - mtx_unlock(&cse->lock); + /* + * Lock to ensure the wakeup() is not missed by the loops + * waiting on cod->done in cryptodev_op() and + * cryptodev_aead(). + */ + mtx_lock(&cod->cse->lock); + cod->done = true; + mtx_unlock(&cod->cse->lock); + wakeup(cod); return (0); } From owner-svn-src-stable-11@freebsd.org Mon Mar 11 22:48:53 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D099F15315AB; Mon, 11 Mar 2019 22:48:52 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6E652880FE; Mon, 11 Mar 2019 22:48:52 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 60E2D196B8; Mon, 11 Mar 2019 22:48:52 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2BMmqAs076752; Mon, 11 Mar 2019 22:48:52 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2BMmptp076749; Mon, 11 Mar 2019 22:48:51 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201903112248.x2BMmptp076749@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Mon, 11 Mar 2019 22:48:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r345039 - in stable/11: share/man/man9 sys/kern sys/sys X-SVN-Group: stable-11 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: in stable/11: share/man/man9 sys/kern sys/sys X-SVN-Commit-Revision: 345039 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 6E652880FE X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-0.99)[-0.995,0]; NEURAL_HAM_SHORT(-0.96)[-0.962,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Mar 2019 22:48:53 -0000 Author: jhb Date: Mon Mar 11 22:48:51 2019 New Revision: 345039 URL: https://svnweb.freebsd.org/changeset/base/345039 Log: MFC 318388: Add sglist_append_sglist(). This function permits a range of one scatter/gather list to be appended to another sglist. This can be used to construct a scatter/gather list that reorders or duplicates ranges from one or more existing scatter/gather lists. Sponsored by: Chelsio Communications Modified: stable/11/share/man/man9/Makefile stable/11/share/man/man9/sglist.9 stable/11/sys/kern/subr_sglist.c stable/11/sys/sys/sglist.h Directory Properties: stable/11/ (props changed) Modified: stable/11/share/man/man9/Makefile ============================================================================== --- stable/11/share/man/man9/Makefile Mon Mar 11 22:43:24 2019 (r345038) +++ stable/11/share/man/man9/Makefile Mon Mar 11 22:48:51 2019 (r345039) @@ -1593,6 +1593,7 @@ MLINKS+=sglist.9 sglist_alloc.9 \ sglist.9 sglist_append_bio.9 \ sglist.9 sglist_append_mbuf.9 \ sglist.9 sglist_append_phys.9 \ + sglist.9 sglist_append_sglist.9 \ sglist.9 sglist_append_uio.9 \ sglist.9 sglist_append_user.9 \ sglist.9 sglist_append_vmpages.9 \ Modified: stable/11/share/man/man9/sglist.9 ============================================================================== --- stable/11/share/man/man9/sglist.9 Mon Mar 11 22:43:24 2019 (r345038) +++ stable/11/share/man/man9/sglist.9 Mon Mar 11 22:48:51 2019 (r345039) @@ -26,7 +26,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 12, 2014 +.Dd May 16, 2017 .Dt SGLIST 9 .Os .Sh NAME @@ -36,6 +36,7 @@ .Nm sglist_append_bio , .Nm sglist_append_mbuf , .Nm sglist_append_phys , +.Nm sglist_append_sglist , .Nm sglist_append_uio , .Nm sglist_append_user , .Nm sglist_append_vmpages , @@ -67,6 +68,8 @@ .Ft int .Fn sglist_append_phys "struct sglist *sg" "vm_paddr_t paddr" "size_t len" .Ft int +.Fn sglist_append_sglist "struct sglist *sg" "struct sglist *source" "size_t offset" "size_t len" +.Ft int .Fn sglist_append_uio "struct sglist *sg" "struct uio *uio" .Ft int .Fn sglist_append_user "struct sglist *sg" "void *buf" "size_t len" "struct thread *td" @@ -250,6 +253,20 @@ The physical address range starts at and is .Fa len bytes long. +.Pp +The +.Nm sglist_append_sglist +function appends physical address ranges described by the scatter/gather list +.Fa source +to the scatter/gather list +.Fa sg . +The physical address ranges start at offset +.Fa offset +within +.Fa source +and continue for +.Fa len +bytes. .Pp The .Nm sglist_append_uio Modified: stable/11/sys/kern/subr_sglist.c ============================================================================== --- stable/11/sys/kern/subr_sglist.c Mon Mar 11 22:43:24 2019 (r345038) +++ stable/11/sys/kern/subr_sglist.c Mon Mar 11 22:48:51 2019 (r345039) @@ -413,6 +413,49 @@ sglist_append_user(struct sglist *sg, void *buf, size_ } /* + * Append a subset of an existing scatter/gather list 'source' to a + * the scatter/gather list 'sg'. If there are insufficient segments, + * then this fails with EFBIG. + */ +int +sglist_append_sglist(struct sglist *sg, struct sglist *source, size_t offset, + size_t length) +{ + struct sgsave save; + struct sglist_seg *ss; + size_t seglen; + int error, i; + + if (sg->sg_maxseg == 0 || length == 0) + return (EINVAL); + SGLIST_SAVE(sg, save); + error = EINVAL; + ss = &sg->sg_segs[sg->sg_nseg - 1]; + for (i = 0; i < source->sg_nseg; i++) { + if (offset >= source->sg_segs[i].ss_len) { + offset -= source->sg_segs[i].ss_len; + continue; + } + seglen = source->sg_segs[i].ss_len - offset; + if (seglen > length) + seglen = length; + error = _sglist_append_range(sg, &ss, + source->sg_segs[i].ss_paddr + offset, seglen); + if (error) + break; + offset = 0; + length -= seglen; + if (length == 0) + break; + } + if (length != 0) + error = EINVAL; + if (error) + SGLIST_RESTORE(sg, save); + return (error); +} + +/* * Append the segments that describe a single uio to a scatter/gather * list. If there are insufficient segments, then this fails with * EFBIG. Modified: stable/11/sys/sys/sglist.h ============================================================================== --- stable/11/sys/sys/sglist.h Mon Mar 11 22:43:24 2019 (r345038) +++ stable/11/sys/sys/sglist.h Mon Mar 11 22:48:51 2019 (r345039) @@ -88,6 +88,8 @@ int sglist_append_bio(struct sglist *sg, struct bio *b int sglist_append_mbuf(struct sglist *sg, struct mbuf *m0); int sglist_append_phys(struct sglist *sg, vm_paddr_t paddr, size_t len); +int sglist_append_sglist(struct sglist *sg, struct sglist *source, + size_t offset, size_t length); int sglist_append_uio(struct sglist *sg, struct uio *uio); int sglist_append_user(struct sglist *sg, void *buf, size_t len, struct thread *td); From owner-svn-src-stable-11@freebsd.org Mon Mar 11 23:16:12 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5E02E1531EAE; Mon, 11 Mar 2019 23:16:12 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 0D12088E96; Mon, 11 Mar 2019 23:16:12 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id EEE8D19C0C; Mon, 11 Mar 2019 23:16:11 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2BNGBBd092515; Mon, 11 Mar 2019 23:16:11 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2BNGA4b092507; Mon, 11 Mar 2019 23:16:10 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201903112316.x2BNGA4b092507@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Mon, 11 Mar 2019 23:16:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r345040 - in stable/11: share/man/man4 sys/conf sys/dev/cxgbe sys/dev/cxgbe/crypto sys/dev/cxgbe/firmware sys/modules/cxgbe sys/modules/cxgbe/ccr sys/powerpc/conf X-SVN-Group: stable-11 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: in stable/11: share/man/man4 sys/conf sys/dev/cxgbe sys/dev/cxgbe/crypto sys/dev/cxgbe/firmware sys/modules/cxgbe sys/modules/cxgbe/ccr sys/powerpc/conf X-SVN-Commit-Revision: 345040 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 0D12088E96 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_SHORT(-0.97)[-0.965,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_MEDIUM(-1.00)[-0.995,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Mar 2019 23:16:12 -0000 Author: jhb Date: Mon Mar 11 23:16:10 2019 New Revision: 345040 URL: https://svnweb.freebsd.org/changeset/base/345040 Log: MFC 318429,318967,319721,319723,323600,323724,328353-328361,330042,343056: Add a driver for the Chelsio T6 crypto accelerator engine. Note that with the set of commits in this batch, no additional tunables are needed to use the driver once it is loaded. 318429: Add a driver for the Chelsio T6 crypto accelerator engine. The ccr(4) driver supports use of the crypto accelerator engine on Chelsio T6 NICs in "lookaside" mode via the opencrypto framework. Currently, the driver supports AES-CBC, AES-CTR, AES-GCM, and AES-XTS cipher algorithms as well as the SHA1-HMAC, SHA2-256-HMAC, SHA2-384-HMAC, and SHA2-512-HMAC authentication algorithms. The driver also supports chaining one of AES-CBC, AES-CTR, or AES-XTS with an authentication algorithm for encrypt-then-authenticate operations. Note that this driver is still under active development and testing and may not yet be ready for production use. It does pass the tests in tests/sys/opencrypto with the exception that the AES-GCM implementation in the driver does not yet support requests with a zero byte payload. To use this driver currently, the "uwire" configuration must be used along with explicitly enabling support for lookaside crypto capabilities in the cxgbe(4) driver. These can be done by setting the following tunables before loading the cxgbe(4) driver: hw.cxgbe.config_file=uwire hw.cxgbe.cryptocaps_allowed=-1 318967: Fail large requests with EFBIG. The adapter firmware in general does not accept PDUs larger than 64k - 1 bytes in size. Sending crypto requests larger than this size result in hangs or incorrect output, so reject them with EFBIG. For requests chaining an AES cipher with an HMAC, the firmware appears to require slightly smaller requests (around 512 bytes). 319721: Add explicit handling for requests with an empty payload. - For HMAC requests, construct a special input buffer to request an empty hash result. - For plain cipher requests and requests that chain an AES cipher with an HMAC, fail with EINVAL if there is no cipher payload. If needed in the future, chained requests that only contain AAD could be serviced as HMAC-only requests. - For GCM requests, the hardware does not support generating the tag for an AAD-only request. Instead, complete these requests synchronously in software on the assumption that such requests are rare. 319723: Fix the software fallback for GCM to validate the existing tag for decrypts. 323600: Fix some incorrect sysctl pointers for some error stats. The bad_session, sglist_error, and process_error sysctl nodes were returning the value of the pad_error node instead of the appropriate error counters. 323724: Enable support for lookaside crypto operations by default. This permits ccr(4) to be used with the default firmware configuration file. 328353: Always store the IV in the immediate portion of a work request. Combined authentication-encryption and GCM requests already stored the IV in the immediate explicitly. This extends this behavior to block cipher requests to work around a firmware bug. While here, simplify the AEAD and GCM handlers to not include always-true conditions. 328354: Always set the IV location to IV_NOP. The firmware ignores this field in the FW_CRYPTO_LOOKASIDE_WR work request. 328355: Reject requests with AAD and IV larger than 511 bytes. The T6 crypto engine's control messages only support a total AAD length (including the prefixed IV) of 511 bytes. Reject requests with large AAD rather than returning incorrect results. 328356: Don't discard AAD and IV output data for AEAD requests. The T6 can hang when processing certain AEAD requests if the request sets a flag asking the crypto engine to discard the input IV and AAD rather than copying them into the output buffer. The existing driver always discards the IV and AAD as we do not need it. As a workaround, allocate a single "dummy" buffer when the ccr driver attaches and change all AEAD requests to write the IV and AAD to this scratch buffer. The contents of the scratch buffer are never used (similar to "bogus_page"), and it is ok for multiple in-flight requests to share this dummy buffer. 328357: Fail crypto requests when the resulting work request is too large. Most crypto requests will not trigger this condition, but a request with a highly-fragmented data buffer (and a resulting "large" S/G list) could trigger it. 328358: Clamp DSGL entries to a length of 2KB. This works around an issue in the T6 that can result in DMA engine stalls if an error occurs while processing a DSGL entry with a length larger than 2KB. 328359: Expand the software fallback for GCM to cover more cases. - Extend ccr_gcm_soft() to handle requests with a non-empty payload. While here, switch to allocating the GMAC context instead of placing it on the stack since it is over 1KB in size. - Allow ccr_gcm() to return a special error value (EMSGSIZE) which triggers a fallback to ccr_gcm_soft(). Move the existing empty payload check into ccr_gcm() and change a few other cases (e.g. large AAD) to fallback to software via EMSGSIZE as well. - Add a new 'sw_fallback' stat to count the number of requests processed via the software fallback. 328360: Don't read or generate an IV until all error checking is complete. In particular, this avoids edge cases where a generated IV might be written into the output buffer even though the request is failed with an error. 328361: Store IV in output buffer in GCM software fallback when requested. Properly honor the lack of the CRD_F_IV_PRESENT flag in the GCM software fallback case for encryption requests. 330042: Don't overflow the ipad[] array when clearing the remainder. After the auth key is copied into the ipad[] array, any remaining bytes are cleared to zero (in case the key is shorter than one block size). The full block size was used as the length of the zero rather than the size of the remaining ipad[]. In practice this overflow was harmless as it could only clear bytes in the following opad[] array which is initialized with a copy of ipad[] in the next statement. 343056: Reject new sessions if the necessary queues aren't initialized. ccr reuses the control queue and first rx queue from the first port on each adapter. The driver cannot send requests until those queues are initialized. Refuse to create sessions for now if the queues aren't ready. This is a workaround until cxgbe allocates one or more dedicated queues for ccr. Relnotes: yes Sponsored by: Chelsio Communications Added: stable/11/share/man/man4/ccr.4 - copied unchanged from r318429, head/share/man/man4/ccr.4 stable/11/sys/dev/cxgbe/crypto/ - copied from r318429, head/sys/dev/cxgbe/crypto/ stable/11/sys/modules/cxgbe/ccr/ - copied from r318429, head/sys/modules/cxgbe/ccr/ Modified: stable/11/share/man/man4/Makefile stable/11/share/man/man4/cxgbe.4 stable/11/sys/conf/NOTES stable/11/sys/conf/files stable/11/sys/dev/cxgbe/adapter.h stable/11/sys/dev/cxgbe/crypto/t4_crypto.c stable/11/sys/dev/cxgbe/firmware/t6fw_cfg.txt stable/11/sys/dev/cxgbe/t4_main.c stable/11/sys/modules/cxgbe/Makefile stable/11/sys/powerpc/conf/NOTES Directory Properties: stable/11/ (props changed) Modified: stable/11/share/man/man4/Makefile ============================================================================== --- stable/11/share/man/man4/Makefile Mon Mar 11 22:48:51 2019 (r345039) +++ stable/11/share/man/man4/Makefile Mon Mar 11 23:16:10 2019 (r345040) @@ -101,6 +101,7 @@ MAN= aac.4 \ cc_newreno.4 \ cc_vegas.4 \ ${_ccd.4} \ + ccr.4 \ cd.4 \ cdce.4 \ cfi.4 \ Copied: stable/11/share/man/man4/ccr.4 (from r318429, head/share/man/man4/ccr.4) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/share/man/man4/ccr.4 Mon Mar 11 23:16:10 2019 (r345040, copy of r318429, head/share/man/man4/ccr.4) @@ -0,0 +1,110 @@ +.\" Copyright (c) 2017, Chelsio Inc +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd May 16, 2017 +.Dt CCR 4 +.Os +.Sh NAME +.Nm ccr +.Nd "Chelsio T6 crypto accelerator driver" +.Sh SYNOPSIS +To compile this driver into the kernel, +place the following lines in your +kernel configuration file: +.Bd -ragged -offset indeunt +.Cd "device ccr" +.Ed +.Pp +To load the driver as a +module at boot time, place the following line in +.Xr loader.conf 5 : +.Bd -literal -offset indent +ccr_load="YES" +.Ed +.Sh DESCRIPTION +The +.Nm +driver provides support for the crypto accelerator engine included on +PCI Express Ethernet adapters based on the Chelsio Terminator 6 ASIC (T6). +The driver accelerates AES-CBC, AES-CTR, AES-GCM, AES-XTS, SHA1-HMAC, +SHA2-256-HMAC, SHA2-384-HMAC, and SHA2-512-HMAC operations for +.Xr crypto 4 +and +.Xr ipsec 4 . +The driver also supports chaining one of AES-CBC, AES-CTR, or AES-XTS with +SHA1-HMAC, SHA2-256-HMAC, SHA2-384-HMAC, or SHA2-512-HMAC for +encrypt-then-authenticate operations. +For further hardware information and questions related to hardware +requirements, see +.Pa http://www.chelsio.com/ . +.Pp +The +.Nm +driver attaches as a child of an existing Chelsio NIC device and thus +requires that the +.Xr cxgbe 4 +driver be active. +.Sh HARDWARE +The +.Nm +driver supports the crypto accelerator engine included on adapters +based on the T6 ASIC: +.Pp +.Bl -bullet -compact +.It +Chelsio T6225-CR +.It +Chelsio T6225-SO-CR +.It +Chelsio T62100-LP-CR +.It +Chelsio T62100-SO-CR +.It +Chelsio T62100-CR +.El +.Sh SUPPORT +For general information and support, +go to the Chelsio support website at: +.Pa http://www.chelsio.com/ . +.Pp +If an issue is identified with this driver with a supported adapter, +email all the specific information related to the issue to +.Aq Mt support@chelsio.com . +.Sh SEE ALSO +.Xr crypto 4 , +.Xr cxgbe 4 , +.Xr ipsec 4 +.Sh HISTORY +The +.Nm +device driver first appeared in +.Fx 12.0 . +.Sh AUTHORS +.An -nosplit +The +.Nm +driver was written by +.An John Baldwin Aq Mt jhb@FreeBSD.org . Modified: stable/11/share/man/man4/cxgbe.4 ============================================================================== --- stable/11/share/man/man4/cxgbe.4 Mon Mar 11 22:48:51 2019 (r345039) +++ stable/11/share/man/man4/cxgbe.4 Mon Mar 11 23:16:10 2019 (r345040) @@ -363,6 +363,7 @@ email all the specific information related to the issu .Sh SEE ALSO .Xr altq 4 , .Xr arp 4 , +.Xr ccr 4 , .Xr cxgb 4 , .Xr cxgbev 4 , .Xr netintro 4 , Modified: stable/11/sys/conf/NOTES ============================================================================== --- stable/11/sys/conf/NOTES Mon Mar 11 22:48:51 2019 (r345039) +++ stable/11/sys/conf/NOTES Mon Mar 11 23:16:10 2019 (r345040) @@ -2884,6 +2884,8 @@ device cryptodev # /dev/crypto for access to h/w device rndtest # FIPS 140-2 entropy tester +device ccr # Chelsio T6 + device hifn # Hifn 7951, 7781, etc. options HIFN_DEBUG # enable debugging support: hw.hifn.debug options HIFN_RNDTEST # enable rndtest support Modified: stable/11/sys/conf/files ============================================================================== --- stable/11/sys/conf/files Mon Mar 11 22:48:51 2019 (r345039) +++ stable/11/sys/conf/files Mon Mar 11 23:16:10 2019 (r345040) @@ -1456,6 +1456,8 @@ t6fw.fw optional cxgbe \ compile-with "${NORMAL_FW}" \ no-obj no-implicit-rule \ clean "t6fw.fw" +dev/cxgbe/crypto/t4_crypto.c optional ccr \ + compile-with "${NORMAL_C} -I$S/dev/cxgbe" dev/cy/cy.c optional cy dev/cy/cy_isa.c optional cy isa dev/cy/cy_pci.c optional cy pci Modified: stable/11/sys/dev/cxgbe/adapter.h ============================================================================== --- stable/11/sys/dev/cxgbe/adapter.h Mon Mar 11 22:48:51 2019 (r345039) +++ stable/11/sys/dev/cxgbe/adapter.h Mon Mar 11 23:16:10 2019 (r345040) @@ -802,6 +802,7 @@ struct adapter { struct iw_tunables iwt; void *iwarp_softc; /* (struct c4iw_dev *) */ void *iscsi_ulp_softc; /* (struct cxgbei_data *) */ + void *ccr_softc; /* (struct ccr_softc *) */ struct l2t_data *l2t; /* L2 table */ struct tid_info tids; Modified: stable/11/sys/dev/cxgbe/crypto/t4_crypto.c ============================================================================== --- head/sys/dev/cxgbe/crypto/t4_crypto.c Wed May 17 22:13:07 2017 (r318429) +++ stable/11/sys/dev/cxgbe/crypto/t4_crypto.c Mon Mar 11 23:16:10 2019 (r345040) @@ -111,12 +111,26 @@ __FBSDID("$FreeBSD$"); */ /* - * The documentation for CPL_RX_PHYS_DSGL claims a maximum of 32 - * SG entries. + * The crypto engine supports a maximum AAD size of 511 bytes. */ +#define MAX_AAD_LEN 511 + +/* + * The documentation for CPL_RX_PHYS_DSGL claims a maximum of 32 SG + * entries. While the CPL includes a 16-bit length field, the T6 can + * sometimes hang if an error occurs while processing a request with a + * single DSGL entry larger than 2k. + */ #define MAX_RX_PHYS_DSGL_SGE 32 -#define DSGL_SGE_MAXLEN 65535 +#define DSGL_SGE_MAXLEN 2048 +/* + * The adapter only supports requests with a total input or output + * length of 64k-1 or smaller. Longer requests either result in hung + * requests or incorrect results. + */ +#define MAX_REQUEST_SIZE 65535 + static MALLOC_DEFINE(M_CCR, "ccr", "Chelsio T6 crypto"); struct ccr_session_hmac { @@ -178,6 +192,13 @@ struct ccr_softc { struct sglist *sg_ulptx; struct sglist *sg_dsgl; + /* + * Pre-allocate a dummy output buffer for the IV and AAD for + * AEAD requests. + */ + char *iv_aad_buf; + struct sglist *sg_iv_aad; + /* Statistics. */ uint64_t stats_blkcipher_encrypt; uint64_t stats_blkcipher_decrypt; @@ -193,6 +214,7 @@ struct ccr_softc { uint64_t stats_bad_session; uint64_t stats_sglist_error; uint64_t stats_process_error; + uint64_t stats_sw_fallback; }; /* @@ -358,7 +380,7 @@ ccr_use_imm_data(u_int transhdr_len, u_int input_len) static void ccr_populate_wreq(struct ccr_softc *sc, struct chcr_wr *crwr, u_int kctx_len, u_int wr_len, uint32_t sid, u_int imm_len, u_int sgl_len, u_int hash_size, - u_int iv_loc, struct cryptop *crp) + struct cryptop *crp) { u_int cctx_size; @@ -376,7 +398,7 @@ ccr_populate_wreq(struct ccr_softc *sc, struct chcr_wr V_FW_CRYPTO_LOOKASIDE_WR_RX_CHID(sc->tx_channel_id) | V_FW_CRYPTO_LOOKASIDE_WR_LCB(0) | V_FW_CRYPTO_LOOKASIDE_WR_PHASH(0) | - V_FW_CRYPTO_LOOKASIDE_WR_IV(iv_loc) | + V_FW_CRYPTO_LOOKASIDE_WR_IV(IV_NOP) | V_FW_CRYPTO_LOOKASIDE_WR_FQIDX(0) | V_FW_CRYPTO_LOOKASIDE_WR_TX_CH(0) | V_FW_CRYPTO_LOOKASIDE_WR_RX_Q_ID(sc->rxq->iq.abs_id)); @@ -412,6 +434,12 @@ ccr_hmac(struct ccr_softc *sc, uint32_t sid, struct cc u_int imm_len, iopad_size; int error, sgl_nsegs, sgl_len; + crd = crp->crp_desc; + + /* Reject requests with too large of an input buffer. */ + if (crd->crd_len > MAX_REQUEST_SIZE) + return (EFBIG); + axf = s->hmac.auth_hash; /* PADs must be 128-bit aligned. */ @@ -425,8 +453,11 @@ ccr_hmac(struct ccr_softc *sc, uint32_t sid, struct cc hash_size_in_response = axf->hashsize; transhdr_len = HASH_TRANSHDR_SIZE(kctx_len); - crd = crp->crp_desc; - if (ccr_use_imm_data(transhdr_len, crd->crd_len)) { + if (crd->crd_len == 0) { + imm_len = axf->blocksize; + sgl_nsegs = 0; + sgl_len = 0; + } else if (ccr_use_imm_data(transhdr_len, crd->crd_len)) { imm_len = crd->crd_len; sgl_nsegs = 0; sgl_len = 0; @@ -442,6 +473,8 @@ ccr_hmac(struct ccr_softc *sc, uint32_t sid, struct cc } wr_len = roundup2(transhdr_len, 16) + roundup2(imm_len, 16) + sgl_len; + if (wr_len > SGE_MAX_WR_LEN) + return (EFBIG); wr = alloc_wrqe(wr_len, sc->txq); if (wr == NULL) { sc->stats_wr_nomem++; @@ -451,7 +484,7 @@ ccr_hmac(struct ccr_softc *sc, uint32_t sid, struct cc memset(crwr, 0, wr_len); ccr_populate_wreq(sc, crwr, kctx_len, wr_len, sid, imm_len, sgl_len, - hash_size_in_response, IV_NOP, crp); + hash_size_in_response, crp); /* XXX: Hardcodes SGE loopback channel of 0. */ crwr->sec_cpl.op_ivinsrtofst = htobe32( @@ -461,7 +494,8 @@ ccr_hmac(struct ccr_softc *sc, uint32_t sid, struct cc V_CPL_TX_SEC_PDU_CPLLEN(2) | V_CPL_TX_SEC_PDU_PLACEHOLDER(0) | V_CPL_TX_SEC_PDU_IVINSRTOFST(0)); - crwr->sec_cpl.pldlen = htobe32(crd->crd_len); + crwr->sec_cpl.pldlen = htobe32(crd->crd_len == 0 ? axf->blocksize : + crd->crd_len); crwr->sec_cpl.cipherstop_lo_authinsert = htobe32( V_CPL_TX_SEC_PDU_AUTHSTART(1) | V_CPL_TX_SEC_PDU_AUTHSTOP(0)); @@ -474,7 +508,8 @@ ccr_hmac(struct ccr_softc *sc, uint32_t sid, struct cc V_SCMD_AUTH_MODE(s->hmac.auth_mode) | V_SCMD_HMAC_CTRL(CHCR_SCMD_HMAC_CTRL_NO_TRUNC)); crwr->sec_cpl.ivgen_hdrlen = htobe32( - V_SCMD_LAST_FRAG(0) | V_SCMD_MORE_FRAGS(0) | V_SCMD_MAC_ONLY(1)); + V_SCMD_LAST_FRAG(0) | + V_SCMD_MORE_FRAGS(crd->crd_len == 0 ? 1 : 0) | V_SCMD_MAC_ONLY(1)); memcpy(crwr->key_ctx.key, s->hmac.ipad, s->hmac.partial_digest_len); memcpy(crwr->key_ctx.key + iopad_size, s->hmac.opad, @@ -488,7 +523,11 @@ ccr_hmac(struct ccr_softc *sc, uint32_t sid, struct cc V_KEY_CONTEXT_MK_SIZE(s->hmac.mk_size) | V_KEY_CONTEXT_VALID(1)); dst = (char *)(crwr + 1) + kctx_len + DUMMY_BYTES; - if (imm_len != 0) + if (crd->crd_len == 0) { + dst[0] = 0x80; + *(uint64_t *)(dst + axf->blocksize - sizeof(uint64_t)) = + htobe64(axf->blocksize << 3); + } else if (imm_len != 0) crypto_copydata(crp->crp_flags, crp->crp_buf, crd->crd_skip, crd->crd_len, dst); else @@ -524,7 +563,7 @@ ccr_blkcipher(struct ccr_softc *sc, uint32_t sid, stru struct wrqe *wr; struct cryptodesc *crd; char *dst; - u_int iv_loc, kctx_len, key_half, op_type, transhdr_len, wr_len; + u_int kctx_len, key_half, op_type, transhdr_len, wr_len; u_int imm_len; int dsgl_nsegs, dsgl_len; int sgl_nsegs, sgl_len; @@ -532,32 +571,21 @@ ccr_blkcipher(struct ccr_softc *sc, uint32_t sid, stru crd = crp->crp_desc; - if (s->blkcipher.key_len == 0) + if (s->blkcipher.key_len == 0 || crd->crd_len == 0) return (EINVAL); if (crd->crd_alg == CRYPTO_AES_CBC && (crd->crd_len % AES_BLOCK_LEN) != 0) return (EINVAL); - iv_loc = IV_NOP; - if (crd->crd_flags & CRD_F_ENCRYPT) { + /* Reject requests with too large of an input buffer. */ + if (crd->crd_len > MAX_REQUEST_SIZE) + return (EFBIG); + + if (crd->crd_flags & CRD_F_ENCRYPT) op_type = CHCR_ENCRYPT_OP; - if (crd->crd_flags & CRD_F_IV_EXPLICIT) - memcpy(iv, crd->crd_iv, s->blkcipher.iv_len); - else - arc4rand(iv, s->blkcipher.iv_len, 0); - iv_loc = IV_IMMEDIATE; - if ((crd->crd_flags & CRD_F_IV_PRESENT) == 0) - crypto_copyback(crp->crp_flags, crp->crp_buf, - crd->crd_inject, s->blkcipher.iv_len, iv); - } else { + else op_type = CHCR_DECRYPT_OP; - if (crd->crd_flags & CRD_F_IV_EXPLICIT) { - memcpy(iv, crd->crd_iv, s->blkcipher.iv_len); - iv_loc = IV_IMMEDIATE; - } else - iv_loc = IV_DSGL; - } - + sglist_reset(sc->sg_dsgl); error = sglist_append_sglist(sc->sg_dsgl, sc->sg_crp, crd->crd_skip, crd->crd_len); @@ -575,22 +603,11 @@ ccr_blkcipher(struct ccr_softc *sc, uint32_t sid, stru if (ccr_use_imm_data(transhdr_len, crd->crd_len + s->blkcipher.iv_len)) { imm_len = crd->crd_len; - if (iv_loc == IV_DSGL) { - crypto_copydata(crp->crp_flags, crp->crp_buf, - crd->crd_inject, s->blkcipher.iv_len, iv); - iv_loc = IV_IMMEDIATE; - } sgl_nsegs = 0; sgl_len = 0; } else { imm_len = 0; sglist_reset(sc->sg_ulptx); - if (iv_loc == IV_DSGL) { - error = sglist_append_sglist(sc->sg_ulptx, sc->sg_crp, - crd->crd_inject, s->blkcipher.iv_len); - if (error) - return (error); - } error = sglist_append_sglist(sc->sg_ulptx, sc->sg_crp, crd->crd_skip, crd->crd_len); if (error) @@ -599,9 +616,10 @@ ccr_blkcipher(struct ccr_softc *sc, uint32_t sid, stru sgl_len = ccr_ulptx_sgl_len(sgl_nsegs); } - wr_len = roundup2(transhdr_len, 16) + roundup2(imm_len, 16) + sgl_len; - if (iv_loc == IV_IMMEDIATE) - wr_len += s->blkcipher.iv_len; + wr_len = roundup2(transhdr_len, 16) + s->blkcipher.iv_len + + roundup2(imm_len, 16) + sgl_len; + if (wr_len > SGE_MAX_WR_LEN) + return (EFBIG); wr = alloc_wrqe(wr_len, sc->txq); if (wr == NULL) { sc->stats_wr_nomem++; @@ -610,8 +628,29 @@ ccr_blkcipher(struct ccr_softc *sc, uint32_t sid, stru crwr = wrtod(wr); memset(crwr, 0, wr_len); + /* + * Read the existing IV from the request or generate a random + * one if none is provided. Optionally copy the generated IV + * into the output buffer if requested. + */ + if (op_type == CHCR_ENCRYPT_OP) { + if (crd->crd_flags & CRD_F_IV_EXPLICIT) + memcpy(iv, crd->crd_iv, s->blkcipher.iv_len); + else + arc4rand(iv, s->blkcipher.iv_len, 0); + if ((crd->crd_flags & CRD_F_IV_PRESENT) == 0) + crypto_copyback(crp->crp_flags, crp->crp_buf, + crd->crd_inject, s->blkcipher.iv_len, iv); + } else { + if (crd->crd_flags & CRD_F_IV_EXPLICIT) + memcpy(iv, crd->crd_iv, s->blkcipher.iv_len); + else + crypto_copydata(crp->crp_flags, crp->crp_buf, + crd->crd_inject, s->blkcipher.iv_len, iv); + } + ccr_populate_wreq(sc, crwr, kctx_len, wr_len, sid, imm_len, sgl_len, 0, - iv_loc, crp); + crp); /* XXX: Hardcodes SGE loopback channel of 0. */ crwr->sec_cpl.op_ivinsrtofst = htobe32( @@ -674,10 +713,8 @@ ccr_blkcipher(struct ccr_softc *sc, uint32_t sid, stru dst = (char *)(crwr + 1) + kctx_len; ccr_write_phys_dsgl(sc, dst, dsgl_nsegs); dst += sizeof(struct cpl_rx_phys_dsgl) + dsgl_len; - if (iv_loc == IV_IMMEDIATE) { - memcpy(dst, iv, s->blkcipher.iv_len); - dst += s->blkcipher.iv_len; - } + memcpy(dst, iv, s->blkcipher.iv_len); + dst += s->blkcipher.iv_len; if (imm_len != 0) crypto_copydata(crp->crp_flags, crp->crp_buf, crd->crd_skip, crd->crd_len, dst); @@ -729,7 +766,7 @@ ccr_authenc(struct ccr_softc *sc, uint32_t sid, struct struct wrqe *wr; struct auth_hash *axf; char *dst; - u_int iv_loc, kctx_len, key_half, op_type, transhdr_len, wr_len; + u_int kctx_len, key_half, op_type, transhdr_len, wr_len; u_int hash_size_in_response, imm_len, iopad_size; u_int aad_start, aad_len, aad_stop; u_int auth_start, auth_stop, auth_insert; @@ -739,53 +776,65 @@ ccr_authenc(struct ccr_softc *sc, uint32_t sid, struct int sgl_nsegs, sgl_len; int error; - if (s->blkcipher.key_len == 0) + /* + * If there is a need in the future, requests with an empty + * payload could be supported as HMAC-only requests. + */ + if (s->blkcipher.key_len == 0 || crde->crd_len == 0) return (EINVAL); if (crde->crd_alg == CRYPTO_AES_CBC && (crde->crd_len % AES_BLOCK_LEN) != 0) return (EINVAL); /* - * AAD is only permitted before the cipher/plain text, not - * after. + * Compute the length of the AAD (data covered by the + * authentication descriptor but not the encryption + * descriptor). To simplify the logic, AAD is only permitted + * before the cipher/plain text, not after. This is true of + * all currently-generated requests. */ if (crda->crd_len + crda->crd_skip > crde->crd_len + crde->crd_skip) return (EINVAL); + if (crda->crd_skip < crde->crd_skip) { + if (crda->crd_skip + crda->crd_len > crde->crd_skip) + aad_len = (crde->crd_skip - crda->crd_skip); + else + aad_len = crda->crd_len; + } else + aad_len = 0; + if (aad_len + s->blkcipher.iv_len > MAX_AAD_LEN) + return (EINVAL); axf = s->hmac.auth_hash; hash_size_in_response = s->hmac.hash_len; - - /* - * The IV is always stored at the start of the buffer even - * though it may be duplicated in the payload. The crypto - * engine doesn't work properly if the IV offset points inside - * of the AAD region, so a second copy is always required. - */ - iv_loc = IV_IMMEDIATE; - if (crde->crd_flags & CRD_F_ENCRYPT) { + if (crde->crd_flags & CRD_F_ENCRYPT) op_type = CHCR_ENCRYPT_OP; - if (crde->crd_flags & CRD_F_IV_EXPLICIT) - memcpy(iv, crde->crd_iv, s->blkcipher.iv_len); - else - arc4rand(iv, s->blkcipher.iv_len, 0); - if ((crde->crd_flags & CRD_F_IV_PRESENT) == 0) - crypto_copyback(crp->crp_flags, crp->crp_buf, - crde->crd_inject, s->blkcipher.iv_len, iv); - } else { + else op_type = CHCR_DECRYPT_OP; - if (crde->crd_flags & CRD_F_IV_EXPLICIT) - memcpy(iv, crde->crd_iv, s->blkcipher.iv_len); - else - crypto_copydata(crp->crp_flags, crp->crp_buf, - crde->crd_inject, s->blkcipher.iv_len, iv); - } /* * The output buffer consists of the cipher text followed by * the hash when encrypting. For decryption it only contains * the plain text. + * + * Due to a firmware bug, the output buffer must include a + * dummy output buffer for the IV and AAD prior to the real + * output buffer. */ + if (op_type == CHCR_ENCRYPT_OP) { + if (s->blkcipher.iv_len + aad_len + crde->crd_len + + hash_size_in_response > MAX_REQUEST_SIZE) + return (EFBIG); + } else { + if (s->blkcipher.iv_len + aad_len + crde->crd_len > + MAX_REQUEST_SIZE) + return (EFBIG); + } sglist_reset(sc->sg_dsgl); + error = sglist_append_sglist(sc->sg_dsgl, sc->sg_iv_aad, 0, + s->blkcipher.iv_len + aad_len); + if (error) + return (error); error = sglist_append_sglist(sc->sg_dsgl, sc->sg_crp, crde->crd_skip, crde->crd_len); if (error) @@ -815,15 +864,25 @@ ccr_authenc(struct ccr_softc *sc, uint32_t sid, struct * The input buffer consists of the IV, any AAD, and then the * cipher/plain text. For decryption requests the hash is * appended after the cipher text. + * + * The IV is always stored at the start of the input buffer + * even though it may be duplicated in the payload. The + * crypto engine doesn't work properly if the IV offset points + * inside of the AAD region, so a second copy is always + * required. */ - if (crda->crd_skip < crde->crd_skip) { - if (crda->crd_skip + crda->crd_len > crde->crd_skip) - aad_len = (crde->crd_skip - crda->crd_skip); - else - aad_len = crda->crd_len; - } else - aad_len = 0; input_len = aad_len + crde->crd_len; + + /* + * The firmware hangs if sent a request which is a + * bit smaller than MAX_REQUEST_SIZE. In particular, the + * firmware appears to require 512 - 16 bytes of spare room + * along with the size of the hash even if the hash isn't + * included in the input buffer. + */ + if (input_len + roundup2(axf->hashsize, 16) + (512 - 16) > + MAX_REQUEST_SIZE) + return (EFBIG); if (op_type == CHCR_DECRYPT_OP) input_len += hash_size_in_response; if (ccr_use_imm_data(transhdr_len, s->blkcipher.iv_len + input_len)) { @@ -887,9 +946,10 @@ ccr_authenc(struct ccr_softc *sc, uint32_t sid, struct else auth_insert = 0; - wr_len = roundup2(transhdr_len, 16) + roundup2(imm_len, 16) + sgl_len; - if (iv_loc == IV_IMMEDIATE) - wr_len += s->blkcipher.iv_len; + wr_len = roundup2(transhdr_len, 16) + s->blkcipher.iv_len + + roundup2(imm_len, 16) + sgl_len; + if (wr_len > SGE_MAX_WR_LEN) + return (EFBIG); wr = alloc_wrqe(wr_len, sc->txq); if (wr == NULL) { sc->stats_wr_nomem++; @@ -898,9 +958,29 @@ ccr_authenc(struct ccr_softc *sc, uint32_t sid, struct crwr = wrtod(wr); memset(crwr, 0, wr_len); + /* + * Read the existing IV from the request or generate a random + * one if none is provided. Optionally copy the generated IV + * into the output buffer if requested. + */ + if (op_type == CHCR_ENCRYPT_OP) { + if (crde->crd_flags & CRD_F_IV_EXPLICIT) + memcpy(iv, crde->crd_iv, s->blkcipher.iv_len); + else + arc4rand(iv, s->blkcipher.iv_len, 0); + if ((crde->crd_flags & CRD_F_IV_PRESENT) == 0) + crypto_copyback(crp->crp_flags, crp->crp_buf, + crde->crd_inject, s->blkcipher.iv_len, iv); + } else { + if (crde->crd_flags & CRD_F_IV_EXPLICIT) + memcpy(iv, crde->crd_iv, s->blkcipher.iv_len); + else + crypto_copydata(crp->crp_flags, crp->crp_buf, + crde->crd_inject, s->blkcipher.iv_len, iv); + } + ccr_populate_wreq(sc, crwr, kctx_len, wr_len, sid, imm_len, sgl_len, - op_type == CHCR_DECRYPT_OP ? hash_size_in_response : 0, iv_loc, - crp); + op_type == CHCR_DECRYPT_OP ? hash_size_in_response : 0, crp); /* XXX: Hardcodes SGE loopback channel of 0. */ crwr->sec_cpl.op_ivinsrtofst = htobe32( @@ -938,7 +1018,7 @@ ccr_authenc(struct ccr_softc *sc, uint32_t sid, struct crwr->sec_cpl.ivgen_hdrlen = htobe32( V_SCMD_IV_GEN_CTRL(0) | V_SCMD_MORE_FRAGS(0) | V_SCMD_LAST_FRAG(0) | V_SCMD_MAC_ONLY(0) | - V_SCMD_AADIVDROP(1) | V_SCMD_HDR_LEN(dsgl_len)); + V_SCMD_AADIVDROP(0) | V_SCMD_HDR_LEN(dsgl_len)); crwr->key_ctx.ctx_hdr = s->blkcipher.key_ctx_hdr; switch (crde->crd_alg) { @@ -974,10 +1054,8 @@ ccr_authenc(struct ccr_softc *sc, uint32_t sid, struct dst = (char *)(crwr + 1) + kctx_len; ccr_write_phys_dsgl(sc, dst, dsgl_nsegs); dst += sizeof(struct cpl_rx_phys_dsgl) + dsgl_len; - if (iv_loc == IV_IMMEDIATE) { - memcpy(dst, iv, s->blkcipher.iv_len); - dst += s->blkcipher.iv_len; - } + memcpy(dst, iv, s->blkcipher.iv_len); + dst += s->blkcipher.iv_len; if (imm_len != 0) { if (aad_len != 0) { crypto_copydata(crp->crp_flags, crp->crp_buf, @@ -1037,7 +1115,7 @@ ccr_gcm(struct ccr_softc *sc, uint32_t sid, struct ccr struct chcr_wr *crwr; struct wrqe *wr; char *dst; - u_int iv_len, iv_loc, kctx_len, op_type, transhdr_len, wr_len; + u_int iv_len, kctx_len, op_type, transhdr_len, wr_len; u_int hash_size_in_response, imm_len; u_int aad_start, aad_stop, cipher_start, cipher_stop, auth_insert; u_int hmac_ctrl, input_len; @@ -1049,63 +1127,71 @@ ccr_gcm(struct ccr_softc *sc, uint32_t sid, struct ccr return (EINVAL); /* + * The crypto engine doesn't handle GCM requests with an empty + * payload, so handle those in software instead. + */ + if (crde->crd_len == 0) + return (EMSGSIZE); + + /* * AAD is only permitted before the cipher/plain text, not * after. */ if (crda->crd_len + crda->crd_skip > crde->crd_len + crde->crd_skip) - return (EINVAL); + return (EMSGSIZE); - hash_size_in_response = s->gmac.hash_len; + if (crda->crd_len + AES_BLOCK_LEN > MAX_AAD_LEN) + return (EMSGSIZE); - /* - * The IV is always stored at the start of the buffer even - * though it may be duplicated in the payload. The crypto - * engine doesn't work properly if the IV offset points inside - * of the AAD region, so a second copy is always required. - * - * The IV for GCM is further complicated in that IPSec - * provides a full 16-byte IV (including the counter), whereas - * the /dev/crypto interface sometimes provides a full 16-byte - * IV (if no IV is provided in the ioctl) and sometimes a - * 12-byte IV (if the IV was explicit). For now the driver - * always assumes a 12-byte IV and initializes the low 4 byte - * counter to 1. - */ - iv_loc = IV_IMMEDIATE; - if (crde->crd_flags & CRD_F_ENCRYPT) { + hash_size_in_response = s->gmac.hash_len; + if (crde->crd_flags & CRD_F_ENCRYPT) op_type = CHCR_ENCRYPT_OP; - if (crde->crd_flags & CRD_F_IV_EXPLICIT) - memcpy(iv, crde->crd_iv, s->blkcipher.iv_len); - else - arc4rand(iv, s->blkcipher.iv_len, 0); - if ((crde->crd_flags & CRD_F_IV_PRESENT) == 0) - crypto_copyback(crp->crp_flags, crp->crp_buf, - crde->crd_inject, s->blkcipher.iv_len, iv); - } else { + else op_type = CHCR_DECRYPT_OP; - if (crde->crd_flags & CRD_F_IV_EXPLICIT) - memcpy(iv, crde->crd_iv, s->blkcipher.iv_len); - else - crypto_copydata(crp->crp_flags, crp->crp_buf, - crde->crd_inject, s->blkcipher.iv_len, iv); - } /* - * If the input IV is 12 bytes, append an explicit counter of - * 1. + * The IV handling for GCM in OCF is a bit more complicated in + * that IPSec provides a full 16-byte IV (including the + * counter), whereas the /dev/crypto interface sometimes + * provides a full 16-byte IV (if no IV is provided in the + * ioctl) and sometimes a 12-byte IV (if the IV was explicit). + * + * When provided a 12-byte IV, assume the IV is really 16 bytes + * with a counter in the last 4 bytes initialized to 1. + * + * While iv_len is checked below, the value is currently + * always set to 12 when creating a GCM session in this driver + * due to limitations in OCF (there is no way to know what the + * IV length of a given request will be). This means that the + * driver always assumes as 12-byte IV for now. */ - if (s->blkcipher.iv_len == 12) { - *(uint32_t *)&iv[12] = htobe32(1); + if (s->blkcipher.iv_len == 12) iv_len = AES_BLOCK_LEN; - } else + else iv_len = s->blkcipher.iv_len; /* * The output buffer consists of the cipher text followed by * the tag when encrypting. For decryption it only contains * the plain text. + * + * Due to a firmware bug, the output buffer must include a + * dummy output buffer for the IV and AAD prior to the real + * output buffer. */ + if (op_type == CHCR_ENCRYPT_OP) { + if (iv_len + crda->crd_len + crde->crd_len + + hash_size_in_response > MAX_REQUEST_SIZE) + return (EFBIG); + } else { + if (iv_len + crda->crd_len + crde->crd_len > MAX_REQUEST_SIZE) + return (EFBIG); + } sglist_reset(sc->sg_dsgl); + error = sglist_append_sglist(sc->sg_dsgl, sc->sg_iv_aad, 0, iv_len + + crda->crd_len); + if (error) + return (error); error = sglist_append_sglist(sc->sg_dsgl, sc->sg_crp, crde->crd_skip, crde->crd_len); if (error) @@ -1132,10 +1218,18 @@ ccr_gcm(struct ccr_softc *sc, uint32_t sid, struct ccr * The input buffer consists of the IV, any AAD, and then the * cipher/plain text. For decryption requests the hash is * appended after the cipher text. + * + * The IV is always stored at the start of the input buffer + * even though it may be duplicated in the payload. The + * crypto engine doesn't work properly if the IV offset points + * inside of the AAD region, so a second copy is always + * required. */ input_len = crda->crd_len + crde->crd_len; if (op_type == CHCR_DECRYPT_OP) input_len += hash_size_in_response; + if (input_len > MAX_REQUEST_SIZE) + return (EFBIG); if (ccr_use_imm_data(transhdr_len, iv_len + input_len)) { imm_len = input_len; sgl_nsegs = 0; @@ -1180,9 +1274,10 @@ ccr_gcm(struct ccr_softc *sc, uint32_t sid, struct ccr else auth_insert = 0; - wr_len = roundup2(transhdr_len, 16) + roundup2(imm_len, 16) + sgl_len; - if (iv_loc == IV_IMMEDIATE) - wr_len += iv_len; + wr_len = roundup2(transhdr_len, 16) + iv_len + roundup2(imm_len, 16) + + sgl_len; + if (wr_len > SGE_MAX_WR_LEN) + return (EFBIG); wr = alloc_wrqe(wr_len, sc->txq); if (wr == NULL) { sc->stats_wr_nomem++; @@ -1191,8 +1286,34 @@ ccr_gcm(struct ccr_softc *sc, uint32_t sid, struct ccr crwr = wrtod(wr); memset(crwr, 0, wr_len); + /* + * Read the existing IV from the request or generate a random + * one if none is provided. Optionally copy the generated IV + * into the output buffer if requested. + * + * If the input IV is 12 bytes, append an explicit 4-byte + * counter of 1. + */ + if (op_type == CHCR_ENCRYPT_OP) { + if (crde->crd_flags & CRD_F_IV_EXPLICIT) + memcpy(iv, crde->crd_iv, s->blkcipher.iv_len); + else + arc4rand(iv, s->blkcipher.iv_len, 0); + if ((crde->crd_flags & CRD_F_IV_PRESENT) == 0) + crypto_copyback(crp->crp_flags, crp->crp_buf, + crde->crd_inject, s->blkcipher.iv_len, iv); + } else { + if (crde->crd_flags & CRD_F_IV_EXPLICIT) + memcpy(iv, crde->crd_iv, s->blkcipher.iv_len); + else + crypto_copydata(crp->crp_flags, crp->crp_buf, + crde->crd_inject, s->blkcipher.iv_len, iv); + } + if (s->blkcipher.iv_len == 12) + *(uint32_t *)&iv[12] = htobe32(1); + ccr_populate_wreq(sc, crwr, kctx_len, wr_len, sid, imm_len, sgl_len, - 0, iv_loc, crp); + 0, crp); /* XXX: Hardcodes SGE loopback channel of 0. */ crwr->sec_cpl.op_ivinsrtofst = htobe32( @@ -1240,7 +1361,7 @@ ccr_gcm(struct ccr_softc *sc, uint32_t sid, struct ccr crwr->sec_cpl.ivgen_hdrlen = htobe32( V_SCMD_IV_GEN_CTRL(0) | V_SCMD_MORE_FRAGS(0) | V_SCMD_LAST_FRAG(0) | V_SCMD_MAC_ONLY(0) | - V_SCMD_AADIVDROP(1) | V_SCMD_HDR_LEN(dsgl_len)); + V_SCMD_AADIVDROP(0) | V_SCMD_HDR_LEN(dsgl_len)); crwr->key_ctx.ctx_hdr = s->blkcipher.key_ctx_hdr; memcpy(crwr->key_ctx.key, s->blkcipher.enckey, s->blkcipher.key_len); @@ -1250,10 +1371,8 @@ ccr_gcm(struct ccr_softc *sc, uint32_t sid, struct ccr dst = (char *)(crwr + 1) + kctx_len; ccr_write_phys_dsgl(sc, dst, dsgl_nsegs); dst += sizeof(struct cpl_rx_phys_dsgl) + dsgl_len; - if (iv_loc == IV_IMMEDIATE) { - memcpy(dst, iv, iv_len); - dst += iv_len; - } + memcpy(dst, iv, iv_len); + dst += iv_len; if (imm_len != 0) { if (crda->crd_len != 0) { crypto_copydata(crp->crp_flags, crp->crp_buf, @@ -1289,7 +1408,153 @@ ccr_gcm_done(struct ccr_softc *sc, struct ccr_session return (error); } +/* + * Handle a GCM request that is not supported by the crypto engine by + * performing the operation in software. Derived from swcr_authenc(). + */ static void +ccr_gcm_soft(struct ccr_session *s, struct cryptop *crp, + struct cryptodesc *crda, struct cryptodesc *crde) +{ + struct auth_hash *axf; + struct enc_xform *exf; + void *auth_ctx; + uint8_t *kschedule; + char block[GMAC_BLOCK_LEN]; + char digest[GMAC_DIGEST_LEN]; + char iv[AES_BLOCK_LEN]; + int error, i, len; + + auth_ctx = NULL; + kschedule = NULL; + + /* Initialize the MAC. */ + switch (s->blkcipher.key_len) { + case 16: + axf = &auth_hash_nist_gmac_aes_128; + break; + case 24: + axf = &auth_hash_nist_gmac_aes_192; + break; + case 32: + axf = &auth_hash_nist_gmac_aes_256; + break; + default: + error = EINVAL; + goto out; + } + auth_ctx = malloc(axf->ctxsize, M_CCR, M_NOWAIT); + if (auth_ctx == NULL) { + error = ENOMEM; + goto out; + } + axf->Init(auth_ctx); + axf->Setkey(auth_ctx, s->blkcipher.enckey, s->blkcipher.key_len); + + /* Initialize the cipher. */ + exf = &enc_xform_aes_nist_gcm; + error = exf->setkey(&kschedule, s->blkcipher.enckey, + s->blkcipher.key_len); + if (error) + goto out; + + /* + * This assumes a 12-byte IV from the crp. See longer comment + * above in ccr_gcm() for more details. + */ + if (crde->crd_flags & CRD_F_ENCRYPT) { + if (crde->crd_flags & CRD_F_IV_EXPLICIT) + memcpy(iv, crde->crd_iv, 12); + else + arc4rand(iv, 12, 0); + if ((crde->crd_flags & CRD_F_IV_PRESENT) == 0) + crypto_copyback(crp->crp_flags, crp->crp_buf, + crde->crd_inject, 12, iv); + } else { + if (crde->crd_flags & CRD_F_IV_EXPLICIT) + memcpy(iv, crde->crd_iv, 12); + else + crypto_copydata(crp->crp_flags, crp->crp_buf, + crde->crd_inject, 12, iv); + } + *(uint32_t *)&iv[12] = htobe32(1); + + axf->Reinit(auth_ctx, iv, sizeof(iv)); + + /* MAC the AAD. */ + for (i = 0; i < crda->crd_len; i += sizeof(block)) { + len = imin(crda->crd_len - i, sizeof(block)); + crypto_copydata(crp->crp_flags, crp->crp_buf, crda->crd_skip + + i, len, block); + bzero(block + len, sizeof(block) - len); + axf->Update(auth_ctx, block, sizeof(block)); + } + + exf->reinit(kschedule, iv); + + /* Do encryption with MAC */ + for (i = 0; i < crde->crd_len; i += sizeof(block)) { + len = imin(crde->crd_len - i, sizeof(block)); + crypto_copydata(crp->crp_flags, crp->crp_buf, crde->crd_skip + + i, len, block); + bzero(block + len, sizeof(block) - len); + if (crde->crd_flags & CRD_F_ENCRYPT) { + exf->encrypt(kschedule, block); + axf->Update(auth_ctx, block, len); + crypto_copyback(crp->crp_flags, crp->crp_buf, + crde->crd_skip + i, len, block); + } else { + axf->Update(auth_ctx, block, len); + } + } + + /* Length block. */ + bzero(block, sizeof(block)); + ((uint32_t *)block)[1] = htobe32(crda->crd_len * 8); + ((uint32_t *)block)[3] = htobe32(crde->crd_len * 8); + axf->Update(auth_ctx, block, sizeof(block)); + + /* Finalize MAC. */ + axf->Final(digest, auth_ctx); + + /* Inject or validate tag. */ + if (crde->crd_flags & CRD_F_ENCRYPT) { + crypto_copyback(crp->crp_flags, crp->crp_buf, crda->crd_inject, + sizeof(digest), digest); + error = 0; + } else { + char digest2[GMAC_DIGEST_LEN]; + + crypto_copydata(crp->crp_flags, crp->crp_buf, crda->crd_inject, + sizeof(digest2), digest2); + if (timingsafe_bcmp(digest, digest2, sizeof(digest)) == 0) { + error = 0; + + /* Tag matches, decrypt data. */ + for (i = 0; i < crde->crd_len; i += sizeof(block)) { + len = imin(crde->crd_len - i, sizeof(block)); + crypto_copydata(crp->crp_flags, crp->crp_buf, + crde->crd_skip + i, len, block); + bzero(block + len, sizeof(block) - len); + exf->decrypt(kschedule, block); + crypto_copyback(crp->crp_flags, crp->crp_buf, + crde->crd_skip + i, len, block); + } + } else + error = EBADMSG; + } + + exf->zerokey(&kschedule); +out: + if (auth_ctx != NULL) { *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-11@freebsd.org Tue Mar 12 13:33:09 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4D22C1531039; Tue, 12 Mar 2019 13:33:09 +0000 (UTC) (envelope-from slw@zxy.spb.ru) Received: from zxy.spb.ru (zxy.spb.ru [195.70.199.98]) (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 D77ED8E66E; Tue, 12 Mar 2019 13:33:08 +0000 (UTC) (envelope-from slw@zxy.spb.ru) Received: from slw by zxy.spb.ru with local (Exim 4.86 (FreeBSD)) (envelope-from ) id 1h3hWc-000N8X-EM; Tue, 12 Mar 2019 16:32:58 +0300 Date: Tue, 12 Mar 2019 16:32:58 +0300 From: Slawa Olhovchenkov To: John Baldwin Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: Re: svn commit: r345040 - in stable/11: share/man/man4 sys/conf sys/dev/cxgbe sys/dev/cxgbe/crypto sys/dev/cxgbe/firmware sys/modules/cxgbe sys/modules/cxgbe/ccr sys/powerpc/conf Message-ID: <20190312133258.GA6462@zxy.spb.ru> References: <201903112316.x2BNGA4b092507@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201903112316.x2BNGA4b092507@repo.freebsd.org> User-Agent: Mutt/1.5.24 (2015-08-30) X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: slw@zxy.spb.ru X-SA-Exim-Scanned: No (on zxy.spb.ru); SAEximRunCond expanded to false X-Rspamd-Queue-Id: D77ED8E66E X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.82 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.82)[-0.820,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; REPLY(-4.00)[] X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Mar 2019 13:33:09 -0000 On Mon, Mar 11, 2019 at 11:16:10PM +0000, John Baldwin wrote: > Author: jhb > Date: Mon Mar 11 23:16:10 2019 > New Revision: 345040 > URL: https://svnweb.freebsd.org/changeset/base/345040 > > Log: > MFC 318429,318967,319721,319723,323600,323724,328353-328361,330042,343056: > Add a driver for the Chelsio T6 crypto accelerator engine. Where I can find example/manual of use this engine from userspace? From owner-svn-src-stable-11@freebsd.org Tue Mar 12 15:46:39 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2BFF21534384; Tue, 12 Mar 2019 15:46:39 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id BA8A16D0EA; Tue, 12 Mar 2019 15:46:38 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from John-Baldwins-MacBook-Pro-3.local (ralph.baldwin.cx [66.234.199.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id E7DBA1F5F9; Tue, 12 Mar 2019 15:46:37 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Subject: Re: svn commit: r345040 - in stable/11: share/man/man4 sys/conf sys/dev/cxgbe sys/dev/cxgbe/crypto sys/dev/cxgbe/firmware sys/modules/cxgbe sys/modules/cxgbe/ccr sys/powerpc/conf To: Slawa Olhovchenkov Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org References: <201903112316.x2BNGA4b092507@repo.freebsd.org> <20190312133258.GA6462@zxy.spb.ru> From: John Baldwin Openpgp: preference=signencrypt Autocrypt: addr=jhb@FreeBSD.org; keydata= mQGiBETQ+XcRBADMFybiq69u+fJRy/0wzqTNS8jFfWaBTs5/OfcV7wWezVmf9sgwn8TW0Dk0 c9MBl0pz+H01dA2ZSGZ5fXlmFIsee1WEzqeJzpiwd/pejPgSzXB9ijbLHZ2/E0jhGBcVy5Yo /Tw5+U/+laeYKu2xb0XPvM0zMNls1ah5OnP9a6Ql6wCgupaoMySb7DXm2LHD1Z9jTsHcAQMD /1jzh2BoHriy/Q2s4KzzjVp/mQO5DSm2z14BvbQRcXU48oAosHA1u3Wrov6LfPY+0U1tG47X 1BGfnQH+rNAaH0livoSBQ0IPI/8WfIW7ub4qV6HYwWKVqkDkqwcpmGNDbz3gfaDht6nsie5Z pcuCcul4M9CW7Md6zzyvktjnbz61BADGDCopfZC4of0Z3Ka0u8Wik6UJOuqShBt1WcFS8ya1 oB4rc4tXfSHyMF63aPUBMxHR5DXeH+EO2edoSwViDMqWk1jTnYza51rbGY+pebLQOVOxAY7k do5Ordl3wklBPMVEPWoZ61SdbcjhHVwaC5zfiskcxj5wwXd2E9qYlBqRg7QeSm9obiBCYWxk d2luIDxqaGJARnJlZUJTRC5vcmc+iGAEExECACAFAkTQ+awCGwMGCwkIBwMCBBUCCAMEFgID AQIeAQIXgAAKCRBy3lIGd+N/BI6RAJ9S97fvbME+3hxzE3JUyUZ6vTewDACdE1stFuSfqMvM jomvZdYxIYyTUpC5Ag0ERND5ghAIAPwsO0B7BL+bz8sLlLoQktGxXwXQfS5cInvL17Dsgnr3 1AKa94j9EnXQyPEj7u0d+LmEe6CGEGDh1OcGFTMVrof2ZzkSy4+FkZwMKJpTiqeaShMh+Goj XlwIMDxyADYvBIg3eN5YdFKaPQpfgSqhT+7El7w+wSZZD8pPQuLAnie5iz9C8iKy4/cMSOrH YUK/tO+Nhw8Jjlw94Ik0T80iEhI2t+XBVjwdfjbq3HrJ0ehqdBwukyeJRYKmbn298KOFQVHO EVbHA4rF/37jzaMadK43FgJ0SAhPPF5l4l89z5oPu0b/+5e2inA3b8J3iGZxywjM+Csq1tqz hltEc7Q+E08AAwUIAL+15XH8bPbjNJdVyg2CMl10JNW2wWg2Q6qdljeaRqeR6zFus7EZTwtX sNzs5bP8y51PSUDJbeiy2RNCNKWFMndM22TZnk3GNG45nQd4OwYK0RZVrikalmJY5Q6m7Z16 4yrZgIXFdKj2t8F+x613/SJW1lIr9/bDp4U9tw0V1g3l2dFtD3p3ZrQ3hpoDtoK70ioIAjjH aIXIAcm3FGZFXy503DOA0KaTWwvOVdYCFLm3zWuSOmrX/GsEc7ovasOWwjPn878qVjbUKWwx Q4QkF4OhUV9zPtf9tDSAZ3x7QSwoKbCoRCZ/xbyTUPyQ1VvNy/mYrBcYlzHodsaqUDjHuW+I SQQYEQIACQUCRND5ggIbDAAKCRBy3lIGd+N/BCO8AJ9j1dWVQWxw/YdTbEyrRKOY8YZNwwCf afMAg8QvmOWnHx3wl8WslCaXaE8= Message-ID: Date: Tue, 12 Mar 2019 08:46:36 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:60.0) Gecko/20100101 Thunderbird/60.5.3 MIME-Version: 1.0 In-Reply-To: <20190312133258.GA6462@zxy.spb.ru> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: BA8A16D0EA X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.96 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; REPLY(-4.00)[]; NEURAL_HAM_SHORT(-0.96)[-0.965,0] X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Mar 2019 15:46:39 -0000 On 3/12/19 6:32 AM, Slawa Olhovchenkov wrote: > On Mon, Mar 11, 2019 at 11:16:10PM +0000, John Baldwin wrote: > >> Author: jhb >> Date: Mon Mar 11 23:16:10 2019 >> New Revision: 345040 >> URL: https://svnweb.freebsd.org/changeset/base/345040 >> >> Log: >> MFC 318429,318967,319721,319723,323600,323724,328353-328361,330042,343056: >> Add a driver for the Chelsio T6 crypto accelerator engine. > > Where I can find example/manual of use this engine from userspace? It's hard to use usefully from userspace (even in 12/head). I have some old patches for openssl 1.0.2's cryptodev engine to teach it about more of the algorithms supported by OCF including the TLS variant of AES-GCM, but I found that the overhead of the extra copies made it not very compelling compared to using AES-NI in userland. (I had some extra changes to make /dev/crypto wire the user pages to avoid the copies and that got the /dev/crypto case down to break-even with doing AES-NI in userland.) In the kernel I see better performance where using T6 to offload crypto for IPsec does use less CPU at higher throughput than using CPU instructions though for AES-GCM AES-NI on the CPU is pretty close. -- John Baldwin From owner-svn-src-stable-11@freebsd.org Tue Mar 12 16:46:35 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 86D1515362BA; Tue, 12 Mar 2019 16:46:35 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 2E6EE7063E; Tue, 12 Mar 2019 16:46:35 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 01302257AC; Tue, 12 Mar 2019 16:46:35 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2CGkYPM049230; Tue, 12 Mar 2019 16:46:34 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2CGkYbn049229; Tue, 12 Mar 2019 16:46:34 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201903121646.x2CGkYbn049229@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Tue, 12 Mar 2019 16:46:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r345069 - stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Commit-Revision: 345069 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 2E6EE7063E X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.93 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.997,0]; NEURAL_HAM_SHORT(-0.93)[-0.935,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Mar 2019 16:46:35 -0000 Author: mav Date: Tue Mar 12 16:46:34 2019 New Revision: 345069 URL: https://svnweb.freebsd.org/changeset/base/345069 Log: MFC r339299: Pull in a follow-on commit to resolve a deadlock in ZFS sequential resilver (r334844) MFV/ZoL: Fix deadlock in IO pipeline commit a76f3d0437e5e974f0f748f8735af3539443b388 Author: Brian Behlendorf Date: Fri Mar 16 16:46:06 2018 -0700 Fix deadlock in IO pipeline In vdev_queue_aggregate() the zio_execute() bypass should not be called under the vdev queue lock. This can result in a deadlock as shown in the stack traces below. Drop the vdev queue lock then walk the parents of the aggregate IO to determine the list of component IOs to be bypassed. This can be done safely without holding the io_lock since the new aggregate IO has not yet been returned and its parents cannot change. --- THREAD 1 --- arc_read() zio_nowait() zio_vdev_io_start() vdev_queue_io() <--- mutex_enter(vq->vq_lock) vdev_queue_io_to_issue() vdev_queue_aggregate() zio_execute() vdev_queue_io_to_issue() vdev_queue_aggregate() zio_execute() zio_vdev_io_assess() zio_wait_for_children() <- mutex_enter(zio->io_lock) --- THREAD 2 --- (inverse order) arc_read() zio_change_priority() <- mutex_enter(zio->zio_lock) vdev_queue_change_io_priority() <- mutex_enter(vq->vq_lock) Reviewed-by: Tom Caputi Reviewed-by: Don Brady Signed-off-by: Brian Behlendorf Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_queue.c Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_queue.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_queue.c Tue Mar 12 16:41:17 2019 (r345068) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_queue.c Tue Mar 12 16:46:34 2019 (r345069) @@ -666,6 +666,7 @@ static zio_t * vdev_queue_aggregate(vdev_queue_t *vq, zio_t *zio) { zio_t *first, *last, *aio, *dio, *mandatory, *nio; + zio_link_t *zl = NULL; uint64_t maxgap = 0; uint64_t size; boolean_t stretch; @@ -809,9 +810,18 @@ vdev_queue_aggregate(vdev_queue_t *vq, zio_t *zio) zio_add_child(dio, aio); vdev_queue_io_remove(vq, dio); + } while (dio != last); + + /* + * We need to drop the vdev queue's lock to avoid a deadlock that we + * could encounter since this I/O will complete immediately. + */ + mutex_exit(&vq->vq_lock); + while ((dio = zio_walk_parents(aio, &zl)) != NULL) { zio_vdev_io_bypass(dio); zio_execute(dio); - } while (dio != last); + } + mutex_enter(&vq->vq_lock); return (aio); } From owner-svn-src-stable-11@freebsd.org Tue Mar 12 17:04:49 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5AF841536EBA; Tue, 12 Mar 2019 17:04:49 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E79A571994; Tue, 12 Mar 2019 17:04:48 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B6BC725B16; Tue, 12 Mar 2019 17:04:48 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2CH4mAn059752; Tue, 12 Mar 2019 17:04:48 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2CH4mAu059751; Tue, 12 Mar 2019 17:04:48 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201903121704.x2CH4mAu059751@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Tue, 12 Mar 2019 17:04:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r345072 - stable/11/usr.sbin/freebsd-update X-SVN-Group: stable-11 X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: stable/11/usr.sbin/freebsd-update X-SVN-Commit-Revision: 345072 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: E79A571994 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.997,0]; NEURAL_HAM_SHORT(-0.96)[-0.962,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Mar 2019 17:04:49 -0000 Author: emaste Date: Tue Mar 12 17:04:48 2019 New Revision: 345072 URL: https://svnweb.freebsd.org/changeset/base/345072 Log: MFC r344818: freebsd-update.8: update example to contemporary versions PR: 235761 Reported by: linimon Modified: stable/11/usr.sbin/freebsd-update/freebsd-update.8 Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.sbin/freebsd-update/freebsd-update.8 ============================================================================== --- stable/11/usr.sbin/freebsd-update/freebsd-update.8 Tue Mar 12 17:03:58 2019 (r345071) +++ stable/11/usr.sbin/freebsd-update/freebsd-update.8 Tue Mar 12 17:04:48 2019 (r345072) @@ -59,13 +59,13 @@ by the .Fx Release Engineering Team, e.g., .Fx -10.3-RELEASE and +11.2-RELEASE and .Fx -11.0-RELEASE, but not +12.0-RELEASE, but not .Fx -10.3-STABLE or +11.2-STABLE or .Fx -12-CURRENT. +13.0-CURRENT. .Sh OPTIONS The following options are supported: .Bl -tag -width "-r newrelease" From owner-svn-src-stable-11@freebsd.org Wed Mar 13 20:26:47 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A28D31540F65; Wed, 13 Mar 2019 20:26:47 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 429C56EB2B; Wed, 13 Mar 2019 20:26:47 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2F315FAEF; Wed, 13 Mar 2019 20:26:47 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2DKQlQF040131; Wed, 13 Mar 2019 20:26:47 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2DKQkE7040130; Wed, 13 Mar 2019 20:26:46 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201903132026.x2DKQkE7040130@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 13 Mar 2019 20:26:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r345112 - stable/11/sys/cam/ctl X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/cam/ctl X-SVN-Commit-Revision: 345112 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 429C56EB2B X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.996,0]; NEURAL_HAM_SHORT(-0.98)[-0.979,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-0.999,0] X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Mar 2019 20:26:47 -0000 Author: mav Date: Wed Mar 13 20:26:46 2019 New Revision: 345112 URL: https://svnweb.freebsd.org/changeset/base/345112 Log: MFC r344586: Scrap some debug printf's, unused for years. Modified: stable/11/sys/cam/ctl/ctl.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cam/ctl/ctl.c ============================================================================== --- stable/11/sys/cam/ctl/ctl.c Wed Mar 13 20:26:27 2019 (r345111) +++ stable/11/sys/cam/ctl/ctl.c Wed Mar 13 20:26:46 2019 (r345112) @@ -1448,12 +1448,6 @@ ctl_isc_event_handler(ctl_ha_channel channel, ctl_ha_e if (softc->ha_mode != CTL_HA_MODE_XFER) io->io_hdr.flags |= CTL_FLAG_INT_COPY; io->io_hdr.nexus = msg->hdr.nexus; -#if 0 - printf("port %u, iid %u, lun %u\n", - io->io_hdr.nexus.targ_port, - io->io_hdr.nexus.initid, - io->io_hdr.nexus.targ_lun); -#endif io->scsiio.tag_num = msg->scsi.tag_num; io->scsiio.tag_type = msg->scsi.tag_type; #ifdef CTL_TIME_IO @@ -1533,11 +1527,6 @@ ctl_isc_event_handler(ctl_ha_channel channel, ctl_ha_e msg->dt.cur_sg_entries); i++, j++) { sgl[i].addr = msg->dt.sg_list[j].addr; sgl[i].len = msg->dt.sg_list[j].len; - -#if 0 - printf("%s: DATAMOVE: %p,%lu j=%d, i=%d\n", - __func__, sgl[i].addr, sgl[i].len, j, i); -#endif } /* @@ -6509,11 +6498,6 @@ ctl_mode_sense(struct ctl_scsiio *ctsio) && (subpage == SMS_SUBPAGE_PAGE_0)) continue; -#if 0 - printf("found page %#x len %d\n", - page_index->page_code & SMPH_PC_MASK, - page_index->page_len); -#endif page_len += page_index->page_len; } break; @@ -6546,12 +6530,6 @@ ctl_mode_sense(struct ctl_scsiio *ctsio) && (subpage != SMS_SUBPAGE_ALL)) continue; -#if 0 - printf("found page %#x len %d\n", - page_index->page_code & SMPH_PC_MASK, - page_index->page_len); -#endif - page_len += page_index->page_len; } @@ -6570,10 +6548,6 @@ ctl_mode_sense(struct ctl_scsiio *ctsio) } total_len = header_len + page_len; -#if 0 - printf("header_len = %d, page_len = %d, total_len = %d\n", - header_len, page_len, total_len); -#endif ctsio->kern_data_ptr = malloc(total_len, M_CTL, M_WAITOK | M_ZERO); ctsio->kern_sg_entries = 0; @@ -8261,10 +8235,6 @@ ctl_persistent_reserve_out(struct ctl_scsiio *ctsio) case SPRO_REGISTER: case SPRO_REG_IGNO: { -#if 0 - printf("Registration received\n"); -#endif - /* * We don't support any of these options, as we report in * the read capabilities request (see @@ -8377,9 +8347,6 @@ ctl_persistent_reserve_out(struct ctl_scsiio *ctsio) break; } case SPRO_RESERVE: -#if 0 - printf("Reserve executed type %d\n", type); -#endif mtx_lock(&lun->lun_lock); if (lun->flags & CTL_LUN_PR_RESERVED) { /* @@ -11932,15 +11899,8 @@ ctl_abort_task(union ctl_io *io) struct ctl_softc *softc = CTL_SOFTC(io); union ctl_io *xio; struct ctl_lun *lun; -#if 0 - struct sbuf sb; - char printbuf[128]; -#endif - int found; uint32_t targ_lun; - found = 0; - /* * Look up the LUN. */ @@ -11953,11 +11913,6 @@ ctl_abort_task(union ctl_io *io) return (1); } -#if 0 - printf("ctl_abort_task: called for lun %lld, tag %d type %d\n", - lun->lun, io->taskio.tag_num, io->taskio.tag_type); -#endif - mtx_lock(&lun->lun_lock); mtx_unlock(&softc->ctl_lock); /* @@ -11969,25 +11924,7 @@ ctl_abort_task(union ctl_io *io) */ for (xio = (union ctl_io *)TAILQ_FIRST(&lun->ooa_queue); xio != NULL; xio = (union ctl_io *)TAILQ_NEXT(&xio->io_hdr, ooa_links)) { -#if 0 - sbuf_new(&sb, printbuf, sizeof(printbuf), SBUF_FIXEDLEN); - sbuf_printf(&sb, "LUN %lld tag %d type %d%s%s%s%s: ", - lun->lun, xio->scsiio.tag_num, - xio->scsiio.tag_type, - (xio->io_hdr.blocked_links.tqe_prev - == NULL) ? "" : " BLOCKED", - (xio->io_hdr.flags & - CTL_FLAG_DMA_INPROG) ? " DMA" : "", - (xio->io_hdr.flags & - CTL_FLAG_ABORT) ? " ABORT" : "", - (xio->io_hdr.flags & - CTL_FLAG_IS_WAS_ON_RTR ? " RTR" : "")); - ctl_scsi_command_string(&xio->scsiio, NULL, &sb); - sbuf_finish(&sb); - printf("%s\n", sbuf_data(&sb)); -#endif - if ((xio->io_hdr.nexus.targ_port != io->io_hdr.nexus.targ_port) || (xio->io_hdr.nexus.initid != io->io_hdr.nexus.initid) || (xio->io_hdr.flags & CTL_FLAG_ABORT)) @@ -12004,8 +11941,8 @@ ctl_abort_task(union ctl_io *io) #if 0 if (((xio->scsiio.tag_type == CTL_TAG_UNTAGGED) && (io->taskio.tag_type == CTL_TAG_UNTAGGED)) - || (xio->scsiio.tag_num == io->taskio.tag_num)) -#endif + || (xio->scsiio.tag_num == io->taskio.tag_num)) { +#else /* * XXX KDM we've got problems with FC, because it * doesn't send down a tag type with aborts. So we @@ -12014,8 +11951,8 @@ ctl_abort_task(union ctl_io *io) * Need to figure that out!! */ if (xio->scsiio.tag_num == io->taskio.tag_num) { +#endif xio->io_hdr.flags |= CTL_FLAG_ABORT; - found = 1; if ((io->io_hdr.flags & CTL_FLAG_FROM_OTHER_SC) == 0 && !(lun->flags & CTL_LUN_PRIMARY_SC)) { union ctl_ha_msg msg_info; @@ -12027,34 +11964,12 @@ ctl_abort_task(union ctl_io *io) msg_info.hdr.msg_type = CTL_MSG_MANAGE_TASKS; msg_info.hdr.original_sc = NULL; msg_info.hdr.serializing_sc = NULL; -#if 0 - printf("Sent Abort to other side\n"); -#endif ctl_ha_msg_send(CTL_HA_CHAN_CTL, &msg_info, sizeof(msg_info.task), M_NOWAIT); } -#if 0 - printf("ctl_abort_task: found I/O to abort\n"); -#endif } } mtx_unlock(&lun->lun_lock); - - if (found == 0) { - /* - * This isn't really an error. It's entirely possible for - * the abort and command completion to cross on the wire. - * This is more of an informative/diagnostic error. - */ -#if 0 - printf("ctl_abort_task: ABORT sent for nonexistent I/O: " - "%u:%u:%u tag %d type %d\n", - io->io_hdr.nexus.initid, - io->io_hdr.nexus.targ_port, - io->io_hdr.nexus.targ_lun, io->taskio.tag_num, - io->taskio.tag_type); -#endif - } io->taskio.task_status = CTL_TASK_FUNCTION_COMPLETE; return (0); } @@ -12622,11 +12537,6 @@ ctl_datamove_remote_write(union ctl_io *io) static int ctl_datamove_remote_dm_read_cb(union ctl_io *io) { -#if 0 - char str[256]; - char path_str[64]; - struct sbuf sb; -#endif uint32_t i; for (i = 0; i < io->scsiio.kern_sg_entries; i++) @@ -12635,23 +12545,6 @@ ctl_datamove_remote_dm_read_cb(union ctl_io *io) CTL_RSGL(io) = NULL; CTL_LSGL(io) = NULL; -#if 0 - scsi_path_string(io, path_str, sizeof(path_str)); - sbuf_new(&sb, str, sizeof(str), SBUF_FIXEDLEN); - sbuf_cat(&sb, path_str); - scsi_command_string(&io->scsiio, NULL, &sb); - sbuf_printf(&sb, "\n"); - sbuf_cat(&sb, path_str); - sbuf_printf(&sb, "Tag: 0x%04x, type %d\n", - io->scsiio.tag_num, io->scsiio.tag_type); - sbuf_cat(&sb, path_str); - sbuf_printf(&sb, "%s: flags %#x, status %#x\n", __func__, - io->io_hdr.flags, io->io_hdr.status); - sbuf_finish(&sb); - printk("%s", sbuf_data(&sb)); -#endif - - /* * The read is done, now we need to send status (good or bad) back * to the other side. @@ -12725,14 +12618,6 @@ ctl_datamove_remote_sgl_setup(union ctl_io *io) */ io->scsiio.kern_sg_entries = i; -#if 0 - printf("%s: kern_sg_entries = %d\n", __func__, - io->scsiio.kern_sg_entries); - for (i = 0; i < io->scsiio.kern_sg_entries; i++) - printf("%s: sg[%d] = %p, %lu\n", __func__, i, - local_sglist[i].addr, local_sglist[i].len); -#endif - return (retval); } @@ -12845,12 +12730,6 @@ ctl_datamove_remote_xfer(union ctl_io *io, unsigned co if (total_used >= io->scsiio.kern_data_len) rq->callback = callback; - -#if 0 - printf("%s: %s: local %p remote %p size %d\n", __func__, - (command == CTL_HA_DT_CMD_WRITE) ? "WRITE" : "READ", - rq->local, rq->remote, rq->size); -#endif isc_ret = ctl_dt_single(rq); if (isc_ret > CTL_HA_STATUS_SUCCESS) From owner-svn-src-stable-11@freebsd.org Wed Mar 13 20:28:09 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 24DA51541077; Wed, 13 Mar 2019 20:28:09 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C4C116EDD9; Wed, 13 Mar 2019 20:28:08 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B727EFAF3; Wed, 13 Mar 2019 20:28:08 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2DKS803040318; Wed, 13 Mar 2019 20:28:08 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2DKS7m1040314; Wed, 13 Mar 2019 20:28:07 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201903132028.x2DKS7m1040314@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 13 Mar 2019 20:28:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r345114 - stable/11/sys/cam/ctl X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/cam/ctl X-SVN-Commit-Revision: 345114 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: C4C116EDD9 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.996,0]; NEURAL_HAM_SHORT(-0.98)[-0.981,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-0.999,0] X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Mar 2019 20:28:09 -0000 Author: mav Date: Wed Mar 13 20:28:07 2019 New Revision: 345114 URL: https://svnweb.freebsd.org/changeset/base/345114 Log: MFC r344636: Refactor command ordering/blocking mechanism in CTL. Replace long per-LUN queue of blocked commands, scanned on each command completion and sometimes even twice, causing up to O(n^^2) processing cost, by much shorter per-command blocked queues, scanned only when respective command completes, and check only commands before the previous blocker, reducing cost to O(n). While there, unblock aborted commands to make them "complete" ASAP to be removed from the OOA queue and so not waste time ordering other commands against them. Aborted commands that were not sent to execution yet should have no visible side effects, so this is safe and easy optimization now, comparing to commands already in processing, which are a still pain. Together those two optimizations should fix quite pathological case, when due to backend slowness CTL accumulated many thousands of blocked requests, partially aborted by initiator and so supposedly not even existing, but still wasting CTL CPU time. Modified: stable/11/sys/cam/ctl/ctl.c stable/11/sys/cam/ctl/ctl_frontend_ioctl.c stable/11/sys/cam/ctl/ctl_io.h stable/11/sys/cam/ctl/ctl_private.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cam/ctl/ctl.c ============================================================================== --- stable/11/sys/cam/ctl/ctl.c Wed Mar 13 20:27:48 2019 (r345113) +++ stable/11/sys/cam/ctl/ctl.c Wed Mar 13 20:28:07 2019 (r345114) @@ -496,8 +496,11 @@ static ctl_action ctl_extent_check_seq(union ctl_io *i static ctl_action ctl_check_for_blockage(struct ctl_lun *lun, union ctl_io *pending_io, union ctl_io *ooa_io); static ctl_action ctl_check_ooa(struct ctl_lun *lun, union ctl_io *pending_io, - union ctl_io *starting_io); -static int ctl_check_blocked(struct ctl_lun *lun); + union ctl_io **starting_io); +static void ctl_try_unblock_io(struct ctl_lun *lun, union ctl_io *io, + bool skip); +static void ctl_try_unblock_others(struct ctl_lun *lun, union ctl_io *io, + bool skip); static int ctl_scsiio_lun_check(struct ctl_lun *lun, const struct ctl_cmd_entry *entry, struct ctl_scsiio *ctsio); @@ -2274,6 +2277,7 @@ ctl_serialize_other_sc_cmd(struct ctl_scsiio *ctsio) union ctl_ha_msg msg_info; struct ctl_lun *lun; const struct ctl_cmd_entry *entry; + union ctl_io *bio; uint32_t targ_lun; targ_lun = ctsio->io_hdr.nexus.targ_mapped_lun; @@ -2332,12 +2336,11 @@ ctl_serialize_other_sc_cmd(struct ctl_scsiio *ctsio) #endif TAILQ_INSERT_TAIL(&lun->ooa_queue, &ctsio->io_hdr, ooa_links); - switch (ctl_check_ooa(lun, (union ctl_io *)ctsio, - (union ctl_io *)TAILQ_PREV(&ctsio->io_hdr, ctl_ooaq, - ooa_links))) { + bio = (union ctl_io *)TAILQ_PREV(&ctsio->io_hdr, ctl_ooaq, ooa_links); + switch (ctl_check_ooa(lun, (union ctl_io *)ctsio, &bio)) { case CTL_ACTION_BLOCK: - ctsio->io_hdr.flags |= CTL_FLAG_BLOCKED; - TAILQ_INSERT_TAIL(&lun->blocked_queue, &ctsio->io_hdr, + ctsio->io_hdr.blocker = bio; + TAILQ_INSERT_TAIL(&bio->io_hdr.blocked_queue, &ctsio->io_hdr, blocked_links); mtx_unlock(&lun->lun_lock); break; @@ -2419,7 +2422,7 @@ ctl_ioctl_fill_ooa(struct ctl_lun *lun, uint32_t *cur_ #endif bcopy(io->scsiio.cdb, entry->cdb, io->scsiio.cdb_len); entry->cdb_len = io->scsiio.cdb_len; - if (io->io_hdr.flags & CTL_FLAG_BLOCKED) + if (io->io_hdr.blocker != NULL) entry->cmd_flags |= CTL_OOACMD_FLAG_BLOCKED; if (io->io_hdr.flags & CTL_FLAG_DMA_INPROG) @@ -3914,6 +3917,7 @@ ctl_alloc_io(void *pool_ref) if (io != NULL) { io->io_hdr.pool = pool_ref; CTL_SOFTC(io) = pool->ctl_softc; + TAILQ_INIT(&io->io_hdr.blocked_queue); } return (io); } @@ -3928,6 +3932,7 @@ ctl_alloc_io_nowait(void *pool_ref) if (io != NULL) { io->io_hdr.pool = pool_ref; CTL_SOFTC(io) = pool->ctl_softc; + TAILQ_INIT(&io->io_hdr.blocked_queue); } return (io); } @@ -3959,6 +3964,7 @@ ctl_zero_io(union ctl_io *io) memset(io, 0, sizeof(*io)); io->io_hdr.pool = pool; CTL_SOFTC(io) = pool->ctl_softc; + TAILQ_INIT(&io->io_hdr.blocked_queue); } int @@ -4719,7 +4725,6 @@ fail: lun->last_busy = getsbinuptime(); #endif TAILQ_INIT(&lun->ooa_queue); - TAILQ_INIT(&lun->blocked_queue); STAILQ_INIT(&lun->error_list); lun->ie_reported = 1; callout_init_mtx(&lun->ie_callout, &lun->lun_lock, 0); @@ -5906,7 +5911,7 @@ ctl_unmap(struct ctl_scsiio *ctsio) ptrlen->ptr = (void *)buf; ptrlen->len = len; ptrlen->flags = byte2; - ctl_check_blocked(lun); + ctl_try_unblock_others(lun, (union ctl_io *)ctsio, FALSE); mtx_unlock(&lun->lun_lock); retval = lun->backend->config_write((union ctl_io *)ctsio); @@ -10793,6 +10798,14 @@ ctl_check_for_blockage(struct ctl_lun *lun, union ctl_ const ctl_serialize_action *serialize_row; /* + * Aborted commands are not going to be executed and may even + * not report completion, so we don't care about their order. + * Let them complete ASAP to clean the OOA queue. + */ + if (pending_io->io_hdr.flags & CTL_FLAG_ABORT) + return (CTL_ACTION_SKIP); + + /* * The initiator attempted multiple untagged commands at the same * time. Can't do that. */ @@ -10922,7 +10935,7 @@ ctl_check_for_blockage(struct ctl_lun *lun, union ctl_ */ static ctl_action ctl_check_ooa(struct ctl_lun *lun, union ctl_io *pending_io, - union ctl_io *starting_io) + union ctl_io **starting_io) { union ctl_io *ooa_io; ctl_action action; @@ -10935,150 +10948,152 @@ ctl_check_ooa(struct ctl_lun *lun, union ctl_io *pendi * queue. If starting_io is NULL, we'll just end up returning * CTL_ACTION_PASS. */ - for (ooa_io = starting_io; ooa_io != NULL; + for (ooa_io = *starting_io; ooa_io != NULL; ooa_io = (union ctl_io *)TAILQ_PREV(&ooa_io->io_hdr, ctl_ooaq, ooa_links)){ - - /* - * This routine just checks to see whether - * cur_blocked is blocked by ooa_io, which is ahead - * of it in the queue. It doesn't queue/dequeue - * cur_blocked. - */ action = ctl_check_for_blockage(lun, pending_io, ooa_io); - switch (action) { - case CTL_ACTION_BLOCK: - case CTL_ACTION_OVERLAP: - case CTL_ACTION_OVERLAP_TAG: - case CTL_ACTION_SKIP: - case CTL_ACTION_ERROR: + if (action != CTL_ACTION_PASS) { + *starting_io = ooa_io; return (action); - break; /* NOTREACHED */ - case CTL_ACTION_PASS: - break; - default: - panic("%s: Invalid action %d\n", __func__, action); } } + *starting_io = NULL; return (CTL_ACTION_PASS); } /* - * Assumptions: - * - An I/O has just completed, and has been removed from the per-LUN OOA - * queue, so some items on the blocked queue may now be unblocked. + * Try to unblock the specified I/O. + * + * skip parameter allows explicitly skip present blocker of the I/O, + * starting from the previous one on OOA queue. It can be used when + * we know for sure that the blocker I/O does no longer count. */ -static int -ctl_check_blocked(struct ctl_lun *lun) +static void +ctl_try_unblock_io(struct ctl_lun *lun, union ctl_io *io, bool skip) { struct ctl_softc *softc = lun->ctl_softc; - union ctl_io *cur_blocked, *next_blocked; + union ctl_io *bio, *obio; + const struct ctl_cmd_entry *entry; + union ctl_ha_msg msg_info; + ctl_action action; mtx_assert(&lun->lun_lock, MA_OWNED); - /* - * Run forward from the head of the blocked queue, checking each - * entry against the I/Os prior to it on the OOA queue to see if - * there is still any blockage. - * - * We cannot use the TAILQ_FOREACH() macro, because it can't deal - * with our removing a variable on it while it is traversing the - * list. - */ - for (cur_blocked = (union ctl_io *)TAILQ_FIRST(&lun->blocked_queue); - cur_blocked != NULL; cur_blocked = next_blocked) { - union ctl_io *prev_ooa; - ctl_action action; + if (io->io_hdr.blocker == NULL) + return; - next_blocked = (union ctl_io *)TAILQ_NEXT(&cur_blocked->io_hdr, - blocked_links); + obio = bio = io->io_hdr.blocker; + if (skip) + bio = (union ctl_io *)TAILQ_PREV(&bio->io_hdr, ctl_ooaq, + ooa_links); + action = ctl_check_ooa(lun, io, &bio); + if (action == CTL_ACTION_BLOCK) { + /* Still blocked, but may be by different I/O now. */ + if (bio != obio) { + TAILQ_REMOVE(&obio->io_hdr.blocked_queue, + &io->io_hdr, blocked_links); + TAILQ_INSERT_TAIL(&bio->io_hdr.blocked_queue, + &io->io_hdr, blocked_links); + io->io_hdr.blocker = bio; + } + return; + } - prev_ooa = (union ctl_io *)TAILQ_PREV(&cur_blocked->io_hdr, - ctl_ooaq, ooa_links); + /* No longer blocked, one way or another. */ + TAILQ_REMOVE(&obio->io_hdr.blocked_queue, &io->io_hdr, blocked_links); + io->io_hdr.blocker = NULL; + switch (action) { + case CTL_ACTION_OVERLAP: + ctl_set_overlapped_cmd(&io->scsiio); + goto error; + case CTL_ACTION_OVERLAP_TAG: + ctl_set_overlapped_tag(&io->scsiio, + io->scsiio.tag_num & 0xff); + goto error; + case CTL_ACTION_PASS: + case CTL_ACTION_SKIP: + + /* Serializing commands from the other SC retire there. */ + if ((io->io_hdr.flags & CTL_FLAG_FROM_OTHER_SC) && + (softc->ha_mode != CTL_HA_MODE_XFER)) { + io->io_hdr.flags &= ~CTL_FLAG_IO_ACTIVE; + msg_info.hdr.original_sc = io->io_hdr.remote_io; + msg_info.hdr.serializing_sc = io; + msg_info.hdr.msg_type = CTL_MSG_R2R; + ctl_ha_msg_send(CTL_HA_CHAN_CTL, &msg_info, + sizeof(msg_info.hdr), M_NOWAIT); + break; + } + /* - * If cur_blocked happens to be the first item in the OOA - * queue now, prev_ooa will be NULL, and the action - * returned will just be CTL_ACTION_PASS. + * Check this I/O for LUN state changes that may have happened + * while this command was blocked. The LUN state may have been + * changed by a command ahead of us in the queue. */ - action = ctl_check_ooa(lun, cur_blocked, prev_ooa); - - switch (action) { - case CTL_ACTION_BLOCK: - /* Nothing to do here, still blocked */ + entry = ctl_get_cmd_entry(&io->scsiio, NULL); + if (ctl_scsiio_lun_check(lun, entry, &io->scsiio) != 0) { + ctl_done(io); break; - case CTL_ACTION_OVERLAP: - case CTL_ACTION_OVERLAP_TAG: - /* - * This shouldn't happen! In theory we've already - * checked this command for overlap... - */ - break; - case CTL_ACTION_PASS: - case CTL_ACTION_SKIP: { - const struct ctl_cmd_entry *entry; + } - /* - * The skip case shouldn't happen, this transaction - * should have never made it onto the blocked queue. - */ - /* - * This I/O is no longer blocked, we can remove it - * from the blocked queue. Since this is a TAILQ - * (doubly linked list), we can do O(1) removals - * from any place on the list. - */ - TAILQ_REMOVE(&lun->blocked_queue, &cur_blocked->io_hdr, - blocked_links); - cur_blocked->io_hdr.flags &= ~CTL_FLAG_BLOCKED; + io->io_hdr.flags |= CTL_FLAG_IS_WAS_ON_RTR; + ctl_enqueue_rtr(io); + break; + case CTL_ACTION_ERROR: + default: + ctl_set_internal_failure(&io->scsiio, + /*sks_valid*/ 0, + /*retry_count*/ 0); - if ((softc->ha_mode != CTL_HA_MODE_XFER) && - (cur_blocked->io_hdr.flags & CTL_FLAG_FROM_OTHER_SC)){ - /* - * Need to send IO back to original side to - * run - */ - union ctl_ha_msg msg_info; +error: + /* Serializing commands from the other SC are done here. */ + if ((io->io_hdr.flags & CTL_FLAG_FROM_OTHER_SC) && + (softc->ha_mode != CTL_HA_MODE_XFER)) { + ctl_try_unblock_others(lun, io, TRUE); + TAILQ_REMOVE(&lun->ooa_queue, &io->io_hdr, ooa_links); - cur_blocked->io_hdr.flags &= ~CTL_FLAG_IO_ACTIVE; - msg_info.hdr.original_sc = - cur_blocked->io_hdr.remote_io; - msg_info.hdr.serializing_sc = cur_blocked; - msg_info.hdr.msg_type = CTL_MSG_R2R; - ctl_ha_msg_send(CTL_HA_CHAN_CTL, &msg_info, - sizeof(msg_info.hdr), M_NOWAIT); - break; - } - entry = ctl_get_cmd_entry(&cur_blocked->scsiio, NULL); - - /* - * Check this I/O for LUN state changes that may - * have happened while this command was blocked. - * The LUN state may have been changed by a command - * ahead of us in the queue, so we need to re-check - * for any states that can be caused by SCSI - * commands. - */ - if (ctl_scsiio_lun_check(lun, entry, - &cur_blocked->scsiio) == 0) { - cur_blocked->io_hdr.flags |= - CTL_FLAG_IS_WAS_ON_RTR; - ctl_enqueue_rtr(cur_blocked); - } else - ctl_done(cur_blocked); + ctl_copy_sense_data_back(io, &msg_info); + msg_info.hdr.original_sc = io->io_hdr.remote_io; + msg_info.hdr.serializing_sc = NULL; + msg_info.hdr.msg_type = CTL_MSG_BAD_JUJU; + ctl_ha_msg_send(CTL_HA_CHAN_CTL, &msg_info, + sizeof(msg_info.scsi), M_WAITOK); + ctl_free_io(io); break; } - default: - /* - * This probably shouldn't happen -- we shouldn't - * get CTL_ACTION_ERROR, or anything else. - */ - break; - } + + ctl_done(io); + break; } +} - return (CTL_RETVAL_COMPLETE); +/* + * Try to unblock I/Os blocked by the specified I/O. + * + * skip parameter allows explicitly skip the specified I/O as blocker, + * starting from the previous one on the OOA queue. It can be used when + * we know for sure that the specified I/O does no longer count (done). + * It has to be still on OOA queue though so that we know where to start. + */ +static void +ctl_try_unblock_others(struct ctl_lun *lun, union ctl_io *bio, bool skip) +{ + union ctl_io *io, *next_io; + + mtx_assert(&lun->lun_lock, MA_OWNED); + + for (io = (union ctl_io *)TAILQ_FIRST(&bio->io_hdr.blocked_queue); + io != NULL; io = next_io) { + next_io = (union ctl_io *)TAILQ_NEXT(&io->io_hdr, blocked_links); + + KASSERT(io->io_hdr.blocker != NULL, + ("I/O %p on blocked list without blocker", io)); + ctl_try_unblock_io(lun, io, skip); + } + KASSERT(!skip || TAILQ_EMPTY(&bio->io_hdr.blocked_queue), + ("blocked_queue is not empty after skipping %p", bio)); } /* @@ -11246,6 +11261,8 @@ ctl_failover_lun(union ctl_io *rio) if (io->flags & CTL_FLAG_IO_ACTIVE) { io->flags |= CTL_FLAG_ABORT; io->flags |= CTL_FLAG_FAILOVER; + ctl_try_unblock_io(lun, + (union ctl_io *)io, FALSE); } else { /* This can be only due to DATAMOVE */ io->msg_type = CTL_MSG_DATAMOVE_DONE; io->flags &= ~CTL_FLAG_DMA_INPROG; @@ -11253,7 +11270,7 @@ ctl_failover_lun(union ctl_io *rio) io->port_status = 31340; ctl_enqueue_isc((union ctl_io *)io); } - } + } else /* We are slave */ if (io->flags & CTL_FLAG_SENT_2OTHER_SC) { io->flags &= ~CTL_FLAG_SENT_2OTHER_SC; @@ -11267,23 +11284,19 @@ ctl_failover_lun(union ctl_io *rio) } } } else { /* SERIALIZE modes */ - TAILQ_FOREACH_SAFE(io, &lun->blocked_queue, blocked_links, - next_io) { - /* We are master */ - if (io->flags & CTL_FLAG_FROM_OTHER_SC) { - TAILQ_REMOVE(&lun->blocked_queue, io, - blocked_links); - io->flags &= ~CTL_FLAG_BLOCKED; - TAILQ_REMOVE(&lun->ooa_queue, io, ooa_links); - ctl_free_io((union ctl_io *)io); - } - } TAILQ_FOREACH_SAFE(io, &lun->ooa_queue, ooa_links, next_io) { /* We are master */ if (io->flags & CTL_FLAG_FROM_OTHER_SC) { + if (io->blocker != NULL) { + TAILQ_REMOVE(&io->blocker->io_hdr.blocked_queue, + io, blocked_links); + io->blocker = NULL; + } + ctl_try_unblock_others(lun, (union ctl_io *)io, + TRUE); TAILQ_REMOVE(&lun->ooa_queue, io, ooa_links); ctl_free_io((union ctl_io *)io); - } + } else /* We are slave */ if (io->flags & CTL_FLAG_SENT_2OTHER_SC) { io->flags &= ~CTL_FLAG_SENT_2OTHER_SC; @@ -11294,7 +11307,6 @@ ctl_failover_lun(union ctl_io *rio) } } } - ctl_check_blocked(lun); } mtx_unlock(&lun->lun_lock); } @@ -11304,6 +11316,7 @@ ctl_scsiio_precheck(struct ctl_softc *softc, struct ct { struct ctl_lun *lun; const struct ctl_cmd_entry *entry; + union ctl_io *bio; uint32_t initidx, targ_lun; int retval = 0; @@ -11479,12 +11492,11 @@ ctl_scsiio_precheck(struct ctl_softc *softc, struct ct return (retval); } - switch (ctl_check_ooa(lun, (union ctl_io *)ctsio, - (union ctl_io *)TAILQ_PREV(&ctsio->io_hdr, - ctl_ooaq, ooa_links))) { + bio = (union ctl_io *)TAILQ_PREV(&ctsio->io_hdr, ctl_ooaq, ooa_links); + switch (ctl_check_ooa(lun, (union ctl_io *)ctsio, &bio)) { case CTL_ACTION_BLOCK: - ctsio->io_hdr.flags |= CTL_FLAG_BLOCKED; - TAILQ_INSERT_TAIL(&lun->blocked_queue, &ctsio->io_hdr, + ctsio->io_hdr.blocker = bio; + TAILQ_INSERT_TAIL(&bio->io_hdr.blocked_queue, &ctsio->io_hdr, blocked_links); mtx_unlock(&lun->lun_lock); return (retval); @@ -11697,6 +11709,7 @@ ctl_do_lun_reset(struct ctl_lun *lun, uint32_t initidx for (xio = (union ctl_io *)TAILQ_FIRST(&lun->ooa_queue); xio != NULL; xio = (union ctl_io *)TAILQ_NEXT(&xio->io_hdr, ooa_links)) { xio->io_hdr.flags |= CTL_FLAG_ABORT | CTL_FLAG_ABORT_STATUS; + ctl_try_unblock_io(lun, xio, FALSE); } /* Clear CA. */ for (i = 0; i < ctl_max_ports; i++) { @@ -11795,6 +11808,7 @@ ctl_abort_tasks_lun(struct ctl_lun *lun, uint32_t targ ctl_ha_msg_send(CTL_HA_CHAN_CTL, &msg_info, sizeof(msg_info.task), M_NOWAIT); } + ctl_try_unblock_io(lun, xio, FALSE); } } } @@ -11967,6 +11981,7 @@ ctl_abort_task(union ctl_io *io) ctl_ha_msg_send(CTL_HA_CHAN_CTL, &msg_info, sizeof(msg_info.task), M_NOWAIT); } + ctl_try_unblock_io(lun, xio, FALSE); } } mtx_unlock(&lun->lun_lock); @@ -12142,8 +12157,8 @@ ctl_handle_isc(union ctl_io *io) break; } mtx_lock(&lun->lun_lock); + ctl_try_unblock_others(lun, io, TRUE); TAILQ_REMOVE(&lun->ooa_queue, &io->io_hdr, ooa_links); - ctl_check_blocked(lun); mtx_unlock(&lun->lun_lock); ctl_free_io(io); break; @@ -12982,6 +12997,13 @@ ctl_process_done(union ctl_io *io) } /* + * Run through the blocked queue of this I/O and see if anything + * can be unblocked, now that this I/O is done and will be removed. + * We need to do it before removal to have OOA position to start. + */ + ctl_try_unblock_others(lun, io, TRUE); + + /* * Remove this from the OOA queue. */ TAILQ_REMOVE(&lun->ooa_queue, &io->io_hdr, ooa_links); @@ -12991,12 +13013,6 @@ ctl_process_done(union ctl_io *io) #endif /* - * Run through the blocked queue on this LUN and see if anything - * has become unblocked, now that this transaction is done. - */ - ctl_check_blocked(lun); - - /* * If the LUN has been invalidated, free it if there is nothing * left on its OOA queue. */ @@ -13151,7 +13167,7 @@ ctl_serseq_done(union ctl_io *io) return; mtx_lock(&lun->lun_lock); io->io_hdr.flags |= CTL_FLAG_SERSEQ_DONE; - ctl_check_blocked(lun); + ctl_try_unblock_others(lun, io, FALSE); mtx_unlock(&lun->lun_lock); } Modified: stable/11/sys/cam/ctl/ctl_frontend_ioctl.c ============================================================================== --- stable/11/sys/cam/ctl/ctl_frontend_ioctl.c Wed Mar 13 20:27:48 2019 (r345113) +++ stable/11/sys/cam/ctl/ctl_frontend_ioctl.c Wed Mar 13 20:28:07 2019 (r345114) @@ -413,6 +413,7 @@ ctl_ioctl_io(struct cdev *dev, u_long cmd, caddr_t add memcpy(io, (void *)addr, sizeof(*io)); io->io_hdr.pool = pool_tmp; CTL_SOFTC(io) = sc_tmp; + TAILQ_INIT(&io->io_hdr.blocked_queue); /* * No status yet, so make sure the status is set properly. Modified: stable/11/sys/cam/ctl/ctl_io.h ============================================================================== --- stable/11/sys/cam/ctl/ctl_io.h Wed Mar 13 20:27:48 2019 (r345113) +++ stable/11/sys/cam/ctl/ctl_io.h Wed Mar 13 20:28:07 2019 (r345114) @@ -85,7 +85,6 @@ typedef enum { CTL_FLAG_DO_AUTOSENSE = 0x00000020, /* grab sense info */ CTL_FLAG_USER_REQ = 0x00000040, /* request came from userland */ CTL_FLAG_ALLOCATED = 0x00000100, /* data space allocated */ - CTL_FLAG_BLOCKED = 0x00000200, /* on the blocked queue */ CTL_FLAG_ABORT_STATUS = 0x00000400, /* return TASK ABORTED status */ CTL_FLAG_ABORT = 0x00000800, /* this I/O should be aborted */ CTL_FLAG_DMA_INPROG = 0x00001000, /* DMA in progress */ @@ -237,14 +236,13 @@ struct ctl_io_hdr { #endif /* CTL_TIME_IO */ uint32_t num_dmas; /* Number of DMAs */ union ctl_io *remote_io; /* I/O counterpart on remote HA side */ - void *pad1; + union ctl_io *blocker; /* I/O blocking this one */ void *pool; /* I/O pool */ union ctl_priv ctl_private[CTL_NUM_PRIV];/* CTL private area */ - void *pad2; - void *pad3; + TAILQ_HEAD(, ctl_io_hdr) blocked_queue; /* I/Os blocked by this one */ STAILQ_ENTRY(ctl_io_hdr) links; /* linked list pointer */ - TAILQ_ENTRY(ctl_io_hdr) ooa_links; - TAILQ_ENTRY(ctl_io_hdr) blocked_links; + TAILQ_ENTRY(ctl_io_hdr) ooa_links; /* ooa_queue links */ + TAILQ_ENTRY(ctl_io_hdr) blocked_links; /* blocked_queue links */ }; typedef enum { Modified: stable/11/sys/cam/ctl/ctl_private.h ============================================================================== --- stable/11/sys/cam/ctl/ctl_private.h Wed Mar 13 20:27:48 2019 (r345113) +++ stable/11/sys/cam/ctl/ctl_private.h Wed Mar 13 20:28:07 2019 (r345114) @@ -388,7 +388,6 @@ struct ctl_lun { sbintime_t last_busy; #endif TAILQ_HEAD(ctl_ooaq, ctl_io_hdr) ooa_queue; - TAILQ_HEAD(ctl_blockq,ctl_io_hdr) blocked_queue; STAILQ_ENTRY(ctl_lun) links; struct scsi_sense_data **pending_sense; ctl_ua_type **pending_ua; From owner-svn-src-stable-11@freebsd.org Wed Mar 13 20:29:11 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CC3E11541142; Wed, 13 Mar 2019 20:29:11 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6BA7C6F03B; Wed, 13 Mar 2019 20:29:11 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 58526FAF5; Wed, 13 Mar 2019 20:29:11 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2DKTBKh040474; Wed, 13 Mar 2019 20:29:11 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2DKTBtO040473; Wed, 13 Mar 2019 20:29:11 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201903132029.x2DKTBtO040473@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 13 Mar 2019 20:29:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r345116 - stable/11/usr.bin/ctlstat X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/usr.bin/ctlstat X-SVN-Commit-Revision: 345116 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 6BA7C6F03B X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.996,0]; NEURAL_HAM_SHORT(-0.98)[-0.978,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-0.999,0] X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Mar 2019 20:29:12 -0000 Author: mav Date: Wed Mar 13 20:29:10 2019 New Revision: 345116 URL: https://svnweb.freebsd.org/changeset/base/345116 Log: MFC r344844: Flush stdout after each iteration. Without this, if output is redirected from the console, it is buffered for too long, making tool quite unusable. Modified: stable/11/usr.bin/ctlstat/ctlstat.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/ctlstat/ctlstat.c ============================================================================== --- stable/11/usr.bin/ctlstat/ctlstat.c Wed Mar 13 20:28:48 2019 (r345115) +++ stable/11/usr.bin/ctlstat/ctlstat.c Wed Mar 13 20:29:10 2019 (r345116) @@ -717,6 +717,7 @@ main(int argc, char **argv) } fprintf(stdout, "\n"); + fflush(stdout); ctx.flags &= ~CTLSTAT_FLAG_FIRST_RUN; if (count != 1) sleep(waittime); From owner-svn-src-stable-11@freebsd.org Thu Mar 14 00:57:56 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0E458154699D; Thu, 14 Mar 2019 00:57:56 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A206F80407; Thu, 14 Mar 2019 00:57:55 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 936971A8E2; Thu, 14 Mar 2019 00:57:55 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2E0vtWI082624; Thu, 14 Mar 2019 00:57:55 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2E0vt9L082623; Thu, 14 Mar 2019 00:57:55 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201903140057.x2E0vt9L082623@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 14 Mar 2019 00:57:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r345121 - stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Commit-Revision: 345121 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: A206F80407 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.996,0]; NEURAL_HAM_SHORT(-0.97)[-0.970,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-0.999,0] X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Mar 2019 00:57:56 -0000 Author: mav Date: Thu Mar 14 00:57:54 2019 New Revision: 345121 URL: https://svnweb.freebsd.org/changeset/base/345121 Log: MFC r344866: Add respective tunables to few ZFS sysctls. Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_label.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Thu Mar 14 00:57:35 2019 (r345120) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Thu Mar 14 00:57:54 2019 (r345121) @@ -1343,22 +1343,22 @@ boolean_t l2arc_noprefetch = B_TRUE; /* don't cache p boolean_t l2arc_feed_again = B_TRUE; /* turbo warmup */ boolean_t l2arc_norw = B_TRUE; /* no reads during writes */ -SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2arc_write_max, CTLFLAG_RW, +SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2arc_write_max, CTLFLAG_RWTUN, &l2arc_write_max, 0, "max write size"); -SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2arc_write_boost, CTLFLAG_RW, +SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2arc_write_boost, CTLFLAG_RWTUN, &l2arc_write_boost, 0, "extra write during warmup"); -SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2arc_headroom, CTLFLAG_RW, +SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2arc_headroom, CTLFLAG_RWTUN, &l2arc_headroom, 0, "number of dev writes"); -SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2arc_feed_secs, CTLFLAG_RW, +SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2arc_feed_secs, CTLFLAG_RWTUN, &l2arc_feed_secs, 0, "interval seconds"); -SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2arc_feed_min_ms, CTLFLAG_RW, +SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2arc_feed_min_ms, CTLFLAG_RWTUN, &l2arc_feed_min_ms, 0, "min interval milliseconds"); -SYSCTL_INT(_vfs_zfs, OID_AUTO, l2arc_noprefetch, CTLFLAG_RW, +SYSCTL_INT(_vfs_zfs, OID_AUTO, l2arc_noprefetch, CTLFLAG_RWTUN, &l2arc_noprefetch, 0, "don't cache prefetch bufs"); -SYSCTL_INT(_vfs_zfs, OID_AUTO, l2arc_feed_again, CTLFLAG_RW, +SYSCTL_INT(_vfs_zfs, OID_AUTO, l2arc_feed_again, CTLFLAG_RWTUN, &l2arc_feed_again, 0, "turbo warmup"); -SYSCTL_INT(_vfs_zfs, OID_AUTO, l2arc_norw, CTLFLAG_RW, +SYSCTL_INT(_vfs_zfs, OID_AUTO, l2arc_norw, CTLFLAG_RWTUN, &l2arc_norw, 0, "no reads during writes"); SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, anon_size, CTLFLAG_RD, Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_label.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_label.c Thu Mar 14 00:57:35 2019 (r345120) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_label.c Thu Mar 14 00:57:54 2019 (r345121) @@ -152,7 +152,7 @@ static boolean_t vdev_trim_on_init = B_TRUE; SYSCTL_DECL(_vfs_zfs_vdev); -SYSCTL_INT(_vfs_zfs_vdev, OID_AUTO, trim_on_init, CTLFLAG_RW, +SYSCTL_INT(_vfs_zfs_vdev, OID_AUTO, trim_on_init, CTLFLAG_RWTUN, &vdev_trim_on_init, 0, "Enable/disable full vdev trim on initialisation"); /* From owner-svn-src-stable-11@freebsd.org Thu Mar 14 00:58:58 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1C0B81546A80; Thu, 14 Mar 2019 00:58:58 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B711980662; Thu, 14 Mar 2019 00:58:57 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id ABB5D1A8E5; Thu, 14 Mar 2019 00:58:57 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2E0wvvL082779; Thu, 14 Mar 2019 00:58:57 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2E0wvR7082778; Thu, 14 Mar 2019 00:58:57 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201903140058.x2E0wvR7082778@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 14 Mar 2019 00:58:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r345123 - stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Commit-Revision: 345123 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: B711980662 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.996,0]; NEURAL_HAM_SHORT(-0.97)[-0.969,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-0.999,0] X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Mar 2019 00:58:58 -0000 Author: mav Date: Thu Mar 14 00:58:57 2019 New Revision: 345123 URL: https://svnweb.freebsd.org/changeset/base/345123 Log: MFC r344903: Improve entropy for ZFS taskqueue selection. I just found that at least on Skylake CPUs cpu_ticks() never returns odd values, only even, and possibly has even bigger step (176/2?), that makes its lower bits very bad entropy source, leaving half of taskqueues unused. Switch to sbinuptime(), closer to upstreams, mitigates the problem by the rate conversion working as kind of hash function. In case that is somehow not enough (timer rate is too low or too divisible) mix in curcpu. Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c Thu Mar 14 00:58:39 2019 (r345122) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c Thu Mar 14 00:58:57 2019 (r345123) @@ -1063,7 +1063,8 @@ spa_taskq_dispatch_ent(spa_t *spa, zio_type_t t, zio_t tq = tqs->stqs_taskq[0]; } else { #ifdef _KERNEL - tq = tqs->stqs_taskq[cpu_ticks() % tqs->stqs_count]; + tq = tqs->stqs_taskq[(u_int)(sbinuptime() + curcpu) % + tqs->stqs_count]; #else tq = tqs->stqs_taskq[gethrtime() % tqs->stqs_count]; #endif From owner-svn-src-stable-11@freebsd.org Thu Mar 14 08:27:03 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F3559153614C; Thu, 14 Mar 2019 08:27:02 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5207F6B455; Thu, 14 Mar 2019 08:27:02 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 41DF21FB71; Thu, 14 Mar 2019 08:27:02 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2E8R231016703; Thu, 14 Mar 2019 08:27:02 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2E8R1b2016702; Thu, 14 Mar 2019 08:27:01 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201903140827.x2E8R1b2016702@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Thu, 14 Mar 2019 08:27:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r345126 - in stable/11/sys: amd64/amd64 i386/i386 X-SVN-Group: stable-11 X-SVN-Commit-Author: ae X-SVN-Commit-Paths: in stable/11/sys: amd64/amd64 i386/i386 X-SVN-Commit-Revision: 345126 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 5207F6B455 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.997,0]; NEURAL_HAM_SHORT(-0.97)[-0.974,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-0.999,0] X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Mar 2019 08:27:03 -0000 Author: ae Date: Thu Mar 14 08:27:01 2019 New Revision: 345126 URL: https://svnweb.freebsd.org/changeset/base/345126 Log: MFC r344873: Fix typo. Modified: stable/11/sys/amd64/amd64/vm_machdep.c stable/11/sys/i386/i386/vm_machdep.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/amd64/amd64/vm_machdep.c ============================================================================== --- stable/11/sys/amd64/amd64/vm_machdep.c Thu Mar 14 08:25:28 2019 (r345125) +++ stable/11/sys/amd64/amd64/vm_machdep.c Thu Mar 14 08:27:01 2019 (r345126) @@ -85,7 +85,7 @@ _Static_assert(OFFSETOF_CURTHREAD == offsetof(struct p _Static_assert(OFFSETOF_CURPCB == offsetof(struct pcpu, pc_curpcb), "OFFSETOF_CURPCB does not correspond with offset of pc_curpcb."); _Static_assert(OFFSETOF_MONITORBUF == offsetof(struct pcpu, pc_monitorbuf), - "OFFSETOF_MONINORBUF does not correspond with offset of pc_monitorbuf."); + "OFFSETOF_MONITORBUF does not correspond with offset of pc_monitorbuf."); struct savefpu * get_pcb_user_save_td(struct thread *td) Modified: stable/11/sys/i386/i386/vm_machdep.c ============================================================================== --- stable/11/sys/i386/i386/vm_machdep.c Thu Mar 14 08:25:28 2019 (r345125) +++ stable/11/sys/i386/i386/vm_machdep.c Thu Mar 14 08:27:01 2019 (r345126) @@ -98,7 +98,7 @@ _Static_assert(OFFSETOF_CURTHREAD == offsetof(struct p _Static_assert(OFFSETOF_CURPCB == offsetof(struct pcpu, pc_curpcb), "OFFSETOF_CURPCB does not correspond with offset of pc_curpcb."); _Static_assert(__OFFSETOF_MONITORBUF == offsetof(struct pcpu, pc_monitorbuf), - "__OFFSETOF_MONINORBUF does not correspond with offset of pc_monitorbuf."); + "__OFFSETOF_MONITORBUF does not correspond with offset of pc_monitorbuf."); union savefpu * get_pcb_user_save_td(struct thread *td) From owner-svn-src-stable-11@freebsd.org Fri Mar 15 08:18:03 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 44C4E154233C; Fri, 15 Mar 2019 08:18:03 +0000 (UTC) (envelope-from avos@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D5E328DC8A; Fri, 15 Mar 2019 08:18:02 +0000 (UTC) (envelope-from avos@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C2A41762D; Fri, 15 Mar 2019 08:18:02 +0000 (UTC) (envelope-from avos@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2F8I2AM071730; Fri, 15 Mar 2019 08:18:02 GMT (envelope-from avos@FreeBSD.org) Received: (from avos@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2F8I28U071729; Fri, 15 Mar 2019 08:18:02 GMT (envelope-from avos@FreeBSD.org) Message-Id: <201903150818.x2F8I28U071729@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avos set sender to avos@FreeBSD.org using -f From: Andriy Voskoboinyk Date: Fri, 15 Mar 2019 08:18:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r345173 - in stable: 11/sbin/ifconfig 12/sbin/ifconfig X-SVN-Group: stable-11 X-SVN-Commit-Author: avos X-SVN-Commit-Paths: in stable: 11/sbin/ifconfig 12/sbin/ifconfig X-SVN-Commit-Revision: 345173 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: D5E328DC8A X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.997,0]; NEURAL_HAM_SHORT(-0.98)[-0.977,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Mar 2019 08:18:03 -0000 Author: avos Date: Fri Mar 15 08:18:02 2019 New Revision: 345173 URL: https://svnweb.freebsd.org/changeset/base/345173 Log: MFC r344748: Allow to build ifconfig(8) without wireless support The change removes SIOC[GS]IEEE80211 handling from ifconfig(8) if WITHOUT_WIRELESS_SUPPORT=yes is set in src.conf(5). Reviewed by: bz Differential Revision: https://reviews.freebsd.org/D19289 Modified: stable/11/sbin/ifconfig/Makefile Directory Properties: stable/11/ (props changed) Changes in other areas also in this revision: Modified: stable/12/sbin/ifconfig/Makefile Directory Properties: stable/12/ (props changed) Modified: stable/11/sbin/ifconfig/Makefile ============================================================================== --- stable/11/sbin/ifconfig/Makefile Fri Mar 15 07:34:06 2019 (r345172) +++ stable/11/sbin/ifconfig/Makefile Fri Mar 15 08:18:02 2019 (r345173) @@ -39,8 +39,10 @@ SRCS+= ifipsec.c # IPsec VTI SRCS+= sfp.c # SFP/SFP+ information LIBADD+= m +.if ${MK_WIRELESS_SUPPORT} != "no" SRCS+= ifieee80211.c # SIOC[GS]IEEE80211 support LIBADD+= 80211 +.endif SRCS+= carp.c # SIOC[GS]VH support SRCS+= ifgroup.c # ... From owner-svn-src-stable-11@freebsd.org Fri Mar 15 11:01:53 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 779741545FB0; Fri, 15 Mar 2019 11:01:53 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 1977592A77; Fri, 15 Mar 2019 11:01:53 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0B70692D1; Fri, 15 Mar 2019 11:01:53 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2FB1qiC060792; Fri, 15 Mar 2019 11:01:52 GMT (envelope-from kp@FreeBSD.org) Received: (from kp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2FB1qKs060791; Fri, 15 Mar 2019 11:01:52 GMT (envelope-from kp@FreeBSD.org) Message-Id: <201903151101.x2FB1qKs060791@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kp set sender to kp@FreeBSD.org using -f From: Kristof Provost Date: Fri, 15 Mar 2019 11:01:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r345176 - stable/11/sys/netpfil/pf X-SVN-Group: stable-11 X-SVN-Commit-Author: kp X-SVN-Commit-Paths: stable/11/sys/netpfil/pf X-SVN-Commit-Revision: 345176 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 1977592A77 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.94 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.997,0]; NEURAL_HAM_SHORT(-0.94)[-0.941,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Mar 2019 11:01:53 -0000 Author: kp Date: Fri Mar 15 11:01:52 2019 New Revision: 345176 URL: https://svnweb.freebsd.org/changeset/base/345176 Log: MFC r344921: pf: Fix DIOCGETSRCNODES r343295 broke DIOCGETSRCNODES by failing to reset 'nr' after counting the number of source tracking nodes. This meant that we never copied the information to userspace, leading to '? -> ?' output from pfctl. PR: 236368 Modified: stable/11/sys/netpfil/pf/pf_ioctl.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/netpfil/pf/pf_ioctl.c ============================================================================== --- stable/11/sys/netpfil/pf/pf_ioctl.c Fri Mar 15 11:01:49 2019 (r345175) +++ stable/11/sys/netpfil/pf/pf_ioctl.c Fri Mar 15 11:01:52 2019 (r345176) @@ -3326,6 +3326,8 @@ DIOCCHANGEADDR_error: break; } + nr = 0; + p = pstore = malloc(psn->psn_len, M_TEMP, M_WAITOK); for (i = 0, sh = V_pf_srchash; i <= pf_srchashmask; i++, sh++) { From owner-svn-src-stable-11@freebsd.org Fri Mar 15 15:16:33 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4360A154B7B5; Fri, 15 Mar 2019 15:16:33 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id DBF446C6F4; Fri, 15 Mar 2019 15:16:32 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B5009BF12; Fri, 15 Mar 2019 15:16:32 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2FFGWWA090936; Fri, 15 Mar 2019 15:16:32 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2FFGVW2090931; Fri, 15 Mar 2019 15:16:31 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201903151516.x2FFGVW2090931@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Fri, 15 Mar 2019 15:16:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r345186 - in stable/11/sys: conf dev/fxp modules/fxp X-SVN-Group: stable-11 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: in stable/11/sys: conf dev/fxp modules/fxp X-SVN-Commit-Revision: 345186 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: DBF446C6F4 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.997,0]; NEURAL_HAM_SHORT(-0.97)[-0.969,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Mar 2019 15:16:33 -0000 Author: markj Date: Fri Mar 15 15:16:31 2019 New Revision: 345186 URL: https://svnweb.freebsd.org/changeset/base/345186 Log: MFC r342214: Remove a use of a negative array index from fxp(4). Modified: stable/11/sys/conf/files stable/11/sys/conf/kern.mk stable/11/sys/dev/fxp/if_fxp.c stable/11/sys/dev/fxp/if_fxpreg.h stable/11/sys/modules/fxp/Makefile Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/conf/files ============================================================================== --- stable/11/sys/conf/files Fri Mar 15 14:49:27 2019 (r345185) +++ stable/11/sys/conf/files Fri Mar 15 15:16:31 2019 (r345186) @@ -1733,8 +1733,7 @@ dev/firewire/sbp.c optional sbp dev/firewire/sbp_targ.c optional sbp_targ dev/flash/at45d.c optional at45d dev/flash/mx25l.c optional mx25l -dev/fxp/if_fxp.c optional fxp \ - compile-with "${NORMAL_C} ${NO_WARRAY_BOUNDS}" +dev/fxp/if_fxp.c optional fxp dev/fxp/inphy.c optional fxp dev/gem/if_gem.c optional gem dev/gem/if_gem_pci.c optional gem pci Modified: stable/11/sys/conf/kern.mk ============================================================================== --- stable/11/sys/conf/kern.mk Fri Mar 15 14:49:27 2019 (r345185) +++ stable/11/sys/conf/kern.mk Fri Mar 15 15:16:31 2019 (r345186) @@ -24,7 +24,6 @@ NO_WSELF_ASSIGN= -Wno-self-assign NO_WUNNEEDED_INTERNAL_DECL= -Wno-unneeded-internal-declaration NO_WSOMETIMES_UNINITIALIZED= -Wno-error-sometimes-uninitialized NO_WCAST_QUAL= -Wno-cast-qual -NO_WARRAY_BOUNDS= -Wno-error-array-bounds # Several other warnings which might be useful in some cases, but not severe # enough to error out the whole kernel build. Display them anyway, so there is # some incentive to fix them eventually. Modified: stable/11/sys/dev/fxp/if_fxp.c ============================================================================== --- stable/11/sys/dev/fxp/if_fxp.c Fri Mar 15 14:49:27 2019 (r345185) +++ stable/11/sys/dev/fxp/if_fxp.c Fri Mar 15 15:16:31 2019 (r345186) @@ -1623,7 +1623,7 @@ fxp_encap(struct fxp_softc *sc, struct mbuf **m_head) cbp->tbd_number = nseg; /* Configure TSO. */ if (m->m_pkthdr.csum_flags & CSUM_TSO) { - cbp->tbd[-1].tb_size = htole32(m->m_pkthdr.tso_segsz << 16); + cbp->tbdtso.tb_size = htole32(m->m_pkthdr.tso_segsz << 16); cbp->tbd[1].tb_size |= htole32(tcp_payload << 16); cbp->ipcb_ip_schedule |= FXP_IPCB_LARGESEND_ENABLE | FXP_IPCB_IP_CHECKSUM_ENABLE | Modified: stable/11/sys/dev/fxp/if_fxpreg.h ============================================================================== --- stable/11/sys/dev/fxp/if_fxpreg.h Fri Mar 15 14:49:27 2019 (r345185) +++ stable/11/sys/dev/fxp/if_fxpreg.h Fri Mar 15 15:16:31 2019 (r345186) @@ -279,10 +279,15 @@ struct fxp_cb_tx { uint16_t cb_status; uint16_t cb_command; uint32_t link_addr; - uint32_t tbd_array_addr; - uint16_t byte_count; - uint8_t tx_threshold; - uint8_t tbd_number; + union { + struct { + uint32_t tbd_array_addr; + uint16_t byte_count; + uint8_t tx_threshold; + uint8_t tbd_number; + }; + struct fxp_tbd tbdtso; + }; /* * The following structure isn't actually part of the TxCB, Modified: stable/11/sys/modules/fxp/Makefile ============================================================================== --- stable/11/sys/modules/fxp/Makefile Fri Mar 15 14:49:27 2019 (r345185) +++ stable/11/sys/modules/fxp/Makefile Fri Mar 15 15:16:31 2019 (r345186) @@ -6,5 +6,3 @@ KMOD= if_fxp SRCS= device_if.h bus_if.h if_fxp.c inphy.c miibus_if.h miidevs.h pci_if.h .include - -CWARNFLAGS+= ${NO_WARRAY_BOUNDS} From owner-svn-src-stable-11@freebsd.org Fri Mar 15 18:50:01 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 02C85152A270; Fri, 15 Mar 2019 18:50:01 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 95AF876267; Fri, 15 Mar 2019 18:50:00 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 881D9E461; Fri, 15 Mar 2019 18:50:00 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2FIo0YZ001590; Fri, 15 Mar 2019 18:50:00 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2FIo0nb001589; Fri, 15 Mar 2019 18:50:00 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201903151850.x2FIo0nb001589@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Fri, 15 Mar 2019 18:50:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r345197 - stable/11/sys/dev/hwpmc X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/11/sys/dev/hwpmc X-SVN-Commit-Revision: 345197 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 95AF876267 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.98)[-0.979,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Mar 2019 18:50:01 -0000 Author: kib Date: Fri Mar 15 18:50:00 2019 New Revision: 345197 URL: https://svnweb.freebsd.org/changeset/base/345197 Log: MFC r345074: Remove useless version check. Modified: stable/11/sys/dev/hwpmc/hwpmc_core.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hwpmc/hwpmc_core.c ============================================================================== --- stable/11/sys/dev/hwpmc/hwpmc_core.c Fri Mar 15 18:18:05 2019 (r345196) +++ stable/11/sys/dev/hwpmc/hwpmc_core.c Fri Mar 15 18:50:00 2019 (r345197) @@ -38,11 +38,7 @@ __FBSDID("$FreeBSD$"); #include #include -#if (__FreeBSD_version >= 1100000) #include -#else -#include -#endif #include #include #include From owner-svn-src-stable-11@freebsd.org Fri Mar 15 18:53:37 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4136B152A49A; Fri, 15 Mar 2019 18:53:37 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D74CD76757; Fri, 15 Mar 2019 18:53:36 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C1E0DE60E; Fri, 15 Mar 2019 18:53:36 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2FIraaI006318; Fri, 15 Mar 2019 18:53:36 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2FIrata006316; Fri, 15 Mar 2019 18:53:36 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201903151853.x2FIrata006316@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Fri, 15 Mar 2019 18:53:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r345199 - in stable/11/sys/x86: include x86 X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: in stable/11/sys/x86: include x86 X-SVN-Commit-Revision: 345199 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: D74CD76757 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_SHORT(-0.98)[-0.979,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Mar 2019 18:53:37 -0000 Author: kib Date: Fri Mar 15 18:53:36 2019 New Revision: 345199 URL: https://svnweb.freebsd.org/changeset/base/345199 Log: MFC r345075: Add register number, CPUID bits, and print identification for TSX force abort errata. Modified: stable/11/sys/x86/include/specialreg.h stable/11/sys/x86/x86/identcpu.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/x86/include/specialreg.h ============================================================================== --- stable/11/sys/x86/include/specialreg.h Fri Mar 15 18:50:36 2019 (r345198) +++ stable/11/sys/x86/include/specialreg.h Fri Mar 15 18:53:36 2019 (r345199) @@ -390,6 +390,7 @@ /* * CPUID instruction 7 Structured Extended Features, leaf 0 edx info */ +#define CPUID_STDEXT3_TSXFA 0x00002000 #define CPUID_STDEXT3_IBPB 0x04000000 #define CPUID_STDEXT3_STIBP 0x08000000 #define CPUID_STDEXT3_L1D_FLUSH 0x10000000 @@ -448,6 +449,7 @@ #define MSR_MTRRcap 0x0fe #define MSR_IA32_ARCH_CAP 0x10a #define MSR_IA32_FLUSH_CMD 0x10b +#define MSR_TSX_FORCE_ABORT 0x10f #define MSR_BBL_CR_ADDR 0x116 #define MSR_BBL_CR_DECC 0x118 #define MSR_BBL_CR_CTL 0x119 Modified: stable/11/sys/x86/x86/identcpu.c ============================================================================== --- stable/11/sys/x86/x86/identcpu.c Fri Mar 15 18:50:36 2019 (r345198) +++ stable/11/sys/x86/x86/identcpu.c Fri Mar 15 18:53:36 2019 (r345199) @@ -991,6 +991,7 @@ printcpuinfo(void) printf("\n Structured Extended Features3=0x%b", cpu_stdext_feature3, "\020" + "\016TSXFA" "\033IBPB" "\034STIBP" "\035L1DFL"