svn commit: r361960 - head/contrib/wpa/src/wps
Author: cy Date: Tue Jun 9 05:43:51 2020 New Revision: 361960 URL: https://svnweb.freebsd.org/changeset/base/361960 Log: Post CVE-2020-12695 cleanup patch: Resolve a Linuxism to fix the build. MFC after:3 days X-MFC with: r361957, r361958, r361959 Modified: head/contrib/wpa/src/wps/wps_upnp.c Modified: head/contrib/wpa/src/wps/wps_upnp.c == --- head/contrib/wpa/src/wps/wps_upnp.c Tue Jun 9 05:39:37 2020 (r361959) +++ head/contrib/wpa/src/wps/wps_upnp.c Tue Jun 9 05:43:51 2020 (r361960) @@ -950,7 +950,11 @@ int get_netif_info(const char *net_if, unsigned *ip_ad errno, strerror(errno)); goto fail; } +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) + addr = (struct sockaddr_in *) _addr; +#else addr = (struct sockaddr_in *) _netmask; +#endif netmask->s_addr = addr->sin_addr.s_addr; } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r361959 - head/contrib/wpa/src/wps
Author: cy Date: Tue Jun 9 05:39:37 2020 New Revision: 361959 URL: https://svnweb.freebsd.org/changeset/base/361959 Log: MFV r361938: Upstream commit message: [PATCH 3/3] WPS UPnP: Handle HTTP initiation failures for events more properly While it is appropriate to try to retransmit the event to another callback URL on a failure to initiate the HTTP client connection, there is no point in trying the exact same operation multiple times in a row. Replve the event_retry() calls with event_addr_failure() for these cases to avoid busy loops trying to repeat the same failing operation. These potential busy loops would go through eloop callbacks, so the process is not completely stuck on handling them, but unnecessary CPU would be used to process the continues retries that will keep failing for the same reason. Obtained from:https://w1.fi/security/2020-1/\ 0003-WPS-UPnP-Handle-HTTP-initiation-failures-for-events-.patch MFC after:3 days Security: VU#339275 and CVE-2020-12695 Modified: head/contrib/wpa/src/wps/wps_upnp_event.c Directory Properties: head/contrib/wpa/ (props changed) Modified: head/contrib/wpa/src/wps/wps_upnp_event.c == --- head/contrib/wpa/src/wps/wps_upnp_event.c Tue Jun 9 05:38:12 2020 (r361958) +++ head/contrib/wpa/src/wps/wps_upnp_event.c Tue Jun 9 05:39:37 2020 (r361959) @@ -294,7 +294,7 @@ static int event_send_start(struct subscription *s) buf = event_build_message(e); if (buf == NULL) { - event_retry(e, 0); + event_addr_failure(e); return -1; } @@ -302,7 +302,7 @@ static int event_send_start(struct subscription *s) event_http_cb, e); if (e->http_event == NULL) { wpabuf_free(buf); - event_retry(e, 0); + event_addr_failure(e); return -1; } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r361958 - head/contrib/wpa/src/wps
Author: cy Date: Tue Jun 9 05:38:12 2020 New Revision: 361958 URL: https://svnweb.freebsd.org/changeset/base/361958 Log: MFV r361937: Upstream commit message: [PATCH 2/3] WPS UPnP: Fix event message generation using a long URL path More than about 700 character URL ended up overflowing the wpabuf used for building the event notification and this resulted in the wpabuf buffer overflow checks terminating the hostapd process. Fix this by allocating the buffer to be large enough to contain the full URL path. However, since that around 700 character limit has been the practical limit for more than ten years, start explicitly enforcing that as the limit or the callback URLs since any longer ones had not worked before and there is no need to enable them now either. Obtained from:https://w1.fi/security/2020-1/\ 0002-WPS-UPnP-Fix-event-message-generation-using-a-long-U.patch MFC after:3 days Security: VU#339275 and CVE-2020-12695 Modified: head/contrib/wpa/src/wps/wps_upnp.c head/contrib/wpa/src/wps/wps_upnp_event.c Directory Properties: head/contrib/wpa/ (props changed) Modified: head/contrib/wpa/src/wps/wps_upnp.c == --- head/contrib/wpa/src/wps/wps_upnp.c Tue Jun 9 05:35:38 2020 (r361957) +++ head/contrib/wpa/src/wps/wps_upnp.c Tue Jun 9 05:38:12 2020 (r361958) @@ -328,9 +328,14 @@ static void subscr_addr_add_url(struct subscription *s int rerr; size_t host_len, path_len; - /* url MUST begin with http: */ - if (url_len < 7 || os_strncasecmp(url, "http://;, 7)) + /* URL MUST begin with HTTP scheme. In addition, limit the length of +* the URL to 700 characters which is around the limit that was +* implicitly enforced for more than 10 years due to a bug in +* generating the event messages. */ + if (url_len < 7 || os_strncasecmp(url, "http://;, 7) || url_len > 700) { + wpa_printf(MSG_DEBUG, "WPS UPnP: Reject an unacceptable URL"); goto fail; + } url += 7; url_len -= 7; Modified: head/contrib/wpa/src/wps/wps_upnp_event.c == --- head/contrib/wpa/src/wps/wps_upnp_event.c Tue Jun 9 05:35:38 2020 (r361957) +++ head/contrib/wpa/src/wps/wps_upnp_event.c Tue Jun 9 05:38:12 2020 (r361958) @@ -147,7 +147,8 @@ static struct wpabuf * event_build_message(struct wps_ struct wpabuf *buf; char *b; - buf = wpabuf_alloc(1000 + wpabuf_len(e->data)); + buf = wpabuf_alloc(1000 + os_strlen(e->addr->path) + + wpabuf_len(e->data)); if (buf == NULL) return NULL; wpabuf_printf(buf, "NOTIFY %s HTTP/1.1\r\n", e->addr->path); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r361957 - head/contrib/wpa/src/wps
Author: cy Date: Tue Jun 9 05:35:38 2020 New Revision: 361957 URL: https://svnweb.freebsd.org/changeset/base/361957 Log: MFV r361936: Upstream commit message: [PATCH 1/3] WPS UPnP: Do not allow event subscriptions with URLs to other networks The UPnP Device Architecture 2.0 specification errata ("UDA errata 16-04-2020.docx") addresses a problem with notifications being allowed to go out to other domains by disallowing such cases. Do such filtering for the notification callback URLs to avoid undesired connections to external networks based on subscriptions that any device in the local network could request when WPS support for external registrars is enabled (the upnp_iface parameter in hostapd configuration). Obtained from:https://w1.fi/security/2020-1/\ 0001-WPS-UPnP-Do-not-allow-event-subscriptions-with-URLs-.patch MFC after:3 days Security: VU#339275 and CVE-2020-12695 Modified: head/contrib/wpa/src/wps/wps_er.c head/contrib/wpa/src/wps/wps_upnp.c head/contrib/wpa/src/wps/wps_upnp_i.h Directory Properties: head/contrib/wpa/ (props changed) Modified: head/contrib/wpa/src/wps/wps_er.c == --- head/contrib/wpa/src/wps/wps_er.c Tue Jun 9 05:01:23 2020 (r361956) +++ head/contrib/wpa/src/wps/wps_er.c Tue Jun 9 05:35:38 2020 (r361957) @@ -1298,7 +1298,7 @@ wps_er_init(struct wps_context *wps, const char *ifnam "with %s", filter); } if (get_netif_info(er->ifname, >ip_addr, >ip_addr_text, - er->mac_addr)) { + NULL, er->mac_addr)) { wpa_printf(MSG_INFO, "WPS UPnP: Could not get IP/MAC address " "for %s. Does it have IP address?", er->ifname); wps_er_deinit(er, NULL, NULL); Modified: head/contrib/wpa/src/wps/wps_upnp.c == --- head/contrib/wpa/src/wps/wps_upnp.c Tue Jun 9 05:01:23 2020 (r361956) +++ head/contrib/wpa/src/wps/wps_upnp.c Tue Jun 9 05:35:38 2020 (r361957) @@ -303,6 +303,14 @@ static void subscr_addr_free_all(struct subscription * } +static int local_network_addr(struct upnp_wps_device_sm *sm, + struct sockaddr_in *addr) +{ + return (addr->sin_addr.s_addr & sm->netmask.s_addr) == + (sm->ip_addr & sm->netmask.s_addr); +} + + /* subscr_addr_add_url -- add address(es) for one url to subscription */ static void subscr_addr_add_url(struct subscription *s, const char *url, size_t url_len) @@ -381,6 +389,7 @@ static void subscr_addr_add_url(struct subscription *s for (rp = result; rp; rp = rp->ai_next) { struct subscr_addr *a; + struct sockaddr_in *addr = (struct sockaddr_in *) rp->ai_addr; /* Limit no. of address to avoid denial of service attack */ if (dl_list_len(>addr_list) >= MAX_ADDR_PER_SUBSCRIPTION) { @@ -389,6 +398,13 @@ static void subscr_addr_add_url(struct subscription *s break; } + if (!local_network_addr(s->sm, addr)) { + wpa_printf(MSG_INFO, + "WPS UPnP: Ignore a delivery URL that points to another network %s", + inet_ntoa(addr->sin_addr)); + continue; + } + a = os_zalloc(sizeof(*a) + alloc_len); if (a == NULL) break; @@ -889,11 +905,12 @@ static int eth_get(const char *device, u8 ea[ETH_ALEN] * @net_if: Selected network interface name * @ip_addr: Buffer for returning IP address in network byte order * @ip_addr_text: Buffer for returning a pointer to allocated IP address text + * @netmask: Buffer for returning netmask or %NULL if not needed * @mac: Buffer for returning MAC address * Returns: 0 on success, -1 on failure */ int get_netif_info(const char *net_if, unsigned *ip_addr, char **ip_addr_text, - u8 mac[ETH_ALEN]) + struct in_addr *netmask, u8 mac[ETH_ALEN]) { struct ifreq req; int sock = -1; @@ -919,6 +936,19 @@ int get_netif_info(const char *net_if, unsigned *ip_ad in_addr.s_addr = *ip_addr; os_snprintf(*ip_addr_text, 16, "%s", inet_ntoa(in_addr)); + if (netmask) { + os_memset(, 0, sizeof(req)); + os_strlcpy(req.ifr_name, net_if, sizeof(req.ifr_name)); + if (ioctl(sock, SIOCGIFNETMASK, ) < 0) { + wpa_printf(MSG_ERROR, + "WPS UPnP: SIOCGIFNETMASK failed: %d (%s)", + errno, strerror(errno)); + goto fail; + } + addr =
svn commit: r361956 - head/usr.sbin/mountd
Author: rmacklem Date: Tue Jun 9 05:01:23 2020 New Revision: 361956 URL: https://svnweb.freebsd.org/changeset/base/361956 Log: Fix a bug where XU_NGROUPS + 1 groups might be copied. r361780 fixed the code so that it would only remove the duplicate when it actually existed. However, that might have resulted in XU_NGROUPS + 1 groups being copied, running off the end of the array. This patch fixes the problem. Spotted during code inspection for other mountd changes. MFC after:2 weeks Modified: head/usr.sbin/mountd/mountd.c Modified: head/usr.sbin/mountd/mountd.c == --- head/usr.sbin/mountd/mountd.c Tue Jun 9 02:07:43 2020 (r361955) +++ head/usr.sbin/mountd/mountd.c Tue Jun 9 05:01:23 2020 (r361956) @@ -3481,6 +3481,8 @@ parsecred(char *namelist, struct xucred *cr) cr->cr_groups[cnt - 1] = groups[cnt]; } else { cr->cr_ngroups = ngroups; + if (cr->cr_ngroups > XU_NGROUPS) + cr->cr_ngroups = XU_NGROUPS; for (cnt = 1; cnt < ngroups; cnt++) cr->cr_groups[cnt] = groups[cnt]; } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r361945 - head/sys/compat/linux
Author: markj Date: Mon Jun 8 22:29:52 2020 New Revision: 361945 URL: https://svnweb.freebsd.org/changeset/base/361945 Log: Stop computing a "sharedram" value when emulating Linux sysinfo(2). The previous code was computing an incorrect value in a very expensive manner. "sharedram" is supposed to be the amount of memory used by named swap objects, which on FreeBSD basically corresponds to memory usage by shared memory objects (including, for example, GEM objects) and tmpfs. We currently have no cheap way to count such pages. The previous code tried to determine the number of copy-on-write pages shared between processes. Just replace the computed value with 0. illumos reportedly does the same thing. Linux itself did not populate this field until a 2014 commit, "mm: export NR_SHMEM via sysinfo(2) / si_meminfo() interfaces". Reported by: mjg MFC after:1 week Modified: head/sys/compat/linux/linux_misc.c Modified: head/sys/compat/linux/linux_misc.c == --- head/sys/compat/linux/linux_misc.c Mon Jun 8 21:51:36 2020 (r361944) +++ head/sys/compat/linux/linux_misc.c Mon Jun 8 22:29:52 2020 (r361945) @@ -79,7 +79,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #ifdef COMPAT_LINUX32 @@ -151,7 +150,6 @@ int linux_sysinfo(struct thread *td, struct linux_sysinfo_args *args) { struct l_sysinfo sysinfo; - vm_object_t object; int i, j; struct timespec ts; @@ -170,13 +168,6 @@ linux_sysinfo(struct thread *td, struct linux_sysinfo_ sysinfo.freeram = sysinfo.totalram - vm_wire_count() * PAGE_SIZE; sysinfo.sharedram = 0; - mtx_lock(_object_list_mtx); - TAILQ_FOREACH(object, _object_list, object_list) - if (object->shadow_count > 1) - sysinfo.sharedram += object->resident_page_count; - mtx_unlock(_object_list_mtx); - - sysinfo.sharedram *= PAGE_SIZE; sysinfo.bufferram = 0; swap_pager_status(, ); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r361944 - in head/sys/dev/virtio: . network
Author: jrtc27 Date: Mon Jun 8 21:51:36 2020 New Revision: 361944 URL: https://svnweb.freebsd.org/changeset/base/361944 Log: virtio: Support non-legacy network device and queue The non-legacy interface always defines num_buffers in the header, regardless of whether VIRTIO_NET_F_MRG_RXBUF, just leaving it unused. We also need to ensure our virtqueue doesn't filter out VIRTIO_F_VERSION_1 during negotiation, as it supports non-legacy transports just fine. This fixes network packet transmission on TinyEMU. Reviewed by: br, brooks (mentor), jhb (mentor) Approved by: br, brooks (mentor), jhb (mentor) Differential Revision:https://reviews.freebsd.org/D25132 Modified: head/sys/dev/virtio/network/if_vtnet.c head/sys/dev/virtio/network/if_vtnetvar.h head/sys/dev/virtio/virtio.c head/sys/dev/virtio/virtqueue.c Modified: head/sys/dev/virtio/network/if_vtnet.c == --- head/sys/dev/virtio/network/if_vtnet.c Mon Jun 8 21:49:42 2020 (r361943) +++ head/sys/dev/virtio/network/if_vtnet.c Mon Jun 8 21:51:36 2020 (r361944) @@ -640,10 +640,13 @@ vtnet_setup_features(struct vtnet_softc *sc) sc->vtnet_flags |= VTNET_FLAG_MAC; } - if (virtio_with_feature(dev, VIRTIO_NET_F_MRG_RXBUF)) { + if (virtio_with_feature(dev, VIRTIO_NET_F_MRG_RXBUF)) sc->vtnet_flags |= VTNET_FLAG_MRG_RXBUFS; + + if (virtio_with_feature(dev, VIRTIO_NET_F_MRG_RXBUF) || + virtio_with_feature(dev, VIRTIO_F_VERSION_1)) sc->vtnet_hdr_size = sizeof(struct virtio_net_hdr_mrg_rxbuf); - } else + else sc->vtnet_hdr_size = sizeof(struct virtio_net_hdr); if (sc->vtnet_flags & VTNET_FLAG_MRG_RXBUFS) @@ -1459,9 +1462,10 @@ vtnet_rxq_enqueue_buf(struct vtnet_rxq *rxq, struct mb sglist_reset(sg); if ((sc->vtnet_flags & VTNET_FLAG_MRG_RXBUFS) == 0) { - MPASS(sc->vtnet_hdr_size == sizeof(struct virtio_net_hdr)); + MPASS(sc->vtnet_hdr_size == sizeof(rxhdr->vrh_uhdr.hdr) || + sc->vtnet_hdr_size == sizeof(rxhdr->vrh_uhdr.mhdr)); rxhdr = (struct vtnet_rx_header *) mdata; - sglist_append(sg, >vrh_hdr, sc->vtnet_hdr_size); + sglist_append(sg, >vrh_uhdr, sc->vtnet_hdr_size); offset = sizeof(struct vtnet_rx_header); } else offset = 0; Modified: head/sys/dev/virtio/network/if_vtnetvar.h == --- head/sys/dev/virtio/network/if_vtnetvar.h Mon Jun 8 21:49:42 2020 (r361943) +++ head/sys/dev/virtio/network/if_vtnetvar.h Mon Jun 8 21:51:36 2020 (r361944) @@ -219,15 +219,20 @@ struct vtnet_softc { * When mergeable buffers are not negotiated, the vtnet_rx_header structure * below is placed at the beginning of the mbuf data. Use 4 bytes of pad to * both keep the VirtIO header and the data non-contiguous and to keep the - * frame's payload 4 byte aligned. + * frame's payload 4 byte aligned. Note that non-legacy drivers still want + * room for a full mergeable buffer header. * * When mergeable buffers are negotiated, the host puts the VirtIO header in * the beginning of the first mbuf's data. */ #define VTNET_RX_HEADER_PAD4 struct vtnet_rx_header { - struct virtio_net_hdr vrh_hdr; - charvrh_pad[VTNET_RX_HEADER_PAD]; + union { + struct virtio_net_hdr hdr; + struct virtio_net_hdr_mrg_rxbuf mhdr; + } vrh_uhdr; + + charvrh_pad[VTNET_RX_HEADER_PAD]; } __packed; /* @@ -296,7 +301,8 @@ CTASSERT(sizeof(struct vtnet_mac_filter) <= PAGE_SIZE) VIRTIO_NET_F_MRG_RXBUF| \ VIRTIO_NET_F_MQ | \ VIRTIO_RING_F_EVENT_IDX | \ - VIRTIO_RING_F_INDIRECT_DESC) + VIRTIO_RING_F_INDIRECT_DESC | \ + VIRTIO_F_VERSION_1) /* * The VIRTIO_NET_F_HOST_TSO[46] features permit us to send the host Modified: head/sys/dev/virtio/virtio.c == --- head/sys/dev/virtio/virtio.cMon Jun 8 21:49:42 2020 (r361943) +++ head/sys/dev/virtio/virtio.cMon Jun 8 21:51:36 2020 (r361944) @@ -79,6 +79,7 @@ static struct virtio_feature_desc virtio_common_featur { VIRTIO_RING_F_INDIRECT_DESC, "RingIndirect" }, { VIRTIO_RING_F_EVENT_IDX, "EventIdx" }, { VIRTIO_F_BAD_FEATURE, "BadFeature"}, + { VIRTIO_F_VERSION_1, "Version1" }, { 0, NULL } }; Modified: head/sys/dev/virtio/virtqueue.c == --- head/sys/dev/virtio/virtqueue.c Mon Jun 8 21:49:42 2020 (r361943) +++
svn commit: r361943 - head/sys/dev/virtio/mmio
Author: jrtc27 Date: Mon Jun 8 21:49:42 2020 New Revision: 361943 URL: https://svnweb.freebsd.org/changeset/base/361943 Log: virtio_mmio: Negotiate the upper half of the feature bits too The feature bits are exposed as a 32-bit register with 2 banks, so we should negotiate both halves. Notably, VIRTIO_F_VERSION_1 is in the upper half, and will be used in an upcoming commit. The PCI bus driver also has this bug, but the legacy BAR layout did not include selector registers and is rather different from the modern layout, so it remains solely as legacy. Reviewed by: br, brooks (mentor), jhb (mentor) Approved by: br, brooks (mentor), jhb (mentor) Differential Revision:https://reviews.freebsd.org/D25131 Modified: head/sys/dev/virtio/mmio/virtio_mmio.c Modified: head/sys/dev/virtio/mmio/virtio_mmio.c == --- head/sys/dev/virtio/mmio/virtio_mmio.c Mon Jun 8 21:38:52 2020 (r361942) +++ head/sys/dev/virtio/mmio/virtio_mmio.c Mon Jun 8 21:49:42 2020 (r361943) @@ -390,7 +390,13 @@ vtmmio_negotiate_features(device_t dev, uint64_t child sc = device_get_softc(dev); + vtmmio_write_config_4(sc, VIRTIO_MMIO_HOST_FEATURES_SEL, 1); host_features = vtmmio_read_config_4(sc, VIRTIO_MMIO_HOST_FEATURES); + host_features <<= 32; + + vtmmio_write_config_4(sc, VIRTIO_MMIO_HOST_FEATURES_SEL, 0); + host_features |= vtmmio_read_config_4(sc, VIRTIO_MMIO_HOST_FEATURES); + vtmmio_describe_features(sc, "host", host_features); /* @@ -402,6 +408,11 @@ vtmmio_negotiate_features(device_t dev, uint64_t child sc->vtmmio_features = features; vtmmio_describe_features(sc, "negotiated", features); + + vtmmio_write_config_4(sc, VIRTIO_MMIO_HOST_FEATURES_SEL, 1); + vtmmio_write_config_4(sc, VIRTIO_MMIO_GUEST_FEATURES, features >> 32); + + vtmmio_write_config_4(sc, VIRTIO_MMIO_HOST_FEATURES_SEL, 0); vtmmio_write_config_4(sc, VIRTIO_MMIO_GUEST_FEATURES, features); return (features); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r361940 - head/usr.bin/mkimg
Author: 0mp (doc,ports committer) Date: Mon Jun 8 21:11:34 2020 New Revision: 361940 URL: https://svnweb.freebsd.org/changeset/base/361940 Log: Use Fl instead of Ar for long flags Also, bump date after r361935. MFC after:1 week Modified: head/usr.bin/mkimg/mkimg.1 Modified: head/usr.bin/mkimg/mkimg.1 == --- head/usr.bin/mkimg/mkimg.1 Mon Jun 8 20:53:57 2020(r361939) +++ head/usr.bin/mkimg/mkimg.1 Mon Jun 8 21:11:34 2020(r361940) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 26, 2017 +.Dd June 8, 2020 .Dt MKIMG 1 .Os .Sh NAME @@ -47,7 +47,7 @@ .Op Fl y .Op Fl s Ar scheme Op Fl p Ar partition ... .Nm -.Ar --formats | --schemes | --version +.Fl -formats | Fl -schemes | Fl -version .Sh DESCRIPTION The .Nm @@ -183,13 +183,13 @@ utility exits immediately after providing the requeste The version of the .Nm utility is printed when the -.Ar --version +.Fl -version option is given. The list of supported output formats is printed when the -.Ar --formats +.Fl -formats option is given and the list of supported partitioning schemes is printed when the -.Ar --schemes +.Fl -schemes option is given. Both the format and scheme lists a space-separated lists for easy handling in scripts. ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r361939 - in head/sys: cam/ctl dev/iscsi
Author: mav Date: Mon Jun 8 20:53:57 2020 New Revision: 361939 URL: https://svnweb.freebsd.org/changeset/base/361939 Log: Implement zero-copy iSCSI target transmission/read. Add ICL_NOCOPY flag to icl_pdu_append_data(), specifying that the method can just reference the data buffer instead of immediately copying it. Extend the offload KPI with optional PDU queue method, allowing to specify completion callback, called when all the data referenced by above has been transferred and won't be accessed any more (the buffers can be freed). Implement the above functionality in software iSCSI driver using mbufs with external storage and reference counter. Note that some NICs (ixl(4)) may keep the mbuf in TX queue for a long time, so CTL has to be ready. Add optional method to struct ctl_scsiio for buffer reference counting. Implement it for CTL block backend, allowing to delay free of the struct ctl_be_block_io and memory it references as needed. In first reincarnation of the patch I tried to delay whole I/O as it is done for FibreChannel, that was cleaner, but due to the above callback delays I had to rewrite it this way to not leave LUN referenced potentially for hours or more. All together on sequential read from ZFS ARC this saves about 30% of CPU time and memory bandwidth by avoiding one of 3 memory copies (the other two are from ZFS ARC to DMU cache and then from DMU cache to CTL buffers). On tests with 2x Xeon Silver 4114 this allows to reach full line rate of 100GigE NIC. Tests with Gold CPUs and two 100GigE NICs are stil TBD, but expectations to saturate them are pretty high. ;) Discussed with: Chelsio Sponsored by: iXsystems, Inc. Modified: head/sys/cam/ctl/ctl_backend_block.c head/sys/cam/ctl/ctl_frontend_iscsi.c head/sys/cam/ctl/ctl_io.h head/sys/dev/iscsi/icl.h head/sys/dev/iscsi/icl_conn_if.m head/sys/dev/iscsi/icl_soft.c head/sys/dev/iscsi/icl_wrappers.h Modified: head/sys/cam/ctl/ctl_backend_block.c == --- head/sys/cam/ctl/ctl_backend_block.cMon Jun 8 20:40:09 2020 (r361938) +++ head/sys/cam/ctl/ctl_backend_block.cMon Jun 8 20:53:57 2020 (r361939) @@ -201,6 +201,7 @@ struct ctl_be_block_io { union ctl_io*io; struct ctl_sg_entry sg_segs[CTLBLK_MAX_SEGS]; struct iovecxiovecs[CTLBLK_MAX_SEGS]; + int refcnt; int bio_cmd; int two_sglists; int num_segs; @@ -305,11 +306,12 @@ ctl_alloc_beio(struct ctl_be_block_softc *softc) beio = uma_zalloc(softc->beio_zone, M_WAITOK | M_ZERO); beio->softc = softc; + beio->refcnt = 1; return (beio); } static void -ctl_free_beio(struct ctl_be_block_io *beio) +ctl_real_free_beio(struct ctl_be_block_io *beio) { struct ctl_be_block_softc *softc = beio->softc; int i; @@ -328,6 +330,22 @@ ctl_free_beio(struct ctl_be_block_io *beio) } static void +ctl_refcnt_beio(void *arg, int diff) +{ + struct ctl_be_block_io *beio = arg; + + if (atomic_fetchadd_int(>refcnt, diff) + diff == 0) + ctl_real_free_beio(beio); +} + +static void +ctl_free_beio(struct ctl_be_block_io *beio) +{ + + ctl_refcnt_beio(beio, -1); +} + +static void ctl_complete_beio(struct ctl_be_block_io *beio) { union ctl_io *io = beio->io; @@ -1613,6 +1631,8 @@ ctl_be_block_dispatch(struct ctl_be_block_lun *be_lun, io->scsiio.kern_data_ptr = (uint8_t *)beio->sg_segs; io->scsiio.kern_data_len = beio->io_len; io->scsiio.kern_sg_entries = beio->num_segs; + io->scsiio.kern_data_ref = ctl_refcnt_beio; + io->scsiio.kern_data_arg = beio; io->io_hdr.flags |= CTL_FLAG_ALLOCATED; /* Modified: head/sys/cam/ctl/ctl_frontend_iscsi.c == --- head/sys/cam/ctl/ctl_frontend_iscsi.c Mon Jun 8 20:40:09 2020 (r361938) +++ head/sys/cam/ctl/ctl_frontend_iscsi.c Mon Jun 8 20:53:57 2020 (r361939) @@ -424,6 +424,17 @@ cfiscsi_pdu_queue(struct icl_pdu *response) CFISCSI_SESSION_UNLOCK(cs); } + static void +cfiscsi_pdu_queue_cb(struct icl_pdu *response, icl_pdu_cb cb) +{ + struct cfiscsi_session *cs = PDU_SESSION(response); + + CFISCSI_SESSION_LOCK(cs); + cfiscsi_pdu_prepare(response); + icl_pdu_queue_cb(response, cb); + CFISCSI_SESSION_UNLOCK(cs); +} + static void cfiscsi_pdu_handle_nop_out(struct icl_pdu *request) { @@ -2417,6 +2428,15 @@ cfiscsi_target_find_or_create(struct cfiscsi_softc *so } static void +cfiscsi_pdu_done(struct icl_pdu *ip, int error) +{ + + if (error != 0) + ; // XXX: Do something on
svn commit: r361935 - in head/usr.bin/mkimg: . tests
Author: gonzo Date: Mon Jun 8 20:28:32 2020 New Revision: 361935 URL: https://svnweb.freebsd.org/changeset/base/361935 Log: Add VHDX support to mkimg(1) VHDX is the successor of Microsoft's VHD file format. It increases maximum capacity of the virtual drive to 64TB and introduces features to better handle power/system failures. VHDX is the required format for 2nd generation Hyper-V VMs. Reviewed by: marcel MFC after:2 weeks Differential Revision:https://reviews.freebsd.org/D25184 Added: head/usr.bin/mkimg/tests/img-1x1-4096-apm.vhdx.hex (contents, props changed) head/usr.bin/mkimg/tests/img-1x1-4096-bsd.vhdx.hex (contents, props changed) head/usr.bin/mkimg/tests/img-1x1-4096-ebr.vhdx.hex (contents, props changed) head/usr.bin/mkimg/tests/img-1x1-4096-gpt.vhdx.hex (contents, props changed) head/usr.bin/mkimg/tests/img-1x1-4096-mbr.vhdx.hex (contents, props changed) head/usr.bin/mkimg/tests/img-1x1-4096-vtoc8.vhdx.hex (contents, props changed) head/usr.bin/mkimg/tests/img-1x1-512-apm.vhdx.hex (contents, props changed) head/usr.bin/mkimg/tests/img-1x1-512-bsd.vhdx.hex (contents, props changed) head/usr.bin/mkimg/tests/img-1x1-512-ebr.vhdx.hex (contents, props changed) head/usr.bin/mkimg/tests/img-1x1-512-gpt.vhdx.hex (contents, props changed) head/usr.bin/mkimg/tests/img-1x1-512-mbr.vhdx.hex (contents, props changed) head/usr.bin/mkimg/tests/img-1x1-512-vtoc8.vhdx.hex (contents, props changed) head/usr.bin/mkimg/tests/img-63x255-4096-apm.vhdx.hex (contents, props changed) head/usr.bin/mkimg/tests/img-63x255-4096-bsd.vhdx.hex (contents, props changed) head/usr.bin/mkimg/tests/img-63x255-4096-ebr.vhdx.hex (contents, props changed) head/usr.bin/mkimg/tests/img-63x255-4096-gpt.vhdx.hex (contents, props changed) head/usr.bin/mkimg/tests/img-63x255-4096-mbr.vhdx.hex (contents, props changed) head/usr.bin/mkimg/tests/img-63x255-4096-vtoc8.vhdx.hex (contents, props changed) head/usr.bin/mkimg/tests/img-63x255-512-apm.vhdx.hex (contents, props changed) head/usr.bin/mkimg/tests/img-63x255-512-bsd.vhdx.hex (contents, props changed) head/usr.bin/mkimg/tests/img-63x255-512-ebr.vhdx.hex (contents, props changed) head/usr.bin/mkimg/tests/img-63x255-512-gpt.vhdx.hex (contents, props changed) head/usr.bin/mkimg/tests/img-63x255-512-mbr.vhdx.hex (contents, props changed) head/usr.bin/mkimg/tests/img-63x255-512-vtoc8.vhdx.hex (contents, props changed) head/usr.bin/mkimg/vhdx.c (contents, props changed) Modified: head/usr.bin/mkimg/Makefile head/usr.bin/mkimg/mkimg.1 head/usr.bin/mkimg/tests/mkimg_test.sh Modified: head/usr.bin/mkimg/Makefile == --- head/usr.bin/mkimg/Makefile Mon Jun 8 20:23:20 2020(r361934) +++ head/usr.bin/mkimg/Makefile Mon Jun 8 20:28:32 2020(r361935) @@ -18,6 +18,7 @@ SRCS+= \ qcow.c \ raw.c \ vhd.c \ + vhdx.c \ vmdk.c # List of schemes to support Modified: head/usr.bin/mkimg/mkimg.1 == --- head/usr.bin/mkimg/mkimg.1 Mon Jun 8 20:23:20 2020(r361934) +++ head/usr.bin/mkimg/mkimg.1 Mon Jun 8 20:28:32 2020(r361935) @@ -257,6 +257,16 @@ To create a fixed VHD file for use by Azure, specify .Fl f Ar vhdf on the command line. The preferred file extension is ".vhd". +.Ss Dynamic VHDX +Microsoft's "Virtual Hard Disk v2" file formats, the +successor to VHD. +VHDX is the required format for the 2nd generation Hyper-V VMs. +To have +.Nm +create a dynamic VHDX file, specify +.Fl f Ar vhdx +on the command line. +The preferred file extension is ".vhdx". .Ss VMDK VMware's "Virtual Machine Disk" file format. It's a sparse file format akin to QCOW and VHD and supported by many Added: head/usr.bin/mkimg/tests/img-1x1-4096-apm.vhdx.hex == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.bin/mkimg/tests/img-1x1-4096-apm.vhdx.hex Mon Jun 8 20:28:32 2020(r361935) @@ -0,0 +1,79 @@ +# $FreeBSD$ + 76 68 64 78 66 69 6c 65 00 00 00 00 00 00 00 00 |vhdxfile| +0010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 || +* +0001 68 65 61 64 64 db 05 73 00 00 00 00 00 00 00 00 |headd..s| +00010010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 || +* +00010040 00 00 01 00 00 00 10 00 00 00 10 00 00 00 00 00 || +00010050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 || +* +0002 68 65 61 64 13 47 fd f1 01 00 00 00 00 00 00 00 |head.G..| +00020010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 || +* +00020040 00 00 01 00 00 00 10 00 00 00 10 00 00 00 00 00 ||
svn commit: r361934 - head/sys/netinet
Author: tuexen Date: Mon Jun 8 20:23:20 2020 New Revision: 361934 URL: https://svnweb.freebsd.org/changeset/base/361934 Log: Whitespace cleanups and removal of a stale comment. MFC after:1 week Modified: head/sys/netinet/sctp_pcb.c head/sys/netinet/sctp_sysctl.c head/sys/netinet/sctputil.c Modified: head/sys/netinet/sctp_pcb.c == --- head/sys/netinet/sctp_pcb.c Mon Jun 8 18:13:38 2020(r361933) +++ head/sys/netinet/sctp_pcb.c Mon Jun 8 20:23:20 2020(r361934) @@ -5686,7 +5686,6 @@ sctp_startup_mcore_threads(void) i++; } } - /* Now start them all */ CPU_FOREACH(cpu) { (void)kproc_create(sctp_mcore_thread, @@ -5695,7 +5694,6 @@ sctp_startup_mcore_threads(void) RFPROC, SCTP_KTHREAD_PAGES, SCTP_MCORE_NAME); - } } #endif Modified: head/sys/netinet/sctp_sysctl.c == --- head/sys/netinet/sctp_sysctl.c Mon Jun 8 18:13:38 2020 (r361933) +++ head/sys/netinet/sctp_sysctl.c Mon Jun 8 20:23:20 2020 (r361934) @@ -451,7 +451,6 @@ sctp_sysctl_handle_assoclist(SYSCTL_HANDLER_ARGS) xstcb.primary_addr = stcb->asoc.primary_destination->ro._l_addr; xstcb.heartbeat_interval = stcb->asoc.heart_beat_delay; xstcb.state = (uint32_t)sctp_map_assoc_state(stcb->asoc.state); - /* 7.0 does not support these */ xstcb.assoc_id = sctp_get_associd(stcb); xstcb.peers_rwnd = stcb->asoc.peers_rwnd; xstcb.in_streams = stcb->asoc.streamincnt; Modified: head/sys/netinet/sctputil.c == --- head/sys/netinet/sctputil.c Mon Jun 8 18:13:38 2020(r361933) +++ head/sys/netinet/sctputil.c Mon Jun 8 20:23:20 2020(r361934) @@ -5565,7 +5565,6 @@ sctp_sorecvmsg(struct socket *so, sockbuf_lock = 1; restart: - restart_nosblocks: if (hold_sblock == 0) { SOCKBUF_LOCK(>so_rcv); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r361933 - head/stand/common
Author: sjg Date: Mon Jun 8 18:13:38 2020 New Revision: 361933 URL: https://svnweb.freebsd.org/changeset/base/361933 Log: loader: install allow for more complete device spec in url Rework to simplify and impose sane url syntax. That is we allow for file://[devname[:fstype]]/package Reviewed by: stevek MFC after:1 week Sponsored by: Juniper Networks Differential Revision: https://reviews.freebsd.org//D25134 Modified: head/stand/common/install.c Modified: head/stand/common/install.c == --- head/stand/common/install.c Mon Jun 8 17:57:21 2020(r361932) +++ head/stand/common/install.c Mon Jun 8 18:13:38 2020(r361933) @@ -184,7 +184,8 @@ cleanup(void) /* * usage: install URL - * where: URL = (tftp|file)://[host]/ + * where: URL = tftp://[host]/ + * or file://[devname[:fstype]]/ */ static int install(char *pkgname) @@ -192,8 +193,9 @@ install(char *pkgname) static char buf[256]; struct fs_ops *proto; struct preloaded_file *fp; - char *s, *currdev; - const char *devname; + char *e, *s, *currdev; + char *devname; + size_t devnamelen; int error, fd, i, local; s = strstr(pkgname, "://"); @@ -201,34 +203,74 @@ install(char *pkgname) goto invalid_url; i = s - pkgname; + s += 3; + if (*s == '\0') + goto invalid_url; + + proto = NULL; + devname = NULL; + devnamelen = 0; + if (i == 4 && !strncasecmp(pkgname, "tftp", i)) { devname = "net0"; + devnamelen = 4; proto = _fsops; local = 0; } else if (i == 4 && !strncasecmp(pkgname, "file", i)) { currdev = getenv("currdev"); - if (currdev != NULL && strcmp(currdev, "pxe0:") == 0) { - devname = "pxe0"; - proto = NULL; + local = 1; + + if (*s == '/') {/* file:/// */ + if (devname == NULL) + devname = currdev; + if (devname == NULL) + devname = "disk1"; + } else {/* file://devname[:fstype]/ */ + devname = s; + e = strchr(devname, '/'); + if (!e) + goto invalid_url; + devnamelen = e - devname; + s = e; /* consume devname */ + } + if ((e = strchr(devname, ':')) != NULL) { + /* could be :fstype */ + devnamelen = e - devname; + switch (e[1]) { + case '\0': /* just currdev */ + break; + case 'd': + proto = _fsops; + break; #ifdef HOSTPROG - } else if (currdev != NULL && strcmp(currdev, "host0:") == 0) { - extern struct fs_ops host_fsops; + case 'h': + { + extern struct fs_ops host_fsops; - devname = "host0"; - proto = _fsops; + proto = _fsops; + } + break; #endif - } else { - devname = "disk1"; + case 'u': + proto = _fsops; + break; + } + } + if (proto == NULL && strncmp(devname, "disk", 4) == 0) { proto = _fsops; } - local = 1; - } else - goto invalid_url; + } - s += 3; - if (*s == '\0') + if (devname == NULL) goto invalid_url; + if (devnamelen == 0) { + /* default is currdev which ends with ':' */ + devnamelen = strlen(devname); + if (devname[devnamelen - 1] == ':') + devnamelen--; + } + if (*s != '/' ) { if (local) goto invalid_url; @@ -252,11 +294,12 @@ install(char *pkgname) } else pkgname = s; - if (strlen(devname) + strlen(pkgname) + 2 > sizeof(buf)) { + i = snprintf(buf, sizeof(buf), "%.*s:%s", + (int) devnamelen, devname, pkgname); + if (i >= (int) sizeof(buf)) { command_errmsg = "package name too long"; return (CMD_ERROR); } - sprintf(buf, "%s:%s", devname, pkgname); setenv("install_package", buf, 1); error =
svn commit: r361932 - head/sys/riscv/riscv
Author: jrtc27 Date: Mon Jun 8 17:57:21 2020 New Revision: 361932 URL: https://svnweb.freebsd.org/changeset/base/361932 Log: riscv: Use SBI shutdown call to implement RB_POWEROFF Currently we only call sbi_shutdown in cpu_reset, which means we reach "Please press any key to reboot." even when RB_POWEROFF is set, and only once the user presses a key do we then shutdown. Instead, register a shutdown_final event handler and make an SBI shutdown call if RB_POWEROFF is set. Reviewed by: br, jhb (mentor), kp Approved by: br, jhb (mentor), kp Differential Revision:https://reviews.freebsd.org/D25183 Modified: head/sys/riscv/riscv/sbi.c Modified: head/sys/riscv/riscv/sbi.c == --- head/sys/riscv/riscv/sbi.c Mon Jun 8 17:40:39 2020(r361931) +++ head/sys/riscv/riscv/sbi.c Mon Jun 8 17:57:21 2020(r361932) @@ -29,8 +29,11 @@ __FBSDID("$FreeBSD$"); #include +#include #include #include +#include +#include #include #include @@ -80,6 +83,13 @@ sbi_get_mimpid(void) return (SBI_CALL0(SBI_EXT_ID_BASE, SBI_BASE_GET_MIMPID)); } +static void +sbi_shutdown_final(void *dummy __unused, int howto) +{ + if ((howto & RB_POWEROFF) != 0) + sbi_shutdown(); +} + void sbi_print_version(void) { @@ -187,3 +197,12 @@ sbi_init(void) KASSERT(sbi_probe_extension(SBI_SHUTDOWN) != 0, ("SBI doesn't implement sbi_shutdown()")); } + +static void +sbi_late_init(void *dummy __unused) +{ + EVENTHANDLER_REGISTER(shutdown_final, sbi_shutdown_final, NULL, + SHUTDOWN_PRI_LAST); +} + +SYSINIT(sbi, SI_SUB_KLD, SI_ORDER_ANY, sbi_late_init, NULL); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r361587 - in head/sys/riscv: include riscv
On Thu, May 28, 2020 at 11:56 AM Mitchell Horne wrote: > > Author: mhorne > Date: Thu May 28 14:56:11 2020 > New Revision: 361587 > URL: https://svnweb.freebsd.org/changeset/base/361587 > > Log: > Add macros simplifying the fake preload setup > > This is in preparation for booting via loader(8). Lift these macros from > arm64 > so we don't need to worry about the size when inserting new elements. This > could have been done in r359673, but I didn't think I would be returning to > this function so soon. > > Reviewed by: markj > Differential Revision:https://reviews.freebsd.org/D24910 > > Modified: > head/sys/riscv/include/vmparam.h > head/sys/riscv/riscv/machdep.c > > Modified: head/sys/riscv/include/vmparam.h > == > --- head/sys/riscv/include/vmparam.hThu May 28 13:48:33 2020 > (r361586) > +++ head/sys/riscv/include/vmparam.hThu May 28 14:56:11 2020 > (r361587) > @@ -190,8 +190,6 @@ > #defineSHAREDPAGE (VM_MAXUSER_ADDRESS - PAGE_SIZE) > #defineUSRSTACKSHAREDPAGE > > -#defineKERNENTRY (0) > - > #defineVM_EARLY_DTB_ADDRESS(VM_MAX_KERNEL_ADDRESS - (2 * > L2_SIZE)) > > /* > > Modified: head/sys/riscv/riscv/machdep.c > == > --- head/sys/riscv/riscv/machdep.c Thu May 28 13:48:33 2020 > (r361586) > +++ head/sys/riscv/riscv/machdep.c Thu May 28 14:56:11 2020 > (r361587) > @@ -733,29 +733,36 @@ fake_preload_metadata(struct riscv_bootparams *rvbp) > vm_offset_t zstart = 0, zend = 0; > #endif > vm_offset_t lastaddr; > - size_t dtb_size; > - int i; > + size_t fake_size, dtb_size; > > - i = 0; > +#define PRELOAD_PUSH_VALUE(type, value) do { \ > + *(type *)((char *)fake_preload + fake_size) = (value); \ > + fake_size += sizeof(type); \ > +} while (0) > > - fake_preload[i++] = MODINFO_NAME; > - fake_preload[i++] = strlen("kernel") + 1; > - strcpy((char*)_preload[i++], "kernel"); > - i += 1; > - fake_preload[i++] = MODINFO_TYPE; > - fake_preload[i++] = strlen("elf64 kernel") + 1; > - strcpy((char*)_preload[i++], "elf64 kernel"); > - i += 3; > - fake_preload[i++] = MODINFO_ADDR; > - fake_preload[i++] = sizeof(vm_offset_t); > - *(vm_offset_t *)_preload[i++] = > - (vm_offset_t)(KERNBASE + KERNENTRY); > - i += 1; > - fake_preload[i++] = MODINFO_SIZE; > - fake_preload[i++] = sizeof(vm_offset_t); > - fake_preload[i++] = (vm_offset_t) - > - (vm_offset_t)(KERNBASE + KERNENTRY); > - i += 1; > +#define PRELOAD_PUSH_STRING(str) do { \ > + uint32_t ssize; \ > + ssize = strlen(str) + 1;\ > + PRELOAD_PUSH_VALUE(uint32_t, ssize);\ > + strcpy(((char *)fake_preload + fake_size), str);\ > + fake_size += ssize; \ > + fake_size = roundup(fake_size, sizeof(u_long)); \ > +} while (0) > + > + fake_size = 0; > + > + PRELOAD_PUSH_VALUE(uint32_t, MODINFO_NAME); > + PRELOAD_PUSH_STRING("kernel"); > + PRELOAD_PUSH_VALUE(uint32_t, MODINFO_TYPE); > + PRELOAD_PUSH_STRING("elf kernel"); Note that the type here was unintentionally changed from "elf64 kernel" to "elf kernel". Fortunately, this ends up being more consistent with both loader(8) and the other fake_preload_metadata routines, which set the type as "elf kernel". Thanks to rpokala@ for pointing this out. > + > + PRELOAD_PUSH_VALUE(uint32_t, MODINFO_ADDR); > + PRELOAD_PUSH_VALUE(uint32_t, sizeof(vm_offset_t)); > + PRELOAD_PUSH_VALUE(uint64_t, KERNBASE); > + > + PRELOAD_PUSH_VALUE(uint32_t, MODINFO_SIZE); > + PRELOAD_PUSH_VALUE(uint32_t, sizeof(size_t)); > + PRELOAD_PUSH_VALUE(uint64_t, (size_t)((vm_offset_t) - KERNBASE)); > #ifdef DDB > #if 0 > /* RISCVTODO */ > @@ -777,19 +784,20 @@ fake_preload_metadata(struct riscv_bootparams *rvbp) > > /* Copy the DTB to KVA space. */ > lastaddr = roundup(lastaddr, sizeof(int)); > - fake_preload[i++] = MODINFO_METADATA | MODINFOMD_DTBP; > - fake_preload[i++] = sizeof(vm_offset_t); > - *(vm_offset_t *)_preload[i] = (vm_offset_t)lastaddr; > - i += sizeof(vm_offset_t) / sizeof(uint32_t); > + PRELOAD_PUSH_VALUE(uint32_t, MODINFO_METADATA | MODINFOMD_DTBP); > + PRELOAD_PUSH_VALUE(uint32_t, sizeof(vm_offset_t)); > + PRELOAD_PUSH_VALUE(vm_offset_t, lastaddr); > dtb_size = fdt_totalsize(rvbp->dtbp_virt); > memmove((void *)lastaddr, (const void *)rvbp->dtbp_virt, dtb_size); > lastaddr =
svn commit: r361931 - head/sys/sys
Author: glebius Date: Mon Jun 8 17:40:39 2020 New Revision: 361931 URL: https://svnweb.freebsd.org/changeset/base/361931 Log: Move MPASS() macros to systm.h. They are widely used all over the kernel and aren't contained only to the locking code. Reviewed by: kib, mjg Differential Revision:https://reviews.freebsd.org/D23656 Modified: head/sys/sys/lock.h head/sys/sys/systm.h Modified: head/sys/sys/lock.h == --- head/sys/sys/lock.h Mon Jun 8 16:11:44 2020(r361930) +++ head/sys/sys/lock.h Mon Jun 8 17:40:39 2020(r361931) @@ -162,16 +162,6 @@ struct lock_class { #definelock_initialized(lo)((lo)->lo_flags & LO_INITIALIZED) -/* - * Helpful macros for quickly coming up with assertions with informative - * panic messages. - */ -#define MPASS(ex) MPASS4(ex, #ex, __FILE__, __LINE__) -#define MPASS2(ex, what) MPASS4(ex, what, __FILE__, __LINE__) -#define MPASS3(ex, file, line) MPASS4(ex, #ex, file, line) -#define MPASS4(ex, what, file, line) \ - KASSERT((ex), ("Assertion %s failed at %s:%d", what, file, line)) - extern struct lock_class lock_class_mtx_sleep; extern struct lock_class lock_class_mtx_spin; extern struct lock_class lock_class_sx; Modified: head/sys/sys/systm.h == --- head/sys/sys/systm.hMon Jun 8 16:11:44 2020(r361930) +++ head/sys/sys/systm.hMon Jun 8 17:40:39 2020(r361931) @@ -142,6 +142,16 @@ void kassert_panic(const char *fmt, ...) __printflike #endif /* + * Helpful macros for quickly coming up with assertions with informative + * panic messages. + */ +#define MPASS(ex) MPASS4(ex, #ex, __FILE__, __LINE__) +#define MPASS2(ex, what) MPASS4(ex, what, __FILE__, __LINE__) +#define MPASS3(ex, file, line) MPASS4(ex, #ex, file, line) +#define MPASS4(ex, what, file, line) \ + KASSERT((ex), ("Assertion %s failed at %s:%d", what, file, line)) + +/* * Assert that a pointer can be loaded from memory atomically. * * This assertion enforces stronger alignment than necessary. For example, ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r361930 - head/usr.sbin/crashinfo
Author: emaste Date: Mon Jun 8 16:11:44 2020 New Revision: 361930 URL: https://svnweb.freebsd.org/changeset/base/361930 Log: crashinfo: stop looking for gdb in /usr/bin/gdb As of r359457 we removed the GDB_LIBEXEC option, always installing in-tree gdb into /usr/libexec/. Thus, there is now no need for crashinfo to include /usr/bin/gdb in the list of pathnames to check when looking for gdb. Modified: head/usr.sbin/crashinfo/crashinfo.sh Modified: head/usr.sbin/crashinfo/crashinfo.sh == --- head/usr.sbin/crashinfo/crashinfo.shMon Jun 8 15:27:44 2020 (r361929) +++ head/usr.sbin/crashinfo/crashinfo.shMon Jun 8 16:11:44 2020 (r361930) @@ -50,7 +50,7 @@ find_gdb() { local binary - for binary in /usr/local/bin/gdb /usr/libexec/gdb /usr/bin/gdb; do + for binary in /usr/local/bin/gdb /usr/libexec/gdb; do if [ -x ${binary} ]; then GDB=${binary} return ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r361926 - in head/sys/netinet: . tcp_stacks
Author: rrs Date: Mon Jun 8 11:48:07 2020 New Revision: 361926 URL: https://svnweb.freebsd.org/changeset/base/361926 Log: An important statistic in determining if a server process (or client) is being delayed is to know the time to first byte in and time to first byte out. Currently we have no way to know these all we have is t_starttime. That (t_starttime) tells us what time the 3 way handshake completed. We don't know when the first request came in or how quickly we responded. Nor from a client perspective do we know how long from when we sent out the first byte before the server responded. This small change adds the ability to track the TTFB's. This will show up in BB logging which then can be pulled for later analysis. Note that currently the tracking is via the ticks variable of all three variables. This provides a very rough estimate (hz=1000 its 1ms). A follow-on set of work will be to change all three of these values into something with a much finer resolution (either microseconds or nanoseconds), though we may want to make the resolution configurable so that on lower powered machines we could still use the much cheaper ticks variable. Sponsored by: Netflix Inc. Differential Revision:https://reviews.freebsd.org/D24902 Modified: head/sys/netinet/tcp_input.c head/sys/netinet/tcp_log_buf.c head/sys/netinet/tcp_log_buf.h head/sys/netinet/tcp_stacks/bbr.c head/sys/netinet/tcp_stacks/rack.c head/sys/netinet/tcp_usrreq.c head/sys/netinet/tcp_var.h Modified: head/sys/netinet/tcp_input.c == --- head/sys/netinet/tcp_input.cMon Jun 8 09:39:48 2020 (r361925) +++ head/sys/netinet/tcp_input.cMon Jun 8 11:48:07 2020 (r361926) @@ -1841,6 +1841,15 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, stru tcp_clean_sackreport(tp); TCPSTAT_INC(tcps_preddat); tp->rcv_nxt += tlen; + if (tlen && + ((tp->t_flags2 & TF2_FBYTES_COMPLETE) == 0) && + (tp->t_fbyte_in == 0)) { + tp->t_fbyte_in = ticks; + if (tp->t_fbyte_in == 0) + tp->t_fbyte_in = 1; + if (tp->t_fbyte_out && tp->t_fbyte_in) + tp->t_flags2 |= TF2_FBYTES_COMPLETE; + } /* * Pull snd_wl1 up to prevent seq wrap relative to * th_seq. @@ -3016,6 +3025,15 @@ dodata: /* XXX */ else tp->t_flags |= TF_ACKNOW; tp->rcv_nxt += tlen; + if (tlen && + ((tp->t_flags2 & TF2_FBYTES_COMPLETE) == 0) && + (tp->t_fbyte_in == 0)) { + tp->t_fbyte_in = ticks; + if (tp->t_fbyte_in == 0) + tp->t_fbyte_in = 1; + if (tp->t_fbyte_out && tp->t_fbyte_in) + tp->t_flags2 |= TF2_FBYTES_COMPLETE; + } thflags = th->th_flags & TH_FIN; TCPSTAT_INC(tcps_rcvpack); TCPSTAT_ADD(tcps_rcvbyte, tlen); Modified: head/sys/netinet/tcp_log_buf.c == --- head/sys/netinet/tcp_log_buf.c Mon Jun 8 09:39:48 2020 (r361925) +++ head/sys/netinet/tcp_log_buf.c Mon Jun 8 11:48:07 2020 (r361926) @@ -1693,6 +1693,9 @@ retry: COPY_STAT(snd_numholes); COPY_STAT(snd_scale); COPY_STAT(rcv_scale); + COPY_STAT_T(flags2); + COPY_STAT_T(fbyte_in); + COPY_STAT_T(fbyte_out); #undef COPY_STAT #undef COPY_STAT_T log_buf->tlb_flex1 = 0; Modified: head/sys/netinet/tcp_log_buf.h == --- head/sys/netinet/tcp_log_buf.h Mon Jun 8 09:39:48 2020 (r361925) +++ head/sys/netinet/tcp_log_buf.h Mon Jun 8 11:48:07 2020 (r361926) @@ -32,7 +32,7 @@ #defineTCP_LOG_REASON_LEN 32 #defineTCP_LOG_TAG_LEN 32 -#defineTCP_LOG_BUF_VER (8) +#defineTCP_LOG_BUF_VER (9) /* * Because the (struct tcp_log_buffer) includes 8-byte uint64_t's, it requires @@ -143,6 +143,7 @@ struct tcp_log_buffer uint32_ttlb_rttvar; /* TCPCB t_rttvar */ uint32_ttlb_rcv_up; /* TCPCB rcv_up */ uint32_ttlb_rcv_adv;/* TCPCB rcv_adv */ + uint32_t
svn commit: r361920 - head/share/man/man5
Author: 0mp (doc,ports committer) Date: Mon Jun 8 09:33:45 2020 New Revision: 361920 URL: https://svnweb.freebsd.org/changeset/base/361920 Log: Document that /lib is always in the list of shared library paths /lib was added to the list in r119011. MFC after:1 week Modified: head/share/man/man5/rc.conf.5 Modified: head/share/man/man5/rc.conf.5 == --- head/share/man/man5/rc.conf.5 Mon Jun 8 09:33:37 2020 (r361919) +++ head/share/man/man5/rc.conf.5 Mon Jun 8 09:33:45 2020 (r361920) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 9, 2020 +.Dd June 8, 2020 .Dt RC.CONF 5 .Os .Sh NAME @@ -3637,8 +3637,10 @@ related programs. Set to the list of shared library paths to use with .Xr ldconfig 8 . NOTE: +.Pa /lib +and .Pa /usr/lib -will always be added first, so it need not appear in this list. +will always be added first, so they need not appear in this list. .It Va ldconfig32_paths .Pq Vt str Set to the list of 32-bit compatibility shared library paths to ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r361905 - in head/sys/riscv: include riscv
Author: arichardson Date: Mon Jun 8 08:52:02 2020 New Revision: 361905 URL: https://svnweb.freebsd.org/changeset/base/361905 Log: RISC-V: Check that the DTB doesn't overlap with kernel This can happen with very large kernels (e.g. ones embedding a root filesystem). The DTB written by OpenSBI/BBL is quite small so this is unlikely to hit important data, but if it does this can result in very confusing and hard-to-debug crashes. Add a KASSERT() and a verbose print to catch this problem with debug kernels. While this will not print any output by default if it fails (that would depend on EARLY_PRINTF), at least the kernel now halts reliably instead of randomly crashing. Reviewed By: mhorne Differential Revision: https://reviews.freebsd.org/D25153 Modified: head/sys/riscv/include/machdep.h head/sys/riscv/riscv/genassym.c head/sys/riscv/riscv/locore.S head/sys/riscv/riscv/machdep.c Modified: head/sys/riscv/include/machdep.h == --- head/sys/riscv/include/machdep.hMon Jun 8 08:51:57 2020 (r361904) +++ head/sys/riscv/include/machdep.hMon Jun 8 08:52:02 2020 (r361905) @@ -42,6 +42,7 @@ struct riscv_bootparams { vm_offset_t kern_phys; /* Kernel base (physical) addr */ vm_offset_t kern_stack; vm_offset_t dtbp_virt; /* Device tree blob virtual addr */ + vm_offset_t dtbp_phys; /* Device tree blob physical addr */ }; extern vm_paddr_t physmap[PHYS_AVAIL_ENTRIES]; Modified: head/sys/riscv/riscv/genassym.c == --- head/sys/riscv/riscv/genassym.c Mon Jun 8 08:51:57 2020 (r361904) +++ head/sys/riscv/riscv/genassym.c Mon Jun 8 08:52:02 2020 (r361905) @@ -106,3 +106,4 @@ ASSYM(RISCV_BOOTPARAMS_KERN_PHYS, offsetof(struct risc ASSYM(RISCV_BOOTPARAMS_KERN_STACK, offsetof(struct riscv_bootparams, kern_stack)); ASSYM(RISCV_BOOTPARAMS_DTBP_VIRT, offsetof(struct riscv_bootparams, dtbp_virt)); +ASSYM(RISCV_BOOTPARAMS_DTBP_PHYS, offsetof(struct riscv_bootparams, dtbp_phys)); Modified: head/sys/riscv/riscv/locore.S == --- head/sys/riscv/riscv/locore.S Mon Jun 8 08:51:57 2020 (r361904) +++ head/sys/riscv/riscv/locore.S Mon Jun 8 08:52:02 2020 (r361905) @@ -221,6 +221,7 @@ va: and t1, a1, t1 add t0, t0, t1 sd t0, RISCV_BOOTPARAMS_DTBP_VIRT(sp) + sd a1, RISCV_BOOTPARAMS_DTBP_PHYS(sp) mv a0, sp call_C_LABEL(initriscv) /* Off we go */ Modified: head/sys/riscv/riscv/machdep.c == --- head/sys/riscv/riscv/machdep.c Mon Jun 8 08:51:57 2020 (r361904) +++ head/sys/riscv/riscv/machdep.c Mon Jun 8 08:52:02 2020 (r361905) @@ -776,8 +776,19 @@ fake_preload_metadata(struct riscv_bootparams *rvbp) PRELOAD_PUSH_VALUE(uint32_t, 0); preload_metadata = (caddr_t)fake_preload; + /* Check if bootloader clobbered part of the kernel with the DTB. */ + KASSERT(rvbp->dtbp_phys + dtb_size <= rvbp->kern_phys || + rvbp->dtbp_phys >= rvbp->kern_phys + (lastaddr - KERNBASE), + ("FDT (%lx-%lx) and kernel (%lx-%lx) overlap", rvbp->dtbp_phys, + rvbp->dtbp_phys + dtb_size, rvbp->kern_phys, + rvbp->kern_phys + (lastaddr - KERNBASE))); KASSERT(fake_size < sizeof(fake_preload), ("Too many fake_preload items")); + + if (boothowto & RB_VERBOSE) + printf("FDT phys (%lx-%lx), kernel phys (%lx-%lx)\n", + rvbp->dtbp_phys, rvbp->dtbp_phys + dtb_size, + rvbp->kern_phys, rvbp->kern_phys + (lastaddr - KERNBASE)); return (lastaddr); } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r361903 - head/sys/riscv/riscv
Author: arichardson Date: Mon Jun 8 08:51:52 2020 New Revision: 361903 URL: https://svnweb.freebsd.org/changeset/base/361903 Log: RISC-V: handle DTB aligned to less than 2MB By default OpenSBI and BBL will pass the DTB at a 2MB-aligned address. However, by default there are no 2MB aligned regions between the SBI and the kernel, so we have to choose a 2MB aligned region after the kernel. OpenSBI defaults to placing the DTB 32MB after the start of the kernel but this is not sufficient for a kernel with a large MFS embedded. We could increase this offset to a larger number (e.g. 64/128/256) but that imposes restrictions on the minimum RAM size. Another solution would be to place the DTB between OpenSBI and the kernel at 1MB alignment, but current locore.S code assumes 2MB alignment. With this change I can now boot on QEMU with an OpenSBI configured to store the DTB at an offset of 1MB. See also https://github.com/riscv/opensbi/issues/169 Reviewed By: mhorne Differential Revision: https://reviews.freebsd.org/D25151 Modified: head/sys/riscv/riscv/locore.S Modified: head/sys/riscv/riscv/locore.S == --- head/sys/riscv/riscv/locore.S Mon Jun 8 02:42:41 2020 (r361902) +++ head/sys/riscv/riscv/locore.S Mon Jun 8 08:51:52 2020 (r361903) @@ -139,6 +139,8 @@ _start: lla s1, pagetable_l2_devmap mv s2, a1 srlis2, s2, PAGE_SHIFT + /* Mask off any bits that aren't aligned */ + andis2, s2, ~((1 << (PTE_PPN1_S - PTE_PPN0_S)) - 1) li t0, (PTE_KERN) sllit2, s2, PTE_PPN0_S /* << PTE_PPN0_S */ @@ -214,6 +216,10 @@ va: sd t0, RISCV_BOOTPARAMS_KERN_STACK(sp) li t0, (VM_EARLY_DTB_ADDRESS) + /* Add offset of DTB within superpage */ + li t1, (L2_OFFSET) + and t1, a1, t1 + add t0, t0, t1 sd t0, RISCV_BOOTPARAMS_DTBP_VIRT(sp) mv a0, sp ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r361904 - head/sys/riscv/riscv
Author: arichardson Date: Mon Jun 8 08:51:57 2020 New Revision: 361904 URL: https://svnweb.freebsd.org/changeset/base/361904 Log: sys/riscv: Remove debug printfs They are only visible with EARLY_PRINTF so don't show up by default. Reviewed By: mhorne Differential Revision: https://reviews.freebsd.org/D25152 Modified: head/sys/riscv/riscv/pmap.c Modified: head/sys/riscv/riscv/pmap.c == --- head/sys/riscv/riscv/pmap.c Mon Jun 8 08:51:52 2020(r361903) +++ head/sys/riscv/riscv/pmap.c Mon Jun 8 08:51:57 2020(r361904) @@ -563,8 +563,6 @@ pmap_bootstrap(vm_offset_t l1pt, vm_paddr_t kernstart, int i; printf("pmap_bootstrap %lx %lx %lx\n", l1pt, kernstart, kernlen); - printf("%lx\n", l1pt); - printf("%lx\n", (KERNBASE >> L1_SHIFT) & Ln_ADDR_MASK); /* Set this early so we can use the pagetable walking functions */ kernel_pmap_store.pm_l1 = (pd_entry_t *)l1pt; ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"